Implemented require.js, optimized a few things