tweaked queue.py