fix serialization of subdocuments