Fixed stats writing