Stats cleanup

These commits were in #2832, I moved them here so we can merge them separately, because I need them.