Fix a few edge cases in nodetags.py