Average population calculation now only writes at end of run