Use more groovy
Refactor templfile clean up