better class serialization