Refactors stats code to be more in line with facets
Adds reference support for stats facets