Reorganize the code to be modular and use requirejs