added requirejs, refactored to module structure