Refactor to use require.js.