Fixes for average calculation.