Change some iterators and reduce the duplicate std::map find calls.
DeDuplicate finding a std::map entry.