diff --git a/src/js/datatypeCleanupJS.js b/src/js/datatypeCleanupJS.js
index 6b94163cef47fa1c3d96625ead990ab9396136d8..1343eb0c3d7ed8460018284f10b0a1f6b28451b1 100644
--- a/src/js/datatypeCleanupJS.js
+++ b/src/js/datatypeCleanupJS.js
@@ -2020,7 +2020,7 @@ App.Entity.Utils.RARuleDatatypeCleanup = function() {
 	function replaceDefaultValues(o) {
 		for (const k in o) {
 			const v = o[k];
-			if (v === "no default setting" || v === "no default change" || v === undefined) {
+			if (v === "no default setting" || v === "no default change" || Number.isNaN(v) || v === undefined) {
 				o[k] = null;
 			} else if (typeof v === 'object') {
 				replaceDefaultValues(v);
@@ -2078,9 +2078,14 @@ App.Entity.Utils.RARuleDatatypeCleanup = function() {
 		function ensureNumTarget(val) {
 			switch (typeof val) {
 				case 'number':
-					return App.RA.makeTarget('==', val);
+					return Number.isNaN(val) ? null : App.RA.makeTarget('==', val);
 				case 'string':
 						return App.RA.makeTarget('==', parseInt(val));
+				case 'object':
+					if (val.hasOwnProperty('val') && Number.isNaN(val.val)) {
+						return null;
+					}
+					return val;
 				default:
 					return val;
 			}