Fix serialization of nested case classes.

Closes #74.