Implemented heap optimization
Merged