Fixed averaging bug.