Fixed heapfy. Initial version of heap uses global data