static compile fix: displayBuffer called fromwithin DisplayCommand
fix static check Runtime Error:
Caught: BUG! exception in phase 'class generation'
On receiver: history.historyList with message: getAt and arguments: id

Not sure what caused this, really
code style closures into methods.
code Style refactorings, mostly allows @CompileStatic and @TypeChecked

This declares types in several places, does some casting too.
Gave unique name to iterators in closures

Could not fix all Type checking and static compile problems,
due to weird hacks around command registry

Not including @CompileStatic and @TypeChecked annotations
because maybe this is to be backported to groovy 1.x, and also
I did not see other code here use them