continuing refactor of statistics code