More RequireJS fixes. Moved more values from global state. Code cleanups.