Fix for deque that was growing during iteration