Refactored to use RequireJS.