Refactoring complete with RequireJS.