Fix bug in enum serialization