Fix bug in tag serialization