Refactoring in PQ and Dijkstra