Made rebuildHeap public, so that the queue can be changed