Adding common serialization to the base class.