removed one memory leak and tweaked energy(old change)