Fix average calculation.