Refactor tag string

Merged Ryan's changes with the latest from master.