This required adding a global stats object. It also contains a bit of refactor to make a type out of the derived counters.