Use a deque for a FIFO instead of the python list LIFO.