removed some legacy code. Fixed energy calculation bug.