Serialization for classes that want to serialize