Fixed average latency calculation. First time in years a braceless if statement actually fools me.