Fixed support for nullables

Nullables were being serialized as objects (i.e. with HasValue and
Value properties), and therefore could not be deserialized.