Using std::deque instead of std::list.

See commit discussion 3fccabd8ea5d6 for details.