Implementation of tag hierarchy
Fix some inconsistencies with tests.