Move statistics code from ratio module