aggregation bug fix (level 0)
lots of code cleaning + debug