Index: Singular/LIB/difform.lib
===================================================================
--- Singular/LIB/difform.lib	(revision 0d6d56592c854c03d576138fd39bd0808f01ce94)
+++ Singular/LIB/difform.lib	(revision 3be95907c1d8f21621eacf23da80eaf327484264)
@@ -23,6 +23,4 @@
     diffAlgebra();                  provides the differential algebra structure and the differential forms dx_1,...,dx_n
     diffAlgebraStructure();         generates the structure of the differential algebra from the basering
-    diffAlgebraCheck();             checks if the basering already has a differential algebra
-    diffAlgebraSwitch();            changes the basering to the differential algebra for computations
     diffAlgebraGens();              defines the differential forms dx_1,...,dx_n
     diffAlgebraUnivDerIdeal(ideal); computes the image of an ideal under the universal derivation
@@ -71,21 +69,17 @@
 KEYWORDS: differential forms;differentials;differential algebra
 ";
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-//                                  Initialization of library                                 //
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-
+// Libraries needed
+LIB "inout.lib";
+
+////////////////////////////////////////////////////////////////////////////////
+//                       Initialization of library                            //
+////////////////////////////////////////////////////////////////////////////////
 
 static proc mod_init()
 {
-        // Type of differential forms:
-        // These are considered as elements (polynomials) in the differential algebra
+    // Type of differential forms:
+    // These are considered as elements (polynomials) in the differential algebra
     // NOTE: the polynomials 'form' are not visible in the basering - only in the differential algebra
-        newstruct("difform","poly form");
+    newstruct("difform","poly form");
 
     // Type of derivations - these are maps: Omega_R^1 -> R
@@ -95,19 +89,19 @@
     newstruct("derivation","list genIm");
 
-        // Overloads for difform
-        system("install", "difform", "=", difformFromPoly, 1);
-        system("install", "difform", "print", difformPrint, 1);
-
-        system("install", "difform", "+", difformAdd, 2);
-        system("install", "difform", "-", difformSub, 2);
-        system("install", "difform", "-", difformNeg, 1);
-        system("install", "difform", "*", difformMul, 2);
+    // Overloads for difform
+    system("install", "difform", "=", difformFromPoly, 1);
+    system("install", "difform", "print", difformPrint, 1);
+
+    system("install", "difform", "+", difformAdd, 2);
+    system("install", "difform", "-", difformSub, 2);
+    system("install", "difform", "-", difformNeg, 1);
+    system("install", "difform", "*", difformMul, 2);
     system("install", "difform", "/", difformDiv, 2);
-        system("install", "difform", "==", difformEqu, 2);
-        system("install", "difform", "<>", difformNeq, 2);
+    system("install", "difform", "==", difformEqu, 2);
+    system("install", "difform", "<>", difformNeq, 2);
     system("install", "difform", ">", difformIsBigger,2);
     system("install", "difform", "<", difformIsSmaller,2);
 
-        system("install", "difform", "deg", difformDeg, 1);
+    system("install", "difform", "deg", difformDeg, 1);
     system("install", "difform", "homog", difformIsHomog, 1);
 
@@ -126,34 +120,30 @@
     system("install", "derivation", "diff", derivationLie, 2);
 
-    // Libraries needed
-    LIB "inout.lib";
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-//                            Construction of differential algebra                            //
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+//                  Construction of differential algebra                      //
+////////////////////////////////////////////////////////////////////////////////
 
 
 // TODO: check if qringNF option is set - if yes: turn off and set afterwards on
 proc diffAlgebra()
-"USAGE:         diffAlgebra();
-SIDE EFFECTS:   If R is the basering, the differential algebra is constructed with name Omega_R
-                and the differential forms dx_1,...,dx_n are available. The name of the differential
-                algebra is stored in the attribute attrib(R,"diffAlgebra").
-NOTE:           - computations with differential forms need the structure of the differential algebra,
-                so this procedure should be executed first.
-                - the variable names 'd' or 'D' should be avoided.
-                - the procedure also works for quotient rings
-KEYWORDS:       differential algebra; differential forms; differentials
-SEE ALSO:       diffAlgebraStructure, diffAlgebraGens, diffAlgebraUnivDerIdeal
-EXAMPLE:        example diffAlgebra; shows an example"
+"USAGE:       diffAlgebra();
+SIDE EFFECTS: If R is the basering, the differential algebra is constructed with name Omega_R
+              and the differential forms dx_1,...,dx_n are available. The name of the differential
+              algebra is stored in the attribute attrib(R,"diffAlgebra").
+NOTE:         - computations with differential forms need the structure of the differential algebra,
+              so this procedure should be executed first.
+              - the variable names 'd' or 'D' should be avoided.
+              - the procedure also works for quotient rings
+KEYWORDS:     differential algebra; differential forms; differentials
+SEE ALSO:     diffAlgebraStructure; diffAlgebraGens; diffAlgebraUnivDerIdeal
+EXAMPLE:      example diffAlgebra; shows an example"
 {
 
     // Build the differential algebra and store its name as an attribute
-    string diffAlg_name = diffAlgebraStructure();
-    attrib(basering,"diffAlgebra",diffAlg_name);
+    ring Omega_R = diffAlgebraStructure();
+    attrib(basering,"diffAlgebra","Omega_R");
 
     // Construct the differential forms dx_1,...,dx_n over the basering
@@ -173,6 +163,4 @@
     string info_text = "// The differential algebra " + attrib(basering,"diffAlgebra") + " was constructed and the differential forms " + basic_forms + " are available.";
     print(info_text);
-    return();
-
 }
 example
@@ -200,14 +188,14 @@
 qring S = std(I);
 diffAlgebra();
-setring Omega_S;
+setring Omega_R;
 
 // The differential algebra is given by:
 basering;
 
-kill Omega_S,dx,dy,dz;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
+kill Omega_R,dx,dy,dz;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -224,20 +212,20 @@
 {
 
-    string basering_name = nameof(basering);
-        list base_list = ringlist(basering);
+    list base_list = ringlist(basering);
     def R_old = basering;
     ideal quot_ideal = base_list[4];
 
-        // Add Dx_1,...,Dx_n as first variables
-        list ext_var = base_list[2];
-        int n = size(ext_var);
-        int i;
-
-        for(i = 1; i <= n; i++){
-        ext_var[n+i] = ext_var[i];
-                ext_var[i] = "D" + ext_var[n+i];
-        }
-
-        base_list[2] = ext_var;
+    // Add Dx_1,...,Dx_n as first variables
+    list ext_var = base_list[2];
+    int n = size(ext_var);
+    int i;
+
+    for(i = 1; i <= n; i++)
+    {
+      ext_var[n+i] = ext_var[i];
+      ext_var[i] = "D" + ext_var[n+i];
+    }
+
+    base_list[2] = ext_var;
 
     // Preserve the monomial order of the basering
@@ -246,35 +234,41 @@
     base_list[3] = list(list("dp",weight_vec)) + base_list[3];
 
-        // Add relations x_i*x_j = x_j*x_i and dx_i*dx_j = -dx_j*dx_i
-        int k = 2*n;
-        matrix C[k][k];
-        matrix D[k][k];
-        int j;
-
-        // Generate strictly upper triangular matrix describing the relations
-        for(i = 1; i <= k; i++){
-            for(j = i+1; j <= k ; j++){
-            if(j <= n){
-                        C[i,j] = -1;
-            }else{
-                C[i,j] = 1;
-            }
-                }
-        }
+    // Add relations x_i*x_j = x_j*x_i and dx_i*dx_j = -dx_j*dx_i
+    int k = 2*n;
+    matrix C[k][k];
+    matrix D[k][k];
+    int j;
+
+    // Generate strictly upper triangular matrix describing the relations
+    for(i = 1; i <= k; i++)
+    {
+      for(j = i+1; j <= k ; j++)
+      {
+        if(j <= n)
+        {
+          C[i,j] = -1;
+        }
+        else
+        {
+          C[i,j] = 1;
+        }
+      }
+    }
 
     base_list[4] = ideal(0);
-        base_list[5] = C;
-        base_list[6] = D;
-
-        // Pass to non-commutative ring with extra variables and relations
-        ring R_intermediate = ring(base_list);
-
-        // Add relations Dx_i*Dx_i = 0 via generating a quotient ring
-        ideal REL;
-        for(i = 1; i <= n; i++){
-                REL[i] = var(i)*var(i);
-        }
-
-        // Build the differential algebra for the polynomial ring - the free module
+    base_list[5] = C;
+    base_list[6] = D;
+
+    // Pass to non-commutative ring with extra variables and relations
+    ring R_intermediate = ring(base_list);
+
+    // Add relations Dx_i*Dx_i = 0 via generating a quotient ring
+    ideal REL;
+    for(i = 1; i <= n; i++)
+    {
+      REL[i] = var(i)*var(i);
+    }
+
+    // Build the differential algebra for the polynomial ring - the free module
     qring diffAlg_poly = twostd(REL);
 
@@ -282,69 +276,31 @@
     ideal quot_ideal = imap(R_old,quot_ideal);
 
-    if(quot_ideal != 0){
-
-        // Compute the universal derivation of the generators of the ideal
-        quot_ideal = quot_ideal + diffAlgebraUnivDerIdeal(quot_ideal);
-
-        // Add the additional relations, generate the differential algebra with name Omega_R and export it
-        string diffAlg_name = "Omega_" + basering_name;
-            execute("qring " + diffAlg_name + " = twostd(quot_ideal);");
-        execute("exportto(Top," + diffAlg_name + ");");
-
-        return(diffAlg_name);
+    if(size(quot_ideal) != 0)
+    {
+      // Compute the universal derivation of the generators of the ideal
+      quot_ideal = quot_ideal + diffAlgebraUnivDerIdeal(quot_ideal);
+
+      // Add the additional relations, generate the differential algebra with name Omega_R and export it
+      qring Omega_R = twostd(quot_ideal);
+      exportto(Top,Omega_R);
+
+      return(Omega_R);
     }
 
     // Give the differential algebra the name Omega_basering and export it
-    string diffAlg_name = "Omega_" + basering_name;
-        execute("ring " + diffAlg_name + " = diffAlg_poly;");
-    execute("exportto(Top," + diffAlg_name + ");");
-
-    return(diffAlg_name);
-
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-proc diffAlgebraCheck()
-"USAGE:         diffAlgebraCheck();
-SIDE EFFECTS:   Checks if the basering has a differential algebra and aborts with an error if this is not the case
-REMARKS:        The procedure checks if the name in the attribute attrib(basering,"diffAlgebra") is not empty. This
-                is the case if the procedure diffAlgebra was executed first.
-NOTE:           whenever computations with differential forms are done, it should be checked if the differential
-                algebra was already generated since differential forms are polynomials in the differential algebra
-KEYWORDS:       differential algebra
-SEE ALSO:       diffAlgebraSwitch"
-{
-    string diffAlg_name = attrib(basering,"diffAlgebra");
-    if(size(diffAlg_name) == 0){
-        ERROR("Ring does not have a differential algebra!");
-    }
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-proc diffAlgebraSwitch()
-"USAGE:         diffAlgebraSwitch();
-ASSUME:         The differential algebra was already constructed.
-SIDE EFFECTS:   Changes the ring: from the basering to the differential algebra.
-NOTE:           whenever computations with differential forms are done, the ring must be changed to the differential
-                algebra since differential forms are polynomials there. But first it should be checked if the algebra
-                is actually available: so before executing diffAlgebraSwitch there should always be an preceding diffAlgebraCheck
-KEYWORDS:       differential algebra
-SEE ALSO:       diffAlgebraCheck"
-{
-
-    string diffAlg_name = attrib(basering,"diffAlgebra");
-    execute("setring " + diffAlg_name);
-    execute("keepring " + diffAlg_name);
-
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
+    ring Omega_R = diffAlg_poly;
+    exportto(Top,Omega_R);
+
+    return(Omega_R);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -356,7 +312,7 @@
 {
 
-    diffAlgebraSwitch();
-
-    list ext_var = ringlist(basering)[2];
+    setring Omega_R;
+
+    list ext_var = ringlist(Omega_R)[2];
     int n = size(ext_var) div 2;
     int i;
@@ -391,11 +347,12 @@
     ideal d_I;
 
-    for(j = 1; j <= k; j++){
+    for(j = 1; j <= k; j++)
+    {
         d_I[j] = 0;
-        for(i = 1; i <= n; i++){
+        for(i = 1; i <= n; i++)
+        {
             d_I[j] = d_I[j] + diff(I[j],var(i+n))*var(i);
         }
     }
-
     return(d_I);
 
@@ -435,17 +392,21 @@
 
     // Get information from input
-    for(i = 1; i <= n; i++){
-        if(typeof(#[i]) == "string"){
-
-            if(#[i] == "gen" && typeof(#[i+1]) == "string"){
+    for(i = 1; i <= n; i++)
+    {
+        if(typeof(#[i]) == "string")
+        {
+            if(#[i] == "gen" && typeof(#[i+1]) == "string")
+            {
                 gen_ord = #[i+1];
-                if(typeof(#[i+2]) == "intvec"){
+                if(typeof(#[i+2]) == "intvec")
+                {
                     intvec gen_weight = #[i+2];
                 }
             }
-
-            if(#[i] == "ringvar" && typeof(#[i+1]) == "string"){
+            if(#[i] == "ringvar" && typeof(#[i+1]) == "string")
+            {
                 ringvar_ord = #[i+1];
-                if(typeof(#[i+2]) == "intvec"){
+                if(typeof(#[i+2]) == "intvec")
+                {
                     intvec ringvar_weight = #[i+2];
                 }
@@ -456,56 +417,68 @@
     // Check input for consistency
     // Generator ordering must be a valid monomial ordering
-    if(gen_ord != "" && gen_ord != "lp" && gen_ord != "rp" && gen_ord != "dp" && gen_ord != "Dp" && gen_ord != "wp" && gen_ord != "Wp"){
-        if(gen_ord != "ls" && gen_ord != "ds" && gen_ord != "Ds" && gen_ord != "ws" && gen_ord != "Ws"){
+    if(gen_ord != "" && gen_ord != "lp" && gen_ord != "rp" && gen_ord != "dp" && gen_ord != "Dp" && gen_ord != "wp" && gen_ord != "Wp")
+    {
+        if(gen_ord != "ls" && gen_ord != "ds" && gen_ord != "Ds" && gen_ord != "ws" && gen_ord != "Ws")
+        {
             ERROR("Not a valid ordering!");
         }
     }
-
     // Ringvariable ordering must be a valid monomial ordering
-    if(ringvar_ord != "" && ringvar_ord != "lp" && ringvar_ord != "rp" && ringvar_ord != "dp" && ringvar_ord != "Dp" && ringvar_ord != "wp" && ringvar_ord != "Wp"){
-        if(ringvar_ord != "ls" && ringvar_ord != "ds" && ringvar_ord != "Ds" && ringvar_ord != "ws" && ringvar_ord != "Ws"){
+    if(ringvar_ord != "" && ringvar_ord != "lp" && ringvar_ord != "rp" && ringvar_ord != "dp" && ringvar_ord != "Dp" && ringvar_ord != "wp" && ringvar_ord != "Wp")
+    {
+        if(ringvar_ord != "ls" && ringvar_ord != "ds" && ringvar_ord != "Ds" && ringvar_ord != "ws" && ringvar_ord != "Ws")
+        {
             ERROR("Not a valid ordering!");
         }
     }
-
     // If the generator ordering is a weighted monomial ordering, a weight-vector is needed
-    if(gen_ord == "wp" || gen_ord == "Wp" || gen_ord == "ws" || gen_ord == "Ws"){
-        if(!defined(gen_weight)){
+    if(gen_ord == "wp" || gen_ord == "Wp" || gen_ord == "ws" || gen_ord == "Ws")
+    {
+        if(!defined(gen_weight))
+        {
             ERROR("No weight vector given!");
         }
-
-        if(size(gen_weight) != k){
+        if(size(gen_weight) != k)
+        {
             ERROR("Weight vector has wrong size!");
         }
-    }else{
+    }
+    else
+    {
     // If a weight vector is given although the monomial ordering is not weighted
-        if(defined(gen_weight)){
+        if(defined(gen_weight))
+        {
             kill gen_weight;
         }
     }
-
     // If the ordering for the ring variables is a weighted monmial ordering, a weight-vector is needed
-    if(ringvar_ord == "wp" || ringvar_ord == "Wp" || ringvar_ord == "ws" || ringvar_ord == "Ws"){
-        if(!defined(ringvar_weight)){
+    if(ringvar_ord == "wp" || ringvar_ord == "Wp" || ringvar_ord == "ws" || ringvar_ord == "Ws")
+    {
+        if(!defined(ringvar_weight))
+        {
             ERROR("No weight vector given!");
         }
-
-        if(size(ringvar_weight) != k){
+        if(size(ringvar_weight) != k)
+        {
             ERROR("Weight vector has wrong size!");
         }
-    }else{
+    }
+    else
+    {
     // If a weight vector is given although the monomial ordering is not weighted
-        if(defined(ringvar_weight)){
+        if(defined(ringvar_weight))
+        {
             kill ringvar_weight;
         }
     }
-
     list L_diff_Alg = ringlist(basering);
     n = size(L_diff_Alg[3]);
 
     // Change ordering of generators
-    if(gen_ord != ""){
+    if(gen_ord != "")
+    {
         L_diff_Alg[3][1][1] = gen_ord;
-        if(defined(gen_weight)){
+        if(defined(gen_weight))
+        {
             L_diff_Alg[3][1][2] = gen_weight;
         }
@@ -513,16 +486,18 @@
 
     // Change the ordering of the ringvariables
-    if(ringvar_ord != ""){
+    if(ringvar_ord != "")
+    {
         list L;
         L[1] = L_diff_Alg[3][1];
-
         L[2] = list();
         L[2][1] = ringvar_ord;
-        if(defined(ringvar_weight)){
+        if(defined(ringvar_weight))
+        {
             L[2][2] = ringvar_weight;
-        }else{
+        }
+        else
+        {
             L[2][2] = 1:k;
         }
-
         L_diff_Alg[3] = L;
     }
@@ -530,5 +505,4 @@
     def T = ring(L_diff_Alg);
     return(T);
-
 }
 
@@ -539,5 +513,5 @@
 proc diffAlgebraListGen(list #)
 "USAGE: diffAlgebraListGen(#); # list
-RETURN:     - a list of generetors of the differential algebra as module over the basering
+RETURN:     - a list of generators of the differential algebra as module over the basering
             - a list of generators of a graded part of the differential algebra
 REMARKS:    In order to find all generators, they are counted 'binary': The generators are in
@@ -552,7 +526,4 @@
 EXAMPLE:    example diffAlgebraListGen; shows an example"
 {
-
-    diffAlgebraCheck();
-
     int n = size(ringlist(basering)[2]);
     int i,k,j;
@@ -564,6 +535,8 @@
 
     // Get optional degree
-    if(size(#) > 0){
-        if(typeof(#[1]) == "int"){
+    if(size(#) > 0)
+    {
+        if(typeof(#[1]) == "int")
+        {
             degr = #[1];
         }
@@ -572,7 +545,8 @@
     // Build the list of all dx_i
     def R_old = basering;
-    diffAlgebraSwitch();
-
-    for(i = 1; i <= n; i++){
+    setring Omega_R;
+
+    for(i = 1; i <= n; i++)
+    {
         current_var.form = var(i);
         var_list[i] = current_var;
@@ -583,5 +557,6 @@
     // Find all generators (of given degree)
     list dual_i;
-    for(i = 1; i < 2^n; i++){
+    for(i = 1; i < 2^n; i++)
+    {
         // Compute dual number representation
         dual_i = diffAlgebraIntToDual(i);
@@ -590,6 +565,8 @@
 
         // Convert dual number to generator
-        for(j = 1; j <= k; j++){
-            if(dual_i[j] != 0){
+        for(j = 1; j <= k; j++)
+        {
+            if(dual_i[j] != 0)
+            {
                 current_gen = current_gen*var_list[j];
             }
@@ -597,5 +574,6 @@
 
         // Add generator if it has the given degree or degree was not chosen
-        if(degr == -1 || difformDeg(current_gen) == degr){
+        if(degr == -1 || difformDeg(current_gen) == degr)
+        {
             GEN_list = GEN_list + list(current_gen);
         }
@@ -603,5 +581,6 @@
 
     // Add generator 1
-    if(degr == 0 || degr == -1){
+    if(degr == 0 || degr == -1)
+    {
         difform gen_one = 1;
         GEN_list = list(gen_one) + GEN_list;
@@ -609,5 +588,4 @@
 
     return(difformListSort(GEN_list));
-
 }
 example
@@ -631,5 +609,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -641,29 +619,26 @@
 SEE ALSO:   diffAlgebraListGen"
 {
-
     list dual_number;
 
-    while(l div 2 != 0){
+    while(l div 2 != 0)
+    {
         dual_number = dual_number + list(l mod 2);
         l = l div 2;
     }
-
     dual_number = dual_number + list(l mod 2);
-
     return(dual_number);
-
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-//                                Procedures for type difform                                 //
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-//----------------------------------- Structural procedures ----------------------------------//
-////////////////////////////////////////////////////////////////////////////////////////////////
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//                     Procedures for type difform                            //
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////
+//----------------------- Structural procedures ------------------------------//
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -677,7 +652,6 @@
 {
 
-    diffAlgebraCheck();
     def R_old = basering;
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     poly g = imap(R_old,f);
@@ -686,5 +660,4 @@
 
     return(df);
-
 }
 example
@@ -712,5 +685,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -726,8 +699,6 @@
 EXAMPLE:    example difformCoef; shows an example"
 {
-
-    diffAlgebraCheck();
     def R_old = basering;
-    diffAlgebraSwitch();
+    setring Omega_R;
     def diff_Alg = basering;
 
@@ -736,11 +707,12 @@
     int i;
 
-        // Build the wedge product of all differential forms dx_i
-        poly wedge_mon = 1;
-        for(i = 1; i <= n; i++){
-                wedge_mon = wedge_mon*var(i);
-        }
-
-        // Find the coefficients of the generators
+    // Build the wedge product of all differential forms dx_i
+    poly wedge_mon = 1;
+    for(i = 1; i <= n; i++)
+    {
+      wedge_mon = wedge_mon*var(i);
+    }
+
+    // Find the coefficients of the generators
     matrix df_coefs = coef(f,wedge_mon);
     int k = ncols(df_coefs);
@@ -753,23 +725,23 @@
     list repr;
 
-    for(i = 1;i <= k;i++){
-        repr[i] = list();
-        setring diff_Alg;
-
-        // Generators as differential forms
-        current_gen.form = df_coefs[1,i];
-
-        // Coefficients are polynomials in the basering
-        coeff_above = df_coefs[2,i];
-        setring R_old;
-        coeff = imap(diff_Alg,coeff_above);
-
-        repr[i][1] = current_gen;
-        repr[i][2] = coeff;
+    for(i = 1;i <= k;i++)
+    {
+      repr[i] = list();
+      setring diff_Alg;
+
+      // Generators as differential forms
+      current_gen.form = df_coefs[1,i];
+
+      // Coefficients are polynomials in the basering
+      coeff_above = df_coefs[2,i];
+      setring R_old;
+      coeff = imap(diff_Alg,coeff_above);
+
+      repr[i][1] = current_gen;
+      repr[i][2] = coeff;
     }
 
     // Return representation
     return(repr);
-
 }
 example
@@ -797,5 +769,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -809,28 +781,25 @@
 SEE ALSO:   difformToString"
 {
-
-    diffAlgebraSwitch();
+    setring Omega_R;
     string df_out_un = string(df.form);
-    list vars_ = ringlist(basering)[2];
+    list vars_ = ringlist(Omega_R)[2];
     int n = size(vars_) div 2;
     int i,j;
 
     // Replace the Dx_i in the string with the dx_i
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         j = find(df_out_un,string(vars_[i]));
 
-        while(j!=0){
+        while(j!=0)
+        {
             df_out_un[j] = "d";
             j = find(df_out_un,vars_[i]);
         }
     }
-
     return(df_out_un);
-
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
+}
+
+////////////////////////////////////////////////////////////////////////////////
 
 // TODO: check optionIsSet("qringNF") - ADD ring.lib !!! and reduce by hand
@@ -848,5 +817,4 @@
 EXAMPLE:    example difformToString; shows an example"
 {
-
     // Get the coefficients
     list repr = difformCoef(df);
@@ -857,9 +825,13 @@
     int i;
 
-    for(i = 1; i <= n; i++){
-        if(typeof(#[i]) == "string"){
-            if(#[i] == "gen" && typeof(#[i+1]) == "string"){
+    for(i = 1; i <= n; i++)
+    {
+        if(typeof(#[i]) == "string")
+        {
+            if(#[i] == "gen" && typeof(#[i+1]) == "string")
+            {
                 gen_ord = #[i+1];
-                if(typeof(#[i+2]) == "intvec"){
+                if(typeof(#[i+2]) == "intvec")
+                {
                     intvec gen_weight = #[i+2];
                 }
@@ -869,11 +841,17 @@
 
     // Sort the generator/coefficients by the chosen ordering
-    if(gen_ord != ""){
-        if(defined(gen_weight)){
+    if(gen_ord != "")
+    {
+        if(defined(gen_weight))
+        {
             repr = difformListSort(repr,"Llist","gen",gen_ord,gen_weight);
-        }else{
+        }
+        else
+        {
             repr = difformListSort(repr,"Llist","gen",gen_ord);
         }
-    }else{
+    }
+    else
+    {
         repr = difformListSort(repr,"Llist");
     }
@@ -888,5 +866,6 @@
     string df_coef_str;
 
-    for(i = n; i >= 1; i--){
+    for(i = n; i >= 1; i--)
+    {
         df_gen = repr[i][1];
         df_gen_str = difformGenToString(df_gen);
@@ -895,5 +874,6 @@
 
         // Check the coefficients and generators
-        while(1){
+        while(1)
+        {
             // Special cases without brackets:
 
@@ -912,11 +892,11 @@
 
         // Add a plus sign
-        if(i > 1){
+        if(i > 1)
+        {
             df_out = df_out + "+";
         }
     }
 
-        return(df_out);
-
+    return(df_out);
 }
 example
@@ -955,9 +935,6 @@
 EXAMPLE:        example difformPrint; shows an example"
 {
-
     // Print in ds-order on the generators
-        print(difformToString(df,"gen","ds"));
-    return();
-
+    print(difformToString(df,"gen","ds"));
 }
 example
@@ -990,15 +967,12 @@
 "
 {
-
-    diffAlgebraCheck();
     list df_gen_repr = difformCoef(df);
     int n = size(df_gen_repr);
 
-    if(n == 1 && df_gen_repr[1][2] == 1){
+    if(n == 1 && df_gen_repr[1][2] == 1)
+    {
         return(1);
     }
-
     return(0);
-
 }
 example
@@ -1043,7 +1017,5 @@
 EXAMPLE:    example difformAdd; shows an example"
 {
-
-    diffAlgebraCheck();
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     difform dsum;
@@ -1089,7 +1061,5 @@
 EXAMPLE:    example difformSub; shows an example"
 {
-
-        diffAlgebraCheck();
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     difform dsub;
@@ -1098,5 +1068,4 @@
 
     return(dsub);
-
 }
 example
@@ -1135,7 +1104,5 @@
 EXAMPLE:    example difformNeg; shows an example"
 {
-
-        diffAlgebraCheck();
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     difform dneg;
@@ -1144,5 +1111,4 @@
 
     return(dneg);
-
 }
 example
@@ -1163,5 +1129,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1173,7 +1139,5 @@
 EXAMPLE:    example difformMul; shows an example"
 {
-
-        diffAlgebraCheck();
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     difform dmul;
@@ -1182,5 +1146,4 @@
 
     return(dmul);
-
 }
 example
@@ -1219,7 +1182,5 @@
 EXAMPLE:    example difformDiv; shows an example"
 {
-
-    diffAlgebraCheck();
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     difform ddiv;
@@ -1228,5 +1189,4 @@
 
     return(ddiv);
-
 }
 example
@@ -1255,5 +1215,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1265,10 +1225,6 @@
 EXAMPLE:    example difformEqu; shows an example"
 {
-
-        diffAlgebraCheck();
-    diffAlgebraSwitch();
-
+    setring Omega_R;
     return(df.form == dg.form);
-
 }
 example
@@ -1293,5 +1249,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1303,7 +1259,5 @@
 EXAMPLE:    example difformNeq; shows an example"
 {
-
         return(!difformEqu(df,dg));
-
 }
 example
@@ -1347,13 +1301,12 @@
 EXAMPLE:    example difformIsBigger; shows an example"
 {
-
-    diffAlgebraCheck();
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     poly df_form = df.form;
     poly dg_form = dg.form;
 
-    if(size(#) > 0){
-        def diff_Alg = basering;
+    if(size(#) > 0)
+    {
+        def diff_Alg = Omega_R;
         ring T = diffAlgebraChangeOrd(#);
 
@@ -1364,5 +1317,4 @@
 
     return(df_form > dg_form);
-
 }
 example
@@ -1392,5 +1344,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1411,12 +1363,11 @@
 EXAMPLE:    example difformIsSmaller; shows an example"
 {
-
-    diffAlgebraCheck();
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     poly df_form = df.form;
     poly dg_form = dg.form;
 
-    if(size(#) > 0){
+    if(size(#) > 0)
+    {
         def diff_Alg = basering;
         ring T = diffAlgebraChangeOrd(#);
@@ -1426,7 +1377,5 @@
         return(df_form_T < dg_form_T);
     }
-
     return(df.form < dg.form);
-
 }
 example
@@ -1456,7 +1405,7 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
-//------------------------- Procedures for computing with the degree -------------------------//
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//------------ Procedures for computing with the degree ----------------------//
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1471,20 +1420,17 @@
 EXAMPLE:    example difformDeg; shows an example"
 {
-
-    diffAlgebraCheck();
-    diffAlgebraSwitch();
+    setring Omega_R;
 
     // Degree of a difform is the degree of the poly with weights 0 for the basering variables
-    int n = size(ringlist(basering)[2]) div 2;
+    int n = size(ringlist(Omega_R)[2]) div 2;
     int i;
     intvec var_weights;
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         var_weights[i] = 1;
         var_weights[i+n] = 0;
     }
-
     return(deg(df.form,var_weights));
-
 }
 example
@@ -1511,6 +1457,5 @@
 }
 
-
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1525,19 +1470,16 @@
 EXAMPLE:    example difformIsHomog; shows an example"
 {
-
-        diffAlgebraCheck();
-    diffAlgebraSwitch();
-
-    int n = size(ringlist(basering)[2]) div 2;
+    setring Omega_R;
+
+    int n = size(ringlist(Omega_R)[2]) div 2;
     int i;
     intvec var_weights;
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         var_weights[i] = 1;
         var_weights[i+n] = 0;
     }
-
     return(homog(df.form,var_weights));
-
 }
 example
@@ -1572,5 +1514,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1583,9 +1525,7 @@
 EXAMPLE:    example difformIsHomogDeg; shows an example"
 {
-
         int df_deg = difformDeg(df);
         int is_hom = difformIsHomog(df);
         return(df_deg == p && is_hom == 1);
-
 }
 example
@@ -1620,5 +1560,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1632,7 +1572,4 @@
 EXAMPLE:    example difformHomogDecomp; shows an example"
 {
-
-    diffAlgebraCheck();
-
     // Highest degree is the nr. of variables in the basering
     int n = size(ringlist(basering)[2]);
@@ -1643,5 +1580,6 @@
 
     // Generate a list full of 0s
-    for(i = 1;i <= (n+1); i++){
+    for(i = 1;i <= (n+1); i++)
+    {
         homog_part[i] = 0;
     }
@@ -1652,18 +1590,20 @@
 
     // Sort in list
-    for(i = 1; i <= k; i++){
+    for(i = 1; i <= k; i++)
+    {
         current_gen = df_gen_repr[i][1];
         current_coef = df_gen_repr[i][2];
         j = difformDeg(current_gen);
 
-        if(j == 0){
+        if(j == 0)
+	{
             homog_part[n+1] = homog_part[n+1] + current_coef*current_gen;
-        }else{
+        }
+	else
+	{
             homog_part[j] = homog_part[j] + current_coef*current_gen;
         }
     }
-
     return(homog_part);
-
 }
 example
@@ -1686,7 +1626,7 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
-//------------------------ Procedures for lists of differential forms ------------------------//
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//--------------- Procedures for lists of differential forms -----------------//
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1699,20 +1639,18 @@
 EXAMPLE:    example difformListCont; shows an example"
 {
-
-    diffAlgebraCheck();
-
     int n = size(L);
     int i;
 
-    for(i = 1; i <= n; i++){
-        if(typeof(L[i]) == "difform"){
-            if(difformEqu(df,L[i])){
+    for(i = 1; i <= n; i++)
+    {
+        if(typeof(L[i]) == "difform")
+	{
+            if(difformEqu(df,L[i]))
+	    {
                 return(1);
             }
         }
     }
-
     return(0);
-
 }
 example
@@ -1742,5 +1680,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1768,7 +1706,4 @@
 EXAMPLE:    example difformListSort; shows an example"
 {
-
-    diffAlgebraCheck();
-
     list orderings = #;
     int n = size(orderings);
@@ -1778,7 +1713,10 @@
 
     // Check for double list
-    for(i = 1; i <= n; i++){
-        if(typeof(orderings[i]) == "string"){
-            if(orderings[i] == "Dlist"){
+    for(i = 1; i <= n; i++)
+    {
+        if(typeof(orderings[i]) == "string")
+	{
+            if(orderings[i] == "Dlist")
+	    {
                 Dlist_flag = 1;
                 orderings = delete(orderings,i);
@@ -1788,7 +1726,10 @@
 
     // Check for list of lists
-    for(i = 1; i <= n; i++){
-        if(typeof(orderings[i]) == "string"){
-            if(orderings[i] == "Llist"){
+    for(i = 1; i <= n; i++)
+    {
+        if(typeof(orderings[i]) == "string")
+	{
+            if(orderings[i] == "Llist")
+	    {
                 Llist_flag = 1;
                 orderings = delete(orderings,i);
@@ -1798,10 +1739,12 @@
 
     // Not both list forms allowed
-    if(Dlist_flag == 1 && Llist_flag == 1){
+    if(Dlist_flag == 1 && Llist_flag == 1)
+    {
         ERROR("Cannot sort double list of lists!");
     }
 
     // Double list detected
-    if(Dlist_flag == 1){
+    if(Dlist_flag == 1)
+    {
         poly temp_form_sec;
         list L_sec = L[2];
@@ -1810,5 +1753,6 @@
 
     // List of lists detected
-    if(Llist_flag == 1){
+    if(Llist_flag == 1)
+    {
         poly temp_form_sec;
         n = size(L);
@@ -1817,5 +1761,6 @@
 
         // Transform list of lists to double list
-        for(i = 1; i <= n; i++){
+        for(i = 1; i <= n; i++)
+	{
             L_temp[i] = L[i][1];
             L_sec[i] = L[i][2];
@@ -1829,8 +1774,10 @@
     n = size(L);
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         temp_form = L[i];
 
-        if(Dlist_flag == 1 || Llist_flag == 1){
+        if(Dlist_flag == 1 || Llist_flag == 1)
+	{
             temp_form_sec = L_sec[i];
         }
@@ -1838,14 +1785,19 @@
         j = i;
 
-        while(j > 1){
-            if(difformIsBigger(L[j-1],temp_form,orderings)){
+        while(j > 1)
+	{
+            if(difformIsBigger(L[j-1],temp_form,orderings))
+	    {
                 L[j] = L[j-1];
 
-                if(Dlist_flag == 1 || Llist_flag == 1){
+                if(Dlist_flag == 1 || Llist_flag == 1)
+		{
                     L_sec[j] = L_sec[j-1];
                 }
 
                 j--;
-            }else{
+            }
+	    else
+	    {
                 break;
             }
@@ -1854,5 +1806,6 @@
         L[j] = temp_form;
 
-        if(Dlist_flag == 1 || Llist_flag == 1){
+        if(Dlist_flag == 1 || Llist_flag == 1)
+	{
             L_sec[j] = temp_form_sec;
         }
@@ -1860,12 +1813,15 @@
 
     // For double list - return a double list
-    if(Dlist_flag == 1){
+    if(Dlist_flag == 1)
+    {
         return(list(L,L_sec));
     }
 
     // For list of lists - return a list of lists
-    if(Llist_flag == 1){
+    if(Llist_flag == 1)
+    {
         L_temp = list();
-        for(i = 1; i <= n; i++){
+        for(i = 1; i <= n; i++)
+	{
             L_temp[i] = list(L[i],L_sec[i]);
         }
@@ -1873,7 +1829,5 @@
         return(L_temp);
     }
-
     return(L);
-
 }
 example
@@ -1918,7 +1872,7 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
-//------------ Procedures for computing with universal derivation and differential -----------//
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//---- Procedures for computing with universal derivation and differential ---//
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1930,20 +1884,16 @@
 EXAMPLE:    example difformUnivDer; shows an example"
 {
-
-    diffAlgebraCheck();
-
-        difform df = 0;
+    difform df = 0;
     difform d_var;
-        int n = size(ringlist(basering)[2]);
-        int i;
-
-        // Build the image under the universal derivation
-        for(i = 1; i <= n; i++){
+    int n = size(ringlist(basering)[2]);
+    int i;
+
+    // Build the image under the universal derivation
+    for(i = 1; i <= n; i++)
+    {
         execute("d_var = d" + string(var(i)));
                 df = df + diff(f,var(i))*d_var;
-        }
-
-        return(df);
-
+    }
+    return(df);
 }
 example
@@ -1965,5 +1915,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -1980,7 +1930,4 @@
 EXAMPLE:    example difformDiff; shows an example"
 {
-
-    diffAlgebraCheck();
-
     difform d_df = 0;
     list df_gen_repr = difformCoef(df);
@@ -1989,10 +1936,9 @@
 
     // Derivate each coefficient
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         d_df = d_df + difformUnivDer(df_gen_repr[i][2])*df_gen_repr[i][1];
     }
-
     return(d_df);
-
 }
 example
@@ -2025,14 +1971,14 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-//                               Procedures for type derivation                               //
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-//----------------------------------- Structural procedures ----------------------------------//
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//                      Procedures for type derivation                        //
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////
+//-------------------------- Structural procedures ---------------------------//
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2051,7 +1997,4 @@
 EXAMPLE:    example derivationFromList; shows an example"
 {
-
-    diffAlgebraCheck();
-
     // Check the structure of the given list
     derivationCheckList(L);
@@ -2062,7 +2005,5 @@
     derivation phi;
     phi.genIm = L;
-
     return(phi);
-
 }
 example
@@ -2095,5 +2036,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2111,14 +2052,14 @@
 SEE ALSO:   derivationFromList, difformIsGen, difformListCont"
 {
-
-    if(size(L) != 2){
+    if(size(L) != 2)
+    {
         ERROR("Given list has wrong size!");
     }
-
-    if(typeof(L[1]) != "list" || typeof(L[2]) != "list"){
+    if(typeof(L[1]) != "list" || typeof(L[2]) != "list")
+    {
         ERROR("Given list does not contain lists!");
     }
-
-    if(size(L[1]) != size(L[2])){
+    if(size(L[1]) != size(L[2]))
+    {
         ERROR("Given list does not have the right form!");
     }
@@ -2128,16 +2069,20 @@
 
     // Need an image for any generator
-    if(n != size(ringlist(basering)[2])){
+    if(n != size(ringlist(basering)[2]))
+    {
         ERROR("Given list has wrong size!");
     }
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         // Right type needed
-        if(typeof(L[1][i]) != "difform" || (typeof(L[2][i]) != "poly" && typeof(L[2][i]) != "int" && typeof(L[2][i]) != "number")){
+        if(typeof(L[1][i]) != "difform" || (typeof(L[2][i]) != "poly" && typeof(L[2][i]) != "int" && typeof(L[2][i]) != "number"))
+	{
             ERROR("Given list contains wrong type!");
         }
 
         // Generator of Omega_R^1
-        if(!(difformIsGen(L[1][i]) && deg(L[1][i]) == 1)){
+        if(!(difformIsGen(L[1][i]) && deg(L[1][i]) == 1))
+	{
             ERROR("Given list contains a non-generator or a generator not of degree 1!");
         }
@@ -2146,7 +2091,9 @@
     // Now check the list L[1] for duplicates of the generators
     list L_i;
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         L_i = delete(L[1],i);
-        if(difformListCont(L_i,L[1][i])){
+        if(difformListCont(L_i,L[1][i]))
+	{
             ERROR("Given list contains duplicate of a generator!");
         }
@@ -2155,5 +2102,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2167,7 +2114,4 @@
 EXAMPLE:    example derivationFromPoly; shows an example"
 {
-
-    diffAlgebraCheck();
-
     list L;
     // First entry of list are the degree-1 generators
@@ -2179,5 +2123,6 @@
     int n = size(L[1]);
     int i;
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         L[2][i] = f;
     }
@@ -2187,5 +2132,4 @@
     phi.genIm = L;
     return(phi);
-
 }
 example
@@ -2206,5 +2150,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2220,10 +2164,11 @@
 EXAMPLE:    example derivationConstructor; shows an example"
 {
-
-    if(typeof(inp) == "list"){
+    if(typeof(inp) == "list")
+    {
         derivation der_cons = derivationFromList(inp);
         return(der_cons);
     }
-    if(typeof(inp) == "poly" || typeof(inp) == "number" || typeof(inp) == "int" || typeof(inp) == "bigint"){
+    if(typeof(inp) == "poly" || typeof(inp) == "number" || typeof(inp) == "int" || typeof(inp) == "bigint")
+    {
         derivation der_cons = derivationFromPoly(inp);
         return(der_cons);
@@ -2266,6 +2211,4 @@
 EXAMPLE:    example derivationToString; shows an example"
 {
-
-    diffAlgebraCheck();
     list temp_genIm = phi.genIm;
 
@@ -2275,9 +2218,13 @@
     int i;
 
-    for(i = 1; i <= n; i++){
-        if(typeof(#[i]) == "string"){
-            if(#[i] == "gen" && typeof(#[i+1]) == "string"){
+    for(i = 1; i <= n; i++)
+    {
+        if(typeof(#[i]) == "string")
+	{
+            if(#[i] == "gen" && typeof(#[i+1]) == "string")
+	    {
                 gen_ord = #[i+1];
-                if(typeof(#[i+2]) == "intvec"){
+                if(typeof(#[i+2]) == "intvec")
+		{
                     intvec gen_weight = #[i+2];
                 }
@@ -2287,8 +2234,12 @@
 
     // Sort the generator/coefficients by the chosen ordering
-    if(gen_ord != ""){
-        if(defined(gen_weight)){
+    if(gen_ord != "")
+    {
+        if(defined(gen_weight))
+	{
             temp_genIm = difformListSort(temp_genIm,"Dlist","gen",gen_ord,gen_weight);
-        }else{
+        }
+	else
+	{
             temp_genIm = difformListSort(temp_genIm,"Dlist","gen",gen_ord);
         }
@@ -2304,10 +2255,10 @@
     int ring_name_size = size(ring_name);
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         phi_out = phi_out + tab(6 + ring_name_size) + difformGenToString(gens[i]) + " |--> " + string(images[i]) + newline;
     }
 
     return(phi_out);
-
 }
 example
@@ -2336,5 +2287,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2347,8 +2298,6 @@
 EXAMPLE:        example derivationPrint; shows an example"
 {
-
     // Orders the generators in ls-order
     print(derivationToString(phi,"gen","ls"));
-
 }
 example
@@ -2377,7 +2326,7 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
-//------------------------------ Basic computational procedures ------------------------------//
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//-------------------- Basic computational procedures ------------------------//
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2392,7 +2341,4 @@
 EXAMPLE:    example derivationAdd; shows an example"
 {
-
-    diffAlgebraCheck();
-
     // Structure for derivation
     derivation add_der;
@@ -2405,5 +2351,6 @@
     int i;
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         // Lists are sorted the same way
         add_list[2][i] = phi.genIm[2][i] + psi.genIm[2][i];
@@ -2413,5 +2360,4 @@
     add_der.genIm = add_list;
     return(add_der);
-
 }
 example
@@ -2443,5 +2389,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2456,7 +2402,4 @@
 EXAMPLE:    example derivationSub; shows an example"
 {
-
-    diffAlgebraCheck();
-
     // Structure for derivation
     derivation sub_der;
@@ -2469,5 +2412,6 @@
     int i;
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         // Lists are sorted the same way
         sub_list[2][i] = phi.genIm[2][i] - psi.genIm[2][i];
@@ -2477,5 +2421,4 @@
     sub_der.genIm = sub_list;
     return(sub_der);
-
 }
 example
@@ -2507,5 +2450,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2517,7 +2460,4 @@
 EXAMPLE:    example derivationNeg; shows an example"
 {
-
-    diffAlgebraCheck();
-
     // Structure for derivation
     derivation neg_der;
@@ -2530,5 +2470,6 @@
     int i;
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         neg_list[2][i] = -phi.genIm[2][i];
     }
@@ -2537,5 +2478,4 @@
     neg_der.genIm = neg_list;
     return(neg_der);
-
 }
 example
@@ -2566,5 +2506,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2578,7 +2518,4 @@
 EXAMPLE:    derivationMul; shows an example"
 {
-
-    diffAlgebraCheck();
-
     // Structure for derivation
     derivation mul_der;
@@ -2591,5 +2528,6 @@
     int i;
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         // Lists are sorted the same way
         mul_list[2][i] = phi.genIm[2][i]*psi.genIm[2][i];
@@ -2599,5 +2537,4 @@
     mul_der.genIm = mul_list;
     return(mul_der);
-
 }
 example
@@ -2629,5 +2566,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2642,13 +2579,12 @@
 EXAMPLE:    example derivationEqu; shows an example"
 {
-
-    diffAlgebraCheck();
-
     int n = size(phi.genIm[1]);
     int i;
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         // Lists are sorted the same way
-        if(phi.genIm[2][i] != psi.genIm[2][i]){
+        if(phi.genIm[2][i] != psi.genIm[2][i])
+	{
             // Different images
             return(0);
@@ -2658,5 +2594,4 @@
     // Images are the same
     return(1);
-
 }
 example
@@ -2687,5 +2622,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2699,7 +2634,5 @@
 EXAMPLE:    example derivationNeq; shows an example"
 {
-
     return(!derivationEqu(phi,psi));
-
 }
 example
@@ -2730,5 +2663,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2747,12 +2680,11 @@
 EXAMPLE:    example derivationEval; shows an example"
 {
-
-    diffAlgebraCheck();
-
-    if(!homog(df)){
+    if(!homog(df))
+    {
         ERROR("Cannot apply derivation to non-homogeneous element!");
     }
 
-    if(deg(df) != 1 && deg(df) != -1){
+    if(deg(df) != 1 && deg(df) != -1)
+    {
         ERROR("Cannot apply derivation to differential form not of degree 1!");
     }
@@ -2765,10 +2697,13 @@
     int j = 1;
 
-    for(i = 1; i <= n; i++){
+    for(i = 1; i <= n; i++)
+    {
         // Both lists are sorted by the monomial ordering on the differential algebra
         // So the generators are sorted the same way in both lists
         // If given df does not involve all generators avoid gaps using j
-        if(j <= k){
-            if(df_gen_repr[j][1] == phi.genIm[1][i]){
+        if(j <= k)
+	{
+            if(df_gen_repr[j][1] == phi.genIm[1][i])
+	    {
                 df_eval = df_eval + df_gen_repr[j][2]*phi.genIm[2][i];
                 j++;
@@ -2776,7 +2711,5 @@
         }
     }
-
     return(df_eval);
-
 }
 example
@@ -2819,7 +2752,7 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
-//----------------------- Procedures for computing the Lie-Derivative ------------------------//
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//------------ Procedures for computing the Lie-Derivative -------------------//
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2834,5 +2767,4 @@
 SEE ALSO:   derivationContraction"
 {
-
     // Sort the list, that dx_1 is the first form, dx_2 the second,...
     list gen_list = phi.genIm[1];
@@ -2845,6 +2777,8 @@
 
     // Go through all degree-1 generators and test if, dx_i occurs in d_gen
-    for(i = 1; i <= n; i++){
-        if(d_gen / gen_list[i] != 0){
+    for(i = 1; i <= n; i++)
+    {
+        if(d_gen / gen_list[i] != 0)
+	{
             applic = applic + ((-1)^(j+1))*derivationEval(phi,gen_list[i])*(d_gen/gen_list[i]);
             j++;
@@ -2855,5 +2789,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2869,7 +2803,4 @@
 EXAMPLE:    example derivationContraction; shows an example"
 {
-
-    diffAlgebraCheck();
-
     list coef_list = difformCoef(df);
     int k = size(coef_list);
@@ -2878,10 +2809,9 @@
 
     // Apply the contraction map to the generators since it is linear
-    for(i = 1; i <= k; i++){
+    for(i = 1; i <= k; i++)
+    {
         applic = applic + coef_list[i][2]*derivationContractionGen(phi,coef_list[i][1]);
     }
-
     return(applic);
-
 }
 example
@@ -2917,5 +2847,5 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
@@ -2930,8 +2860,6 @@
 EXAMPLE:    example derivationLie; shows an example"
 {
-
     difform lie_form = derivationContraction(phi,difformDiff(df)) + difformDiff(derivationContraction(phi,df));
     return(lie_form);
-
 }
 example
@@ -2969,67 +2897,68 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-//                                       Test examples                                        //
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+//                             Test examples                                  //
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: differential algebra over ring of characteristic 0
-proc diffAlgebra_example_1(){
+proc diffAlgebra_example_1()
+{
     ring R = 0,(x,y,z),dp;
     diffAlgebra();
-
     exportto(Top,R);
 }
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: differential algebra over big ring of characteristic 0 and block ordering
-proc diffAlgebra_example_2(){
+proc diffAlgebra_example_2()
+{
     ring R = 0,(a,b,x,y,z,t,s,e,r,w,i),(ls(3),dp(4),lp);
     diffAlgebra();
-
     exportto(Top,R);
 }
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: differential algebra over ring of positive characteristic
-proc diffAlgebra_example_3(){
+proc diffAlgebra_example_3()
+{
     ring R = 31,(a,b,x),dp;
     diffAlgebra();
-
     exportto(Top,R);
 }
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: differential algebra over quotient ring
-proc diffAlgebra_example_4(){
+proc diffAlgebra_example_4()
+{
     ring S = 0,(x,y,z),lp;
     ideal I = x2-y4,xyz;
     qring R = std(I);
     diffAlgebra();
-
     exportto(Top,R);
 }
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: differential form over ring of characteristic 0
-proc difform_example_1(){
+proc difform_example_1()
+{
     ring R = 0,(x,y,z),ds;
     diffAlgebra();
@@ -3042,9 +2971,10 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: differential form over ring of positive characteristic
-proc difform_example_2(){
+proc difform_example_2()
+{
     ring R = 31,(x,y,z,a,b,c),lp;
     diffAlgebra();
@@ -3057,9 +2987,10 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: derivation by list
-proc derivation_example_1(){
+proc derivation_example_1()
+{
     ring R = 0,(x,y,z),lp;
     diffAlgebra();
@@ -3076,9 +3007,10 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: derivation by list
-proc derivation_example_2(){
+proc derivation_example_2()
+{
     ring R = 0,(a,b,c,x,y,z),lp;
     diffAlgebra();
@@ -3094,9 +3026,10 @@
 
 
-////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 
 // EXAMPLE: derivations by list
-proc derivation_example_3(){
+proc derivation_example_3()
+{
     ring R = 0,(x,y,z),dp;
     diffAlgebra();
@@ -3121,3 +3054,2 @@
 }
 
-
