Fix incorrect types.
Support internal references to defined classes
Raise exceptions rather than errors when serialization errors occurs.