Fixed a bug with and refactored the referenced map loading code.