Refactored nightly stats history recording