Fixed avg aggregation function bug.