Revert "Unreverting the revert of statistics with memory leak, fixing the bug"

This reverts commit a109954314c578c30ba8b9b260b7273680306233.