Maxheap changed to behave more functional