Refactored map related code to map.coffee.
Refactored some init code.