some small fixes to get rid of nan
reinserting lost energy