Serialization for custom classes

Here's my code for getting custom data types to work.