Fixed Bug in Total Energy Calculations