Fixes for sum_by and a few other changes