Fix race condition by using a std::map iterator instead of [ ] notation,
which is not read-only.