Added requirejs, refactored architecture