fixes to energy minimization