Necessary additions for toObject and fromObject for #729.