Refactored - split code into require.js modules