Reorganized the code and added missing JS files