Reorganization of the code using AMD pattern enabled by require.js.