Refactoring stats and flush method