Refactored to use Require.js
Still ugly, but its uglyness is split across several files