Added macros for multiple heaps, started to adapt code