Added serialization of polymorphic types.