New attempt to generalize stats, after #12606. Since #12355 did not get merged, i want go get first get my change done and the try to fix sum.