Added all required functionality and switched to require.js