fix data aggregation bugs
simplify