clean up engine.js code and comments