Polymorph classes supported in serializer.

The serializer now supports cases where the actual object is different from
the object declared, sending once the class name on the stream.