Fix a potential bug during serialization