switched from queue.queue to collections.deque, about 10x faster