intermediate refactoring of Heap and PriorityQueue