Revert "Started overhauling of heap management."...
  -Reverting because too much time has passed and i do
   not remember what i was doing.

This reverts commit 11476ba67756cba7fe34de94759091cfa00c38d8.
Refactor methods in several files.