More work on rewrite and unit tests for paideia_stats