Implemented priority queue.