diff --git a/reformulation-core/src/main/java/org/semanticweb/ontop/owlrefplatform/core/translator/IntermediateQueryToDatalogTranslator.java b/reformulation-core/src/main/java/org/semanticweb/ontop/owlrefplatform/core/translator/IntermediateQueryToDatalogTranslator.java
index <HASH>..<HASH> 100644
--- a/reformulation-core/src/main/java/org/semanticweb/ontop/owlrefplatform/core/translator/IntermediateQueryToDatalogTranslator.java
+++ b/reformulation-core/src/main/java/org/semanticweb/ontop/owlrefplatform/core/translator/IntermediateQueryToDatalogTranslator.java
@@ -112,7 +112,7 @@ public class IntermediateQueryToDatalogTranslator {
 		List<Function> atoms = new LinkedList<Function>();
 		
 		//Constructing the rule
-		CQIE newrule = ofac.getCQIE(substitutedHead, atoms);
+		CQIE newrule = ofac.getCQIE(convertToMutableFunction(substitutedHead), atoms);
 		
 		pr.appendRule(newrule);
 		
@@ -218,7 +218,7 @@ public class IntermediateQueryToDatalogTranslator {
 		
 			QueryNode nod= listnode.get(0);
 			if (nod instanceof ConstructionNode) {
-					Function newAns = ((ConstructionNode) nod).getProjectionAtom();
+					Function newAns = convertToMutableFunction(((ConstructionNode) nod).getProjectionAtom());
 					body.add(newAns);
 					return body;
 				}else{
Makes the heads and the sub-rule atoms mutable after translation back to Datalog.