Fix bug with aggregation.