optimized saving of stats to save memory