Added serialization of polymorphic types.
Merge pull request #2 from dkorolev/test

Added serialization of polymorphic types.