Refactor map.js a bit
Merge branch 'master' into kris