stats_utils: major cleanup