Beefed up the pqueue implementation.