Major refactorings of javascript for public map