Cleanup + refactored grouping