Correct work with heap.