Metastability and anomalous behavior in the HMF model: connections to nonextensive thermodynamics and glassy dynamics