Ported the optimization of the IntervalWriter to the general StatisticsWriter.