small refactor of maps code to make it more modular.