Refactored map, added some new stuff and rewritten a lot of code.