Replace Queue with deque, where possible

Deques are also threadsafe, but a bit more efficient