Applying performance optimization also to the priority queue