diff --git a/Solver/function.cpp b/Solver/function.cpp
index c135be15a815f291234402d5cb276da703cac1e5..daf95950717933280dcd62dba21f79eaddf309f9 100644
--- a/Solver/function.cpp
+++ b/Solver/function.cpp
@@ -78,7 +78,7 @@ dataCacheDouble &dataCacheMap::get(const function *f, dataCacheDouble *caller)
     }
   }
   if (r==NULL)
-    r = new dataCacheDouble(this, const_cast<function*>(f));
+    r = new dataCacheDouble(this, (function*)(f));
   if (caller)
     r->addMeAsDependencyOf(caller);
   return *r;
@@ -87,7 +87,7 @@ dataCacheDouble &dataCacheMap::get(const function *f, dataCacheDouble *caller)
 dataCacheDouble &dataCacheMap::substitute(const function *f) 
 {
   dataCacheDouble *&r= _cacheDoubleMap[f];
-  r = new dataCacheDouble(this, const_cast<function*>(f));
+  r = new dataCacheDouble(this, (function*)(f));
   return *r;
 }
 
diff --git a/Solver/function.h b/Solver/function.h
index 193eddeee47097e6a022a99a7128c45b3e5f774d..d099676280b563af99c627501336baf23b4598d7 100644
--- a/Solver/function.h
+++ b/Solver/function.h
@@ -52,6 +52,8 @@ class function {
   virtual void call (dataCacheMap *m, fullMatrix<double> &res)=0;
   std::vector<argument*> arguments;
   const fullMatrix<double> &addArgument(const function *f, int iMap = 0) {
+    if(f==NULL)
+      throw;
     arguments.push_back(new argument(iMap, f));
     return arguments.back()->val;
   }
@@ -173,6 +175,9 @@ class dataCacheMap {
   }
   void addSecondaryCache(dataCacheMap *s) {
     _secondaryCaches.push_back(s);
+    if(_secondaryCaches.size()>1){
+      printf("!!!!!!!!!!!!!!!!!!!!!\n");
+    }
   }
   dataCacheDouble &get(const function *f, dataCacheDouble *caller=0);
   dataCacheDouble &substitute(const function *f);