Correct serialization of classes.