Fix aggregate functions