Use range-based for.

With a few concomitant simplifications and formatting tweaks.

I usually used "entry" when the thing being iterated over was a map.

Probably some (perhaps most) of these "auto"s should instead use the
actual type for clarity (now that it is not an iterator).