diff --git a/core/codegen-runtime/src/main/java/org/overture/codegen/runtime/Utils.java b/core/codegen-runtime/src/main/java/org/overture/codegen/runtime/Utils.java
index <HASH>..<HASH> 100644
--- a/core/codegen-runtime/src/main/java/org/overture/codegen/runtime/Utils.java
+++ b/core/codegen-runtime/src/main/java/org/overture/codegen/runtime/Utils.java
@@ -59,4 +59,10 @@ public class Utils
 
 		return "mk_" + record.getClass().getSimpleName() + "(" + str + ")";
 	}
+	
+	@SuppressWarnings("unchecked")
+	public static <T extends ValueType> T clone(T t)
+	{
+		return (T) (t != null ? t.clone() : t);
+	}
 }
Now cloning of code generated value types is done using a utility function to guards against values being "null" which is possible for optionally typed values