Finish up PriorityQueue

Important parts:
- fix all thread-safety issues
- fix heap integrity issue (description: if an item was removed, then we always heapify the root slot, but if the item was from another position then it's a mistake. Since we replace a deleted item with the last slot then we have to heapify a deleted position to move heap to consistent state).