Replaced PriorityQueue with heapq