#define Val_mDOMString(s) (copy_string((char*) (s)))
#define mDOMString_val(v) ((mDOMStringRef) String_val(v))
#define mDOMNode_val(v) ((mDOMNodeRef) v)
-#define Val_mDOMNode_option(p) ((p != NULL) ? ml_some((value) p) : Val_unit)
+
+#define mDOMNode_option_mDOMNodeRef(p) (((p) != NULL) ? ml_some((value) (p)) : Val_unit)
+#define mDOMNodeRef_mDOMNode_option(v) (((v) == Val_unit) ? NULL : Field((v),0))
+#define Val_mDOMNodeRef(p) ((value) mDOMNode_option_mDOMNodeRef(p))
+#define mDOMNodeRef_val(v) ((mDOMNodeRef) mDOMNodeRef_mDOMNode_option(v))