kheap: Comment and refactor the heap code