Heap Management

heap management and memory reclaiming, along with design fixes