change generated code layout and remove unneeded engine hooks
add a bit more logging control to engine
clean code to match jslint