First working (but very hacky) RequireJS implementation.