some improvements in grouping