Major rebase of code from Java to Groovy.