Refactoring: changed Flames algorithm to use Groovy collections