Fix dequeue to set new array elements correctly.