Fix a fatal bug in tag setting