Lots of refactoring - now using require.js