Refactored map, added docs and did some tests