map refactor: keep all map code in single file