Moved the updateMappingOnMaster logic into a single place.

Closes #5798