more fixes for aggregates (still not 100% correct)