Refactored some groovy files to Java