-refactored a bunch of stuff for maps