Refactoring corpus stats collection.