Fixed modifying dictionary during iteration bug.