Restructured and commented map.js