Refactoring

I'm not finished yet, but started refactoring the JavaScript code to be cleaner and more functional. The initial refactoring should theoretically make the map load faster.