Rewrite pieces of groupby that depended on block items