Serialization/unserialization fixes