Grouping and filtering refactoring.