Refactor of map generator used in Mangle.rekey to make it clearer how it is used