Add tag_counts and tag_stats generation

Still needs testing before merging into master, should end up in 2.0 release.