Fix writer

It is possible that the serialized attribute will be nil instead of a hash. If that's the case, then 1.) the hash needs to be initialized and 2.) we must use the setter (=) method to actually write the attribute. It isn't enough to set a variable equal to a hash - that will never get persisted.