Tidied up mapAPI.js a bit