Improvements to tag handling, including sorting and grouping.