Aggregation function bugfix.