Stat computation is refactored.