improvements to groupby