Cleaned up code so that a shared method is used to get most common value
in a map.