Refactor keydef reader in map generation into a separate method