Dequeue implementation.