Fixed the AMD boilerplate so that it works with the RequireJS optimizer.
Revert previous change.
Formatting fixes and minor conditional simplification.