Adding blocking queue and refactor of priority queue