More refactoring of map js