Use Map.entrySet where possible

Improves run-time efficiency and addresses FindBugs warnings.