Refactored code, split things up into different files, added amd with require.js