Index: Singular/LIB/resjung.lib
===================================================================
--- Singular/LIB/resjung.lib	(revision 3b614ecf39de68c3a807a600dd27a5329966b5cd)
+++ Singular/LIB/resjung.lib	(revision f4031a1a86ed2a5d4cac3880a048f2b79333421b)
@@ -44,22 +44,21 @@
   int n = nvars(A);
   list l = equidim(id);
+  int i,j;
   int k = size(l);
   ideal LastTwo = var(n-1),var(n);
   ideal lowdim = 1;   //the components of id with dimension smaller 2
   if(k>1){
-    for(int j=1;j<k;j++){
+    for(j=1;j<k;j++){
       lowdim = intersect(lowdim,l[j]);
     }
-    kill j;
   } 
-  kill k;
   //lowdim = radical(lowdim);  // affects performance
   ideal I = l[size(l)];  
   poly product=1;
   kill l;  
-  for(int i=1; i < n-1; i++){ 
+  for(i=1; i < n-1; i++){ 
   //elimination of all variables exept var(i),var(n-1),var(n)
     intvec v;
-    for(int j=1; j < n-1; j++){
+    for(j=1; j < n-1; j++){
       if(j<>i){
         v[j]=1;
@@ -71,4 +70,5 @@
     v[size(v)+1]=0;
     v[size(v)+1]=0;
+    if(defined(ringl)) {kill ringl;}
     list ringl = ringlist(A);
     list l;
@@ -90,8 +90,9 @@
     if(attrib(J,"isPrincipal")==0){
       setring R;
-      for(int j = 1;j<=size(J);j++){   //determines the monic polynomial in var(i) with coefficents in C2
+      for(j = 1;j<=size(J);j++){   //determines the monic polynomial in var(i) with coefficents in C2
+        if(defined(w)) {kill w;}
         intvec w = leadexp(J[j]);
         attrib(w,"isMonic",1);
-        for(int k = 1;k<=size(w);k++){
+        for(k = 1;k<=size(w);k++){
           if(w[k] <> 0 && k <> i){
             attrib(w,"isMonic",0);
@@ -99,5 +100,4 @@
           }
         }
-        kill k;
         if(attrib(w,"isMonic")==1){
           index = j;
@@ -106,5 +106,4 @@
         kill w;
       }
-      kill j;
       setring A;
     }
@@ -138,7 +137,9 @@
 proc buildFP(list embR,ideal NoetherN, map phi){
   def A = basering;
+  int i,j,k;
   list fibreP;
   int n = nvars(A);
-  for(int i=1;i<=size(embR);i++){
+  for(i=1;i<=size(embR);i++){
+    if(defined(R)) {kill R;}
     def R = embR[i];
     setring R;
@@ -146,5 +147,5 @@
 // create data for the new ring 
 // e.g. if A=K[x_1,..,x_n] and R=K[y_1,..,y_m], K[x_1,..,x_n-2,y_1,..,y_m]
-    for(int j = 1; j<= nvars(R);j++){
+    for(j = 1; j<= nvars(R);j++){
        string st = string(var(j));
        temp[2][n-2+j] = st;
@@ -159,11 +160,11 @@
     setring R2;
     ideal Temp=0;           //defines map from R to R2 which is the inclusion
-    for(int k=n-1;k<n-1+nvars(R);k++){
+    for(k=n-1;k<n-1+nvars(R);k++){
       Temp = Temp + ideal(var(k));
     }
     map f = R,Temp;
-    kill Temp,k;
+    kill Temp;
     ideal FibPMI = ideal(0);       //defines the map from A to R2
-    for(int k=1;k<=nvars(A)-m;k++){
+    for(k=1;k<=nvars(A)-m;k++){
       FibPMI=FibPMI+var(k);
     }
@@ -179,5 +180,5 @@
     fibreP[i] = R2;
     setring R;
-    kill J,R,R2,k,j,m;
+    kill J,R,R2,m;
   }
   return(fibreP);
@@ -219,4 +220,5 @@
     for(int i = 1;i<=size(result);i++){        
 // had zero dimensional components which are now added to the end result
+      if(defined(R)) {kill R;}
       def R = result[i];
       setring R; 
@@ -245,4 +247,5 @@
 // to our situation 
   def H = basering;
+  int i,j,k;
   setring H;  attrib(BO[2],"smoothC",0);
   export(BO);
@@ -255,5 +258,5 @@
     int count2 = 0;         // counts the number of smooth charts
     int p = size(result);
-    for(int j = 1;j<=p;j++){
+    for(j = 1;j<=p;j++){
       if(attrib(result[j],"isResolved")==0){
         if(defined(R)){kill R;}
@@ -264,5 +267,5 @@
           list primdecPC = primdecGTZ(BO[2]);
           attrib(result[j],"smoothC",1);
-          for(int i = 1;i<=size(primdecPC);i++){
+          for(i = 1;i<=size(primdecPC);i++){
             ideal Sl = groebner(slocus(primdecPC[i][2]));
             if(deg(NF(1,Sl))!=-1){
@@ -280,5 +283,5 @@
 // if we blew up a non rational singularity, the exeptional divisors 
 // are reduzible, so we need to separate them
-                for(int k=1;k<=size(blowup);k++){
+                for(k=1;k<=size(blowup);k++){
                   def R2=blowup[k];
                   setring R2;
@@ -294,21 +297,18 @@
                   kill L,R2;
                 }
-                kill k;
               }
               kill primdecSL;
               list hlp;
-              for(int k = 1;k<j;k++){
+              for(k = 1;k<j;k++){
                 hlp[k]=result[k];
                 attrib(hlp[k],"isResolved",attrib(result[k],"isResolved"));
                 attrib(hlp[k],"smoothC",attrib(result[k],"smoothC"));
               }
-              kill k;
-              for(int k =1;k<=size(blowup);k++){
+              for(k =1;k<=size(blowup);k++){
                 hlp[size(hlp)+1]=blowup[k];
                 attrib(hlp[size(hlp)],"isResolved",0);
                 attrib(hlp[size(hlp)],"smoothC",0);
               }
-              kill k;
-              for(int k = j+1;k<=size(result);k++){
+              for(k = j+1;k<=size(result);k++){
                 hlp[size(hlp)+1]=result[k];
                 attrib(hlp[size(hlp)],"isResolved",attrib(result[k],"isResolved"));
@@ -316,5 +316,5 @@
               }
               result = hlp;
-              kill hlp,k;
+              kill hlp;
               i=size(primdecPC);
             }
@@ -324,5 +324,5 @@
             kill Sl;
           }
-          kill i,primdecPC;
+          kill primdecPC;
           j=p;
           break; 
@@ -333,16 +333,15 @@
           int count = 0;
           ideal Collect = BO[2];
-          for(int i = 1;i<=size(BO[4]);i++){
+          for(i = 1;i<=size(BO[4]);i++){
             Collect = Collect*BO[4][i];
           }
           list primdecSL = primdecGTZ(slocus(Collect));
-          for(int k = 1;k<=size(primdecSL);k++){
+          for(k = 1;k<=size(primdecSL);k++){
              attrib(primdecSL[k],"isRational",1);
           }
-          kill k;
           if(defined(blowup)){kill blowup;}
           list blowup = blowUpBO(BO,primdecSL[1][2],3);
           if(attrib(primdecSL[1],"isRational")==0){
-            for(int k=1;k<=size(blowup);k++){
+            for(k=1;k<=size(blowup);k++){
               def R2=blowup[k];
               setring R2;
@@ -358,8 +357,7 @@
               kill L,R2;
             }
-            kill k;
           }
-          kill Collect,i;
-          for(int i=1;i<=size(primdecSL);i++){
+          kill Collect;
+          for(i=1;i<=size(primdecSL);i++){
             list L = BO[4];
             L[size(L)+1]=BO[2];
@@ -372,17 +370,15 @@
               list blowup = blowUpBO(BO,primdecSL[i][2],3);
               list hlp;
-              for(int k = 1;k<j;k++){
+              for(k = 1;k<j;k++){
                 hlp[k]=result[k];
                 attrib(hlp[k],"isResolved",attrib(result[k],"isResolved"));
                 attrib(hlp[k],"smoothC",attrib(result[k],"smoothC"));
               }
-              kill k;
-              for(int k =1;k<=size(blowup);k++){
+              for(k =1;k<=size(blowup);k++){
                 hlp[size(hlp)+1]=blowup[k];
                 attrib(hlp[size(hlp)],"isResolved",0);
                 attrib(hlp[size(hlp)],"smoothC",1);
               }
-              kill k;
-              for(int k = j+1;k<=size(result);k++){
+              for(k = j+1;k<=size(result);k++){
                 hlp[size(hlp)+1]=result[k];
                 attrib(hlp[size(hlp)],"isResolved",attrib(result[k],"isResolved"));
@@ -390,5 +386,5 @@
               }
               result = hlp;
-              kill hlp,k;
+              kill hlp;
               j = p;
               break;
@@ -399,5 +395,4 @@
             kill L;
           }
-          kill i;
           if(count == size(primdecSL)){
             attrib(result[j],"isResolved",1);
@@ -414,5 +409,5 @@
       break;
     }
-    kill count2,j,p;
+    kill count2,p;
     safety++;
   }
@@ -437,4 +432,5 @@
 "
 {
+  int i;
   if(!defined(noeth)){
     int noeth = 0;
@@ -472,5 +468,5 @@
       else{
         ideal NoetherPos = var(pos);
-        for(int i = 1;i<=3;i++){
+        for(i = 1;i<=3;i++){
           if(i<>pos){
             NoetherPos = NoetherPos + var(i);
@@ -501,6 +497,6 @@
     list nor = normal(NoetherN);
     list result;
-    for(int i = 1;i<=size(nor);i++){
-      def R = nor[i];
+    for(i = 1;i<=size(nor[1]);i++){
+      def R = nor[1][i];
       setring R;
       ideal QIdeal = norid;
@@ -547,11 +543,12 @@
   list fibreP = jungfib(id,noeth);
   list result;
-  for(int i =1;i<=size(fibreP);i++){
+  int i,j;
+  for(i =1;i<=size(fibreP);i++){
     def R1 = fibreP[i];
     setring R1;
     map f1 = A,BMap;
-    list nor = normal(QIdeal);
-    for(int j = 1;j<=size(nor);j++){
-      def R2 = nor[j];
+    def nor = normal(QIdeal);
+    for(j = 1;j<=size(nor[1]);j++){
+      def R2 = nor[1][j];
       setring R2;
       map f2 = R1,normap;
@@ -561,7 +558,8 @@
       export(QIdeal);
       result[size(result)+1] = R2;
-      kill R2,f2;
-    }
-    kill j,nor,R1;
+      setring R1;
+      kill R2;
+    }
+    kill R1;
   }
   return(result);
@@ -602,6 +600,7 @@
   def A = basering;
   list result;
+  int i,j;
   list nor = jungnormal(id,noeth);
-  for(int i = 1;i<=size(nor);i++){
+  for(i = 1;i<=size(nor);i++){
     if(defined(R)){kill R;}
     def R3 = nor[i];
@@ -614,5 +613,5 @@
     if(QIdeal <> 0){
       list res = resolve(QIdeal);
-      for(int j =1;j<=size(res[1]);j++){
+      for(j =1;j<=size(res[1]);j++){
         def R2 = res[1][j];
         setring R2;
@@ -628,5 +627,5 @@
         kill R2;
       }
-      kill j,res;
+      kill res;
     }
     else{
@@ -654,4 +653,5 @@
   def A = basering;
   list ringA=ringlist(A);
+  int i,j,k;
   int index = 0;
   if(size(id)==1 && nvars(A)){  // test if V(id) = C[x,y,z]/<f>
@@ -662,6 +662,5 @@
     kill v;
     poly f = id[1];
-    int j = 0;
-    for(int i = 1;i<=3;i++){
+    for(i = 1;i<=3;i++){
       setring A;
       list l = ringA;  //change ordering to lp and var(i)>var(j) j!=i
@@ -680,6 +679,5 @@
       intvec v = leadexp(I[1]);
       attrib(v,"isMonic",1);
-      if(defined(k)){kill k;}
-      for(int k = 2;k<=3;k++){  
+      for(k = 2;k<=3;k++){  
 // checks whether f is monic in var(i)
         if(v[k] <> 0 || v[1] == 0){ 
@@ -689,5 +687,4 @@
         }
       }
-      kill k;
       if(attrib(v,"isMonic")==1){
         index = i;
@@ -791,4 +788,5 @@
   ideal BMap= maxideal(1);
   export(BMap);
+  int i,j;
   export(QIdeal);
   if(dim(QIdeal)<>2){
@@ -803,5 +801,5 @@
     if(defined(count)){kill count;}
     int count =0;
-    for(int i = 1;i<= size(result);i++){
+    for(i = 1;i<= size(result);i++){
       attrib(result[i],"isSmooth",1);
       def R = result[i];
@@ -823,9 +821,8 @@
       kill R;
     }
-    kill i;
     if(count == size(result)){return(result);}
     count = 0;
     list hlp;
-    for(int i = 1;i<=size(result);i++){
+    for(i = 1;i<=size(result);i++){
       if(attrib(result[i],"isSmooth")==1){
         hlp[size(hlp)+1] = result[i];
@@ -840,6 +837,6 @@
       list nor = normal(QIdeal);
       //print(N2);
-      for(int j = 1;j<= size(nor);j++){
-        def R3 = nor[j];
+      for(j = 1;j<= size(nor[1]);j++){
+        def R3 = nor[1][j];
         setring R3;
         def R2 = changeord("dp");
