diff --git a/src/cp/CodeGeneration.scala b/src/cp/CodeGeneration.scala
index 72ffcbc9a380ea41a1c52f3dd4f92f0a8608ba7e..fbba285ecf243a2a40ed5f3085abe3d051fd9c82 100644
--- a/src/cp/CodeGeneration.scala
+++ b/src/cp/CodeGeneration.scala
@@ -41,6 +41,9 @@ trait CodeGeneration {
   private lazy val skipCounterFunction            = definitions.getMember(runtimeMethodsModule, "skipCounter")
   private lazy val copySettingsFunction           = definitions.getMember(runtimeMethodsModule, "copySettings")
   private lazy val variableFromLFunction          = definitions.getMember(runtimeMethodsModule, "variableFromL")
+  private lazy val isSetFunction                  = definitions.getMember(runtimeMethodsModule, "isSet")
+  private lazy val toScalaMapFunction             = definitions.getMember(runtimeMethodsModule, "toScalaMap")
+  private lazy val toScalaSetFunction             = definitions.getMember(runtimeMethodsModule, "toScalaSet")
 
   private lazy val converterClass                 = definitions.getClass("cp.Converter")
 
@@ -72,6 +75,10 @@ trait CodeGeneration {
   private lazy val andClass                       = definitions.getClass("purescala.Trees.And")
   private lazy val equalsClass                    = definitions.getClass("purescala.Trees.Equals")
   private lazy val finiteSetClass                 = definitions.getClass("purescala.Trees.FiniteSet")
+  private lazy val finiteSetModule                = definitions.getModule("purescala.Trees.FiniteSet")
+  private lazy val finiteMapClass                 = definitions.getClass("purescala.Trees.FiniteMap")
+  private lazy val finiteMapModule                = definitions.getModule("purescala.Trees.FiniteMap")
+  private lazy val singletonMapClass              = definitions.getClass("purescala.Trees.SingletonMap")
 
   private def termModules(arity : Int)            = definitions.getModule("cp.Terms.Term" + arity)
 
@@ -125,6 +132,8 @@ trait CodeGeneration {
       // the following is for the recursive method
       val intSym        = methodSym.newValue(NoPosition, unit.fresh.newName("value")).setInfo(definitions.IntClass.tpe)
       val booleanSym    = methodSym.newValue(NoPosition, unit.fresh.newName("value")).setInfo(definitions.BooleanClass.tpe)
+      val finiteMapSym  = methodSym.newValue(NoPosition, unit.fresh.newName("map")).setInfo(finiteMapClass.tpe)
+      val finiteSetSym  = methodSym.newValue(NoPosition, unit.fresh.newName("set")).setInfo(finiteSetClass.tpe)
 
       val ccdBinderSym  = methodSym.newValue(NoPosition, unit.fresh.newName("ccd")).setInfo(caseClassDefClass.tpe)
       val argsBinderSym = methodSym.newValue(NoPosition, unit.fresh.newName("args")).setInfo(typeRef(NoPrefix, definitions.SeqClass, List(exprClass.tpe)))
@@ -158,9 +167,21 @@ trait CodeGeneration {
             }))
       }).toList
 
+      def anonymousFunctionFromMethod(methodSymbol: Symbol, argType: Type): Tree = {
+        val anonFunSym = methodSymbol.newValue(NoPosition, nme.ANON_FUN_NAME) setInfo (methodSymbol.tpe)
+        val argValue = anonFunSym.newValue(NoPosition, unit.fresh.newName("x")) setInfo (argType)
+        val anonFun = Function(
+          List(ValDef(argValue, EmptyTree)),
+          methodSym APPLY ID(argValue)
+        ) setSymbol anonFunSym 
+        anonFun
+      }
+
       val matchExpr = (methodSym ARG 0) MATCH ( List(
-        CASE((intLiteralModule) APPLY (intSym BIND WILD()))         ==> ID(intSym) ,
-        CASE((booleanLiteralModule) APPLY (booleanSym BIND WILD())) ==> ID(booleanSym)) :::
+        CASE((intLiteralModule) APPLY (intSym BIND WILD()))         ==> ID(intSym),
+        CASE((booleanLiteralModule) APPLY (booleanSym BIND WILD())) ==> ID(booleanSym),
+        CASE(finiteMapSym BIND ((finiteMapModule) APPLY (WILD())))  ==> (toScalaMapFunction APPLY (ID(finiteMapSym), anonymousFunctionFromMethod(methodSym, exprClass.tpe))),
+        CASE(finiteSetSym BIND ((finiteSetModule) APPLY (WILD())))  ==> (toScalaSetFunction APPLY (ID(finiteSetSym), anonymousFunctionFromMethod(methodSym, exprClass.tpe)))) :::
         caseClassMatchCases :::
         List(DEFAULT                                                ==> THROW(exceptionClass, LIT("Cannot convert FunCheck expression to Scala term"))) : _*
       )
@@ -184,6 +205,7 @@ trait CodeGeneration {
       // TODO how to declare this type Set[_] 
       val setType     = typeRef(NoPrefix, setClass, List(WildcardType))
       val setSym     = methodSym.newValue(NoPosition, unit.fresh.newName("value")).setInfo(setType)
+      val setSymAlt = methodSym.newValue(NoPosition, unit.fresh.newName("set")).setInfo(definitions.AnyClass.tpe)
 
       // anonymous function for mapping set to FiniteSet expression
       // val anonFunSym = methodSym.newValue(NoPosition, nme.ANON_FUN_NAME) setInfo (methodSym.tpe)
@@ -229,7 +251,9 @@ trait CodeGeneration {
 
       val matchExpr = (methodSym ARG 0) MATCH ( List(
         CASE(intSym     BIND Typed(WILD(), TypeTree(definitions.IntClass.tpe)))     ==> NEW(ID(intLiteralClass), ID(intSym)) ,
-        CASE(booleanSym BIND Typed(WILD(), TypeTree(definitions.BooleanClass.tpe))) ==> NEW(ID(booleanLiteralClass), ID(booleanSym))/*,
+        CASE(booleanSym BIND Typed(WILD(), TypeTree(definitions.BooleanClass.tpe))) ==> NEW(ID(booleanLiteralClass), ID(booleanSym))
+        //(CASE(setSymAlt) IF (isSetFunction APPLY (ID(setSymAlt))))                  ==> NEW(ID(finiteSetClass), 
+        /*,
         CASE(setSym     BIND Typed(WILD(), TypeTree(setType)))                      ==> NEW(ID(finiteSetClass), NEW(ID(intLiteralClass), LIT(42)), TypeApply(setSym DOT setToSeqFunction DOT seqMapFunction, List(TypeTree(exprClass.tpe))) APPLY anonFun)*/) :::
         caseClassMatchCases :::
         List(DEFAULT                                                                ==> THROW(exceptionClass, LIT("Cannot convert Scala term to FunCheck expression"))) : _*
diff --git a/src/cp/ConstraintSolving.scala b/src/cp/ConstraintSolving.scala
index 08224728dbf5e57d84e696776976e7443ea8f25f..a767280defae40c1a88567e621d2dbb395eb286f 100644
--- a/src/cp/ConstraintSolving.scala
+++ b/src/cp/ConstraintSolving.scala
@@ -27,7 +27,6 @@ object ConstraintSolving {
     private var isInconsistent: Boolean = false
     private var alreadyAsserted: Set[Expr] = Set.empty[Expr]
     private var toNegateForNextModel: Seq[(Seq[Identifier], Seq[Expr])] = Seq.empty
-    private var active: Boolean = false
 
     def restart(): Unit = {
       // println("restart called")
@@ -43,10 +42,6 @@ object ConstraintSolving {
         solver = newSolver(p)
     }
 
-    def isActive(): Boolean = active
-    def activate(): Unit = { active = true }
-    def deactivate(): Unit = { active = false }
-
     def assertConstraint(expr: Expr): Boolean = {
       if (!alreadyAsserted.contains(expr)) {
         alreadyAsserted = alreadyAsserted + expr
diff --git a/src/cp/LTrees.scala b/src/cp/LTrees.scala
index 028b83247c9d8d5a4d4425dc72a3b31183b3b6c9..ff490bf7fa5e37f065a9b732318a18b7c6d9609a 100644
--- a/src/cp/LTrees.scala
+++ b/src/cp/LTrees.scala
@@ -13,46 +13,37 @@ object LTrees {
     import scala.collection._
     import scala.collection.generic._
 
-    val (consts, exprWithConsts) = combineConstraint(constraint)
-    private var assertQueue: Seq[Expr] = Seq.empty
-    private var shouldCleanup = false
-
-    // assert the associated constraint
     import ConstraintSolving.GlobalContext
     GlobalContext.initializeIfNeeded(constraint.program)
-    if (!GlobalContext.isActive()) {
-      GlobalContext.activate()
-      shouldCleanup = true
-    }
-    GlobalContext.assertConstraint(exprWithConsts)
 
-    def enqueue(expr: Expr): Unit = {
-      assertQueue = expr +: assertQueue
-    }
+    private var liveSet: Set[Expr] = Set.empty
+    private var deadSet: Set[Expr] = Set.empty
 
-    def assertEnqueued(): Unit = {
-      if (!assertQueue.isEmpty) {
-        GlobalContext.assertConstraint(And(assertQueue))
-        assertQueue = Seq.empty
-      }
-    }
+    private var liveGuards: Map[Expr,Expr] = Map.empty
+
+    private var previouslyReturned: Seq[Expr] = Seq.empty
 
     def isStillSat(): Boolean = {
-      assertEnqueued()
-      GlobalContext.assertModelNegation()
-      GlobalContext.checkConsistency()
+      val (newConsts, newExpr) = combineConstraint(constraint)
+
+      // do it first for enumeration of one L var:
+      assert(newConsts.size == 1)
+      val newConst = newConsts.head
+      val newGuard = FreshIdentifier("live_" + newConst)
+
+      val toAssert = Implies(Variable(newGuard), newExpr)
+      GlobalContext.assertConstraint(toAssert)
+
+      sys.error("not implemented")
     }
 
     private def lStream(): Stream[L[T]] = {
-      if (isStillSat())
-        Stream.cons(new L[T](this, consts), lStream())
-      else {
-        if (shouldCleanup) {
-          GlobalContext.restart()
-          GlobalContext.deactivate()
-        }
-        Stream.empty
-      }
+      // if (isStillSat())
+      //   Stream.cons(new L[T](this, consts), lStream())
+      // else {
+      //   Stream.empty
+      // }
+      throw new Exception()
     }
 
     def flatMap [B, That] (f: (L[T]) ⇒ GenTraversableOnce[B])(implicit bf: CanBuildFrom[Traversable[L[T]], B, That]): That = {
diff --git a/src/cp/RuntimeMethods.scala b/src/cp/RuntimeMethods.scala
index 784bfa6a953ed186b93780fa4f7806249283812f..fb837bb34fd4418f8043030327daf3b91805a915 100644
--- a/src/cp/RuntimeMethods.scala
+++ b/src/cp/RuntimeMethods.scala
@@ -10,6 +10,7 @@ object RuntimeMethods {
 
   import purescala.Definitions._
   import purescala.Trees._
+  import purescala.TypeTrees._
   import purescala.Common._
   import purescala.{DefaultReporter,QuietReporter}
   import purescala.FairZ3Solver
@@ -120,4 +121,27 @@ object RuntimeMethods {
     assert(ids.size == 1)
     Variable(ids.head)
   }
+
+  def isSet(a: Any): Boolean = a.isInstanceOf[Set[_]]
+  def isMap(a: Any): Boolean = a.isInstanceOf[Map[_,_]]
+  def isFunction(a: Any): Boolean = a.isInstanceOf[Function1[_,_]]
+
+  def toScalaMap(e: Expr, e2s: (Expr) => Any): Map[_,_] = e match {
+    case FiniteMap(ss) => (ss.map{
+      case SingletonMap(k, v) => (e2s(k), e2s(v))
+    }).toMap
+    case _ => sys.error("Trying to convert " + e + " to a Scala map")
+  }
+
+  def toScalaSet(e: Expr, e2s: (Expr) => Any): Set[_] = e match {
+    case FiniteSet(es) => es.map(e => e2s(e)).toSet
+    case _ => sys.error("Trying to convert " + e + " to a Scala set")
+  }
+
+  def toScalaFunction(e: Expr, e2s: (Expr) => Any): Any = (e, e.getType) match {
+    case (AnonymousFunction(es, ev), FunctionType(fts, tt)) => {
+      throw new Exception("TODO")
+    }
+    case _ => sys.error("Trying to convert " + e + " to a Scala set")
+  }
 }
diff --git a/src/cp/Terms.scala b/src/cp/Terms.scala
index c2b81de2390ec71ad08eeb47cdef352d9eed9d1a..fc1d0da2a957c1660463f7e04a538bcba80c13c2 100644
--- a/src/cp/Terms.scala
+++ b/src/cp/Terms.scala
@@ -126,22 +126,15 @@ object Terms {
     lazy val evaluator : (Seq[Expr]) => R = (s : Seq[Expr]) => scalaFunction(converter.expr2scala(s(0)).asInstanceOf[T1])
   
     override def apply(x_0 : T1) : R = scalaFunction(x_0)
-
-    def customize(generator : Iterator[T1])(implicit asBooleanFunction : (T1 => R) => (T1 => Boolean)) : Term1[T1,Boolean] = {
-      new Term[T1,Boolean](program, expr, types, converter) with Term1[T1,Boolean] {
-        val scalaFunction : (T1) => Boolean = Term1.this.scalaFunction
-        override def findAll(implicit asConstraint: (Term[T1,Boolean]) => Term[T1,Boolean]) : Iterator[T1] = generator.filter(scalaFunction(_))
-      }
-    }
   
     def ||(other : Term1[T1,Boolean])(implicit asBoolean : (R) => Boolean) : Term1[T1,Boolean] = 
-      Term1(this.program, Or(this.expr, other.expr), (x_0 : T1) => this.scalaFunction(x_0) || other.scalaFunction(x_0), this.types, this.converter)
+      Term1(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1) => this.scalaFunction(x_0) || other.scalaFunction(x_0), this.types, this.converter)
   
     def &&(other : Term1[T1,Boolean])(implicit asBoolean : (R) => Boolean) : Term1[T1,Boolean] = 
-      Term1(this.program, And(this.expr, other.expr), (x_0 : T1) => this.scalaFunction(x_0) && other.scalaFunction(x_0), this.types, this.converter)
+      Term1(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1) => this.scalaFunction(x_0) && other.scalaFunction(x_0), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term1[T1,Boolean] = 
-      Term1(this.program, Not(this.expr), (x_0 : T1) => ! this.scalaFunction(x_0), this.types, this.converter)
+      Term1(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1) => ! this.scalaFunction(x_0), this.types, this.converter)
   
     def minimizing(minFunc : Term1[T1,Int])(implicit asConstraint : t2c) : MinConstraint1[T1] = {
       MinConstraint1[T1](asConstraint(this), minFunc)
@@ -149,47 +142,47 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term1[A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 1)
-      Term1(this.program, newExpr, (x_0 : A1) => this.scalaFunction(other.scalaFunction(x_0)), newTypes, this.converter)
+      Term1(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1) => this.scalaFunction(other.scalaFunction(x_0)), newTypes, this.converter)
     }
     
     def compose0[A1, A2](other : Term2[A1, A2, T1]) : Term2[A1, A2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 2, 1)
-      Term2(this.program, newExpr, (x_0 : A1, x_1 : A2) => this.scalaFunction(other.scalaFunction(x_0, x_1)), newTypes, this.converter)
+      Term2(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2) => this.scalaFunction(other.scalaFunction(x_0, x_1)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3](other : Term3[A1, A2, A3, T1]) : Term3[A1, A2, A3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 3, 1)
-      Term3(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2)), newTypes, this.converter)
+      Term3(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T1]) : Term4[A1, A2, A3, A4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 4, 1)
-      Term4(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3)), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T1]) : Term5[A1, A2, A3, A4, A5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 5, 1)
-      Term5(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4)), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T1]) : Term6[A1, A2, A3, A4, A5, A6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 6, 1)
-      Term6(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5)), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6, A7](other : Term7[A1, A2, A3, A4, A5, A6, A7, T1]) : Term7[A1, A2, A3, A4, A5, A6, A7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 7, 1)
-      Term7(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6)), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6, A7, A8](other : Term8[A1, A2, A3, A4, A5, A6, A7, A8, T1]) : Term8[A1, A2, A3, A4, A5, A6, A7, A8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 8, 1)
-      Term8(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : A8) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7)), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : A8) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6, A7, A8, A9](other : Term9[A1, A2, A3, A4, A5, A6, A7, A8, A9, T1]) : Term9[A1, A2, A3, A4, A5, A6, A7, A8, A9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 9, 1)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : A8, x_8 : A9) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : A8, x_8 : A9) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
     }
   }
   
@@ -202,13 +195,13 @@ object Terms {
     override def apply(x_0 : T1, x_1 : T2) : R = scalaFunction(x_0, x_1)
   
     def ||(other : Term2[T1,T2,Boolean])(implicit asBoolean : (R) => Boolean) : Term2[T1,T2,Boolean] = 
-      Term2(this.program, Or(this.expr, other.expr), (x_0 : T1,x_1 : T2) => this.scalaFunction(x_0,x_1) || other.scalaFunction(x_0,x_1), this.types, this.converter)
+      Term2(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2) => this.scalaFunction(x_0,x_1) || other.scalaFunction(x_0,x_1), this.types, this.converter)
   
     def &&(other : Term2[T1,T2,Boolean])(implicit asBoolean : (R) => Boolean) : Term2[T1,T2,Boolean] = 
-      Term2(this.program, And(this.expr, other.expr), (x_0 : T1,x_1 : T2) => this.scalaFunction(x_0,x_1) && other.scalaFunction(x_0,x_1), this.types, this.converter)
+      Term2(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2) => this.scalaFunction(x_0,x_1) && other.scalaFunction(x_0,x_1), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term2[T1,T2,Boolean] = 
-      Term2(this.program, Not(this.expr), (x_0 : T1,x_1 : T2) => ! this.scalaFunction(x_0,x_1), this.types, this.converter)
+      Term2(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1,x_1 : T2) => ! this.scalaFunction(x_0,x_1), this.types, this.converter)
   
     def minimizing(minFunc : Term2[T1,T2,Int])(implicit asConstraint : t2c) : MinConstraint2[T1,T2] = {
       MinConstraint2[T1,T2](asConstraint(this), minFunc)
@@ -216,82 +209,82 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term2[A1, T2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 2)
-      Term2(this.program, newExpr, (x_0 : A1, x_1 : T2) => this.scalaFunction(other.scalaFunction(x_0), x_1), newTypes, this.converter)
+      Term2(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : T2) => this.scalaFunction(other.scalaFunction(x_0), x_1), newTypes, this.converter)
     }
     
     def compose1[A1](other : Term1[A1, T2]) : Term2[T1, A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 1, 2)
-      Term2(this.program, newExpr, (x_0 : T1, x_1 : A1) => this.scalaFunction(x_0, other.scalaFunction(x_1)), newTypes, this.converter)
+      Term2(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1) => this.scalaFunction(x_0, other.scalaFunction(x_1)), newTypes, this.converter)
     }
     
     def compose0[A1, A2](other : Term2[A1, A2, T1]) : Term3[A1, A2, T2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 2, 2)
-      Term3(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2), newTypes, this.converter)
+      Term3(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2), newTypes, this.converter)
     }
     
     def compose1[A1, A2](other : Term2[A1, A2, T2]) : Term3[T1, A1, A2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 2, 2)
-      Term3(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2)), newTypes, this.converter)
+      Term3(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3](other : Term3[A1, A2, A3, T1]) : Term4[A1, A2, A3, T2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 3, 2)
-      Term4(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3](other : Term3[A1, A2, A3, T2]) : Term4[T1, A1, A2, A3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 3, 2)
-      Term4(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3)), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T1]) : Term5[A1, A2, A3, A4, T2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 4, 2)
-      Term5(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T2]) : Term5[T1, A1, A2, A3, A4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 4, 2)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4)), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T1]) : Term6[A1, A2, A3, A4, A5, T2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 5, 2)
-      Term6(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4), x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4), x_5), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T2]) : Term6[T1, A1, A2, A3, A4, A5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 5, 2)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5)), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T1]) : Term7[A1, A2, A3, A4, A5, A6, T2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 6, 2)
-      Term7(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5), x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5), x_6), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T2]) : Term7[T1, A1, A2, A3, A4, A5, A6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 6, 2)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6)), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6, A7](other : Term7[A1, A2, A3, A4, A5, A6, A7, T1]) : Term8[A1, A2, A3, A4, A5, A6, A7, T2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 7, 2)
-      Term8(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6), x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6), x_7), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5, A6, A7](other : Term7[A1, A2, A3, A4, A5, A6, A7, T2]) : Term8[T1, A1, A2, A3, A4, A5, A6, A7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 7, 2)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : A7) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6, x_7)), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : A7) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6, x_7)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6, A7, A8](other : Term8[A1, A2, A3, A4, A5, A6, A7, A8, T1]) : Term9[A1, A2, A3, A4, A5, A6, A7, A8, T2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 8, 2)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : A8, x_8 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : A8, x_8 : T2) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5, A6, A7, A8](other : Term8[A1, A2, A3, A4, A5, A6, A7, A8, T2]) : Term9[T1, A1, A2, A3, A4, A5, A6, A7, A8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 8, 2)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : A7, x_8 : A8) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : A7, x_8 : A8) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
     }
   }
   
@@ -304,13 +297,13 @@ object Terms {
     override def apply(x_0 : T1, x_1 : T2, x_2 : T3) : R = scalaFunction(x_0, x_1, x_2)
   
     def ||(other : Term3[T1,T2,T3,Boolean])(implicit asBoolean : (R) => Boolean) : Term3[T1,T2,T3,Boolean] = 
-      Term3(this.program, Or(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3) => this.scalaFunction(x_0,x_1,x_2) || other.scalaFunction(x_0,x_1,x_2), this.types, this.converter)
+      Term3(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3) => this.scalaFunction(x_0,x_1,x_2) || other.scalaFunction(x_0,x_1,x_2), this.types, this.converter)
   
     def &&(other : Term3[T1,T2,T3,Boolean])(implicit asBoolean : (R) => Boolean) : Term3[T1,T2,T3,Boolean] = 
-      Term3(this.program, And(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3) => this.scalaFunction(x_0,x_1,x_2) && other.scalaFunction(x_0,x_1,x_2), this.types, this.converter)
+      Term3(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3) => this.scalaFunction(x_0,x_1,x_2) && other.scalaFunction(x_0,x_1,x_2), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term3[T1,T2,T3,Boolean] = 
-      Term3(this.program, Not(this.expr), (x_0 : T1,x_1 : T2,x_2 : T3) => ! this.scalaFunction(x_0,x_1,x_2), this.types, this.converter)
+      Term3(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3) => ! this.scalaFunction(x_0,x_1,x_2), this.types, this.converter)
   
     def minimizing(minFunc : Term3[T1,T2,T3,Int])(implicit asConstraint : t2c) : MinConstraint3[T1,T2,T3] = {
       MinConstraint3[T1,T2,T3](asConstraint(this), minFunc)
@@ -318,107 +311,107 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term3[A1, T2, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 3)
-      Term3(this.program, newExpr, (x_0 : A1, x_1 : T2, x_2 : T3) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2), newTypes, this.converter)
+      Term3(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : T2, x_2 : T3) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2), newTypes, this.converter)
     }
     
     def compose1[A1](other : Term1[A1, T2]) : Term3[T1, A1, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 1, 3)
-      Term3(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2), newTypes, this.converter)
+      Term3(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2), newTypes, this.converter)
     }
     
     def compose2[A1](other : Term1[A1, T3]) : Term3[T1, T2, A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 1, 3)
-      Term3(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2)), newTypes, this.converter)
+      Term3(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2)), newTypes, this.converter)
     }
     
     def compose0[A1, A2](other : Term2[A1, A2, T1]) : Term4[A1, A2, T2, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 2, 3)
-      Term4(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3), newTypes, this.converter)
     }
     
     def compose1[A1, A2](other : Term2[A1, A2, T2]) : Term4[T1, A1, A2, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 2, 3)
-      Term4(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3), newTypes, this.converter)
     }
     
     def compose2[A1, A2](other : Term2[A1, A2, T3]) : Term4[T1, T2, A1, A2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 2, 3)
-      Term4(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3)), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3](other : Term3[A1, A2, A3, T1]) : Term5[A1, A2, A3, T2, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 3, 3)
-      Term5(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3](other : Term3[A1, A2, A3, T2]) : Term5[T1, A1, A2, A3, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 3, 3)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3](other : Term3[A1, A2, A3, T3]) : Term5[T1, T2, A1, A2, A3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 3, 3)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4)), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T1]) : Term6[A1, A2, A3, A4, T2, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 4, 3)
-      Term6(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2, x_5 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2, x_5 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4, x_5), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T2]) : Term6[T1, A1, A2, A3, A4, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 4, 3)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4), x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4), x_5), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T3]) : Term6[T1, T2, A1, A2, A3, A4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 4, 3)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5)), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T1]) : Term7[A1, A2, A3, A4, A5, T2, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 5, 3)
-      Term7(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : T2, x_6 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4), x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : T2, x_6 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4), x_5, x_6), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T2]) : Term7[T1, A1, A2, A3, A4, A5, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 5, 3)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5), x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5), x_6), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T3]) : Term7[T1, T2, A1, A2, A3, A4, A5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 5, 3)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6)), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T1]) : Term8[A1, A2, A3, A4, A5, A6, T2, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 6, 3)
-      Term8(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : T2, x_7 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5), x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : T2, x_7 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5), x_6, x_7), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T2]) : Term8[T1, A1, A2, A3, A4, A5, A6, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 6, 3)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6), x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6), x_7), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T3]) : Term8[T1, T2, A1, A2, A3, A4, A5, A6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 6, 3)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : A6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6, x_7)), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : A6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6, x_7)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6, A7](other : Term7[A1, A2, A3, A4, A5, A6, A7, T1]) : Term9[A1, A2, A3, A4, A5, A6, A7, T2, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 7, 3)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : T2, x_8 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : A7, x_7 : T2, x_8 : T3) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5, A6, A7](other : Term7[A1, A2, A3, A4, A5, A6, A7, T2]) : Term9[T1, A1, A2, A3, A4, A5, A6, A7, T3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 7, 3)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : A7, x_8 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : A7, x_8 : T3) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4, A5, A6, A7](other : Term7[A1, A2, A3, A4, A5, A6, A7, T3]) : Term9[T1, T2, A1, A2, A3, A4, A5, A6, A7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 7, 3)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : A6, x_8 : A7) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : A6, x_8 : A7) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
     }
   }
   
@@ -431,13 +424,13 @@ object Terms {
     override def apply(x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4) : R = scalaFunction(x_0, x_1, x_2, x_3)
   
     def ||(other : Term4[T1,T2,T3,T4,Boolean])(implicit asBoolean : (R) => Boolean) : Term4[T1,T2,T3,T4,Boolean] = 
-      Term4(this.program, Or(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4) => this.scalaFunction(x_0,x_1,x_2,x_3) || other.scalaFunction(x_0,x_1,x_2,x_3), this.types, this.converter)
+      Term4(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4) => this.scalaFunction(x_0,x_1,x_2,x_3) || other.scalaFunction(x_0,x_1,x_2,x_3), this.types, this.converter)
   
     def &&(other : Term4[T1,T2,T3,T4,Boolean])(implicit asBoolean : (R) => Boolean) : Term4[T1,T2,T3,T4,Boolean] = 
-      Term4(this.program, And(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4) => this.scalaFunction(x_0,x_1,x_2,x_3) && other.scalaFunction(x_0,x_1,x_2,x_3), this.types, this.converter)
+      Term4(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4) => this.scalaFunction(x_0,x_1,x_2,x_3) && other.scalaFunction(x_0,x_1,x_2,x_3), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term4[T1,T2,T3,T4,Boolean] = 
-      Term4(this.program, Not(this.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4) => ! this.scalaFunction(x_0,x_1,x_2,x_3), this.types, this.converter)
+      Term4(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4) => ! this.scalaFunction(x_0,x_1,x_2,x_3), this.types, this.converter)
   
     def minimizing(minFunc : Term4[T1,T2,T3,T4,Int])(implicit asConstraint : t2c) : MinConstraint4[T1,T2,T3,T4] = {
       MinConstraint4[T1,T2,T3,T4](asConstraint(this), minFunc)
@@ -445,122 +438,122 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term4[A1, T2, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 4)
-      Term4(this.program, newExpr, (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3), newTypes, this.converter)
     }
     
     def compose1[A1](other : Term1[A1, T2]) : Term4[T1, A1, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 1, 4)
-      Term4(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3), newTypes, this.converter)
     }
     
     def compose2[A1](other : Term1[A1, T3]) : Term4[T1, T2, A1, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 1, 4)
-      Term4(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3), newTypes, this.converter)
     }
     
     def compose3[A1](other : Term1[A1, T4]) : Term4[T1, T2, T3, A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 1, 4)
-      Term4(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3)), newTypes, this.converter)
+      Term4(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3)), newTypes, this.converter)
     }
     
     def compose0[A1, A2](other : Term2[A1, A2, T1]) : Term5[A1, A2, T2, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 2, 4)
-      Term5(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4), newTypes, this.converter)
     }
     
     def compose1[A1, A2](other : Term2[A1, A2, T2]) : Term5[T1, A1, A2, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 2, 4)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4), newTypes, this.converter)
     }
     
     def compose2[A1, A2](other : Term2[A1, A2, T3]) : Term5[T1, T2, A1, A2, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 2, 4)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4), newTypes, this.converter)
     }
     
     def compose3[A1, A2](other : Term2[A1, A2, T4]) : Term5[T1, T2, T3, A1, A2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 2, 4)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4)), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3](other : Term3[A1, A2, A3, T1]) : Term6[A1, A2, A3, T2, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 3, 4)
-      Term6(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3, x_5 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3, x_5 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4, x_5), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3](other : Term3[A1, A2, A3, T2]) : Term6[T1, A1, A2, A3, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 3, 4)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3, x_5 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3, x_5 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4, x_5), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3](other : Term3[A1, A2, A3, T3]) : Term6[T1, T2, A1, A2, A3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 3, 4)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4), x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4), x_5), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3](other : Term3[A1, A2, A3, T4]) : Term6[T1, T2, T3, A1, A2, A3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 3, 4)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5)), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T1]) : Term7[A1, A2, A3, A4, T2, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 4, 4)
-      Term7(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2, x_5 : T3, x_6 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2, x_5 : T3, x_6 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T2]) : Term7[T1, A1, A2, A3, A4, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 4, 4)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : T3, x_6 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4), x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : T3, x_6 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4), x_5, x_6), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T3]) : Term7[T1, T2, A1, A2, A3, A4, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 4, 4)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5), x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5), x_6), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T4]) : Term7[T1, T2, T3, A1, A2, A3, A4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 4, 4)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6)), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T1]) : Term8[A1, A2, A3, A4, A5, T2, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 5, 4)
-      Term8(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : T2, x_6 : T3, x_7 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4), x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : T2, x_6 : T3, x_7 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4), x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T2]) : Term8[T1, A1, A2, A3, A4, A5, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 5, 4)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : T3, x_7 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5), x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : T3, x_7 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5), x_6, x_7), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T3]) : Term8[T1, T2, A1, A2, A3, A4, A5, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 5, 4)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6), x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6), x_7), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T4]) : Term8[T1, T2, T3, A1, A2, A3, A4, A5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 5, 4)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : A5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6, x_7)), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : A5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6, x_7)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T1]) : Term9[A1, A2, A3, A4, A5, A6, T2, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 6, 4)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : T2, x_7 : T3, x_8 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : A6, x_6 : T2, x_7 : T3, x_8 : T4) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T2]) : Term9[T1, A1, A2, A3, A4, A5, A6, T3, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 6, 4)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : T3, x_8 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : A6, x_7 : T3, x_8 : T4) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T3]) : Term9[T1, T2, A1, A2, A3, A4, A5, A6, T4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 6, 4)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : A6, x_8 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : A6, x_8 : T4) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3, A4, A5, A6](other : Term6[A1, A2, A3, A4, A5, A6, T4]) : Term9[T1, T2, T3, A1, A2, A3, A4, A5, A6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 6, 4)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : A5, x_8 : A6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : A5, x_8 : A6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
     }
   }
   
@@ -573,13 +566,13 @@ object Terms {
     override def apply(x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5) : R = scalaFunction(x_0, x_1, x_2, x_3, x_4)
   
     def ||(other : Term5[T1,T2,T3,T4,T5,Boolean])(implicit asBoolean : (R) => Boolean) : Term5[T1,T2,T3,T4,T5,Boolean] = 
-      Term5(this.program, Or(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4), this.types, this.converter)
+      Term5(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4), this.types, this.converter)
   
     def &&(other : Term5[T1,T2,T3,T4,T5,Boolean])(implicit asBoolean : (R) => Boolean) : Term5[T1,T2,T3,T4,T5,Boolean] = 
-      Term5(this.program, And(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4), this.types, this.converter)
+      Term5(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term5[T1,T2,T3,T4,T5,Boolean] = 
-      Term5(this.program, Not(this.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4), this.types, this.converter)
+      Term5(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4), this.types, this.converter)
   
     def minimizing(minFunc : Term5[T1,T2,T3,T4,T5,Int])(implicit asConstraint : t2c) : MinConstraint5[T1,T2,T3,T4,T5] = {
       MinConstraint5[T1,T2,T3,T4,T5](asConstraint(this), minFunc)
@@ -587,127 +580,127 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term5[A1, T2, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 5)
-      Term5(this.program, newExpr, (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4), newTypes, this.converter)
     }
     
     def compose1[A1](other : Term1[A1, T2]) : Term5[T1, A1, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 1, 5)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4), newTypes, this.converter)
     }
     
     def compose2[A1](other : Term1[A1, T3]) : Term5[T1, T2, A1, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 1, 5)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4), newTypes, this.converter)
     }
     
     def compose3[A1](other : Term1[A1, T4]) : Term5[T1, T2, T3, A1, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 1, 5)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4), newTypes, this.converter)
     }
     
     def compose4[A1](other : Term1[A1, T5]) : Term5[T1, T2, T3, T4, A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 1, 5)
-      Term5(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4)), newTypes, this.converter)
+      Term5(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4)), newTypes, this.converter)
     }
     
     def compose0[A1, A2](other : Term2[A1, A2, T1]) : Term6[A1, A2, T2, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 2, 5)
-      Term6(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4, x_5 : T5) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4, x_5 : T5) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4, x_5), newTypes, this.converter)
     }
     
     def compose1[A1, A2](other : Term2[A1, A2, T2]) : Term6[T1, A1, A2, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 2, 5)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4, x_5 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4, x_5 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4, x_5), newTypes, this.converter)
     }
     
     def compose2[A1, A2](other : Term2[A1, A2, T3]) : Term6[T1, T2, A1, A2, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 2, 5)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4, x_5 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4, x_5 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4, x_5), newTypes, this.converter)
     }
     
     def compose3[A1, A2](other : Term2[A1, A2, T4]) : Term6[T1, T2, T3, A1, A2, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 2, 5)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4), x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4), x_5), newTypes, this.converter)
     }
     
     def compose4[A1, A2](other : Term2[A1, A2, T5]) : Term6[T1, T2, T3, T4, A1, A2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 2, 5)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5)), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3](other : Term3[A1, A2, A3, T1]) : Term7[A1, A2, A3, T2, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 3, 5)
-      Term7(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3, x_5 : T4, x_6 : T5) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3, x_5 : T4, x_6 : T5) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3](other : Term3[A1, A2, A3, T2]) : Term7[T1, A1, A2, A3, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 3, 5)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3, x_5 : T4, x_6 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3, x_5 : T4, x_6 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3](other : Term3[A1, A2, A3, T3]) : Term7[T1, T2, A1, A2, A3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 3, 5)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : T4, x_6 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4), x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : T4, x_6 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4), x_5, x_6), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3](other : Term3[A1, A2, A3, T4]) : Term7[T1, T2, T3, A1, A2, A3, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 3, 5)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5), x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5), x_6), newTypes, this.converter)
     }
     
     def compose4[A1, A2, A3](other : Term3[A1, A2, A3, T5]) : Term7[T1, T2, T3, T4, A1, A2, A3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 3, 5)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6)), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T1]) : Term8[A1, A2, A3, A4, T2, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 4, 5)
-      Term8(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2, x_5 : T3, x_6 : T4, x_7 : T5) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2, x_5 : T3, x_6 : T4, x_7 : T5) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T2]) : Term8[T1, A1, A2, A3, A4, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 4, 5)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : T3, x_6 : T4, x_7 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4), x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : T3, x_6 : T4, x_7 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4), x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T3]) : Term8[T1, T2, A1, A2, A3, A4, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 4, 5)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : T4, x_7 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5), x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : T4, x_7 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5), x_6, x_7), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T4]) : Term8[T1, T2, T3, A1, A2, A3, A4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 4, 5)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6), x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6), x_7), newTypes, this.converter)
     }
     
     def compose4[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T5]) : Term8[T1, T2, T3, T4, A1, A2, A3, A4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 4, 5)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : A4) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6, x_7)), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : A4) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6, x_7)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T1]) : Term9[A1, A2, A3, A4, A5, T2, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 5, 5)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : T2, x_6 : T3, x_7 : T4, x_8 : T5) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : A5, x_5 : T2, x_6 : T3, x_7 : T4, x_8 : T5) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3, x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T2]) : Term9[T1, A1, A2, A3, A4, A5, T3, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 5, 5)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : T3, x_7 : T4, x_8 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : A5, x_6 : T3, x_7 : T4, x_8 : T5) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T3]) : Term9[T1, T2, A1, A2, A3, A4, A5, T4, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 5, 5)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : T4, x_8 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : A5, x_7 : T4, x_8 : T5) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T4]) : Term9[T1, T2, T3, A1, A2, A3, A4, A5, T5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 5, 5)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : A5, x_8 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : A5, x_8 : T5) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
     }
     
     def compose4[A1, A2, A3, A4, A5](other : Term5[A1, A2, A3, A4, A5, T5]) : Term9[T1, T2, T3, T4, A1, A2, A3, A4, A5, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 5, 5)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : A4, x_8 : A5) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : A4, x_8 : A5) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6, x_7, x_8)), newTypes, this.converter)
     }
   }
   
@@ -720,13 +713,13 @@ object Terms {
     override def apply(x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6) : R = scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5)
   
     def ||(other : Term6[T1,T2,T3,T4,T5,T6,Boolean])(implicit asBoolean : (R) => Boolean) : Term6[T1,T2,T3,T4,T5,T6,Boolean] = 
-      Term6(this.program, Or(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5), this.types, this.converter)
+      Term6(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5), this.types, this.converter)
   
     def &&(other : Term6[T1,T2,T3,T4,T5,T6,Boolean])(implicit asBoolean : (R) => Boolean) : Term6[T1,T2,T3,T4,T5,T6,Boolean] = 
-      Term6(this.program, And(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5), this.types, this.converter)
+      Term6(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term6[T1,T2,T3,T4,T5,T6,Boolean] = 
-      Term6(this.program, Not(this.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5), this.types, this.converter)
+      Term6(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5), this.types, this.converter)
   
     def minimizing(minFunc : Term6[T1,T2,T3,T4,T5,T6,Int])(implicit asConstraint : t2c) : MinConstraint6[T1,T2,T3,T4,T5,T6] = {
       MinConstraint6[T1,T2,T3,T4,T5,T6](asConstraint(this), minFunc)
@@ -734,122 +727,122 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term6[A1, T2, T3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 6)
-      Term6(this.program, newExpr, (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4, x_5), newTypes, this.converter)
     }
     
     def compose1[A1](other : Term1[A1, T2]) : Term6[T1, A1, T3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 1, 6)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4, x_5), newTypes, this.converter)
     }
     
     def compose2[A1](other : Term1[A1, T3]) : Term6[T1, T2, A1, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 1, 6)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5, x_5 : T6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5, x_5 : T6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4, x_5), newTypes, this.converter)
     }
     
     def compose3[A1](other : Term1[A1, T4]) : Term6[T1, T2, T3, A1, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 1, 6)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5, x_5 : T6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4, x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5, x_5 : T6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4, x_5), newTypes, this.converter)
     }
     
     def compose4[A1](other : Term1[A1, T5]) : Term6[T1, T2, T3, T4, A1, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 1, 6)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : T6) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4), x_5), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : T6) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4), x_5), newTypes, this.converter)
     }
     
     def compose5[A1](other : Term1[A1, T6]) : Term6[T1, T2, T3, T4, T5, A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 1, 6)
-      Term6(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5)), newTypes, this.converter)
+      Term6(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5)), newTypes, this.converter)
     }
     
     def compose0[A1, A2](other : Term2[A1, A2, T1]) : Term7[A1, A2, T2, T3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 2, 6)
-      Term7(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose1[A1, A2](other : Term2[A1, A2, T2]) : Term7[T1, A1, A2, T3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 2, 6)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose2[A1, A2](other : Term2[A1, A2, T3]) : Term7[T1, T2, A1, A2, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 2, 6)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4, x_5 : T5, x_6 : T6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4, x_5 : T5, x_6 : T6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose3[A1, A2](other : Term2[A1, A2, T4]) : Term7[T1, T2, T3, A1, A2, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 2, 6)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : T5, x_6 : T6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4), x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : T5, x_6 : T6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4), x_5, x_6), newTypes, this.converter)
     }
     
     def compose4[A1, A2](other : Term2[A1, A2, T5]) : Term7[T1, T2, T3, T4, A1, A2, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 2, 6)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : T6) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5), x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : T6) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5), x_6), newTypes, this.converter)
     }
     
     def compose5[A1, A2](other : Term2[A1, A2, T6]) : Term7[T1, T2, T3, T4, T5, A1, A2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 2, 6)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6)), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3](other : Term3[A1, A2, A3, T1]) : Term8[A1, A2, A3, T2, T3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 3, 6)
-      Term8(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3, x_5 : T4, x_6 : T5, x_7 : T6) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3, x_5 : T4, x_6 : T5, x_7 : T6) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3](other : Term3[A1, A2, A3, T2]) : Term8[T1, A1, A2, A3, T3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 3, 6)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3, x_5 : T4, x_6 : T5, x_7 : T6) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3, x_5 : T4, x_6 : T5, x_7 : T6) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3](other : Term3[A1, A2, A3, T3]) : Term8[T1, T2, A1, A2, A3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 3, 6)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : T4, x_6 : T5, x_7 : T6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4), x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : T4, x_6 : T5, x_7 : T6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4), x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3](other : Term3[A1, A2, A3, T4]) : Term8[T1, T2, T3, A1, A2, A3, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 3, 6)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : T5, x_7 : T6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5), x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : T5, x_7 : T6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5), x_6, x_7), newTypes, this.converter)
     }
     
     def compose4[A1, A2, A3](other : Term3[A1, A2, A3, T5]) : Term8[T1, T2, T3, T4, A1, A2, A3, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 3, 6)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : T6) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6), x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : T6) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6), x_7), newTypes, this.converter)
     }
     
     def compose5[A1, A2, A3](other : Term3[A1, A2, A3, T6]) : Term8[T1, T2, T3, T4, T5, A1, A2, A3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 3, 6)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : A3) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6, x_7)), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : A3) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6, x_7)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T1]) : Term9[A1, A2, A3, A4, T2, T3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 4, 6)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2, x_5 : T3, x_6 : T4, x_7 : T5, x_8 : T6) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : A4, x_4 : T2, x_5 : T3, x_6 : T4, x_7 : T5, x_8 : T6) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2, x_3), x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T2]) : Term9[T1, A1, A2, A3, A4, T3, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 4, 6)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : T3, x_6 : T4, x_7 : T5, x_8 : T6) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : A4, x_5 : T3, x_6 : T4, x_7 : T5, x_8 : T6) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3, x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T3]) : Term9[T1, T2, A1, A2, A3, A4, T4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 4, 6)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : T4, x_7 : T5, x_8 : T6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : A4, x_6 : T4, x_7 : T5, x_8 : T6) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T4]) : Term9[T1, T2, T3, A1, A2, A3, A4, T5, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 4, 6)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : T5, x_8 : T6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : A4, x_7 : T5, x_8 : T6) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
     }
     
     def compose4[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T5]) : Term9[T1, T2, T3, T4, A1, A2, A3, A4, T6, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 4, 6)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : A4, x_8 : T6) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : A4, x_8 : T6) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6, x_7), x_8), newTypes, this.converter)
     }
     
     def compose5[A1, A2, A3, A4](other : Term4[A1, A2, A3, A4, T6]) : Term9[T1, T2, T3, T4, T5, A1, A2, A3, A4, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 4, 6)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : A3, x_8 : A4) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6, x_7, x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : A3, x_8 : A4) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6, x_7, x_8)), newTypes, this.converter)
     }
   }
   
@@ -862,13 +855,13 @@ object Terms {
     override def apply(x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7) : R = scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6)
   
     def ||(other : Term7[T1,T2,T3,T4,T5,T6,T7,Boolean])(implicit asBoolean : (R) => Boolean) : Term7[T1,T2,T3,T4,T5,T6,T7,Boolean] = 
-      Term7(this.program, Or(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6), this.types, this.converter)
+      Term7(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6), this.types, this.converter)
   
     def &&(other : Term7[T1,T2,T3,T4,T5,T6,T7,Boolean])(implicit asBoolean : (R) => Boolean) : Term7[T1,T2,T3,T4,T5,T6,T7,Boolean] = 
-      Term7(this.program, And(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6), this.types, this.converter)
+      Term7(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term7[T1,T2,T3,T4,T5,T6,T7,Boolean] = 
-      Term7(this.program, Not(this.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6), this.types, this.converter)
+      Term7(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6), this.types, this.converter)
   
     def minimizing(minFunc : Term7[T1,T2,T3,T4,T5,T6,T7,Int])(implicit asConstraint : t2c) : MinConstraint7[T1,T2,T3,T4,T5,T6,T7] = {
       MinConstraint7[T1,T2,T3,T4,T5,T6,T7](asConstraint(this), minFunc)
@@ -876,107 +869,107 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term7[A1, T2, T3, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 7)
-      Term7(this.program, newExpr, (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose1[A1](other : Term1[A1, T2]) : Term7[T1, A1, T3, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 1, 7)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose2[A1](other : Term1[A1, T3]) : Term7[T1, T2, A1, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 1, 7)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose3[A1](other : Term1[A1, T4]) : Term7[T1, T2, T3, A1, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 1, 7)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5, x_5 : T6, x_6 : T7) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4, x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5, x_5 : T6, x_6 : T7) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4, x_5, x_6), newTypes, this.converter)
     }
     
     def compose4[A1](other : Term1[A1, T5]) : Term7[T1, T2, T3, T4, A1, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 1, 7)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : T6, x_6 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4), x_5, x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : T6, x_6 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4), x_5, x_6), newTypes, this.converter)
     }
     
     def compose5[A1](other : Term1[A1, T6]) : Term7[T1, T2, T3, T4, T5, A1, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 1, 7)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5), x_6), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5), x_6), newTypes, this.converter)
     }
     
     def compose6[A1](other : Term1[A1, T7]) : Term7[T1, T2, T3, T4, T5, T6, A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 6, 1, 7)
-      Term7(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6)), newTypes, this.converter)
+      Term7(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6)), newTypes, this.converter)
     }
     
     def compose0[A1, A2](other : Term2[A1, A2, T1]) : Term8[A1, A2, T2, T3, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 2, 7)
-      Term8(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose1[A1, A2](other : Term2[A1, A2, T2]) : Term8[T1, A1, A2, T3, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 2, 7)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose2[A1, A2](other : Term2[A1, A2, T3]) : Term8[T1, T2, A1, A2, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 2, 7)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose3[A1, A2](other : Term2[A1, A2, T4]) : Term8[T1, T2, T3, A1, A2, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 2, 7)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : T5, x_6 : T6, x_7 : T7) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4), x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : T5, x_6 : T6, x_7 : T7) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4), x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose4[A1, A2](other : Term2[A1, A2, T5]) : Term8[T1, T2, T3, T4, A1, A2, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 2, 7)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : T6, x_7 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5), x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : T6, x_7 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5), x_6, x_7), newTypes, this.converter)
     }
     
     def compose5[A1, A2](other : Term2[A1, A2, T6]) : Term8[T1, T2, T3, T4, T5, A1, A2, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 2, 7)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6), x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6), x_7), newTypes, this.converter)
     }
     
     def compose6[A1, A2](other : Term2[A1, A2, T7]) : Term8[T1, T2, T3, T4, T5, T6, A1, A2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 6, 2, 7)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : A2) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6, x_7)), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : A2) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6, x_7)), newTypes, this.converter)
     }
     
     def compose0[A1, A2, A3](other : Term3[A1, A2, A3, T1]) : Term9[A1, A2, A3, T2, T3, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 3, 7)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3, x_5 : T4, x_6 : T5, x_7 : T6, x_8 : T7) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : A3, x_3 : T2, x_4 : T3, x_5 : T4, x_6 : T5, x_7 : T6, x_8 : T7) => this.scalaFunction(other.scalaFunction(x_0, x_1, x_2), x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose1[A1, A2, A3](other : Term3[A1, A2, A3, T2]) : Term9[T1, A1, A2, A3, T3, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 3, 7)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3, x_5 : T4, x_6 : T5, x_7 : T6, x_8 : T7) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : A3, x_4 : T3, x_5 : T4, x_6 : T5, x_7 : T6, x_8 : T7) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2, x_3), x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose2[A1, A2, A3](other : Term3[A1, A2, A3, T3]) : Term9[T1, T2, A1, A2, A3, T4, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 3, 7)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : T4, x_6 : T5, x_7 : T6, x_8 : T7) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : A3, x_5 : T4, x_6 : T5, x_7 : T6, x_8 : T7) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3, x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose3[A1, A2, A3](other : Term3[A1, A2, A3, T4]) : Term9[T1, T2, T3, A1, A2, A3, T5, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 3, 7)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : T5, x_7 : T6, x_8 : T7) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : A3, x_6 : T5, x_7 : T6, x_8 : T7) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose4[A1, A2, A3](other : Term3[A1, A2, A3, T5]) : Term9[T1, T2, T3, T4, A1, A2, A3, T6, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 3, 7)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : T6, x_8 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : A3, x_7 : T6, x_8 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5, x_6), x_7, x_8), newTypes, this.converter)
     }
     
     def compose5[A1, A2, A3](other : Term3[A1, A2, A3, T6]) : Term9[T1, T2, T3, T4, T5, A1, A2, A3, T7, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 3, 7)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : A3, x_8 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6, x_7), x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : A3, x_8 : T7) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6, x_7), x_8), newTypes, this.converter)
     }
     
     def compose6[A1, A2, A3](other : Term3[A1, A2, A3, T7]) : Term9[T1, T2, T3, T4, T5, T6, A1, A2, A3, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 6, 3, 7)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : A2, x_8 : A3) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6, x_7, x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : A2, x_8 : A3) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6, x_7, x_8)), newTypes, this.converter)
     }
   }
   
@@ -989,13 +982,13 @@ object Terms {
     override def apply(x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) : R = scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7)
   
     def ||(other : Term8[T1,T2,T3,T4,T5,T6,T7,T8,Boolean])(implicit asBoolean : (R) => Boolean) : Term8[T1,T2,T3,T4,T5,T6,T7,T8,Boolean] = 
-      Term8(this.program, Or(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7), this.types, this.converter)
+      Term8(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7), this.types, this.converter)
   
     def &&(other : Term8[T1,T2,T3,T4,T5,T6,T7,T8,Boolean])(implicit asBoolean : (R) => Boolean) : Term8[T1,T2,T3,T4,T5,T6,T7,T8,Boolean] = 
-      Term8(this.program, And(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7), this.types, this.converter)
+      Term8(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term8[T1,T2,T3,T4,T5,T6,T7,T8,Boolean] = 
-      Term8(this.program, Not(this.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7), this.types, this.converter)
+      Term8(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7), this.types, this.converter)
   
     def minimizing(minFunc : Term8[T1,T2,T3,T4,T5,T6,T7,T8,Int])(implicit asConstraint : t2c) : MinConstraint8[T1,T2,T3,T4,T5,T6,T7,T8] = {
       MinConstraint8[T1,T2,T3,T4,T5,T6,T7,T8](asConstraint(this), minFunc)
@@ -1003,82 +996,82 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term8[A1, T2, T3, T4, T5, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 8)
-      Term8(this.program, newExpr, (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose1[A1](other : Term1[A1, T2]) : Term8[T1, A1, T3, T4, T5, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 1, 8)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose2[A1](other : Term1[A1, T3]) : Term8[T1, T2, A1, T4, T5, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 1, 8)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose3[A1](other : Term1[A1, T4]) : Term8[T1, T2, T3, A1, T5, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 1, 8)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4, x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4, x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose4[A1](other : Term1[A1, T5]) : Term8[T1, T2, T3, T4, A1, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 1, 8)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4), x_5, x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : T6, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4), x_5, x_6, x_7), newTypes, this.converter)
     }
     
     def compose5[A1](other : Term1[A1, T6]) : Term8[T1, T2, T3, T4, T5, A1, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 1, 8)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5), x_6, x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : T7, x_7 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5), x_6, x_7), newTypes, this.converter)
     }
     
     def compose6[A1](other : Term1[A1, T7]) : Term8[T1, T2, T3, T4, T5, T6, A1, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 6, 1, 8)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6), x_7), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6), x_7), newTypes, this.converter)
     }
     
     def compose7[A1](other : Term1[A1, T8]) : Term8[T1, T2, T3, T4, T5, T6, T7, A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 7, 1, 8)
-      Term8(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, other.scalaFunction(x_7)), newTypes, this.converter)
+      Term8(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, other.scalaFunction(x_7)), newTypes, this.converter)
     }
     
     def compose0[A1, A2](other : Term2[A1, A2, T1]) : Term9[A1, A2, T2, T3, T4, T5, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 2, 8)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : A2, x_2 : T2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(other.scalaFunction(x_0, x_1), x_2, x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose1[A1, A2](other : Term2[A1, A2, T2]) : Term9[T1, A1, A2, T3, T4, T5, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 2, 8)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : A2, x_3 : T3, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, other.scalaFunction(x_1, x_2), x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose2[A1, A2](other : Term2[A1, A2, T3]) : Term9[T1, T2, A1, A2, T4, T5, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 2, 8)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : A2, x_4 : T4, x_5 : T5, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2, x_3), x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose3[A1, A2](other : Term2[A1, A2, T4]) : Term9[T1, T2, T3, A1, A2, T5, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 2, 8)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : T5, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : A2, x_5 : T5, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3, x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose4[A1, A2](other : Term2[A1, A2, T5]) : Term9[T1, T2, T3, T4, A1, A2, T6, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 2, 8)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : A2, x_6 : T6, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4, x_5), x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose5[A1, A2](other : Term2[A1, A2, T6]) : Term9[T1, T2, T3, T4, T5, A1, A2, T7, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 2, 8)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6), x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : A2, x_7 : T7, x_8 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5, x_6), x_7, x_8), newTypes, this.converter)
     }
     
     def compose6[A1, A2](other : Term2[A1, A2, T7]) : Term9[T1, T2, T3, T4, T5, T6, A1, A2, T8, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 6, 2, 8)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : A2, x_8 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6, x_7), x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : A2, x_8 : T8) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6, x_7), x_8), newTypes, this.converter)
     }
     
     def compose7[A1, A2](other : Term2[A1, A2, T8]) : Term9[T1, T2, T3, T4, T5, T6, T7, A1, A2, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 7, 2, 8)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : A1, x_8 : A2) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, other.scalaFunction(x_7, x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : A1, x_8 : A2) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, other.scalaFunction(x_7, x_8)), newTypes, this.converter)
     }
   }
   
@@ -1091,13 +1084,13 @@ object Terms {
     override def apply(x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) : R = scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8)
   
     def ||(other : Term9[T1,T2,T3,T4,T5,T6,T7,T8,T9,Boolean])(implicit asBoolean : (R) => Boolean) : Term9[T1,T2,T3,T4,T5,T6,T7,T8,T9,Boolean] = 
-      Term9(this.program, Or(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8,x_8 : T9) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8), this.types, this.converter)
+      Term9(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8,x_8 : T9) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8) || other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8), this.types, this.converter)
   
     def &&(other : Term9[T1,T2,T3,T4,T5,T6,T7,T8,T9,Boolean])(implicit asBoolean : (R) => Boolean) : Term9[T1,T2,T3,T4,T5,T6,T7,T8,T9,Boolean] = 
-      Term9(this.program, And(this.expr, other.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8,x_8 : T9) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8), this.types, this.converter)
+      Term9(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8,x_8 : T9) => this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8) && other.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8), this.types, this.converter)
   
     def unary_!(implicit asBoolean : (R) => Boolean) : Term9[T1,T2,T3,T4,T5,T6,T7,T8,T9,Boolean] = 
-      Term9(this.program, Not(this.expr), (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8,x_8 : T9) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8), this.types, this.converter)
+      Term9(this.program, Not(this.expr), if (this.scalaFunction == null) null else (x_0 : T1,x_1 : T2,x_2 : T3,x_3 : T4,x_4 : T5,x_5 : T6,x_6 : T7,x_7 : T8,x_8 : T9) => ! this.scalaFunction(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8), this.types, this.converter)
   
     def minimizing(minFunc : Term9[T1,T2,T3,T4,T5,T6,T7,T8,T9,Int])(implicit asConstraint : t2c) : MinConstraint9[T1,T2,T3,T4,T5,T6,T7,T8,T9] = {
       MinConstraint9[T1,T2,T3,T4,T5,T6,T7,T8,T9](asConstraint(this), minFunc)
@@ -1105,47 +1098,47 @@ object Terms {
   
     def compose0[A1](other : Term1[A1, T1]) : Term9[A1, T2, T3, T4, T5, T6, T7, T8, T9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 0, 1, 9)
-      Term9(this.program, newExpr, (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : A1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(other.scalaFunction(x_0), x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose1[A1](other : Term1[A1, T2]) : Term9[T1, A1, T3, T4, T5, T6, T7, T8, T9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 1, 1, 9)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : A1, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, other.scalaFunction(x_1), x_2, x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose2[A1](other : Term1[A1, T3]) : Term9[T1, T2, A1, T4, T5, T6, T7, T8, T9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 2, 1, 9)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : A1, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, other.scalaFunction(x_2), x_3, x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose3[A1](other : Term1[A1, T4]) : Term9[T1, T2, T3, A1, T5, T6, T7, T8, T9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 3, 1, 9)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : A1, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, other.scalaFunction(x_3), x_4, x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose4[A1](other : Term1[A1, T5]) : Term9[T1, T2, T3, T4, A1, T6, T7, T8, T9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 4, 1, 9)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : A1, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, x_3, other.scalaFunction(x_4), x_5, x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose5[A1](other : Term1[A1, T6]) : Term9[T1, T2, T3, T4, T5, A1, T7, T8, T9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 5, 1, 9)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5), x_6, x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : A1, x_6 : T7, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, other.scalaFunction(x_5), x_6, x_7, x_8), newTypes, this.converter)
     }
     
     def compose6[A1](other : Term1[A1, T7]) : Term9[T1, T2, T3, T4, T5, T6, A1, T8, T9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 6, 1, 9)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6), x_7, x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : A1, x_7 : T8, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, other.scalaFunction(x_6), x_7, x_8), newTypes, this.converter)
     }
     
     def compose7[A1](other : Term1[A1, T8]) : Term9[T1, T2, T3, T4, T5, T6, T7, A1, T9, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 7, 1, 9)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : A1, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, other.scalaFunction(x_7), x_8), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : A1, x_8 : T9) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, other.scalaFunction(x_7), x_8), newTypes, this.converter)
     }
     
     def compose8[A1](other : Term1[A1, T9]) : Term9[T1, T2, T3, T4, T5, T6, T7, T8, A1, R] = {
       val (newExpr, newTypes) = Terms.compose(other, this, 8, 1, 9)
-      Term9(this.program, newExpr, (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, other.scalaFunction(x_8)), newTypes, this.converter)
+      Term9(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (x_0 : T1, x_1 : T2, x_2 : T3, x_3 : T4, x_4 : T5, x_5 : T6, x_6 : T7, x_7 : T8, x_8 : A1) => this.scalaFunction(x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, other.scalaFunction(x_8)), newTypes, this.converter)
     }
   }
   
diff --git a/src/cp/Utils.scala b/src/cp/Utils.scala
index 3dad778aec02f031058a37c6f0cdb7f6b27417ec..cf306265cbcfb29f7a2c5cfe5d545ffeed577966 100644
--- a/src/cp/Utils.scala
+++ b/src/cp/Utils.scala
@@ -21,11 +21,11 @@ object Utils {
         val anonFunArgs = (0 until arity).map(i => "x_%d" format (i))
         val anonFunArgsString = anonFunArgs.mkString(",")
         val orMethod = """def ||(other : %s)%s : %s = 
-  Term%d(this.program, Or(this.expr, other.expr), (%s) => this.scalaFunction(%s) || other.scalaFunction(%s), this.types, this.converter)""" format (booleanTraitName, curriedImplicit2Boolean, booleanTraitName, arity, anonFunParamString, anonFunArgsString, anonFunArgsString)
+  Term%d(this.program, Or(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (%s) => this.scalaFunction(%s) || other.scalaFunction(%s), this.types, this.converter)""" format (booleanTraitName, curriedImplicit2Boolean, booleanTraitName, arity, anonFunParamString, anonFunArgsString, anonFunArgsString)
         val andMethod = """def &&(other : %s)%s : %s = 
-  Term%d(this.program, And(this.expr, other.expr), (%s) => this.scalaFunction(%s) && other.scalaFunction(%s), this.types, this.converter)""" format (booleanTraitName, curriedImplicit2Boolean, booleanTraitName, arity, anonFunParamString, anonFunArgsString, anonFunArgsString)
+  Term%d(this.program, And(this.expr, other.expr), if (this.scalaFunction == null || other.scalaFunction == null) null else (%s) => this.scalaFunction(%s) && other.scalaFunction(%s), this.types, this.converter)""" format (booleanTraitName, curriedImplicit2Boolean, booleanTraitName, arity, anonFunParamString, anonFunArgsString, anonFunArgsString)
         val notMethod = """def unary_!%s : %s = 
-  Term%d(this.program, Not(this.expr), (%s) => ! this.scalaFunction(%s), this.types, this.converter)""" format (curriedImplicit2Boolean, booleanTraitName, arity, anonFunParamString, anonFunArgsString)
+  Term%d(this.program, Not(this.expr), if (this.scalaFunction == null) null else (%s) => ! this.scalaFunction(%s), this.types, this.converter)""" format (curriedImplicit2Boolean, booleanTraitName, arity, anonFunParamString, anonFunArgsString)
         
         val intTraitName = "Term%d%s" format (arity, (traitArgParams ++ Seq("Int")).mkString("[", ",", "]"))
         val minimizingMethod = 
@@ -50,7 +50,7 @@ object Utils {
             val s2 =
 """def compose%d[%s](other : Term%d[%s]) : Term%d[%s] = {
   val (newExpr, newTypes) = Terms.compose(other, this, %d, %d, %d)
-  Term%d(this.program, newExpr, (%s) => this.scalaFunction(%s), newTypes, this.converter)
+  Term%d(this.program, newExpr, if (this.scalaFunction == null || other.scalaFunction == null) null else (%s) => this.scalaFunction(%s), newTypes, this.converter)
 }""" format (index, fParams.mkString(", "), arityF, fTermParams.mkString(", "), resultTermArity, resultTermParams.mkString(", "), index, arityF, arity, resultTermArity, scalaFunctionParams.mkString(", "), thisFunctionParams.mkString(", "))
 
             s2