Add writing of aggregate stats.