Quantification and minimization of energy loss mechanisms in microelectromechanical resonators