Fixed an issue where maps weren't being exported using the correct file extension.

Also, some code cleanup.