Index: kernel/gfan.cc
===================================================================
--- kernel/gfan.cc	(revision cef1fb8a6b684adbc201e50f3ee51a42e97ee1f6)
+++ kernel/gfan.cc	(revision f07b38c1ed274ea04d13d9833c405827e38e5c3d)
@@ -64,5 +64,5 @@
 
 #ifndef gfan_DEBUG
-//#define gfan_DEBUG
+// #define gfan_DEBUG 1
 #ifndef gfan_DEBUGLEVEL
 #define gfan_DEBUGLEVEL 1
@@ -377,5 +377,6 @@
 // 	if (this->rootRing!=NULL && this->rootRing!=(ip_sring *)0xfefefefefefefefe)
 // 		rDelete(this->rootRing);
-	//rDelete(this->baseRing);
+// 	if(this->UCN!=1)
+// 		rDelete(this->baseRing);
 	facet *fAct;
 	facet *fDel;
@@ -389,4 +390,6 @@
 		delete fDel;
 	}
+	this->counter--;
+	dd_FreeMatrix(this->ddFacets);
 	//dd_FreeMatrix(this->ddFacets);
 }			
@@ -447,5 +450,5 @@
 		
 /** For debugging purposes only */
-void gcone::showSLA(facet &f)
+volatile void gcone::showSLA(facet &f)
 {
 	facet *fAct;
@@ -952,10 +955,10 @@
 	fNormal = f->getFacetNormal();	//read this->fNormal;
 
-	std::cout << "running gcone::flip" << std::endl;
-	std::cout << "flipping UCN " << this->getUCN() << endl;
-	cout << "over facet (";
-	fNormal->show(1,0);
-	cout << ") with UCN " << f->getUCN();
-	std::cout << std::endl;
+// 	std::cout << "running gcone::flip" << std::endl;
+// 	std::cout << "flipping UCN " << this->getUCN() << endl;
+// 	cout << "over facet (";
+// 	fNormal->show(1,0);
+// 	cout << ") with UCN " << f->getUCN();
+// 	std::cout << std::endl;
 
 	/*1st step: Compute the initial ideal*/
@@ -1216,5 +1219,5 @@
 	f->flipRing=rCopy(dstRing);	//store the ring on the other side
 //#ifdef gfan_DEBUG
-	cout << "Flipped GB is UCN " << counter+1 << ":" << endl;
+// 	cout << "Flipped GB is UCN " << counter+1 << ":" << endl;
 //  	this->idDebugPrint(dstRing_I);
 // 	cout << endl;
@@ -1723,11 +1726,18 @@
 			gcTmp->showFacets(1);
 #endif
+			/*add facets to SLA here*/
+			SearchListRoot=gcTmp->enqueueNewFacets(*SearchListRoot);
+			
  			if(gfanHeuristic==1)
  			{
 				gcTmp->writeConeToFile(*gcTmp);
+// 				idDelete((ideal*)&gcTmp->gcBasis);
+				for(int ii=0;ii<IDELEMS(gcTmp->gcBasis);ii++)
+				{
+					gcTmp->gcBasis->m[ii]=(poly)NULL;
+				}
  			}
-			/*add facets to SLA here*/
-			SearchListRoot=gcTmp->enqueueNewFacets(*SearchListRoot);
-#ifdef gfan_DEBUG
+			
+#if gfan_DEBUG
 			if(SearchListRoot!=NULL)
 				gcTmp->showSLA(*SearchListRoot);
@@ -1766,5 +1776,5 @@
 				{
  					deleteMarker = gcHead;
- 					gcHead = gcNext->next;
+//  					gcHead = gcNext->next;
 					//gcNext->next->prev = NULL;
 				}
@@ -1772,6 +1782,6 @@
 				{
 					deleteMarker = gcNext;
-					gcNext->prev->next = gcNext->next;
-					gcNext->next->prev = gcNext->prev;
+// 					gcNext->prev->next = gcNext->next;
+// 					gcNext->next->prev = gcNext->prev;
 				}
 // 				gcNext = gcNext->next;
@@ -1794,5 +1804,5 @@
 					gcAct = gcNext;
 					//implant the GB into gcAct
-					readConeFromFile(gcNext->getUCN(), gcAct);
+					readConeFromFile(gcAct->getUCN(), gcAct);
 					rAct=rCopy(gcAct->baseRing);
 					rComplete(rAct);
@@ -2453,5 +2463,8 @@
 				while(!line.empty())
 				{
+// 					resPoly=pInit();
+// 					strPoly=pInit();
 					hasNegCoeff = FALSE;
+					hasCoeffInQ = FALSE;
 					found = line.find_first_of("+-");	//get the first monomial
 					string tmp;
@@ -2473,5 +2486,5 @@
 						hasCoeffInQ = TRUE;
 						strCoeffNom=strMonom.substr(0,found);						
-						strCoeffDenom=strMonom.substr(found+1,strMonom.find_first_not_of("1234567890"));
+						strCoeffDenom=strMonom.substr(found+1,strMonom.find_first_not_of("1234567890",found+1));
 						strMonom.erase(0,found);
 						strMonom.erase(0,strMonom.find_first_not_of("1234567890/"));			
@@ -2541,5 +2554,5 @@
 				}//while(!line.empty())		
 			
-				gcBasis->m[jj]=pCopy(resPoly);
+				gc->gcBasis->m[jj]=pCopy(resPoly);
 				resPoly=NULL;	//reset
 			}
@@ -2586,6 +2599,12 @@
 		l->m[0].data=(void*)gcAct->getUCN();
 		l->m[1].rtyp=IDEAL_CMD;
+		/*The following is necessary for leaves in the tree of cones
+		* Since we don't use them in the computation and gcBasis is 
+		* set to (poly)NULL in noRevS we need to get this back here.
+		*/
+		if(gcAct->gcBasis->m[0]==(poly)NULL)
+			gcAct->readConeFromFile(gcAct->getUCN(),gcAct);
 		l->m[1].data=(void*)idrCopyR_NoSort(gcAct->gcBasis,gcAct->getBaseRing());
-		
+
 		l->m[2].rtyp=INTVEC_CMD;
 		intvec iv=(gcAct->f2M(gcAct,gcAct->facetPtr));
@@ -2717,5 +2736,14 @@
 		res = inputIdeal; 
 		lResList=lprepareResult(gcRoot,gcRoot->getCounter());
-// 		res=lResList;
+		/*Cleanup*/
+		gcone *gcDel;	
+		gcDel = gcRoot;
+		gcAct = gcRoot;
+		do
+		{
+			gcDel = gcAct;
+			gcAct = gcAct->next;
+			delete gcDel;
+		}while(gcAct!=NULL);
 	}
 	dd_free_global_constants();
@@ -2730,4 +2758,5 @@
 	}
 	
+	/*Return result*/
 	return lResList;
 }
Index: kernel/gfan.h
===================================================================
--- kernel/gfan.h	(revision cef1fb8a6b684adbc201e50f3ee51a42e97ee1f6)
+++ kernel/gfan.h	(revision f07b38c1ed274ea04d13d9833c405827e38e5c3d)
@@ -165,5 +165,5 @@
 		int getPredUCN();		
 		void showFacets(short codim=1);
-		void showSLA(facet &f);
+		volatile void showSLA(facet &f);
 		void idDebugPrint(ideal const &I);
 		void invPrint(ideal const &I);
