diff --git a/pub/lib/func.cpp b/pub/lib/func.cpp
index d73f6017e7c3fa14652211046e0f767b9de42d82..530888f9fbf3ac6da8b8d5e77c1f8b10923449da 100644
--- a/pub/lib/func.cpp
+++ b/pub/lib/func.cpp
@@ -402,23 +402,20 @@ void NFunctions::display_functions()
     // first operators by precedence, then functions.
 
     cout << "Operators by precedence:\n";
-    cout << flist.size() << "\n";
-//    int prec = -1;
+    int prec = -1;
     for( int i=0; i<flist.size(); ++i ){
         const CFunc *f;
         f = flist[i];
-        cout << i << "\n";
-        cout << f->txt << "\n";
-//        if( f->prec ) { // operators
-//            if( f->prec!=prec )
-//                cout << "\n ";
-//            cout << " " << f->txt;
-//        } /*else { // functions
-//            if( f->prec!=prec )
-//                cout << "\nBuilt-in functions:\n";
-//            cout << "  " << f->txt << f->com << "\n";
-//            }*/
-//        prec = f->prec;
+        if( f->prec ) { // operators
+            if( f->prec!=prec )
+                cout << "\n ";
+            cout << " " << f->txt;
+        } else { // functions
+            if( f->prec!=prec )
+                cout << "\nBuilt-in functions:\n";
+            cout << "  " << f->txt << f->com << "\n";
+            }
+        prec = f->prec;
     }
 }
 
@@ -431,186 +428,186 @@ void CFunc::register_me() const
 void NFunctions::initialize(void)
 {
     // operators by precedence (as in xax_yacc.ypp):
-    CFunc2( "+-",  func_pm,   deri_pm,    1   ).register_me();
-    CFunc2( "^",   func_pow,  deri_pow,   2   ).register_me();
-    CFunc1( "!",   func_not,  0,          3   ).register_me();
-    CFunc1( "neg", func_neg,  deri_neg,   4   ).register_me();
-    CFunc2( "over",func_over, 0,          5   ).register_me();
-    CFunc2( "*",   func_mul,  deri_mul,   6   ).register_me();
-    CFunc2( "/",   func_div,  deri_div,   6   ).register_me();
-    CFunc2( "mod", func_mod,  0,          6   ).register_me();
-    CFunc2( "div", func_idiv, 0,          6   ).register_me();
-    CFunc2( "+",   func_add,  deri_add,   7   ).register_me();
-    CFunc2( "-",   func_sub,  deri_sub,   7   ).register_me();
-    CFunc2( ">",   func_gt,   0,          8   ).register_me();
-    CFunc2( ">=",  func_ge,   0,          8   ).register_me();
-    CFunc2( "<",   func_lt,   0,          8   ).register_me();
-    CFunc2( "<=",  func_le,   0,          8   ).register_me();
-    CFunc2( "==",  func_eq,   0,          9   ).register_me();
-    CFunc2( "!=",  func_ne,   0,          9   ).register_me();
-    CFunc2( "xor", func_xor,  0,         10   ).register_me();
-    CFunc2( "&&",  func_and,  0,         11   ).register_me();
-    CFunc2( "||",  func_or ,  0,         12   ).register_me();
-    CFunc3( "?:",  func_cond, deri_cond, 13 ).register_me();
+    (new CFunc2( "+-",  func_pm,   deri_pm,    1   ))->register_me();
+    (new CFunc2( "^",   func_pow,  deri_pow,   2   ))->register_me();
+    (new CFunc1( "!",   func_not,  0,          3   ))->register_me();
+    (new CFunc1( "neg", func_neg,  deri_neg,   4   ))->register_me();
+    (new CFunc2( "over",func_over, 0,          5   ))->register_me();
+    (new CFunc2( "*",   func_mul,  deri_mul,   6   ))->register_me();
+    (new CFunc2( "/",   func_div,  deri_div,   6   ))->register_me();
+    (new CFunc2( "mod", func_mod,  0,          6   ))->register_me();
+    (new CFunc2( "div", func_idiv, 0,          6   ))->register_me();
+    (new CFunc2( "+",   func_add,  deri_add,   7   ))->register_me();
+    (new CFunc2( "-",   func_sub,  deri_sub,   7   ))->register_me();
+    (new CFunc2( ">",   func_gt,   0,          8   ))->register_me();
+    (new CFunc2( ">=",  func_ge,   0,          8   ))->register_me();
+    (new CFunc2( "<",   func_lt,   0,          8   ))->register_me();
+    (new CFunc2( "<=",  func_le,   0,          8   ))->register_me();
+    (new CFunc2( "==",  func_eq,   0,          9   ))->register_me();
+    (new CFunc2( "!=",  func_ne,   0,          9   ))->register_me();
+    (new CFunc2( "xor", func_xor,  0,         10   ))->register_me();
+    (new CFunc2( "&&",  func_and,  0,         11   ))->register_me();
+    (new CFunc2( "||",  func_or ,  0,         12   ))->register_me();
+    (new CFunc3( "?:",  func_cond, deri_cond, 13 ))->register_me();
 
     // f( 1 arg )
-    CFunc1( "ln",   func_ln,    deri_ln, 0,
-           "(x): natural logarithm of x, or 0 if x<=0" ).register_me();
-    CFunc1( "lg",   func_lg,    deri_lg, 0,
-           "(x): decadic logarithm of x, or 0 if x<=0" ).register_me();
-    CFunc1( "sqrt", func_sqrt,  deri_sqrt, 0,
-           "(x): square root of x, or 0 if x<0" ).register_me();
-    CFunc1( "abs",  func_abs,   deri_abs, 0,
-           "(x): absolute value of x" ).register_me();
-    CFunc1( "abs",  func_sign,   deri_sign, 0,
-           "(x): sign of x" ).register_me();
-    CFunc1( "exp",  func_exp,   deri_exp, 0,
-           "(x): exponential function of x" ).register_me();
-    CFunc1( "sin",  func_sin, 0, 0,
-           "(x): sine of x (where x in radian)" ).register_me();
-    CFunc1( "cos",  func_cos, 0, 0,
-           "(x): cosine of x (where x in radian)" ).register_me();
-    CFunc1( "tan",  func_tan, 0, 0,
-           "(x): tangent of x (where x in radian)" ).register_me();
-    CFunc1( "cot",  func_cot, 0, 0,
-           "(x): cotangent of x (where x in radian)" ).register_me();
-    CFunc1( "sind",  func_sind, 0, 0,
-           "(x): sine of x (where x in degrees)" ).register_me();
-    CFunc1( "cosd",  func_cosd, 0, 0,
-           "(x): cosine of x (where x in degrees)" ).register_me();
-    CFunc1( "tand",  func_tand, 0, 0,
-           "(x): tangent of x (where x in degrees)" ).register_me();
-    CFunc1( "cotd",  func_cotd, 0, 0,
-           "(x): cotangent of x (where x in degrees)" ).register_me();
-    CFunc1( "asin", func_asin, 0, 0,
+    (new CFunc1( "ln",   func_ln,    deri_ln, 0,
+           "(x): natural logarithm of x, or 0 if x<=0" ))->register_me();
+    (new CFunc1( "lg",   func_lg,    deri_lg, 0,
+           "(x): decadic logarithm of x, or 0 if x<=0" ))->register_me();
+    (new CFunc1( "sqrt", func_sqrt,  deri_sqrt, 0,
+           "(x): square root of x, or 0 if x<0" ))->register_me();
+    (new CFunc1( "abs",  func_abs,   deri_abs, 0,
+           "(x): absolute value of x" ))->register_me();
+    (new CFunc1( "abs",  func_sign,   deri_sign, 0,
+           "(x): sign of x" ))->register_me();
+    (new CFunc1( "exp",  func_exp,   deri_exp, 0,
+           "(x): exponential function of x" ))->register_me();
+    (new CFunc1( "sin",  func_sin, 0, 0,
+           "(x): sine of x (where x in radian)" ))->register_me();
+    (new CFunc1( "cos",  func_cos, 0, 0,
+           "(x): cosine of x (where x in radian)" ))->register_me();
+    (new CFunc1( "tan",  func_tan, 0, 0,
+           "(x): tangent of x (where x in radian)" ))->register_me();
+    (new CFunc1( "cot",  func_cot, 0, 0,
+           "(x): cotangent of x (where x in radian)" ))->register_me();
+    (new CFunc1( "sind",  func_sind, 0, 0,
+           "(x): sine of x (where x in degrees)" ))->register_me();
+    (new CFunc1( "cosd",  func_cosd, 0, 0,
+           "(x): cosine of x (where x in degrees)" ))->register_me();
+    (new CFunc1( "tand",  func_tand, 0, 0,
+           "(x): tangent of x (where x in degrees)" ))->register_me();
+    (new CFunc1( "cotd",  func_cotd, 0, 0,
+           "(x): cotangent of x (where x in degrees)" ))->register_me();
+    (new CFunc1( "asin", func_asin, 0, 0,
            "(x): arc sine of x (result is in radian; return 0 if |x|>1)"
-        ).register_me();
-    CFunc1( "acos", func_acos, 0, 0,
+        ))->register_me();
+    (new CFunc1( "acos", func_acos, 0, 0,
            "(x): arc cosine of x (result is in radian; return 0 if |x|>1)"
-        ).register_me();
-    CFunc1( "atan", func_atan, 0, 0,
-           "(x): arc tangent of x (result is in radian)" ).register_me();
-    CFunc1( "acot", func_acot, 0, 0,
-           "(x): arc cotangent of x (result is in radian)" ).register_me();
-    CFunc1( "asind", func_asind, 0, 0,
+        ))->register_me();
+    (new CFunc1( "atan", func_atan, 0, 0,
+           "(x): arc tangent of x (result is in radian)" ))->register_me();
+    (new CFunc1( "acot", func_acot, 0, 0,
+           "(x): arc cotangent of x (result is in radian)" ))->register_me();
+    (new CFunc1( "asind", func_asind, 0, 0,
            "(x): arc sine of x (result is in degrees; return 0 if |x|>1)"
-        ).register_me();
-    CFunc1( "acosd", func_acosd, 0, 0,
+        ))->register_me();
+    (new CFunc1( "acosd", func_acosd, 0, 0,
            "(x): arc cosine of x (result is in degrees; return 0 if |x|>1)"
-        ).register_me();
-    CFunc1( "atand", func_atand, 0, 0,
-           "(x): arc tangent of x (result is in degrees)" ).register_me();
-    CFunc1( "acotd", func_acotd, 0, 0,
-           "(x): arc cotangent of x (result is in degrees)" ).register_me();
-    CFunc1( "sinh", func_sinh, 0, 0,
-           "(x): hyperbolic sine of x" ).register_me();
-    CFunc1( "cosh", func_cosh, 0, 0,
-           "(x): hyperbolic cosine of x" ).register_me();
-    CFunc1( "tanh", func_tanh, 0, 0,
-           "(x): hyperbolic tangent of x" ).register_me();
-    CFunc1( "coth", func_coth, 0, 0,
-           "(x): hyperbolic tangent of x" ).register_me();
-    CFunc1( "j0", func_j0, 0, 0,
-           "(x): spherical Bessel function x" ).register_me();
-    CFunc1( "j1", func_j1, 0, 0,
-           "(x): spherical Bessel function x" ).register_me();
-    CFunc1( "fac",func_fac, 0, 0,
-           "(x): factorial of nearest integer of x" ).register_me();
-    CFunc1( "cata",func_cata, 0, 0,
-           "(x): Catalan number of nearest integer of x" ).register_me();
-    CFunc1( "gamma",func_gamma, 0, 0,
-           "(x): gamma function of x (i.e. factorial of x-1)" ).register_me();
-    CFunc1( "lgamma",func_lgamma, 0, 0,
-           "(x): ln of gamma of x" ).register_me();
-    CFunc1( "debye1",func_debye1, 0, 0,
-           "(x): Debye function D1 of x" ).register_me();
-    CFunc1( "debye3",func_debye3, 0, 0,
-           "(x): Debye function D3 of x" ).register_me();
-    CFunc1( "debyeu2",func_debye_msd, 0, 0,
+        ))->register_me();
+    (new CFunc1( "atand", func_atand, 0, 0,
+           "(x): arc tangent of x (result is in degrees)" ))->register_me();
+    (new CFunc1( "acotd", func_acotd, 0, 0,
+           "(x): arc cotangent of x (result is in degrees)" ))->register_me();
+    (new CFunc1( "sinh", func_sinh, 0, 0,
+           "(x): hyperbolic sine of x" ))->register_me();
+    (new CFunc1( "cosh", func_cosh, 0, 0,
+           "(x): hyperbolic cosine of x" ))->register_me();
+    (new CFunc1( "tanh", func_tanh, 0, 0,
+           "(x): hyperbolic tangent of x" ))->register_me();
+    (new CFunc1( "coth", func_coth, 0, 0,
+           "(x): hyperbolic tangent of x" ))->register_me();
+    (new CFunc1( "j0", func_j0, 0, 0,
+           "(x): spherical Bessel function x" ))->register_me();
+    (new CFunc1( "j1", func_j1, 0, 0,
+           "(x): spherical Bessel function x" ))->register_me();
+    (new CFunc1( "fac",func_fac, 0, 0,
+           "(x): factorial of nearest integer of x" ))->register_me();
+    (new CFunc1( "cata",func_cata, 0, 0,
+           "(x): Catalan number of nearest integer of x" ))->register_me();
+    (new CFunc1( "gamma",func_gamma, 0, 0,
+           "(x): gamma function of x (i.e. factorial of x-1)" ))->register_me();
+    (new CFunc1( "lgamma",func_lgamma, 0, 0,
+           "(x): ln of gamma of x" ))->register_me();
+    (new CFunc1( "debye1",func_debye1, 0, 0,
+           "(x): Debye function D1 of x" ))->register_me();
+    (new CFunc1( "debye3",func_debye3, 0, 0,
+           "(x): Debye function D3 of x" ))->register_me();
+    (new CFunc1( "debyeu2",func_debye_msd, 0, 0,
            "(x): Debye mean squared displacement's temperature dependence"
-        ).register_me();
-    CFunc1( "debyeui",func_debye_ui, 0, 0,
-           "(x): Debye internal energy" ).register_me();
-    CFunc1( "debyecv",func_debye_cv, 0, 0,
-           "(x): Debye heat capacity" ).register_me();
-    CFunc1( "erfP", func_erfP, 0, 0,
-           "(x): ?" ).register_me();
-    CFunc1( "erfQ", func_erfQ , 0, 0,
-           "(x): ?"  ).register_me();
-    CFunc1( "erf",  func_erf, 0, 0,
-           "(x): error function of x" ).register_me();
-    CFunc1( "erfc", func_erfc, 0, 0,
-           "(x): complementary error function of x" ).register_me();
-    CFunc1( "dawson", func_dawson, 0, 0,
-           "(x): Dawson function of x" ).register_me();
-    CFunc1( "sinc", func_sinc, 0, 0,
-           "(x): sinus cardinalis, sin(x)/x" ).register_me();
-    CFunc1( "ceil", func_ceil, 0, 0,
-           "(x): the smallest integer i with i>=x" ).register_me();
-    CFunc1( "floor",func_floor, 0, 0,
-           "(x): the largest integer i with i<=x" ).register_me();
-    CFunc1( "nint", func_nint, 0, 0,
-           "(x): the integer nearest to x" ).register_me();
-
-    CFunc1( "diehl", func_diehl, 0, 0,
+        ))->register_me();
+    (new CFunc1( "debyeui",func_debye_ui, 0, 0,
+           "(x): Debye internal energy" ))->register_me();
+    (new CFunc1( "debyecv",func_debye_cv, 0, 0,
+           "(x): Debye heat capacity" ))->register_me();
+    (new CFunc1( "erfP", func_erfP, 0, 0,
+           "(x): ?" ))->register_me();
+    (new CFunc1( "erfQ", func_erfQ , 0, 0,
+           "(x): ?"  ))->register_me();
+    (new CFunc1( "erf",  func_erf, 0, 0,
+           "(x): error function of x" ))->register_me();
+    (new CFunc1( "erfc", func_erfc, 0, 0,
+           "(x): complementary error function of x" ))->register_me();
+    (new CFunc1( "dawson", func_dawson, 0, 0,
+           "(x): Dawson function of x" ))->register_me();
+    (new CFunc1( "sinc", func_sinc, 0, 0,
+           "(x): sinus cardinalis, sin(x)/x" ))->register_me();
+    (new CFunc1( "ceil", func_ceil, 0, 0,
+           "(x): the smallest integer i with i>=x" ))->register_me();
+    (new CFunc1( "floor",func_floor, 0, 0,
+           "(x): the largest integer i with i<=x" ))->register_me();
+    (new CFunc1( "nint", func_nint, 0, 0,
+           "(x): the integer nearest to x" ))->register_me();
+
+    (new CFunc1( "diehl", func_diehl, 0, 0,
            "(cauchywid/gausswid): normalized convolution gauss(*)cauchy"
-        ).register_me();
-    CFunc1( "lndiehl", func_lndiehl, 0, 0,
+        ))->register_me();
+    (new CFunc1( "lndiehl", func_lndiehl, 0, 0,
            "(cauchywid/gausswid): ln of normalized convolution gauss(*)cauchy"
-        ).register_me();
+        ))->register_me();
 
 
     // f(2 args)
-    CFunc2( "min",  func_min, 0, 0,
-           "(x,y): the smaller of the two arguments x and y" ).register_me();
-    CFunc2( "max",  func_max, 0, 0,
-           "(x,y): the smaller of the two arguments x and y" ).register_me();
-    CFunc2( "ran",  func_ran, 0, 0,
-           "(x,y): a random number between x and y" ).register_me();
-
-    CFunc2( "gauss",   func_gauss, 0, 0,
+    (new CFunc2( "min2",  func_min, 0, 0,
+           "(x,y): the smaller of the two arguments x and y" ))->register_me();
+    (new CFunc2( "max2",  func_max, 0, 0,
+           "(x,y): the smaller of the two arguments x and y" ))->register_me();
+    (new CFunc2( "ran",  func_ran, 0, 0,
+           "(x,y): a random number between x and y" ))->register_me();
+
+    (new CFunc2( "gauss",   func_gauss, 0, 0,
            "(x,s): the normalized Gaussian exp(-x^2/2/s^2)/sqrt(2 pi)/s"
-        ).register_me();
-    CFunc2( "gnn",     func_gaussnn, 0, 0,
-           "(x,s): the unnormalized Gaussian exp(-x^2/2/s^2)" ).register_me();
-    CFunc2( "cauchy",  func_cauchy, 0, 0,
-           "(x,w): the Cauchy-Lorentz function ?/(x^2+w^2)" ).register_me();
+        ))->register_me();
+    (new CFunc2( "gnn",     func_gaussnn, 0, 0,
+           "(x,s): the unnormalized Gaussian exp(-x^2/2/s^2)" ))->register_me();
+    (new CFunc2( "cauchy",  func_cauchy, 0, 0,
+           "(x,w): the Cauchy-Lorentz function ?/(x^2+w^2)" ))->register_me();
 
 
     // f(3 args)
-    CFunc3( "rehavneg", func_re_havneg, 0, 0,
+    (new CFunc3( "rehavneg", func_re_havneg, 0, 0,
            "(x,y,z): real part of the Havriliak-Negami function"
-        ).register_me();
-    CFunc3( "imhavneg", func_im_havneg, 0, 0,
+        ))->register_me();
+    (new CFunc3( "imhavneg", func_im_havneg, 0, 0,
            "(x,y,z): imaginary part of the Havriliak-Negami function"
-        ).register_me();
-    CFunc3( "q4w",      func_q4w, 0, 0,
-           "(x,y,z): ?" ).register_me();
-    CFunc3( "cauchy2",  func_cauchy2, 0, 0,
-           "(x,y,z): ?" ).register_me();
-    CFunc3( "kwwc", func_kwwc, 0, 0,
+        ))->register_me();
+    (new CFunc3( "q4w",      func_q4w, 0, 0,
+           "(x,y,z): ?" ))->register_me();
+    (new CFunc3( "cauchy2",  func_cauchy2, 0, 0,
+           "(x,y,z): ?" ))->register_me();
+    (new CFunc3( "kwwc", func_kwwc, 0, 0,
            "(w,tau,b): Fourier cosine transform (t->w) of exp((t/tau)^b)"
-        ).register_me();
-    CFunc3( "kwws", func_kwws, 0, 0,
+        ))->register_me();
+    (new CFunc3( "kwws", func_kwws, 0, 0,
            "(w,tau,b): Fourier sine transform (t->w) of exp((t/tau)^b)"
-        ).register_me();
-    CFunc3( "kwwp", func_kwwp, 0, 0,
+        ))->register_me();
+    (new CFunc3( "kwwp", func_kwwp, 0, 0,
            "(w,tau,b): primitive of "
            "Fourier cosine transform (t->w) of exp((t/tau)^b)"
-        ).register_me();
-    CFunc3( "voigt", func_voigt, 0, 0,
+        ))->register_me();
+    (new CFunc3( "voigt", func_voigt, 0, 0,
            "(x,sigma,gamma): convolution of Gaussian(x,sigma) and "
            "Lorentzian(x,gamma)"
-        ).register_me();
-    CFunc3( "zorn", func_zorn, 0, 0,
+        ))->register_me();
+    (new CFunc3( "zorn", func_zorn, 0, 0,
            "(I,<I>,s): Zorn's multiple-scattering corrected elastic intensity"
-        ).register_me();
-    CFunc3( "zorn2", func_zorn_gauss, 0, 0,
+        ))->register_me();
+    (new CFunc3( "zorn2", func_zorn_gauss, 0, 0,
            "(q,<u^2>,s): Zorn's multiple-scattering corrected Gaussian "
-           "elastic intensity for Si111" ).register_me();
-    CFunc3( "rrdm", func_rrdm, 0, 0,
+           "elastic intensity for Si111" ))->register_me();
+    (new CFunc3( "rrdm", func_rrdm, 0, 0,
            "(w*t0,EA_mean/T,EA_stdv/EA_mean: rotational rate distribution model"
-        ).register_me();
-    CFunc3( "rotdiff", func_rotdiff, 0, 0,
-           "(w,tau,qb: rotational diffusion spectrum)").register_me();
+        ))->register_me();
+    (new CFunc3( "rotdiff", func_rotdiff, 0, 0,
+           "(w,tau,qb: rotational diffusion spectrum)"))->register_me();
 }
diff --git a/pub/lib/node.cpp b/pub/lib/node.cpp
index 1d2cb25615a26c4f8d3a8e26299677a1bb114a47..6ecd71e5c417afc83b6c4e817af5ce49600d8f1f 100644
--- a/pub/lib/node.cpp
+++ b/pub/lib/node.cpp
@@ -244,29 +244,27 @@ CNodeGeni::CNodeGeni( /*const class CFunc *_fun,*/ PNode _a0 )
 void CNodeGeni::tree_val( CResult& ret, const CContext& ctx ) const
 {
     try {
+        if( ctx.dim!=CContext::_1 )
+            throw "Unexpected vectorial context " + ctx.context_info();
+        CContext myctx(ctx);
+        myctx.dim = CContext::_VI;
+        myctx.nv = -1;
         // evaluate arguments,
-        // assert that all results are vectorial,
         CResult a[maxarg];
         for ( int iarg=0; iarg<narg; ++iarg ) {
-            arg[iarg]->tree_val( a[iarg], ctx );
-            if ( !a[iarg].vectorial )
-                throw "argument " + S(iarg) + " of generalized integral " +
-                    tree_info() + " is scalar: " + a[iarg].result_info();
-            if ( !a[iarg].v.size() )
-                throw "BUG: argument " + S(iarg) + " of generalized integral " +
-                    tree_info() + " is empty vector: " + a[iarg].result_info();
+            arg[iarg]->tree_val( a[iarg], myctx );
         }
         // determine size of vectorial arguments
         int n=0;
         for ( int iarg=0; iarg<narg; ++iarg ) {
             if ( !a[iarg].vectorial )
-                continue;
+                throw "argument " + S(iarg) + " of generalized integral " +
+                    tree_info() + " is scalar: " + a[iarg].result_info();
             if ( n==0 )
                 n = a[iarg].v.size();
             else if ( a[iarg].v.size() != n )
                 throw string("vector arguments have different size");
         }
-        ret.preset_v( n, ctx.want_error );
         // now evaluate the function
         int idx = 0;
         double r = a[0].v[0];
@@ -276,6 +274,7 @@ void CNodeGeni::tree_val( CResult& ret, const CContext& ctx ) const
                 idx = i;
             }
         }
+        ret.vectorial = false;
         ret.r = r;
         if( ctx.want_error && a[0].has_err() )
             ret.dr = a[0].dv[idx];
@@ -473,13 +472,16 @@ void CNodeIva::tree_val( CResult& ret, const CContext& ctx ) const
                     } else {
                         int j = ref->get_j( ctx, f->nJ() );
                         PSpec sj = fd->VS(j);
-                        if ( ctx.nv != sj->size() )
+                        int nv = ctx.nv;
+                        if ( nv==-1 ) {
+                            nv = sj->size();
+                        } else if ( nv != sj->size() )
                             throw string("ref_val ") + var->var_info() +
                                 ": requested vec(" + S(ctx.nv) +
                                 "), found vec(" + S( sj->size() );
                         if        ( var->typ == CVar::_I ) {
-                            ret.preset_v( ctx.nv, false );
-                            for( int i=0; i<ctx.nv; ++i )
+                            ret.preset_v( nv, false );
+                            for( int i=0; i<nv; ++i )
                                 ret.v[i] = i;
                         } else if ( var->typ == CVar::_X ) {
                             ret.set_v( sj->x );
diff --git a/pub/lib/xax_lex.lpp b/pub/lib/xax_lex.lpp
index 4efff14c496f6a84f9499b5fbb14c397a1bb52b5..34b635f7f6652ed98589557206bc8fa8529d6370 100644
--- a/pub/lib/xax_lex.lpp
+++ b/pub/lib/xax_lex.lpp
@@ -106,6 +106,9 @@ e {
             xaxlval->p = (void*) f1;
             return FNCT;
         }
+	if ( !strcmp( xaxtext, "valmax" ) ) {
+	   return GENI;
+	}
         throw( "invalid expression: unknown identifier " + string(xaxtext) );
 	return 0;
         }
diff --git a/pub/lib/xax_yacc.ypp b/pub/lib/xax_yacc.ypp
index 45b658d6a12670d6bdde423056401b898dfece2b..3bf2868a5a2f520860ffa44e30da69f1bd57d150 100644
--- a/pub/lib/xax_yacc.ypp
+++ b/pub/lib/xax_yacc.ypp
@@ -67,7 +67,7 @@ int xaxlex(YYSTYPE *xaxlval); // created by lex.l
 %left BOP_PM  /* error */
 
 /* other tokens created by lex.l: */
-%token NUM IDX REF DUMMY CEV FNCT END CONV PCONV DIRAC REG
+%token NUM IDX REF DUMMY CEV FNCT GENI END CONV PCONV DIRAC REG
 
 /* Grammar follows */
 
@@ -100,6 +100,8 @@ exp:                       /* double-valued expression */
       | FNCT '(' exp ',' exp ',' exp ')' {
                              $$.t =  PNode( new CNodeFun(
                                     (CFunc*) $1.p,$3.t,$5.t,$7.t) ); }
+      | GENI '(' exp ')'   { $$.t = PNode( new CNodeGeni(
+                                    /*(CFunc*) $1.p,*/ $3.t) ); }
       | exp '+' exp        { $$.t = BINFUNC("+", $1, $3); }
       | exp '-' exp        { $$.t = BINFUNC("-", $1, $3); }
       | exp '*' exp        { $$.t = BINFUNC("*", $1, $3); }