diff --git a/pub/lib/commands.cpp b/pub/lib/commands.cpp
index e42246e200a9a8750059299d45a9ec2f09209bbe..464a7866e0882b6c4995f3be76ad7c0f2691eb74 100644
--- a/pub/lib/commands.cpp
+++ b/pub/lib/commands.cpp
@@ -8,99 +8,94 @@
 //! \brief Function fridaCommand: executes one main-level command.
 
 #include "defs.hpp"
+#include "ptr.hpp"
 
 #include <cstring>
 
-#include "../trivia/file_ops.hpp"
-#include "../readplus/ask.hpp"
 #include "../plot/dualplot.hpp"
 #include "../plot/plowin.hpp"
+#include "../readplus/ask.hpp"
+#include "../trivia/file_ops.hpp"
 
 #include "config.hpp"
-#include "olf.hpp"
-#include "mem.hpp"
-#include "fsel.hpp"
+#include "curve.hpp"
 #include "edif.hpp"
-#include "import.hpp"
-#include "func.hpp"
-#include "fregistry.hpp"
-#include "reduce_spec.hpp"
-#include "opr.hpp"
-#include "plot.hpp"
+#include "expr.hpp"
 #include "file_in.hpp"
 #include "file_out.hpp"
-#include "rssm.hpp"
-#include "manip.hpp"
-#include "curve.hpp"
 #include "fit.hpp"
-#include "expr.hpp"
+#include "fregistry.hpp"
+#include "fsel.hpp"
+#include "func.hpp"
+#include "import.hpp"
+#include "manip.hpp"
+#include "mem.hpp"
 #include "obj.hpp"
+#include "olf.hpp"
+#include "opr.hpp"
+#include "plot.hpp"
 #include "reduce_curv.hpp"
+#include "reduce_spec.hpp"
+#include "rssm.hpp"
 #include "special.hpp"
 
 
 //! Executes cmd if is a Frida command, and returns true when successful.
 
-bool frida_command( string cmd )
+bool frida_command(string cmd)
 {
     int i;
 
     // Extract overwrite marker:
     SMem::instance()->overwrite = 0;
-    if ( cmd.size()>1 && cmd[cmd.size()-1]=='!' ) {
+    if (cmd.size() > 1 && cmd[cmd.size() - 1] == '!') {
         SMem::instance()->overwrite = 1;
-        cmd.erase(cmd.size()-1,1);
+        cmd.erase(cmd.size() - 1, 1);
     }
 
     // If there are new files, make them new default
     SFSel::instance()->sel_collect_begin();
 
     if (cmd == "h" || cmd == "?") {
-        cout <<
-            "This is Frida, version " VERSION "\n"
-            "Plain commands:\n"
-            "  a    add to plot\n"
-            "  p    plot (g for list of other plot commands)\n"
-            "  t    show execution time (for development)\n"
-            "  !    execute shell command\n"
-            "  quit terminate Frida session\n"
-            "Command groups (type initial letter for help):\n"
-            "  c    curves and fits\n"
-            "  d    directory (inspect internal files)\n"
-            "  e    edit (change textual parameters)\n"
-            "  g    graphics setup\n"
-            "  f    file input, output, creation\n"
-            "  m    manipulate data (select, bin, reorganise, ...)\n"
-            "  o    operate on variables, compute integrals, ...\n"
-            "  r    read raw data (currently only for SPHERES)\n"
-            "  _    special / temporary commands\n"
-            "Modifier (appended to command):\n"
-            "  !    operate in place (overwrite)\n"
-            "More help:\n"
-            "  hc   constants\n"
-            "  hf   functions of scalar arguments\n"
-            "  hid  dimension-reducing functionals of data (replaced 'oio')\n"
-            "  hic  dimension-reducing functionals of curves\n"
-            "  ho   operators by precedence\n"
-            "  hr   handling resolution functions (convolution, Dirac delta function)\n"
-            "  hv   variables\n"
-            "  \\h   meta commands and macros\n"
-            ;
+        cout << "This is Frida, version " VERSION "\n"
+                "Plain commands:\n"
+                "  a    add to plot\n"
+                "  p    plot (g for list of other plot commands)\n"
+                "  t    show execution time (for development)\n"
+                "  !    execute shell command\n"
+                "  quit terminate Frida session\n"
+                "Command groups (type initial letter for help):\n"
+                "  c    curves and fits\n"
+                "  d    directory (inspect internal files)\n"
+                "  e    edit (change textual parameters)\n"
+                "  g    graphics setup\n"
+                "  f    file input, output, creation\n"
+                "  m    manipulate data (select, bin, reorganise, ...)\n"
+                "  o    operate on variables, compute integrals, ...\n"
+                "  r    read raw data (currently only for SPHERES)\n"
+                "  _    special / temporary commands\n"
+                "Modifier (appended to command):\n"
+                "  !    operate in place (overwrite)\n"
+                "More help:\n"
+                "  hc   constants\n"
+                "  hf   functions of scalar arguments\n"
+                "  hid  dimension-reducing functionals of data (replaced 'oio')\n"
+                "  hic  dimension-reducing functionals of curves\n"
+                "  ho   operators by precedence\n"
+                "  hr   handling resolution functions (convolution, Dirac delta function)\n"
+                "  hv   variables\n"
+                "  \\h   meta commands and macros\n";
 
     } else if (cmd == "hc") {
-        cout <<
-            "Constants for use in expressions\n"
-            "  e   2.718.. Euler number\n"
-            "  pi  3.141.. \n"
-            "  inf infinity\n"
-            ;
+        cout << "Constants for use in expressions\n"
+                "  e   2.718.. Euler number\n"
+                "  pi  3.141.. \n"
+                "  inf infinity\n";
     } else if (cmd == "hf") {
         SFuncRegistry::instance()->display_functions();
     } else if (cmd == "hi") {
-        cout <<
-            "  hid  dimension-reducing functionals of data (replacing 'oio')\n"
-            "  hic  dimension-reducing functionals of curves\n"
-            ;
+        cout << "  hid  dimension-reducing functionals of data (replacing 'oio')\n"
+                "  hic  dimension-reducing functionals of curves\n";
     } else if (cmd == "hid" || cmd == "oio") {
         SGeniRegistry::instance()->display_entries();
     } else if (cmd == "hic") {
@@ -108,130 +103,125 @@ bool frida_command( string cmd )
     } else if (cmd == "ho") {
         SFuncRegistry::instance()->display_operators();
     } else if (cmd == "hr") {
-        cout <<
-            "Generic form of fit function that is to be convolved with a resolution spectrum:\n"
-            "    p0+p1*resol(p9)+p2*conv(f(t,p3,...,p8),p9)\n"
-            "Notes:\n"
-            "    - flat background of amplitude p0 does not need convolution\n"
-            "    - 'resol' copies the resolution data\n"
-            "      (implicit convolution of a Dirac delta distribution with the resolution)\n"
-            "    - 'conv' convolutes the given function f(t,...) with the resolution\n"
-            "    - p9 is a shift in t; most often it can be set to zero\n"
-            "      (a zero shift argument may be omitted from 'conv', but not from 'resol')\n"
-            "To activate the convolution:\n"
-            "    - use command 'cv' to provide resolution file reference\n"
-            "If function f has a sharp peak (strong variation within one resolution bin):\n"
-            "    - use 'pconv(F(t,...))', where F is the primitive of f\n"
-            ;
+        cout << "Generic form of fit function that is to be convolved with a resolution spectrum:\n"
+                "    p0+p1*resol(p9)+p2*conv(f(t,p3,...,p8),p9)\n"
+                "Notes:\n"
+                "    - flat background of amplitude p0 does not need convolution\n"
+                "    - 'resol' copies the resolution data\n"
+                "      (implicit convolution of a Dirac delta distribution with the resolution)\n"
+                "    - 'conv' convolutes the given function f(t,...) with the resolution\n"
+                "    - p9 is a shift in t; most often it can be set to zero\n"
+                "      (a zero shift argument may be omitted from 'conv', but not from 'resol')\n"
+                "To activate the convolution:\n"
+                "    - use command 'cv' to provide resolution file reference\n"
+                "If function f has a sharp peak (strong variation within one resolution bin):\n"
+                "    - use 'pconv(F(t,...))', where F is the primitive of f\n";
     } else if (cmd == "hv") {
-        cout <<
-            "Variables for use in expressions\n"
-            "  t         dummy argument in curve definition\n"
-            "  k         index running over files in online memory\n"
-            "  j         index running over slices (spectra or curves) in a file\n"
-            "  i         index running over points in a spectrum\n"
-            "  nk        number of files in online memory\n"
-            "  nj[K]     number of slices (spectra or curves) in a file\n"
-            "  ni[K,J]   number of points in a spectrum\n"
-            "  rL[K]     file-wide parameter number L\n"
-            "  zL[K,J]   slice-wide parameter number L\n"
-            "  pL[K,J]   curve parameter number L\n"
-            "  f[K,J](A) curve's function value for argument A\n"
-            "  x[K,J,I]  x-value of a point in a spectrum\n"
-            "  y[K,J,I]  y-value of a point in a spectrum\n"
-            "  dy[K,J,I] error of y[K,J,I]\n"
-            "Note on index placeholders K,J,I:\n"
-            "  - each of them can be omitted\n"
-            "  - when omitted, the respective default value k, j, or i is used\n"
-            "  - no comma needed when only omitted indices follow\n"
-            "  - the bracket may also be omitted altogether\n"
-            "  - hence are equivalent: x = x[k,j,i] = x[k,j,] = x[k,j] = x[k,] = x[k]\n"
-            ;
+        cout << "Variables for use in expressions\n"
+                "  t         dummy argument in curve definition\n"
+                "  k         index running over files in online memory\n"
+                "  j         index running over slices (spectra or curves) in a file\n"
+                "  i         index running over points in a spectrum\n"
+                "  nk        number of files in online memory\n"
+                "  nj[K]     number of slices (spectra or curves) in a file\n"
+                "  ni[K,J]   number of points in a spectrum\n"
+                "  rL[K]     file-wide parameter number L\n"
+                "  zL[K,J]   slice-wide parameter number L\n"
+                "  pL[K,J]   curve parameter number L\n"
+                "  f[K,J](A) curve's function value for argument A\n"
+                "  x[K,J,I]  x-value of a point in a spectrum\n"
+                "  y[K,J,I]  y-value of a point in a spectrum\n"
+                "  dy[K,J,I] error of y[K,J,I]\n"
+                "Note on index placeholders K,J,I:\n"
+                "  - each of them can be omitted\n"
+                "  - when omitted, the respective default value k, j, or i is used\n"
+                "  - no comma needed when only omitted indices follow\n"
+                "  - the bracket may also be omitted altogether\n"
+                "  - hence are equivalent: x = x[k,j,i] = x[k,j,] = x[k,j] = x[k,] = x[k]\n";
 
     } else if (cmd == "c") {
         cout << "Curve and fit commands:\n"
-            "  cc   create\n"
-            "  cca  create artificial curve (no data reference)\n"
-            "Basic operations:\n"
-            "  cm   modify function\n"
-            "  cd   set data file to fit\n"
-            "  cv   set file to convolute with (cv-: no convolution)\n"
-            "  cr   set fit range restriction\n"
-            "  cf   fit\n"
-            "  cfs  fit, allow slow convolution\n"
-            "  cp   print parameters\n"
-            "Parameter attributes:\n"
-            "  cx   fix parameters\n"
-            "  cg   make parameters global (same for all curves in the file)\n"
-            "  cu   unfix parameters (remove fixed and global attributes)\n"
-            "File attributes:\n"
-            "  cwc  weighing: constant\n"
-            "  cwl  weighing: logarithmic\n"
-            "  cwv  weighing: reciprocal variance (default)\n"
-            "  cwvd weighing: reciprocal variance, data only\n"
-            "  cwvc weighing: reciprocal variance, curve only\n"
-            "  cgd+ graphics: take x points from data reference file\n"
-            "  cgd- graphics: create x points by dividing the plot window\n"
-            "Frida-wide settings:\n"
-            "  cs?  show fit parameters, and indicate commands to modify them\n"
-            "  cn?  show parameters for numeric integration, and indicate commands to modify them\n"
-            ;
+                "  cc   create\n"
+                "  cca  create artificial curve (no data reference)\n"
+                "Basic operations:\n"
+                "  cm   modify function\n"
+                "  cd   set data file to fit\n"
+                "  cv   set file to convolute with (cv-: no convolution)\n"
+                "  cr   set fit range restriction\n"
+                "  cf   fit\n"
+                "  cfs  fit, allow slow convolution\n"
+                "  cp   print parameters\n"
+                "Parameter attributes:\n"
+                "  cx   fix parameters\n"
+                "  cg   make parameters global (same for all curves in the file)\n"
+                "  cu   unfix parameters (remove fixed and global attributes)\n"
+                "File attributes:\n"
+                "  cwc  weighing: constant\n"
+                "  cwl  weighing: logarithmic\n"
+                "  cwv  weighing: reciprocal variance (default)\n"
+                "  cwvd weighing: reciprocal variance, data only\n"
+                "  cwvc weighing: reciprocal variance, curve only\n"
+                "  cgd+ graphics: take x points from data reference file\n"
+                "  cgd- graphics: create x points by dividing the plot window\n"
+                "Frida-wide settings:\n"
+                "  cs?  show fit parameters, and indicate commands to modify them\n"
+                "  cn?  show parameters for numeric integration, and indicate commands to modify "
+                "them\n";
 
     } else if (cmd == "ci") {
         cout << "obsolete command: 'ci 1' has become 'oi p1'\n";
 
-    } else if (cmd == "cc" ) {
+    } else if (cmd == "cc") {
         NCurveFile::create_fitcurve();
-    } else if (cmd == "cca" ) {
+    } else if (cmd == "cca") {
         NCurveFile::create_freecurve();
 
-    } else if (cmd == "cm" ) {
+    } else if (cmd == "cm") {
         NCurveFile::change_expr();
 
-    } else if (cmd == "cd" || cmd == "cv" || cmd == "cv-" ) {
-        NCurveFile::set_file_reference( cmd.substr(1) );
+    } else if (cmd == "cd" || cmd == "cv" || cmd == "cv-") {
+        NCurveFile::set_file_reference(cmd.substr(1));
 
-    } else if (cmd == "cr" ) {
+    } else if (cmd == "cr") {
         NCurveFile::change_range();
 
     } else if (cmd == "cp") {
         NCurveFile::show_pars();
 
     } else if (cmd == "cf") {
-        NCurveFit::fit( false );
+        NCurveFit::fit(false);
     } else if (cmd == "cfs") {
-        NCurveFit::fit( true );
-    } else if (cmd == "cx" || cmd == "cg" || cmd == "cu" ) {
-        NCurveFile::set_par_attr( cmd[1] );
-    } else if (cmd.substr(0,2) == "cw" || cmd.substr(0,2) == "cg") {
-        NCurveFile::set_properties( cmd.substr(1) );
+        NCurveFit::fit(true);
+    } else if (cmd == "cx" || cmd == "cg" || cmd == "cu") {
+        NCurveFile::set_par_attr(cmd[1]);
+    } else if (cmd.substr(0, 2) == "cw" || cmd.substr(0, 2) == "cg") {
+        NCurveFile::set_properties(cmd.substr(1));
 
-    } else if (cmd.substr(0,2) == "cs") {
+    } else if (cmd.substr(0, 2) == "cs") {
         NCurveFit::set_fit_tuning_pars(cmd.substr(2));
 
-    } else if (cmd.substr(0,2) == "cn") {
+    } else if (cmd.substr(0, 2) == "cn") {
         NCvin::set_integration_tuning_pars(cmd.substr(2));
 
 
-    } else if ( cmd == "d" ) {
+    } else if (cmd == "d") {
         cout << "Directory commands: inspect internal files\n"
-            "  df   list of files\n"
-            "  dz   z-values and spectral ranges\n"
-            "  dp   x|y-values\n"
-            "  dy   y-values\n"
-            "  dr   real parameters\n"
-            "  dc   coordinate names and units\n"
-            "  dd   doc lines\n"
-            ;
+                "  df   list of files\n"
+                "  dz   z-values and spectral ranges\n"
+                "  dp   x|y-values\n"
+                "  dy   y-values\n"
+                "  dr   real parameters\n"
+                "  dc   coordinate names and units\n"
+                "  dd   doc lines\n";
 
     } else if (cmd == "df") {
         NEdif::show_files();
     } else if (cmd == "dz") {
         NEdif::show_spectra();
-    } else if (cmd == "dp" ) {
-        NOperate::show( "xyd" );
-    } else if (cmd == "dy" ) {
-        NOperate::show( "y" );
+    } else if (cmd == "dp") {
+        NOperate::show("xyd");
+    } else if (cmd == "dy") {
+        NOperate::show("y");
     } else if (cmd == "dr") {
         NEdif::show_numpars();
     } else if (cmd == "dc") {
@@ -239,15 +229,14 @@ bool frida_command( string cmd )
     } else if (cmd == "dd") {
         NEdif::show_doc();
 
-    } else if ( cmd == "e" ) {
+    } else if (cmd == "e") {
         cout << "Edit commands:\n"
-            "  ef         file name\n"
-            "  ec<coord>  name and unit of <coord>=x,y,z0,..\n"
-            "  ed         documentation lines\n"
-            ;
+                "  ef         file name\n"
+                "  ec<coord>  name and unit of <coord>=x,y,z0,..\n"
+                "  ed         documentation lines\n";
 
-    } else if (cmd.substr(0,2) == "ec") {
-        NEdif::edit_coord( cmd.substr(2) );
+    } else if (cmd.substr(0, 2) == "ec") {
+        NEdif::edit_coord(cmd.substr(2));
     } else if (cmd == "ed") {
         NEdif::edit_doc();
     } else if (cmd == "ef") {
@@ -256,40 +245,39 @@ bool frida_command( string cmd )
 
     } else if (cmd == "f") {
         cout << "File commands:\n"
-            "  fl   load from disk\n"
-            "  fs   save to disk\n"
-            "  fso  save to disk, allow overwrite\n"
-            "  fe0  export to old y08 format (obsolete!)\n"
-            "  fe1  export (only z and y, one line per spectrum)\n"
-            "  fe2  export (one block per spectrum: z header and x-y lines)\n"
-            "  fc   copy\n"
-            "  fx   exchange (copy, then delete source)\n"
-            "  fdel delete\n"
-            "  fm   make\n"
-            "  ft(h|v|c)[m|b][s][d]  read tab\n"
-            "       h horizontal (only y values, one line per spectrum)\n"
-            "       v vertical (one x-y pair per line)\n"
-            "       c choose vertical columns\n"
-            "       m multi-block (blocks begin with z line)\n"
-            "       b multi-block (without z lines)\n"
-            "       s from script\n"
-            "       d input includes dy\n"
-            ;
+                "  fl   load from disk\n"
+                "  fs   save to disk\n"
+                "  fso  save to disk, allow overwrite\n"
+                "  fe0  export to old y08 format (obsolete!)\n"
+                "  fe1  export (only z and y, one line per spectrum)\n"
+                "  fe2  export (one block per spectrum: z header and x-y lines)\n"
+                "  fc   copy\n"
+                "  fx   exchange (copy, then delete source)\n"
+                "  fdel delete\n"
+                "  fm   make\n"
+                "  ft(h|v|c)[m|b][s][d]  read tab\n"
+                "       h horizontal (only y values, one line per spectrum)\n"
+                "       v vertical (one x-y pair per line)\n"
+                "       c choose vertical columns\n"
+                "       m multi-block (blocks begin with z line)\n"
+                "       b multi-block (without z lines)\n"
+                "       s from script\n"
+                "       d input includes dy\n";
 
     } else if (cmd == "fl") {
         NFileIn::load();
     } else if (cmd == "fs") {
-        NFileOut::save( "yda" );
+        NFileOut::save("yda");
     } else if (cmd == "fso") {
-        NFileOut::save( "yda", true );
+        NFileOut::save("yda", true);
     } else if (cmd == "fe0") {
-        NFileOut::save( "y08" );
+        NFileOut::save("y08");
     } else if (cmd == "fe0o") {
-        NFileOut::save( "y08", true );
+        NFileOut::save("y08", true);
     } else if (cmd == "fe1") {
-        NFileOut::save( "csv" );
+        NFileOut::save("csv");
     } else if (cmd == "fe2") {
-        NFileOut::save( "tab" );
+        NFileOut::save("tab");
     } else if (cmd == "fc") {
         SMem::instance()->mem_copy();
     } else if (cmd == "fx") {
@@ -298,161 +286,155 @@ bool frida_command( string cmd )
         SFSel::instance()->sel_delete();
     } else if (cmd == "fm") {
         NImport::make_grid();
-    } else if (cmd.substr(0,2) == "ft") {
-        NImport::read_tab( cmd.substr(2) );
+    } else if (cmd.substr(0, 2) == "ft") {
+        NImport::read_tab(cmd.substr(2));
 
 
     } else if (cmd == "g") {
-        cout <<
-            "Graphics commands:\n"
-            "  p    plot\n"
-            "  pr   plot with new autoranges\n"
-            "  pn   plot next spectrum\n"
-            "  pv   plot previous spectrum\n"
-            "  a    add to plot\n"
-            "  an   add next spectrum\n"
-            "  av   add previous spectrum\n"
-            "  gd   graphic dialog (feed commands to gnuplot)\n"
-            "Save for print:\n"
-            "  gp   plot to complete .ps file\n"
-            "  gf   plot to short .psX file\n"
-            "Change window:\n"
-            "  gw   list of plot windows\n"
-            "  g<n> switch to plot window <n>\n"
-            "Set axes:\n"
-            "  gx   set x range\n"
-            "  gy   set x range\n"
-            "  ga   auto-ranges\n"
-            "  gxa  x auto-range\n"
-            "  gya  y auto-range\n"
-            "  gxl  log x (toggle; or use gxl+ gxl-)\n"
-            "  gyl  log y\n"
-            "  gxf  force x into frame (toggle; or use gxf+ gxf-)\n"
-            "  gyf  force y into frame (toggle; or use gyf+ gyf-)\n"
-            "Other setup:\n"
-            "  ge   plot error bars (toggle, or ge+ ge-)\n"
-            "  gnd  set maximum number of data points\n"
-            "  gnc  number of equidistant base points for curve plotting\n"
-            "  gcr  allow iterative refinement for curve plotting?\n"
-            "Help:\n"
-            "  gsym explain plot symbols\n"
-            ;
-
-    } else if ( cmd == "gx" ) {
-        SPloWin::instance()->current()->X.ask_and_set( "Plot x range" );
-    } else if ( cmd == "gy" ) {
-        SPloWin::instance()->current()->Y.ask_and_set( "Plot y range" );
-    } else if ( cmd == "ga" ) {
+        cout << "Graphics commands:\n"
+                "  p    plot\n"
+                "  pr   plot with new autoranges\n"
+                "  pn   plot next spectrum\n"
+                "  pv   plot previous spectrum\n"
+                "  a    add to plot\n"
+                "  an   add next spectrum\n"
+                "  av   add previous spectrum\n"
+                "  gd   graphic dialog (feed commands to gnuplot)\n"
+                "Save for print:\n"
+                "  gp   plot to complete .ps file\n"
+                "  gf   plot to short .psX file\n"
+                "Change window:\n"
+                "  gw   list of plot windows\n"
+                "  g<n> switch to plot window <n>\n"
+                "Set axes:\n"
+                "  gx   set x range\n"
+                "  gy   set x range\n"
+                "  ga   auto-ranges\n"
+                "  gxa  x auto-range\n"
+                "  gya  y auto-range\n"
+                "  gxl  log x (toggle; or use gxl+ gxl-)\n"
+                "  gyl  log y\n"
+                "  gxf  force x into frame (toggle; or use gxf+ gxf-)\n"
+                "  gyf  force y into frame (toggle; or use gyf+ gyf-)\n"
+                "Other setup:\n"
+                "  ge   plot error bars (toggle, or ge+ ge-)\n"
+                "  gnd  set maximum number of data points\n"
+                "  gnc  number of equidistant base points for curve plotting\n"
+                "  gcr  allow iterative refinement for curve plotting?\n"
+                "Help:\n"
+                "  gsym explain plot symbols\n";
+
+    } else if (cmd == "gx") {
+        SPloWin::instance()->current()->X.ask_and_set("Plot x range");
+    } else if (cmd == "gy") {
+        SPloWin::instance()->current()->Y.ask_and_set("Plot y range");
+    } else if (cmd == "ga") {
         SPloWin::instance()->current()->X.set_auto();
         SPloWin::instance()->current()->Y.set_auto();
-    } else if ( cmd == "gxa" ) {
+    } else if (cmd == "gxa") {
         SPloWin::instance()->current()->X.set_auto();
-    } else if ( cmd == "gya" ) {
+    } else if (cmd == "gya") {
         SPloWin::instance()->current()->Y.set_auto();
-    } else if ( cmd.substr(0,2) == "gx" ||
-                cmd.substr(0,2) == "gy" ||
-                cmd.substr(0,2) == "ge" ) {
-        SPloWin::instance()->current()->set_aux( cmd );
-    } else if ( cmd=="gnd" ) {
-        SPloWin::instance()->current()->maxpoints =
-            iask( "Maximum number of data points in plot",
-                  SPloWin::instance()->current()->maxpoints );
-    } else if ( cmd=="gnc" ) {
-        SPloWin::instance()->current()->equipoints =
-            iask( "Number of equidistant base points for curve plotting",
-                  SPloWin::instance()->current()->equipoints );
-    } else if ( cmd=="gcr" ) {
-        SPloWin::instance()->current()->refine =
-            bask( "Allow iterative refinement for curve plotting",
-                  SPloWin::instance()->current()->refine );
-    } else if (cmd == "gp" || cmd == "gf" ) {
-        string ps_outdir = CNode::eval( "psdir" )->to_s();
-        string ps_head = CNode::eval( "pshead" )->to_s();
-        string ps_dict = cmd=="gp" ? CNode::eval( "psdict" )->to_s() : "";
-        SPloWin::instance()->current()->write_postscript( ps_outdir, ps_head, ps_dict );
-    } else if ( cmd == "gw" ) {
+    } else if (cmd.substr(0, 2) == "gx" || cmd.substr(0, 2) == "gy" || cmd.substr(0, 2) == "ge") {
+        SPloWin::instance()->current()->set_aux(cmd);
+    } else if (cmd == "gnd") {
+        SPloWin::instance()->current()->maxpoints = iask(
+            "Maximum number of data points in plot", SPloWin::instance()->current()->maxpoints);
+    } else if (cmd == "gnc") {
+        SPloWin::instance()->current()->equipoints = iask(
+            "Number of equidistant base points for curve plotting",
+            SPloWin::instance()->current()->equipoints);
+    } else if (cmd == "gcr") {
+        SPloWin::instance()->current()->refine = bask(
+            "Allow iterative refinement for curve plotting",
+            SPloWin::instance()->current()->refine);
+    } else if (cmd == "gp" || cmd == "gf") {
+        string ps_outdir = CNode::eval("psdir")->to_s();
+        string ps_head = CNode::eval("pshead")->to_s();
+        string ps_dict = cmd == "gp" ? CNode::eval("psdict")->to_s() : "";
+        SPloWin::instance()->current()->write_postscript(ps_outdir, ps_head, ps_dict);
+    } else if (cmd == "gw") {
         SPloWin::instance()->display_list();
-    } else if ( sscanf( cmd.c_str(), "g%i", &i )==1 ) {
-        SPloWin::instance()->select( i );
+    } else if (sscanf(cmd.c_str(), "g%i", &i) == 1) {
+        SPloWin::instance()->select(i);
     } else if (cmd == "gd") { // graph dialog
         string cmd;
         cout << "entering mygnuplot - to leave, type q\n";
-        while(1) {
+        while (1) {
             cmd = sask("mygnuplot> ");
-            if (cmd.substr(0,1)=="q")
+            if (cmd.substr(0, 1) == "q")
                 break;
             SPloWin::instance()->current()->gp_write(cmd);
         }
     } else if (cmd == "gsym") {
-        system( ("gv " + CNode::eval( "psgsym" )->to_s() + "&").c_str() );
+        system(("gv " + CNode::eval("psgsym")->to_s() + "&").c_str());
     } else if (cmd == "p") {
-        NPlot::plot( SPloWin::instance()->current(), false );
+        NPlot::plot(SPloWin::instance()->current(), false);
     } else if (cmd == "pr") {
         SPloWin::instance()->current()->X.set_auto();
         SPloWin::instance()->current()->Y.set_auto();
-        NPlot::plot( SPloWin::instance()->current(), false );
+        NPlot::plot(SPloWin::instance()->current(), false);
     } else if (cmd == "pn") {
-        NPlot::plot( SPloWin::instance()->current(), false, "next" );
+        NPlot::plot(SPloWin::instance()->current(), false, "next");
     } else if (cmd == "pv") {
-        NPlot::plot( SPloWin::instance()->current(), false, "prev" );
+        NPlot::plot(SPloWin::instance()->current(), false, "prev");
     } else if (cmd == "a") {
-        NPlot::plot( SPloWin::instance()->current(), true );
+        NPlot::plot(SPloWin::instance()->current(), true);
     } else if (cmd == "an") {
-        NPlot::plot( SPloWin::instance()->current(), true, "next" );
+        NPlot::plot(SPloWin::instance()->current(), true, "next");
     } else if (cmd == "av") {
-        NPlot::plot( SPloWin::instance()->current(), true, "prev" );
+        NPlot::plot(SPloWin::instance()->current(), true, "prev");
 
 
     } else if (cmd == "k") {
         cout << "Commands to modify the internal file selection:\n"
-            "  kn    next\n"
-            "  kv    previous\n";
+                "  kn    next\n"
+                "  kv    previous\n";
     } else if (cmd == "kn") {
-        SFSel::instance()->sel_increment( +1 );
+        SFSel::instance()->sel_increment(+1);
     } else if (cmd == "kv") {
-        SFSel::instance()->sel_increment( -1 );
+        SFSel::instance()->sel_increment(-1);
 
     } else if (cmd == "m") {
         cout << "Commands to manipulate data:\n"
-            "  m/    protect spectra from forthcoming operations\n"
-            "  m/-   lift protections\n"
-            "Generic manipulations (expression driven):\n"
-            "  md    generic delete\n"
-            "  mr    generic retain\n"
-            "Per point:\n"
-            "  mpd   delete\n"
-            "  mpr   retain\n"
-            "  mpa   average (=bin), list controlled\n"
-            "  mpaf  average, reduce number of points by fixed factor\n"
-            "  mpaea average according to error bound (absolute)\n"
-            "  mpaer average according to error bound (relative)\n"
-            "  mpbf  break into spectra by fixed factor\n"
-            "  mpo   sort\n"
-            "  mpq   average when x equal\n"
-            "  mpsym symmetrize: map -x -> x, then average\n"
-            "  mpe-  remove error bar\n"
-            "Per spectrum:\n"
-            "  msd   delete\n"
-            "  msr   retain\n"
-            "  msa   average\n"
-            "  msb   break into files\n"
-            "  msj   join\n"
-            "  ms*   spawn spectra\n"
-            "  msx   z_max <-> x\n"
-            "  mso   sort by expression\n"
-            "  msoz  sort by z-values\n"
-            "  mzx   exchange / rotate z coordinates\n"
-            "  mz-   delete z coordinate\n"
-            "Per file:\n"
-            "  mfj   merge (\"join\")\n"
-            "  mfj+  merge, adding z=number-of-input-file\n"
-            "  mfjp  merge pointwise\n"
-            "  mr-   remove real par\n"
-            "Interpolation operations:\n"
-            "  mi    locate y in x' to determine y'(x'=y)\n"
-            "Histogram operations:\n"
-            "  mhm   bin data\n"
-            ;
+                "  m/    protect spectra from forthcoming operations\n"
+                "  m/-   lift protections\n"
+                "Generic manipulations (expression driven):\n"
+                "  md    generic delete\n"
+                "  mr    generic retain\n"
+                "Per point:\n"
+                "  mpd   delete\n"
+                "  mpr   retain\n"
+                "  mpa   average (=bin), list controlled\n"
+                "  mpaf  average, reduce number of points by fixed factor\n"
+                "  mpaea average according to error bound (absolute)\n"
+                "  mpaer average according to error bound (relative)\n"
+                "  mpbf  break into spectra by fixed factor\n"
+                "  mpo   sort\n"
+                "  mpq   average when x equal\n"
+                "  mpsym symmetrize: map -x -> x, then average\n"
+                "  mpe-  remove error bar\n"
+                "Per spectrum:\n"
+                "  msd   delete\n"
+                "  msr   retain\n"
+                "  msa   average\n"
+                "  msb   break into files\n"
+                "  msj   join\n"
+                "  ms*   spawn spectra\n"
+                "  msx   z_max <-> x\n"
+                "  mso   sort by expression\n"
+                "  msoz  sort by z-values\n"
+                "  mzx   exchange / rotate z coordinates\n"
+                "  mz-   delete z coordinate\n"
+                "Per file:\n"
+                "  mfj   merge (\"join\")\n"
+                "  mfj+  merge, adding z=number-of-input-file\n"
+                "  mfjp  merge pointwise\n"
+                "  mr-   remove real par\n"
+                "Interpolation operations:\n"
+                "  mi    locate y in x' to determine y'(x'=y)\n"
+                "Histogram operations:\n"
+                "  mhm   bin data\n";
 
     } else if (cmd == "m/") {
         NManip::freeze_slices();
@@ -463,15 +445,15 @@ bool frida_command( string cmd )
     } else if (cmd == "mr") {
         NOperate::select(0);
     } else if (cmd == "mpd") {
-        NManip::points_select( true );
+        NManip::points_select(true);
     } else if (cmd == "mpr") {
-        NManip::points_select( false );
+        NManip::points_select(false);
     } else if (cmd == "mpa") {
         NManip::points_rebin();
     } else if (cmd == "mpaf") {
         NManip::points_rebin_by_factor();
-    } else if (cmd.substr(0,4) == "mpae") {
-        NManip::points_rebin_by_err( cmd.substr(4) );
+    } else if (cmd.substr(0, 4) == "mpae") {
+        NManip::points_rebin_by_err(cmd.substr(4));
     } else if (cmd == "mpbf") {
         NManip::points_break_by_factor();
     } else if (cmd == "mpo") {
@@ -483,9 +465,9 @@ bool frida_command( string cmd )
     } else if (cmd == "mpe-") {
         NManip::points_remove_err();
     } else if (cmd == "msd") {
-        NManip::slices_select( true );
+        NManip::slices_select(true);
     } else if (cmd == "msr") {
-        NManip::slices_select( false );
+        NManip::slices_select(false);
     } else if (cmd == "msa") {
         NManip::slices_rebin();
     } else if (cmd == "msb") {
@@ -507,8 +489,8 @@ bool frida_command( string cmd )
         NManip::slices_sort_by_z();
     } else if (cmd == "mfjp") {
         NManip::files_merge_pointwise();
-    } else if (cmd.substr(0,3) == "mfj") {
-        NManip::files_merge( cmd.substr(3) );
+    } else if (cmd.substr(0, 3) == "mfj") {
+        NManip::files_merge(cmd.substr(3));
     } else if (cmd == "mr-") {
         NEdif::del_numpar();
     } else if (cmd == "mi") {
@@ -519,24 +501,25 @@ bool frida_command( string cmd )
 
     } else if (cmd == "o") {
         cout << "Commands to operate on variables or spectra:\n"
-            "  ox       on x\n"
-            "  oy       on y\n"
-            "  oz0,..   on z0,..\n"
-            "  oz+      add new z value\n"
-            "  or0,..   on r0,..\n"
-            "  or+      add new real par\n"
-            "  op0,..   on p0,.. (fit parameter)\n"
-            "  op*      on all fit parameters\n"
-            "  opa      take absolute value\n"
-            "  opc      copy from another curve\n"
-            "  ofi      functional integrate\n"
-            "  ofs      summation up to current index\n"
-            "  ofd      functional derivate\n"
-            "  ofac     functional autocorrelate\n"
-            "  oi       rank-reducing operations (""generalized integrals"")\n"
-            "  oixy     choose two columns, save them as x and y\n"
-            "  oixyd    choose three columns, save them as x, y, dy\n"
-            ;
+                "  ox       on x\n"
+                "  oy       on y\n"
+                "  oz0,..   on z0,..\n"
+                "  oz+      add new z value\n"
+                "  or0,..   on r0,..\n"
+                "  or+      add new real par\n"
+                "  op0,..   on p0,.. (fit parameter)\n"
+                "  op*      on all fit parameters\n"
+                "  opa      take absolute value\n"
+                "  opc      copy from another curve\n"
+                "  ofi      functional integrate\n"
+                "  ofs      summation up to current index\n"
+                "  ofd      functional derivate\n"
+                "  ofac     functional autocorrelate\n"
+                "  oi       rank-reducing operations ("
+                "generalized integrals"
+                ")\n"
+                "  oixy     choose two columns, save them as x and y\n"
+                "  oixyd    choose three columns, save them as x, y, dy\n";
 
     } else if (cmd == "op") {
         throw S("use op<n> to modify one parameter, or op* to modify all");
@@ -546,60 +529,58 @@ bool frida_command( string cmd )
         NCurveFile::pars_abs();
     } else if (cmd == "opc") {
         NCurveFile::pars_copy();
-    } else if (cmd[0]=='o' && strchr("xydzpr", cmd[1])) {
-        NOperate::Pointwise( cmd.substr(1) );
-    } else if (cmd.substr(0,2) == "of") {
-        NOperate::Functional( cmd.substr(2) );
+    } else if (cmd[0] == 'o' && strchr("xydzpr", cmd[1])) {
+        NOperate::Pointwise(cmd.substr(1));
+    } else if (cmd.substr(0, 2) == "of") {
+        NOperate::Functional(cmd.substr(2));
     } else if (cmd == "oi") {
         NOperate::Integral();
-    } else if (cmd.substr(0,4) == "oixy") {
-        NOperate::IntXY( cmd.substr(2) );
+    } else if (cmd.substr(0, 4) == "oixy") {
+        NOperate::IntXY(cmd.substr(2));
 
 
     } else if (cmd == "r") {
         cout << "Read raw data from SPHERES:\n"
-            "  ry   load energy spectra\n"
-            "  ry2  load also spectra for open state\n"
-            "  ry4  load also chopper histograms\n"
-            "  ry8  load spectra for two directions separately\n"
-            "  ryd  load only spectra for two directions\n"
-            "  ryo  load only spectra for open state\n"
-            "  ryc  raw counts (no normalization)\n"
-            "  rs   load series of energy spectra\n"
-            "  rs2  load also spectra for open state\n"
-            ;
-
-    } else if (cmd == "ry" ) {
-        NRSSM::read_spec( 0 );
+                "  ry   load energy spectra\n"
+                "  ry2  load also spectra for open state\n"
+                "  ry4  load also chopper histograms\n"
+                "  ry8  load spectra for two directions separately\n"
+                "  ryd  load only spectra for two directions\n"
+                "  ryo  load only spectra for open state\n"
+                "  ryc  raw counts (no normalization)\n"
+                "  rs   load series of energy spectra\n"
+                "  rs2  load also spectra for open state\n";
+
+    } else if (cmd == "ry") {
+        NRSSM::read_spec(0);
     } else if (cmd == "ry2") {
-        NRSSM::read_spec( 1 );
+        NRSSM::read_spec(1);
     } else if (cmd == "ry4") {
-        NRSSM::read_spec( 3 );
+        NRSSM::read_spec(3);
     } else if (cmd == "ry8") {
-        NRSSM::read_spec( 7 );
+        NRSSM::read_spec(7);
     } else if (cmd == "ryd") {
-        NRSSM::read_spec( 12 );
+        NRSSM::read_spec(12);
     } else if (cmd == "ryo") {
-        NRSSM::read_spec( 9 );
+        NRSSM::read_spec(9);
     } else if (cmd == "ryc") {
-        NRSSM::read_spec( 16 );
+        NRSSM::read_spec(16);
     } else if (cmd == "rs") {
-        NRSSM::read_series( 0 );
+        NRSSM::read_series(0);
     } else if (cmd == "rs2") {
-        NRSSM::read_series( 1 );
+        NRSSM::read_series(1);
 
 
     } else if (cmd == "!") {
         string sh_cmd;
         sh_cmd = sask("shell command");
-        triv::system( sh_cmd );
+        triv::system(sh_cmd);
 
 
     } else if (cmd == "_") {
         cout << "Special programs:\n"
-            "  _fc      cosine Fourier transform\n"
-            "  _t       test (may change at any moment)\n"
-            ;
+                "  _fc      cosine Fourier transform\n"
+                "  _t       test (may change at any moment)\n";
 
 
     } else if (cmd == "_fc") {
@@ -608,7 +589,7 @@ bool frida_command( string cmd )
     } else if (cmd == "_t") {
         NSpecial::Test();
 
-    } else if ( cmd == "qui" || cmd=="quit" ) {
+    } else if (cmd == "qui" || cmd == "quit") {
         exit(0);
 
     } else {
diff --git a/pub/lib/commands.hpp b/pub/lib/commands.hpp
index 260846f59ca722ca5b7c6549e91d0244220f331a..1546b3d98d081446f02c2d3c56fa81953bd94930 100644
--- a/pub/lib/commands.hpp
+++ b/pub/lib/commands.hpp
@@ -1,10 +1,10 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                        
-//*  (C) Joachim Wuttke 1990-, C++ rewrite 2001-                           
-//*  http://apps.jcns.fz-juelich.de/frida                                  
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, C++ rewrite 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  commands.hpp
 //! \brief Function fridaCommand: executes one main-level command.
 
-bool frida_command( string cmd );
+bool frida_command(string cmd);
diff --git a/pub/lib/coord.cpp b/pub/lib/coord.cpp
index 34ead20072a4299a1febc5eee67463c04f90f15e..32a70c84df15727ebf55faa27bc0421361cb282c 100644
--- a/pub/lib/coord.cpp
+++ b/pub/lib/coord.cpp
@@ -21,77 +21,80 @@
 
 //! Constructor parsing "name (unit)", where unit may be empty.
 
-CCoord::CCoord( const string in )
+CCoord::CCoord(const string in)
 {
     int i, j, np, n;
     n = in.size();
-    if (in[n-1]!=')')
+    if (in[n - 1] != ')')
         throw S("input must terminate with ')'");
-    for(j=n-2, np=1; j!=(int)-1; j--) {
-        if (in[j]==')')
+    for (j = n - 2, np = 1; j != (int)-1; j--) {
+        if (in[j] == ')')
             np++;
-        else if (in[j]=='(') {
+        else if (in[j] == '(') {
             np--;
-            if (np==0) break;
+            if (np == 0)
+                break;
         }
     }
-    if (np!=0)
+    if (np != 0)
         throw S("input must contain balanced parentheses");
-    for (i=j; i>0 && strchr(" \t",in[i-1]); i--) ;
-    if (i==0)
+    for (i = j; i > 0 && strchr(" \t", in[i - 1]); i--)
+        ;
+    if (i == 0)
         throw S("input must contain a non-empty coordinate name");
-    name = in.substr(0,i);
-    unit = in.substr(j+1, n-j-2);
+    name = in.substr(0, i);
+    unit = in.substr(j + 1, n - j - 2);
 }
 
 //! Interactive setting with help functionality.
 
-void CCoord::ask_and_set( const string& quest )
+void CCoord::ask_and_set(const string& quest)
 {
     string prompt = quest;
-    if( name!="" )
+    if (name != "")
         prompt += " [" + str_std() + "]";
     prompt += " ? ";
-    for( ;; ) {
-        string resp = NMacro::readln( prompt );
-        if        ( resp == "\\q" ) {
+    for (;;) {
+        string resp = NMacro::readln(prompt);
+        if (resp == "\\q") {
             throw S("user escape to main menu");
-        } else if ( resp == "" ) {
-            if ( name!="" )
+        } else if (resp == "") {
+            if (name != "")
                 return; // keep current value
             cout << "no default available\n";
-        } else if ( resp == "?" ) {
+        } else if (resp == "?") {
             cout << "required input type: coordinate name and unit\n";
             cout << "input must be in the form: name (unit)\n";
-            if( name!="" )
-                cout << "just press ENTER to let current value unchanged ["
-                     << str_std() << "]\n";
+            if (name != "")
+                cout << "just press ENTER to let current value unchanged [" << str_std() << "]\n";
         } else {
             int i, j, np, n;
             n = resp.size();
-            if (resp[n-1]!=')') {
+            if (resp[n - 1] != ')') {
                 cout << "input must terminate with ')'\n";
                 continue;
             }
-            for(j=n-2, np=1; j!=(int)-1; j--) {
-                if (resp[j]==')')
+            for (j = n - 2, np = 1; j != (int)-1; j--) {
+                if (resp[j] == ')')
                     np++;
-                else if (resp[j]=='(') {
+                else if (resp[j] == '(') {
                     np--;
-                    if (np==0) break;
+                    if (np == 0)
+                        break;
                 }
             }
-            if (np!=0){
+            if (np != 0) {
                 cout << "input must contain balanced parentheses\n";
                 continue;
             }
-            for (i=j; i>0 && strchr(" \t",resp[i-1]); i--) ;
-            if (i==0){
+            for (i = j; i > 0 && strchr(" \t", resp[i - 1]); i--)
+                ;
+            if (i == 0) {
                 cout << "input must contain a non-empty coordinate name\n";
                 continue;
             }
-            name = resp.substr(0,i);
-            unit = resp.substr(j+1, n-j-2);
+            name = resp.substr(0, i);
+            unit = resp.substr(j + 1, n - j - 2);
             return;
         }
     }
@@ -100,31 +103,28 @@ void CCoord::ask_and_set( const string& quest )
 
 //! Standard string.
 
-string CCoord::str_std() const
-{
-    return name + " (" + unit + ")";
-}
+string CCoord::str_std() const { return name + " (" + unit + ")"; }
 
 //! Compact string for use in tables.
 
-string CCoord::str_compact( int maxlen ) const
+string CCoord::str_compact(int maxlen) const
 {
     string ret = name + "(" + unit + ")";
-    if ( maxlen==0 || ret.length() <= maxlen )
+    if (maxlen == 0 || ret.length() <= maxlen)
         return ret;
     ret = name;
-    if ( ret.length() <= maxlen )
+    if (ret.length() <= maxlen)
         return ret;
-    if( maxlen>3 )
-        return name.substr(0,maxlen-2) + "..";
-    return name.substr(0,maxlen);
+    if (maxlen > 3)
+        return name.substr(0, maxlen - 2) + "..";
+    return name.substr(0, maxlen);
 }
 
 //! String for use in PostScript output.
 
 string CCoord::str_ps() const // two blanks instead of one, and no unit ""
 {
-    return name + ( unit!="" ? ("  (" + unit + ")") : "");
+    return name + (unit != "" ? ("  (" + unit + ")") : "");
 }
 
 //! Parse old a01 format.
@@ -132,30 +132,27 @@ string CCoord::str_ps() const // two blanks instead of one, and no unit ""
 string CCoord::load_a01(string in)
 {
     string::size_type t1, t2;
-    if(!in.size()) {
+    if (!in.size()) {
         name = "";
         unit = "";
         return "";
     }
-    if ((t1 = in.find('\t'))==string::npos) {
+    if ((t1 = in.find('\t')) == string::npos) {
         name = in;
         unit = "";
         return "";
     }
-    name = in.substr(0,t1);
-    if ((t2 = in.find('\t', t1+1))==string::npos) {
-        unit = in.substr(t1+1);
+    name = in.substr(0, t1);
+    if ((t2 = in.find('\t', t1 + 1)) == string::npos) {
+        unit = in.substr(t1 + 1);
         return "";
     }
-    unit = in.substr(t1+1,t2-t1);
-    return in.substr(t2+1);
+    unit = in.substr(t1 + 1, t2 - t1);
+    return in.substr(t2 + 1);
 }
 
 //**************************************************************************************************
 //*  outside CCoord
 //**************************************************************************************************
 
-std::ostream& operator<< (std::ostream &s, CCoord C)
-{
-    return s << C.str_std();
-}
+std::ostream& operator<<(std::ostream& s, CCoord C) { return s << C.str_std(); }
diff --git a/pub/lib/coord.hpp b/pub/lib/coord.hpp
index 10ec7f4b190bc6675f163d2e4e3cf50bea560cc2..3a0c7a6c9fe2e83e660935adfd9e4ad8e82d7c99 100644
--- a/pub/lib/coord.hpp
+++ b/pub/lib/coord.hpp
@@ -10,50 +10,50 @@
 
 //! A coordinate, consisting of a name and a unit.
 
-class CCoord {
- public:
+class CCoord
+{
+public:
     string name;
     string unit;
 
     CCoord() {}
     //! Creates instance with given name and unit.
-    CCoord( const string _name, const string _unit ) :
-        name(_name), unit(_unit) {}
+    CCoord(const string _name, const string _unit) : name(_name), unit(_unit) {}
     //! Creates instance. Given string will be parsed into name and unit.
-    CCoord( const string in );
+    CCoord(const string in);
 
-    void ask_and_set( const string& quest );
+    void ask_and_set(const string& quest);
 
-    friend std::ostream& operator<< (std::ostream &s, CCoord C);
+    friend std::ostream& operator<<(std::ostream& s, CCoord C);
     string str_std() const;
-    string str_compact( int maxlen=0 ) const;
+    string str_compact(int maxlen = 0) const;
     string str_ps() const;
     string to_a01() const;
     string load_a01(string);
 
     //! Has this instance nonvoid contents?
-    bool defined() { return name!=""; }
+    bool defined() { return name != ""; }
     //! Are two instances equal?
-    bool operator== (const CCoord& Co2) const {
-        return (name==Co2.name) && (unit==Co2.unit); }
+    bool operator==(const CCoord& Co2) const { return (name == Co2.name) && (unit == Co2.unit); }
     //! Returns negation of operator==.
-    bool operator!= (const CCoord& Co2) const {
-        return !(*this==Co2); }
+    bool operator!=(const CCoord& Co2) const { return !(*this == Co2); }
 };
 
 
 //! A file-wide parameter, consisting of a coordinate and a value.
 
-class CParam {
- public:
+class CParam
+{
+public:
     CCoord Co;
     double val;
     double dval; //!< Error of val. Still unused.
 
     //! Creates instance with fully given contents.
-    CParam( CCoord _Co, double _val=0, double _dval=0 )
-        : Co(_Co), val(_val), dval(_dval) {}
+    CParam(CCoord _Co, double _val = 0, double _dval = 0) : Co(_Co), val(_val), dval(_dval) {}
     //! Creates instance with fully given, partly unparsed contents.
-    CParam( string _name, string _unit="", double _val=0, double _dval=0 ) :
-        Co( CCoord(_name, _unit) ), val(_val), dval(_dval) {}
+    CParam(string _name, string _unit = "", double _val = 0, double _dval = 0)
+        : Co(CCoord(_name, _unit)), val(_val), dval(_dval)
+    {
+    }
 };
\ No newline at end of file
diff --git a/pub/lib/curve.cpp b/pub/lib/curve.cpp
index a0070bf7d10a2af81c4853bdf822f4c0402e2f13..f4c6c3cdde658c38997f2fc4cf80a7312c090795 100644
--- a/pub/lib/curve.cpp
+++ b/pub/lib/curve.cpp
@@ -13,15 +13,15 @@
 
 #include "../readplus/ask.hpp"
 
-#include "olf.hpp"
-#include "mem.hpp"
+#include "curve.hpp"
+#include "expr.hpp"
 #include "fsel.hpp"
 #include "loop.hpp"
-#include "slice.hpp"
-#include "curve.hpp"
+#include "mem.hpp"
 #include "obj.hpp"
-#include "expr.hpp"
+#include "olf.hpp"
 #include "opr.hpp"
+#include "slice.hpp"
 #include "xax_lex.hpp"
 
 using boost::format;
@@ -38,33 +38,33 @@ void NCurveFile::create_fitcurve()
 {
     FileIterator fiter(SFSel::instance()->selD());
 
-    POlc fc( new COlc );
-    fc->curve_query( "Curve definition" );
+    POlc fc(new COlc);
+    fc->curve_query("Curve definition");
     fc->curve_set_defaults();
 
-    while( const COld *fd = fiter.nextD() ) {
-        POlc fout( fc->new_POlc() );
-        vector<double> P( fout->nP, 1.0 );
+    while (const COld* fd = fiter.nextD()) {
+        POlc fout(fc->new_POlc());
+        vector<double> P(fout->nP, 1.0);
         fout->name = string("fit_") + fd->name;
         fout->kd = fiter.k();
         fout->xco = fd->xco;
         fout->yco = fd->yco;
         fout->ZCo = fd->ZCo;
         fout->RPar = fd->RPar;
-        fout->log_action( "cc " + fc->expr + " # z from " + fd->name );
+        fout->log_action("cc " + fc->expr + " # z from " + fd->name);
         fout->weighing = COlc::_VAR;
-        if( fd->has_nonzero_dy() ) {
-             fout->weighing = COlc::_LIN;
-             cout << "Constant weight since there are data points with dy=0\n";
+        if (fd->has_nonzero_dy()) {
+            fout->weighing = COlc::_LIN;
+            cout << "Constant weight since there are data points with dy=0\n";
         }
-        for (int j=0; j<fd->nJ(); j++) {
-            PCurve sout( new CCurve );
+        for (int j = 0; j < fd->nJ(); j++) {
+            PCurve sout(new CCurve);
             sout->z = fd->VS(j)->z;
             sout->P = P;
-            sout->ParAttr.resize( fout->nP, 'u' );
-            fout->V.push_back( move(sout) );
+            sout->ParAttr.resize(fout->nP, 'u');
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout) );
+        SMem::instance()->mem_store(move(fout));
     }
 }
 
@@ -73,22 +73,22 @@ void NCurveFile::create_fitcurve()
 
 void NCurveFile::create_freecurve()
 {
-    static int default_no=0;
+    static int default_no = 0;
 
-    POlc fout( new COlc );
-    fout->curve_query( "Curve definition" );
+    POlc fout(new COlc);
+    fout->curve_query("Curve definition");
     fout->curve_set_defaults();
 
     fout->name = string("curve") + S(default_no++);
-    fout->xco = CCoord( "x", "" );
-    fout->yco = CCoord( "y", "" );
+    fout->xco = CCoord("x", "");
+    fout->yco = CCoord("y", "");
     fout->kd = -1;
-    fout->log_action( "cca " + fout->expr );
-    PCurve sout( new CCurve );
-    sout->P.resize    ( fout->nP, 1.0 );
-    sout->ParAttr.resize( fout->nP, 'u' );
-    fout->V.push_back( move(sout) );
-    SMem::instance()->mem_store( move(fout) );
+    fout->log_action("cca " + fout->expr);
+    PCurve sout(new CCurve);
+    sout->P.resize(fout->nP, 1.0);
+    sout->ParAttr.resize(fout->nP, 'u');
+    fout->V.push_back(move(sout));
+    SMem::instance()->mem_store(move(fout));
 }
 
 
@@ -101,24 +101,24 @@ void NCurveFile::create_freecurve()
 
 void NCurveFile::change_expr()
 {
-    POlc ftmp( new COlc );
-    ftmp->curve_query( "Replace curve definition by" );
+    POlc ftmp(new COlc);
+    ftmp->curve_query("Replace curve definition by");
 
     FileIterator fiter(SFSel::instance()->selC());
 
-    while( COlc *fc = fiter.nextC() ) {
+    while (COlc* fc = fiter.nextC()) {
         int nPold = fc->nP;
         fc->expr = ftmp->expr;
         fc->T = ftmp->T;
         fc->nP = ftmp->nP;
-        fc->log_action( "cm " + ftmp->expr );
+        fc->log_action("cm " + ftmp->expr);
         fc->PCo.resize(fc->nP);
-        for( int ip=nPold; ip<fc->nP; ip++ )
+        for (int ip = nPold; ip < fc->nP; ip++)
             fc->PCo[ip] = CCoord("p" + S(ip), "");
-        for (int j=0; j<fc->nJ(); j++) {
-            fc->VC(j)->P.resize( fc->nP );
-            fc->VC(j)->ParAttr.resize( fc->nP, 'u' );
-            for( int ip=nPold; ip<fc->nP; ip++ )
+        for (int j = 0; j < fc->nJ(); j++) {
+            fc->VC(j)->P.resize(fc->nP);
+            fc->VC(j)->ParAttr.resize(fc->nP, 'u');
+            for (int ip = nPold; ip < fc->nP; ip++)
                 fc->VC(j)->P[ip] = 1.0;
         }
     }
@@ -127,7 +127,7 @@ void NCurveFile::change_expr()
 
 //! Queries and sets data file or convolution file reference.
 
-void NCurveFile::set_file_reference( const string& which )
+void NCurveFile::set_file_reference(const string& which)
 // which = "d"  set data file
 //         "v"  set convolution file
 //         "v-" switch convolution off
@@ -136,37 +136,37 @@ void NCurveFile::set_file_reference( const string& which )
 
     string expr;
     RNode T;
-    if( which=="v-" )
+    if (which == "v-")
         ; // no preparation
     else {
-        if      ( which=="d" )
-            expr = wask( "Fit data file" );
-        else if ( which=="v" )
-            expr = wask( "Convolute with file" );
+        if (which == "d")
+            expr = wask("Fit data file");
+        else if (which == "v")
+            expr = wask("Convolute with file");
         else
-            throw "BUG: unexpected which="+which;
-        if (expr!="")
-            T = user_xaxparse( expr.c_str() );
+            throw "BUG: unexpected which=" + which;
+        if (expr != "")
+            T = user_xaxparse(expr.c_str());
     }
 
-    while ( COlc *fc = fiter.nextC() ) {
+    while (COlc* fc = fiter.nextC()) {
         int k = fiter.k();
-        if     ( which=="v-" )
+        if (which == "v-")
             fc->kconv = -1;
-        else if ( expr=="" ) {
+        else if (expr == "") {
             // show current settings
-            cout << format( "curve %-2d -> data %-2d" ) % k % fc->kd;
-            if( fc->kconv!=-1 )
-                cout << format( "; convolute with %-2d" ) % fc->kconv;
+            cout << format("curve %-2d -> data %-2d") % k % fc->kd;
+            if (fc->kconv != -1)
+                cout << format("; convolute with %-2d") % fc->kconv;
             cout << "\n";
         } else {
-            CContext ctx( k );
-            int lval = T->tree_val_idx( ctx, "K" );
-            SMem::instance()->mem_get_D( lval ); // assert that it is a data file
-            if      ( which=="d" ) {
+            CContext ctx(k);
+            int lval = T->tree_val_idx(ctx, "K");
+            SMem::instance()->mem_get_D(lval); // assert that it is a data file
+            if (which == "d") {
                 fc->kd = lval;
-            } else if ( which=="v" ) {
-                if ( !fc->T->has_conv() )
+            } else if (which == "v") {
+                if (!fc->T->has_conv())
                     cout << "curve " << k << " needs no convolutand\n";
                 else
                     fc->kconv = lval;
@@ -178,23 +178,23 @@ void NCurveFile::set_file_reference( const string& which )
 
 //! Queries parameters to Fix or unfix.
 
-void NCurveFile::set_par_attr( char attr )
+void NCurveFile::set_par_attr(char attr)
 {
     FileIterator fiter(SFSel::instance()->selC());
 
     static string sel;
-    sel = wask( S("Set parameter status to '")+attr+"' for which parameters", sel );
-    if( sel=="" )
+    sel = wask(S("Set parameter status to '") + attr + "' for which parameters", sel);
+    if (sel == "")
         return;
-    RNode Tsel = user_xaxparse( sel.c_str() );
+    RNode Tsel = user_xaxparse(sel.c_str());
 
-    while( COlc *fc = fiter.nextC() ) {
-        RObjVecInt vsel = Tsel->to_index_list( fc->nP );
+    while (COlc* fc = fiter.nextC()) {
+        RObjVecInt vsel = Tsel->to_index_list(fc->nP);
         if (!vsel)
             throw S("not a valid index list");
-        for( int ip: vsel->v ) {
-            for( int j=0; j<fc->nJ(); ++j ){
-                if ( fc->V[j]->frozen )
+        for (int ip : vsel->v) {
+            for (int j = 0; j < fc->nJ(); ++j) {
+                if (fc->V[j]->frozen)
                     continue;
                 fc->VC(j)->ParAttr[ip] = attr;
             }
@@ -209,40 +209,40 @@ void NCurveFile::change_range()
 {
     FileIterator fiter(SFSel::instance()->selC());
 
-    string expr = sask( "Expression restricting the fit range" );
+    string expr = sask("Expression restricting the fit range");
 
-    while( COlc *fc = fiter.nextC() ) {
+    while (COlc* fc = fiter.nextC()) {
         fc->range_expr = expr;
-        fc->log_action( "cr " + expr );
-        if( expr=="" ) {
+        fc->log_action("cr " + expr);
+        if (expr == "") {
             fc->range_T = nullptr;
             continue;
         }
-        fc->range_T = user_xaxparse( expr.c_str() );
+        fc->range_T = user_xaxparse(expr.c_str());
     }
 }
 
 
 //! Sets switches as given through command string.
 
-void NCurveFile::set_properties( string which )
+void NCurveFile::set_properties(string which)
 {
     FileIterator fiter(SFSel::instance()->selC());
 
-    while ( COlc *fc = fiter.nextC() ) {
-        if      (which=="wc")
+    while (COlc* fc = fiter.nextC()) {
+        if (which == "wc")
             fc->weighing = COlc::_LIN;
-        else if (which=="wl")
+        else if (which == "wl")
             fc->weighing = COlc::_LOG;
-        else if (which=="wv")
+        else if (which == "wv")
             fc->weighing = COlc::_VAR;
-        else if (which=="wvc")
+        else if (which == "wvc")
             fc->weighing = COlc::_VARC;
-        else if (which=="wvd")
+        else if (which == "wvd")
             fc->weighing = COlc::_VARD;
-        else if (which=="gd+")
+        else if (which == "gd+")
             fc->plot_to_grid = true;
-        else if (which=="gd-")
+        else if (which == "gd-")
             fc->plot_to_grid = false;
         else
             throw "unknown property '" + which + "'";
@@ -260,10 +260,10 @@ void NCurveFile::set_properties( string which )
 void NCurveFile::pars_query()
 {
     FileIterator fiter(SFSel::instance()->selC());
-    while( const COlc *fc = fiter.nextC() ) {
-        for( int ip=0; ip<fc->nP; ++ip ) {
+    while (const COlc* fc = fiter.nextC()) {
+        for (int ip = 0; ip < fc->nP; ++ip) {
             fc = fiter.currentC();
-            NOperate::Pointwise( "p" + S(ip) );
+            NOperate::Pointwise("p" + S(ip));
         }
     }
 }
@@ -274,21 +274,21 @@ void NCurveFile::pars_query()
 void NCurveFile::pars_abs()
 {
     static string sel;
-    sel = wask( "Absolute values of which parameters", sel );
-    if( sel=="" )
+    sel = wask("Absolute values of which parameters", sel);
+    if (sel == "")
         return;
-    RNode Tsel = user_xaxparse( sel.c_str() );
+    RNode Tsel = user_xaxparse(sel.c_str());
 
     FileIterator fiter(SFSel::instance()->selC());
-    while( COlc *fc = fiter.nextC() ) {
-        RObjVecInt vsel = Tsel->to_index_list( fc->nP );
+    while (COlc* fc = fiter.nextC()) {
+        RObjVecInt vsel = Tsel->to_index_list(fc->nP);
         if (!vsel)
             throw S("not a valid index list");
-        for ( int j=0; j<fc->nJ(); j++ ) {
-            if ( fc->V[j]->frozen )
+        for (int j = 0; j < fc->nJ(); j++) {
+            if (fc->V[j]->frozen)
                 continue;
-            for( int ip: vsel->v )
-                fc->VC(j)->P[ip] = fabs( fc->VC(j)->P[ip] );
+            for (int ip : vsel->v)
+                fc->VC(j)->P[ip] = fabs(fc->VC(j)->P[ip]);
         }
     }
 }
@@ -298,32 +298,32 @@ void NCurveFile::pars_abs()
 void NCurveFile::pars_copy()
 {
     static string ej = "j", ek = "k";
-    ek = wask( "Copy from file", ek );
-    RNode Tk = user_xaxparse( ek.c_str() );
-    ej = wask( "Copy from curve", ej );
-    RNode Tj = user_xaxparse( ej.c_str() );
+    ek = wask("Copy from file", ek);
+    RNode Tk = user_xaxparse(ek.c_str());
+    ej = wask("Copy from curve", ej);
+    RNode Tj = user_xaxparse(ej.c_str());
     static string sel;
-    sel = sask( "Copy which parameters", sel );
-    if( sel=="" )
+    sel = sask("Copy which parameters", sel);
+    if (sel == "")
         return;
-    RNode Tsel = user_xaxparse( sel.c_str() );
+    RNode Tsel = user_xaxparse(sel.c_str());
 
     FileIterator fiter(SFSel::instance()->selC());
-    while( COlc *fc = fiter.nextC() ) {
-        RObjVecInt vsel = Tsel->to_index_list( fc->nP );
+    while (COlc* fc = fiter.nextC()) {
+        RObjVecInt vsel = Tsel->to_index_list(fc->nP);
         if (!vsel)
             throw S("not a valid index list");
-        for ( int j=0; j<fc->nJ(); j++ ) {
-            if ( fc->V[j]->frozen )
+        for (int j = 0; j < fc->nJ(); j++) {
+            if (fc->V[j]->frozen)
                 continue;
-            CContext ctx( fiter.k(), j );
-            int k2 = Tk->tree_val_idx( ctx, "K" );
-            int j2 = Tj->tree_val_idx( ctx, "J" );
-            const COlc *f2 = SMem::instance()->mem_get_C( k2 );
-            if( j2>=f2->nJ() )
+            CContext ctx(fiter.k(), j);
+            int k2 = Tk->tree_val_idx(ctx, "K");
+            int j2 = Tj->tree_val_idx(ctx, "J");
+            const COlc* f2 = SMem::instance()->mem_get_C(k2);
+            if (j2 >= f2->nJ())
                 throw "no curve " + S(j2) + " in file " + S(k2);
-            for( int ip: vsel->v ) {
-                if( ip>=f2->nP )
+            for (int ip : vsel->v) {
+                if (ip >= f2->nP)
                     throw "no p" + S(ip) + " in file " + S(k2);
                 fc->VC(j)->P[ip] = f2->VC(j2)->P[ip];
             }
@@ -336,32 +336,32 @@ void NCurveFile::pars_copy()
 void NCurveFile::show_pars()
 {
     FileIterator fiter(SFSel::instance()->selC());
-    while( const COlc *fc = fiter.nextC() )
+    while (const COlc* fc = fiter.nextC())
         fc->print_info_table();
 }
 
 //! Sets resolution file reference *sv, *kv, *jv.
 
-void NCurveFile::get_conv( const CSpec **sv, int *kv, int *jv, int k, int j )
+void NCurveFile::get_conv(const CSpec** sv, int* kv, int* jv, int k, int j)
 {
     // set *kv and *fv for given k:
-    const COlc *fc = SMem::instance()->mem_get_C(k);
+    const COlc* fc = SMem::instance()->mem_get_C(k);
     *kv = fc->kconv;
-    if( *kv==(int)-1 ) { // no convolution
+    if (*kv == (int)-1) { // no convolution
         *jv = -1; // should not be needed
         return;
     }
-    const COld *fv = SMem::instance()->mem_get_D(*kv);
+    const COld* fv = SMem::instance()->mem_get_D(*kv);
 
     // set *jv and *sv for given j:
-    if ( j>=fc->nJ() )
+    if (j >= fc->nJ())
         throw S("BUG: setConv called with invalid j");
-    if      ( fv->nJ()==1 )       // nJ:1  correspondence
+    if (fv->nJ() == 1) // nJ:1  correspondence
         *jv = 0;
-    else if ( fv->nJ()==fc->nJ() ) // nJ:nJ correspondence
+    else if (fv->nJ() == fc->nJ()) // nJ:nJ correspondence
         *jv = j;
     else
-        throw "cannot convolute file " + S(k) + " with resolution " +
-            S(*kv) + ": number of spectra does not match";
+        throw "cannot convolute file " + S(k) + " with resolution " + S(*kv)
+            + ": number of spectra does not match";
     *sv = fv->VS(*jv);
 }
diff --git a/pub/lib/curve.hpp b/pub/lib/curve.hpp
index 7f29315a9fd8bc58edfac41f25cb57899b451f62..f8c9461bc01fcd5c570d172f05a0482a216ed927 100644
--- a/pub/lib/curve.hpp
+++ b/pub/lib/curve.hpp
@@ -7,24 +7,26 @@
 //! \file  curve.hpp
 //! \brief NCurveFile: Methods to create, inspect, modify curve files.
 
+class CSpec;
 
 //! Methods to create, inspect, modify curve files.
 
-namespace NCurveFile {
+namespace NCurveFile
+{
 
-    void create_fitcurve();
-    void create_freecurve();
-    void change_expr();
-    void change_range();
-    void set_file_reference( const string& which );
+void create_fitcurve();
+void create_freecurve();
+void change_expr();
+void change_range();
+void set_file_reference(const string& which);
 
-    void set_properties( string which );
-    void pars_query();
-    void pars_abs();
-    void pars_copy();
-    void show_pars();
-    void edit_pars();
-    void set_par_attr( char attr );
+void set_properties(string which);
+void pars_query();
+void pars_abs();
+void pars_copy();
+void show_pars();
+void edit_pars();
+void set_par_attr(char attr);
 
-    void get_conv( const CSpec **sv, int *kv, int *jv, int k, int j );
+void get_conv(const CSpec** sv, int* kv, int* jv, int k, int j);
 }
diff --git a/pub/lib/defs.hpp b/pub/lib/defs.hpp
index 2025d24baa131569aa64123488250c71cce7eab9..043855bdbdc3cc9af0a1afefae82db9a85481b99 100644
--- a/pub/lib/defs.hpp
+++ b/pub/lib/defs.hpp
@@ -17,7 +17,7 @@
 #include "../trivia/string_convs.hpp"
 #define S(a) triv::strg((a))
 
-#define SQR(a) ((a)*(a))
+#define SQR(a) ((a) * (a))
 
 using std::map;
 using std::string;
diff --git a/pub/lib/edif.cpp b/pub/lib/edif.cpp
index 69edf6753a277d1d0dfc3eff510f9aa8391b2606..8b37097dbd0396c6a8c2b3178c6de7713ba5dce2 100644
--- a/pub/lib/edif.cpp
+++ b/pub/lib/edif.cpp
@@ -9,22 +9,22 @@
 
 #include "defs.hpp"
 
-#include <fstream>
 #include <boost/format.hpp>
+#include <fstream>
 
+#include "../readplus/ask.hpp"
+#include "../trivia/file_ops.hpp"
 #include "../trivia/string_ops.hpp"
 #include "../trivia/vector_ops.hpp"
-#include "../trivia/file_ops.hpp"
-#include "../readplus/ask.hpp"
 
-#include "olf.hpp"
-#include "mem.hpp"
+#include "edif.hpp"
 #include "fsel.hpp"
-#include "loop.hpp"
-#include "slice.hpp"
 #include "genus.hpp"
+#include "loop.hpp"
+#include "mem.hpp"
 #include "obj.hpp"
-#include "edif.hpp"
+#include "olf.hpp"
+#include "slice.hpp"
 
 using boost::format;
 
@@ -37,49 +37,47 @@ using boost::format;
 
 void NEdif::show_files()
 {
-    FileIterator fiter( triv::iota_list( SMem::instance()->mem_size() ), true );
-    while( const COlo *f = fiter.next() ) {
-        const COlc *fc = dynamic_cast<const COlc*>( f );
-        const COld *fd = dynamic_cast<const COld*>( f );
+    FileIterator fiter(triv::iota_list(SMem::instance()->mem_size()), true);
+    while (const COlo* f = fiter.next()) {
+        const COlc* fc = dynamic_cast<const COlc*>(f);
+        const COld* fd = dynamic_cast<const COld*>(f);
         // prepare ztext
         string ztext;
-        if( f->nZ() ){
-            if        ( f->ZCo.size()==1 ) {
+        if (f->nZ()) {
+            if (f->ZCo.size() == 1) {
                 ztext = f->ZCo[0].str_compact(16);
-            } else if ( f->ZCo.size()==2 ) {
+            } else if (f->ZCo.size() == 2) {
                 ztext = f->ZCo[0].str_compact(10) + ", ";
-                ztext += f->ZCo[1].str_compact( 16 - ztext.length() );
-            } else if ( f->ZCo.size()==3 ) {
+                ztext += f->ZCo[1].str_compact(16 - ztext.length());
+            } else if (f->ZCo.size() == 3) {
                 ztext = f->ZCo[0].str_compact(8) + ",";
-                ztext += f->ZCo[1].str_compact(16 - ztext.length()-4) + ",";
+                ztext += f->ZCo[1].str_compact(16 - ztext.length() - 4) + ",";
                 ztext += f->ZCo[2].str_compact(16 - ztext.length());
             } else {
                 ztext = f->ZCo[0].str_compact(6) + ",";
-                ztext += f->ZCo[1].str_compact(16 - ztext.length()-9) + ",";
-                ztext += f->ZCo[2].str_compact(16 - ztext.length()-6) + ",";
-                ztext += f->ZCo[3].str_compact(16 - ztext.length()-3) + ",..";
+                ztext += f->ZCo[1].str_compact(16 - ztext.length() - 9) + ",";
+                ztext += f->ZCo[2].str_compact(16 - ztext.length() - 6) + ",";
+                ztext += f->ZCo[3].str_compact(16 - ztext.length() - 3) + ",..";
             }
         } else {
-            ztext = string( 16, ' ' );
+            ztext = string(16, ' ');
         }
         // prepare xytext
         string xytext;
-        if( fd ) {
+        if (fd) {
             int npts = fd->nPts();
             string txtpts;
             if (npts)
-                txtpts = str( format( "%-6d" ) % npts );
+                txtpts = str(format("%-6d") % npts);
             else
                 txtpts = "     ?";
             xytext = txtpts + f->xco.str_compact(12) + " " + f->yco.str_compact(12);
-        } else if ( fc ) {
-            xytext = fc->expr.substr(0,25);
+        } else if (fc) {
+            xytext = fc->expr.substr(0, 25);
         }
         // print everything
-        cout << format( "%3i%1s%-16s %5i %-16s %-32s\n" ) %
-            fiter.k() %
-            ( f->as_on_disk ? "=" : " " ) %
-            f->name % f->nJ() % ztext % xytext;
+        cout << format("%3i%1s%-16s %5i %-16s %-32s\n") % fiter.k() % (f->as_on_disk ? "=" : " ")
+                % f->name % f->nJ() % ztext % xytext;
     }
 }
 
@@ -89,22 +87,22 @@ void NEdif::show_files()
 void NEdif::show_spectra()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while( const COlo *f = fiter.next() ) {
+    while (const COlo* f = fiter.next()) {
         cout << "file " << fiter.k() << ":\n";
-        if ( const COld *fd = dynamic_cast<const COld*>( f ) ) {
-            printf( "%3s ", "j" );
-            for ( const CCoord& zco: f->ZCo )
+        if (const COld* fd = dynamic_cast<const COld*>(f)) {
+            printf("%3s ", "j");
+            for (const CCoord& zco : f->ZCo)
                 printf(" %12.12s", zco.str_compact().c_str());
-            printf( " %12s (%4s) %12s\n", "x_inf", "#pts", "x_sup" );
-            for ( int j=0; j<f->nJ(); j++ ) {
-                printf( "%3i%c", j, f->V[j]->frozen ? '/' : ' ' );
-                for ( RObj z: f->V[j]->z )
-                    printf( " %s", z->to_s(12,12,6).c_str() );
-                printf( " %12.6g (%4i) %12.6g\n",
-                        fd->VS(j)->x[0], fd->nPts(j),
-                        fd->VS(j)->x[fd->nPts(j)-1] );
+            printf(" %12s (%4s) %12s\n", "x_inf", "#pts", "x_sup");
+            for (int j = 0; j < f->nJ(); j++) {
+                printf("%3i%c", j, f->V[j]->frozen ? '/' : ' ');
+                for (RObj z : f->V[j]->z)
+                    printf(" %s", z->to_s(12, 12, 6).c_str());
+                printf(
+                    " %12.6g (%4i) %12.6g\n", fd->VS(j)->x[0], fd->nPts(j),
+                    fd->VS(j)->x[fd->nPts(j) - 1]);
             }
-        } else if ( const COlc *fc = dynamic_cast<const COlc*>( f ) ) {
+        } else if (const COlc* fc = dynamic_cast<const COlc*>(f)) {
             fc->print_info_table();
         }
     }
@@ -116,11 +114,11 @@ void NEdif::show_spectra()
 void NEdif::show_coord()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while( const COlo *f = fiter.next() ) {
-        string out = str( format( "%3i" ) % fiter.k() );
+    while (const COlo* f = fiter.next()) {
+        string out = str(format("%3i") % fiter.k());
         out += " x: " + f->xco.str_compact();
         out += "  y: " + f->yco.str_compact();
-        for ( int i=0; i<f->nZ(); i++ )
+        for (int i = 0; i < f->nZ(); i++)
             out += "  z" + S(i) + ": " + f->ZCo[i].str_compact();
         cout << out << "\n";
     }
@@ -132,23 +130,24 @@ void NEdif::show_coord()
 void NEdif::show_coordZ()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    const COlo *f = fiter.next();
+    const COlo* f = fiter.next();
     // Get current coordinates:
-    vector<CCoord> ZCo = f->ZCo;;
+    vector<CCoord> ZCo = f->ZCo;
+    ;
     int nz = ZCo.size();
     if (nz)
-        for ( int i=0; i<nz; ++i)
+        for (int i = 0; i < nz; ++i)
             printf("  %i: %s\n", i, ZCo[i].str_compact().c_str());
     else
         printf("  there are no z coordinates\n");
 
     // Check other input files:
-    while ( f = fiter.next() ) {
+    while (f = fiter.next()) {
         int k = fiter.k();
-        if ( f->ZCo.size()!=nz )
+        if (f->ZCo.size() != nz)
             throw "file " + S(k) + " has different number of z coordinates";
-        for ( int i=0; i<nz; ++i)
-            if ( f->ZCo[i]!=ZCo[i] )
+        for (int i = 0; i < nz; ++i)
+            if (f->ZCo[i] != ZCo[i])
                 throw "file " + S(k) + " has different z coordinate " + S(i);
     }
 }
@@ -159,9 +158,9 @@ void NEdif::show_coordZ()
 void NEdif::show_numpars()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while ( const COlo *f = fiter.next() ) {
+    while (const COlo* f = fiter.next()) {
         cout << "# file " << fiter.k() << ":\n";
-        for ( int m=0; m<f->RPar.size(); m++ )
+        for (int m = 0; m < f->RPar.size(); m++)
             cout << "  " << f->RPar[m].Co.str_compact() << ": " << f->RPar[m].val << "\n";
     }
 }
@@ -172,10 +171,10 @@ void NEdif::show_numpars()
 void NEdif::show_doc()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while( const COlo *f = fiter.next() ) {
-        if( fiter.size()>1 )
+    while (const COlo* f = fiter.next()) {
+        if (fiter.size() > 1)
             cout << "# file " << fiter.k() << ":\n";
-        for ( int i=0; i<f->lDoc.size(); i++ )
+        for (int i = 0; i < f->lDoc.size(); i++)
             cout << f->lDoc[i] << "\n";
     }
 }
@@ -191,10 +190,10 @@ void NEdif::show_doc()
 void NEdif::edit_fnam()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while( COlo* f = fiter.next() ) {
-        string fnam = wask( ("Rename " + f->name).c_str(), f->name );
-        if ( fnam != f->name ){
-            f->log_action( "ef " + fnam + " # < " + f->name );
+    while (COlo* f = fiter.next()) {
+        string fnam = wask(("Rename " + f->name).c_str(), f->name);
+        if (fnam != f->name) {
+            f->log_action("ef " + fnam + " # < " + f->name);
             f->name = fnam;
         }
     }
@@ -202,51 +201,54 @@ void NEdif::edit_fnam()
 
 //! Modify coordinate names and units.
 
-void NEdif::edit_coord( string which )
+void NEdif::edit_coord(string which)
 { // EMBEDDED_DIALOG
-    CGenus genus( which );
+    CGenus genus(which);
 
     FileIterator fiter(SFSel::instance()->sel());
     // check whether all files have the same coordinate:
-    COlo *fin = fiter.next();
-    CCoord old_co = fin->coord( genus );
+    COlo* fin = fiter.next();
+    CCoord old_co = fin->coord(genus);
     bool uniform = true;
     bool multifile = false;
-    while ( fin = fiter.next() ) {
+    while (fin = fiter.next()) {
         multifile = true;
-        if ( fin->coord( genus )!=old_co ) {
+        if (fin->coord(genus) != old_co) {
             uniform = false;
             break;
         }
     }
 
     // list current values:
-    if ( multifile && !uniform ) {
+    if (multifile && !uniform) {
         fiter.reset();
-        while ( fin = fiter.next() ) {
-            cout << "  file " << fiter.k() << ": " << fin->coord( genus ) <<"\n";
+        while (fin = fiter.next()) {
+            cout << "  file " << fiter.k() << ": " << fin->coord(genus) << "\n";
         }
     }
-    string in = sask( "Coordinate "+which+": name(unit)" +
-                      ( multifile ? " or f to proceed file by file" : "" ),
-                      uniform ? old_co.str_compact() : "f" );
+    string in = sask(
+        "Coordinate " + which + ": name(unit)" + (multifile ? " or f to proceed file by file" : ""),
+        uniform ? old_co.str_compact() : "f");
     fiter.reset();
-    if ( multifile && in=="f" ) {
-        while ( fin = fiter.next() ) {
-            old_co = fin->coord( genus );
-            in = sask( "Coordinate "+which+" for file "+S(fiter.k())+": name(unit)",
-                       old_co.str_compact() );
+    if (multifile && in == "f") {
+        while (fin = fiter.next()) {
+            old_co = fin->coord(genus);
+            in = sask(
+                "Coordinate " + which + " for file " + S(fiter.k()) + ": name(unit)",
+                old_co.str_compact());
             CCoord new_co(in);
-            fin->log_action( "ec"+string(which)+" "+new_co.str_compact()+
-                                 " # old: " + old_co.str_compact() );
-            fin->set_coord( genus, new_co );
+            fin->log_action(
+                "ec" + string(which) + " " + new_co.str_compact() + " # old: "
+                + old_co.str_compact());
+            fin->set_coord(genus, new_co);
         }
     } else {
         CCoord new_co(in);
-        while ( fin = fiter.next() ) {
-            fin->log_action( "ec"+string(which)+" "+new_co.str_compact()+
-                                 " # old: " + old_co.str_compact() );
-            fin->set_coord( genus, new_co );
+        while (fin = fiter.next()) {
+            fin->log_action(
+                "ec" + string(which) + " " + new_co.str_compact() + " # old: "
+                + old_co.str_compact());
+            fin->set_coord(genus, new_co);
         }
     }
 }
@@ -257,53 +259,53 @@ void NEdif::edit_coord( string which )
 void NEdif::edit_doc()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    COlo *f;
+    COlo* f;
 
     // obtain unused tmp file name:
-    string fname = triv::next_tmp_file( "/tmp/frida.%i" );
+    string fname = triv::next_tmp_file("/tmp/frida.%i");
 
     // transfer to tmp file:
-    std::ofstream Fo( fname.c_str() );
-    while ( f = fiter.next() ) {
+    std::ofstream Fo(fname.c_str());
+    while (f = fiter.next()) {
         Fo << "### FILE " << fiter.k() << " " << f->name << " ###\n";
-        for ( string lin: f->lDoc )
+        for (string lin : f->lDoc)
             Fo << lin << "\n";
     }
     Fo.close();
 
     // let user edit that file:
-    system( ("vi " + fname).c_str() );
+    system(("vi " + fname).c_str());
 
     // read back from tmp file:
     fiter.reset();
     FILE* Fi;
-    if( !(Fi = fopen( fname.c_str(), "r" )) )
+    if (!(Fi = fopen(fname.c_str(), "r")))
         throw S("cannot read back from tmp file");
     string line;
-    while ( triv::freadln(Fi, &line) ){
-        if ( line.substr(0,3)=="###" ) {
+    while (triv::freadln(Fi, &line)) {
+        if (line.substr(0, 3) == "###") {
             f = fiter.next();
-            if ( line.substr(3,6) != " FILE " )
+            if (line.substr(3, 6) != " FILE ")
                 throw S("invalid change in ### line: 'FILE' not found");
             string aux;
-            triv::string_extract_word( line.substr(9), &aux, &line );
+            triv::string_extract_word(line.substr(9), &aux, &line);
             int kin;
-            if ( !triv::any2int( aux, &kin ) )
+            if (!triv::any2int(aux, &kin))
                 throw S("invalid change in ### line: file number not found");
-            if ( kin != fiter.k() )
+            if (kin != fiter.k())
                 throw S("invalid change in ### line: wrong file number");
-            triv::string_extract_word( line, &aux, &line );
-            if ( aux != f->name )
+            triv::string_extract_word(line, &aux, &line);
+            if (aux != f->name)
                 throw S("invalid change in ### line: wrong file name");
             f->lDoc.clear();
         } else {
-            f->log_action( line );
+            f->log_action(line);
         }
     }
 
     // delete tmp file:
-    fclose( Fi );
-    system( ("rm -f " + fname).c_str() );
+    fclose(Fi);
+    system(("rm -f " + fname).c_str());
 }
 
 
@@ -311,11 +313,11 @@ void NEdif::edit_doc()
 
 void NEdif::del_numpar()
 {
-    int iN = zask( "Index of numeric parameter to delete" );
+    int iN = zask("Index of numeric parameter to delete");
     FileIterator fiter(SFSel::instance()->sel());
-    while ( COlo *f = fiter.next() ) {
-        if( iN>=f->RPar.size() )
-            throw "file " + S( fiter.k() ) + " has no numpar n" + S(iN);
-        f->RPar.erase( f->RPar.begin()+iN );
+    while (COlo* f = fiter.next()) {
+        if (iN >= f->RPar.size())
+            throw "file " + S(fiter.k()) + " has no numpar n" + S(iN);
+        f->RPar.erase(f->RPar.begin() + iN);
     }
 }
diff --git a/pub/lib/edif.hpp b/pub/lib/edif.hpp
index e2811f0df0c073fa86c9e961d9b5372d197c41f3..591adbb1889f37777373fa6bebcfad951b9aa3f4 100644
--- a/pub/lib/edif.hpp
+++ b/pub/lib/edif.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                         
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  edif.hpp
@@ -10,15 +10,16 @@
 
 //! Methods to inspect and edit data and metadata.
 
-namespace NEdif {
-    void show_files();
-    void show_spectra();
-    void show_coord();
-    void show_coordZ();
-    void show_numpars();
-    void show_doc();
-    void edit_fnam();
-    void edit_coord( string which );
-    void edit_doc();
-    void del_numpar();
+namespace NEdif
+{
+void show_files();
+void show_spectra();
+void show_coord();
+void show_coordZ();
+void show_numpars();
+void show_doc();
+void edit_fnam();
+void edit_coord(string which);
+void edit_doc();
+void del_numpar();
 }
diff --git a/pub/lib/expr.cpp b/pub/lib/expr.cpp
index bb016db032b1ff512960ed0e7d2d4566dcc5b504..f9005b551cdbb37e958983ba042b20adfe49594c 100644
--- a/pub/lib/expr.cpp
+++ b/pub/lib/expr.cpp
@@ -14,10 +14,10 @@ using boost::format;
 
 #include "../trivia/vector_ops.hpp"
 
-#include "olf.hpp"
+#include "expr.hpp"
 #include "mem.hpp"
 #include "obj.hpp"
-#include "expr.hpp"
+#include "olf.hpp"
 #include "xax_lex.hpp"
 
 
@@ -28,52 +28,57 @@ using boost::format;
 
 //! Constructor. Sets k,j,i to arguments. Sets other members to defaults.
 
-CContext::CContext( int _k, int _j, int _i )
-    : k(_k), j(_j), i(_i),                     // set from arguments
-      vt(0), dim(_1), want_error(false), nv(0) // can be changed later
+CContext::CContext(int _k, int _j, int _i)
+    : k(_k)
+    , j(_j)
+    , i(_i)
+    , // set from arguments
+    vt(0)
+    , dim(_1)
+    , want_error(false)
+    , nv(0) // can be changed later
 {
-    if ( k==(int)-1 )
+    if (k == (int)-1)
         return; // not sure whether k=-1 makes sense
-    const COlo *f = SMem::instance()->mem_get(k);
-    if ( j==(int)-1 ) {
-        if ( f->nJ()==1 )
+    const COlo* f = SMem::instance()->mem_get(k);
+    if (j == (int)-1) {
+        if (f->nJ() == 1)
             j = 0;
-    } else if ( j>=f->nJ() )
-        throw "invalid evaluation context, j="+S(j)+">=nJ="+S(f->nJ());
+    } else if (j >= f->nJ())
+        throw "invalid evaluation context, j=" + S(j) + ">=nJ=" + S(f->nJ());
 
-    const COld *fd = dynamic_cast<const COld*>(f);
-    if ( !fd ) {
-        if ( i!=(int)-1 )
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd) {
+        if (i != (int)-1)
             throw S("invalid evaluation context, i set for curve file");
         return;
     }
 
-    if ( j==(int)-1 )
+    if (j == (int)-1)
         return;
     int ni = fd->nPts(j);
-    if ( i==(int)-1 ) {
-        if ( ni==1 )
+    if (i == (int)-1) {
+        if (ni == 1)
             i = 0;
-    } else if ( i>=ni )
-        throw "invalid evaluation context for j="+S(j)+": i="+
-            S(i)+">=ni="+S(ni);
+    } else if (i >= ni)
+        throw "invalid evaluation context for j=" + S(j) + ": i=" + S(i) + ">=ni=" + S(ni);
 }
 
 
 //! Sets request of a vector of doubles, corresponding to input points 't'.
 
-void CContext::request_VT( const vector<double> *_vt )
+void CContext::request_VT(const vector<double>* _vt)
 {
     dim = _VT;
     nv = _vt->size();
     vt = _vt;
-    if( !triv::is_equidist( &vt_step, *vt ) || vt_step<0 )
+    if (!triv::is_equidist(&vt_step, *vt) || vt_step < 0)
         vt_step = 0;
 }
 
 //! Sets request of a vector of _nv indices.
 
-void CContext::request_VI( int _nv )
+void CContext::request_VI(int _nv)
 {
     dim = _VI;
     nv = _nv;
@@ -83,14 +88,14 @@ void CContext::request_VI( int _nv )
 
 string CContext::context_info() const
 {
-    string out = str( format( "[%i,%i," ) % k % j );
-    if ( dim==_1 )
-        out += str( format( "%i]" ) % i );
-    else if ( dim==_VI )
-        out += str( format( "{%i}]" ) % nv );
-    else if ( dim==_VT )
-        out += str( format( "%i*t]" ) % nv );
-    if ( want_error )
+    string out = str(format("[%i,%i,") % k % j);
+    if (dim == _1)
+        out += str(format("%i]") % i);
+    else if (dim == _VI)
+        out += str(format("{%i}]") % nv);
+    else if (dim == _VT)
+        out += str(format("%i*t]") % nv);
+    if (want_error)
         out += "+-";
     return out;
 }
@@ -103,58 +108,52 @@ string CContext::context_info() const
 
 //! Returns file index k in given context.
 
-int CRef1::get_k( const CContext& ctx ) const
+int CRef1::get_k(const CContext& ctx) const
 {
     int k;
-    if ( tk ) {
-        RObj tmp = tk->tree_val( ctx );
+    if (tk) {
+        RObj tmp = tk->tree_val(ctx);
         RObjInt pi = PCAST<const CObjInt>(tmp);
-        if ( !pi )
+        if (!pi)
             throw "index K=" + tk->tree_info() + "->" + tmp->to_s() + " is not integer";
         k = pi->val;
     } else {
         k = ctx.k;
     }
-    if ( k==(int)-1 )
+    if (k == (int)-1)
         throw S("missing or invalid k");
-    SMem::instance()->mem_get( k ); // to assert existence of file
+    SMem::instance()->mem_get(k); // to assert existence of file
     return k;
 }
 
 
 //! Returns true if index k has an explicit dependence on i.
 
-bool CRef1::k_depends_on_i() const
-{
-    return tk && tk->i_dependent();
-}
+bool CRef1::k_depends_on_i() const { return tk && tk->i_dependent(); }
 
 
 //! Returns string representation of the class instance.
 
-string CRef1::ref_info() const
-{
-    return "[" + ( tk ? tk->tree_info() : "K" ) + "]";
-}
+string CRef1::ref_info() const { return "[" + (tk ? tk->tree_info() : "K") + "]"; }
 
 
 //! Returns spectrum index j in given context.
 
-int CRef2::get_j( const CContext& ctx, int nj ) const
+int CRef2::get_j(const CContext& ctx, int nj) const
 {
     int j;
-    if ( tj ) {
-        RObj tmp = tj->tree_val( ctx );
+    if (tj) {
+        RObj tmp = tj->tree_val(ctx);
         RObjInt pi = PCAST<const CObjInt>(tmp);
-        if ( !pi )
+        if (!pi)
             throw "index J=" + tj->tree_info() + "->" + tmp->to_s() + " is not integer";
         j = pi->val;
     } else {
         j = ctx.j;
     }
-    if ( j==-1 )
+    if (j == -1)
         throw S("index J=-1 (not defined?)");
-    else if ( j<0 || j>=nj )
+    else if (j < 0 || j >= nj)
         throw "index J=" + S(j) + " is out of bounds";
     return j;
 }
@@ -162,19 +161,14 @@ int CRef2::get_j( const CContext& ctx, int nj ) const
 
 //! Returns true if index j has an explicit dependence on i.
 
-bool CRef2::j_depends_on_i() const
-{
-    return tj && tj->i_dependent();
-}
+bool CRef2::j_depends_on_i() const { return tj && tj->i_dependent(); }
 
 
 //! Returns string representation of the class instance.
 
 string CRef2::ref_info() const
 {
-    return "[" +
-        ( tk ? tk->tree_info() : "K" ) + "," +
-        ( tj ? tj->tree_info() : "J" ) + "]";
+    return "[" + (tk ? tk->tree_info() : "K") + "," + (tj ? tj->tree_info() : "J") + "]";
 }
 
 
@@ -182,10 +176,8 @@ string CRef2::ref_info() const
 
 string CRef3::ref_info() const
 {
-    return "[" +
-        ( tk ? tk->tree_info() : "K" ) + "," +
-        ( tj ? tj->tree_info() : "J" ) + "," +
-        ( ti ? ti->tree_info() : "I" ) + "]";
+    return "[" + (tk ? tk->tree_info() : "K") + "," + (tj ? tj->tree_info() : "J") + ","
+        + (ti ? ti->tree_info() : "I") + "]";
 }
 
 
@@ -196,38 +188,38 @@ string CRef3::ref_info() const
 
 //! Evaluates the node, and returns a non-negative integer.
 
-int CNode::tree_val_idx( const CContext& ctx, const string& name ) const
+int CNode::tree_val_idx(const CContext& ctx, const string& name) const
 {
-    RObj val = tree_val( ctx );
+    RObj val = tree_val(ctx);
     RObjInt pi = PCAST<const CObjInt>(val);
-    if ( !pi )
-        throw "index "+name+"="+val->to_s()+" is not integer";
+    if (!pi)
+        throw "index " + name + "=" + val->to_s() + " is not integer";
     int ret = pi->val;
-    if( ret<0 )
-        throw "index "+name+"="+val->to_s()+" is negativ";
+    if (ret < 0)
+        throw "index " + name + "=" + val->to_s() + " is negativ";
     return ret;
 }
 
 
 //! Evaluates the node, and returns a list of non-negative integers.
 
-RObjVecInt CNode::to_index_list( int siz ) const
+RObjVecInt CNode::to_index_list(int siz) const
 {
     CContext ctx;
     int nret = siz;
-    ctx.request_VI( nret );
+    ctx.request_VI(nret);
     ctx.want_error = false;
-    RObj val = tree_val( ctx );
-    if ( RObjInt ri = PCAST<const CObjInt>( val ) ) {
-        PObjVecInt ret( new CObjVecInt );
+    RObj val = tree_val(ctx);
+    if (RObjInt ri = PCAST<const CObjInt>(val)) {
+        PObjVecInt ret(new CObjVecInt);
         int ival = ri->to_i();
-        if( ival<0 || ival>=siz )
+        if (ival < 0 || ival >= siz)
             return nullptr;
-        ret->v.push_back( ival );
+        ret->v.push_back(ival);
         return ret;
-    } else if ( RObjVecInt riv = PCAST<const CObjVecInt>( val ) ) {
-        for( int ival: riv->v )
-            if( ival<0 || ival>=siz )
+    } else if (RObjVecInt riv = PCAST<const CObjVecInt>(val)) {
+        for (int ival : riv->v)
+            if (ival < 0 || ival >= siz)
                 return nullptr;
         return riv;
     } else {
@@ -241,23 +233,23 @@ RObjVecInt CNode::to_index_list( int siz ) const
 
 //! Evaluates the node in a scalar context.
 
-RObj CNode::tree_point_val( int k, int j, int i ) const
+RObj CNode::tree_point_val(int k, int j, int i) const
 {
-    CContext ctx( k, j, i );
+    CContext ctx(k, j, i);
     ctx.want_error = true;
-    return tree_val( ctx );
+    return tree_val(ctx);
 }
 
 
 //! Evaluates the node, and returns a double. OBSOLET!?
 
-double CNode::tree_point_dbl( int k, int j, int i ) const
+double CNode::tree_point_dbl(int k, int j, int i) const
 {
-    CContext ctx( k, j, i );
+    CContext ctx(k, j, i);
     ctx.want_error = false;
-    RObj val = tree_val( ctx );
+    RObj val = tree_val(ctx);
     RObjNum pr = PCAST<const CObjNum>(val);
-    if ( !pr )
+    if (!pr)
         throw S("Tree point value has unexpected type");
     return pr->to_r();
 }
@@ -265,25 +257,25 @@ double CNode::tree_point_dbl( int k, int j, int i ) const
 
 //! Evaluates the node, and sets vectors *ret and *dret according to the result.
 
-void CNode::tree_vec_val( vector<double> *ret, vector<double> *dret, int k, int j ) const
+void CNode::tree_vec_val(vector<double>* ret, vector<double>* dret, int k, int j) const
 {
-    CContext ctx( k, j );
+    CContext ctx(k, j);
     int nret = ret->size();
-    ctx.request_VI( nret );
+    ctx.request_VI(nret);
     ctx.want_error = (bool)dret;
-    RObj val = tree_val( ctx );
-    if        ( RObjNum pr = PCAST<const CObjNum>(val) ) {
-        ret->assign( nret, pr->to_r() );
-        if( dret && pr->has_err() )
-            dret->assign( nret, pr->to_dr() );
-
-    } else if ( RObjVecInt pv = PCAST<const CObjVecInt>(val) ) {
-        for( int i=0; i<nret; ++i )
+    RObj val = tree_val(ctx);
+    if (RObjNum pr = PCAST<const CObjNum>(val)) {
+        ret->assign(nret, pr->to_r());
+        if (dret && pr->has_err())
+            dret->assign(nret, pr->to_dr());
+
+    } else if (RObjVecInt pv = PCAST<const CObjVecInt>(val)) {
+        for (int i = 0; i < nret; ++i)
             (*ret)[i] = pv->to_r(i);
-    } else if ( RObjVecDbl pv = PCAST<const CObjVecDbl>(val) ) {
+    } else if (RObjVecDbl pv = PCAST<const CObjVecDbl>(val)) {
         *ret = pv->v;
-        if( dret ) {
-            if ( RObjVecEnu pdv = PCAST<const CObjVecEnu>(val) )
+        if (dret) {
+            if (RObjVecEnu pdv = PCAST<const CObjVecEnu>(val))
                 *dret = pdv->dv;
             else
                 dret->clear();
@@ -294,8 +286,8 @@ void CNode::tree_vec_val( vector<double> *ret, vector<double> *dret, int k, int
 
 //! Returns a node obtained by parsing the given expression.
 
-RObj CNode::eval( string expr )
+RObj CNode::eval(string expr)
 {
-    RNode T = user_xaxparse( expr.c_str() );
+    RNode T = user_xaxparse(expr.c_str());
     return T->tree_point_val();
 }
diff --git a/pub/lib/expr.hpp b/pub/lib/expr.hpp
index 784d4f31f5b708827bbaa18461d642c8dca87737..618cf9e1929e7d1330bb929b4f0744ae63291c85 100644
--- a/pub/lib/expr.hpp
+++ b/pub/lib/expr.hpp
@@ -9,21 +9,22 @@
 
 //! The context in which a CNode shall be evaluated.
 
-class CContext {
- public:
-    int k;                         //!< Index of file we are refering to
-    int j;                         //!< Index of scan we are refering to
-    int i;                         //!< Index of point we are refering to
-    const vector<double> *vt;      //!< A vector we may refer to
-    double vt_step;                //!< Step of equidistant vt, otherwise 0
-    enum TDim { _1, _VI, _VT } dim;//!< Kind of requested output
-    bool want_error;               //!< Are errors requested?
-    int nv;                        //!< Number of requested vector elements
-
-    CContext( int _k=-1, int _j=-1, int _i=-1 );
-
-    void request_VT( const vector<double> *_vt );
-    void request_VI( int _nv );
+class CContext
+{
+public:
+    int k; //!< Index of file we are refering to
+    int j; //!< Index of scan we are refering to
+    int i; //!< Index of point we are refering to
+    const vector<double>* vt; //!< A vector we may refer to
+    double vt_step; //!< Step of equidistant vt, otherwise 0
+    enum TDim { _1, _VI, _VT } dim; //!< Kind of requested output
+    bool want_error; //!< Are errors requested?
+    int nv; //!< Number of requested vector elements
+
+    CContext(int _k = -1, int _j = -1, int _i = -1);
+
+    void request_VT(const vector<double>* _vt);
+    void request_VI(int _nv);
 
     string context_info() const;
 };
@@ -31,11 +32,12 @@ class CContext {
 
 //! Holds a node that yields index k.
 
-class CRef1 {
- public:
+class CRef1
+{
+public:
     RNode tk; //!< A node yielding the workspace index k.
-    CRef1( RNode _tk=nullptr ) : tk(_tk) {}
-    int get_k( const CContext& ctx ) const;
+    CRef1(RNode _tk = nullptr) : tk(_tk) {}
+    int get_k(const CContext& ctx) const;
     bool k_depends_on_i() const;
     virtual string ref_info() const;
 };
@@ -43,11 +45,12 @@ class CRef1 {
 
 //! Holds a pair of nodes that yield indices k,j.
 
-class CRef2 : public CRef1 {
- public:
+class CRef2 : public CRef1
+{
+public:
     RNode tj; //!< A node yielding the spectrum index j.
-    CRef2( RNode _tk=nullptr, RNode _tj=nullptr ) : CRef1(_tk), tj(_tj) {}
-    int get_j( const CContext& ctx, int nj ) const;
+    CRef2(RNode _tk = nullptr, RNode _tj = nullptr) : CRef1(_tk), tj(_tj) {}
+    int get_j(const CContext& ctx, int nj) const;
     bool j_depends_on_i() const;
     virtual string ref_info() const;
 };
@@ -55,19 +58,23 @@ class CRef2 : public CRef1 {
 
 //! Holds a triple of nodes that yield indices k,j,i.
 
-class CRef3 : public CRef2 {
- public:
+class CRef3 : public CRef2
+{
+public:
     RNode ti; //!< A node yielding the point index i.
-    CRef3( RNode _tk=nullptr, RNode _tj=nullptr, RNode _ti=nullptr ) : CRef2(_tk,_tj), ti(_ti) {}
+    CRef3(RNode _tk = nullptr, RNode _tj = nullptr, RNode _ti = nullptr) : CRef2(_tk, _tj), ti(_ti)
+    {
+    }
     virtual string ref_info() const;
 };
 
 
 //! Virtual base class for all kinds of nodes in an expression tree.
 
-class CNode {
- private:
- public:
+class CNode
+{
+private:
+public:
     virtual ~CNode() {}
 
     virtual int npar() const { return 0; }
@@ -79,21 +86,21 @@ class CNode {
     virtual bool has_conv() const { return false; } //!< does node depend on resolution ?
 
     //! Evaluate tree. Private. User calls pass through API implemented below.
-    virtual RObj tree_val( const CContext& ctx ) const =0;
+    virtual RObj tree_val(const CContext& ctx) const = 0;
     //! API for tree evaluation: compute one index.
-    int tree_val_idx( const CContext& ctx, const string& name ) const;
+    int tree_val_idx(const CContext& ctx, const string& name) const;
     virtual bool looks_like_indices() const { return false; }
-    RObjVecInt to_index_list( int siz ) const;
+    RObjVecInt to_index_list(int siz) const;
 
     //! API for tree evaluation: compute one numeric value.
-    RObj tree_point_val( int k=-1, int j=-1, int i=-1 ) const;
-    double tree_point_dbl( int k=-1, int j=-1, int i=-1 ) const;
+    RObj tree_point_val(int k = -1, int j = -1, int i = -1) const;
+    double tree_point_dbl(int k = -1, int j = -1, int i = -1) const;
 
     //! API for tree evaluation: compute an array.
-    void tree_vec_val( vector<double> *ret, vector<double> *dret, int k=-1, int j=-1 ) const;
+    void tree_vec_val(vector<double>* ret, vector<double>* dret, int k = -1, int j = -1) const;
 
-    virtual CCoord node_coord( int k=-1 ) const =0;
-    virtual string tree_info() const =0;  //!< introspection, for debugging
+    virtual CCoord node_coord(int k = -1) const = 0;
+    virtual string tree_info() const = 0; //!< introspection, for debugging
 
-    static RObj eval( string expr );
+    static RObj eval(string expr);
 };
diff --git a/pub/lib/fassign.cpp b/pub/lib/fassign.cpp
index 9089869d1f78fc179dcc13a530bade2d047db074..8c78ed2494e12d07463c8097d2cabc77538ac6b7 100644
--- a/pub/lib/fassign.cpp
+++ b/pub/lib/fassign.cpp
@@ -10,34 +10,31 @@
 #include "defs.hpp"
 
 
+#include "fregistry.hpp"
 #include "func.hpp"
-#include "ptr.hpp"
 #include "obj.hpp"
-#include "fregistry.hpp"
+#include "ptr.hpp"
 #include "variables.hpp"
 
 
-template<class A>
-A func_assign (string key, A v)
+template <class A> A func_assign(string key, A v)
 {
-    SVariRegistry::instance()->register_scalar( key, CObj::objectify(v) );
+    SVariRegistry::instance()->register_scalar(key, CObj::objectify(v));
     return v;
 }
 void func_assign(double& r, double& dr, string key, double v, double dv)
 {
-    SVariRegistry::instance()->register_scalar( key, CObj::objectify(v, dv) );
-    r = v; dr = dv;
+    SVariRegistry::instance()->register_scalar(key, CObj::objectify(v, dv));
+    r = v;
+    dr = dv;
 }
 
-int func_defined (string key)
-{
-    return SVariRegistry::instance()->find( key ) ? 1 : 0;
-}
+int func_defined(string key) { return SVariRegistry::instance()->find(key) ? 1 : 0; }
 
-void func_undef (string key)
+void func_undef(string key)
 {
-    bool ret = SVariRegistry::instance()->undef( key );
-    if( !ret )
+    bool ret = SVariRegistry::instance()->undef(key);
+    if (!ret)
         throw "key " + key + " was not defined";
 }
 
@@ -46,15 +43,14 @@ void fassign_initialize()
     auto G = SFuncRegistry::instance();
     CFuncMetadata m;
 
-    m = { "=",   2, "a=b     [assignment]", 14 };
-    G->register_fct_i_si ( m,  func_assign );
-    G->register_fct_d_sd ( m,  func_assign );
-    G->register_fct_e_se ( m,  func_assign );
-    G->register_fct_s_ss ( m,  func_assign );
+    m = { "=", 2, "a=b     [assignment]", 14 };
+    G->register_fct_i_si(m, func_assign);
+    G->register_fct_d_sd(m, func_assign);
+    G->register_fct_e_se(m, func_assign);
+    G->register_fct_s_ss(m, func_assign);
 
     m = { "defined", 1, "(s): 1 if there is a variable s" };
-    G->register_fct_i_s  ( m,  func_defined );
+    G->register_fct_i_s(m, func_defined);
     m = { "undef", 1, "(s): undefine variable s, return 1 upon success" };
-    G->register_fct_0_s  ( m,  func_undef );
-
+    G->register_fct_0_s(m, func_undef);
 }
diff --git a/pub/lib/fbase.cpp b/pub/lib/fbase.cpp
index 6e094c5964c907f3c8dbe8ccc76e1b362627b2c0..2c08f6c335d525b1b2391f63f0bf8509d71ae025 100644
--- a/pub/lib/fbase.cpp
+++ b/pub/lib/fbase.cpp
@@ -15,126 +15,190 @@
 #include <kww.h>
 
 #include "defs.hpp"
-#include "func.hpp"
 #include "fregistry.hpp"
+#include "func.hpp"
 
 #include <cerf.h> // include after boost::shared_ptr, otherwise use of 'I' in template clashes
 
-const double PI    = M_PI;    //4*atan(1.);
-const double TWOPI = 2*M_PI; //8*atan(1.);
+const double PI = M_PI; // 4*atan(1.);
+const double TWOPI = 2 * M_PI; // 8*atan(1.);
 
-static triv::RandomNumberGenerator *rng = nullptr;
+static triv::RandomNumberGenerator* rng = nullptr;
 
 
 //**************************************************************************************************
 //*  Functions of one argument
 //**************************************************************************************************
 
-template<class A>
-void func_pop(A v) {;}
+template <class A> void func_pop(A v) { ; }
 
 double func_to_d(int v) { return v; }
 double func_to_d(double v) { return v; }
 double func_to_d(string s)
 {
     double ret;
-    if ( triv::any2dbl( s, &ret ) )
+    if (triv::any2dbl(s, &ret))
         return ret;
-    throw "Cannot convert "+s+" to floating-point number";
+    throw "Cannot convert " + s + " to floating-point number";
 }
 
-template<class A>
-int func_not(A v) { return !v; }
+template <class A> int func_not(A v) { return !v; }
 
-template<class A>
-A func_neg(A v) { return -v; }
-void func_neg(double& r, double& dr, double v, double dv) { r=-v; dr=dv; }
+template <class A> A func_neg(A v) { return -v; }
+void func_neg(double& r, double& dr, double v, double dv)
+{
+    r = -v;
+    dr = dv;
+}
 
-double func_ln(double v) { return v>0 ? log(v) : 0; }
+double func_ln(double v) { return v > 0 ? log(v) : 0; }
 void func_ln(double& r, double& dr, double v, double dv)
-{ if(v>0) { r=log(v); dr=dv/v; } else { r=0; dr=0; } }
+{
+    if (v > 0) {
+        r = log(v);
+        dr = dv / v;
+    } else {
+        r = 0;
+        dr = 0;
+    }
+}
 
-double func_lg(double v) { return v>0 ? log10(v) : 0; }
+double func_lg(double v) { return v > 0 ? log10(v) : 0; }
 void func_lg(double& r, double& dr, double v, double dv)
-{ if(v>0) { r=log10(v); dr=dv/v/log(10); } else { r=0; dr=0; } }
+{
+    if (v > 0) {
+        r = log10(v);
+        dr = dv / v / log(10);
+    } else {
+        r = 0;
+        dr = 0;
+    }
+}
 
-double func_sqrt(double v) { return v>=0 ? sqrt(v) : 0; }
+double func_sqrt(double v) { return v >= 0 ? sqrt(v) : 0; }
 void func_sqrt(double& r, double& dr, double v, double dv)
-{ if(v>0) { r=sqrt(v); dr=dv/2/r; } else { r=0; dr=0; } }
+{
+    if (v > 0) {
+        r = sqrt(v);
+        dr = dv / 2 / r;
+    } else {
+        r = 0;
+        dr = 0;
+    }
+}
 
 double func_abs(double v) { return fabs(v); }
-int    func_abs(int v)    { return abs(v); }
-void   func_abs(double& r,double& dr, double v,double dv) { r=fabs(v); dr=dv; }
+int func_abs(int v) { return abs(v); }
+void func_abs(double& r, double& dr, double v, double dv)
+{
+    r = fabs(v);
+    dr = dv;
+}
 
-template<class A>
-A func_sign(A v) {
-    if      ( v<0 )
+template <class A> A func_sign(A v)
+{
+    if (v < 0)
         return -1;
-    else if ( v>0 )
+    else if (v > 0)
         return 1;
     else
         return 0;
 }
-void func_sign(double& r,double& dr, double v,double dv) { r=func_sign(v); dr=dv; }
+void func_sign(double& r, double& dr, double v, double dv)
+{
+    r = func_sign(v);
+    dr = dv;
+}
 
 double func_exp(double v) { return exp(v); }
-void func_exp(double& r, double& dr, double v, double dv) { r=exp(v); dr=dv*r; }
+void func_exp(double& r, double& dr, double v, double dv)
+{
+    r = exp(v);
+    dr = dv * r;
+}
 
 double func_sin(double v) { return sin(v); }
-void func_sin(double& r, double& dr, double v, double dv) { r=sin(v); dr=dv*fabs(cos(v)); }
+void func_sin(double& r, double& dr, double v, double dv)
+{
+    r = sin(v);
+    dr = dv * fabs(cos(v));
+}
 double func_cos(double v) { return cos(v); }
-void func_cos(double& r, double& dr, double v, double dv) { r=cos(v); dr=dv*fabs(sin(v)); }
+void func_cos(double& r, double& dr, double v, double dv)
+{
+    r = cos(v);
+    dr = dv * fabs(sin(v));
+}
 double func_tan(double v) { return tan(v); }
-double func_cot(double v) { double t=tan(v); return t==0?0:1/t;}
+double func_cot(double v)
+{
+    double t = tan(v);
+    return t == 0 ? 0 : 1 / t;
+}
 
-double func_sind(double v) { return sin(v*TWOPI/360.); }
-double func_cosd(double v) { return cos(v*TWOPI/360.); }
-double func_tand(double v) { return tan(v*TWOPI/360.); }
-double func_cotd(double v) { double t=tan(v*TWOPI/360.);  return t==0?0:1/t; }
+double func_sind(double v) { return sin(v * TWOPI / 360.); }
+double func_cosd(double v) { return cos(v * TWOPI / 360.); }
+double func_tand(double v) { return tan(v * TWOPI / 360.); }
+double func_cotd(double v)
+{
+    double t = tan(v * TWOPI / 360.);
+    return t == 0 ? 0 : 1 / t;
+}
 
-double func_asin(double v) { return (-1<=v && v<=1) ? asin(v) : 0; }
-double func_acos(double v) { return (-1<=v && v<=1) ? acos(v) : 0; }
+double func_asin(double v) { return (-1 <= v && v <= 1) ? asin(v) : 0; }
+double func_acos(double v) { return (-1 <= v && v <= 1) ? acos(v) : 0; }
 double func_atan(double v) { return atan(v); }
-double func_acot(double v) { return v!=0 ? atan(1/v) : TWOPI/4; }
+double func_acot(double v) { return v != 0 ? atan(1 / v) : TWOPI / 4; }
 
-double func_asind(double v) { return (-1<=v && v<=1) ? 360./TWOPI*asin(v) : 0; }
-double func_acosd(double v) { return (-1<=v && v<=1) ? 360./TWOPI*acos(v) : 0; }
-double func_atand(double v) { return 360./TWOPI*atan(v); }
-double func_acotd(double v) { return v!=0 ? 360./TWOPI*atan(1/v) : 90; }
+double func_asind(double v) { return (-1 <= v && v <= 1) ? 360. / TWOPI * asin(v) : 0; }
+double func_acosd(double v) { return (-1 <= v && v <= 1) ? 360. / TWOPI * acos(v) : 0; }
+double func_atand(double v) { return 360. / TWOPI * atan(v); }
+double func_acotd(double v) { return v != 0 ? 360. / TWOPI * atan(1 / v) : 90; }
 
 double func_sinh(double v) { return sinh(v); }
 double func_cosh(double v) { return cosh(v); }
 double func_tanh(double v) { return tanh(v); }
-double func_coth(double v) { double t=tanh(v); return t==0?0:1/t;}
+double func_coth(double v)
+{
+    double t = tanh(v);
+    return t == 0 ? 0 : 1 / t;
+}
 
-double func_j0(double v) { return v==0 ? 1 : sin(v)/v; }
-double func_j1(double v) { return v==0 ? 1 : (sin(v)/v-cos(v))/v; }
+double func_j0(double v) { return v == 0 ? 1 : sin(v) / v; }
+double func_j1(double v) { return v == 0 ? 1 : (sin(v) / v - cos(v)) / v; }
 
-double func_fac(double v) { return v>-.5 ? tgamma(round(v+1)) : 0; }
-double func_cata(double v) { // Catalan number ?
-    if ( v<=-.5 )
+double func_fac(double v) { return v > -.5 ? tgamma(round(v + 1)) : 0; }
+double func_cata(double v)
+{ // Catalan number ?
+    if (v <= -.5)
         return 0;
     double x = round(v);
-    return exp( lgamma( 2*x+1 ) - lgamma( x+1 ) -
-                lgamma( x+2 ) ); }
+    return exp(lgamma(2 * x + 1) - lgamma(x + 1) - lgamma(x + 2));
+}
 
-double func_gamma(double v) { return v>0 ? tgamma(v) : 0; }
-double func_lgamma(double v) { return v>0 ? lgamma(v) : 0; }
+double func_gamma(double v) { return v > 0 ? tgamma(v) : 0; }
+double func_lgamma(double v) { return v > 0 ? lgamma(v) : 0; }
 // could be extended to non-integer negative arguments...
 
-double func_debye1(double v) { return v>=0 ? gsl_sf_debye_1(v) : 0; }
-double func_debye3(double v) { return v>=0 ? gsl_sf_debye_3(v) : 0; }
-double func_debye_msd(double v) { // mean squared displacement
-                                  // without prefactors
-                                  // without zero temperature oscillations
-    return v>1e-2 ? 2*v*gsl_sf_debye_1(1/v) : 0; }
-double func_debye_ui(double v) { // internal energy
-    return v>=0 ? 3*v*gsl_sf_debye_3(1/v) : 0; }
-double func_debye_cv(double v) { // heat capacity
-    double eps=1e-12;
-    return v>=eps ? (func_debye_ui(v+eps)-func_debye_ui(v-eps))/(2*eps) : 0; }
-
-double func_erfP(double v) { return 1-gsl_sf_erf_Q(v); }
+double func_debye1(double v) { return v >= 0 ? gsl_sf_debye_1(v) : 0; }
+double func_debye3(double v) { return v >= 0 ? gsl_sf_debye_3(v) : 0; }
+double func_debye_msd(double v)
+{ // mean squared displacement
+    // without prefactors
+    // without zero temperature oscillations
+    return v > 1e-2 ? 2 * v * gsl_sf_debye_1(1 / v) : 0;
+}
+double func_debye_ui(double v)
+{ // internal energy
+    return v >= 0 ? 3 * v * gsl_sf_debye_3(1 / v) : 0;
+}
+double func_debye_cv(double v)
+{ // heat capacity
+    double eps = 1e-12;
+    return v >= eps ? (func_debye_ui(v + eps) - func_debye_ui(v - eps)) / (2 * eps) : 0;
+}
+
+double func_erfP(double v) { return 1 - gsl_sf_erf_Q(v); }
 double func_erfQ(double v) { return gsl_sf_erf_Q(v); }
 double func_erf(double v) { return gsl_sf_erf(v); }
 double func_erfc(double v) { return gsl_sf_erfc(v); }
@@ -142,136 +206,171 @@ double func_erfi(double v) { return erfi(v); }
 
 double func_dawson(double v) { return gsl_sf_dawson(v); }
 
-double func_sinc(double v) { return v==0 ? 1 : sin(v)/v; }
+double func_sinc(double v) { return v == 0 ? 1 : sin(v) / v; }
 
-int func_ceil(double v)  { return (int)(ceil(v)+0.5); }
-int func_floor(double v) { return (int)(floor(v)+0.5); }
-int func_nint(double v)  { return (int)(round(v)+0.5); }
+int func_ceil(double v) { return (int)(ceil(v) + 0.5); }
+int func_floor(double v) { return (int)(floor(v) + 0.5); }
+int func_nint(double v) { return (int)(round(v) + 0.5); }
 
 // Ad hoc for uses in physics:
 
-double func_lndiehl( double a ) {
+double func_lndiehl(double a)
+{
     // ln( \int dw gauss(w,gausswid) cauchy(w,cauchywid) / gauss(0,gausswid) )
     // argumnt a = cauchywid/gausswid
-    return SQR(a)/2 + gsl_sf_log_erfc( a/sqrt(2) );
+    return SQR(a) / 2 + gsl_sf_log_erfc(a / sqrt(2));
 }
 
-double func_diehl( double a ) {
+double func_diehl(double a)
+{
     // \int dw gauss(w,gausswid) cauchy(w,cauchywid) / gauss(0,gausswid)
     // argumnt a = cauchywid/gausswid
-    return exp( func_lndiehl(a) );
+    return exp(func_lndiehl(a));
 }
 
-int func_exit( int a ) { exit(a); return 0; }
+int func_exit(int a)
+{
+    exit(a);
+    return 0;
+}
 
-int func_exit_if( int a, string s ) { if(a) { cout << s << "\n"; exit(1); } return 0; }
-int func_exit_unless( int a, string s ) { return func_exit_if( !a, s ); }
+int func_exit_if(int a, string s)
+{
+    if (a) {
+        cout << s << "\n";
+        exit(1);
+    }
+    return 0;
+}
+int func_exit_unless(int a, string s) { return func_exit_if(!a, s); }
 
 //**************************************************************************************************
 //*  Functions of two arguments
 //**************************************************************************************************
 
-//double func_pm(double v, double a) { return v; }
-void func_pm(double& r, double& dr, double v, double a){ r=v; dr=a; }
+// double func_pm(double v, double a) { return v; }
+void func_pm(double& r, double& dr, double v, double a)
+{
+    r = v;
+    dr = a;
+}
 
-template<class A>
-A func_add(A v, A a) { return v+a; }
+template <class A> A func_add(A v, A a) { return v + a; }
 void func_add(double& r, double& dr, double v, double dv, double a, double da)
-{ r=v+a; dr=sqrt(dv*dv+da*da); }
+{
+    r = v + a;
+    dr = sqrt(dv * dv + da * da);
+}
 
-template<class A>
-A func_sub(A v, A a) { return v-a; }
+template <class A> A func_sub(A v, A a) { return v - a; }
 void func_sub(double& r, double& dr, double v, double dv, double a, double da)
-{ r=v-a; dr=sqrt(dv*dv+da*da); }
+{
+    r = v - a;
+    dr = sqrt(dv * dv + da * da);
+}
 
-template<class A>
-A func_mul(A v, A a) { return v*a; }
+template <class A> A func_mul(A v, A a) { return v * a; }
 void func_mul(double& r, double& dr, double v, double dv, double a, double da)
-{ r=v*a; dr=sqrt(SQR(v*da)+SQR(a*dv)); }
+{
+    r = v * a;
+    dr = sqrt(SQR(v * da) + SQR(a * dv));
+}
 
-double func_div(double v, double a) { return a!=0 ? v/a : 0; }
+double func_div(double v, double a) { return a != 0 ? v / a : 0; }
 void func_div(double& r, double& dr, double v, double dv, double a, double da)
-{ if(a==0) { r=0; dr=0; } else { r=v/a; dr=sqrt(SQR(dv/a)+SQR(v*da/a/a)); } }
+{
+    if (a == 0) {
+        r = 0;
+        dr = 0;
+    } else {
+        r = v / a;
+        dr = sqrt(SQR(dv / a) + SQR(v * da / a / a));
+    }
+}
 
-int func_idiv(int v, int a) { return a!=0 ? v/a : 0; }
-int func_idiv(double v, int a) { return a!=0 ? (int)(ceil(v)+0.5)/a : 0; }
+int func_idiv(int v, int a) { return a != 0 ? v / a : 0; }
+int func_idiv(double v, int a) { return a != 0 ? (int)(ceil(v) + 0.5) / a : 0; }
 
-int func_mod(int v, int a) { return v%a; }
-double func_mod(double v, double a) { return fmod(v,a); }
+int func_mod(int v, int a) { return v % a; }
+double func_mod(double v, double a) { return fmod(v, a); }
 
 double func_pow(double a, double b)
-{ return ( a>0 || (a==0&&b>0) || b==(int)b ) ? pow(a,b) : 0; }
+{
+    return (a > 0 || (a == 0 && b > 0) || b == (int)b) ? pow(a, b) : 0;
+}
 void func_pow(double& r, double& dr, double a, double da, double b, double db)
 {
-    if ( a>0 ) {
-        r = pow(a,b);
-        dr = r*b/a*sqrt(SQR(da)+SQR(db));
-    } else if ( a==0 && b>0 ) {
-        r = pow(a,b);
-        dr = b*pow(a,b-1)*db;
-    } else if ( b==(int)b ) {
-        r = pow(a,b);
-        dr = r*b/a*da;
+    if (a > 0) {
+        r = pow(a, b);
+        dr = r * b / a * sqrt(SQR(da) + SQR(db));
+    } else if (a == 0 && b > 0) {
+        r = pow(a, b);
+        dr = b * pow(a, b - 1) * db;
+    } else if (b == (int)b) {
+        r = pow(a, b);
+        dr = r * b / a * da;
     } else {
         r = 0;
         dr = 0;
     }
 }
 
-template<class A>
-int func_eq (A v, A a) { return v == a; }
-template<class A>
-int func_ne (A v, A a) { return v != a; }
-template<class A>
-int func_gt (A v, A a) { return v > a; }
-template<class A>
-int func_ge (A v, A a) { return v >= a; }
-template<class A>
-int func_lt (A v, A a) { return v < a; }
-template<class A>
-int func_le (A v, A a) { return v <= a; }
-template<class A>
-int func_and(A v, A a) { return v && a; }
-template<class A>
-int func_or (A v, A a) { return v || a; }
-template<class A>
-int func_xor(A v, A a) { return (bool) v ^ (bool) a; }
-
-double func_over(double v, double a) {
-    return  ( 0<=v && 0<=a && a<=v && v <= 400 ) ?
-        tgamma(v+1)/tgamma(a+1)/tgamma(v-a+1) :
-        0; }
-
-template<class A>
-A func_min (A v, A a) { return v<a ? v : a; }
-template<class A>
-A func_max (A v, A a) { return v>a ? v : a; }
-
-double func_gauss (double x, double s) {
-    return s==0 ? 0 : exp(-x*x/(2*s*s))/sqrt(TWOPI*s*s); }
-double func_gaussnn (double x, double s) { // Gauss not normalized
-    return s==0 ? 0 : exp(-x*x/(2*s*s)); }
-double func_cauchy (double x, double s) {
-    return s==0 ? 0 : fabs(s)/PI/(x*x+s*s); }
-
-double func_ran (double v, double a) {
+template <class A> int func_eq(A v, A a) { return v == a; }
+template <class A> int func_ne(A v, A a) { return v != a; }
+template <class A> int func_gt(A v, A a) { return v > a; }
+template <class A> int func_ge(A v, A a) { return v >= a; }
+template <class A> int func_lt(A v, A a) { return v < a; }
+template <class A> int func_le(A v, A a) { return v <= a; }
+template <class A> int func_and(A v, A a) { return v && a; }
+template <class A> int func_or(A v, A a) { return v || a; }
+template <class A> int func_xor(A v, A a) { return (bool)v ^ (bool)a; }
+
+double func_over(double v, double a)
+{
+    return (0 <= v && 0 <= a && a <= v && v <= 400)
+        ? tgamma(v + 1) / tgamma(a + 1) / tgamma(v - a + 1)
+        : 0;
+}
+
+template <class A> A func_min(A v, A a) { return v < a ? v : a; }
+template <class A> A func_max(A v, A a) { return v > a ? v : a; }
+
+double func_gauss(double x, double s)
+{
+    return s == 0 ? 0 : exp(-x * x / (2 * s * s)) / sqrt(TWOPI * s * s);
+}
+double func_gaussnn(double x, double s)
+{ // Gauss not normalized
+    return s == 0 ? 0 : exp(-x * x / (2 * s * s));
+}
+double func_cauchy(double x, double s) { return s == 0 ? 0 : fabs(s) / PI / (x * x + s * s); }
+
+double func_ran(double v, double a)
+{
     // a random number between v and a :
     if (!rng)
         rng = new triv::RandomNumberGenerator();
-    return rng->uniform( func_min(v,a), func_max(v,a) ); }
+    return rng->uniform(func_min(v, a), func_max(v, a));
+}
 
 // Havriliak-Negami: unchecked formulae from disreputable source:
 
-double aux_phi_havneg (double v, double a){
-    return atan( pow(v,a)*sin(M_PI*a/2)/(1+pow(v,a)*cos(M_PI*a/2)) ); }
+double aux_phi_havneg(double v, double a)
+{
+    return atan(pow(v, a) * sin(M_PI * a / 2) / (1 + pow(v, a) * cos(M_PI * a / 2)));
+}
 
-double func_re_havneg (double v, double a, double g) {
-    return pow( 1 + 2*pow(v,a)*cos(M_PI*a/2)+pow(v,2*a), -g/2 ) *
-        cos( g*aux_phi_havneg( v, a ) ); }
+double func_re_havneg(double v, double a, double g)
+{
+    return pow(1 + 2 * pow(v, a) * cos(M_PI * a / 2) + pow(v, 2 * a), -g / 2)
+        * cos(g * aux_phi_havneg(v, a));
+}
 
-double func_im_havneg (double v, double a, double g) {
-    return pow( 1 + 2*pow(v,a)*cos(M_PI*a/2)+pow(v,2*a), -g/2 ) *
-        sin( g*aux_phi_havneg( v, a ) ); }
+double func_im_havneg(double v, double a, double g)
+{
+    return pow(1 + 2 * pow(v, a) * cos(M_PI * a / 2) + pow(v, 2 * a), -g / 2)
+        * sin(g * aux_phi_havneg(v, a));
+}
 
 
 //**************************************************************************************************
@@ -281,58 +380,93 @@ double func_im_havneg (double v, double a, double g) {
 int func_cond(int v, int a, int b) { return v ? a : b; }
 double func_cond(double v, double a, double b) { return v ? a : b; }
 void func_cond(double& r, double& dr, double v, double dv, double a, double da, double b, double db)
-{ if(v) { r=a; dr=da; } else { r=b; dr=db; } }
+{
+    if (v) {
+        r = a;
+        dr = da;
+    } else {
+        r = b;
+        dr = db;
+    }
+}
 
-double func_q4w( double hbarw, double Ei, double twotheta) {
+double func_q4w(double hbarw, double Ei, double twotheta)
+{
     // calculate Q in Angstroem-1 when hbar*w and E_i are given in meV
-    if( hbarw>Ei ) return -1;
-    return sqrt( (1/2.07212349) *
-                 ( 2*Ei-hbarw-2*sqrt(Ei*(Ei-hbarw))*cos(twotheta*TWOPI/360) ) );
-}
-
-double func_cauchy2 (double x, double p, double w) {
-    return w==0 ? 0 : w/PI*(1.0/(SQR(x-p)+SQR(w))+1.0/(SQR(x+p)+SQR(w)));
-}
-
-double func_kwwc( double v, double t, double b ){
-    if( b<0.1 || b>2.0 ) return 0;
-    return t/PI*kwwc( v*t, b ); }
-double func_kwws( double v, double t, double b ){
-    if( b<0.1 || b>2.0 ) return 0;
-    return t/PI*kwws( v*t, b ); }
-double func_kwwp( double v, double t, double b ){
-    if( b<0.1 || b>2.0 || t<=0 ) return 0;
-    return 1/PI*kwwp( v*t, b ); }
-
-double func_kwwmc( double v, double tmean, double b ){
-    if( b<0.1 || b>2.0 ) return 0;
-    double tkww = tmean*b/tgamma(1/b);
-    return tkww/PI*kwwc( v*tkww, b ); }
-double func_kwwms( double v, double tmean, double b ){
-    if( b<0.1 || b>2.0 ) return 0;
-    double tkww = tmean*b/tgamma(1/b);
-    return tkww/PI*kwws( v*tkww, b ); }
-double func_kwwmp( double v, double tmean, double b ){
-    if( b<0.1 || b>2.0 || tmean<=0 ) return 0;
-    double tkww = tmean*b/tgamma(1/b);
-    return 1/PI*kwwp( v*tkww, b ); }
-
-double func_voigt( double v, double s, double g ){
-    return (s||g) ? voigt(v,s,g) : 0;
-}
-
-double func_zorn( double v, double vavg, double s ) {
-    if( s<=0 || s>=1 ) return 0;
-    return (1-s)*(v+s*vavg*vavg/(1-s*vavg)); }
-
-double func_zorn_gauss( double q, double u2, double s ) {
-    if( s<=0 || s>=1 ) return 0;
-    double qmax = 4*PI/6.27; // Si111
-    double v = exp(-u2*SQR(q));
-    double vavg = (1-exp(-u2*SQR(qmax))) / (u2*SQR(qmax));
-    return (1-s)*(v+s*vavg*vavg/(1-s*vavg)); }
-
-double func_rrdm( double wred, double act0, double relwidth ) {
+    if (hbarw > Ei)
+        return -1;
+    return sqrt(
+        (1 / 2.07212349)
+        * (2 * Ei - hbarw - 2 * sqrt(Ei * (Ei - hbarw)) * cos(twotheta * TWOPI / 360)));
+}
+
+double func_cauchy2(double x, double p, double w)
+{
+    return w == 0 ? 0 : w / PI * (1.0 / (SQR(x - p) + SQR(w)) + 1.0 / (SQR(x + p) + SQR(w)));
+}
+
+double func_kwwc(double v, double t, double b)
+{
+    if (b < 0.1 || b > 2.0)
+        return 0;
+    return t / PI * kwwc(v * t, b);
+}
+double func_kwws(double v, double t, double b)
+{
+    if (b < 0.1 || b > 2.0)
+        return 0;
+    return t / PI * kwws(v * t, b);
+}
+double func_kwwp(double v, double t, double b)
+{
+    if (b < 0.1 || b > 2.0 || t <= 0)
+        return 0;
+    return 1 / PI * kwwp(v * t, b);
+}
+
+double func_kwwmc(double v, double tmean, double b)
+{
+    if (b < 0.1 || b > 2.0)
+        return 0;
+    double tkww = tmean * b / tgamma(1 / b);
+    return tkww / PI * kwwc(v * tkww, b);
+}
+double func_kwwms(double v, double tmean, double b)
+{
+    if (b < 0.1 || b > 2.0)
+        return 0;
+    double tkww = tmean * b / tgamma(1 / b);
+    return tkww / PI * kwws(v * tkww, b);
+}
+double func_kwwmp(double v, double tmean, double b)
+{
+    if (b < 0.1 || b > 2.0 || tmean <= 0)
+        return 0;
+    double tkww = tmean * b / tgamma(1 / b);
+    return 1 / PI * kwwp(v * tkww, b);
+}
+
+double func_voigt(double v, double s, double g) { return (s || g) ? voigt(v, s, g) : 0; }
+
+double func_zorn(double v, double vavg, double s)
+{
+    if (s <= 0 || s >= 1)
+        return 0;
+    return (1 - s) * (v + s * vavg * vavg / (1 - s * vavg));
+}
+
+double func_zorn_gauss(double q, double u2, double s)
+{
+    if (s <= 0 || s >= 1)
+        return 0;
+    double qmax = 4 * PI / 6.27; // Si111
+    double v = exp(-u2 * SQR(q));
+    double vavg = (1 - exp(-u2 * SQR(qmax))) / (u2 * SQR(qmax));
+    return (1 - s) * (v + s * vavg * vavg / (1 - s * vavg));
+}
+
+double func_rrdm(double wred, double act0, double relwidth)
+{
     // Rotational rate distribution model [review: Colmenero 2005]
     //   Gaussian distribution of Barriers, Arrhenius law, rotational jumps.
     // Dimensionless:
@@ -340,68 +474,68 @@ double func_rrdm( double wred, double act0, double relwidth ) {
     //   act0 = mean{E_A}/(k_B T),
     //   relwidth = stdv{E_A} / mean{E_A};
     //   multiply result by T/Omega_0.
-    const int N=101;
-    double actsig = act0*relwidth;
-    double actrange = 3*actsig;
-    if ( act0-actrange <= 0 )
+    const int N = 101;
+    double actsig = act0 * relwidth;
+    double actrange = 3 * actsig;
+    if (act0 - actrange <= 0)
         return 0;
-    double da = actrange/((N-1)/2);
+    double da = actrange / ((N - 1) / 2);
     double ret = 0;
-    for( int i=0; i<N; ++i ) {
-        double a = act0 + da*(i-(N-1)/2);
-        ret += exp( -SQR((a-act0)/actsig)/2 ) *func_cauchy( wred, exp(-a) );
+    for (int i = 0; i < N; ++i) {
+        double a = act0 + da * (i - (N - 1) / 2);
+        ret += exp(-SQR((a - act0) / actsig) / 2) * func_cauchy(wred, exp(-a));
     }
-    return ret * da / sqrt(2*PI) / actsig;
+    return ret * da / sqrt(2 * PI) / actsig;
 }
 
-double func_rotdiff( double w, double tau, double qb )
+double func_rotdiff(double w, double tau, double qb)
 // Rotational diffusion spectrum
 {
     double ret = 0;
-    if( qb<=0 )
+    if (qb <= 0)
         return 0;
-    for( int l=1; l<=12; ++l ){
-        ret += (2*l+1) * pow( gsl_sf_bessel_jl( l, qb ), 2 ) *
-            l*(l+1)*tau/PI/(SQR(w*tau)+SQR(l*(l+1)));
+    for (int l = 1; l <= 12; ++l) {
+        ret += (2 * l + 1) * pow(gsl_sf_bessel_jl(l, qb), 2) * l * (l + 1) * tau / PI
+            / (SQR(w * tau) + SQR(l * (l + 1)));
     }
     return ret;
 }
 
-double func_ornuhl( double _w, double _a, double _b )
+double func_ornuhl(double _w, double _a, double _b)
 // Ornstein-Uhlenbeck spectrum FT[exp(-|b|t-a(1-exp(-t))),
 //    computed for w->0 by expanding the outer exponential in e^(a e^(-x/w))
 //    which turns out to converge rapidly for all w
 {
-    const double ornuhl_delta=2.2e-16, ornuhl_eps=5.5e-20;
+    const double ornuhl_delta = 2.2e-16, ornuhl_eps = 5.5e-20;
     long double w = _w;
     long double a = _a;
     long double b = fabs(_b);
-    if ( a==0 )
-        return b/(SQR(b)+SQR(w));
-    long double a_log = logl( a );
-    long double S=0;      // summed series
-    long double h;        // exponent
-    long double f;        // Cauchy-Lorentz function
-    long double u;        // precomputed common factors
-    long double u_next=0; // - next value [initialized to avoid warning]
+    if (a == 0)
+        return b / (SQR(b) + SQR(w));
+    long double a_log = logl(a);
+    long double S = 0; // summed series
+    long double h; // exponent
+    long double f; // Cauchy-Lorentz function
+    long double u; // precomputed common factors
+    long double u_next = 0; // - next value [initialized to avoid warning]
 
     // sum the expansion
-    for ( int k=0; k<1000; ++k ) {
+    for (int k = 0; k < 1000; ++k) {
         u = u_next;
-        h = k*a_log - lgammal((long double)(k+1));
-        if ( h>DBL_MAX_EXP )
+        h = k * a_log - lgammal((long double)(k + 1));
+        if (h > DBL_MAX_EXP)
             return -3; // exponent overflow
-        if ( h<DBL_MIN_EXP )
+        if (h < DBL_MIN_EXP)
             return -4; // exponent underflow
-        f = (k+b)/(SQR(k+b)+SQR(w));
-        u_next = expl( h ) *f;
+        f = (k + b) / (SQR(k + b) + SQR(w));
+        u_next = expl(h) * f;
         S += u;
-        if( k==0 )
+        if (k == 0)
             continue;
         // termination criteria
-        if ( ornuhl_eps*S+u_next <= ornuhl_delta*S )
-            return exp(-a)*S; // reached required precision
-        else if ( u_next<DBL_MIN )
+        if (ornuhl_eps * S + u_next <= ornuhl_delta * S)
+            return exp(-a) * S; // reached required precision
+        else if (u_next < DBL_MIN)
             return -7; // underflow
     }
     return -9; // too many terms
@@ -419,245 +553,249 @@ void fbase_initialize()
     CFuncMetadata m;
 
     // operators by precedence (which should agree with xax_yacc.ypp):
-    m = { "+-",  2, "a+-da   [set error]", 1  };
-    G->register_fct_e_dd ( m, func_pm );
-    m = { "^",   2, "a^b     [exponentiation]", 2 };
-    G->register_fct_d_dd ( m, func_pow );
-    G->register_fct_e_ee ( m, func_pow );
-    m = { "!",   1, "!a      [negation]", 3 };
-    G->register_fct_i_i  ( m, func_not );
-    G->register_fct_i_d  ( m, func_not );
+    m = { "+-", 2, "a+-da   [set error]", 1 };
+    G->register_fct_e_dd(m, func_pm);
+    m = { "^", 2, "a^b     [exponentiation]", 2 };
+    G->register_fct_d_dd(m, func_pow);
+    G->register_fct_e_ee(m, func_pow);
+    m = { "!", 1, "!a      [negation]", 3 };
+    G->register_fct_i_i(m, func_not);
+    G->register_fct_i_d(m, func_not);
     m = { "neg", 1, "-a      [negative value]", 4 };
-    G->register_fct_i_i  ( m, func_neg );
-    G->register_fct_d_d  ( m, func_neg );
-    G->register_fct_e_e  ( m, func_neg );
-    m = { "/",   2, "a/b     [quotient]", 5 };
-    G->register_fct_d_dd ( m, func_div );
-    G->register_fct_e_ee ( m, func_div );
-    m = { "//",  2, "i//j    [integer quotient]", 5 };
-    G->register_fct_i_ii ( m, func_idiv );
-    G->register_fct_i_di ( m, func_idiv );
-    m = { "%",   2, "i%j     [remainder]", 5 };
-    G->register_fct_i_ii ( m, func_mod );
-    G->register_fct_d_dd ( m, func_mod );
-    m = { "*",   2, "a*b     [product]", 6 };
-    G->register_fct_i_ii ( m, func_mul );
-    G->register_fct_d_dd ( m, func_mul );
-    G->register_fct_e_ee ( m, func_mul );
-    m = { "+",   2, "a+b     [sum]", 7 };
-    G->register_fct_i_ii ( m, func_add );
-    G->register_fct_d_dd ( m, func_add );
-    G->register_fct_e_ee ( m, func_add );
-    m = { "-",   2, "a-b     [difference]", 7 };
-    G->register_fct_i_ii ( m, func_sub );
-    G->register_fct_d_dd ( m, func_sub );
-    G->register_fct_e_ee ( m, func_sub );
-    m = { ">",   2, "a>b     [greater]", 8 };
-    G->register_fct_i_ii ( m, func_gt );
-    G->register_fct_i_dd ( m, func_gt );
-    m = { "<",   2, "a<b     [less]", 8 };
-    G->register_fct_i_ii ( m, func_lt );
-    G->register_fct_i_dd ( m, func_lt );
-    m = { ">=",  2, "a>=b    [greater or equal]", 8 };
-    G->register_fct_i_ii ( m, func_ge );
-    G->register_fct_i_dd ( m, func_ge );
-    m = { "<=",  2, "a<=b    [less or equal]", 8 };
-    G->register_fct_i_ii ( m, func_le );
-    G->register_fct_i_dd ( m, func_le );
-    m = { "==",  2, "a==b    [equality]", 9 };
-    G->register_fct_i_ii ( m, func_eq );
-    G->register_fct_i_dd ( m, func_eq );
-    m = { "!=",  2, "a!=b    [unequality]", 9 };
-    G->register_fct_i_ii ( m, func_ne );
-    G->register_fct_i_dd ( m, func_ne );
+    G->register_fct_i_i(m, func_neg);
+    G->register_fct_d_d(m, func_neg);
+    G->register_fct_e_e(m, func_neg);
+    m = { "/", 2, "a/b     [quotient]", 5 };
+    G->register_fct_d_dd(m, func_div);
+    G->register_fct_e_ee(m, func_div);
+    m = { "//", 2, "i//j    [integer quotient]", 5 };
+    G->register_fct_i_ii(m, func_idiv);
+    G->register_fct_i_di(m, func_idiv);
+    m = { "%", 2, "i%j     [remainder]", 5 };
+    G->register_fct_i_ii(m, func_mod);
+    G->register_fct_d_dd(m, func_mod);
+    m = { "*", 2, "a*b     [product]", 6 };
+    G->register_fct_i_ii(m, func_mul);
+    G->register_fct_d_dd(m, func_mul);
+    G->register_fct_e_ee(m, func_mul);
+    m = { "+", 2, "a+b     [sum]", 7 };
+    G->register_fct_i_ii(m, func_add);
+    G->register_fct_d_dd(m, func_add);
+    G->register_fct_e_ee(m, func_add);
+    m = { "-", 2, "a-b     [difference]", 7 };
+    G->register_fct_i_ii(m, func_sub);
+    G->register_fct_d_dd(m, func_sub);
+    G->register_fct_e_ee(m, func_sub);
+    m = { ">", 2, "a>b     [greater]", 8 };
+    G->register_fct_i_ii(m, func_gt);
+    G->register_fct_i_dd(m, func_gt);
+    m = { "<", 2, "a<b     [less]", 8 };
+    G->register_fct_i_ii(m, func_lt);
+    G->register_fct_i_dd(m, func_lt);
+    m = { ">=", 2, "a>=b    [greater or equal]", 8 };
+    G->register_fct_i_ii(m, func_ge);
+    G->register_fct_i_dd(m, func_ge);
+    m = { "<=", 2, "a<=b    [less or equal]", 8 };
+    G->register_fct_i_ii(m, func_le);
+    G->register_fct_i_dd(m, func_le);
+    m = { "==", 2, "a==b    [equality]", 9 };
+    G->register_fct_i_ii(m, func_eq);
+    G->register_fct_i_dd(m, func_eq);
+    m = { "!=", 2, "a!=b    [unequality]", 9 };
+    G->register_fct_i_ii(m, func_ne);
+    G->register_fct_i_dd(m, func_ne);
     m = { "xor", 2, "a^b     [exclusive or]", 10 };
-    G->register_fct_i_ii ( m, func_xor );
-    G->register_fct_i_dd ( m, func_xor );
-    m = { "&&",  2, "a&&b    [and]", 11 };
-    G->register_fct_i_ii ( m, func_and );
-    G->register_fct_i_dd ( m, func_and );
-    m = { "||",  2, "a||b    [or]", 11 };
-    G->register_fct_i_ii ( m, func_or );
-    G->register_fct_i_dd ( m, func_or );
-    m = { "?:",  2, "a?b:c   [if a then b else c]", 13 };
-    G->register_fct_i_iii( m, func_cond );
-    G->register_fct_d_ddd( m, func_cond );
-    G->register_fct_e_eee( m, func_cond );
+    G->register_fct_i_ii(m, func_xor);
+    G->register_fct_i_dd(m, func_xor);
+    m = { "&&", 2, "a&&b    [and]", 11 };
+    G->register_fct_i_ii(m, func_and);
+    G->register_fct_i_dd(m, func_and);
+    m = { "||", 2, "a||b    [or]", 11 };
+    G->register_fct_i_ii(m, func_or);
+    G->register_fct_i_dd(m, func_or);
+    m = { "?:", 2, "a?b:c   [if a then b else c]", 13 };
+    G->register_fct_i_iii(m, func_cond);
+    G->register_fct_d_ddd(m, func_cond);
+    G->register_fct_e_eee(m, func_cond);
 
 
     // f( 1 arg )
     m = { "to_d", 1, "(x): convert x to floating-point number" };
-    G->register_fct_d_i  ( m, func_to_d );
-    G->register_fct_d_d  ( m, func_to_d );
-    G->register_fct_d_s  ( m, func_to_d );
+    G->register_fct_d_i(m, func_to_d);
+    G->register_fct_d_d(m, func_to_d);
+    G->register_fct_d_s(m, func_to_d);
     m = { "pop", 1, "(x): do nothing" };
-    G->register_fct_0_i  ( m, func_pop );
-    G->register_fct_0_d  ( m, func_pop );
-    G->register_fct_0_s  ( m, func_pop );
+    G->register_fct_0_i(m, func_pop);
+    G->register_fct_0_d(m, func_pop);
+    G->register_fct_0_s(m, func_pop);
     m = { "exit", 1, "(x): exit(x)" };
-    G->register_fct_i_i  ( m, func_exit );
+    G->register_fct_i_i(m, func_exit);
     m = { "ln", 1, "(x): natural logarithm of x, or 0 if x<=0" };
-    G->register_fct_d_d  ( m, func_ln );
-    G->register_fct_e_e  ( m, func_ln );
+    G->register_fct_d_d(m, func_ln);
+    G->register_fct_e_e(m, func_ln);
     m = { "lg", 1, "(x): decadic logarithm of x, or 0 if x<=0" };
-    G->register_fct_d_d  ( m, func_lg );
-    G->register_fct_e_e  ( m, func_lg );
+    G->register_fct_d_d(m, func_lg);
+    G->register_fct_e_e(m, func_lg);
     m = { "sqrt", 1, "(x): square root of x, or 0 if x<0" };
-    G->register_fct_d_d  ( m, func_sqrt );
-    G->register_fct_e_e  ( m, func_sqrt );
+    G->register_fct_d_d(m, func_sqrt);
+    G->register_fct_e_e(m, func_sqrt);
     m = { "abs", 1, "(x): absolute value of x" };
-    G->register_fct_i_i  ( m, func_abs );
-    G->register_fct_d_d  ( m, func_abs );
-    G->register_fct_e_e  ( m, func_abs );
+    G->register_fct_i_i(m, func_abs);
+    G->register_fct_d_d(m, func_abs);
+    G->register_fct_e_e(m, func_abs);
     m = { "sign", 1, "(x): sign of x" };
-    G->register_fct_i_i  ( m, func_sign );
-    G->register_fct_d_d  ( m, func_sign );
-    G->register_fct_e_e  ( m, func_sign );
+    G->register_fct_i_i(m, func_sign);
+    G->register_fct_d_d(m, func_sign);
+    G->register_fct_e_e(m, func_sign);
     m = { "exp", 1, "(x): exponential function of x" };
-    G->register_fct_d_d  ( m, func_exp );
-    G->register_fct_e_e  ( m, func_exp );
+    G->register_fct_d_d(m, func_exp);
+    G->register_fct_e_e(m, func_exp);
     m = { "sin", 1, "(x): sine of x (where x in radian)" };
-    G->register_fct_d_d  ( m, func_sin );
-    G->register_fct_e_e  ( m, func_sin );
+    G->register_fct_d_d(m, func_sin);
+    G->register_fct_e_e(m, func_sin);
     m = { "cos", 1, "(x): cosine of x (where x in radian)" };
-    G->register_fct_d_d  ( m, func_cos );
-    G->register_fct_e_e  ( m, func_cos );
+    G->register_fct_d_d(m, func_cos);
+    G->register_fct_e_e(m, func_cos);
     m = { "tan", 1, "(x): tangent of x (where x in radian)" };
-    G->register_fct_d_d  ( m, func_tan );
+    G->register_fct_d_d(m, func_tan);
     m = { "cot", 1, "(x): cotangent of x (where x in radian)" };
-    G->register_fct_d_d  ( m, func_cot );
+    G->register_fct_d_d(m, func_cot);
     m = { "sind", 1, "(x): sine of x (where x in degrees)" };
-    G->register_fct_d_d  ( m, func_sind );
+    G->register_fct_d_d(m, func_sind);
     m = { "cosd", 1, "(x): cosine of x (where x in degrees)" };
-    G->register_fct_d_d  ( m, func_cosd );
+    G->register_fct_d_d(m, func_cosd);
     m = { "tand", 1, "(x): tangent of x (where x in degrees)" };
-    G->register_fct_d_d  ( m, func_tand );
+    G->register_fct_d_d(m, func_tand);
     m = { "cotd", 1, "(x): cotangent of x (where x in degrees)" };
-    G->register_fct_d_d  ( m, func_cotd );
+    G->register_fct_d_d(m, func_cotd);
     m = { "asin", 1, "(x): arc sine of x (result is in radian; 0 if |x|>1)" };
-    G->register_fct_d_d  ( m, func_asin );
+    G->register_fct_d_d(m, func_asin);
     m = { "acos", 1, "(x): arc cosine of x (result is in radian; 0 if |x|>1)" };
-    G->register_fct_d_d  ( m, func_acos );
+    G->register_fct_d_d(m, func_acos);
     m = { "atan", 1, "(x): arc tangent of x (result is in radian)" };
-    G->register_fct_d_d  ( m, func_atan );
+    G->register_fct_d_d(m, func_atan);
     m = { "acot", 1, "(x): arc cotangent of x (result is in radian)" };
-    G->register_fct_d_d  ( m, func_acot );
+    G->register_fct_d_d(m, func_acot);
     m = { "asind", 1, "(x): arc sine of x (result is in degrees; 0 if |x|>1)" };
-    G->register_fct_d_d  ( m, func_asind );
+    G->register_fct_d_d(m, func_asind);
     m = { "acosd", 1, "(x): arc cosine of x (result is in degrees; 0 if |x|>1)" };
-    G->register_fct_d_d  ( m, func_acosd );
+    G->register_fct_d_d(m, func_acosd);
     m = { "atand", 1, "(x): arc tangent of x (result is in degrees)" };
-    G->register_fct_d_d  ( m, func_atand );
+    G->register_fct_d_d(m, func_atand);
     m = { "acotd", 1, "(x): arc cotangent of x (result is in degrees)" };
-    G->register_fct_d_d  ( m, func_acotd );
+    G->register_fct_d_d(m, func_acotd);
     m = { "sinh", 1, "(x): hyperbolic sine of x" };
-    G->register_fct_d_d  ( m, func_sinh );
+    G->register_fct_d_d(m, func_sinh);
     m = { "cosh", 1, "(x): hyperbolic cosine of x" };
-    G->register_fct_d_d  ( m, func_cosh );
+    G->register_fct_d_d(m, func_cosh);
     m = { "tanh", 1, "(x): hyperbolic tangent of x" };
-    G->register_fct_d_d  ( m, func_tanh );
+    G->register_fct_d_d(m, func_tanh);
     m = { "coth", 1, "(x): hyperbolic tangent of x" };
-    G->register_fct_d_d  ( m, func_coth );
+    G->register_fct_d_d(m, func_coth);
     m = { "j0", 1, "(x): spherical Bessel function x" };
-    G->register_fct_d_d  ( m, func_j0 );
+    G->register_fct_d_d(m, func_j0);
     m = { "j1", 1, "(x): spherical Bessel function x" };
-    G->register_fct_d_d  ( m, func_j1 );
+    G->register_fct_d_d(m, func_j1);
     m = { "fac", 1, "(x): factorial of nearest integer of x" };
-    G->register_fct_d_d  ( m, func_fac );
+    G->register_fct_d_d(m, func_fac);
     m = { "cata", 1, "(x): Catalan number of nearest integer of x" };
-    G->register_fct_d_d  ( m, func_cata );
+    G->register_fct_d_d(m, func_cata);
     m = { "gamma", 1, "(x): gamma function of x (i.e. factorial of x-1)" };
-    G->register_fct_d_d  ( m, func_gamma );
+    G->register_fct_d_d(m, func_gamma);
     m = { "lgamma", 1, "(x): ln of gamma of x" };
-    G->register_fct_d_d  ( m, func_lgamma );
+    G->register_fct_d_d(m, func_lgamma);
     m = { "debye1", 1, "(x): Debye function D1 of x" };
-    G->register_fct_d_d  ( m, func_debye1 );
+    G->register_fct_d_d(m, func_debye1);
     m = { "debye3", 1, "(x): Debye function D3 of x" };
-    G->register_fct_d_d  ( m, func_debye3 );
+    G->register_fct_d_d(m, func_debye3);
     m = { "debyeu2", 1, "(x): Debye mean squared displacement's temperature dependence" };
-    G->register_fct_d_d  ( m, func_debye_msd );
+    G->register_fct_d_d(m, func_debye_msd);
     m = { "debyeui", 1, "(x): Debye internal energy" };
-    G->register_fct_d_d  ( m, func_debye_ui );
+    G->register_fct_d_d(m, func_debye_ui);
     m = { "debyecv", 1, "(x): Debye heat capacity" };
-    G->register_fct_d_d  ( m, func_debye_cv );
+    G->register_fct_d_d(m, func_debye_cv);
     m = { "erfP", 1, "(x): ?" };
-    G->register_fct_d_d  ( m, func_erfP );
+    G->register_fct_d_d(m, func_erfP);
     m = { "erfQ", 1, "(x): ?" };
-    G->register_fct_d_d  ( m, func_erfQ );
+    G->register_fct_d_d(m, func_erfQ);
     m = { "erf", 1, "(x): error function of x" };
-    G->register_fct_d_d  ( m, func_erf );
+    G->register_fct_d_d(m, func_erf);
     m = { "erfc", 1, "(x): complementary error function of x" };
-    G->register_fct_d_d  ( m, func_erfc );
+    G->register_fct_d_d(m, func_erfc);
     m = { "erfi", 1, "(x): imaginary error function of x" };
-    G->register_fct_d_d  ( m, func_erfi );
+    G->register_fct_d_d(m, func_erfi);
     m = { "dawson", 1, "(x): Dawson function of x" };
-    G->register_fct_d_d  ( m, func_dawson );
+    G->register_fct_d_d(m, func_dawson);
     m = { "sinc", 1, "(x): sinus cardinalis, sin(x)/x" };
-    G->register_fct_d_d  ( m, func_sinc );
+    G->register_fct_d_d(m, func_sinc);
     m = { "ceil", 1, "(x): the smallest integer i with i>=x" };
-    G->register_fct_i_d  ( m, func_ceil );
+    G->register_fct_i_d(m, func_ceil);
     m = { "floor", 1, "(x): the largest integer i with i<=x" };
-    G->register_fct_i_d  ( m, func_floor );
+    G->register_fct_i_d(m, func_floor);
     m = { "nint", 1, "(x): the integer nearest to x" };
-    G->register_fct_i_d  ( m, func_nint );
+    G->register_fct_i_d(m, func_nint);
 
     m = { "diehl", 1, "(cauchywid/gausswid): normalized convolution gauss(*)cauchy" };
-    G->register_fct_d_d  ( m, func_diehl );
+    G->register_fct_d_d(m, func_diehl);
     m = { "lndiehl", 1, "(cauchywid/gausswid): ln of normalized convolution gauss(*)cauchy" };
-    G->register_fct_d_d  ( m, func_lndiehl );
+    G->register_fct_d_d(m, func_lndiehl);
 
     // f(2 args)
     m = { "exit_if", 2, "(x,s): throw s if x" };
-    G->register_fct_i_is ( m, func_exit_if );
+    G->register_fct_i_is(m, func_exit_if);
     m = { "exit_unless", 1, "(x,s): throw s if !x" };
-    G->register_fct_i_is ( m, func_exit_unless );
+    G->register_fct_i_is(m, func_exit_unless);
     m = { "min2", 2, "(x,y): the smaller of the two arguments x and y" };
-    G->register_fct_i_ii ( m, func_min );
-    G->register_fct_d_dd ( m, func_min );
+    G->register_fct_i_ii(m, func_min);
+    G->register_fct_d_dd(m, func_min);
     m = { "max2", 2, "(x,y): the smaller of the two arguments x and y" };
-    G->register_fct_i_ii ( m, func_max );
-    G->register_fct_d_dd ( m, func_max );
+    G->register_fct_i_ii(m, func_max);
+    G->register_fct_d_dd(m, func_max);
     m = { "ran", 2, "(x,y): a random number between x and y" };
-    G->register_fct_d_dd ( m, func_ran );
+    G->register_fct_d_dd(m, func_ran);
 
     m = { "gauss", 2, "(x,s): the normalized Gaussian exp(-x^2/2/s^2)/sqrt(2 pi)/s" };
-    G->register_fct_d_dd ( m, func_gauss );
+    G->register_fct_d_dd(m, func_gauss);
     m = { "gnn", 2, "(x,s): the unnormalized Gaussian exp(-x^2/2/s^2)" };
-    G->register_fct_d_dd ( m, func_gaussnn );
+    G->register_fct_d_dd(m, func_gaussnn);
     m = { "cauchy", 2, "(x,w): the Cauchy-Lorentz function ?/(x^2+w^2)" };
-    G->register_fct_d_dd ( m, func_cauchy );
+    G->register_fct_d_dd(m, func_cauchy);
 
     // f(3 args)
     m = { "rehavneg", 3, "(x,y,z): real part of the Havriliak-Negami function" };
-    G->register_fct_d_ddd( m, func_re_havneg );
+    G->register_fct_d_ddd(m, func_re_havneg);
     m = { "imhavneg", 3, "(x,y,z): imaginary part of the Havriliak-Negami function" };
-    G->register_fct_d_ddd( m, func_im_havneg );
+    G->register_fct_d_ddd(m, func_im_havneg);
     m = { "q4w", 3, "(x,y,z): ?" };
-    G->register_fct_d_ddd( m, func_q4w );
+    G->register_fct_d_ddd(m, func_q4w);
     m = { "cauchy2", 3, "(x,y,z): ?" };
-    G->register_fct_d_ddd( m, func_cauchy2 );
+    G->register_fct_d_ddd(m, func_cauchy2);
     m = { "kwwc", 3, "(w,tau,b): Fourier cosine transform (t->w) of exp((t/tau)^b)" };
-    G->register_fct_d_ddd( m, func_kwwc );
+    G->register_fct_d_ddd(m, func_kwwc);
     m = { "kwws", 3, "(w,tau,b): Fourier sine transform (t->w) of exp((t/tau)^b)" };
-    G->register_fct_d_ddd( m, func_kwws );
+    G->register_fct_d_ddd(m, func_kwws);
     m = { "kwwp", 3, "(w,tau,b): primitive of Fourier cosine transform (t->w) of exp((t/tau)^b)" };
-    G->register_fct_d_ddd( m, func_kwwp );
+    G->register_fct_d_ddd(m, func_kwwp);
     m = { "kwwmc", 3, "(w,<tau>,b): Fourier cosine transform (t->w) of exp((t/tau)^b)" };
-    G->register_fct_d_ddd( m, func_kwwc );
+    G->register_fct_d_ddd(m, func_kwwc);
     m = { "kwwms", 3, "(w,<tau>,b): Fourier sine transform (t->w) of exp((t/tau)^b)" };
-    G->register_fct_d_ddd( m, func_kwws );
-    m = { "kwwmp", 3, "(w,<tau>,b): primitive of Fourier cosine transform (t->w) of exp((t/tau)^b)" };
-    G->register_fct_d_ddd( m, func_kwwp );
+    G->register_fct_d_ddd(m, func_kwws);
+    m = { "kwwmp", 3,
+          "(w,<tau>,b): primitive of Fourier cosine transform (t->w) of exp((t/tau)^b)" };
+    G->register_fct_d_ddd(m, func_kwwp);
     m = { "voigt", 3, "(x,sigma,gamma): convolution of Gaussian(x,sigma) and Lorentzian(x,gamma)" };
-    G->register_fct_d_ddd( m, func_voigt );
+    G->register_fct_d_ddd(m, func_voigt);
     m = { "zorn", 3, "(I,<I>,s): Zorn's multiple-scattering corrected elastic intensity" };
-    G->register_fct_d_ddd( m, func_zorn );
-    m = { "zorn2", 3, "(q,<u^2>,s): Zorn's multiple-scattering corrected Gaussian elastic intensity for Si111" };
-    G->register_fct_d_ddd( m, func_zorn_gauss );
+    G->register_fct_d_ddd(m, func_zorn);
+    m = {
+        "zorn2", 3,
+        "(q,<u^2>,s): Zorn's multiple-scattering corrected Gaussian elastic intensity for Si111"
+    };
+    G->register_fct_d_ddd(m, func_zorn_gauss);
     m = { "rrdm", 3, "(w*t0,EA_mean/T,EA_stdv/EA_mean: rotational rate distribution model" };
-    G->register_fct_d_ddd( m, func_rrdm );
+    G->register_fct_d_ddd(m, func_rrdm);
     m = { "ornuhl", 3, "(w,a,b) Ornstein-Uhlenbeck spectrum FT[exp(-|b|t-a(1-exp(-t)))]" };
-    G->register_fct_d_ddd( m, func_ornuhl );
+    G->register_fct_d_ddd(m, func_ornuhl);
     m = { "rotdiff", 3, "(w,tau,qb: rotational diffusion spectrum)" };
-    G->register_fct_d_ddd( m, func_rotdiff );
+    G->register_fct_d_ddd(m, func_rotdiff);
 }
diff --git a/pub/lib/file_in.cpp b/pub/lib/file_in.cpp
index 369a2e101277ef054d2a6c4a37e423e9dea6cf94..b8d27c805b704b8d516c27e940d80b32dc2fc2cf 100644
--- a/pub/lib/file_in.cpp
+++ b/pub/lib/file_in.cpp
@@ -14,23 +14,24 @@
 
 #include <yaml-cpp/yaml.h>
 
-#include "../trivia/string_ops.hpp"
-#include "../trivia/file_ops.hpp"
 #include "../readplus/ask.hpp"
+#include "../trivia/file_ops.hpp"
+#include "../trivia/string_ops.hpp"
 
-#include "olf.hpp"
+#include "file_in.hpp"
 #include "mem.hpp"
-#include "slice.hpp"
 #include "obj.hpp"
-#include "file_in.hpp"
+#include "olf.hpp"
+#include "slice.hpp"
 
 
-namespace NFileIn {
-    void Load_yda( std::ifstream& F_in, string fnam );
-    void Load_08( std::ifstream& F_in, string flong );
-    void Load_01( FILE *F_in, string flong );
-    void LoadSpec_01( FILE *F_in, PSpec& sout, int nz );
-    void Load_96( FILE *F_in, string flong );
+namespace NFileIn
+{
+void Load_yda(std::ifstream& F_in, string fnam);
+void Load_08(std::ifstream& F_in, string flong);
+void Load_01(FILE* F_in, string flong);
+void LoadSpec_01(FILE* F_in, PSpec& sout, int nz);
+void Load_96(FILE* F_in, string flong);
 }
 
 
@@ -38,36 +39,34 @@ namespace NFileIn {
 
 void NFileIn::load(void)
 {
-    string pattern = sask( "Load file(s)" );
-    vector<string> fNames = triv::glob_file_list( pattern, "yda y08 a01 i96" );
-    for( string fnam: fNames ) {
-        try{
+    string pattern = sask("Load file(s)");
+    vector<string> fNames = triv::glob_file_list(pattern, "yda y08 a01 i96");
+    for (string fnam : fNames) {
+        try {
             string fdir, fshort, fext;
-            triv::fname_divide( fnam, &fdir, &fshort, &fext);
-            if ( fext=="y08" || fext=="yda" ) {
-                std::ifstream FS (fnam.c_str(), std::ios_base::in);
-                if( FS.fail() )
+            triv::fname_divide(fnam, &fdir, &fshort, &fext);
+            if (fext == "y08" || fext == "yda") {
+                std::ifstream FS(fnam.c_str(), std::ios_base::in);
+                if (FS.fail())
                     throw string("cannot open file");
                 cout << ".. loading file " << fnam << "\n";
-                Load_yda( FS, fshort );
+                Load_yda(FS, fshort);
                 FS.close();
-            } else if ( fext=="a01" || fext=="i96" ) {
-                FILE *F_in;
-                if( !(F_in = fopen(fnam.c_str(), "r")) )
+            } else if (fext == "a01" || fext == "i96") {
+                FILE* F_in;
+                if (!(F_in = fopen(fnam.c_str(), "r")))
                     throw "cannot open file " + fnam;
-                if ( fext=="a01" ) {
-                    Load_01( F_in, fnam.c_str() );
-                } else if ( fext=="i96" ) {
-                    Load_96( F_in, fnam.c_str() );
+                if (fext == "a01") {
+                    Load_01(F_in, fnam.c_str());
+                } else if (fext == "i96") {
+                    Load_96(F_in, fnam.c_str());
                 }
-                fclose( F_in );
+                fclose(F_in);
             } else
                 throw "unknown extension " + fext;
-        }
-        catch(string& ex) {
+        } catch (string& ex) {
             throw "Cannot load " + fnam + ": " + ex;
-        }
-        catch(std::exception& ex) {
+        } catch (std::exception& ex) {
             throw "Cannot load " + fnam + ": " + ex.what();
         }
     }
@@ -78,49 +77,49 @@ void NFileIn::load(void)
 void NFileIn::Load_yda(std::ifstream& FS, string fnam)
 {
     const YAML::Node doc = YAML::Load(FS);
-    if( doc.Type() != YAML::NodeType::Map )
+    if (doc.Type() != YAML::NodeType::Map)
         throw S("document root is not of MAP type");
 
-    //read meta
-    if(!doc["Meta"])
+    // read meta
+    if (!doc["Meta"])
         throw S("no Meta");
-    if ( doc["Meta"].Type() != YAML::NodeType::Map )
+    if (doc["Meta"].Type() != YAML::NodeType::Map)
         throw S("Meta is not of MAP type");
 
-    if(!doc["Meta"]["format"])
+    if (!doc["Meta"]["format"])
         throw S("no format in Meta");
     string s = doc["Meta"]["format"].as<string>();
     int version;
-    if      ( s == "frida/y08 for yaml1" )
+    if (s == "frida/y08 for yaml1")
         version = 1;
-    else if ( s == "yaml/frida 2.0" )
+    else if (s == "yaml/frida 2.0")
         version = 2;
     else
         throw "unknown data format '" + s + "'";
 
-    if(!doc["Meta"]["type"])
+    if (!doc["Meta"]["type"])
         throw S("no type in Meta");
     string type = doc["Meta"]["type"].as<string>();
 
     // create output file
     POlo fout;
     bool isdata;
-    COlc *fc = nullptr;
-    if ( type == "generic tabular data" ){
+    COlc* fc = nullptr;
+    if (type == "generic tabular data") {
         isdata = true;
-        fout = POld( new COld );
-    } else if ( type == "frida2 curve" ){
+        fout = POld(new COld);
+    } else if (type == "frida2 curve") {
         isdata = false;
-        fout = POlc( new COlc );
+        fout = POlc(new COlc);
         fc = dynamic_cast<COlc*>(fout.get());
-     } else
-        throw "Invalid file type "+type;
+    } else
+        throw "Invalid file type " + type;
 
     // read history
-    if(!doc["History"])
+    if (!doc["History"])
         throw S("no History");
-    if ( doc["History"].Type() != YAML::NodeType::Sequence &&
-         (version>1 || doc["History"].size()>0 ) )
+    if (doc["History"].Type() != YAML::NodeType::Sequence
+        && (version > 1 || doc["History"].size() > 0))
         throw S("History is not of SEQUENCE type");
     for (int i = 0; i < doc["History"].size(); i++) {
         string s = doc["History"][i].as<string>();
@@ -128,319 +127,317 @@ void NFileIn::Load_yda(std::ifstream& FS, string fnam)
     }
 
     // read coord
-    if(!doc["Coord"])
+    if (!doc["Coord"])
         throw S("no Coord");
-    if ( doc["Coord"].Type() != YAML::NodeType::Map )
+    if (doc["Coord"].Type() != YAML::NodeType::Map)
         throw S("Coord is not of MAP type");
-    if( const YAML::Node& dCo = doc["Coord"]["x"] ){
+    if (const YAML::Node& dCo = doc["Coord"]["x"]) {
         fout->xco.name = dCo["name"].as<string>();
-        fout->xco.unit =dCo["unit"].as<string>();
+        fout->xco.unit = dCo["unit"].as<string>();
     } else
         throw S("no x coord");
-    if( const YAML::Node& dCo = doc["Coord"]["y"] ){
+    if (const YAML::Node& dCo = doc["Coord"]["y"]) {
         fout->yco.name = dCo["name"].as<string>();
         fout->yco.unit = dCo["unit"].as<string>();
     } else
         throw S("no y coord");
-    if ( version==1 ) {
+    if (version == 1) {
         int iz = 0;
-        while(const YAML::Node& dCo = doc["Coord"]["z"+S(iz)]){
+        while (const YAML::Node& dCo = doc["Coord"]["z" + S(iz)]) {
             CCoord co(dCo["name"].as<string>(), dCo["unit"].as<string>());
-            fout->ZCo.push_back( co );
+            fout->ZCo.push_back(co);
             ++iz;
         }
     } else {
-        if ( doc["Coord"]["z"].Type() != YAML::NodeType::Sequence )
+        if (doc["Coord"]["z"].Type() != YAML::NodeType::Sequence)
             throw S("Coord[z] is not of SEQUENCE type");
-        for ( auto dCo: doc["Coord"]["z"] ) {
+        for (auto dCo : doc["Coord"]["z"]) {
             CCoord co(dCo["name"].as<string>(), dCo["unit"].as<string>());
-            fout->ZCo.push_back( co );
+            fout->ZCo.push_back(co);
         }
     }
 
     // read r-pars
-    if ( version==1 ) {
-        if(!doc["Param"])
+    if (version == 1) {
+        if (!doc["Param"])
             throw S("no Param");
-        if ( doc["Param"].Type() != YAML::NodeType::Sequence  && doc["Param"].size() > 0)
+        if (doc["Param"].Type() != YAML::NodeType::Sequence && doc["Param"].size() > 0)
             throw S("Param is not of SEQUENCE type");
-        for( int iParam = 0; iParam < (doc["Param"].size()); iParam++ ){
-            if ( doc["Param"][iParam].Type() != YAML::NodeType::Map )
+        for (int iParam = 0; iParam < (doc["Param"].size()); iParam++) {
+            if (doc["Param"][iParam].Type() != YAML::NodeType::Map)
                 throw "Param " + S(iParam) + " is not of MAP type";
-            CCoord co(doc["Param"][iParam]["name"].as<string>(),
-                      doc["Param"][iParam]["unit"].as<string>());
+            CCoord co(
+                doc["Param"][iParam]["name"].as<string>(),
+                doc["Param"][iParam]["unit"].as<string>());
             string s = doc["Param"][iParam]["value"].as<string>();
             double num;
-            if( !triv::any2dbl( s, &num ) )
+            if (!triv::any2dbl(s, &num))
                 throw "param(" + co.name + "): invalid value " + s;
-            fout->RPar.push_back( CParam( co, num ) );
+            fout->RPar.push_back(CParam(co, num));
         }
     } else {
-        if(!doc["RPar"])
+        if (!doc["RPar"])
             throw S("no RPar");
-        if ( doc["RPar"].Type() != YAML::NodeType::Sequence )
+        if (doc["RPar"].Type() != YAML::NodeType::Sequence)
             throw S("RPar is not of SEQUENCE type");
-        for ( auto dCo: doc["RPar"] ) {
-            if ( dCo.Type() != YAML::NodeType::Map )
+        for (auto dCo : doc["RPar"]) {
+            if (dCo.Type() != YAML::NodeType::Map)
                 throw S("an r-par is not of MAP type");
             CCoord co(dCo["name"].as<string>(), dCo["unit"].as<string>());
             double val = dCo["val"].as<double>();
-            fout->RPar.push_back( CParam( co, val ) );
+            fout->RPar.push_back(CParam(co, val));
         }
     }
 
     // for curve, read formula
-    if( !isdata ) {
-       string expr;
-        if ( version==1 ) {
-            if( !doc["Formula"] )
+    if (!isdata) {
+        string expr;
+        if (version == 1) {
+            if (!doc["Formula"])
                 throw S("DEFICIENT FILE: no formula");
             expr = doc["Formula"].as<string>();
         } else {
             const YAML::Node& nod = doc["Curve"];
-            if( !nod )
+            if (!nod)
                 throw S("DEFICIENT FILE: no Curve section");
             expr = nod["expr"].as<string>();
             fc->nP = nod["nPar"].as<int>();
-            fc->weighing = COlc::name2wgt( nod["weighing"].as<string>() );
+            fc->weighing = COlc::name2wgt(nod["weighing"].as<string>());
             fc->chi2 = nod["chi2"].as<double>();
         }
-        fc->parse_function( expr );
+        fc->parse_function(expr);
         fc->curve_set_defaults();
     }
 
     // start to read slices
-    if ( version==1 ) {
-        if(!doc["Tables"])
+    if (version == 1) {
+        if (!doc["Tables"])
             throw S("no Tables");
-        if ( doc["Tables"].Type() != YAML::NodeType::Sequence && doc["Tables"].size() > 0 )
+        if (doc["Tables"].Type() != YAML::NodeType::Sequence && doc["Tables"].size() > 0)
             throw S("Tables is not of SEQUENCE type");
         for (int iTable = 0; iTable < (doc["Tables"].size()); iTable++) {
-            if ( doc["Tables"][iTable].Type() != YAML::NodeType::Map )
+            if (doc["Tables"][iTable].Type() != YAML::NodeType::Map)
                 throw "Tables " + S(iTable) + " is not of MAP type";
             vector<RObj> z;
-            for(int iz=0; iz<fout->ZCo.size(); ++iz ){
-                string s = doc["Tables"][iTable]["z" + S(iz)].as<string>() ;
+            for (int iz = 0; iz < fout->ZCo.size(); ++iz) {
+                string s = doc["Tables"][iTable]["z" + S(iz)].as<string>();
                 double num;
-                if( !triv::any2dbl( s, &num ) )
+                if (!triv::any2dbl(s, &num))
                     throw "z" + S(iz) + ": invalid value " + s;
-                z.push_back( RObjDbl( new CObjDbl( num ) ) );
+                z.push_back(RObjDbl(new CObjDbl(num)));
             }
 
-            if( isdata ) {
-                PSpec sout( new CSpec );
+            if (isdata) {
+                PSpec sout(new CSpec);
                 sout->z = z;
                 string xytag;
-                if ( doc["Tables"][iTable]["xy"] ) {
+                if (doc["Tables"][iTable]["xy"]) {
                     string res, lin;
                     string val = doc["Tables"][iTable]["xy"].as<string>();
-                    while( val != "" ) {
-                        triv::string_extract_line( val, &lin, &res );
+                    while (val != "") {
+                        triv::string_extract_line(val, &lin, &res);
                         double vx, vy;
-                        if( sscanf( lin.c_str(), "%lg %lg\n", &vx, &vy )!=2 )
+                        if (sscanf(lin.c_str(), "%lg %lg\n", &vx, &vy) != 2)
                             throw "xy: bad data line: " + lin;
-                        sout->push_xy( vx, vy );
+                        sout->push_xy(vx, vy);
                         val = res;
                     };
-                } else if ( doc["Tables"][iTable]["xyd"] ) {
-                    //itxy.second() >> val;
+                } else if (doc["Tables"][iTable]["xyd"]) {
+                    // itxy.second() >> val;
                     string res, lin;
                     string val = doc["Tables"][iTable]["xyd"].as<string>();
-                    while( val != "" ) {
-                        triv::string_extract_line( val, &lin, &res );
+                    while (val != "") {
+                        triv::string_extract_line(val, &lin, &res);
                         double vx, vy, dy;
-                        if( sscanf( lin.c_str(), "%lg %lg %lg\n",&vx, &vy, &dy )!=3 )
+                        if (sscanf(lin.c_str(), "%lg %lg %lg\n", &vx, &vy, &dy) != 3)
                             throw "xyd: bad data line: " + lin;
-                        sout->push_xyd( vx, vy, dy );
+                        sout->push_xyd(vx, vy, dy);
                         val = res;
                     };
                 } else
                     throw "invalid xytag " + xytag;
-                fout->V.push_back( move(sout) );
+                fout->V.push_back(move(sout));
             } else {
-                PCurve cout( new CCurve );
+                PCurve cout(new CCurve);
                 cout->z = z;
-                for( int ip=0; ip<fc->nP; ++ip ){
+                for (int ip = 0; ip < fc->nP; ++ip) {
                     string res;
                     string val = doc["Tables"][iTable]["p" + S(ip)].as<string>();
                     double num;
-                    if( !triv::any2dbl( val, &num ) )
+                    if (!triv::any2dbl(val, &num))
                         throw "p" + S(ip) + ": invalid value " + val;
-                    cout->P.push_back( num );
-                    cout->ParAttr.push_back( 'u' );
+                    cout->P.push_back(num);
+                    cout->ParAttr.push_back('u');
                 }
-                fout->V.push_back( move(cout) );
+                fout->V.push_back(move(cout));
             }
         }
     } else {
-        if(!doc["Slices"])
+        if (!doc["Slices"])
             throw S("no Slices");
-        if ( doc["Slices"].Type() != YAML::NodeType::Sequence )
+        if (doc["Slices"].Type() != YAML::NodeType::Sequence)
             throw S("section Slices is not of SEQUENCE type");
-        for ( const YAML::Node& nodeSlic: doc["Slices"] ) {
-            if ( nodeSlic.Type() != YAML::NodeType::Map )
+        for (const YAML::Node& nodeSlic : doc["Slices"]) {
+            if (nodeSlic.Type() != YAML::NodeType::Map)
                 throw S("a slice is not of MAP type");
             const YAML::Node& nodeZ = nodeSlic["z"];
-            if(!nodeZ)
+            if (!nodeZ)
                 throw S("a slice has no z entry");
-            if ( nodeZ.Type() != YAML::NodeType::Sequence )
+            if (nodeZ.Type() != YAML::NodeType::Sequence)
                 throw S("a z entry is not of SEQUENCE type");
             vector<RObj> z;
-            for ( const YAML::Node& nodeZi: nodeZ ) {
-                if ( nodeSlic.Type() != YAML::NodeType::Map )
+            for (const YAML::Node& nodeZi : nodeZ) {
+                if (nodeSlic.Type() != YAML::NodeType::Map)
                     throw S("a z entry is not of MAP type");
-                z.push_back( RObjDbl( new CObjDbl( nodeZi["val"].as<double>() ) ) );
+                z.push_back(RObjDbl(new CObjDbl(nodeZi["val"].as<double>())));
             }
-            if( isdata ) {
-                PSpec sout( new CSpec );
+            if (isdata) {
+                PSpec sout(new CSpec);
                 sout->z = z;
-                if(!nodeSlic["x"])
+                if (!nodeSlic["x"])
                     throw S("a slice has no x entry");
-                if ( nodeSlic["x"].Type() != YAML::NodeType::Sequence )
+                if (nodeSlic["x"].Type() != YAML::NodeType::Sequence)
                     throw S("an x entry is not of SEQUENCE type");
-                for ( const YAML::Node& nodeEle: nodeSlic["x"] )
-                    sout->x.push_back( nodeEle.as<double>() );
+                for (const YAML::Node& nodeEle : nodeSlic["x"])
+                    sout->x.push_back(nodeEle.as<double>());
 
-                if(!nodeSlic["y"])
+                if (!nodeSlic["y"])
                     throw S("a slice has no y entry");
-                if ( nodeSlic["y"].Type() != YAML::NodeType::Sequence )
+                if (nodeSlic["y"].Type() != YAML::NodeType::Sequence)
                     throw S("a y entry is not of SEQUENCE type");
-                for ( const YAML::Node& nodeEle: nodeSlic["y"] )
-                    sout->y.push_back( nodeEle.as<double>() );
-                if( sout->y.size() != sout->x.size() )
+                for (const YAML::Node& nodeEle : nodeSlic["y"])
+                    sout->y.push_back(nodeEle.as<double>());
+                if (sout->y.size() != sout->x.size())
                     throw S("a y entry differs in length from x");
 
-                if( nodeSlic["dy"] ) {
-                    if ( nodeSlic["dy"].Type() != YAML::NodeType::Sequence )
+                if (nodeSlic["dy"]) {
+                    if (nodeSlic["dy"].Type() != YAML::NodeType::Sequence)
                         throw S("a dy entry is not of SEQUENCE type");
-                    for ( const YAML::Node& nodeEle: nodeSlic["dy"] )
-                        sout->dy.push_back( nodeEle.as<double>() );
-                    if( sout->dy.size() != sout->x.size() )
+                    for (const YAML::Node& nodeEle : nodeSlic["dy"])
+                        sout->dy.push_back(nodeEle.as<double>());
+                    if (sout->dy.size() != sout->x.size())
                         throw S("a dy entry differs in length from x");
                 }
-                fout->V.push_back( move(sout) );
+                fout->V.push_back(move(sout));
             } else {
-                PCurve cout( new CCurve );
+                PCurve cout(new CCurve);
                 cout->z = z;
-                if(!nodeSlic["p"])
+                if (!nodeSlic["p"])
                     throw S("a slice has no p entry");
-                if ( nodeSlic["p"].Type() != YAML::NodeType::Sequence )
+                if (nodeSlic["p"].Type() != YAML::NodeType::Sequence)
                     throw S("a p entry is not of SEQUENCE type");
-                for ( const YAML::Node& nodeEle: nodeSlic["p"] )
-                    cout->P.push_back( nodeEle.as<double>() );
-                if ( cout->P.size()!=fc->nP )
+                for (const YAML::Node& nodeEle : nodeSlic["p"])
+                    cout->P.push_back(nodeEle.as<double>());
+                if (cout->P.size() != fc->nP)
                     throw S("number of p entries conflicts with nPar");
 
-                if(!nodeSlic["attr"])
+                if (!nodeSlic["attr"])
                     throw S("a slice has no attr entry");
-                if ( nodeSlic["attr"].Type() != YAML::NodeType::Sequence )
+                if (nodeSlic["attr"].Type() != YAML::NodeType::Sequence)
                     throw S("an attr entry is not of SEQUENCE type");
-                for ( const YAML::Node& nodeEle: nodeSlic["attr"] )
-                    cout->ParAttr.push_back( nodeEle.as<char>() );
-                if ( cout->ParAttr.size()!=fc->nP )
+                for (const YAML::Node& nodeEle : nodeSlic["attr"])
+                    cout->ParAttr.push_back(nodeEle.as<char>());
+                if (cout->ParAttr.size() != fc->nP)
                     throw S("number of attr entries conflicts with nPar");
 
                 cout->fitOutcome = nodeSlic["fitOutcome"].as<double>();
                 cout->fitChi2 = nodeSlic["fitChi2"].as<double>();
                 cout->fitR2 = nodeSlic["fitR2"].as<double>();
 
-                fout->V.push_back( move(cout) );
+                fout->V.push_back(move(cout));
             }
         }
     }
 
     fout->name = fnam;
     fout->as_on_disk = true;
-    SMem::instance()->mem_store( move(fout) );
+    SMem::instance()->mem_store(move(fout));
 }
 
 
 //! Load a .a01 formatted file.
 
-void NFileIn::Load_01( FILE *F_in, string flong )
+void NFileIn::Load_01(FILE* F_in, string flong)
 {
     string lin, key, val, fdir, fshort, fext;
-    int iz, nj=0, j;
+    int iz, nj = 0, j;
     CCoord co;
-    POld fout( new COld );
+    POld fout(new COld);
 
-    triv::fname_divide( flong, &fdir, &fshort, &fext);
+    triv::fname_divide(flong, &fdir, &fshort, &fext);
 
-    if     ( triv::freadln(F_in, &lin)<=0 )
-        throw  "file empty or starting with empty line";
-    if     ( lin!=string("ASCII-01 JWu") )
+    if (triv::freadln(F_in, &lin) <= 0)
+        throw "file empty or starting with empty line";
+    if (lin != string("ASCII-01 JWu"))
         throw ".a01 file starts with illegal header [" + lin + "]";
 
-    if ( triv::freadln(F_in, &lin)<=0 || lin.length()<5 ||
-         lin.substr(0,4)!=string("typ ") )
+    if (triv::freadln(F_in, &lin) <= 0 || lin.length() < 5 || lin.substr(0, 4) != string("typ "))
         throw "no valid typ line";
-    if        ( lin.substr(4)=="D" ) {
+    if (lin.substr(4) == "D") {
         // ok
-    } else if ( lin.substr(4)=="C" ) {
+    } else if (lin.substr(4) == "C") {
         throw "reading curve files not implemented";
     } else {
         throw "invalid type [" + lin.substr(4) + "]";
     }
 
     while (1) { // loop over input lines
-        if ( !triv::freadln(F_in, &lin) )
+        if (!triv::freadln(F_in, &lin))
             throw "unexpected end-of-file";
 
         // regular exit when "eof" is reached:
-        if ( lin=="eof" ) {
+        if (lin == "eof") {
             fout->as_on_disk = true;
-            SMem::instance()->mem_store( move(fout) );
+            SMem::instance()->mem_store(move(fout));
             return;
         }
 
-        if ( lin.size() < 4 )
+        if (lin.size() < 4)
             throw "incomplete line";
 
-        key = lin.substr(0,4);
+        key = lin.substr(0, 4);
         val = lin.substr(4);
 
-        if        (key=="fil ") {
-            if (val!=fshort) {
-                cout << "warning: file '" << fshort <<
-                    "' renamed from '" << val << "'\n";
+        if (key == "fil ") {
+            if (val != fshort) {
+                cout << "warning: file '" << fshort << "' renamed from '" << val << "'\n";
             }
             fout->name = fshort;
-        } else if (key=="doc ") {
+        } else if (key == "doc ") {
             fout->lDoc.push_back(val);
-        } else if (key=="x   ") {
+        } else if (key == "x   ") {
             fout->xco.load_a01(val);
-        } else if (key=="y   ") {
+        } else if (key == "y   ") {
             fout->yco.load_a01(val);
-        } else if (lin[0]=='z') {
-            if ( sscanf(lin.substr(1,3).c_str(), "%i", &iz)!=1 )
+        } else if (lin[0] == 'z') {
+            if (sscanf(lin.substr(1, 3).c_str(), "%i", &iz) != 1)
                 throw "z coordinates must be numbered";
-            if ( iz!=fout->ZCo.size() )
+            if (iz != fout->ZCo.size())
                 throw "z coordinates must be sorted";
             co.load_a01(val);
             fout->ZCo.push_back(co);
-        } else if (lin.substr(0,4)=="rpa ") {
+        } else if (lin.substr(0, 4) == "rpa ") {
             string in = lin.substr(4);
             int ji = in.find_first_not_of(" \t");
             double dval;
-            if( ji>=20 || !triv::any2dbl( in.substr(ji,20), &dval ) )
+            if (ji >= 20 || !triv::any2dbl(in.substr(ji, 20), &dval))
                 throw "invalid rpa line\n";
-            fout->RPar.push_back( CParam( CCoord(), dval ) );
+            fout->RPar.push_back(CParam(CCoord(), dval));
             throw "a01 file contains rpa section. "
-                "Check the source code preceeding this error message. "
-                "It is possibly broken. If not, remove this exception.";
-        } else if (key=="#j  ") {
-            if ( sscanf(val.c_str(), "%i", &nj)!=1 )
-               throw "after key #j no no. of spectra";
-        } else if (key=="scn ") {
-            if ( sscanf(val.c_str(), "%i", &j)!=1 ) {
+                  "Check the source code preceeding this error message. "
+                  "It is possibly broken. If not, remove this exception.";
+        } else if (key == "#j  ") {
+            if (sscanf(val.c_str(), "%i", &nj) != 1)
+                throw "after key #j no no. of spectra";
+        } else if (key == "scn ") {
+            if (sscanf(val.c_str(), "%i", &j) != 1) {
                 cout << "warning: number of spectra not given\n";
-            } else if ( j!=fout->nJ() ) {
-                cout << "warning: spec " << fout->nJ() <<
-                    " has label " << j << "\n";
+            } else if (j != fout->nJ()) {
+                cout << "warning: spec " << fout->nJ() << " has label " << j << "\n";
             }
-            PSpec sout( new CSpec );
-            LoadSpec_01( F_in, sout, fout->nZ() );
-            fout->V.push_back( move(sout) );
+            PSpec sout(new CSpec);
+            LoadSpec_01(F_in, sout, fout->nZ());
+            fout->V.push_back(move(sout));
         } else {
             throw "Unexpected key [" + key + "]";
         }
@@ -450,7 +447,7 @@ void NFileIn::Load_01( FILE *F_in, string flong )
 
 //! Load a spectrum from a .a01 formatted files.
 
-void NFileIn::LoadSpec_01( FILE *F_in, PSpec& sout, int nz )
+void NFileIn::LoadSpec_01(FILE* F_in, PSpec& sout, int nz)
 {
     int err;
     int i, m, n;
@@ -458,26 +455,26 @@ void NFileIn::LoadSpec_01( FILE *F_in, PSpec& sout, int nz )
     double v, w;
 
     // get z values:
-    if ((err=fscanf(F_in, "%4c%i\n", lab, &m))!=2)
+    if ((err = fscanf(F_in, "%4c%i\n", lab, &m)) != 2)
         throw "expecting Z head line, found " + S(err) + " entries";
     if (strncmp(lab, "Z   ", 4))
         throw "found [" + string(lab) + "] in Z head line";
-    if (m!=nz)
+    if (m != nz)
         throw "found " + S(m) + " Z entries, expecting " + S(nz);
-    for ( i=0; i<nz; ++i ) {
-        if ((err=fscanf(F_in, "%lg\n", &v))!=1)
+    for (i = 0; i < nz; ++i) {
+        if ((err = fscanf(F_in, "%lg\n", &v)) != 1)
             throw "expecting z value, found " + S(err) + " entries";
-        sout->z.push_back( PObjDbl( new CObjDbl( v ) ) );
+        sout->z.push_back(PObjDbl(new CObjDbl(v)));
     }
 
     // get xy values:
-    if ( (err=fscanf(F_in, "%4c%i\n", lab, &n))!=2 )
+    if ((err = fscanf(F_in, "%4c%i\n", lab, &n)) != 2)
         throw "expecting XY head line, found " + S(err) + " entries";
-    if (strncmp(lab, "XY  ", 4) )
+    if (strncmp(lab, "XY  ", 4))
         throw "found [" + string(lab) + "] in XY head line";
 
-    for (i=0; i<n; i++) {
-        if ((err=fscanf(F_in, "%lg %lg\n", &v, &w))!=2) {
+    for (i = 0; i < n; i++) {
+        if ((err = fscanf(F_in, "%lg %lg\n", &v, &w)) != 2) {
             throw "expecting xy pair, found S(err) entries";
         }
         sout->push_xy(v, w);
@@ -487,150 +484,128 @@ void NFileIn::LoadSpec_01( FILE *F_in, PSpec& sout, int nz )
 
 //! Load a .i96 formatted file.
 
-void NFileIn::Load_96( FILE *F_in, string flong )
+void NFileIn::Load_96(FILE* F_in, string flong)
 {
     string lin, key, val, fdir, fshort, fext;
     double r0, r1, r2;
     int n, nspec, ival;
-    POld fout( new COld );
+    POld fout(new COld);
     CCoord co;
     PSpec sout;
 
-    triv::fname_divide( flong, &fdir, &fshort, &fext);
+    triv::fname_divide(flong, &fdir, &fshort, &fext);
     fout->name = fshort;
 
-    if     ( !triv::freadln(F_in, &lin) )
+    if (!triv::freadln(F_in, &lin))
         throw "file empty or starting with empty line";
-    if     ( lin!=string("ASCII-96") )
+    if (lin != string("ASCII-96"))
         throw ".i96 file starts with illegal header [" + lin + "]";
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<9 ||
-         lin.substr(0,9)!=string("(a24,a56)") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 9 || lin.substr(0, 9) != string("(a24,a56)"))
         throw "no valid intro to block 2";
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<24 ||
-         lin.substr(0,3)!=string("fil") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 24 || lin.substr(0, 3) != string("fil"))
         throw "tag 'fil' not found in block 2";
-    if ( triv::strip(lin.substr(24))!=fshort ) {
-                cout << "warning: i96 file '" << fshort <<
-                    "' renamed from '" << lin.substr(24) << "'\n";
+    if (triv::strip(lin.substr(24)) != fshort) {
+        cout << "warning: i96 file '" << fshort << "' renamed from '" << lin.substr(24) << "'\n";
     }
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<24 ||
-         lin.substr(0,3)!=string("tit") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 24 || lin.substr(0, 3) != string("tit"))
         throw "tag 'tit' not found in block 2";
-    fout->lDoc.push_back( triv::strip(lin.substr(24)) );
+    fout->lDoc.push_back(triv::strip(lin.substr(24)));
 
-    while( !triv::freadln(F_in, &lin) && lin.length()>=24 &&
-         lin.substr(0,3)==string("doc") )
-        fout->lDoc.push_back( triv::strip(lin.substr(24)) );
+    while (!triv::freadln(F_in, &lin) && lin.length() >= 24 && lin.substr(0, 3) == string("doc"))
+        fout->lDoc.push_back(triv::strip(lin.substr(24)));
 
-    if( lin.substr(0,3)!=string("dir") )
+    if (lin.substr(0, 3) != string("dir"))
         throw "tag 'dir' not found in block 2";
 
-    while ( triv::freadln(F_in, &lin) &&
-            !( lin.length()>=6 &&
-               lin.substr(0,6)==string("&eob 2") ) )
+    while (triv::freadln(F_in, &lin)
+           && !(lin.length() >= 6 && lin.substr(0, 6) == string("&eob 2")))
         ;
 
-    if ( !triv::freadln(F_in, &lin) )
+    if (!triv::freadln(F_in, &lin))
         throw "missed &eob 3";
 
-    if( lin.length()<9 || lin.substr(0,9)!=string("(a24,i16)") )
+    if (lin.length() < 9 || lin.substr(0, 9) != string("(a24,i16)"))
         throw "no valid intro to block 3";
 
-    while ( !triv::freadln(F_in, &lin) &&
-            !( lin.length()>=6 &&
-               lin.substr(0,6)==string("&eob 3") ) )
+    while (!triv::freadln(F_in, &lin)
+           && !(lin.length() >= 6 && lin.substr(0, 6) == string("&eob 3")))
         ;
 
-    if ( !triv::freadln(F_in, &lin) )
+    if (!triv::freadln(F_in, &lin))
         throw "missed &eob 3";
 
-    if ( lin.length()<16 || lin.substr(0,16)!=string("(a24,a24,g20.10)") )
+    if (lin.length() < 16 || lin.substr(0, 16) != string("(a24,a24,g20.10)"))
         throw "no valid intro to block 4";
 
-    while ( !triv::freadln(F_in, &lin) && lin.length()>=48 &&
-            lin.substr(0,4)!=string("&eob") ){
-        if( sscanf( lin.substr(48).c_str(), "%lg", &r0 )!=1 )
+    while (!triv::freadln(F_in, &lin) && lin.length() >= 48 && lin.substr(0, 4) != string("&eob")) {
+        if (sscanf(lin.substr(48).c_str(), "%lg", &r0) != 1)
             throw "no real value in rpar line";
-        fout->RPar.push_back(
-            CParam( lin.substr(0,24), lin.substr(24,24), r0 ) );
+        fout->RPar.push_back(CParam(lin.substr(0, 24), lin.substr(24, 24), r0));
     }
 
-    if( lin.substr(0,6)!=string("&eob 4") )
+    if (lin.substr(0, 6) != string("&eob 4"))
         throw "no valid eob 4";
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<9 ||
-         lin.substr(0,12)!=string("(a4,a24,a24)") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 9
+        || lin.substr(0, 12) != string("(a4,a24,a24)"))
         throw "no valid intro to block 5";
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<28 ||
-         lin.substr(0,1)!=string("x") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 28 || lin.substr(0, 1) != string("x"))
         throw "no x coordinate";
-    fout->xco = CCoord( triv::strip(lin.substr(4,24)),
-                        triv::strip(lin.substr(28,24)) );
+    fout->xco = CCoord(triv::strip(lin.substr(4, 24)), triv::strip(lin.substr(28, 24)));
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<28 ||
-         lin.substr(0,1)!=string("y") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 28 || lin.substr(0, 1) != string("y"))
         throw "no y coordinate";
-    fout->yco = CCoord( triv::strip(lin.substr(4,24)),
-                        triv::strip(lin.substr(28,24)) );
+    fout->yco = CCoord(triv::strip(lin.substr(4, 24)), triv::strip(lin.substr(28, 24)));
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<28 ||
-         lin.substr(0,1)!=string("z") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 28 || lin.substr(0, 1) != string("z"))
         throw "no z coordinate";
-    fout->ZCo.push_back( CCoord( triv::strip(lin.substr(4,24)),
-                                 triv::strip(lin.substr(28,24)) ) );
+    fout->ZCo.push_back(CCoord(triv::strip(lin.substr(4, 24)), triv::strip(lin.substr(28, 24))));
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<6 ||
-         lin.substr(0,6)!=string("&eob 5") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 6 || lin.substr(0, 6) != string("&eob 5"))
         throw "no valid eob 5";
 
-    if ( !triv::freadln(F_in, &lin) || lin.length()<5 ||
-         lin.substr(0,5)!=string("(a80)") )
+    if (!triv::freadln(F_in, &lin) || lin.length() < 5 || lin.substr(0, 5) != string("(a80)"))
         throw "no valid intro to block 6";
 
-    while ( triv::freadln(F_in, &lin)>0 &&
-            !( lin.length()>=6 &&
-               lin.substr(0,6)==string("&eob 6") ) )
-        fout->lDoc.push_back( lin );
+    while (triv::freadln(F_in, &lin) > 0
+           && !(lin.length() >= 6 && lin.substr(0, 6) == string("&eob 6")))
+        fout->lDoc.push_back(lin);
 
-    if ( !triv::freadln(F_in, &lin) )
+    if (!triv::freadln(F_in, &lin))
         throw "missed &eob 6";
-    for( int i=1; i<3; ++i )
-        if ( !triv::freadln(F_in, &lin) )
+    for (int i = 1; i < 3; ++i)
+        if (!triv::freadln(F_in, &lin))
             throw "no valid intro to block 7";
 
-    if ( !triv::freadln(F_in, &lin) ||
-         sscanf( lin.c_str(), "%i %i", &nspec, &ival )!=2 )
-            throw "no nspec or 2nd arg in intro to block 7";
+    if (!triv::freadln(F_in, &lin) || sscanf(lin.c_str(), "%i %i", &nspec, &ival) != 2)
+        throw "no nspec or 2nd arg in intro to block 7";
 
-    for( int j=0; j<nspec; ++j ){
-        sout = PSpec( new CSpec );
-        if ( !triv::freadln(F_in, &lin) || lin.length()<10 ||
-             lin.substr(0,9)!=string("&spectrum") ||
-             sscanf( lin.substr(10).c_str(), "%i", &ival )!=1 ||
-             ival!=j+1 )
+    for (int j = 0; j < nspec; ++j) {
+        sout = PSpec(new CSpec);
+        if (!triv::freadln(F_in, &lin) || lin.length() < 10
+            || lin.substr(0, 9) != string("&spectrum")
+            || sscanf(lin.substr(10).c_str(), "%i", &ival) != 1 || ival != j + 1)
             throw "no valid intro to spectrum";
 
-        if ( !triv::freadln(F_in, &lin) ||
-             sscanf( lin.c_str(), "%i %lg", &n, &r0 )!=2 )
+        if (!triv::freadln(F_in, &lin) || sscanf(lin.c_str(), "%i %lg", &n, &r0) != 2)
             throw "no valid header in spectrum";
-        sout->z.push_back( PObjDbl( new CObjDbl( r0 ) ) );
+        sout->z.push_back(PObjDbl(new CObjDbl(r0)));
 
-        for( int i=0; i<n; ++i ){
-            if ( !F_in || !triv::freadln(F_in, &lin) )
-                throw "i96: failed to read data line " +
-                    S(i) + " of " + S(n);
-            if ( sscanf( lin.c_str(), "%lg %lg %lg", &r0, &r1, &r2 )!=3 )
+        for (int i = 0; i < n; ++i) {
+            if (!F_in || !triv::freadln(F_in, &lin))
+                throw "i96: failed to read data line " + S(i) + " of " + S(n);
+            if (sscanf(lin.c_str(), "%lg %lg %lg", &r0, &r1, &r2) != 3)
                 throw "i96: bad data line: '" + lin + "'";
             sout->push_xy(r0, r1);
         }
 
-        fout->V.push_back( move(sout) );
+        fout->V.push_back(move(sout));
     }
 
     fout->as_on_disk = true;
-    SMem::instance()->mem_store( move(fout) );
+    SMem::instance()->mem_store(move(fout));
 }
diff --git a/pub/lib/file_in.hpp b/pub/lib/file_in.hpp
index 644c44da0d14a5fe9fe462a8b649efab1bd7da1e..4be81539f85b34255702df14524666cff6d10703 100644
--- a/pub/lib/file_in.hpp
+++ b/pub/lib/file_in.hpp
@@ -10,6 +10,7 @@
 
 //! Method to load files, with support for various old formats.
 
-namespace NFileIn {
-    void load();
+namespace NFileIn
+{
+void load();
 }
\ No newline at end of file
diff --git a/pub/lib/file_out.cpp b/pub/lib/file_out.cpp
index 55fb3a11086f47e116b80280f1acb367d3d4c02e..ecc0a6c1907f6f7c9c0d2961da4a6db9816ab6e0 100644
--- a/pub/lib/file_out.cpp
+++ b/pub/lib/file_out.cpp
@@ -12,65 +12,66 @@
 #include <fstream>
 #include <yaml-cpp/yaml.h>
 
-#include "../trivia/yaml_out.hpp"
 #include "../readplus/ask.hpp"
+#include "../trivia/yaml_out.hpp"
 
-#include "olf.hpp"
+#include "file_out.hpp"
 #include "fsel.hpp"
 #include "loop.hpp"
 #include "obj.hpp"
+#include "olf.hpp"
 #include "slice.hpp"
-#include "file_out.hpp"
 
-namespace NFileOut {
-    void save_yda(  std::ofstream& ofs, const COlo *f );
-    void save_y08( FILE *file, const COlo *f );
-    void save_csv( FILE *file, const COlo *f );
-    void save_tab( FILE *file, const COlo *f );
+namespace NFileOut
+{
+void save_yda(std::ofstream& ofs, const COlo* f);
+void save_y08(FILE* file, const COlo* f);
+void save_csv(FILE* file, const COlo* f);
+void save_tab(FILE* file, const COlo* f);
 }
 
 
 //! Queries file names, and writes files.
 
-void NFileOut::save( string fmt, bool allow_overwrite )
+void NFileOut::save(string fmt, bool allow_overwrite)
 { // EMBEDDED_DIALOG
     string outfnam;
     FileIterator fiter(SFSel::instance()->sel());
-    while( COlo *f = fiter.next() ) {
+    while (COlo* f = fiter.next()) {
         // query output file name
-        outfnam = wask( "Save as (."+fmt+")", f->name);
-        if ( outfnam=="" )
+        outfnam = wask("Save as (." + fmt + ")", f->name);
+        if (outfnam == "")
             return;
         f->name = outfnam;
-        outfnam += "."+fmt;
+        outfnam += "." + fmt;
         // document file save
-        f->log_action( "fs " + outfnam + " # " + triv::time2strg( time(0) ) );
+        f->log_action("fs " + outfnam + " # " + triv::time2strg(time(0)));
         // prevent unintended overwriting
-        if( !allow_overwrite ){
-            FILE *file;
-            if ( (file = fopen(outfnam.c_str(), "r")) ) {
+        if (!allow_overwrite) {
+            FILE* file;
+            if ((file = fopen(outfnam.c_str(), "r"))) {
                 fclose(file);
-                throw "file "+outfnam+" exists, use fso to overwrite";
+                throw "file " + outfnam + " exists, use fso to overwrite";
             }
         }
         // save file
-        if( fmt=="yda"){
+        if (fmt == "yda") {
             std::ofstream ofs;
-            ofs.open( outfnam, std::ofstream::out );
-            save_yda( ofs, f );
+            ofs.open(outfnam, std::ofstream::out);
+            save_yda(ofs, f);
             ofs.close();
         } else {
-            FILE *file;
-            if ( !(file = fopen(outfnam.c_str(), "w")) )
+            FILE* file;
+            if (!(file = fopen(outfnam.c_str(), "w")))
                 throw "cannot write to file " + outfnam;
-            if( fmt=="y08" ) {
-                save_y08( file, f );
-            } else if( fmt=="csv" ) {
-                save_csv( file, f );
-            } else if( fmt=="tab" ) {
-                save_tab( file, f );
+            if (fmt == "y08") {
+                save_y08(file, f);
+            } else if (fmt == "csv") {
+                save_csv(file, f);
+            } else if (fmt == "tab") {
+                save_tab(file, f);
             } else
-                throw "BUG: Unknown format "+fmt;
+                throw "BUG: Unknown format " + fmt;
             fclose(file);
         }
         f->as_on_disk = true;
@@ -80,49 +81,46 @@ void NFileOut::save( string fmt, bool allow_overwrite )
 
 //! Writes a file in format y15.
 
-void NFileOut::save_yda( std::ofstream& ofs, const COlo *f )
+void NFileOut::save_yda(std::ofstream& ofs, const COlo* f)
 {
-    const COld *fd = dynamic_cast<const COld*>( f );
-    const COlc *fc = dynamic_cast<const COlc*>( f );
+    const COld* fd = dynamic_cast<const COld*>(f);
+    const COlc* fc = dynamic_cast<const COlc*>(f);
 
     YAML::Emitter out;
     out << YAML::BeginMap;
 
     out << YAML::Key << "Meta" << YAML::Value << YAML::BeginMap;
     out << YAML::Key << "format" << YAML::Value << "yaml/frida 2.0";
-    out << YAML::Key << "type" << YAML::Value << ( fd ? "generic tabular data" : "frida2 curve" );
+    out << YAML::Key << "type" << YAML::Value << (fd ? "generic tabular data" : "frida2 curve");
     out << YAML::EndMap;
 
     out << YAML::Key << "History" << YAML::Value << YAML::BeginSeq;
-    for ( string lin: f->lDoc )
+    for (string lin : f->lDoc)
         out << lin;
     out << YAML::EndSeq;
 
     out << YAML::Key << "Coord" << YAML::Value << YAML::BeginMap;
-    out << YAML::Key << "x" << YAML::Value << YAML::Flow << YAML::BeginMap <<
-        YAML::Key << "name" << YAML::Value << f->xco.name <<
-        YAML::Key << "unit" << YAML::Value << f->xco.unit << YAML::EndMap;
-    out << YAML::Key << "y" << YAML::Value << YAML::Flow << YAML::BeginMap <<
-        YAML::Key << "name" << YAML::Value << f->yco.name <<
-        YAML::Key << "unit" << YAML::Value << f->yco.unit << YAML::EndMap;
+    out << YAML::Key << "x" << YAML::Value << YAML::Flow << YAML::BeginMap << YAML::Key << "name"
+        << YAML::Value << f->xco.name << YAML::Key << "unit" << YAML::Value << f->xco.unit
+        << YAML::EndMap;
+    out << YAML::Key << "y" << YAML::Value << YAML::Flow << YAML::BeginMap << YAML::Key << "name"
+        << YAML::Value << f->yco.name << YAML::Key << "unit" << YAML::Value << f->yco.unit
+        << YAML::EndMap;
     out << YAML::Key << "z" << YAML::Value << YAML::Flow << YAML::BeginSeq;
-    for ( auto& zco: f->ZCo )
-        out << YAML::BeginMap <<
-            YAML::Key << "name" << YAML::Value << zco.name <<
-            YAML::Key << "unit" << YAML::Value << zco.unit << YAML::EndMap;
+    for (auto& zco : f->ZCo)
+        out << YAML::BeginMap << YAML::Key << "name" << YAML::Value << zco.name << YAML::Key
+            << "unit" << YAML::Value << zco.unit << YAML::EndMap;
     out << YAML::EndSeq;
     out << YAML::EndMap;
 
     out << YAML::Key << "RPar" << YAML::Value << YAML::BeginSeq;
-    for ( auto& rpar: f->RPar )
-        out << YAML::BeginMap <<
-            YAML::Key << "name" << YAML::Value << rpar.Co.name <<
-            YAML::Key << "unit" << YAML::Value << rpar.Co.unit <<
-            YAML::Key << "val" << YAML::Value << rpar.val <<
-            YAML::Key << "stdv" << YAML::Value << rpar.dval << YAML::EndMap;
+    for (auto& rpar : f->RPar)
+        out << YAML::BeginMap << YAML::Key << "name" << YAML::Value << rpar.Co.name << YAML::Key
+            << "unit" << YAML::Value << rpar.Co.unit << YAML::Key << "val" << YAML::Value
+            << rpar.val << YAML::Key << "stdv" << YAML::Value << rpar.dval << YAML::EndMap;
     out << YAML::EndSeq;
 
-    if( fc ) {
+    if (fc) {
         out << YAML::Key << "Curve" << YAML::Value << YAML::BeginMap;
         out << YAML::Key << "expr" << YAML::Value << fc->expr;
         out << YAML::Key << "nPar" << YAML::Value << fc->nP;
@@ -132,30 +130,30 @@ void NFileOut::save_yda( std::ofstream& ofs, const COlo *f )
     }
 
     out << YAML::Key << "Slices" << YAML::Value << YAML::BeginSeq;
-    for( size_t j=0; j<f->V.size(); ++j ) {
+    for (size_t j = 0; j < f->V.size(); ++j) {
         out << YAML::BeginMap;
         out << YAML::Key << "j" << YAML::Value << j;
-        const CSlice *s = f->V[j].get();
+        const CSlice* s = f->V[j].get();
         out << YAML::Key << "z" << YAML::Value << YAML::Flow << YAML::BeginSeq;
-        for( auto& z: s->z ) {
+        for (auto& z : s->z) {
             out << YAML::BeginMap;
-            if( auto pz = PCAST<const CObjNum>(z) ) {
+            if (auto pz = PCAST<const CObjNum>(z)) {
                 out << YAML::Key << "val" << YAML::Value << pz->to_r();
-                if( auto pdz = PCAST<const CObjEnu>(z) )
+                if (auto pdz = PCAST<const CObjEnu>(z))
                     out << YAML::Key << "stdv" << YAML::Value << pdz->to_dr();
             } else
                 out << YAML::Key << "string" << YAML::Value << z->to_s();
             out << YAML::EndMap;
         }
         out << YAML::EndSeq;
-        if   ( fd ) {
-            const CSpec *sd = fd->VS(j);
+        if (fd) {
+            const CSpec* sd = fd->VS(j);
             out << YAML::Key << "x" << YAML::Value << YAML::Flow << sd->x;
             out << YAML::Key << "y" << YAML::Value << YAML::Flow << sd->y;
-            if( sd->has_dy() )
+            if (sd->has_dy())
                 out << YAML::Key << "dy" << YAML::Value << YAML::Flow << sd->dy;
         } else {
-            const CCurve *sc = fc->VC(j);
+            const CCurve* sc = fc->VC(j);
             out << YAML::Key << "p" << YAML::Value << YAML::Flow << sc->P;
             out << YAML::Key << "attr" << YAML::Value << YAML::Flow << sc->ParAttr;
             out << YAML::Key << "fitOutcome" << YAML::Value << sc->fitOutcome;
@@ -170,72 +168,72 @@ void NFileOut::save_yda( std::ofstream& ofs, const COlo *f )
 
 //! Writes a file in format y08.
 
-void NFileOut::save_y08( FILE *file, const COlo *f )
+void NFileOut::save_y08(FILE* file, const COlo* f)
 {
-    const COld *fd = dynamic_cast<const COld*>( f );
-    const COlc *fc = dynamic_cast<const COlc*>( f );
-
-    fprintf( file, "Meta:\n"
-             "  format:  frida/y08 for yaml1\n"
-             "  type:    %s\n",
-             fd ? "generic tabular data" : "frida2 curve" );
-
-    fprintf( file, "History:\n" );
-    for ( string lin: f->lDoc )
-        fprintf( file, "- %s\n", triv::yaml(lin).c_str() );
-
-    fprintf( file, "Coord:\n" );
-    fprintf( file, "  x:\n    name: %s\n    unit: %s\n",
-             triv::yaml(f->xco.name).c_str(), triv::yaml(f->xco.unit).c_str() );
-    fprintf( file, "  y:\n    name: %s\n    unit: %s\n",
-             triv::yaml(f->yco.name).c_str(), triv::yaml(f->yco.unit).c_str() );
-    for ( int i=0; i<f->ZCo.size(); i++ )
-        fprintf( file, "  z%i:\n    name: %s\n    unit: %s\n",
-                 i, triv::yaml(f->ZCo[i].name).c_str(),
-                 triv::yaml(f->ZCo[i].unit).c_str() );
-
-    fprintf( file, "Param:\n" );
-    for ( int i=0; i<f->RPar.size(); i++ )
-        fprintf( file,
-                 "  -\n    name:  %s\n    unit:  %s\n    value: %20.15g\n",
-                 triv::yaml(f->RPar[i].Co.name).c_str(),
-                 triv::yaml(f->RPar[i].Co.unit).c_str(),
-                 f->RPar[i].val );
-
-    if( fc ) {
-        fprintf( file, "Formula: %s\n", fc->expr.c_str() );
+    const COld* fd = dynamic_cast<const COld*>(f);
+    const COlc* fc = dynamic_cast<const COlc*>(f);
+
+    fprintf(
+        file, "Meta:\n"
+              "  format:  frida/y08 for yaml1\n"
+              "  type:    %s\n",
+        fd ? "generic tabular data" : "frida2 curve");
+
+    fprintf(file, "History:\n");
+    for (string lin : f->lDoc)
+        fprintf(file, "- %s\n", triv::yaml(lin).c_str());
+
+    fprintf(file, "Coord:\n");
+    fprintf(
+        file, "  x:\n    name: %s\n    unit: %s\n", triv::yaml(f->xco.name).c_str(),
+        triv::yaml(f->xco.unit).c_str());
+    fprintf(
+        file, "  y:\n    name: %s\n    unit: %s\n", triv::yaml(f->yco.name).c_str(),
+        triv::yaml(f->yco.unit).c_str());
+    for (int i = 0; i < f->ZCo.size(); i++)
+        fprintf(
+            file, "  z%i:\n    name: %s\n    unit: %s\n", i, triv::yaml(f->ZCo[i].name).c_str(),
+            triv::yaml(f->ZCo[i].unit).c_str());
+
+    fprintf(file, "Param:\n");
+    for (int i = 0; i < f->RPar.size(); i++)
+        fprintf(
+            file, "  -\n    name:  %s\n    unit:  %s\n    value: %20.15g\n",
+            triv::yaml(f->RPar[i].Co.name).c_str(), triv::yaml(f->RPar[i].Co.unit).c_str(),
+            f->RPar[i].val);
+
+    if (fc) {
+        fprintf(file, "Formula: %s\n", fc->expr.c_str());
     }
 
-    fprintf( file, "Tables: # %i tables follow\n", f->nJ() );
+    fprintf(file, "Tables: # %i tables follow\n", f->nJ());
 
-    for( int j=0; j<f->nJ(); j++ ){
-        fprintf( file, "  - # table %i\n", j );
-        CSlice *s = f->V[j].get();
-        for ( int i=0; i<f->nZ(); i++ ) {
-            if( RObjNum pz = PCAST<const CObjNum>(s->z[i]) ) {
-                fprintf( file, "    z%i: %18.10g\n", i, pz->to_r() );
-                if( RObjNum pdz = PCAST<const CObjEnu>(s->z[i]) )
-                    fprintf( file, "    dz%i: %18.10g\n", i, pdz->to_dr() );
+    for (int j = 0; j < f->nJ(); j++) {
+        fprintf(file, "  - # table %i\n", j);
+        CSlice* s = f->V[j].get();
+        for (int i = 0; i < f->nZ(); i++) {
+            if (RObjNum pz = PCAST<const CObjNum>(s->z[i])) {
+                fprintf(file, "    z%i: %18.10g\n", i, pz->to_r());
+                if (RObjNum pdz = PCAST<const CObjEnu>(s->z[i]))
+                    fprintf(file, "    dz%i: %18.10g\n", i, pdz->to_dr());
             } else
-                fprintf( file, "    z%i: %s\n", i, s->z[i]->to_s().c_str() );
+                fprintf(file, "    z%i: %s\n", i, s->z[i]->to_s().c_str());
         }
-        if   ( fd ) {
-            const CSpec *s = fd->VS(j);
-            if( s->dy.size() ) {
-                fprintf( file, "    xyd: |2 # %i entries\n", (int)s->size() );
-                for( int i=0; i<s->size(); i++ )
-                    fprintf( file, "      %20.15g %20.15g %20.15g\n",
-                             s->x[i], s->y[i], s->dy[i] );
+        if (fd) {
+            const CSpec* s = fd->VS(j);
+            if (s->dy.size()) {
+                fprintf(file, "    xyd: |2 # %i entries\n", (int)s->size());
+                for (int i = 0; i < s->size(); i++)
+                    fprintf(file, "      %20.15g %20.15g %20.15g\n", s->x[i], s->y[i], s->dy[i]);
             } else {
-                fprintf( file, "    xy: |2 # %i entries\n", (int)s->size() );
-                for( int i=0; i<s->size(); i++ )
-                    fprintf( file, "      %20.15g %20.15g\n",
-                             s->x[i], s->y[i] );
+                fprintf(file, "    xy: |2 # %i entries\n", (int)s->size());
+                for (int i = 0; i < s->size(); i++)
+                    fprintf(file, "      %20.15g %20.15g\n", s->x[i], s->y[i]);
             }
         } else {
-            CCurve *s = fc->VC(j);
-            for ( int i=0; i<fc->nP; i++ )
-                fprintf( file, "    p%i: %18.10g\n", i, s->P[i] );
+            CCurve* s = fc->VC(j);
+            for (int i = 0; i < fc->nP; i++)
+                fprintf(file, "    p%i: %18.10g\n", i, s->P[i]);
         }
     }
 }
@@ -243,36 +241,37 @@ void NFileOut::save_y08( FILE *file, const COlo *f )
 
 //! Writes y as tab-separated table.
 
-void NFileOut::save_csv( FILE *file, const COlo *f )
+void NFileOut::save_csv(FILE* file, const COlo* f)
 {
-    const COld *fd = dynamic_cast<const COld*>( f );
-    if( !fd )
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd)
         throw S("csv save not implemented for non-data files");
-    for( int j=0; j<f->nJ(); j++ ){
-        for( int i=0; i<fd->VS(j)->size(); ++i ){
-            fprintf( file, "%g\t", fd->VS(j)->y[i] );
+    for (int j = 0; j < f->nJ(); j++) {
+        for (int i = 0; i < fd->VS(j)->size(); ++i) {
+            fprintf(file, "%g\t", fd->VS(j)->y[i]);
         }
-        fprintf( file, "\n" );
+        fprintf(file, "\n");
     }
 }
 
 
 //! Writes data as x-y columns with z header lines.
 
-void NFileOut::save_tab( FILE *file, const COlo *f )
+void NFileOut::save_tab(FILE* file, const COlo* f)
 {
-    const COld *fd = dynamic_cast<const COld*>( f );
-    if( !fd )
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd)
         throw S("tab save not implemented for non-data files");
-    for( int j=0; j<f->nJ(); j++ ){
-        for( int iz=0; iz<f->ZCo.size(); ++iz ){
-            if( iz>0 )  fprintf( file, "\t" );
-            fprintf( file, "%g", PCAST<const CObjNum>(fd->VS(j)->z[iz])->to_r() );
+    for (int j = 0; j < f->nJ(); j++) {
+        for (int iz = 0; iz < f->ZCo.size(); ++iz) {
+            if (iz > 0)
+                fprintf(file, "\t");
+            fprintf(file, "%g", PCAST<const CObjNum>(fd->VS(j)->z[iz])->to_r());
         }
-        fprintf( file, "\n" );
-        for( int i=0; i<fd->VS(j)->size(); ++i ){
-            fprintf( file, "%g\t%g\n", fd->VS(j)->x[i], fd->VS(j)->y[i] );
+        fprintf(file, "\n");
+        for (int i = 0; i < fd->VS(j)->size(); ++i) {
+            fprintf(file, "%g\t%g\n", fd->VS(j)->x[i], fd->VS(j)->y[i]);
         }
-        fprintf( file, "\n" );
+        fprintf(file, "\n");
     }
 }
diff --git a/pub/lib/file_out.hpp b/pub/lib/file_out.hpp
index 08a6322495666f86866fd7c2d6b410b2f19c67a6..e6377f8a438406228aef0fd07890dd6435fe6042 100644
--- a/pub/lib/file_out.hpp
+++ b/pub/lib/file_out.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                         
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-, this file 2009-               
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-, this file 2009-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  file_out.hpp
@@ -10,6 +10,7 @@
 
 //! Method to save files.
 
-namespace NFileOut {
-    void save( string fmt, bool allow_overwrite=false );
+namespace NFileOut
+{
+void save(string fmt, bool allow_overwrite = false);
 }
\ No newline at end of file
diff --git a/pub/lib/fit.cpp b/pub/lib/fit.cpp
index e676d812dc4eada7249eacf22b3abde946b5b745..492474808faeab85b525de9d21101a4bed11b23c 100644
--- a/pub/lib/fit.cpp
+++ b/pub/lib/fit.cpp
@@ -9,42 +9,43 @@
 
 #include "defs.hpp"
 
-#include <future>
 #include <boost/format.hpp>
+#include <future>
 #include <lmmin.h>
 
 #include "../readplus/ask.hpp"
 
-#include "olf.hpp"
-#include "mem.hpp"
+#include "fit.hpp"
 #include "fsel.hpp"
 #include "loop.hpp"
-#include "slice.hpp"
-#include "fit.hpp"
+#include "mem.hpp"
 #include "obj.hpp"
+#include "olf.hpp"
+#include "slice.hpp"
 
 using boost::format;
 
 bool allow_slow_conv = true;
 
-namespace NCurveFit {
-    string fit_one_spec( COlc *fc, const COld *fd, int k, int j, const lm_control_struct& control );
-    void fit_global( COlc *fc, const COld *fd, int k, const lm_control_struct& control );
+namespace NCurveFit
+{
+string fit_one_spec(COlc* fc, const COld* fd, int k, int j, const lm_control_struct& control);
+void fit_global(COlc* fc, const COld* fd, int k, const lm_control_struct& control);
 }
 
 void conditionally_parallel_for_with_report(
-    bool condition, int niter,
-    const std::function<string(int)>& exec, const std::function<void(const string&)>& report )
+    bool condition, int niter, const std::function<string(int)>& exec,
+    const std::function<void(const string&)>& report)
 {
-    if ( condition ) {
+    if (condition) {
         vector<std::future<string>> workers;
-        for ( int i=0; i<niter; ++i )
-            workers.push_back( std::async(std::launch::async, exec, i) );
-        for ( auto& w: workers )
-            report( w.get() );
+        for (int i = 0; i < niter; ++i)
+            workers.push_back(std::async(std::launch::async, exec, i));
+        for (auto& w : workers)
+            report(w.get());
     } else {
-        for ( int i=0; i<niter; ++i )
-            report( exec(i) );
+        for (int i = 0; i < niter; ++i)
+            report(exec(i));
     }
 }
 
@@ -53,36 +54,37 @@ void conditionally_parallel_for_with_report(
 //**************************************************************************************************
 
 
-namespace NCurveFit {
-    double Epsilon = 1.e-14;
-    double Factor=100.;
-    int nCall=200;
-    int verbosity=0;
-    double maxtime = 3;
+namespace NCurveFit
+{
+double Epsilon = 1.e-14;
+double Factor = 100.;
+int nCall = 200;
+int verbosity = 0;
+double maxtime = 3;
 }
 
 
 //! Set auxiliary parameters for the fit. Directly called from main program.
 
-void NCurveFit::set_fit_tuning_pars( string which )
+void NCurveFit::set_fit_tuning_pars(string which)
 {
-    if      ( which=="?" ) {
+    if (which == "?") {
         cout << "Fit setup:\n";
         cout << "  [csc] nCall = " << nCall << "\n";
         cout << "  [csv] Verbosity = " << verbosity << "\n";
         cout << "  [csf] Step bound factor = " << Factor << "\n";
         cout << "  [cse] Differentiation step epsilon = " << Epsilon << "\n";
         cout << "  [cst] Timeout = " << maxtime << "s\n";
-    } else if ( which=="v" )
-        verbosity = iask( "Verbosity (between 0 and 15, or'ed flags logic)", verbosity );
-    else if ( which=="c" )
-        nCall = iask( "Maximum number of Levenberg-Marquardt steps", nCall );
-    else if ( which=="f" )
-        Factor = dask( "Step bound factor (generally between 0.01 and 100)", Factor );
-    else if ( which=="e" )
-        Epsilon = dask( "Differentiation step epsilon", Epsilon );
-    else if ( which=="t" )
-        maxtime = dask( "Max duration of fits (in s)", maxtime );
+    } else if (which == "v")
+        verbosity = iask("Verbosity (between 0 and 15, or'ed flags logic)", verbosity);
+    else if (which == "c")
+        nCall = iask("Maximum number of Levenberg-Marquardt steps", nCall);
+    else if (which == "f")
+        Factor = dask("Step bound factor (generally between 0.01 and 100)", Factor);
+    else if (which == "e")
+        Epsilon = dask("Differentiation step epsilon", Epsilon);
+    else if (which == "t")
+        maxtime = dask("Max duration of fits (in s)", maxtime);
 }
 
 
@@ -93,54 +95,53 @@ void NCurveFit::set_fit_tuning_pars( string which )
 //! Returns zero when residues were computed sucessfully.
 
 static int compute_residues(
-    double* fvec, const int mdat, const int j, const CSpec *s, RObj& cu, const COlc::TWgt wt )
+    double* fvec, const int mdat, const int j, const CSpec* s, RObj& cu, const COlc::TWgt wt)
 {
     try {
         int n = s->size();
 
-        if ( ( wt==COlc::_VAR || wt==COlc::_VARD ) && s->dy.size()!=n )
+        if ((wt == COlc::_VAR || wt == COlc::_VARD) && s->dy.size() != n)
             throw S("missing data error bars for weighing");
 
-        for ( int i=0; i<n; i++) {
-            if( !std::isfinite(cu->to_r(i)) )
+        for (int i = 0; i < n; i++) {
+            if (!std::isfinite(cu->to_r(i)))
                 throw "infinite function value at x[" + S(i) + "]=" + S(s->x[i]);
 
-            if        ( wt==COlc::_LIN ) {
-                fvec[mdat+i] = s->y[i] - cu->to_r(i);
-            } else if ( wt==COlc::_LOG ) {
-                if ( s->y[i] < 1e-99 ) {
-                    throw "cannot weigh with log y: spectrum " +
-                        S(j) + " channel " + S(i) + " has y=" + S(s->y[i]);
-                } else if ( cu->to_r(i) < 1e-99 ) {
-                    fvec[mdat+i] = 99; // giant penalty
+            if (wt == COlc::_LIN) {
+                fvec[mdat + i] = s->y[i] - cu->to_r(i);
+            } else if (wt == COlc::_LOG) {
+                if (s->y[i] < 1e-99) {
+                    throw "cannot weigh with log y: spectrum " + S(j) + " channel " + S(i)
+                        + " has y=" + S(s->y[i]);
+                } else if (cu->to_r(i) < 1e-99) {
+                    fvec[mdat + i] = 99; // giant penalty
                 } else {
-                    fvec[mdat+i] = log( s->y[i] / cu->to_r(i) );
+                    fvec[mdat + i] = log(s->y[i] / cu->to_r(i));
                 }
-            } else if ( wt==COlc::_VAR || wt==COlc::_VARC || wt==COlc::_VARD ) {
+            } else if (wt == COlc::_VAR || wt == COlc::_VARC || wt == COlc::_VARD) {
                 double dr;
-                if     ( wt==COlc::_VAR )
-                    dr = sqrt( SQR(s->dy[i]) + SQR(cu->to_dr(i)) );
-                else if( wt==COlc::_VARC )
+                if (wt == COlc::_VAR)
+                    dr = sqrt(SQR(s->dy[i]) + SQR(cu->to_dr(i)));
+                else if (wt == COlc::_VARC)
                     dr = cu->to_dr(i);
-                else if( wt==COlc::_VARD )
+                else if (wt == COlc::_VARD)
                     dr = s->dy[i];
                 else
                     throw S("BUG: unforeseen case");
-                if ( dr < 1e-99 )
-                    throw "cannot weigh with dy: spectrum " + S(j) +
-                        " channel " + S(i) + " has y{len=" + S(s->y.size()) + "}=" + S(s->y[i]) +
-                        ", dy{len=" + S(s->dy.size()) + "}=" + S(s->dy[i]) +
-                        "; theory yields y=" + S(cu->to_r(i)) +
-                        ", dy=" + (cu->has_err() ? S(cu->to_dr(i)) : S("n/a"));
-                fvec[mdat+i] = ( s->y[i] - cu->to_r(i) ) / dr;
+                if (dr < 1e-99)
+                    throw "cannot weigh with dy: spectrum " + S(j) + " channel " + S(i)
+                        + " has y{len=" + S(s->y.size()) + "}=" + S(s->y[i]) + ", dy{len="
+                        + S(s->dy.size()) + "}=" + S(s->dy[i]) + "; theory yields y="
+                        + S(cu->to_r(i)) + ", dy=" + (cu->has_err() ? S(cu->to_dr(i)) : S("n/a"));
+                fvec[mdat + i] = (s->y[i] - cu->to_r(i)) / dr;
             }
         }
         return 0;
-    } catch ( string& s ) {
+    } catch (string& s) {
         cout << "\ncannot compute residues:\n" << s << "\n";
-    } catch ( const char* s ) {
+    } catch (const char* s) {
         cout << "\ncannot compute residues:\nBUG: ill-formatted exception:\n" << s << "\n";
-    } catch ( ... ) {
+    } catch (...) {
         cout << "cannot compute residues:\nBUG: invalid exception\n";
     }
     return 1;
@@ -154,8 +155,8 @@ static int compute_residues(
 //! Data transfer between frida and lm_minimize callback functions.
 
 typedef struct {
-    const COld *fd;
-    COlc *fc;
+    const COld* fd;
+    COlc* fc;
     int k;
     int j;
     double timeout;
@@ -164,8 +165,8 @@ typedef struct {
 
 //! Callback routine for use in lm_minimize: function evaluation.
 
-static void fit_evaluate( const double* par, int m_dat, const void *data,
-                          double* fvec, int *userbreak )
+static void
+fit_evaluate(const double* par, int m_dat, const void* data, double* fvec, int* userbreak)
 // arguments (required by lmmin):
 //    par       r/w  function parameters, to be optimized
 //    m_dat     r    number of data points
@@ -174,35 +175,35 @@ static void fit_evaluate( const double* par, int m_dat, const void *data,
 //    userbreak w    can be use to terminate the minimization
 {
     try {
-        FitDatTyp *mydata;
-        mydata = (FitDatTyp*) data;
-        if( mydata->timeout && time(nullptr) > mydata->timeout )
+        FitDatTyp* mydata;
+        mydata = (FitDatTyp*)data;
+        if (mydata->timeout && time(nullptr) > mydata->timeout)
             throw S("reached fit time out");
-        COlc *fc = mydata->fc;
-        const COld *fd = mydata->fd;
+        COlc* fc = mydata->fc;
+        const COld* fd = mydata->fd;
         COlc::TWgt wt = fc->weighing;
         CCurve* c = fc->VC(mydata->j);
 
         int ip = 0;
-        for( int i=0; i<fc->nP; ++i )
-            if ( fc->VC(mydata->j)->ParAttr[i]!='x' )
+        for (int i = 0; i < fc->nP; ++i)
+            if (fc->VC(mydata->j)->ParAttr[i] != 'x')
                 c->P[i] = par[ip++];
 
-        const CSpec *s = fd->VS(mydata->j);
-        bool want_error = wt==COlc::_VAR || wt==COlc::_VARC;
+        const CSpec* s = fd->VS(mydata->j);
+        bool want_error = wt == COlc::_VAR || wt == COlc::_VARC;
 
-        RObj cu = fc->eval_curve( s->x, mydata->k, mydata->j, want_error );
+        RObj cu = fc->eval_curve(s->x, mydata->k, mydata->j, want_error);
 
-        if( compute_residues( fvec, 0, mydata->j, s, cu, wt ) )
+        if (compute_residues(fvec, 0, mydata->j, s, cu, wt))
             *userbreak = -1;
 
-    } catch ( string& s ) {
+    } catch (string& s) {
         cout << "\n" << s << "\n";
         *userbreak = -1;
-    } catch ( const char* s ) {
+    } catch (const char* s) {
         cout << "\n" << s << "\n";
         *userbreak = -1;
-    } catch ( ... ) {
+    } catch (...) {
         cout << "BUG: fit_evaluate catched invalid exception\n";
         *userbreak = -1;
     }
@@ -211,13 +212,13 @@ static void fit_evaluate( const double* par, int m_dat, const void *data,
 
 //! Fits one spectrum. Used when there are no global parameters. Returns an info line.
 
-string NCurveFit::fit_one_spec( COlc *fc, const COld *fd, int k, int j,
-                                const lm_control_struct& control )
+string
+NCurveFit::fit_one_spec(COlc* fc, const COld* fd, int k, int j, const lm_control_struct& control)
 {
     try {
         CSpec* D = fd->VS(j);
         CCurve* C = fc->VC(j);
-        if ( C->frozen )
+        if (C->frozen)
             throw S("frozen, no fit");
         FitDatTyp data;
         data.fc = fc;
@@ -225,58 +226,59 @@ string NCurveFit::fit_one_spec( COlc *fc, const COld *fd, int k, int j,
         data.k = k;
         data.j = j;
         int nd = D->size();
-        if ( !nd )
+        if (!nd)
             throw "empty data set in spectrum " + S(j);
 
         // Transfer parameters from C->P to Par
         //   (lmmin modifies Par; fit_evaluate transfers values back from Par to C->P)
         int np = fc->nP;
         vector<double> Par;
-        for ( int ip=0; ip<np; ++ip )
-            if( C->ParAttr[ip]!='x' )
-                Par.push_back( C->P[ip] );
+        for (int ip = 0; ip < np; ++ip)
+            if (C->ParAttr[ip] != 'x')
+                Par.push_back(C->P[ip]);
         int npfree = Par.size();
-        if ( npfree<=0 )
+        if (npfree <= 0)
             throw S("no free parameters");
 
         // Levenberg-Marquardt routine from library lmfit:
 
-        data.timeout = time(nullptr) + std::thread::hardware_concurrency()*maxtime;
+        data.timeout = time(nullptr) + std::thread::hardware_concurrency() * maxtime;
 
         lm_status_struct status;
-        lmmin( npfree, &(Par[0]), nd, &data, fit_evaluate, &control, &status );
+        lmmin(npfree, &(Par[0]), nd, &data, fit_evaluate, &control, &status);
 
-        if( status.outcome==11 )
+        if (status.outcome == 11)
             throw S("exception in fit function");
 
         // Fit quality metrics Q:
 
-        C->fitOutcome = (double) status.outcome;
+        C->fitOutcome = (double)status.outcome;
 
         // coefficient of determination R^2 (for linear regression)
         double ysum1 = 0, ysum2 = 0;
-        for( int i=0; i<nd; ++i ){
+        for (int i = 0; i < nd; ++i) {
             ysum1 += D->y[i];
-            ysum2 += SQR( D->y[i] );
+            ysum2 += SQR(D->y[i]);
         }
-        double ydev2 = ysum2 - SQR( ysum1 )/nd; // = nd * <(y-<y>)^2>
-        C->fitR2 = ydev2!=0 ? 1 - SQR(status.fnorm) / ydev2 : -1;
+        double ydev2 = ysum2 - SQR(ysum1) / nd; // = nd * <(y-<y>)^2>
+        C->fitR2 = ydev2 != 0 ? 1 - SQR(status.fnorm) / ydev2 : -1;
 
         // mean deviation (chi^2 if fvec is weighed with 1/dy)
         int nfreedom = nd - npfree - 1;
-        if( nfreedom<1 ) nfreedom = 1;
+        if (nfreedom < 1)
+            nfreedom = 1;
         C->fitChi2 = SQR(status.fnorm) / nfreedom;
 
-        string out = str( format( "%3i%3i" ) % k % j );
-        for ( int i=0; i<npfree; i++ )
-            out += str( format(" %12g" ) % Par[i] );
-        out += str( format(" (%3i->%9.7g)" ) % status.nfev % C->fitChi2 );
+        string out = str(format("%3i%3i") % k % j);
+        for (int i = 0; i < npfree; i++)
+            out += str(format(" %12g") % Par[i]);
+        out += str(format(" (%3i->%9.7g)") % status.nfev % C->fitChi2);
         out += lm_shortmsg[status.outcome];
         return out;
     } catch (string& e) {
-        return str( format( "%3i%3i failed: %s" ) % k % j % e );
+        return str(format("%3i%3i failed: %s") % k % j % e);
     } catch (...) {
-        return str( format( "%3i%3i failed with unexpected exception type" ) % k % j );
+        return str(format("%3i%3i failed with unexpected exception type") % k % j);
     }
 }
 
@@ -288,8 +290,8 @@ string NCurveFit::fit_one_spec( COlc *fc, const COld *fd, int k, int j,
 //! Data transfer between frida and lm_minimize callback functions.
 
 typedef struct {
-    const COld *fd;
-    COlc *fc;
+    const COld* fd;
+    COlc* fc;
     vector<int> J2J;
     vector<int> Offset;
     int k;
@@ -300,8 +302,8 @@ typedef struct {
 
 //! Callback routine for use in lm_minimize: function evaluation.
 
-static void fit_evaluate_glo( const double* par, int m_dat, const void *data,
-                              double* fvec, int *userbreak )
+static void
+fit_evaluate_glo(const double* par, int m_dat, const void* data, double* fvec, int* userbreak)
 // arguments (required by lmmin):
 //    par       r/w  function parameters, to be optimized
 //    m_dat     r    number of data points
@@ -310,70 +312,68 @@ static void fit_evaluate_glo( const double* par, int m_dat, const void *data,
 //    userbreak w    can be use to terminate the minimization
 {
     try {
-        FitGloDatTyp* mydata = (FitGloDatTyp*) data;
-        if( mydata->timeout && time(nullptr) > mydata->timeout )
+        FitGloDatTyp* mydata = (FitGloDatTyp*)data;
+        if (mydata->timeout && time(nullptr) > mydata->timeout)
             throw S("reached fit time out");
-        COlc *fc = mydata->fc;
-        const COld *fd = mydata->fd;
+        COlc* fc = mydata->fc;
+        const COld* fd = mydata->fd;
         COlc::TWgt wt = fc->weighing;
 
         int npar = 0;
-        for( int ip=0; ip<fc->nP; ++ip ) {
-            if ( fc->VC(mydata->J2J[0])->ParAttr[ip]=='g' ) {
-                for( int j: mydata->J2J )
+        for (int ip = 0; ip < fc->nP; ++ip) {
+            if (fc->VC(mydata->J2J[0])->ParAttr[ip] == 'g') {
+                for (int j : mydata->J2J)
                     fc->VC(j)->P[ip] = par[npar];
                 npar++;
             } else {
-                for( int j: mydata->J2J )
-                    if ( fc->VC(j)->ParAttr[ip]=='u' )
+                for (int j : mydata->J2J)
+                    if (fc->VC(j)->ParAttr[ip] == 'u')
                         fc->VC(j)->P[ip] = par[npar++];
             }
         }
-        if ( npar != mydata->npfree )
+        if (npar != mydata->npfree)
             throw S("inconsistent number of free parameters");
 
-        bool want_error = wt==COlc::_VAR || wt==COlc::_VARC;
-        if ( !NCurveFit::verbosity && mydata->J2J.size()>1 ) {
+        bool want_error = wt == COlc::_VAR || wt == COlc::_VARC;
+        if (!NCurveFit::verbosity && mydata->J2J.size() > 1) {
             vector<std::future<int>> workers;
-            for ( int jj=0; jj<mydata->J2J.size(); ++jj ) {
-                workers.push_back(
-                    std::async(
-                        std::launch::async,
-                        [&](int _jj) -> int
-                        {
-                            RObj cu = fc->eval_curve( fd->VS(mydata->J2J[_jj])->x,
-                                                      mydata->k, mydata->J2J[_jj], want_error );
-                            return compute_residues(
-                                fvec, mydata->Offset[_jj], mydata->J2J[_jj],
-                                fd->VS(mydata->J2J[_jj]), cu, wt );
-                        }, jj
-                        )
-                    );
+            for (int jj = 0; jj < mydata->J2J.size(); ++jj) {
+                workers.push_back(std::async(
+                    std::launch::async,
+                    [&](int _jj) -> int {
+                        RObj cu = fc->eval_curve(
+                            fd->VS(mydata->J2J[_jj])->x, mydata->k, mydata->J2J[_jj], want_error);
+                        return compute_residues(
+                            fvec, mydata->Offset[_jj], mydata->J2J[_jj], fd->VS(mydata->J2J[_jj]),
+                            cu, wt);
+                    },
+                    jj));
             }
-            for ( auto& w: workers ) {
-                if( w.get() ) {
+            for (auto& w : workers) {
+                if (w.get()) {
                     *userbreak = -1;
                     return;
                 }
             }
         } else {
-            for ( int jj=0; jj<mydata->J2J.size(); ++jj ) {
-                RObj cu = fc->eval_curve( fd->VS(mydata->J2J[jj])->x,
-                                          mydata->k, mydata->J2J[jj], want_error );
-                if ( compute_residues( fvec, mydata->Offset[jj], mydata->J2J[jj],
-                                       fd->VS(mydata->J2J[jj]), cu, wt ) ) {
+            for (int jj = 0; jj < mydata->J2J.size(); ++jj) {
+                RObj cu = fc->eval_curve(
+                    fd->VS(mydata->J2J[jj])->x, mydata->k, mydata->J2J[jj], want_error);
+                if (compute_residues(
+                        fvec, mydata->Offset[jj], mydata->J2J[jj], fd->VS(mydata->J2J[jj]), cu,
+                        wt)) {
                     *userbreak = -1;
                     return;
                 }
             }
         }
-    } catch ( string& s ) {
+    } catch (string& s) {
         cout << "\n" << s << "\n";
         *userbreak = -1;
-    } catch ( const char* s ) {
+    } catch (const char* s) {
         cout << "\n" << s << "\n";
         *userbreak = -1;
-    } catch ( ... ) {
+    } catch (...) {
         cout << "BUG: fitEvaluate catched invalid exception\n";
         *userbreak = -1;
     }
@@ -382,7 +382,7 @@ static void fit_evaluate_glo( const double* par, int m_dat, const void *data,
 
 //! Fits all spectra simultaneously. Used when there are global parameters.
 
-void NCurveFit::fit_global( COlc *fc, const COld *fd, int k, const lm_control_struct& control )
+void NCurveFit::fit_global(COlc* fc, const COld* fd, int k, const lm_control_struct& control)
 {
     FitGloDatTyp data;
     data.fc = fc;
@@ -390,106 +390,106 @@ void NCurveFit::fit_global( COlc *fc, const COld *fd, int k, const lm_control_st
     data.k = k;
 
     // Set vector J2J to contain indices of non-frozen curves.
-    for( int j=0; j<fc->nJ(); ++j )
-        if ( !fc->VC(j)->frozen )
+    for (int j = 0; j < fc->nJ(); ++j)
+        if (!fc->VC(j)->frozen)
             data.J2J.push_back(j);
-    if ( !data.J2J.size() )
+    if (!data.J2J.size())
         throw S("all curves are frozen");
     int njj = data.J2J.size();
 
     // Set vector Par to contain all free fit parameters.
     int np = fc->nP;
     vector<double> Par;
-    for ( int ip=0; ip<np; ++ip ) {
+    for (int ip = 0; ip < np; ++ip) {
         int j0 = data.J2J[0];
-        for( int jj=1; jj<njj; ++jj ) {
+        for (int jj = 1; jj < njj; ++jj) {
             int j = data.J2J[jj];
-            if( (fc->VC(j0)->ParAttr[ip]=='g') ^ (fc->VC(j)->ParAttr[ip]=='g') )
+            if ((fc->VC(j0)->ParAttr[ip] == 'g') ^ (fc->VC(j)->ParAttr[ip] == 'g'))
                 throw S("Global attribute must be uniform for all non-frozen spectra");
         }
-        if ( fc->VC(j0)->ParAttr[ip]=='g' ) {
-            Par.push_back( fc->VC(j0)->P[ip] );
+        if (fc->VC(j0)->ParAttr[ip] == 'g') {
+            Par.push_back(fc->VC(j0)->P[ip]);
         } else {
-            for( int j: data.J2J )
-                if ( fc->VC(j)->ParAttr[ip]=='u' )
-                    Par.push_back( fc->VC(j)->P[ip] );
+            for (int j : data.J2J)
+                if (fc->VC(j)->ParAttr[ip] == 'u')
+                    Par.push_back(fc->VC(j)->P[ip]);
         }
     }
     int npfree = Par.size();
-    if ( npfree<=0 )
+    if (npfree <= 0)
         return;
     data.npfree = npfree;
 
     int nd = 0;
-    for( int j: data.J2J ) {
-        data.Offset.push_back( nd );
+    for (int j : data.J2J) {
+        data.Offset.push_back(nd);
         nd += fd->VS(j)->size();
     }
 
     // Levenberg-Marquardt routine from library lmfit:
 
-    data.timeout = time(nullptr) + fc->nJ()*maxtime;
+    data.timeout = time(nullptr) + fc->nJ() * maxtime;
 
     lm_status_struct status;
-    lmmin( npfree, &(Par[0]), nd, &data, fit_evaluate_glo, &control, &status );
+    lmmin(npfree, &(Par[0]), nd, &data, fit_evaluate_glo, &control, &status);
 
-    if( status.outcome==11 )
+    if (status.outcome == 11)
         throw S("exception in fit function");
 
     COlc::TWgt wt = fc->weighing;
-    bool want_error = wt==COlc::_VAR || wt==COlc::_VARC;
+    bool want_error = wt == COlc::_VAR || wt == COlc::_VARC;
 
-    int nfreedom = std::max( 1, nd - npfree - 1 );
+    int nfreedom = std::max(1, nd - npfree - 1);
     fc->chi2 = SQR(status.fnorm) / nfreedom;
-    cout << str( format( "%3i global fit result: chi^2=%14.7g\n" ) % k % fc->chi2 );
+    cout << str(format("%3i global fit result: chi^2=%14.7g\n") % k % fc->chi2);
 
-    for( int j: data.J2J ) {
-        fc->VC(j)->fitOutcome = (double) status.outcome;
+    for (int j : data.J2J) {
+        fc->VC(j)->fitOutcome = (double)status.outcome;
 
         // compute deviation per spectrum:
-        const CSpec *s = fd->VS(j);
-        RObj cu = fc->eval_curve( s->x, k, j, want_error );
+        const CSpec* s = fd->VS(j);
+        RObj cu = fc->eval_curve(s->x, k, j, want_error);
         int n = s->size();
-        double *fvec = (double*) malloc( n*sizeof(double) );
-        compute_residues( fvec, 0, j, s, cu, wt );
-        double fnorm = lm_enorm( n, fvec );
-        free( fvec );
+        double* fvec = (double*)malloc(n * sizeof(double));
+        compute_residues(fvec, 0, j, s, cu, wt);
+        double fnorm = lm_enorm(n, fvec);
+        free(fvec);
 
         // coefficient of determination R^2 (for linear regression)
         double ysum1 = 0, ysum2 = 0;
-        for( int i=0; i<n; ++i ){
+        for (int i = 0; i < n; ++i) {
             double y = fd->VS(j)->y[i];
             ysum1 += y;
-            ysum2 += SQR( y );
+            ysum2 += SQR(y);
         }
-        double ydev2 = ysum2 - SQR( ysum1 )/n;
-        fc->VC(j)->fitR2 = ydev2!=0 ? 1 - SQR(fnorm) / ydev2 : -1;
+        double ydev2 = ysum2 - SQR(ysum1) / n;
+        fc->VC(j)->fitR2 = ydev2 != 0 ? 1 - SQR(fnorm) / ydev2 : -1;
 
         // mean deviation (chi^2 if fvec is weighed with 1/dy)
         double xpfree = 0;
-        for ( int ip=0; ip<np; ++ip ) {
-             if      ( fc->VC(j)->ParAttr[ip]=='u' )
-                 xpfree += 1;
-             else if ( fc->VC(j)->ParAttr[ip]=='g' )
-                 xpfree += 1.0/fc->nJ();
+        for (int ip = 0; ip < np; ++ip) {
+            if (fc->VC(j)->ParAttr[ip] == 'u')
+                xpfree += 1;
+            else if (fc->VC(j)->ParAttr[ip] == 'g')
+                xpfree += 1.0 / fc->nJ();
         }
-        double xfreedom = std::max( 1.0, fd->VS(j)->size() - xpfree - 1 );
+        double xfreedom = std::max(1.0, fd->VS(j)->size() - xpfree - 1);
         fc->VC(j)->fitChi2 = SQR(fnorm) / xfreedom;
     }
 
     // print results:
-    for( int jj=0; jj<njj; ++jj ) {
+    for (int jj = 0; jj < njj; ++jj) {
         int j = data.J2J[jj];
-        printf( "%3i%3i", k, j );
-        for ( int ip=0; ip<np; ip++ ) {
-            if ( fc->VC(j)->ParAttr[ip]=='x' )
+        printf("%3i%3i", k, j);
+        for (int ip = 0; ip < np; ip++) {
+            if (fc->VC(j)->ParAttr[ip] == 'x')
                 continue;
-            printf( " %12g", fc->VC(j)->P[ip] );
-            if ( fc->VC(j)->ParAttr[ip]!='u' )
-                printf( "%c", fc->VC(j)->ParAttr[ip] );
+            printf(" %12g", fc->VC(j)->P[ip]);
+            if (fc->VC(j)->ParAttr[ip] != 'u')
+                printf("%c", fc->VC(j)->ParAttr[ip]);
         }
-        printf( " (%3i->%9.7g)", status.nfev, fc->VC(j)->fitChi2 );
-        printf( "%s\n", lm_shortmsg[ status.outcome ] );
+        printf(" (%3i->%9.7g)", status.nfev, fc->VC(j)->fitChi2);
+        printf("%s\n", lm_shortmsg[status.outcome]);
     }
 }
 
@@ -500,28 +500,29 @@ void NCurveFit::fit_global( COlc *fc, const COld *fd, int k, const lm_control_st
 
 //! Fits selected curve files to the data files they refer to.
 
-void NCurveFit::fit( bool _allow_slow_conv )
+void NCurveFit::fit(bool _allow_slow_conv)
 {
-    lm_control_struct control = lm_control_double;;
+    lm_control_struct control = lm_control_double;
+    ;
     allow_slow_conv = _allow_slow_conv;
 
     FileIterator fiter(SFSel::instance()->selC());
 
-    while ( COlc *fc = fiter.nextC() ) {
+    while (COlc* fc = fiter.nextC()) {
 
         // assert validity of parameter attributes
-        for( int j=0; j<fc->nJ(); ++j )
+        for (int j = 0; j < fc->nJ(); ++j)
             fc->VC(j)->assert_attr();
 
-        const COld *fd = SMem::instance()->mem_get_D(fc->kd);
-        if ( fc->nJ() != fd->nJ() )
+        const COld* fd = SMem::instance()->mem_get_D(fc->kd);
+        if (fc->nJ() != fd->nJ())
             throw S("data file and curve file have different number of spectra");
-        if ( !fc->nJ() )
+        if (!fc->nJ())
             throw S("BUG: empty curve and data file");
-        if ( ( fc->weighing==COlc::_VAR || fc->weighing==COlc::_VARD ) && !fd->VS(0)->has_dy() )
+        if ((fc->weighing == COlc::_VAR || fc->weighing == COlc::_VARD) && !fd->VS(0)->has_dy())
             throw S("Data have no error bars, cannot apply chosen fit weights");
 
-        if( fc->range_T ) {
+        if (fc->range_T) {
             throw S("TODO: restore range evaluation");
             /*
             // overwrite fd with data that obye the range restriction:
@@ -552,20 +553,20 @@ void NCurveFit::fit( bool _allow_slow_conv )
         control.patience = nCall;
         control.verbosity = verbosity;
 
-        if ( fc->has_global_par() ) {
-            fit_global( fc, fd, fiter.k(), control );
+        if (fc->has_global_par()) {
+            fit_global(fc, fd, fiter.k(), control);
         } else {
             fc->chi2 = 0;
             vector<int> J;
-            for ( int j=0; j<fc->nJ(); j++ )
-                if ( !fc->VC(j)->frozen )
-                    J.push_back( j );
+            for (int j = 0; j < fc->nJ(); j++)
+                if (!fc->VC(j)->frozen)
+                    J.push_back(j);
             conditionally_parallel_for_with_report(
                 !NCurveFit::verbosity, J.size(),
                 [&](int _jj) -> string {
-                    return fit_one_spec( fc, fd, fiter.k(), J[_jj], control ) + "\n"; },
-                [&](const string& msg) -> void {
-                    cout << msg; } );
+                    return fit_one_spec(fc, fd, fiter.k(), J[_jj], control) + "\n";
+                },
+                [&](const string& msg) -> void { cout << msg; });
         } // fit mode
     } // k
 }
diff --git a/pub/lib/fit.hpp b/pub/lib/fit.hpp
index 2abca300c81742b3c50f33675d5cdb0d15316d32..9c1ccd9fd4ff874e6631347821a9602910123d70 100644
--- a/pub/lib/fit.hpp
+++ b/pub/lib/fit.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                          
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                 
-//*  http://apps.jcns.fz-juelich.de/frida                                    
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  fit.hpp
@@ -10,7 +10,8 @@
 
 //! Methods related to fitting.
 
-namespace NCurveFit {
-    void set_fit_tuning_pars( string which );
-    void fit( bool _allow_slow_conv );
+namespace NCurveFit
+{
+void set_fit_tuning_pars(string which);
+void fit(bool _allow_slow_conv);
 }
diff --git a/pub/lib/fregistry.cpp b/pub/lib/fregistry.cpp
index 1c6f2d28753abccd4c752c5a4dee081267382e28..d3f46e5e2ecaff8e3ac2f17f7bebbe6c1c3b9420 100644
--- a/pub/lib/fregistry.cpp
+++ b/pub/lib/fregistry.cpp
@@ -10,8 +10,8 @@
 #include "defs.hpp"
 
 
-#include "func.hpp"
 #include "fregistry.hpp"
+#include "func.hpp"
 
 
 //! Prints a list of registered operators, for online help.
@@ -19,8 +19,8 @@
 void SFuncRegistry::display_operators() const
 {
     cout << "Operators by precedence:\n";
-    for( auto f: FList ){
-        if( !f->precedence )
+    for (auto f : FList) {
+        if (!f->precedence)
             continue;
         cout << "  " << f->explanation << "\n";
     }
@@ -32,8 +32,8 @@ void SFuncRegistry::display_operators() const
 void SFuncRegistry::display_functions() const
 {
     cout << "\nBuilt-in functions:\n";
-    for( auto f: FList ){
-        if( f->precedence )
+    for (auto f : FList) {
+        if (f->precedence)
             continue;
         cout << "  " << f->tag << f->explanation << "\n";
     }
@@ -44,15 +44,15 @@ void SFuncRegistry::display_functions() const
 //! The function name must have been previously registered using register_fct_meta.
 
 void SFuncRegistry::register_fct_template(
-    const CFuncMetadata& _m, const char* _outtype, const char* _intypes, funcPtr _f )
+    const CFuncMetadata& _m, const char* _outtype, const char* _intypes, funcPtr _f)
 {
     auto pos = FMap.find(_m.tag);
     CFunc* F;
-    if( pos == FMap.end() ) {
-        F = new CFunc( _m );
-        FMap.insert( std::make_pair( _m.tag, F ) );
-        FList.push_back( F );
+    if (pos == FMap.end()) {
+        F = new CFunc(_m);
+        FMap.insert(std::make_pair(_m.tag, F));
+        FList.push_back(F);
     } else
         F = pos->second;
-    F->tyfuList.push_back( new CTypedFunc( _outtype, _intypes, _f ) );
+    F->tyfuList.push_back(new CTypedFunc(_outtype, _intypes, _f));
 }
diff --git a/pub/lib/fregistry.hpp b/pub/lib/fregistry.hpp
index d77c748a4ea94cfc50741caea5b53d246f455c7f..4b06d44078e1ff530ca2280c6ecb1748e3a06579 100644
--- a/pub/lib/fregistry.hpp
+++ b/pub/lib/fregistry.hpp
@@ -10,131 +10,186 @@
 #include "registry.hpp"
 
 //  Low-level function types.
-typedef void   (*func_0_i) (int);
-typedef void   (*func_0_d) (double);
-typedef void   (*func_0_s) (string);
-
-typedef int    (*func_i_i) (int);
-typedef int    (*func_i_d) (double);
-typedef int    (*func_i_s) (string);
-typedef double (*func_d_i) (int);
-typedef double (*func_d_d) (double);
-typedef double (*func_d_s) (string);
-typedef void   (*func_e_e) (double&,double&, double,double);
-typedef string (*func_s_s) (string);
-
-typedef int    (*func_i_ii) (int, int);
-typedef int    (*func_i_id) (int, double);
-typedef int    (*func_i_is) (int, string);
-typedef int    (*func_i_di) (double, int);
-typedef int    (*func_i_dd) (double, double);
-typedef int    (*func_i_si) (string, int);
-typedef double (*func_d_ii) (int, int);
-typedef double (*func_d_id) (int, double);
-typedef double (*func_d_di) (double, int);
-typedef double (*func_d_dd) (double, double);
-typedef double (*func_d_sd) (string, double);
-typedef void   (*func_e_dd) (double&,double&, double, double);
-typedef void   (*func_e_ee) (double&,double&, double,double, double,double);
-typedef void   (*func_e_se) (double&,double&, string, double,double);
-typedef string (*func_s_si) (string, int);
-typedef string (*func_s_ss) (string, string);
-
-typedef int    (*func_i_iii) (int, int, int);
-typedef double (*func_d_ddd) (double, double, double);
-typedef void   (*func_e_eee) (double&,double&, double,double, double,double, double,double);
+typedef void (*func_0_i)(int);
+typedef void (*func_0_d)(double);
+typedef void (*func_0_s)(string);
+
+typedef int (*func_i_i)(int);
+typedef int (*func_i_d)(double);
+typedef int (*func_i_s)(string);
+typedef double (*func_d_i)(int);
+typedef double (*func_d_d)(double);
+typedef double (*func_d_s)(string);
+typedef void (*func_e_e)(double&, double&, double, double);
+typedef string (*func_s_s)(string);
+
+typedef int (*func_i_ii)(int, int);
+typedef int (*func_i_id)(int, double);
+typedef int (*func_i_is)(int, string);
+typedef int (*func_i_di)(double, int);
+typedef int (*func_i_dd)(double, double);
+typedef int (*func_i_si)(string, int);
+typedef double (*func_d_ii)(int, int);
+typedef double (*func_d_id)(int, double);
+typedef double (*func_d_di)(double, int);
+typedef double (*func_d_dd)(double, double);
+typedef double (*func_d_sd)(string, double);
+typedef void (*func_e_dd)(double&, double&, double, double);
+typedef void (*func_e_ee)(double&, double&, double, double, double, double);
+typedef void (*func_e_se)(double&, double&, string, double, double);
+typedef string (*func_s_si)(string, int);
+typedef string (*func_s_ss)(string, string);
+
+typedef int (*func_i_iii)(int, int, int);
+typedef double (*func_d_ddd)(double, double, double);
+typedef void (*func_e_eee)(double&, double&, double, double, double, double, double, double);
 
 
 //! A singleton class, holding a collection of CFunc's.
 
-class SFuncRegistry : public IRegistryTmp<CFunc>, public triv::ISingleton<SFuncRegistry> {
- private:
+class SFuncRegistry : public IRegistryTmp<CFunc>, public triv::ISingleton<SFuncRegistry>
+{
+private:
     virtual string type_name() const { return "operator and function"; }
     void register_fct_template(
-        const CFuncMetadata& _m, const char* _outtype, const char* _intypes, funcPtr _f );
+        const CFuncMetadata& _m, const char* _outtype, const char* _intypes, funcPtr _f);
 
- public:
+public:
     void display_functions() const;
     void display_operators() const;
 
-    void register_fct_0_i( const CFuncMetadata& _m, func_0_i _f )
-        { register_fct_template( _m, "0", "i", (funcPtr)_f ); }
-
-    void register_fct_0_d( const CFuncMetadata& _m, func_0_d _f )
-        { register_fct_template( _m, "0", "d", (funcPtr)_f ); }
-
-    void register_fct_0_s( const CFuncMetadata& _m, func_0_s _f )
-        {    register_fct_template( _m, "0", "s", (funcPtr)_f ); }
-
-    void register_fct_i_i( const CFuncMetadata& _m, func_i_i _f )
-        { register_fct_template( _m, "i", "i", (funcPtr)_f ); }
-
-    void register_fct_i_d( const CFuncMetadata& _m, func_i_d _f )
-        { register_fct_template( _m, "i", "d", (funcPtr)_f ); }
-
-    void register_fct_i_s( const CFuncMetadata& _m, func_i_s _f )
-        { register_fct_template( _m, "i", "s", (funcPtr)_f ); }
-
-    void register_fct_d_i( const CFuncMetadata& _m, func_d_i _f )
-        { register_fct_template( _m, "d", "i", (funcPtr)_f ); }
-
-    void register_fct_d_d( const CFuncMetadata& _m, func_d_d _f )
-        { register_fct_template( _m, "d", "d", (funcPtr)_f ); }
-
-    void register_fct_d_s( const CFuncMetadata& _m, func_d_s _f )
-        { register_fct_template( _m, "d", "s", (funcPtr)_f ); }
-
-    void register_fct_e_e( const CFuncMetadata& _m, func_e_e _f )
-        { register_fct_template( _m, "e", "e", (funcPtr)_f ); }
-
-    void register_fct_i_ii( const CFuncMetadata& _m, func_i_ii _f )
-        { register_fct_template( _m, "i", "ii", (funcPtr)_f ); }
-
-    void register_fct_i_id( const CFuncMetadata& _m, func_i_id _f )
-        { register_fct_template( _m, "i", "id", (funcPtr)_f ); }
-
-    void register_fct_i_is( const CFuncMetadata& _m, func_i_is _f )
-        { register_fct_template( _m, "i", "is", (funcPtr)_f ); }
-
-    void register_fct_i_di( const CFuncMetadata& _m, func_i_di _f )
-        { register_fct_template( _m, "i", "di", (funcPtr)_f ); }
-
-    void register_fct_i_dd( const CFuncMetadata& _m, func_i_dd _f )
-        { register_fct_template( _m, "i", "dd", (funcPtr)_f ); }
-
-    void register_fct_i_si( const CFuncMetadata& _m, func_i_si _f )
-        { register_fct_template( _m, "i", "si", (funcPtr)_f ); }
-
-    void register_fct_d_ii( const CFuncMetadata& _m, func_d_ii _f )
-        { register_fct_template( _m, "d", "ii", (funcPtr)_f ); }
-
-    void register_fct_d_dd( const CFuncMetadata& _m, func_d_dd _f )
-        { register_fct_template( _m, "d", "dd", (funcPtr)_f ); }
-
-    void register_fct_d_sd( const CFuncMetadata& _m, func_d_sd _f )
-        { register_fct_template( _m, "d", "sd", (funcPtr)_f ); }
-
-    void register_fct_e_dd( const CFuncMetadata& _m, func_e_dd _f )
-        { register_fct_template( _m, "e", "dd", (funcPtr)_f ); }
-
-    void register_fct_e_ee( const CFuncMetadata& _m, func_e_ee _f )
-        { register_fct_template( _m, "e", "ee", (funcPtr)_f ); }
-
-    void register_fct_e_se( const CFuncMetadata& _m, func_e_se _f )
-        { register_fct_template( _m, "e", "se", (funcPtr)_f ); }
-
-    void register_fct_s_si( const CFuncMetadata& _m, func_s_si _f )
-        { register_fct_template( _m, "s", "si", (funcPtr)_f ); }
-
-    void register_fct_s_ss( const CFuncMetadata& _m, func_s_ss _f )
-        { register_fct_template( _m, "s", "ss", (funcPtr)_f ); }
-
-    void register_fct_i_iii( const CFuncMetadata& _m, func_i_iii _f )
-        { register_fct_template( _m, "i", "iii", (funcPtr)_f ); }
-
-    void register_fct_d_ddd( const CFuncMetadata& _m, func_d_ddd _f )
-        { register_fct_template( _m, "d", "ddd", (funcPtr)_f ); }
-
-    void register_fct_e_eee( const CFuncMetadata& _m, func_e_eee _f )
-        { register_fct_template( _m, "e", "eee", (funcPtr)_f ); }
+    void register_fct_0_i(const CFuncMetadata& _m, func_0_i _f)
+    {
+        register_fct_template(_m, "0", "i", (funcPtr)_f);
+    }
+
+    void register_fct_0_d(const CFuncMetadata& _m, func_0_d _f)
+    {
+        register_fct_template(_m, "0", "d", (funcPtr)_f);
+    }
+
+    void register_fct_0_s(const CFuncMetadata& _m, func_0_s _f)
+    {
+        register_fct_template(_m, "0", "s", (funcPtr)_f);
+    }
+
+    void register_fct_i_i(const CFuncMetadata& _m, func_i_i _f)
+    {
+        register_fct_template(_m, "i", "i", (funcPtr)_f);
+    }
+
+    void register_fct_i_d(const CFuncMetadata& _m, func_i_d _f)
+    {
+        register_fct_template(_m, "i", "d", (funcPtr)_f);
+    }
+
+    void register_fct_i_s(const CFuncMetadata& _m, func_i_s _f)
+    {
+        register_fct_template(_m, "i", "s", (funcPtr)_f);
+    }
+
+    void register_fct_d_i(const CFuncMetadata& _m, func_d_i _f)
+    {
+        register_fct_template(_m, "d", "i", (funcPtr)_f);
+    }
+
+    void register_fct_d_d(const CFuncMetadata& _m, func_d_d _f)
+    {
+        register_fct_template(_m, "d", "d", (funcPtr)_f);
+    }
+
+    void register_fct_d_s(const CFuncMetadata& _m, func_d_s _f)
+    {
+        register_fct_template(_m, "d", "s", (funcPtr)_f);
+    }
+
+    void register_fct_e_e(const CFuncMetadata& _m, func_e_e _f)
+    {
+        register_fct_template(_m, "e", "e", (funcPtr)_f);
+    }
+
+    void register_fct_i_ii(const CFuncMetadata& _m, func_i_ii _f)
+    {
+        register_fct_template(_m, "i", "ii", (funcPtr)_f);
+    }
+
+    void register_fct_i_id(const CFuncMetadata& _m, func_i_id _f)
+    {
+        register_fct_template(_m, "i", "id", (funcPtr)_f);
+    }
+
+    void register_fct_i_is(const CFuncMetadata& _m, func_i_is _f)
+    {
+        register_fct_template(_m, "i", "is", (funcPtr)_f);
+    }
+
+    void register_fct_i_di(const CFuncMetadata& _m, func_i_di _f)
+    {
+        register_fct_template(_m, "i", "di", (funcPtr)_f);
+    }
+
+    void register_fct_i_dd(const CFuncMetadata& _m, func_i_dd _f)
+    {
+        register_fct_template(_m, "i", "dd", (funcPtr)_f);
+    }
+
+    void register_fct_i_si(const CFuncMetadata& _m, func_i_si _f)
+    {
+        register_fct_template(_m, "i", "si", (funcPtr)_f);
+    }
+
+    void register_fct_d_ii(const CFuncMetadata& _m, func_d_ii _f)
+    {
+        register_fct_template(_m, "d", "ii", (funcPtr)_f);
+    }
+
+    void register_fct_d_dd(const CFuncMetadata& _m, func_d_dd _f)
+    {
+        register_fct_template(_m, "d", "dd", (funcPtr)_f);
+    }
+
+    void register_fct_d_sd(const CFuncMetadata& _m, func_d_sd _f)
+    {
+        register_fct_template(_m, "d", "sd", (funcPtr)_f);
+    }
+
+    void register_fct_e_dd(const CFuncMetadata& _m, func_e_dd _f)
+    {
+        register_fct_template(_m, "e", "dd", (funcPtr)_f);
+    }
+
+    void register_fct_e_ee(const CFuncMetadata& _m, func_e_ee _f)
+    {
+        register_fct_template(_m, "e", "ee", (funcPtr)_f);
+    }
+
+    void register_fct_e_se(const CFuncMetadata& _m, func_e_se _f)
+    {
+        register_fct_template(_m, "e", "se", (funcPtr)_f);
+    }
+
+    void register_fct_s_si(const CFuncMetadata& _m, func_s_si _f)
+    {
+        register_fct_template(_m, "s", "si", (funcPtr)_f);
+    }
+
+    void register_fct_s_ss(const CFuncMetadata& _m, func_s_ss _f)
+    {
+        register_fct_template(_m, "s", "ss", (funcPtr)_f);
+    }
+
+    void register_fct_i_iii(const CFuncMetadata& _m, func_i_iii _f)
+    {
+        register_fct_template(_m, "i", "iii", (funcPtr)_f);
+    }
+
+    void register_fct_d_ddd(const CFuncMetadata& _m, func_d_ddd _f)
+    {
+        register_fct_template(_m, "d", "ddd", (funcPtr)_f);
+    }
+
+    void register_fct_e_eee(const CFuncMetadata& _m, func_e_eee _f)
+    {
+        register_fct_template(_m, "e", "eee", (funcPtr)_f);
+    }
 };
diff --git a/pub/lib/fsel.cpp b/pub/lib/fsel.cpp
index a4d14597b779d268f73789b5c50a1a37a8bba891..c0c041682fda80de5bb8e41cba63d7727243af11 100644
--- a/pub/lib/fsel.cpp
+++ b/pub/lib/fsel.cpp
@@ -9,28 +9,25 @@
 
 #include "defs.hpp"
 
-#include "olf.hpp"
-#include "obj.hpp"
-#include "mem.hpp"
 #include "fsel.hpp"
+#include "mem.hpp"
+#include "obj.hpp"
+#include "olf.hpp"
 
 //**************************************************************************************************
 //*  Read online file selection
 //**************************************************************************************************
 
 //! Returns current selection.
-const vector<int>& SFSel::sel() const
-{
-    return FSel;
-}
+const vector<int>& SFSel::sel() const { return FSel; }
 
 //! Returns list of data files in current selection
 vector<int> SFSel::selD() const
 {
     vector<int> ret;
-    for( int k: FSel )
-        if( dynamic_cast<const COld*>(SMem::instance()->mem_get(k)) )
-            ret.push_back( k );
+    for (int k : FSel)
+        if (dynamic_cast<const COld*>(SMem::instance()->mem_get(k)))
+            ret.push_back(k);
     return ret;
 }
 
@@ -38,16 +35,16 @@ vector<int> SFSel::selD() const
 vector<int> SFSel::selC() const
 {
     vector<int> ret;
-    for( int k: FSel )
-        if( dynamic_cast<const COlc*>(SMem::instance()->mem_get(k)) )
-            ret.push_back( k );
+    for (int k : FSel)
+        if (dynamic_cast<const COlc*>(SMem::instance()->mem_get(k)))
+            ret.push_back(k);
     return ret;
 }
 
 //! First selected file.
 COlo* SFSel::sel_first() const
 {
-    if( !FSel.size() )
+    if (!FSel.size())
         throw S("empty file selection");
     return SMem::instance()->mem_get(FSel[0]);
 }
@@ -56,8 +53,8 @@ COlo* SFSel::sel_first() const
 int SFSel::nJ_max() const
 {
     int ret = 0;
-    for( int iv: FSel )
-        ret = std::max( ret, SMem::instance()->mem_get(iv)->nJ() );
+    for (int iv : FSel)
+        ret = std::max(ret, SMem::instance()->mem_get(iv)->nJ());
     return ret;
 }
 
@@ -65,13 +62,10 @@ int SFSel::nJ_max() const
 //*  Write to online file selection
 //**************************************************************************************************
 
-void SFSel::sel_push_back( int k )
-{
-    FSelNew.push_back( k );
-}
+void SFSel::sel_push_back(int k) { FSelNew.push_back(k); }
 
 //! Receive new file selection.
-void SFSel::sel_push( const vector<int>& _FSel )
+void SFSel::sel_push(const vector<int>& _FSel)
 {
     FSelOld = FSel;
     FSel = _FSel;
@@ -80,32 +74,28 @@ void SFSel::sel_push( const vector<int>& _FSel )
 //! Go back to previous file selection.
 void SFSel::sel_delete()
 {
-    for (int i = FSel.size()-1; i>=0; --i)
-        SMem::instance()->mem_del( FSel[i] );
+    for (int i = FSel.size() - 1; i >= 0; --i)
+        SMem::instance()->mem_del(FSel[i]);
     FSel = FSelOld;
     FSelOld.clear();
 }
 
 //! Return true if file selection can be taken from 'inp'.
-void SFSel::set_selection( RObjVecInt _sel )
-{
-    sel_push( _sel->v );
-}
+void SFSel::set_selection(RObjVecInt _sel) { sel_push(_sel->v); }
 
 //! Start collection of new files.
-void SFSel::sel_collect_begin()
-{   FSelNew.clear(); }
+void SFSel::sel_collect_begin() { FSelNew.clear(); }
 
 //! End collection of new files, and make them the new default selection.
 void SFSel::sel_collect_end()
 {
-    if( !SMem::instance()->overwrite && FSelNew.size()>0 )
-        sel_push( FSelNew );
+    if (!SMem::instance()->overwrite && FSelNew.size() > 0)
+        sel_push(FSelNew);
 }
 
 //! Step up or down.
-void SFSel::sel_increment( int step )
+void SFSel::sel_increment(int step)
 {
-    for( int i=0; i<FSel.size(); ++i )
+    for (int i = 0; i < FSel.size(); ++i)
         FSel[i] += step;
 }
diff --git a/pub/lib/fsel.hpp b/pub/lib/fsel.hpp
index 6bf6d768316ca9020c98b1058dffdf4e74b1b47d..0b2a9090093fccbc6dbd6196da02cfa9e7fba024 100644
--- a/pub/lib/fsel.hpp
+++ b/pub/lib/fsel.hpp
@@ -11,10 +11,12 @@
 
 //! Online memory and the default file selection.
 
-class SFSel : public triv::ISingleton<SFSel> {
+class SFSel : public triv::ISingleton<SFSel>
+{
 private:
     vector<int> FSel, FSelOld, FSelNew;
-    void sel_push( const vector<int>& _FSel );
+    void sel_push(const vector<int>& _FSel);
+
 public:
     // Read file selection:
     const vector<int>& sel() const;
@@ -25,9 +27,9 @@ public:
 
     // Modify file selection:
     void sel_delete();
-    void sel_push_back( int k );
-    void set_selection( RObjVecInt _sel );
+    void sel_push_back(int k);
+    void set_selection(RObjVecInt _sel);
     void sel_collect_begin();
     void sel_collect_end();
-    void sel_increment( int step );
+    void sel_increment(int step);
 };
diff --git a/pub/lib/fstring.cpp b/pub/lib/fstring.cpp
index d53a78a9e1e4ea4918690a96148adf81ef88c7df..5bbf513f7501f926ad61af01f95cd9362b91d3b6 100644
--- a/pub/lib/fstring.cpp
+++ b/pub/lib/fstring.cpp
@@ -10,15 +10,15 @@
 #include "defs.hpp"
 
 #include "commands.hpp"
-#include "func.hpp"
 #include "fregistry.hpp"
+#include "func.hpp"
 
 
 //**************************************************************************************************
 //*  Functions of one argument
 //**************************************************************************************************
 
-void func_cmd(string s) { frida_command( s ); } // TO CHECK: -> "eval" ? right approach ?
+void func_cmd(string s) { frida_command(s); } // TO CHECK: -> "eval" ? right approach ?
 
 int func_len(string s) { return s.size(); }
 
@@ -30,7 +30,7 @@ int func_len(string s) { return s.size(); }
 string func_mul(string s, int n)
 {
     string ret = s;
-    for( int i=1; i<n; ++i )
+    for (int i = 1; i < n; ++i)
         ret += s;
     return ret;
 }
@@ -48,12 +48,12 @@ void fstring_initialize()
     CFuncMetadata m;
 
     // operators by precedence (which should agree with xax_yacc.ypp):
-    m = { "*",   2, "a*b     [product]", 6 }; // TODO: copying this line from fbase is weird
-    G->register_fct_s_si ( m, func_mul );
+    m = { "*", 2, "a*b     [product]", 6 }; // TODO: copying this line from fbase is weird
+    G->register_fct_s_si(m, func_mul);
 
     // f( 1 arg )
     m = { "cmd", 1, "(s): execute s as Frida command" };
-    G->register_fct_0_s  ( m, func_cmd );
+    G->register_fct_0_s(m, func_cmd);
     m = { "len", 1, "(s): length of string s" };
-    G->register_fct_i_s  ( m, func_len );
+    G->register_fct_i_s(m, func_len);
 }
diff --git a/pub/lib/func.cpp b/pub/lib/func.cpp
index eb098577bd62568a06df0a74ed14b99a9a2b041c..8c7e7f24ff0a94cb99db11611f4848a3593aef88 100644
--- a/pub/lib/func.cpp
+++ b/pub/lib/func.cpp
@@ -11,8 +11,8 @@
 
 #include <algorithm>
 
-#include "func.hpp"
 #include "coord.hpp"
+#include "func.hpp"
 
 
 //**************************************************************************************************
@@ -21,10 +21,10 @@
 
 //! Returns the typed function that takes exactly the given input types.
 
-const CTypedFunc* CFunc::find_exact_tyfu( string intypes ) const
+const CTypedFunc* CFunc::find_exact_tyfu(string intypes) const
 {
-    for ( auto p=tyfuList.begin(); p!=tyfuList.end(); ++p ) {
-        if ( (*p)->intypes==intypes )
+    for (auto p = tyfuList.begin(); p != tyfuList.end(); ++p) {
+        if ((*p)->intypes == intypes)
             return *p;
     }
     return NULL;
@@ -32,23 +32,23 @@ const CTypedFunc* CFunc::find_exact_tyfu( string intypes ) const
 
 //! Returns the typed function that can deal best with the given input.
 
-const CTypedFunc* CFunc::find_tyfu( string intypes, bool want_error ) const
+const CTypedFunc* CFunc::find_tyfu(string intypes, bool want_error) const
 {
     const CTypedFunc* tf;
-    if( tf = find_exact_tyfu( intypes ) )
+    if (tf = find_exact_tyfu(intypes))
         return tf;
     // cast all i to d:
-    std::replace( intypes.begin(), intypes.end(), 'i', 'd' );
-    if( tf = find_exact_tyfu( intypes ) )
+    std::replace(intypes.begin(), intypes.end(), 'i', 'd');
+    if (tf = find_exact_tyfu(intypes))
         return tf;
-    if( intypes.find('e')!=string::npos ) {
+    if (intypes.find('e') != string::npos) {
         // cast all d to e:
-        std::replace( intypes.begin(), intypes.end(), 'd', 'e' );
-        if( tf = find_exact_tyfu( intypes ) )
+        std::replace(intypes.begin(), intypes.end(), 'd', 'e');
+        if (tf = find_exact_tyfu(intypes))
             return tf;
         // cast all e to d:
-        std::replace( intypes.begin(), intypes.end(), 'e', 'd' );
-        if( tf = find_exact_tyfu( intypes ) )
+        std::replace(intypes.begin(), intypes.end(), 'e', 'd');
+        if (tf = find_exact_tyfu(intypes))
             return tf;
     }
     return NULL;
@@ -61,18 +61,18 @@ const CTypedFunc* CFunc::find_tyfu( string intypes, bool want_error ) const
 
 //! Return default coordinate of function of one argument.
 
-CCoord CFunc::coord( const CCoord& co1 ) const
+CCoord CFunc::coord(const CCoord& co1) const
 {
     CCoord co = co1;
-    if        (tag=="0-") {
+    if (tag == "0-") {
         co.name = "-" + co1.name;
-    } else if (tag=="ln") {
+    } else if (tag == "ln") {
         co.name = "ln " + co1.name;
-    } else if (tag=="lg") {
+    } else if (tag == "lg") {
         co.name = "lg " + co1.name;
-    } else if (tag=="sqrt") {
+    } else if (tag == "sqrt") {
         co.name = "sqrt (" + co1.name + ")";
-        co.unit = co1.unit=="" ? "" : "(" + co1.unit + ")^1/2";
+        co.unit = co1.unit == "" ? "" : "(" + co1.unit + ")^1/2";
     } else {
         co.name = tag + "(" + co1.name + ")";
     }
@@ -81,42 +81,42 @@ CCoord CFunc::coord( const CCoord& co1 ) const
 
 //! Return default coordinate of function of two arguments.
 
-CCoord CFunc::coord( const CCoord& co1, const CCoord& co2 ) const
+CCoord CFunc::coord(const CCoord& co1, const CCoord& co2) const
 {
     CCoord co = co1;
 
-    if ( tag=="+" || tag=="-" ) {
-        if( co1.name==co2.name ){
-            if( co1.unit!=co2.unit )
+    if (tag == "+" || tag == "-") {
+        if (co1.name == co2.name) {
+            if (co1.unit != co2.unit)
                 throw S("same coordinate name and different units in additive operation");
             co = co1;
         } else {
             co.name = co1.name + tag + co2.name;
-            if ( co1.unit=="" )
+            if (co1.unit == "")
                 co.unit = "";
-            else if ( co2.unit!="" && co2.unit!=co1.unit) {
-                cout << "? different units " << co1.unit << " and " <<
-                    co2.unit << " in additive operation\n";
+            else if (co2.unit != "" && co2.unit != co1.unit) {
+                cout << "? different units " << co1.unit << " and " << co2.unit
+                     << " in additive operation\n";
                 co.unit = "";
             } else
                 co.unit = co1.unit;
         }
-    } else if ( tag=="*" || tag=="/" ) {
+    } else if (tag == "*" || tag == "/") {
         co.name = co1.name + tag + co2.name;
-        if     ( co1.unit!="" && co2.unit!="" )
+        if (co1.unit != "" && co2.unit != "")
             co.unit = co1.unit + tag + co2.unit;
-        else if( co1.unit!="" )
+        else if (co1.unit != "")
             co.unit = co1.unit;
-        else if( co2.unit!="" )
-            co.unit = tag=="*" ? co2.unit : "1/(" + co2.unit + ")";
+        else if (co2.unit != "")
+            co.unit = tag == "*" ? co2.unit : "1/(" + co2.unit + ")";
         else
             co.unit = "";
-    } else if ( tag=="^" ) {
+    } else if (tag == "^") {
         if (co2.unit != "") {
             cout << "? exponent is not dimensionless\n";
         }
         co.name = co1.name + "^" + co2.name;
-        co.unit = co1.unit=="" ? "" : ( co1.unit + "^<val>" );
+        co.unit = co1.unit == "" ? "" : (co1.unit + "^<val>");
     } else {
         co.name = tag + "(" + co1.name + "," + co2.name + ")";
         co.unit = "";
@@ -126,8 +126,7 @@ CCoord CFunc::coord( const CCoord& co1, const CCoord& co2 ) const
 
 //! Return default coordinate of function of three arguments.
 
-CCoord CFunc::coord( const CCoord& co1, const CCoord& co2, const CCoord& co3 )
-    const
+CCoord CFunc::coord(const CCoord& co1, const CCoord& co2, const CCoord& co3) const
 {
     CCoord co;
     co.name = tag + "(" + co1.name + "," + co2.name + "," + co3.name + ")";
diff --git a/pub/lib/func.hpp b/pub/lib/func.hpp
index bbd3a49e92a0c662bcebc2fece89e8fab90e57bb..c29efc5116c49b17d9547a85ddcd9989544bac85 100644
--- a/pub/lib/func.hpp
+++ b/pub/lib/func.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                         
-//*  (C) Joachim Wuttke 2001-                                               
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  func.hpp
@@ -14,39 +14,48 @@ typedef void (*funcPtr)(void); // generic pointer-to-function type
 
 //! A wrapper holding a function with fixed input and output types.
 
-class CTypedFunc {
- public:
+class CTypedFunc
+{
+public:
     const string outtype;
     const string intypes;
     funcPtr f; // the polymorphic function pointer
-    CTypedFunc( const char* _outtype, const char* _intypes, funcPtr _f )
-        : outtype(_outtype), intypes(_intypes), f(_f) {};
+    CTypedFunc(const char* _outtype, const char* _intypes, funcPtr _f)
+        : outtype(_outtype), intypes(_intypes), f(_f){};
 };
 
 //! Metadata for an untyped function.
 
-class CFuncMetadata {
- public:
+class CFuncMetadata
+{
+public:
     string tag;
     int narg;
     string explanation;
     int precedence;
     CFuncMetadata() {}
-    CFuncMetadata( string _tag, int _narg, string _explanation, int _precedence=0 )
-        : tag(_tag), narg(_narg), explanation(_explanation), precedence(_precedence) {}
+    CFuncMetadata(string _tag, int _narg, string _explanation, int _precedence = 0)
+        : tag(_tag), narg(_narg), explanation(_explanation), precedence(_precedence)
+    {
+    }
 };
 
 
 //! A wrapper holding function metadata and implementations for various input and output types.
 
-class CFunc : public CFuncMetadata {
- public:
-    CFunc( const CFuncMetadata& _m ) : CFuncMetadata( _m ) {}
-    ~CFunc() { for( auto t: tyfuList ) delete t; }
+class CFunc : public CFuncMetadata
+{
+public:
+    CFunc(const CFuncMetadata& _m) : CFuncMetadata(_m) {}
+    ~CFunc()
+    {
+        for (auto t : tyfuList)
+            delete t;
+    }
     vector<const CTypedFunc*> tyfuList; //! List of available typed function instances.
-    const CTypedFunc* find_exact_tyfu( string intypes ) const;
-    const CTypedFunc* find_tyfu( string intypes, bool want_error ) const;
-    class CCoord coord( const CCoord& co ) const;
-    class CCoord coord( const CCoord& co1, const CCoord& co2 ) const;
-    class CCoord coord( const CCoord& co1, const CCoord& co2, const CCoord& co3 ) const;
+    const CTypedFunc* find_exact_tyfu(string intypes) const;
+    const CTypedFunc* find_tyfu(string intypes, bool want_error) const;
+    class CCoord coord(const CCoord& co) const;
+    class CCoord coord(const CCoord& co1, const CCoord& co2) const;
+    class CCoord coord(const CCoord& co1, const CCoord& co2, const CCoord& co3) const;
 };
diff --git a/pub/lib/genus.cpp b/pub/lib/genus.cpp
index 90a0da6bac0e8e1edd53a94cc106428edc0af2ef..2ade5f7edd11217357c1b350e7533146b1c01f3e 100644
--- a/pub/lib/genus.cpp
+++ b/pub/lib/genus.cpp
@@ -7,8 +7,8 @@
 //! \file  genus.cpp
 //! \brief Variable reference CGenus.
 
-#include "defs.hpp"
 #include "genus.hpp"
+#include "defs.hpp"
 
 
 //**************************************************************************************************
@@ -18,12 +18,12 @@
 
 //! Returns number contained in parameter label s, starting at index pos.
 
-int CGenus::request_num( string s, int pos )
+int CGenus::request_num(string s, int pos)
 {
-    if ( s.size()<=pos )
+    if (s.size() <= pos)
         throw "missing parameter number in '" + s + "'";
     int ret;
-    if ( !triv::any2int( s.substr(pos), &ret ) )
+    if (!triv::any2int(s.substr(pos), &ret))
         throw "invalid parameter number in '" + s + "'";
     return ret;
 }
@@ -31,44 +31,44 @@ int CGenus::request_num( string s, int pos )
 
 //! Creates instance according to given parameter label.
 
-CGenus::CGenus( string s )
+CGenus::CGenus(string s)
 {
     num = -1;
-    if( s.size()<1 )
+    if (s.size() < 1)
         throw S("Variable name missing");
 
-    if ( s[0]=='p' ) {        // curve parameter
-        num = request_num( s, 1 );
+    if (s[0] == 'p') { // curve parameter
+        num = request_num(s, 1);
         categ = VCateg::CP;
-    } else if ( s=="z+" ) {          // new z value
+    } else if (s == "z+") { // new z value
         categ = VCateg::Z;
-    } else if ( s[0]=='z' ) {        // existing z value
-        num = request_num( s, 1 );
+    } else if (s[0] == 'z') { // existing z value
+        num = request_num(s, 1);
         categ = VCateg::Z;
-    } else if ( s=="r+" ) {          // new real par
+    } else if (s == "r+") { // new real par
         categ = VCateg::R;
-    } else if ( s[0]=='r' ) { // existing real par
-        num = request_num( s, 1 );
+    } else if (s[0] == 'r') { // existing real par
+        num = request_num(s, 1);
         categ = VCateg::R;
-    } else if ( s=="nk" ) {
+    } else if (s == "nk") {
         categ = VCateg::NK;
-    } else if ( s=="nj" ) {
+    } else if (s == "nj") {
         categ = VCateg::NJ;
-    } else if ( s=="ni" ) {
+    } else if (s == "ni") {
         categ = VCateg::NI;
-    } else if ( s=="x" ) {
+    } else if (s == "x") {
         categ = VCateg::X;
-    } else if ( s=="y" ) {
+    } else if (s == "y") {
         categ = VCateg::Y;
-    } else if ( s=="dy" ) {
+    } else if (s == "dy") {
         categ = VCateg::DY;
-    } else if ( s=="c" ) {
+    } else if (s == "c") {
         categ = VCateg::C;
-    } else if ( s=="outcome" ) {
+    } else if (s == "outcome") {
         categ = VCateg::COUTCOME;
-    } else if ( s=="chi2" ) {
+    } else if (s == "chi2") {
         categ = VCateg::CCHI2;
-    } else if ( s=="R2" ) {
+    } else if (s == "R2") {
         categ = VCateg::CR2;
     } else {
         throw "Invalid variable '" + s + "'";
@@ -82,24 +82,50 @@ string CGenus::genus_info() const
 {
     string ret;
     switch (categ) {
-    case VCateg::X:  ret = "x";  break;
-    case VCateg::Y:  ret = "y";  break;
-    case VCateg::DY: ret = "dy";  break;
-    case VCateg::C:  ret = "c";  break;
-    case VCateg::Z:  ret = "z";  break;
-    case VCateg::R:  ret = "r";  break;
-    case VCateg::CP: ret = "p";  break;
-    case VCateg::COUTCOME: ret = "outcome_code"; break;
-    case VCateg::CCHI2: ret = "chi2"; break;
-    case VCateg::CR2: ret = "R2"; break;
-    case VCateg::NK: ret = "nk"; break;
-    case VCateg::NJ: ret = "nj"; break;
-    case VCateg::NI: ret = "ni"; break;
+    case VCateg::X:
+        ret = "x";
+        break;
+    case VCateg::Y:
+        ret = "y";
+        break;
+    case VCateg::DY:
+        ret = "dy";
+        break;
+    case VCateg::C:
+        ret = "c";
+        break;
+    case VCateg::Z:
+        ret = "z";
+        break;
+    case VCateg::R:
+        ret = "r";
+        break;
+    case VCateg::CP:
+        ret = "p";
+        break;
+    case VCateg::COUTCOME:
+        ret = "outcome_code";
+        break;
+    case VCateg::CCHI2:
+        ret = "chi2";
+        break;
+    case VCateg::CR2:
+        ret = "R2";
+        break;
+    case VCateg::NK:
+        ret = "nk";
+        break;
+    case VCateg::NJ:
+        ret = "nj";
+        break;
+    case VCateg::NI:
+        ret = "ni";
+        break;
     default:
         throw S("BUG: no info available for unexpected variable category");
     }
-    if ( numbered() ) {
-        if( num==-1 )
+    if (numbered()) {
+        if (num == -1)
             ret += "+";
         else
             ret += S(num);
diff --git a/pub/lib/genus.hpp b/pub/lib/genus.hpp
index 348090b488cf2cf9a1b9403fc02f7cba199968be..14e4a677ef5d1486934395037a925ff88b566240 100644
--- a/pub/lib/genus.hpp
+++ b/pub/lib/genus.hpp
@@ -11,55 +11,54 @@
 //! Variable category.
 
 enum class VCateg : char {
-    X, Y, Z, R, // data
-    DY,            // associated error
-    C, CP,        // curve, curve parameters
-    COUTCOME, CCHI2, CR2, // fit outcome
-    NK, NJ, NI,  // number of files, of spectra in file, of points in spectrum
+    X,
+    Y,
+    Z,
+    R, // data
+    DY, // associated error
+    C,
+    CP, // curve, curve parameters
+    COUTCOME,
+    CCHI2,
+    CR2, // fit outcome
+    NK,
+    NJ,
+    NI, // number of files, of spectra in file, of points in spectrum
     _LAST_
 };
 
 
 //! Variable reference, composed of a category and a number, if applicable.
 
-class CGenus {
- public:
+class CGenus
+{
+public:
     VCateg categ;
     int num;
 
-    CGenus( VCateg categ, int num=0 ) : categ(categ), num(num) {}
-    CGenus( const string s );
+    CGenus(VCateg categ, int num = 0) : categ(categ), num(num) {}
+    CGenus(const string s);
 
-    bool is_errvar() const { return
-            categ==VCateg::DY; }
-    bool fitoutcome() const { return
-            categ==VCateg::COUTCOME ||
-            categ==VCateg::CCHI2 ||
-            categ==VCateg::CR2; }
-    bool pointwise() const { return
-            categ==VCateg::X ||
-            categ==VCateg::Y ||
-            categ==VCateg::DY; }
-    bool curvewise() const { return
-            categ==VCateg::C ||
-            categ==VCateg::CP ||
-            fitoutcome(); }
-    bool slicewise() const { return
-            curvewise() ||
-            categ==VCateg::Z ||
-            categ==VCateg::NI; }
-    bool filewise() const { return
-            categ==VCateg::R ||
-            categ==VCateg::NJ; }
-    bool sessionwise() const { return
-            categ==VCateg::NK; }
-    bool numbered() const { return
-            categ==VCateg::CP ||
-            categ==VCateg::R ||
-            categ==VCateg::Z; }
+    bool is_errvar() const { return categ == VCateg::DY; }
+    bool fitoutcome() const
+    {
+        return categ == VCateg::COUTCOME || categ == VCateg::CCHI2 || categ == VCateg::CR2;
+    }
+    bool pointwise() const
+    {
+        return categ == VCateg::X || categ == VCateg::Y || categ == VCateg::DY;
+    }
+    bool curvewise() const { return categ == VCateg::C || categ == VCateg::CP || fitoutcome(); }
+    bool slicewise() const { return curvewise() || categ == VCateg::Z || categ == VCateg::NI; }
+    bool filewise() const { return categ == VCateg::R || categ == VCateg::NJ; }
+    bool sessionwise() const { return categ == VCateg::NK; }
+    bool numbered() const
+    {
+        return categ == VCateg::CP || categ == VCateg::R || categ == VCateg::Z;
+    }
 
     string genus_info() const;
 
- private:
-    static int request_num( string s, int pos );
+private:
+    static int request_num(string s, int pos);
 };
diff --git a/pub/lib/import.cpp b/pub/lib/import.cpp
index 58503105a46afecb389b9fbfcbbee6c1b3f269b7..21485c6ecef20ae23e36847c735df64fcf51c041 100644
--- a/pub/lib/import.cpp
+++ b/pub/lib/import.cpp
@@ -10,81 +10,82 @@
 #include "defs.hpp"
 
 
-#include "../trivia/string_ops.hpp"
-#include "../trivia/file_ops.hpp"
 #include "../readplus/ask.hpp"
+#include "../trivia/file_ops.hpp"
+#include "../trivia/string_ops.hpp"
 
-#include "olf.hpp"
+#include "import.hpp"
 #include "mem.hpp"
 #include "obj.hpp"
+#include "olf.hpp"
 #include "slice.hpp"
-#include "import.hpp"
 
 
 //! Create a new online file from table.
 
-void NImport::read_tab( string qualif )
+void NImport::read_tab(string qualif)
 { // EMBEDDED_DIALOG
     // ** parse qualif **
-    if( qualif.find_first_not_of("hvcsbmd")!=string::npos )
+    if (qualif.find_first_not_of("hvcsbmd") != string::npos)
         throw S("invalid qualifier");
     char dir = qualif[0];
-    if( !( dir=='h' || dir=='v' || dir=='c' ) )
+    if (!(dir == 'h' || dir == 'v' || dir == 'c'))
         throw S("missing qualifier h or v");
-    bool horizontal = dir=='h';
-    bool choosecol = dir=='c';
-    static int iycol=0;
-    bool fromscript = qualif.find('s')!=string::npos;
-    bool multiblock = qualif.find('m')!=string::npos;
-    bool simpleblock = qualif.find('b')!=string::npos;
+    bool horizontal = dir == 'h';
+    bool choosecol = dir == 'c';
+    static int iycol = 0;
+    bool fromscript = qualif.find('s') != string::npos;
+    bool multiblock = qualif.find('m') != string::npos;
+    bool simpleblock = qualif.find('b') != string::npos;
     if (multiblock && simpleblock)
         throw S("incompatible options bm");
-    bool with_d = qualif.find('d')!=string::npos;
-    if( horizontal && with_d )
+    bool with_d = qualif.find('d') != string::npos;
+    if (horizontal && with_d)
         throw S("incompatible options hd");
 
     // ** input from script or from file **
     static string script;
     vector<string> inFiles;
-    if( fromscript ){
-        inFiles.push_back( "/ram/tab" );
-        script = sask("Script (writing to "+inFiles[0]+")", script);
-        triv::system( script );
+    if (fromscript) {
+        inFiles.push_back("/ram/tab");
+        script = sask("Script (writing to " + inFiles[0] + ")", script);
+        triv::system(script);
     } else {
-        string fnames = sask( "Read tab from file(s)" );
-        inFiles = triv::glob_file_list( fnames, "" );
+        string fnames = sask("Read tab from file(s)");
+        inFiles = triv::glob_file_list(fnames, "");
     }
 
-    if( choosecol ){
-        printf( "at present, x:=i\n" );
-        iycol = iask( "Read y from column", iycol );
-        if( iycol<0 ) return;
+    if (choosecol) {
+        printf("at present, x:=i\n");
+        iycol = iask("Read y from column", iycol);
+        if (iycol < 0)
+            return;
     }
 
-    FILE *fd;
+    FILE* fd;
     string fdir, fshort, fext;
-    for( int iF=0; iF<inFiles.size(); ++iF ) {
-        if( !(fd = fopen(inFiles[iF].c_str(), "r")) )
+    for (int iF = 0; iF < inFiles.size(); ++iF) {
+        if (!(fd = fopen(inFiles[iF].c_str(), "r")))
             throw "cannot open file " + inFiles[iF];
         cout << ".. reading from " << inFiles[iF] << "\n";
-        POld fout( new COld );
-        if( fromscript ) {
-            fout->log_action( "ft"+qualif+" " + script );
+        POld fout(new COld);
+        if (fromscript) {
+            fout->log_action("ft" + qualif + " " + script);
             fout->name = script;
         } else {
-            triv::fname_divide( inFiles[iF], &fdir, &fshort, &fext);
-            fout->log_action( "ft"+qualif+" " + inFiles[iF] );
+            triv::fname_divide(inFiles[iF], &fdir, &fshort, &fext);
+            fout->log_action("ft" + qualif + " " + inFiles[iF]);
             fout->name = fshort;
-            if( choosecol ){
-                fout->log_action( "y from column " + S(iycol) );
+            if (choosecol) {
+                fout->log_action("y from column " + S(iycol));
                 fout->name += "_" + S(iycol);
             }
         }
 
         // ** file-level settings **
-        if( choosecol ){
+        if (choosecol) {
             fout->xco = CCoord("i", "");
-            fout->yco = CCoord("y"+S(iycol), "");
+            fout->yco = CCoord("y" + S(iycol), "");
         } else {
             fout->xco = CCoord("x", "");
             fout->yco = CCoord("y", "");
@@ -100,115 +101,108 @@ void NImport::read_tab( string qualif )
         int nzdat = 0;
         double val;
         PSpec s;
-        while( triv::freadln(fd, &lin) ) {
+        while (triv::freadln(fd, &lin)) {
             ++n_in;
-            if( lin.substr(0,4)=="#rpa" ){
-                triv::string_extract_word( lin.substr(4), &s1, &s2 );
-                if( !triv::any2dbl( s2, &val ) )
-                    printf( "invalid parameter line [%s]\n", lin.c_str() );
+            if (lin.substr(0, 4) == "#rpa") {
+                triv::string_extract_word(lin.substr(4), &s1, &s2);
+                if (!triv::any2dbl(s2, &val))
+                    printf("invalid parameter line [%s]\n", lin.c_str());
                 else
-                    fout->RPar.push_back( CParam( s2, "", val) );
+                    fout->RPar.push_back(CParam(s2, "", val));
                 continue;
             }
-            if( lin[0]=='#' )
+            if (lin[0] == '#')
                 continue;
 
-            if( nline==-1 ) { // start of block
-                if( !horizontal && nblock!=0 && s && s->size()>0 )
-                    fout->V.push_back( move(s) );
-                if( multiblock ) {
-                    if( !triv::str2vec(lin, &zdat, 0, false) )
-                        throw "invalid header line [" + lin +
-                            "] (or legitimate break ?)";
-                    if( nblock==0 ){ // first header
+            if (nline == -1) { // start of block
+                if (!horizontal && nblock != 0 && s && s->size() > 0)
+                    fout->V.push_back(move(s));
+                if (multiblock) {
+                    if (!triv::str2vec(lin, &zdat, 0, false))
+                        throw "invalid header line [" + lin + "] (or legitimate break ?)";
+                    if (nblock == 0) { // first header
                         nzdat = zdat.size();
-                        for( int iz=0; iz<nzdat; ++iz )
-                            fout->ZCo.push_back( CCoord("z"+S(iz), "") );
-                    } else if( zdat.size() != nzdat )
-                        throw "line " + S(n_in) +
-                            ": header has length " + S(zdat.size()) +
-                            " instead of " + S(nzdat);
-                } else if( simpleblock ) {
-                    if( nblock==0 ) // first header
-                        fout->ZCo.push_back( CCoord("#block", "") );
+                        for (int iz = 0; iz < nzdat; ++iz)
+                            fout->ZCo.push_back(CCoord("z" + S(iz), ""));
+                    } else if (zdat.size() != nzdat)
+                        throw "line " + S(n_in) + ": header has length " + S(zdat.size())
+                            + " instead of " + S(nzdat);
+                } else if (simpleblock) {
+                    if (nblock == 0) // first header
+                        fout->ZCo.push_back(CCoord("#block", ""));
                     nzdat = 1;
                     zdat = { (double)nblock };
                 }
-                if( nblock==0 && horizontal ) {
+                if (nblock == 0 && horizontal) {
                     nz = 1;
-                    if( multiblock || simpleblock )
+                    if (multiblock || simpleblock)
                         nz += nzdat;
-                    fout->ZCo.push_back( CCoord("line", "") );
+                    fout->ZCo.push_back(CCoord("line", ""));
                 }
-                if( !horizontal ){
-                    s = PSpec( new CSpec );
-                    s->z.resize( nz );
-                    for( int iz=0; iz<nzdat; ++iz )
-                        s->z[iz] = RObjDbl( new CObjDbl( zdat[iz] ) );
+                if (!horizontal) {
+                    s = PSpec(new CSpec);
+                    s->z.resize(nz);
+                    for (int iz = 0; iz < nzdat; ++iz)
+                        s->z[iz] = RObjDbl(new CObjDbl(zdat[iz]));
                 }
                 nline = 0;
                 ++nblock;
-                if( multiblock ) // this was a header line
+                if (multiblock) // this was a header line
                     continue;
             }
 
-            if( lin=="" && nline!=-1 ) { // end-of-block
+            if (lin == "" && nline != -1) { // end-of-block
                 nline = -1;
                 continue;
             }
 
             // regular data line
-            if( !triv::str2vec(lin, &dat, 0, false) )
-                throw "cannot parse line "+S(nline)+" in block "+
-                    S(nblock)+" ["+lin+"]";
-            if(dat.size()==0)
-                throw "no data in line "+S(nline)+" in block "+
-                    S(nblock)+" ["+lin+"]";
-
-            if( horizontal ) { // new spectrum for every line
-                s = PSpec( new CSpec );
-                s->z.resize( nz );
-                for( int iz=0; iz<nzdat; ++iz )
-                    s->z[iz] = RObjDbl( new CObjDbl( zdat[iz] ) );
-                s->z[nz-1] = RObjInt( new CObjInt( nline ) );
-                for( int i=0; i<dat.size(); ++i )
-                    s->push_xy( (double)i, dat[i] );
-                fout->V.push_back( move(s) );
+            if (!triv::str2vec(lin, &dat, 0, false))
+                throw "cannot parse line " + S(nline) + " in block " + S(nblock) + " [" + lin + "]";
+            if (dat.size() == 0)
+                throw "no data in line " + S(nline) + " in block " + S(nblock) + " [" + lin + "]";
+
+            if (horizontal) { // new spectrum for every line
+                s = PSpec(new CSpec);
+                s->z.resize(nz);
+                for (int iz = 0; iz < nzdat; ++iz)
+                    s->z[iz] = RObjDbl(new CObjDbl(zdat[iz]));
+                s->z[nz - 1] = RObjInt(new CObjInt(nline));
+                for (int i = 0; i < dat.size(); ++i)
+                    s->push_xy((double)i, dat[i]);
+                fout->V.push_back(move(s));
             } else { // vertical
-                if( choosecol ){
-                    if( iycol>=dat.size() )
-                        throw "line "+S(n_in)+" (line "+S(nline)+
-                            " in block "+S(nblock)+") ["+lin+
-                            "] contains only "+S(dat.size())+" values; "+
-                            "cannot read y from col "+S(iycol);
-                    s->push_xy( (double)nline, dat[iycol] );
+                if (choosecol) {
+                    if (iycol >= dat.size())
+                        throw "line " + S(n_in) + " (line " + S(nline) + " in block " + S(nblock)
+                            + ") [" + lin + "] contains only " + S(dat.size()) + " values; "
+                            + "cannot read y from col " + S(iycol);
+                    s->push_xy((double)nline, dat[iycol]);
                 } else {
-                    if( dat.size()!=(with_d?3:2) ){
-                        throw "line "+S(n_in)+" (line "+S(nline)+
-                            " in block "+S(nblock)+") ["+ lin+
-                            "] contains "+S(dat.size())+" values; "+
-                            "at present, exactly "+S(with_d?3:2)+
-                            " are required";
+                    if (dat.size() != (with_d ? 3 : 2)) {
+                        throw "line " + S(n_in) + " (line " + S(nline) + " in block " + S(nblock)
+                            + ") [" + lin + "] contains " + S(dat.size()) + " values; "
+                            + "at present, exactly " + S(with_d ? 3 : 2) + " are required";
                     }
                     if (with_d)
-                        s->push_xy( dat[0], dat[1] );
+                        s->push_xy(dat[0], dat[1]);
                     else
-                        s->push_xyd( dat[0], dat[1], dat[2] );
+                        s->push_xyd(dat[0], dat[1], dat[2]);
                 }
             }
             ++nline;
         } // end of file input loop
 
-        if( !horizontal && s && s->size()>0 )
-            fout->V.push_back( move(s) );
+        if (!horizontal && s && s->size() > 0)
+            fout->V.push_back(move(s));
 
-        if( !(fout->nJ()) )
+        if (!(fout->nJ()))
             throw "no input lines";
-        if( fout->nJ()==1 ){
+        if (fout->nJ() == 1) {
             fout->ZCo.clear();
             fout->VS(0)->z.clear();
         }
-        SMem::instance()->mem_store( move(fout) );
+        SMem::instance()->mem_store(move(fout));
     }
 }
 
@@ -217,45 +211,49 @@ void NImport::read_tab( string qualif )
 
 void NImport::make_grid()
 {
-    POld fout( new COld );
+    POld fout(new COld);
 
-    static int ni=1, nj=1;
+    static int ni = 1, nj = 1;
     static string fnam;
 
     int niIn = iask("Number of points per spectrum", ni);
-    if (niIn<1) return;
+    if (niIn < 1)
+        return;
     ni = niIn;
 
     int njIn = iask("Number of spectra", nj);
-    if (njIn<1) return;
+    if (njIn < 1)
+        return;
     nj = njIn;
 
-    fnam = "grid"+S(ni);
-    if (nj>1) fnam += "x"+S(nj);
+    fnam = "grid" + S(ni);
+    if (nj > 1)
+        fnam += "x" + S(nj);
 
     fout->name = wask("Save as", fnam);
-    fout->log_action( "fm " + S(ni) + " " + S(nj) );
+    fout->log_action("fm " + S(ni) + " " + S(nj));
 
     // *** set coordinates ***
     fout->xco = CCoord("x", "");
     fout->yco = CCoord("y", "");
-    if (nj>1)
+    if (nj > 1)
         fout->ZCo.push_back(CCoord("z", ""));
 
     // *** loop over spectra ***
-    for (int j=0; j<nj; ++j) {
-        PSpec s( new CSpec );
+    for (int j = 0; j < nj; ++j) {
+        PSpec s(new CSpec);
 
         s->x.resize(ni);
-        for( int i=0; i<ni; ++i )
-            s->x[i] = ((double)i)/ni;
+        for (int i = 0; i < ni; ++i)
+            s->x[i] = ((double)i) / ni;
         s->y.clear();
-        s->y.resize( ni, 0. );
+        s->y.resize(ni, 0.);
 
-        if (nj>1) s->z.push_back( RObjInt( new CObjInt(j) ) );
+        if (nj > 1)
+            s->z.push_back(RObjInt(new CObjInt(j)));
 
-        fout->V.push_back( move(s));
+        fout->V.push_back(move(s));
     }
 
-    SMem::instance()->mem_store( move(fout) );
+    SMem::instance()->mem_store(move(fout));
 }
diff --git a/pub/lib/import.hpp b/pub/lib/import.hpp
index d53b1090bd618ef69d2aeca95a8c8437ad4e69e8..1fbbe285beea201370c298e574e94185f297f106 100644
--- a/pub/lib/import.hpp
+++ b/pub/lib/import.hpp
@@ -10,7 +10,8 @@
 
 //! Import tables or make data ex nihilo.
 
-namespace NImport {
-    void read_tab( string qualif );
-    void make_grid();
+namespace NImport
+{
+void read_tab(string qualif);
+void make_grid();
 }
diff --git a/pub/lib/jsel.cpp b/pub/lib/jsel.cpp
index 2d381a05e4cdfd78f84aef40ceb4a71a4424cc6b..0b33016ef302eb264ac1d76ae8175c4c30b9ceeb 100644
--- a/pub/lib/jsel.cpp
+++ b/pub/lib/jsel.cpp
@@ -13,29 +13,29 @@
 #include "../readplus/ask.hpp"
 #include "../trivia/vector_ops.hpp"
 
-#include "olf.hpp"
+#include "expr.hpp"
 #include "fsel.hpp"
 #include "loop.hpp"
 #include "obj.hpp"
-#include "expr.hpp"
+#include "olf.hpp"
 #include "xax_lex.hpp"
 
 //! Interactive spectrum selection.
 
-void JSelAsk( string quest, vector<int>& jLis )
+void JSelAsk(string quest, vector<int>& jLis)
 { // EMBEDDED_DIALOG
     FileIterator fiter(SFSel::instance()->sel());
     int nJmax = 0;
-    while ( const COlo *f = fiter.next() )
-        nJmax = std::max( nJmax, f->nJ() );
+    while (const COlo* f = fiter.next())
+        nJmax = std::max(nJmax, f->nJ());
 
-    if ( nJmax==1 ){
+    if (nJmax == 1) {
         jLis.resize(1);
         jLis[0] = 0;
     } else {
-        string expr = wask( quest, triv::indices_to_s( jLis ) );
-        RNode T = user_xaxparse( expr.c_str() );
-        RObjVecInt v = T->to_index_list( nJmax );
+        string expr = wask(quest, triv::indices_to_s(jLis));
+        RNode T = user_xaxparse(expr.c_str());
+        RObjVecInt v = T->to_index_list(nJmax);
         if (!v)
             throw S("not a valid index list");
         jLis = v->v;
diff --git a/pub/lib/jsel.hpp b/pub/lib/jsel.hpp
index 187fa1497bbce74b4a4819387da86e7dd2b2b11d..9fd893f71195ee08cbe1cc6d3d4cf08e21b0cea0 100644
--- a/pub/lib/jsel.hpp
+++ b/pub/lib/jsel.hpp
@@ -1,11 +1,11 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                         
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  jsel.hpp
 //! \brief Selection of spec/curve index j.
 
 
-void JSelAsk( string quest, vector<int>& JSel );
+void JSelAsk(string quest, vector<int>& JSel);
diff --git a/pub/lib/loop.cpp b/pub/lib/loop.cpp
index 7589e972b39a235d6781cddf02e818fbd6fe6f51..c53be658f43c4d6baefa7332b4f6015d26fb08a1 100644
--- a/pub/lib/loop.cpp
+++ b/pub/lib/loop.cpp
@@ -7,59 +7,60 @@
 //! \file  loop.cpp
 //! \brief Implements iterator over file selection.
 
+#include "loop.hpp"
 #include "defs.hpp"
-#include "olf.hpp"
 #include "mem.hpp"
-#include "loop.hpp"
+#include "olf.hpp"
 
-FileIterator::FileIterator( const vector<int>& _Sel, bool tolerate_empty )
+FileIterator::FileIterator(const vector<int>& _Sel, bool tolerate_empty)
 {
     Sel = _Sel;
-    for( int k: Sel )
-        if( k<0 || k>=SMem::instance()->mem_size() )
+    for (int k : Sel)
+        if (k < 0 || k >= SMem::instance()->mem_size())
             throw "invalid entry " + S(k) + " in file selection";
-    if ( !tolerate_empty && !size() )
+    if (!tolerate_empty && !size())
         throw S("empty file selection");
     reset();
 }
 
 int FileIterator::k() const
 {
-    if( iV<0 || iV>=Sel.size() )
+    if (iV < 0 || iV >= Sel.size())
         throw "BUG: FileIterator::k() called from invalid state";
     return Sel[iV];
 }
 
 COlo* FileIterator::current()
 {
-    if( iV<0 )
+    if (iV < 0)
         throw "BUG: FileIterator::current() called from invalid state";
-    if( iV>=Sel.size() )
+    if (iV >= Sel.size())
         return nullptr;
-    int k=Sel[iV];
-    if( k<0 )
+    int k = Sel[iV];
+    if (k < 0)
         throw S("BUG: k<0 in file selection");
-    if( k>=SMem::instance()->mem_size() )
-        throw "FileSelection["+S(iV)+"]="+S(k)+" exceeds online memory size "+S(SMem::instance()->mem_size());
+    if (k >= SMem::instance()->mem_size())
+        throw "FileSelection[" + S(iV) + "]=" + S(k) + " exceeds online memory size "
+            + S(SMem::instance()->mem_size());
     return SMem::instance()->mem_get(k);
 }
 
 COld* FileIterator::currentD()
 {
-    COlo *f = current();
-    if( !f )
+    COlo* f = current();
+    if (!f)
         return nullptr;
-    if( COld *ret = dynamic_cast<COld*>(f) )
+    if (COld* ret = dynamic_cast<COld*>(f))
         return ret;
     throw S("BUG: non-D file found by D iterator");
 }
 
 COlc* FileIterator::currentC()
 {
-    COlo *f = current();
-    if( !f )
+    COlo* f = current();
+    if (!f)
         return nullptr;
-    if( COlc *ret = dynamic_cast<COlc*>(f) )
+    if (COlc* ret = dynamic_cast<COlc*>(f))
         return ret;
     throw S("BUG: non-C file found by C iterator");
 }
diff --git a/pub/lib/loop.hpp b/pub/lib/loop.hpp
index 5feeee171fd26068807c0fab5e2e00c18089078b..cbb52bd9fd7d1d4670b8492eb2e0172d1b4c3fa6 100644
--- a/pub/lib/loop.hpp
+++ b/pub/lib/loop.hpp
@@ -10,12 +10,14 @@
 
 //! Iterate over all files in selection.
 
-class FileIterator {
+class FileIterator
+{
 private:
     int iV;
     vector<int> Sel;
+
 public:
-    FileIterator( const vector<int>& _Sel, bool tolerate_empty=false );
+    FileIterator(const vector<int>& _Sel, bool tolerate_empty = false);
     void reset() { iV = -1; }
     int k() const;
     int iteration() const { return iV; }
@@ -24,7 +26,19 @@ public:
     COlo* current();
     COld* currentD();
     COlc* currentC();
-    COlo* next() { ++iV; return current(); }
-    COld* nextD() { ++iV; return currentD(); }
-    COlc* nextC() { ++iV; return currentC(); }
+    COlo* next()
+    {
+        ++iV;
+        return current();
+    }
+    COld* nextD()
+    {
+        ++iV;
+        return currentD();
+    }
+    COlc* nextC()
+    {
+        ++iV;
+        return currentC();
+    }
 };
diff --git a/pub/lib/manip.cpp b/pub/lib/manip.cpp
index 9d0a9f1905af4d04916aa99fb50bf5d88cc6bd21..0439bd672a1f791bd3adb4dbc182d0a1f1049787 100644
--- a/pub/lib/manip.cpp
+++ b/pub/lib/manip.cpp
@@ -11,25 +11,26 @@
 
 #include <boost/format.hpp>
 
-#include "../trivia/vector_ops.hpp"
 #include "../readplus/ask.hpp"
+#include "../trivia/vector_ops.hpp"
 
-#include "olf.hpp"
-#include "mem.hpp"
+#include "expr.hpp" // for sort, symmetrize
 #include "fsel.hpp"
-#include "loop.hpp"
 #include "jsel.hpp"
-#include "slice.hpp"
-#include "obj.hpp"
-#include "expr.hpp" // for sort, symmetrize
+#include "loop.hpp"
 #include "manip.hpp"
+#include "mem.hpp"
+#include "obj.hpp"
+#include "olf.hpp"
+#include "slice.hpp"
 #include "xax_lex.hpp"
 
 using boost::format;
 
 // local routines:
-namespace NManip {
-    void ScaRemoveConstantZ( COlo *f );
+namespace NManip
+{
+void ScaRemoveConstantZ(COlo* f);
 }
 
 
@@ -43,17 +44,17 @@ void NManip::freeze_slices()
 {
     FileIterator fiter(SFSel::instance()->sel());
     string sel;
-    sel = wask( "Protect which spectra from forthcoming operations" );
-    if ( sel=="" )
+    sel = wask("Protect which spectra from forthcoming operations");
+    if (sel == "")
         return;
-    RNode Tsel = user_xaxparse( sel.c_str() );
-    while ( COlo *fio = fiter.next() ) {
-        RObjVecInt vsel = Tsel->to_index_list( fio->nJ() );
+    RNode Tsel = user_xaxparse(sel.c_str());
+    while (COlo* fio = fiter.next()) {
+        RObjVecInt vsel = Tsel->to_index_list(fio->nJ());
         if (!vsel)
             throw S("not a valid index list");
-        for ( int j=0; j<fio->nJ(); ++j )
-            fio->V[j]->frozen = triv::contains( vsel->v, j );
-        fio->log_action( "m/ " + sel );
+        for (int j = 0; j < fio->nJ(); ++j)
+            fio->V[j]->frozen = triv::contains(vsel->v, j);
+        fio->log_action("m/ " + sel);
     }
 }
 
@@ -62,10 +63,10 @@ void NManip::freeze_slices()
 void NManip::unfreeze_all_slices()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while ( COlo *fio = fiter.next() ) {
-        for ( int j=0; j<fio->nJ(); ++j )
+    while (COlo* fio = fiter.next()) {
+        for (int j = 0; j < fio->nJ(); ++j)
             fio->V[j]->frozen = false;
-        fio->log_action( "m/-" );
+        fio->log_action("m/-");
     }
 }
 
@@ -76,39 +77,39 @@ void NManip::unfreeze_all_slices()
 
 //! Delete (or retain) points according to list of indices.
 
-void NManip::points_select( bool sel_del )
+void NManip::points_select(bool sel_del)
 {
     FileIterator fiter(SFSel::instance()->selD());
     static string sel = "";
-    sel = wask( string( sel_del ? "Delete" : "Retain" ) + " which points", sel );
-    if ( sel=="" )
+    sel = wask(string(sel_del ? "Delete" : "Retain") + " which points", sel);
+    if (sel == "")
         return;
-    RNode Tsel = user_xaxparse( sel.c_str() );
-
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
-        fout->log_action( "mp" + string( sel_del ? "d" : "r" ) + " " + sel );
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin->VS(j);
-            PSpec sout( new CSpec );
+    RNode Tsel = user_xaxparse(sel.c_str());
+
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
+        fout->log_action("mp" + string(sel_del ? "d" : "r") + " " + sel);
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            PSpec sout(new CSpec);
             sout->z = sin->z;
-            RObjVecInt vsel = Tsel->to_index_list( sin->size() );
+            RObjVecInt vsel = Tsel->to_index_list(sin->size());
             if (!vsel)
                 throw S("not a valid index list");
-            for ( int i=0; i<sin->size(); i++ ) {
-                if ( sel_del ^ triv::contains(vsel->v, i) ) {
-                    if ( sin->has_dy() )
-                        sout->push_xyd( sin->x[i], sin->y[i], sin->dy[i] );
+            for (int i = 0; i < sin->size(); i++) {
+                if (sel_del ^ triv::contains(vsel->v, i)) {
+                    if (sin->has_dy())
+                        sout->push_xyd(sin->x[i], sin->y[i], sin->dy[i]);
                     else
-                        sout->push_xy( sin->x[i], sin->y[i] );
+                        sout->push_xy(sin->x[i], sin->y[i]);
                 }
             }
-            if ( sout->size() )
-                fout->V.push_back( move(sout) );
+            if (sout->size())
+                fout->V.push_back(move(sout));
         }
-        if ( !fout->V.size() )
+        if (!fout->V.size())
             throw S("no data point left");
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -120,32 +121,32 @@ void NManip::points_rebin()
     FileIterator fiter(SFSel::instance()->selD());
 
     static string sel;
-    sel = wask( "Start bins at points", sel );
-    if ( sel=="" )
+    sel = wask("Start bins at points", sel);
+    if (sel == "")
         return;
-    RNode Tsel = user_xaxparse( sel.c_str() );
+    RNode Tsel = user_xaxparse(sel.c_str());
 
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
         fout->log_action("mpa " + sel);
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin->VS(j);
-            RObjVecInt vsel = Tsel->to_index_list( sin->size() );
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            RObjVecInt vsel = Tsel->to_index_list(sin->size());
             if (!vsel)
                 throw S("not a valid index list");
-            if ( !vsel->size() )
+            if (!vsel->size())
                 throw S("BUG: unexpected empty bin list");
             vector<int> breaks = vsel->v;
-            if ( breaks[0]!=0 )
+            if (breaks[0] != 0)
                 throw S("First bin must start at 0");
-            breaks.push_back( sin->size() );
+            breaks.push_back(sin->size());
 
-            PSpec sout = sin->binned( breaks );
+            PSpec sout = sin->binned(breaks);
 
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -155,88 +156,89 @@ void NManip::points_rebin()
 void NManip::points_rebin_by_factor()
 {
     FileIterator fiter(SFSel::instance()->selD());
-    static int ng=2;
-    ng = iask( "Number of points per bin", ng );
-    if ( ng<1 )
+    static int ng = 2;
+    ng = iask("Number of points per bin", ng);
+    if (ng < 1)
         throw S("invalid choice");
 
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
-        fout->log_action( "mpaf " + S(ng) );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
+        fout->log_action("mpaf " + S(ng));
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
+        for (int j = 0; j < fin->nJ(); j++) {
             const CSpec* sin = fin->VS(j);
 
             int nout = sin->size() / ng;
-            if ( nout<1 )
+            if (nout < 1)
                 throw "not enough points in spectrum " + S(j);
-            vector<int> breaks( nout+1 );
-            for ( int iout=0; iout<nout+1; ++iout )
-                breaks[iout] = iout*ng;
+            vector<int> breaks(nout + 1);
+            for (int iout = 0; iout < nout + 1; ++iout)
+                breaks[iout] = iout * ng;
 
-            PSpec sout = sin->binned( breaks );
+            PSpec sout = sin->binned(breaks);
 
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
 
 //! Bin points to keep errors below a certain bound.
 
-void NManip::points_rebin_by_err( const string& subcmd )
+void NManip::points_rebin_by_err(const string& subcmd)
 {
     FileIterator fiter(SFSel::instance()->selD());
     bool mode_abs;
-    if      ( subcmd=="a" )
+    if (subcmd == "a")
         mode_abs = true;
-    else if ( subcmd=="r" )
+    else if (subcmd == "r")
         mode_abs = false;
     else
         throw S("invalid subcommand");
 
     static double errbound;
-    errbound = dask( "Keep error below", errbound );
+    errbound = dask("Keep error below", errbound);
 
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
         string groupinfo;
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin->VS(j);
-            PSpec sout( new CSpec() );
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            PSpec sout(new CSpec());
             sout->z = sin->z;
-            if ( !sin->has_dy() )
+            if (!sin->has_dy())
                 throw S("no errors available");
             double xg = 0, yg = 0, vg = 0;
-            int ng = 0, istart=0;
-            for ( int i=0; i<sin->size(); ++i ) {
-                if ( !mode_abs && sin->y[i]<0 )
-                    throw ("negative counts not compatible with relative error bounds");
+            int ng = 0, istart = 0;
+            for (int i = 0; i < sin->size(); ++i) {
+                if (!mode_abs && sin->y[i] < 0)
+                    throw("negative counts not compatible with relative error bounds");
                 xg += sin->x[i];
                 yg += sin->y[i];
-                vg += SQR( sin->dy[i] );
+                vg += SQR(sin->dy[i]);
                 ++ng;
                 double dg = sqrt(vg);
-                if ( (  mode_abs && dg/ng<errbound ) ||
-                     ( !mode_abs && yg>0 && dg/yg<errbound ) )
-                {
-                    sout->push_xyd( xg/ng, yg/ng, dg/ng );
+                if ((mode_abs && dg / ng < errbound)
+                    || (!mode_abs && yg > 0 && dg / yg < errbound)) {
+                    sout->push_xyd(xg / ng, yg / ng, dg / ng);
                     groupinfo += S(istart) + ",";
-                    xg = 0; yg = 0; vg = 0; ng = 0;
-                    istart = i+1;
+                    xg = 0;
+                    yg = 0;
+                    vg = 0;
+                    ng = 0;
+                    istart = i + 1;
                 }
             }
-            if ( sout->size() )
-                fout->V.push_back( move(sout) );
+            if (sout->size())
+                fout->V.push_back(move(sout));
         }
         string docline = "mpae" + subcmd + " " + S(errbound);
-        if ( fin->nJ()==1 )
-            docline += " #=> groups " + groupinfo.substr(0,groupinfo.size()-1);
-        fout->log_action( docline );
-        if ( fout->nJ() )
-            SMem::instance()->mem_store( move(fout), fiter.k() );
-
+        if (fin->nJ() == 1)
+            docline += " #=> groups " + groupinfo.substr(0, groupinfo.size() - 1);
+        fout->log_action(docline);
+        if (fout->nJ())
+            SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -247,32 +249,32 @@ void NManip::points_break_by_factor()
 {
     FileIterator fiter(SFSel::instance()->selD());
     static int ng;
-    ng = iask( "Number of points per spectrum", ng );
-    if ( ng<1 )
+    ng = iask("Number of points per spectrum", ng);
+    if (ng < 1)
         throw S("invalid choice");
 
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
-        fout->log_action( "mpbf " + S(ng) );
-        fout->ZCo.push_back( CCoord("no-in-break", ""));
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
+        fout->log_action("mpbf " + S(ng));
+        fout->ZCo.push_back(CCoord("no-in-break", ""));
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
+        for (int j = 0; j < fin->nJ(); j++) {
             const CSpec* sin = fin->VS(j);
             int jsub = 0;
-            for( int i=0; i<sin->size(); i+=ng ){
-                PSpec sout( new CSpec() );
+            for (int i = 0; i < sin->size(); i += ng) {
+                PSpec sout(new CSpec());
                 sout->z = sin->z;
-                sout->z.push_back( RObjInt( new CObjInt(jsub++) ) );
-                for( int ii=i; ii<sin->size() && ii<i+ng; ++ii ){
-                    if( sin->has_dy() )
-                        sout->push_xyd( sin->x[ii], sin->y[ii], sin->dy[ii] );
+                sout->z.push_back(RObjInt(new CObjInt(jsub++)));
+                for (int ii = i; ii < sin->size() && ii < i + ng; ++ii) {
+                    if (sin->has_dy())
+                        sout->push_xyd(sin->x[ii], sin->y[ii], sin->dy[ii]);
                     else
-                        sout->push_xy( sin->x[ii], sin->y[ii] );
+                        sout->push_xy(sin->x[ii], sin->y[ii]);
                 }
-                fout->V.push_back( move(sout) );
+                fout->V.push_back(move(sout));
             }
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -283,35 +285,36 @@ void NManip::points_sort()
 {
     FileIterator fiter(SFSel::instance()->selD());
     string expr = sask("Sort points according to");
-    if (expr=="") return;
-    RNode T = user_xaxparse( expr.c_str() );
-    if ( T->has_dummy() )
+    if (expr == "")
+        return;
+    RNode T = user_xaxparse(expr.c_str());
+    if (T->has_dummy())
         throw S("dummy argument t not allowed when operating on data");
 
-    while ( const COld *fin = fiter.nextD() ) {
+    while (const COld* fin = fiter.nextD()) {
         int k = fiter.k();
-        POld fout( fin->new_POld() );
-        fout->log_action("mpo "+expr);
+        POld fout(fin->new_POld());
+        fout->log_action("mpo " + expr);
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin->VS(j);
-            PSpec sout( new CSpec );
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            PSpec sout(new CSpec);
             sout->z = sin->z;
 
             int n = sin->size();
             vector<double> v(n);
-            T->tree_vec_val( &v, 0, k, j );
-            vector<size_t> P = triv::sorted_indices( v );
-            sout->resize( n, sin->has_dy() );
-            for (int i=0; i<n; ++i) {
+            T->tree_vec_val(&v, 0, k, j);
+            vector<size_t> P = triv::sorted_indices(v);
+            sout->resize(n, sin->has_dy());
+            for (int i = 0; i < n; ++i) {
                 sout->x[i] = sin->x[P[i]];
-                sout->y[i]  = sin->y[P[i]];
-                if ( sin->has_dy() )
+                sout->y[i] = sin->y[P[i]];
+                if (sin->has_dy())
                     sout->dy[i] = sin->dy[P[i]];
             }
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -322,39 +325,40 @@ void NManip::points_rebin_duplicates()
 {
     FileIterator fiter(SFSel::instance()->selD());
     COld fout;
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
         fout->log_action("mpq # average points when x equal");
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin->VS(j);
-            PSpec sout( new CSpec );
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            PSpec sout(new CSpec);
             sout->z = sin->z;
 
             int n = sin->size();
-            int ii=0;
-            for ( int i=0; i<n; i=ii ) {
+            int ii = 0;
+            for (int i = 0; i < n; i = ii) {
                 double xg = sin->x[i];
                 double yg = sin->y[i];
                 double eg = NAN;
-                if ( sin->has_dy() )
+                if (sin->has_dy())
                     eg = SQR(sin->dy[i]);
                 int ng = 1;
-                for ( ii=i+1; ii<n; ++ii ) {
-                    if (sin->x[ii] != xg) break;
+                for (ii = i + 1; ii < n; ++ii) {
+                    if (sin->x[ii] != xg)
+                        break;
                     yg += sin->y[ii];
-                    if ( sin->has_dy() )
-                        eg += SQR( sin->y[ii] );
+                    if (sin->has_dy())
+                        eg += SQR(sin->y[ii]);
                     ++ng;
                 }
-                if ( sin->has_dy() )
-                    sout->push_xyd(xg, yg/ng, sqrt(eg)/ng );
+                if (sin->has_dy())
+                    sout->push_xyd(xg, yg / ng, sqrt(eg) / ng);
                 else
-                    sout->push_xy(xg, yg/ng);
+                    sout->push_xy(xg, yg / ng);
             }
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -365,59 +369,62 @@ void NManip::points_symmetrize()
 {
     FileIterator fiter(SFSel::instance()->selD());
     static string expr = "0";
-    expr = sask( "Assume symmetry with mirror positioned at", expr );
-    if ( expr=="" ) return;
-    RNode T = user_xaxparse( expr.c_str() );
+    expr = sask("Assume symmetry with mirror positioned at", expr);
+    if (expr == "")
+        return;
+    RNode T = user_xaxparse(expr.c_str());
 
-    while ( const COld *fin = fiter.nextD() ) {
+    while (const COld* fin = fiter.nextD()) {
         int k = fiter.k();
-        POld fout( fin->new_POld() );
-        fout->log_action("mpsym "+expr);
+        POld fout(fin->new_POld());
+        fout->log_action("mpsym " + expr);
 
-        for (int j=0; j<fin->nJ(); j++) {
+        for (int j = 0; j < fin->nJ(); j++) {
             int n, i, il, ih, nl, nh;
-            const CSpec *sin = fin->VS(j);
-            PSpec sout( new CSpec );
+            const CSpec* sin = fin->VS(j);
+            PSpec sout(new CSpec);
             sout->z = sin->z;
-            if ( !triv::is_ascending( sin->x ) )
+            if (!triv::is_ascending(sin->x))
                 throw S("not ascending");
             double step;
-            if ( !triv::is_equidist( &step, sin->x ) )
+            if (!triv::is_equidist(&step, sin->x))
                 throw S("not equidistant");
-            double centre = T->tree_point_dbl( k, j );
-            il = (int) ( (centre - sin->x[0])/step );
+            double centre = T->tree_point_dbl(k, j);
+            il = (int)((centre - sin->x[0]) / step);
             ih = il + 1;
             n = sin->size();
             nl = il + 1;
             nh = n - ih;
-            if ( nl<1 || nh<1 )
+            if (nl < 1 || nh < 1)
                 throw S("nothing to symmetrize");
-            for (i=0; i<(nl<nh?nl:nh); ++i) {
-                if ( sin->has_dy() )
-                    sout->push_xyd( ( -sin->x[il-i] + sin->x[ih+i] ) / 2,
-                                    ( sin->y[il-i] + sin->y[ih+i] ) / 2,
-                                    sqrt( SQR(sin->dy[il-i]) + SQR(sin->dy[ih+i]) ) / 2 );
+            for (i = 0; i < (nl < nh ? nl : nh); ++i) {
+                if (sin->has_dy())
+                    sout->push_xyd(
+                        (-sin->x[il - i] + sin->x[ih + i]) / 2,
+                        (sin->y[il - i] + sin->y[ih + i]) / 2,
+                        sqrt(SQR(sin->dy[il - i]) + SQR(sin->dy[ih + i])) / 2);
                 else
-                    sout->push_xy( ( -sin->x[il-i] + sin->x[ih+i] ) / 2,
-                                   ( sin->y[il-i] + sin->y[ih+i] ) / 2 );
+                    sout->push_xy(
+                        (-sin->x[il - i] + sin->x[ih + i]) / 2,
+                        (sin->y[il - i] + sin->y[ih + i]) / 2);
             }
-            if ( nl<nh ) {
-                for (i=nl; i<nh; ++i)
-                    if ( sin->has_dy() )
-                        sout->push_xyd( sin->x[ih+i], sin->y[ih+i], sin->dy[ih+i] );
+            if (nl < nh) {
+                for (i = nl; i < nh; ++i)
+                    if (sin->has_dy())
+                        sout->push_xyd(sin->x[ih + i], sin->y[ih + i], sin->dy[ih + i]);
                     else
-                        sout->push_xy( sin->x[ih+i], sin->y[ih+i] );
+                        sout->push_xy(sin->x[ih + i], sin->y[ih + i]);
             } else {
-                for (i=nh; i<nl; ++i)
-                    if ( sin->has_dy() )
-                        sout->push_xyd( -sin->x[il-i], sin->y[il-i], sin->dy[il-i] );
+                for (i = nh; i < nl; ++i)
+                    if (sin->has_dy())
+                        sout->push_xyd(-sin->x[il - i], sin->y[il - i], sin->dy[il - i]);
                     else
-                        sout->push_xy( -sin->x[il-i], sin->y[il-i] );
+                        sout->push_xy(-sin->x[il - i], sin->y[il - i]);
             }
             sout->z = sin->z;
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -426,18 +433,18 @@ void NManip::points_symmetrize()
 void NManip::points_remove_err()
 {
     FileIterator fiter(SFSel::instance()->selD());
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
         fout->log_action("mpe-");
-        for (int j=0; j<fin->nJ(); j++) {
-            const CSpec *sin = fin->VS(j);
-            PSpec sout( new CSpec );
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            PSpec sout(new CSpec);
             sout->z = sin->z;
             sout->x = sin->x;
             sout->y = sin->y;
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -448,23 +455,23 @@ void NManip::points_remove_err()
 
 //! Remove z variable that does not genusy with j.
 
-void NManip::ScaRemoveConstantZ( COlo *fio )
+void NManip::ScaRemoveConstantZ(COlo* fio)
 {
-    for ( int iz=fio->nZ()-1; iz>=0; --iz ) {
+    for (int iz = fio->nZ() - 1; iz >= 0; --iz) {
         int nj = fio->nJ();
-        if ( nj<1 )
+        if (nj < 1)
             throw S("file contains no spectrum");
-        double z = fio->z(0,iz)->to_r();
+        double z = fio->z(0, iz)->to_r();
         bool z_is_const = true;
-        for ( int j=1; j<nj; ++j ) {
-            if ( fio->z(j,iz)->to_r() != z ) {
+        for (int j = 1; j < nj; ++j) {
+            if (fio->z(j, iz)->to_r() != z) {
                 z_is_const = false;
             }
         }
-        if ( z_is_const ) {
-            printf( " constant z%i becomes r%i\n", iz, (int)fio->RPar.size() );
-            fio->RPar.push_back( CParam( fio->ZCo[iz], z ) );
-            fio->remove_z( iz );
+        if (z_is_const) {
+            printf(" constant z%i becomes r%i\n", iz, (int)fio->RPar.size());
+            fio->RPar.push_back(CParam(fio->ZCo[iz], z));
+            fio->remove_z(iz);
         }
     }
 }
@@ -472,25 +479,24 @@ void NManip::ScaRemoveConstantZ( COlo *fio )
 
 //! Delete (or retain) spectra according to list of indices.
 
-void NManip::slices_select( bool sel_del )
+void NManip::slices_select(bool sel_del)
 {
     vector<int> JSel, JSelSorted;
     static string jSel = "";
-    JSelAsk( string( sel_del ? "Delete" : "Retain" ) + " which spectra", JSel );
+    JSelAsk(string(sel_del ? "Delete" : "Retain") + " which spectra", JSel);
 
     FileIterator fiter(SFSel::instance()->sel());
-    while ( const COlo *fin = fiter.next() ) {
-        POlo fout( fin->new_POlo() );
+    while (const COlo* fin = fiter.next()) {
+        POlo fout(fin->new_POlo());
         // JSel.evaluate( 0, fin->nJ()-1 );
-        fout->log_action( "ms" + string( sel_del ? "d" : "r" ) +
-                              " " + triv::indices_to_s(JSel) );
-        for ( int j=0; j<fin->nJ(); ++j ) {
-            if ( sel_del ^ triv::contains(JSel, j ) ) {
-                fout->V.push_back( fin->copy_slice( j ) );
+        fout->log_action("ms" + string(sel_del ? "d" : "r") + " " + triv::indices_to_s(JSel));
+        for (int j = 0; j < fin->nJ(); ++j) {
+            if (sel_del ^ triv::contains(JSel, j)) {
+                fout->V.push_back(fin->copy_slice(j));
             }
         }
-        ScaRemoveConstantZ( fout.get() );
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        ScaRemoveConstantZ(fout.get());
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -502,113 +508,115 @@ void NManip::slices_rebin()
     FileIterator fiter(SFSel::instance()->sel());
     vector<int> JSel;
     static string jSel = "";
-    JSelAsk( "Start groups at spectra", JSel );
-    while ( const COlo *fin = fiter.next() ) {
-        if( fin->nJ()<=1 )
+    JSelAsk("Start groups at spectra", JSel);
+    while (const COlo* fin = fiter.next()) {
+        if (fin->nJ() <= 1)
             throw S("Only one slice in file");
-        const COld *fd = dynamic_cast<const COld*>( fin );
-        const COlc *fc = dynamic_cast<const COlc*>( fin );
-        POlo fout( fin->new_POlo() );
+        const COld* fd = dynamic_cast<const COld*>(fin);
+        const COlc* fc = dynamic_cast<const COlc*>(fin);
+        POlo fout(fin->new_POlo());
         // JSel.evaluate( 0, fin->nJ()-1 );
-        if ( JSel.size()<1 || JSel[0]!=0 )
+        if (JSel.size() < 1 || JSel[0] != 0)
             throw S("spectrum selection must contain 0");
         vector<int> BreakPoints;
-        copy_if( JSel.begin(), JSel.end(), back_inserter(BreakPoints),
-                 [&](int j){ return j<fin->nJ(); } );
-        BreakPoints.push_back( fin->nJ() );
+        copy_if(JSel.begin(), JSel.end(), back_inserter(BreakPoints), [&](int j) {
+            return j < fin->nJ();
+        });
+        BreakPoints.push_back(fin->nJ());
         fout->log_action("msa " + triv::indices_to_s(JSel));
-        for ( int iv=0; iv<BreakPoints.size()-1; iv++ ) {
+        for (int iv = 0; iv < BreakPoints.size() - 1; iv++) {
             int ji = BreakPoints[iv];
-            int jf = BreakPoints[iv+1];
-            int mj = jf-ji;
-            if( mj<=0 )
+            int jf = BreakPoints[iv + 1];
+            int mj = jf - ji;
+            if (mj <= 0)
                 throw S("Empty group");
             int nz = fin->nZ();
-            vector<double> zout( nz );
-            for ( int iz=0; iz<nz; ++iz ) {
+            vector<double> zout(nz);
+            for (int iz = 0; iz < nz; ++iz) {
                 double z = 0;
-                for ( int jj=ji; jj<jf; jj++ ) {
-                    auto pz = PCAST<const CObjNum>(fin->z(jj,iz));
-                    if( !pz )
-                        throw "z"+S(iz)+" is not a number";
+                for (int jj = ji; jj < jf; jj++) {
+                    auto pz = PCAST<const CObjNum>(fin->z(jj, iz));
+                    if (!pz)
+                        throw "z" + S(iz) + " is not a number";
                     z += pz->to_r();
                 }
-                zout[iz] = z/mj;
+                zout[iz] = z / mj;
             }
-            if ( fd ) {
-                PSpec sout( new CSpec() );
+            if (fd) {
+                PSpec sout(new CSpec());
                 bool in_with_dy = fd->VS(ji)->has_dy();
-                bool out_with_dy = in_with_dy || mj>1;
+                bool out_with_dy = in_with_dy || mj > 1;
                 int n = fd->nPts(ji);
-                sout->resize( n, out_with_dy );
+                sout->resize(n, out_with_dy);
                 // x grids must be equal:
                 sout->x = fd->VS(ji)->x;
-                for ( int jj=ji+1; jj<jf; jj++ ) {
-                    if ( fd->VS(jj)->has_dy() != in_with_dy )
+                for (int jj = ji + 1; jj < jf; jj++) {
+                    if (fd->VS(jj)->has_dy() != in_with_dy)
                         throw S("some slices have dy, others not");
-                    if ( fd->nPts(jj) != n )
-                        throw "grids differ in size: ni[,"+S(jj)+"]="+S(fd->nPts(jj))+
-                            " vs ni[,"+S(ji)+"]="+S(n);
-                    for ( int i=0; i<fd->nPts(jj); ++i ) {
-                        if ( fd->VS(jj)->x[i] != sout->x[i] )
-                            throw "grids differ: x[,"+S(jj)+","+S(i)+"]="+S(fd->VS(jj)->x[i])+
-                                " vs x[,"+S(ji)+","+S(i)+"]="+S(sout->x[i]);
+                    if (fd->nPts(jj) != n)
+                        throw "grids differ in size: ni[," + S(jj) + "]=" + S(fd->nPts(jj))
+                            + " vs ni[," + S(ji) + "]=" + S(n);
+                    for (int i = 0; i < fd->nPts(jj); ++i) {
+                        if (fd->VS(jj)->x[i] != sout->x[i])
+                            throw "grids differ: x[," + S(jj) + "," + S(i) + "]="
+                                + S(fd->VS(jj)->x[i]) + " vs x[," + S(ji) + "," + S(i) + "]="
+                                + S(sout->x[i]);
                     }
                 }
                 // bin y:
-                for ( int i=0; i<n; i++ ) {
+                for (int i = 0; i < n; i++) {
                     double ym = 0;
-                    for ( int jj=ji; jj<jf; jj++)
+                    for (int jj = ji; jj < jf; jj++)
                         ym += fd->VS(jj)->y[i];
-                    if ( mj!=jf-ji || mj<1 )
+                    if (mj != jf - ji || mj < 1)
                         throw S("BUG: inconsistent number of binned spectra");
                     ym /= mj;
                     sout->y[i] = ym;
-                    if ( out_with_dy ) {
+                    if (out_with_dy) {
                         // TODO needs justification / documentation
-                        if (mj<2) {
-                            if ( !in_with_dy )
+                        if (mj < 2) {
+                            if (!in_with_dy)
                                 throw S("BUG: should not compute variance for case mj=1");
                             sout->dy[i] = fd->VS(ji)->dy[i];
                         } else {
                             double vm_src = 0, vm_grp = 0;
-                            for ( int jj=ji; jj<jf; jj++) {
-                                if( fd->VS(jj)->has_dy() )
+                            for (int jj = ji; jj < jf; jj++) {
+                                if (fd->VS(jj)->has_dy())
                                     vm_src += SQR(fd->VS(jj)->dy[i]);
-                                vm_grp += SQR(fd->VS(jj)->y[i]-ym);
+                                vm_grp += SQR(fd->VS(jj)->y[i] - ym);
                             }
-                            double vm = vm_src/mj/mj;
-                            if( mj>1 )
-                                vm += vm_grp / (mj-1);
+                            double vm = vm_src / mj / mj;
+                            if (mj > 1)
+                                vm += vm_grp / (mj - 1);
                             sout->dy[i] = sqrt(vm);
                         }
                     }
                 }
-                for ( int iz=0; iz<nz; ++iz )
-                    sout->z.push_back( PObjDbl( new CObjDbl(zout[iz]) ) );
-                fout->V.push_back( move(sout) );
-            } else if ( fc ) {
-                PCurve cout( new CCurve );
+                for (int iz = 0; iz < nz; ++iz)
+                    sout->z.push_back(PObjDbl(new CObjDbl(zout[iz])));
+                fout->V.push_back(move(sout));
+            } else if (fc) {
+                PCurve cout(new CCurve);
                 int np = fc->nP;
                 vector<double> p(np);
-                for ( int ip=0; ip<np; ip++ ) {
+                for (int ip = 0; ip < np; ip++) {
                     int mj = 0;
                     double pm = 0;
-                    for ( int jj=ji; jj<jf; jj++) {
+                    for (int jj = ji; jj < jf; jj++) {
                         pm += fc->VC(jj)->P[ip];
                         ++mj;
                     }
-                    p[ip] = mj==0 ? 0 : pm/mj;
+                    p[ip] = mj == 0 ? 0 : pm / mj;
                 }
                 cout->P = p;
-                for ( int iz=0; iz<nz; ++iz )
-                    cout->z.push_back( PObjDbl( new CObjDbl(zout[iz]) ) );
-                cout->ParAttr.resize( np, 'u' );
-                fout->V.push_back( move(cout) );
+                for (int iz = 0; iz < nz; ++iz)
+                    cout->z.push_back(PObjDbl(new CObjDbl(zout[iz])));
+                cout->ParAttr.resize(np, 'u');
+                fout->V.push_back(move(cout));
             }
         }
-        ScaRemoveConstantZ( fout.get() );
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        ScaRemoveConstantZ(fout.get());
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -620,34 +628,34 @@ void NManip::slices_merge()
     FileIterator fiter(SFSel::instance()->selD());
     vector<int> JSel;
     static string jSel = "";
-    JSelAsk( "Start groups at spectra", JSel );
+    JSelAsk("Start groups at spectra", JSel);
 
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
         // JSel.evaluate( 0, fin->nJ()-1 );
-        if (JSel.size()<1 || JSel[0]!=0)
+        if (JSel.size() < 1 || JSel[0] != 0)
             throw S("spectrum selection must contain 0");
         fout->log_action("msj " + triv::indices_to_s(JSel));
         cout << "WARNING: z just taken from first spectrum of each group\n";
-        for ( int iv=0; iv<JSel.size(); iv++ ) {
+        for (int iv = 0; iv < JSel.size(); iv++) {
             int ji, jf;
             ji = JSel[iv];
-            jf = ( iv<JSel.size()-1 ? JSel[iv+1] : fin->nJ() );
-            PSpec sout( new CSpec( *(fin->VS(ji)) ) );
+            jf = (iv < JSel.size() - 1 ? JSel[iv + 1] : fin->nJ());
+            PSpec sout(new CSpec(*(fin->VS(ji))));
             bool with_dy = fin->VS(ji)->has_dy();
-            for ( int jj=ji+1; jj<jf; jj++) {
-                if ( fin->VS(jj)->has_dy() != with_dy )
+            for (int jj = ji + 1; jj < jf; jj++) {
+                if (fin->VS(jj)->has_dy() != with_dy)
                     throw S("some spectra have error bars, others not");
-                for ( int i=0; i<fin->VS(jj)->size(); ++i )
-                    if ( with_dy )
-                        sout->push_xyd( fin->VS(jj)->x[i], fin->VS(jj)->y[i], fin->VS(jj)->dy[i]);
+                for (int i = 0; i < fin->VS(jj)->size(); ++i)
+                    if (with_dy)
+                        sout->push_xyd(fin->VS(jj)->x[i], fin->VS(jj)->y[i], fin->VS(jj)->dy[i]);
                     else
-                        sout->push_xy( fin->VS(jj)->x[i], fin->VS(jj)->y[i] );
+                        sout->push_xy(fin->VS(jj)->x[i], fin->VS(jj)->y[i]);
             }
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        ScaRemoveConstantZ( fout.get() );
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        ScaRemoveConstantZ(fout.get());
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -659,23 +667,24 @@ void NManip::slices_spawn()
     FileIterator fiter(SFSel::instance()->sel());
     static int njj = 2;
     int njjIn = iask("output will have how many copies of input spectrum", njj);
-    if (njjIn<1) return;
+    if (njjIn < 1)
+        return;
     njj = njjIn;
 
-    while ( const COlo *fin = fiter.next() ) {
-        POlo fout( fin->new_POlo() );
-        fout->log_action( "ms* " + S(njj) );
+    while (const COlo* fin = fiter.next()) {
+        POlo fout(fin->new_POlo());
+        fout->log_action("ms* " + S(njj));
 
-        fout->ZCo.insert( fout->ZCo.begin(), CCoord("no-in-spawn", ""));
+        fout->ZCo.insert(fout->ZCo.begin(), CCoord("no-in-spawn", ""));
 
-        for ( int jj=0; jj<njj; ++jj ) {
-            for ( int j=0; j<fin->nJ(); j++ ) {
-                PSlice sout = fin->copy_slice( j );
-                sout->z.insert( sout->z.begin(), PObjInt( new CObjInt( jj ) ) );
-                fout->V.push_back( move(sout) );
+        for (int jj = 0; jj < njj; ++jj) {
+            for (int j = 0; j < fin->nJ(); j++) {
+                PSlice sout = fin->copy_slice(j);
+                sout->z.insert(sout->z.begin(), PObjInt(new CObjInt(jj)));
+                fout->V.push_back(move(sout));
             }
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -685,79 +694,80 @@ void NManip::slices_spawn()
 void NManip::exchange_x_z()
 {
     FileIterator fiter(SFSel::instance()->selD());
-    while ( const COld *fin = fiter.nextD() ) {
+    while (const COld* fin = fiter.nextD()) {
         int izco = fin->ZCo.size() - 1;
-        if ( izco==(int)-1 )
+        if (izco == (int)-1)
             throw S("no input z coordinate");
-        POld fout( fin->new_POld() );
+        POld fout(fin->new_POld());
         fout->log_action(
-            "msx # exchanging x=" + fin->xco.str_compact() +
-            " with z" + S(izco) + "=" + fin->ZCo[izco].str_compact() );
+            "msx # exchanging x=" + fin->xco.str_compact() + " with z" + S(izco) + "="
+            + fin->ZCo[izco].str_compact());
         fout->xco = fin->ZCo[izco];
         fout->ZCo[izco] = fin->xco;
 
-        if ( fin->nJ()<=0 )
+        if (fin->nJ() <= 0)
             throw S("no spectra in file");
 
         vector<double> zcommon, xcommon;
         int ji, jf;
 
-        for ( ji=0; ji<fin->nJ(); ) {
+        for (ji = 0; ji < fin->nJ();) {
             zcommon.clear();
-            for ( int i=0; i<izco; ++i)
+            for (int i = 0; i < izco; ++i)
                 zcommon.push_back(fin->V[ji]->z[i]->to_r());
 
-            for ( jf=ji+1; jf<fin->nJ(); jf++ )
-                for ( int i=0; i<izco; ++i)
+            for (jf = ji + 1; jf < fin->nJ(); jf++)
+                for (int i = 0; i < izco; ++i)
                     if (fin->V[jf]->z[i]->to_r() != zcommon[i])
                         goto end_group;
         end_group:
 
             // build common grid:
             xcommon.clear();
-            for ( int j=ji; j<jf; ++j )
-                for ( int i=0; i<fin->VS(j)->size(); ++i )
-                    xcommon.push_back( fin->VS(j)->x[i] );
-            sort( xcommon.begin(), xcommon.end() );
+            for (int j = ji; j < jf; ++j)
+                for (int i = 0; i < fin->VS(j)->size(); ++i)
+                    xcommon.push_back(fin->VS(j)->x[i]);
+            sort(xcommon.begin(), xcommon.end());
             triv::make_unique(&xcommon, 1e-180, 1e-20);
 
-            printf("group of spectra %i .. %i has %i different x\n", ji, jf-1, (int)xcommon.size());
+            printf(
+                "group of spectra %i .. %i has %i different x\n", ji, jf - 1, (int)xcommon.size());
 
             int ii = 0; // a guess
-            for ( int i=0; i<xcommon.size(); ++i ) {
-                PSpec sout( new CSpec );
+            for (int i = 0; i < xcommon.size(); ++i) {
+                PSpec sout(new CSpec);
 
-                for( double z: zcommon )
-                    sout->z.push_back( PObjDbl( new CObjDbl(z) ) );
-                sout->z.push_back( PObjDbl( new CObjDbl(xcommon[i]) ) );
+                for (double z : zcommon)
+                    sout->z.push_back(PObjDbl(new CObjDbl(z)));
+                sout->z.push_back(PObjDbl(new CObjDbl(xcommon[i])));
 
                 bool with_dy = true;
-                for ( int j=ji; j<jf; ++j ) {
-                    if ( !( fin->VS(j)->has_dy() ) ) {
+                for (int j = ji; j < jf; ++j) {
+                    if (!(fin->VS(j)->has_dy())) {
                         with_dy = false;
                         break;
                     }
                 }
-                for ( int j=ji; j<jf; ++j ) {
-                    const CSpec* sin = fin->VS( j );
-                    if ( sin->x[ii]!=xcommon[i] ) { // guess failed
-                        for (ii=0; ii<sin->size(); ++ii)
-                            if ( sin->x[ii]==xcommon[i] )
+                for (int j = ji; j < jf; ++j) {
+                    const CSpec* sin = fin->VS(j);
+                    if (sin->x[ii] != xcommon[i]) { // guess failed
+                        for (ii = 0; ii < sin->size(); ++ii)
+                            if (sin->x[ii] == xcommon[i])
                                 break;
                     }
-                    if ( ii<sin->size() ) {
-                        if ( with_dy )
-                            sout->push_xyd( sin->z[izco]->to_r(), sin->y[ii], sin->dy[ii] );
+                    if (ii < sin->size()) {
+                        if (with_dy)
+                            sout->push_xyd(sin->z[izco]->to_r(), sin->y[ii], sin->dy[ii]);
                         else
-                            sout->push_xy( sin->z[izco]->to_r(), sin->y[ii] );
+                            sout->push_xy(sin->z[izco]->to_r(), sin->y[ii]);
                     }
                 }
-                fout->V.push_back( move(sout) );
+                fout->V.push_back(move(sout));
                 ++ii;
             }
             ji = jf;
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -768,23 +778,24 @@ void NManip::slices_sort()
 {
     FileIterator fiter(SFSel::instance()->sel());
     string expr = sask("Sort spectra according to");
-    if (expr=="") return;
-    RNode T = user_xaxparse( expr.c_str() );
+    if (expr == "")
+        return;
+    RNode T = user_xaxparse(expr.c_str());
 
-    while ( const COlo *fin = fiter.next() ) {
-        POlo fout( fin->new_POlo() );
-        fout->log_action( "mso "+expr );
+    while (const COlo* fin = fiter.next()) {
+        POlo fout(fin->new_POlo());
+        fout->log_action("mso " + expr);
 
         int nj = fin->nJ();
         vector<double> v(nj);
-        for (int j=0; j<nj; j++)
-            v[j] = T->tree_point_dbl( fiter.k(), j );
+        for (int j = 0; j < nj; j++)
+            v[j] = T->tree_point_dbl(fiter.k(), j);
 
-        vector<size_t> P = triv::sorted_indices( v );
-        for (int j=0; j<nj; j++)
-            fout->V.push_back( fin->copy_slice( P[j] ) );
+        vector<size_t> P = triv::sorted_indices(v);
+        for (int j = 0; j < nj; j++)
+            fout->V.push_back(fin->copy_slice(P[j]));
 
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -794,24 +805,24 @@ void NManip::slices_sort()
 void NManip::slices_sort_by_z()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while ( const COlo *fin = fiter.next() ) {
-        POlo fout( fin->new_POlo() );
-        fout->log_action( "msoz" );
-        for (int j=0; j<fin->nJ(); j++)
-            fout->V.push_back( fin->copy_slice( j ) );
-        sort( fout->V.begin(), fout->V.end(), []( const PSlice& E1, const PSlice& E2 ) {
-                if( E1->z.size()!=E2->z.size() )
-                    throw S("BUG: inconsistent z.size in CompareZ");
-                int nz = E1->z.size();
-                for( int iz=0; iz<nz; ++iz ){
-                    if    ( E1->z[iz]->to_r() > E2->z[iz]->to_r() )
-                        return false;
-                    if    ( E1->z[iz]->to_r() < E2->z[iz]->to_r() )
-                        return true;
-                }
-                return false;
-            } );
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+    while (const COlo* fin = fiter.next()) {
+        POlo fout(fin->new_POlo());
+        fout->log_action("msoz");
+        for (int j = 0; j < fin->nJ(); j++)
+            fout->V.push_back(fin->copy_slice(j));
+        sort(fout->V.begin(), fout->V.end(), [](const PSlice& E1, const PSlice& E2) {
+            if (E1->z.size() != E2->z.size())
+                throw S("BUG: inconsistent z.size in CompareZ");
+            int nz = E1->z.size();
+            for (int iz = 0; iz < nz; ++iz) {
+                if (E1->z[iz]->to_r() > E2->z[iz]->to_r())
+                    return false;
+                if (E1->z[iz]->to_r() < E2->z[iz]->to_r())
+                    return true;
+            }
+            return false;
+        });
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -824,96 +835,96 @@ void NManip::zcoords_reorder()
     int nzmin, nzmax = 0;
     char mod;
     string com;
-    int num1=-1, num2=-1;  // nonsense initialization to suppress warning
+    int num1 = -1, num2 = -1; // nonsense initialization to suppress warning
 
-    while ( const COlo *fin = fiter.next() ) {
-        nzmax = std::max( (int)nzmax, (int)fin->ZCo.size() );
+    while (const COlo* fin = fiter.next()) {
+        nzmax = std::max((int)nzmax, (int)fin->ZCo.size());
     }
-    if       ( nzmax<=1 )
+    if (nzmax <= 1)
         throw S("nothing to exchange");
-    else if ( nzmax==2 ) {
+    else if (nzmax == 2) {
         mod = 'r';
-        printf( "exchanging two z coordinates\n" );
+        printf("exchanging two z coordinates\n");
         com = "exchanged two z coordinates";
         num1 = 1;
         nzmin = 2;
     } else {
         string sel;
-        sel = wask( "Rotate(r,rr,...), revert(m), exchange(<number>)" );
-        if      ( sel[0]=='r' ) {
+        sel = wask("Rotate(r,rr,...), revert(m), exchange(<number>)");
+        if (sel[0] == 'r') {
             mod = 'r';
             num1 = 1;
-            while ( sel.length() > num1 ) {
-                if ( sel[num1++]!='r' )
+            while (sel.length() > num1) {
+                if (sel[num1++] != 'r')
                     throw S("invalid selection");
             }
             com = "rotated z coordinates by " + S(num1);
             nzmin = 2;
-        } else if ( sel=="m" ) {
+        } else if (sel == "m") {
             mod = 'm';
             com = "reverted z coordinates";
             nzmin = 2;
         } else {
-            if ( sscanf(sel.c_str(), "%i", &num1)!=1 )
+            if (sscanf(sel.c_str(), "%i", &num1) != 1)
                 throw S("invalid selection");
-            if ( num1>=nzmax )
+            if (num1 >= nzmax)
                 throw "no more than " + S(nzmax) + " z coordinates";
-            num2 = iask( "Exchange with coordinate" );
-            if ( num2>=nzmax )
+            num2 = iask("Exchange with coordinate");
+            if (num2 >= nzmax)
                 throw "no more than " + S(nzmax) + " z coordinates";
-            else if ( num1==num2 )
+            else if (num1 == num2)
                 throw S("nothing to exchange");
             mod = 'x';
-            com = "exchanged z coordinates "+S(num1)+" and "+S(num2);
-            nzmin = std::max( num1, num2 )+1;
+            com = "exchanged z coordinates " + S(num1) + " and " + S(num2);
+            nzmin = std::max(num1, num2) + 1;
         }
     }
 
     fiter.reset();
-    while ( const COlo *fin = fiter.next() ) {
-        POlo fout( fin->new_POlo() );
-        fout->log_action( com );
-        for (int j=0; j<fin->nJ(); j++)
-            fout->V.push_back( fin->copy_slice( j ) );
+    while (const COlo* fin = fiter.next()) {
+        POlo fout(fin->new_POlo());
+        fout->log_action(com);
+        for (int j = 0; j < fin->nJ(); j++)
+            fout->V.push_back(fin->copy_slice(j));
 
         int nz = fout->ZCo.size();
-        if      ( nz<nzmin ) {
+        if (nz < nzmin) {
             cout << "WARNING nz<nzmin\n";
-        } else if ( mod=='r' ) {
-            for ( int irot=0; irot<num1; ++irot ) {
-                for ( int iz=1; iz<nz; ++iz ) {
-                    fout->ZCo[iz] = fin->ZCo[iz-1];
+        } else if (mod == 'r') {
+            for (int irot = 0; irot < num1; ++irot) {
+                for (int iz = 1; iz < nz; ++iz) {
+                    fout->ZCo[iz] = fin->ZCo[iz - 1];
                 }
-                fout->ZCo[0] = fin->ZCo[nz-1];
+                fout->ZCo[0] = fin->ZCo[nz - 1];
             }
-        } else if ( mod=='m' ) {
-            for ( int iz=0; iz<nz; ++iz ) {
-                fout->ZCo[iz] = fin->ZCo[nz-1-iz];
+        } else if (mod == 'm') {
+            for (int iz = 0; iz < nz; ++iz) {
+                fout->ZCo[iz] = fin->ZCo[nz - 1 - iz];
             }
         } else { // mod=='x'
             fout->ZCo[num1] = fin->ZCo[num2];
             fout->ZCo[num2] = fin->ZCo[num1];
         }
 
-        for ( int j=0; j<fin->V.size(); j++ ) {
-            if      ( nz<nzmin ) {
+        for (int j = 0; j < fin->V.size(); j++) {
+            if (nz < nzmin) {
                 // do nothing
-            } else if ( mod=='r' ) {
-                for ( int irot=0; irot<num1; ++irot ) {
-                    for ( int iz=1; iz<nz; ++iz )
-                        fout->V[j]->z[iz] = fin->V[j]->z[iz-1];
-                    fout->V[j]->z[0] = fin->V[j]->z[nz-1];
+            } else if (mod == 'r') {
+                for (int irot = 0; irot < num1; ++irot) {
+                    for (int iz = 1; iz < nz; ++iz)
+                        fout->V[j]->z[iz] = fin->V[j]->z[iz - 1];
+                    fout->V[j]->z[0] = fin->V[j]->z[nz - 1];
                 }
-            } else if ( mod=='m' ) {
-                for ( int iz=0; iz<nz; ++iz ) {
-                    fout->V[j]->z[iz] = fin->V[j]->z[nz-1-iz];
+            } else if (mod == 'm') {
+                for (int iz = 0; iz < nz; ++iz) {
+                    fout->V[j]->z[iz] = fin->V[j]->z[nz - 1 - iz];
                 }
-            } else  { // mod=='x'
+            } else { // mod=='x'
                 fout->V[j]->z[num1] = fin->V[j]->z[num2];
                 fout->V[j]->z[num2] = fin->V[j]->z[num1];
             }
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -924,45 +935,45 @@ void NManip::zcoord_delete()
 {
     FileIterator fiter(SFSel::instance()->sel());
     string sel;
-    sel = wask( "List of z coordinates to be removed" );
-    if ( sel=="" )
+    sel = wask("List of z coordinates to be removed");
+    if (sel == "")
         return;
-    RNode Tsel = user_xaxparse( sel.c_str() );
+    RNode Tsel = user_xaxparse(sel.c_str());
 
-    while ( const COlo *fin = fiter.next() ) {
-        POlo fout( fin->new_POlo() );
-        fout->log_action( "mz- "+sel );
+    while (const COlo* fin = fiter.next()) {
+        POlo fout(fin->new_POlo());
+        fout->log_action("mz- " + sel);
 
-        if ( !fin->nJ() )
+        if (!fin->nJ())
             throw S("BUG: no spectra");
-        for ( int j=0; j<fin->nJ(); j++ )
-            fout->V.push_back( fin->copy_slice( j ) );
+        for (int j = 0; j < fin->nJ(); j++)
+            fout->V.push_back(fin->copy_slice(j));
 
-        RObjVecInt vsel = Tsel->to_index_list( fin->ZCo.size() );
+        RObjVecInt vsel = Tsel->to_index_list(fin->ZCo.size());
         if (!vsel)
-            throw "Invalid index list '"+sel+"'; max index is "+S(fin->ZCo.size()-1);
-        if ( fin->nJ()>1 && fin->ZCo.size()-vsel->size()<1 )
+            throw "Invalid index list '" + sel + "'; max index is " + S(fin->ZCo.size() - 1);
+        if (fin->nJ() > 1 && fin->ZCo.size() - vsel->size() < 1)
             throw "Cannot delete all z coordinates since there is more than one slice";
         vector<int> lis = vsel->v;
-        sort( lis.begin(), lis.end() );
-        reverse( lis.begin(), lis.end() );
+        sort(lis.begin(), lis.end());
+        reverse(lis.begin(), lis.end());
 
         int nRPar = fout->RPar.size();
-        for ( int iv=0; iv<lis.size(); ++iv ) {
+        for (int iv = 0; iv < lis.size(); ++iv) {
             int iz = lis[iv];
-            fout->RPar.insert( fout->RPar.begin()+nRPar, fout->ZCo[iz] );
-            fout->ZCo.erase( fout->ZCo.begin()+iz );
+            fout->RPar.insert(fout->RPar.begin() + nRPar, fout->ZCo[iz]);
+            fout->ZCo.erase(fout->ZCo.begin() + iz);
             double zval = 0;
-            for ( int j=0; j<fin->nJ(); j++ ) {
-                auto pz = PCAST<const CObjNum>(fin->z(j,iz));
-                if( !pz )
-                    throw "z"+S(iz)+" is not a number";
+            for (int j = 0; j < fin->nJ(); j++) {
+                auto pz = PCAST<const CObjNum>(fin->z(j, iz));
+                if (!pz)
+                    throw "z" + S(iz) + " is not a number";
                 zval += pz->to_r();
-                fout->V[j]->z.erase( fout->V[j]->z.begin()+iz );
+                fout->V[j]->z.erase(fout->V[j]->z.begin() + iz);
             }
             fout->RPar[nRPar].val = zval / fin->nJ();
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -972,33 +983,33 @@ void NManip::zcoord_delete()
 void NManip::slices_break()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while ( const COlo *fin = fiter.next() ) {
-        if ( !(fin->ZCo.size()) )
+    while (const COlo* fin = fiter.next()) {
+        if (!(fin->ZCo.size()))
             throw S("no z coordinate");
         CCoord zco = fin->ZCo[0];
 
         // intermediate file, on which output files will be based:
-        POlo ftmp( fin->new_POlo() );
+        POlo ftmp(fin->new_POlo());
         ftmp->V.clear();
-        ftmp->log_action( "msb # eliminating " + zco.str_compact() );
-        ftmp->ZCo.erase( ftmp->ZCo.begin() );
+        ftmp->log_action("msb # eliminating " + zco.str_compact());
+        ftmp->ZCo.erase(ftmp->ZCo.begin());
         int jout = 0;
 
-        for ( int j=0; j<fin->nJ(); ) {
-            POlo fout( ftmp->new_POlo() );
-            fout->log_action( "msb" );
-            double zval = fin->z(j,0)->to_r();
-            fout->RPar.push_back( CParam( zco, zval ) );
+        for (int j = 0; j < fin->nJ();) {
+            POlo fout(ftmp->new_POlo());
+            fout->log_action("msb");
+            double zval = fin->z(j, 0)->to_r();
+            fout->RPar.push_back(CParam(zco, zval));
             do {
-                PSlice sout( fin->copy_slice(j) );
-                sout->z.erase( sout->z.begin() );
-                fout->V.push_back( move(sout) );
-            } while ( ++j<fin->nJ() && fin->z(j,0)->to_r()==zval );
+                PSlice sout(fin->copy_slice(j));
+                sout->z.erase(sout->z.begin());
+                fout->V.push_back(move(sout));
+            } while (++j < fin->nJ() && fin->z(j, 0)->to_r() == zval);
             fout->name += "_" + S(jout++);
-            SMem::instance()->mem_store( move(fout) );
+            SMem::instance()->mem_store(move(fout));
         }
-        if ( SMem::instance()->overwrite )
-            SMem::instance()->mem_del( fiter.k() );
+        if (SMem::instance()->overwrite)
+            SMem::instance()->mem_del(fiter.k());
     }
 }
 
@@ -1009,29 +1020,29 @@ void NManip::slices_break()
 
 //! Merge files, concatenating spectra/curves.
 
-void NManip::files_merge( const string& opts )
+void NManip::files_merge(const string& opts)
 {
-    if ( SFSel::instance()->sel().size()<=1 )
+    if (SFSel::instance()->sel().size() <= 1)
         throw S("won't merge less than 2 files");
 
     FileIterator fiter(SFSel::instance()->sel());
     // parse options:
     bool add_zk = false;
-    if ( opts=="+" )
+    if (opts == "+")
         add_zk = true;
 
     // Determine file type, which must be the same for all input files.
-    const COlo *fin = fiter.next();
+    const COlo* fin = fiter.next();
     POlo fout;
-    if        ( dynamic_cast<const COld*>(fin) ) {
-        fout = POld( new COld() );
-        while ( fin = fiter.next() )
-            if ( !dynamic_cast<const COld*>(fin) )
+    if (dynamic_cast<const COld*>(fin)) {
+        fout = POld(new COld());
+        while (fin = fiter.next())
+            if (!dynamic_cast<const COld*>(fin))
                 throw S("cannot merge data and curve file");
-    } else if ( dynamic_cast<const COlc*>(fin) ) {
-        fout = POlc( new COlc() );
-        while ( fin = fiter.next() )
-            if ( !dynamic_cast<const COlc*>(fin) )
+    } else if (dynamic_cast<const COlc*>(fin)) {
+        fout = POlc(new COlc());
+        while (fin = fiter.next())
+            if (!dynamic_cast<const COlc*>(fin))
                 throw S("cannot merge curve and data file");
     } else
         throw S("BUG: unexpected POlo type");
@@ -1042,8 +1053,8 @@ void NManip::files_merge( const string& opts )
     fout->xco = fin->xco;
     fout->yco = fin->yco;
     fout->ZCo = fin->ZCo;
-    if ( const COlc *fc = dynamic_cast<const COlc*>(fin) ) {
-        COlc *fcout = dynamic_cast<COlc*>(fout.get());
+    if (const COlc* fc = dynamic_cast<const COlc*>(fin)) {
+        COlc* fcout = dynamic_cast<COlc*>(fout.get());
         fcout->expr = fc->expr;
         fcout->evaMode = fc->evaMode;
         fcout->scrInpMode = fc->scrInpMode;
@@ -1051,54 +1062,54 @@ void NManip::files_merge( const string& opts )
         fcout->PCo = fc->PCo;
         fcout->T = fc->T;
     }
-    while ( fin = fiter.next() ) {
-        if ( fin->xco != fout->xco )
+    while (fin = fiter.next()) {
+        if (fin->xco != fout->xco)
             throw S("different x coordinates");
-        if ( fin->yco != fout->yco )
+        if (fin->yco != fout->yco)
             throw S("different y coordinates");
-        if ( fin->ZCo.size() != fout->ZCo.size() )
+        if (fin->ZCo.size() != fout->ZCo.size())
             throw S("different numer of z coordinates");
-        for ( int i=0; i<fout->ZCo.size(); ++i )
-            if ( fin->ZCo[i] != fout->ZCo[i] )
-                throw "different z"+S(i)+" coordinate";
-        if ( const COlc *fc = dynamic_cast<const COlc*>(fin) ) {
-            const COlc *fcout = dynamic_cast<const COlc*>(fout.get());
-            if ( fc->expr != fcout->expr  )
+        for (int i = 0; i < fout->ZCo.size(); ++i)
+            if (fin->ZCo[i] != fout->ZCo[i])
+                throw "different z" + S(i) + " coordinate";
+        if (const COlc* fc = dynamic_cast<const COlc*>(fin)) {
+            const COlc* fcout = dynamic_cast<const COlc*>(fout.get());
+            if (fc->expr != fcout->expr)
                 throw S("different curve definitions");
-            if ( fc->evaMode != fcout->evaMode )
+            if (fc->evaMode != fcout->evaMode)
                 throw S("different curve evaluation mode");
-            if ( fc->nP != fcout->nP )
+            if (fc->nP != fcout->nP)
                 throw S("different number of curve parameters");
-            if ( fc->PCo.size() != fcout->PCo.size() )
+            if (fc->PCo.size() != fcout->PCo.size())
                 throw S("inconsistent number of curve parameters");
         }
     }
 
     // check RPar, and prepare move to z if they differ:
     fiter.reset();
-    vector<CParam> RPar( fiter.next()->RPar );
+    vector<CParam> RPar(fiter.next()->RPar);
     int nR = RPar.size();
-    vector<bool> RParDiff( nR, false );
-    while ( (fin = fiter.next()) ) {
-        if ( fin->RPar.size() != nR )
+    vector<bool> RParDiff(nR, false);
+    while ((fin = fiter.next())) {
+        if (fin->RPar.size() != nR)
             throw S("different numer of r parameters");
-        for ( int i=0; i<nR; ++i )
-            if (fin->RPar[i].Co != RPar[i].Co )
+        for (int i = 0; i < nR; ++i)
+            if (fin->RPar[i].Co != RPar[i].Co)
                 throw S("different r parameter");
-        for ( int i=0; i<nR; ++i )
-            if (fin->RPar[i].val != RPar[i].val )
+        for (int i = 0; i < nR; ++i)
+            if (fin->RPar[i].val != RPar[i].val)
                 RParDiff[i] = true;
     }
     auto zinsert = fout->ZCo.begin();
-    for ( int i=0; i<nR; ++i ) {
-        if ( RParDiff[i] )
-            fout->ZCo.insert( zinsert++, RPar[i].Co );
+    for (int i = 0; i < nR; ++i) {
+        if (RParDiff[i])
+            fout->ZCo.insert(zinsert++, RPar[i].Co);
         else
-            fout->RPar.push_back( RPar[i] );
+            fout->RPar.push_back(RPar[i]);
     }
-    if ( add_zk || !fout->ZCo.size() ) {
+    if (add_zk || !fout->ZCo.size()) {
         // there must be at least one z coordinate
-        fout->ZCo.insert( fout->ZCo.begin(), CCoord("number-of-input-file", "") );
+        fout->ZCo.insert(fout->ZCo.begin(), CCoord("number-of-input-file", ""));
         add_zk = true;
     }
 
@@ -1106,38 +1117,38 @@ void NManip::files_merge( const string& opts )
     string fnam;
     fiter.reset();
     fnam = fiter.next()->name;
-    while ( fin = fiter.next() ) {
-        int n2=fin->name.size();
-        if ( n2<fnam.size() )
-            fnam.erase( fnam.begin()+n2, fnam.end() );
-        for ( int i=0; i<fnam.size(); ++i )
-            if (fnam[i]!=(fin->name)[i])
+    while (fin = fiter.next()) {
+        int n2 = fin->name.size();
+        if (n2 < fnam.size())
+            fnam.erase(fnam.begin() + n2, fnam.end());
+        for (int i = 0; i < fnam.size(); ++i)
+            if (fnam[i] != (fin->name)[i])
                 fnam[i] = ' ';
     }
-    for ( auto cp = fnam.begin(); cp != fnam.end(); ++cp )
-        if (*cp==' ')
+    for (auto cp = fnam.begin(); cp != fnam.end(); ++cp)
+        if (*cp == ' ')
             fnam.erase(cp--);
     if (fnam == "") {
-        static int callNo=0;
-        fnam = str( format( "merge%03u" ) % callNo++ );
+        static int callNo = 0;
+        fnam = str(format("merge%03u") % callNo++);
     }
     fout->name = fnam;
 
     // doc lines:
-    fout->log_action( "mfj # " + fnam + " is merger of:" );
+    fout->log_action("mfj # " + fnam + " is merger of:");
     fiter.reset();
-    const COlo *f1 = fiter.next();
+    const COlo* f1 = fiter.next();
     fout->log_action("- " + f1->name);
-    for ( int i=0; i<f1->lDoc.size(); ++i )
+    for (int i = 0; i < f1->lDoc.size(); ++i)
         fout->log_action("  " + f1->lDoc[i]);
-    while ( (fin = fiter.next()) ) {
+    while ((fin = fiter.next())) {
         fout->log_action("- " + fin->name);
         string line = "  ";
-        for ( int i=0; i<fin->lDoc.size(); ++i ) {
-            if ( i<f1->lDoc.size() && fin->lDoc[i]==f1->lDoc[i] ) {
+        for (int i = 0; i < fin->lDoc.size(); ++i) {
+            if (i < f1->lDoc.size() && fin->lDoc[i] == f1->lDoc[i]) {
                 line += "=";
             } else {
-                fout->log_action( line + fin->lDoc[i] );
+                fout->log_action(line + fin->lDoc[i]);
                 line = "  ";
             }
         }
@@ -1145,24 +1156,24 @@ void NManip::files_merge( const string& opts )
 
     // now merge the Zentries, and add new z's:
     fiter.reset();
-    while ( fin = fiter.next() ) {
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            PSlice sout( fin->copy_slice(j) );
+    while (fin = fiter.next()) {
+        for (int j = 0; j < fin->nJ(); j++) {
+            PSlice sout(fin->copy_slice(j));
             auto zinsert = sout->z.begin();
-            for ( int i=0; i<nR; ++i )
-                if ( RParDiff[i] )
-                    sout->z.insert( zinsert++, PObjDbl( new CObjDbl( fin->RPar[i].val ) ) );
-            if ( add_zk )
-                sout->z.insert( sout->z.begin(), PObjInt( new CObjInt( fiter.iteration() ) ) );
-            fout->V.push_back( move(sout) );
+            for (int i = 0; i < nR; ++i)
+                if (RParDiff[i])
+                    sout->z.insert(zinsert++, PObjDbl(new CObjDbl(fin->RPar[i].val)));
+            if (add_zk)
+                sout->z.insert(sout->z.begin(), PObjInt(new CObjInt(fiter.iteration())));
+            fout->V.push_back(move(sout));
         }
     }
 
-    if ( SMem::instance()->overwrite ) {
+    if (SMem::instance()->overwrite) {
         SFSel::instance()->sel_delete();
         SMem::instance()->overwrite = false; // since we modified the file selection
     }
-    SMem::instance()->mem_store( move(fout) );
+    SMem::instance()->mem_store(move(fout));
 }
 
 
@@ -1172,38 +1183,38 @@ void NManip::files_merge_pointwise()
 {
     FileIterator fiter(SFSel::instance()->selD());
     // Copy first input file:
-    const COld *fin = fiter.nextD();
-    POld fout( fin->new_POld() );
-    fout->copy_mainvec( fin );
+    const COld* fin = fiter.nextD();
+    POld fout(fin->new_POld());
+    fout->copy_mainvec(fin);
 
     // Merge further input files:
-    while ( fin = fiter.nextD() ) {
-        if ( fin->nJ() != fout->nJ() )
+    while (fin = fiter.nextD()) {
+        if (fin->nJ() != fout->nJ())
             throw S("different # spectra");
-        if ( fin->xco != fout->xco || fin->yco != fout->yco )
+        if (fin->xco != fout->xco || fin->yco != fout->yco)
             throw S("different x/y coordinates");
 
-        for ( int j=0; j<fout->nJ(); ++j ) {
-            const CSpec *sin = fin->VS(j);
+        for (int j = 0; j < fout->nJ(); ++j) {
+            const CSpec* sin = fin->VS(j);
             CSpec* sout = fout->VS(j);
-            if ( sin->z.size() != sout->z.size() )
+            if (sin->z.size() != sout->z.size())
                 throw S("different # z entries");
-            for ( int i=0; i<sout->z.size(); ++i )
-                if ( sin->z[i] != sout->z[i] )
+            for (int i = 0; i < sout->z.size(); ++i)
+                if (sin->z[i] != sout->z[i])
                     throw S("different # z values");
-            if ( sin->has_dy() ^ sout->has_dy() )
+            if (sin->has_dy() ^ sout->has_dy())
                 throw S("different on/off status of error bars");
-            for ( int i=0; i<sin->size(); ++i ) {
-                if ( sin->has_dy() )
-                    sout->push_xyd( sin->x[i], sin->y[i], sin->dy[i] );
+            for (int i = 0; i < sin->size(); ++i) {
+                if (sin->has_dy())
+                    sout->push_xyd(sin->x[i], sin->y[i], sin->dy[i]);
                 else
-                    sout->push_xy( sin->x[i], sin->y[i] );
+                    sout->push_xy(sin->x[i], sin->y[i]);
             }
         }
-        fout->log_action( "appended pointwise " + fin->name );
+        fout->log_action("appended pointwise " + fin->name);
     }
 
-    SMem::instance()->mem_store( move(fout) );
+    SMem::instance()->mem_store(move(fout));
 }
 
 
@@ -1215,51 +1226,50 @@ void NManip::files_merge_pointwise()
 
 void NManip::interpolate()
 {
-    string expr = wask( "Interpolate in reference file" );
-    if (expr=="")
+    string expr = wask("Interpolate in reference file");
+    if (expr == "")
         return;
-    RNode T = user_xaxparse( expr.c_str() );
+    RNode T = user_xaxparse(expr.c_str());
 
     FileIterator fiter(SFSel::instance()->selD());
-    while ( const COld *fin = fiter.nextD() ) {
+    while (const COld* fin = fiter.nextD()) {
         int k = fiter.k();
-        CContext ctx( k );
-        int k2 = T->tree_val_idx( ctx, "K" );
-        COld *f2 = SMem::instance()->mem_get_D( k2 );
-
-        POld fout( fin->new_POld() );
-        fout->copy_mainvec( fin );
-        fout->log_action( "mi " + S(k2) );
-
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin ->VS(j);
-            CSpec* s2  = f2  ->VS(j);
-            CSpec* sout= fout->VS(j);
+        CContext ctx(k);
+        int k2 = T->tree_val_idx(ctx, "K");
+        COld* f2 = SMem::instance()->mem_get_D(k2);
+
+        POld fout(fin->new_POld());
+        fout->copy_mainvec(fin);
+        fout->log_action("mi " + S(k2));
+
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            CSpec* s2 = f2->VS(j);
+            CSpec* sout = fout->VS(j);
             int i2 = 0;
-            if ( sin->y[0]<s2->x[0] )
-                throw "File "+S(k)+", spec "+S(j)+": y[0] not in reference";
-            for ( int i=0; i<sin->size(); i++ ) {
+            if (sin->y[0] < s2->x[0])
+                throw "File " + S(k) + ", spec " + S(j) + ": y[0] not in reference";
+            for (int i = 0; i < sin->size(); i++) {
                 double p = sin->y[i];
-                if ( p==s2->x[i2] ) {
+                if (p == s2->x[i2]) {
                     sout->y[i] = s2->y[i2];
                     continue;
                 }
-                while ( i2+1<s2->size() ) {
-                    if ( p<=s2->x[i2+1] )
+                while (i2 + 1 < s2->size()) {
+                    if (p <= s2->x[i2 + 1])
                         goto found_i2;
                     ++i2;
                 }
-                throw "File "+S(k)+", spec "+S(j)+": y["+S(i)+
-                    "] not in reference";
+                throw "File " + S(k) + ", spec " + S(j) + ": y[" + S(i) + "] not in reference";
             found_i2:
-                double step = s2->x[i2+1] - s2->x[i2];
-                if ( step <= 0 )
+                double step = s2->x[i2 + 1] - s2->x[i2];
+                if (step <= 0)
                     throw S("Reference not monotonous");
-                sout->y[i] = ( s2->y[i2]*(s2->x[i2+1]-p) +
-                               s2->y[i2+1]*(p-s2->x[i2]) ) / step;
+                sout->y[i] =
+                    (s2->y[i2] * (s2->x[i2 + 1] - p) + s2->y[i2 + 1] * (p - s2->x[i2])) / step;
             }
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -1273,63 +1283,62 @@ void NManip::interpolate()
 void NManip::make_histogram()
 {
     // Determine range:
-    double xmin=0, xmax=0; // initialized to prevent warning
+    double xmin = 0, xmax = 0; // initialized to prevent warning
     int npts = 0;
     FileIterator fiter(SFSel::instance()->selD());
-    while ( const COld *fin = fiter.nextD() ) {
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin ->VS(j);
-            for ( int i=0; i<sin->size(); i++ ) {
+    while (const COld* fin = fiter.nextD()) {
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            for (int i = 0; i < sin->size(); i++) {
                 double x = sin->x[i];
-                if ( !npts ) {
+                if (!npts) {
                     xmin = x;
                     xmax = x;
-                } else if ( x<xmin ) {
+                } else if (x < xmin) {
                     xmin = x;
-                } else if ( x>xmax ) {
+                } else if (x > xmax) {
                     xmax = x;
                 }
                 ++npts;
             }
         }
     }
-    cout << "there are " << npts << " points extending from " << xmin <<
-        " to " << xmax << "\n";
+    cout << "there are " << npts << " points extending from " << xmin << " to " << xmax << "\n";
 
     // Obtain number of bins:
     static int nbin = 32;
-    if ( npts<nbin/3 ) // adapt default
-        npts = nbin/4;
-    nbin = iask( "Number of bins", nbin );
-    if ( nbin<2 )
+    if (npts < nbin / 3) // adapt default
+        npts = nbin / 4;
+    nbin = iask("Number of bins", nbin);
+    if (nbin < 2)
         throw S("at least 2 bins required");
 
     // Set output grid:
     vector<double> xout(nbin);
-    double dx = (xmax-xmin)/(nbin-1);
-    for ( int i=0; i<nbin; ++i )
-        xout[i] = xmin + dx*i;
+    double dx = (xmax - xmin) / (nbin - 1);
+    for (int i = 0; i < nbin; ++i)
+        xout[i] = xmin + dx * i;
 
     // Create and fill output histograms:
     fiter.reset();
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
-        fout->log_action("mhm " + S(nbin) );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
+        fout->log_action("mhm " + S(nbin));
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin->VS(j);
-            PSpec sout( new CSpec() );
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            PSpec sout(new CSpec());
             sout->z = sin->z;
             sout->x = xout;
             sout->y = vector<double>(nbin, 0.);
-            for ( int i=0; i<sin->size(); ++i ) {
-                int iout = lrint( floor((sin->x[i]-xmin)/dx+0.5 ) );
-                if ( iout<0 || iout>=nbin )
-                    throw "BUG: invalid iout="+S(iout)+" for y="+S(sin->x[i]);
+            for (int i = 0; i < sin->size(); ++i) {
+                int iout = lrint(floor((sin->x[i] - xmin) / dx + 0.5));
+                if (iout < 0 || iout >= nbin)
+                    throw "BUG: invalid iout=" + S(iout) + " for y=" + S(sin->x[i]);
                 sout->y[iout] += sin->y[i];
             }
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
diff --git a/pub/lib/manip.hpp b/pub/lib/manip.hpp
index ab1613482594c99df5d09a1fdfa53631b68b96c0..0e169e07240f2c935d297d4942433bac4c37f741 100644
--- a/pub/lib/manip.hpp
+++ b/pub/lib/manip.hpp
@@ -9,30 +9,31 @@
 
 //! Manipulate data (select, bin, sort, ...)
 
-namespace NManip {
-    void freeze_slices();
-    void unfreeze_all_slices();
-    void points_select( bool sel_del );
-    void points_rebin();
-    void points_rebin_by_factor();
-    void points_rebin_by_err( const string& subcmd );
-    void points_rebin_duplicates();
-    void points_break_by_factor();
-    void points_sort();
-    void points_symmetrize();
-    void points_remove_err();
-    void slices_select( bool sel_del );
-    void slices_rebin();
-    void slices_merge();
-    void slices_break();
-    void slices_spawn();
-    void zcoords_reorder();
-    void zcoord_delete();
-    void slices_sort();
-    void slices_sort_by_z();
-    void exchange_x_z();
-    void make_histogram();
-    void files_merge( const string& opts );
-    void files_merge_pointwise();
-    void interpolate();
+namespace NManip
+{
+void freeze_slices();
+void unfreeze_all_slices();
+void points_select(bool sel_del);
+void points_rebin();
+void points_rebin_by_factor();
+void points_rebin_by_err(const string& subcmd);
+void points_rebin_duplicates();
+void points_break_by_factor();
+void points_sort();
+void points_symmetrize();
+void points_remove_err();
+void slices_select(bool sel_del);
+void slices_rebin();
+void slices_merge();
+void slices_break();
+void slices_spawn();
+void zcoords_reorder();
+void zcoord_delete();
+void slices_sort();
+void slices_sort_by_z();
+void exchange_x_z();
+void make_histogram();
+void files_merge(const string& opts);
+void files_merge_pointwise();
+void interpolate();
 }
diff --git a/pub/lib/mem.cpp b/pub/lib/mem.cpp
index 89b7605913cd2bf3a317ccfa838f60589382cb29..f6d2a5be90013507385d12ab877896ca2ea0a16c 100644
--- a/pub/lib/mem.cpp
+++ b/pub/lib/mem.cpp
@@ -9,10 +9,10 @@
 
 #include "defs.hpp"
 
-#include "olf.hpp"
-#include "mem.hpp"
 #include "fsel.hpp"
 #include "loop.hpp"
+#include "mem.hpp"
+#include "olf.hpp"
 
 
 //**************************************************************************************************
@@ -20,35 +20,32 @@
 //**************************************************************************************************
 
 //! Returns number of files in online memory.
-int SMem::mem_size() const
-{
-    return MOM.size();
-}
+int SMem::mem_size() const { return MOM.size(); }
 
 //! Return pointer to file with index k.
-COlo* SMem::mem_get( int k ) const
+COlo* SMem::mem_get(int k) const
 {
-    if ( k<0 )
+    if (k < 0)
         throw "negative number " + S(k) + " cannot be a file index";
-    if ( k>=MOM.size() )
+    if (k >= MOM.size())
         throw "file index " + S(k) + " not in online memory";
     return MOM[k].get();
 }
 
 //! Return pointer to file with index k, provided it contains data.
-COld* SMem::mem_get_D( int k ) const
+COld* SMem::mem_get_D(int k) const
 {
-    COld *ret = dynamic_cast<COld*>( mem_get( k ) );
-    if( !ret )
+    COld* ret = dynamic_cast<COld*>(mem_get(k));
+    if (!ret)
         throw "file " + S(k) + " is not a data file";
     return ret;
 }
 
 //! Return pointer to file with index k, provided it contains curves.
-COlc* SMem::mem_get_C( int k ) const
+COlc* SMem::mem_get_C(int k) const
 {
-    COlc *ret = dynamic_cast<COlc*>( mem_get( k ) );
-    if( !ret )
+    COlc* ret = dynamic_cast<COlc*>(mem_get(k));
+    if (!ret)
         throw "file " + S(k) + " is not a curve file";
     return ret;
 }
@@ -59,26 +56,26 @@ COlc* SMem::mem_get_C( int k ) const
 //**************************************************************************************************
 
 //! Store file f in online memory. If overwrite and k!=-1, overwrite file k.
-void SMem::mem_store( POlo&& f, int k )
+void SMem::mem_store(POlo&& f, int k)
 {
     f->check_integrity();
-    if( overwrite && k!=-1 ){
+    if (overwrite && k != -1) {
         // replace file k
-        if( k>=MOM.size() )
+        if (k >= MOM.size())
             throw S("BUG: cannot overwrite inexistent file");
-        f.swap( MOM[k] );
+        f.swap(MOM[k]);
     } else {
         // append at end of online memory
-        MOM.push_back( POlo() );
-        f.swap( MOM.back() );
-        SFSel::instance()->sel_push_back( MOM.size()-1 );
+        MOM.push_back(POlo());
+        f.swap(MOM.back());
+        SFSel::instance()->sel_push_back(MOM.size() - 1);
     }
 }
 
 //! Remove file k from online memory.
-void SMem::mem_del( int k )
+void SMem::mem_del(int k)
 {
-    MOM.erase(MOM.begin()+k);
+    MOM.erase(MOM.begin() + k);
     /* TODO update old SFSel::instance()->selection(s) after file deletion
        for( int i=0; i<FSFSel::instance()->SelOld.size(); ++i )
        if ( FSFSel::instance()->SelOld[i] > k )
@@ -90,10 +87,10 @@ void SMem::mem_del( int k )
 void SMem::mem_copy()
 {
     FileIterator fiter(SFSel::instance()->sel());
-    while ( const COlo *fin = fiter.next() ){
-        POlo fout( fin->new_POlo() );
-        fout->copy_mainvec( fin );
-        mem_store( move(fout) );
+    while (const COlo* fin = fiter.next()) {
+        POlo fout(fin->new_POlo());
+        fout->copy_mainvec(fin);
+        mem_store(move(fout));
     }
 }
 
diff --git a/pub/lib/mem.hpp b/pub/lib/mem.hpp
index 8ce73ee1dc9f075a7c48f4e1d5b92a41aa879c34..6be9b8458325d057b92b2409ee3782f1ae2f95f0 100644
--- a/pub/lib/mem.hpp
+++ b/pub/lib/mem.hpp
@@ -11,22 +11,24 @@
 
 //! Online memory and the default file selection.
 
-class SMem : public triv::ISingleton<SMem> {
+class SMem : public triv::ISingleton<SMem>
+{
 private:
     vector<POlo> MOM;
     vector<POlo> BAK;
+
 public:
     bool overwrite;
 
     // Read from online memory:
-    COlo* mem_get  ( int k ) const;
-    COld* mem_get_D( int k ) const;
-    COlc* mem_get_C( int k ) const;
+    COlo* mem_get(int k) const;
+    COld* mem_get_D(int k) const;
+    COlc* mem_get_C(int k) const;
     int mem_size() const;
 
     // Modify online memory (file selection is changed accordingly):
-    void mem_store( POlo&& olo, int k=-1 );
-    void mem_del( int k );
+    void mem_store(POlo&& olo, int k = -1);
+    void mem_del(int k);
     void mem_xchange();
     void mem_copy();
 };
diff --git a/pub/lib/node.cpp b/pub/lib/node.cpp
index 484bbd48be0b90f43e549bb7f74685db3b1c4460..658f99480d46cd962c0d8e464375951514c02615 100644
--- a/pub/lib/node.cpp
+++ b/pub/lib/node.cpp
@@ -11,18 +11,18 @@
 
 #include <algorithm>
 
-#include "olf.hpp"
+#include "curve.hpp"
+#include "expr.hpp"
+#include "fregistry.hpp"
+#include "func.hpp"
 #include "mem.hpp"
+#include "node.hpp"
+#include "obj.hpp"
+#include "olf.hpp"
+#include "reduce_curv.hpp"
+#include "reduce_spec.hpp"
 #include "slice.hpp"
 #include "variables.hpp"
-#include "func.hpp"
-#include "fregistry.hpp"
-#include "reduce_spec.hpp"
-#include "reduce_curv.hpp"
-#include "obj.hpp"
-#include "expr.hpp"
-#include "node.hpp"
-#include "curve.hpp"
 
 extern bool allow_slow_conv; // set in curve.cpp
 
@@ -33,36 +33,36 @@ extern bool allow_slow_conv; // set in curve.cpp
 
 bool CNodeWithArgs::has_dummy() const
 {
-    return std::any_of( arg.begin(), arg.end(), [](RNode a){ return a && a->has_dummy(); } );
+    return std::any_of(arg.begin(), arg.end(), [](RNode a) { return a && a->has_dummy(); });
 }
 
 bool CNodeWithArgs::has_conv() const
 {
-    return std::any_of( arg.begin(), arg.end(), [](RNode a){ return a && a->has_conv(); } );
+    return std::any_of(arg.begin(), arg.end(), [](RNode a) { return a && a->has_conv(); });
 }
 
 int CNodeWithArgs::npar() const
 {
     int ret = 0;
-    for ( RNode a: arg )
-        if( a )
-            ret = std::max( ret, a->npar() );
+    for (RNode a : arg)
+        if (a)
+            ret = std::max(ret, a->npar());
     return ret;
 }
 
 bool CNodeWithArgs::k_dependent() const
 {
-    return std::any_of( arg.begin(), arg.end(), [](RNode a){ return a && a->k_dependent(); } );
+    return std::any_of(arg.begin(), arg.end(), [](RNode a) { return a && a->k_dependent(); });
 }
 
 bool CNodeWithArgs::j_dependent() const
 {
-    return std::any_of( arg.begin(), arg.end(), [](RNode a){ return a && a->j_dependent(); } );
+    return std::any_of(arg.begin(), arg.end(), [](RNode a) { return a && a->j_dependent(); });
 }
 
 bool CNodeWithArgs::i_dependent() const
 {
-    return std::any_of( arg.begin(), arg.end(), [](RNode a){ return a && a->i_dependent(); } );
+    return std::any_of(arg.begin(), arg.end(), [](RNode a) { return a && a->i_dependent(); });
 }
 
 
@@ -70,21 +70,15 @@ bool CNodeWithArgs::i_dependent() const
 //* CNodeFun: function/operator node
 //**************************************************************************************************
 
-CNodeFun1::CNodeFun1( const CFunc* _fu, RNode _a0 )
-    : CNodeFun(1, _fu)
-{
-    arg[0] = _a0;
-}
+CNodeFun1::CNodeFun1(const CFunc* _fu, RNode _a0) : CNodeFun(1, _fu) { arg[0] = _a0; }
 
-CNodeFun2::CNodeFun2( const CFunc* _fu, RNode _a0, RNode _a1 )
-    : CNodeFun(2, _fu)
+CNodeFun2::CNodeFun2(const CFunc* _fu, RNode _a0, RNode _a1) : CNodeFun(2, _fu)
 {
     arg[0] = _a0;
     arg[1] = _a1;
 }
 
-CNodeFun3::CNodeFun3( const CFunc* _fu, RNode _a0, RNode _a1, RNode _a2 )
-    : CNodeFun(3, _fu)
+CNodeFun3::CNodeFun3(const CFunc* _fu, RNode _a0, RNode _a1, RNode _a2) : CNodeFun(3, _fu)
 {
     arg[0] = _a0;
     arg[1] = _a1;
@@ -93,184 +87,180 @@ CNodeFun3::CNodeFun3( const CFunc* _fu, RNode _a0, RNode _a1, RNode _a2 )
 
 //! Returns the result of function evaluation for given arguments.
 
-RObj CNodeFun::tree_val( const CContext& ctx ) const
+RObj CNodeFun::tree_val(const CContext& ctx) const
 {
     string basetypes;
     const CTypedFunc* tf = nullptr;
     try {
-         // evaluate arguments, determine if all results are scalar.
+        // evaluate arguments, determine if all results are scalar.
         vector<RObj> pa(narg);
         basetypes = "";
         bool is_scalar = true;
-        for ( int iarg=0; iarg<narg; ++iarg ) {
-            pa[iarg] = arg[iarg]->tree_val( ctx );
+        for (int iarg = 0; iarg < narg; ++iarg) {
+            pa[iarg] = arg[iarg]->tree_val(ctx);
             basetypes += pa[iarg]->base_type();
-            if ( pa[iarg]->is_vec() )
+            if (pa[iarg]->is_vec())
                 is_scalar = false;
         }
 
-        tf = fu->find_tyfu( basetypes, ctx.want_error );
-        if( !tf )
+        tf = fu->find_tyfu(basetypes, ctx.want_error);
+        if (!tf)
             throw "function " + fu->tag + " not implemented for argument types " + basetypes;
         funcPtr f = tf->f;
 
-        if( is_scalar ) {
-            if        ( tf->outtype=="0" ) {
-                if       ( tf->intypes=="i" )
-                    (*(func_0_i)(f))( pa[0]->to_i() );
-                else if  ( tf->intypes=="d" )
-                    (*(func_0_d)(f))( pa[0]->to_r() );
-                else if  ( tf->intypes=="s" )
-                    (*(func_0_s)(f))( pa[0]->to_s() );
+        if (is_scalar) {
+            if (tf->outtype == "0") {
+                if (tf->intypes == "i")
+                    (*(func_0_i)(f))(pa[0]->to_i());
+                else if (tf->intypes == "d")
+                    (*(func_0_d)(f))(pa[0]->to_r());
+                else if (tf->intypes == "s")
+                    (*(func_0_s)(f))(pa[0]->to_s());
                 else
                     throw S("BUG: unexpected intypes");
-                return RObjStr( new CObjStr( "__nullptr__" ) );
-            } else if ( tf->outtype=="i" ) {
+                return RObjStr(new CObjStr("__nullptr__"));
+            } else if (tf->outtype == "i") {
                 int val;
-                if       ( tf->intypes=="i" )
-                    val = (*(func_i_i)(f))( pa[0]->to_i() );
-                else if  ( tf->intypes=="d" )
-                    val = (*(func_i_d)(f))( pa[0]->to_r() );
-                else if  ( tf->intypes=="s" )
-                    val = (*(func_i_s)(f))( pa[0]->to_s() );
-                else if  ( tf->intypes=="ii" )
-                    val = (*(func_i_ii)(f))( pa[0]->to_i(), pa[1]->to_i() );
-                else if  ( tf->intypes=="is" )
-                    val = (*(func_i_is)(f))( pa[0]->to_i(), pa[1]->to_s() );
-                else if  ( tf->intypes=="dd" )
-                    val = (*(func_i_dd)(f))( pa[0]->to_r(), pa[1]->to_r() );
-                else if  ( tf->intypes=="si" )
-                    val = (*(func_i_si)(f))( pa[0]->to_s(), pa[1]->to_i() );
-                else if  ( tf->intypes=="iii" )
-                    val = (*(func_i_iii)(f))( pa[0]->to_i(), pa[1]->to_i(), pa[2]->to_i() );
+                if (tf->intypes == "i")
+                    val = (*(func_i_i)(f))(pa[0]->to_i());
+                else if (tf->intypes == "d")
+                    val = (*(func_i_d)(f))(pa[0]->to_r());
+                else if (tf->intypes == "s")
+                    val = (*(func_i_s)(f))(pa[0]->to_s());
+                else if (tf->intypes == "ii")
+                    val = (*(func_i_ii)(f))(pa[0]->to_i(), pa[1]->to_i());
+                else if (tf->intypes == "is")
+                    val = (*(func_i_is)(f))(pa[0]->to_i(), pa[1]->to_s());
+                else if (tf->intypes == "dd")
+                    val = (*(func_i_dd)(f))(pa[0]->to_r(), pa[1]->to_r());
+                else if (tf->intypes == "si")
+                    val = (*(func_i_si)(f))(pa[0]->to_s(), pa[1]->to_i());
+                else if (tf->intypes == "iii")
+                    val = (*(func_i_iii)(f))(pa[0]->to_i(), pa[1]->to_i(), pa[2]->to_i());
                 else
                     throw S("BUG: unexpected intypes");
-                return RObjInt( new CObjInt( val ) );
+                return RObjInt(new CObjInt(val));
 
-            } else if ( tf->outtype=="d" ) {
+            } else if (tf->outtype == "d") {
                 double val;
-                if       ( tf->intypes=="i" )
-                    val = (*(func_d_i)(f))( pa[0]->to_i() );
-                else if  ( tf->intypes=="d" )
-                    val = (*(func_d_d)(f))( pa[0]->to_r() );
-                else if  ( tf->intypes=="s" )
-                    val = (*(func_d_s)(f))( pa[0]->to_s() );
-                else if  ( tf->intypes=="ii" )
-                    val = (*(func_d_ii)(f))( pa[0]->to_i(), pa[1]->to_i() );
-                else if  ( tf->intypes=="dd" )
-                    val = (*(func_d_dd)(f))( pa[0]->to_r(), pa[1]->to_r() );
-                else if  ( tf->intypes=="sd" )
-                    val = (*(func_d_sd)(f))( pa[0]->to_s(), pa[1]->to_r() );
-                else if  ( tf->intypes=="ddd" )
-                    val = (*(func_d_ddd)(f))( pa[0]->to_r(), pa[1]->to_r(), pa[2]->to_r() );
+                if (tf->intypes == "i")
+                    val = (*(func_d_i)(f))(pa[0]->to_i());
+                else if (tf->intypes == "d")
+                    val = (*(func_d_d)(f))(pa[0]->to_r());
+                else if (tf->intypes == "s")
+                    val = (*(func_d_s)(f))(pa[0]->to_s());
+                else if (tf->intypes == "ii")
+                    val = (*(func_d_ii)(f))(pa[0]->to_i(), pa[1]->to_i());
+                else if (tf->intypes == "dd")
+                    val = (*(func_d_dd)(f))(pa[0]->to_r(), pa[1]->to_r());
+                else if (tf->intypes == "sd")
+                    val = (*(func_d_sd)(f))(pa[0]->to_s(), pa[1]->to_r());
+                else if (tf->intypes == "ddd")
+                    val = (*(func_d_ddd)(f))(pa[0]->to_r(), pa[1]->to_r(), pa[2]->to_r());
                 else
                     throw S("BUG: unexpected intypes");
-                return RObjDbl( new CObjDbl( val ) );
-            } else if ( tf->outtype=="e" ) {
+                return RObjDbl(new CObjDbl(val));
+            } else if (tf->outtype == "e") {
                 double val, err;
-                if       ( tf->intypes=="e" )
-                    (*(func_e_e)(f))( val, err,
-                             pa[0]->to_r(), pa[0]->to_dr() );
-                else if  ( tf->intypes=="dd" )
-                    (*(func_e_dd)(f))( val, err, pa[0]->to_r(), pa[1]->to_r() );
-                else if  ( tf->intypes=="ee" )
-                    (*(func_e_ee)(f))( val, err,
-                             pa[0]->to_r(), pa[0]->to_dr(),
-                             pa[1]->to_r(), pa[1]->to_dr() );
-                else if  ( tf->intypes=="se" )
-                    (*(func_e_se)(f))( val, err,
-                             pa[0]->to_s(),
-                             pa[1]->to_r(), pa[1]->to_dr() );
-                else if  ( tf->intypes=="eee" )
-                    (*(func_e_eee)(f))( val, err,
-                             pa[0]->to_r(), pa[0]->to_dr(),
-                             pa[1]->to_r(), pa[1]->to_dr(),
-                             pa[2]->to_r(), pa[2]->to_dr() );
+                if (tf->intypes == "e")
+                    (*(func_e_e)(f))(val, err, pa[0]->to_r(), pa[0]->to_dr());
+                else if (tf->intypes == "dd")
+                    (*(func_e_dd)(f))(val, err, pa[0]->to_r(), pa[1]->to_r());
+                else if (tf->intypes == "ee")
+                    (*(func_e_ee)(f))(
+                        val, err, pa[0]->to_r(), pa[0]->to_dr(), pa[1]->to_r(), pa[1]->to_dr());
+                else if (tf->intypes == "se")
+                    (*(func_e_se)(f))(val, err, pa[0]->to_s(), pa[1]->to_r(), pa[1]->to_dr());
+                else if (tf->intypes == "eee")
+                    (*(func_e_eee)(f))(
+                        val, err, pa[0]->to_r(), pa[0]->to_dr(), pa[1]->to_r(), pa[1]->to_dr(),
+                        pa[2]->to_r(), pa[2]->to_dr());
                 else
                     throw S("BUG: unexpected intypes");
-                return RObjEnu( new CObjEnu( val, err ) );
-            } else if ( tf->outtype=="s" ) {
+                return RObjEnu(new CObjEnu(val, err));
+            } else if (tf->outtype == "s") {
                 string val;
-                if       ( tf->intypes=="s" )
-                    val = (*(func_s_s)(f))( pa[0]->to_s() );
-                else if  ( tf->intypes=="si" )
-                    val = (*(func_s_si)(f))( pa[0]->to_s(), pa[1]->to_i() );
-                else if  ( tf->intypes=="ss" )
-                    val = (*(func_s_ss)(f))( pa[0]->to_s(), pa[1]->to_s() );
+                if (tf->intypes == "s")
+                    val = (*(func_s_s)(f))(pa[0]->to_s());
+                else if (tf->intypes == "si")
+                    val = (*(func_s_si)(f))(pa[0]->to_s(), pa[1]->to_i());
+                else if (tf->intypes == "ss")
+                    val = (*(func_s_ss)(f))(pa[0]->to_s(), pa[1]->to_s());
                 else
                     throw S("BUG: unexpected intypes");
-                return PObjStr( new CObjStr( val ) );
+                return PObjStr(new CObjStr(val));
             } else
                 throw S("BUG: unexpected outtype");
-        } else { //is_vec()
+        } else { // is_vec()
             // determine length of input vectors
-            int n=1;
-            for ( int iarg=0; iarg<narg; ++iarg ) {
+            int n = 1;
+            for (int iarg = 0; iarg < narg; ++iarg) {
                 int na = pa[iarg]->size();
-                if      ( n==1 )
+                if (n == 1)
                     n = na;
-                else if ( na != 1 && na != n )
+                else if (na != 1 && na != n)
                     throw S("vector arguments have different sizes");
             }
-            if        ( tf->outtype=="i" ) {
-                PObjVecInt ret( new CObjVecInt( n ) );
-                if       ( tf->intypes=="i" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_i_i)(f))( pa[0]->to_i(i) );
-                else if  ( tf->intypes=="d" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_i_d)(f))( pa[0]->to_r(i) );
-                else if  ( tf->intypes=="ii" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_i_ii)(f))( pa[0]->to_i(i), pa[1]->to_i(i) );
-                else if  ( tf->intypes=="dd" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_i_dd)(f))( pa[0]->to_r(i), pa[1]->to_r(i) );
-                else if  ( tf->intypes=="iii" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_i_iii)(f))( pa[0]->to_i(i), pa[1]->to_i(i), pa[2]->to_i(i) );
+            if (tf->outtype == "i") {
+                PObjVecInt ret(new CObjVecInt(n));
+                if (tf->intypes == "i")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] = (*(func_i_i)(f))(pa[0]->to_i(i));
+                else if (tf->intypes == "d")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] = (*(func_i_d)(f))(pa[0]->to_r(i));
+                else if (tf->intypes == "ii")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] = (*(func_i_ii)(f))(pa[0]->to_i(i), pa[1]->to_i(i));
+                else if (tf->intypes == "dd")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] = (*(func_i_dd)(f))(pa[0]->to_r(i), pa[1]->to_r(i));
+                else if (tf->intypes == "iii")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] =
+                            (*(func_i_iii)(f))(pa[0]->to_i(i), pa[1]->to_i(i), pa[2]->to_i(i));
                 else
                     throw S("BUG: unexpected intypes");
                 return ret;
-            } else if ( tf->outtype=="d" ) {
-                PObjVecDbl ret( new CObjVecDbl( n ) );
-                if       ( tf->intypes=="i" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_d_i)(f))( pa[0]->to_i(i) );
-                else if  ( tf->intypes=="d" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_d_d)(f))( pa[0]->to_r(i) );
-                else if  ( tf->intypes=="ii" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_d_ii)(f))( pa[0]->to_i(i), pa[1]->to_i(i) );
-                else if  ( tf->intypes=="dd" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_d_dd)(f))( pa[0]->to_r(i), pa[1]->to_r(i) );
-                else if  ( tf->intypes=="ddd" )
-                    for ( int i=0; i<n; ++i )
-                        ret->v[i] = (*(func_d_ddd)(f))( pa[0]->to_r(i), pa[1]->to_r(i), pa[2]->to_r(i) );
+            } else if (tf->outtype == "d") {
+                PObjVecDbl ret(new CObjVecDbl(n));
+                if (tf->intypes == "i")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] = (*(func_d_i)(f))(pa[0]->to_i(i));
+                else if (tf->intypes == "d")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] = (*(func_d_d)(f))(pa[0]->to_r(i));
+                else if (tf->intypes == "ii")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] = (*(func_d_ii)(f))(pa[0]->to_i(i), pa[1]->to_i(i));
+                else if (tf->intypes == "dd")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] = (*(func_d_dd)(f))(pa[0]->to_r(i), pa[1]->to_r(i));
+                else if (tf->intypes == "ddd")
+                    for (int i = 0; i < n; ++i)
+                        ret->v[i] =
+                            (*(func_d_ddd)(f))(pa[0]->to_r(i), pa[1]->to_r(i), pa[2]->to_r(i));
                 else
                     throw S("BUG: unexpected intypes");
                 return ret;
-            } else if ( tf->outtype=="e" ) {
-                PObjVecEnu ret( new CObjVecEnu( n ) );
-                if       ( tf->intypes=="e" )
-                    for ( int i=0; i<n; ++i )
-                        (*(func_e_e)(f))( ret->v[i], ret->dv[i], pa[0]->to_r(i), pa[0]->to_dr(i) );
-                else if  ( tf->intypes=="dd" )
-                    for ( int i=0; i<n; ++i )
-                        (*(func_e_dd)(f))( ret->v[i], ret->dv[i], pa[0]->to_r(i), pa[1]->to_r(i) );
-                else if  ( tf->intypes=="ee" )
-                    for ( int i=0; i<n; ++i )
-                        (*(func_e_ee)(f))( ret->v[i], ret->dv[i],
-                                           pa[0]->to_r(i), pa[0]->to_dr(i),
-                                           pa[1]->to_r(i), pa[1]->to_dr(i) );
-                else if  ( tf->intypes=="eee" )
-                    for ( int i=0; i<n; ++i )
-                        (*(func_e_eee)(f))( ret->v[i], ret->dv[i],
-                             pa[0]->to_r(i), pa[0]->to_dr(i),
-                             pa[1]->to_r(i), pa[1]->to_dr(i),
-                             pa[2]->to_r(i), pa[2]->to_dr(i) );
+            } else if (tf->outtype == "e") {
+                PObjVecEnu ret(new CObjVecEnu(n));
+                if (tf->intypes == "e")
+                    for (int i = 0; i < n; ++i)
+                        (*(func_e_e)(f))(ret->v[i], ret->dv[i], pa[0]->to_r(i), pa[0]->to_dr(i));
+                else if (tf->intypes == "dd")
+                    for (int i = 0; i < n; ++i)
+                        (*(func_e_dd)(f))(ret->v[i], ret->dv[i], pa[0]->to_r(i), pa[1]->to_r(i));
+                else if (tf->intypes == "ee")
+                    for (int i = 0; i < n; ++i)
+                        (*(func_e_ee)(f))(
+                            ret->v[i], ret->dv[i], pa[0]->to_r(i), pa[0]->to_dr(i), pa[1]->to_r(i),
+                            pa[1]->to_dr(i));
+                else if (tf->intypes == "eee")
+                    for (int i = 0; i < n; ++i)
+                        (*(func_e_eee)(f))(
+                            ret->v[i], ret->dv[i], pa[0]->to_r(i), pa[0]->to_dr(i), pa[1]->to_r(i),
+                            pa[1]->to_dr(i), pa[2]->to_r(i), pa[2]->to_dr(i));
                 else
                     throw S("BUG: unexpected intypes");
                 return ret;
@@ -278,33 +268,27 @@ RObj CNodeFun::tree_val( const CContext& ctx ) const
                 throw S("BUG: unexpected outtype");
         }
         throw S("BUG: unexpected case");
-    } catch( string& ex ) {
-        throw ex+"\n called by function node "+tree_info()+" {intypes='"+basetypes+"', " +
-            ( tf ? ( "cast to '"+tf->intypes+"', outtype='"+tf->outtype+"', " ) : "" ) +
-            "context: "+ctx.context_info()+"}";
+    } catch (string& ex) {
+        throw ex + "\n called by function node " + tree_info() + " {intypes='" + basetypes + "', "
+            + (tf ? ("cast to '" + tf->intypes + "', outtype='" + tf->outtype + "', ") : "")
+            + "context: " + ctx.context_info() + "}";
     }
 }
 
 
-CCoord CNodeFun1::node_coord( int k ) const
-{
-    return fu->coord( arg[0]->node_coord( k ) );
-}
-CCoord CNodeFun2::node_coord( int k ) const
+CCoord CNodeFun1::node_coord(int k) const { return fu->coord(arg[0]->node_coord(k)); }
+CCoord CNodeFun2::node_coord(int k) const
 {
-    return fu->coord( arg[0]->node_coord( k ), arg[1]->node_coord( k ) );
+    return fu->coord(arg[0]->node_coord(k), arg[1]->node_coord(k));
 }
-CCoord CNodeFun3::node_coord( int k ) const
+CCoord CNodeFun3::node_coord(int k) const
 {
-    return fu->coord( arg[0]->node_coord( k ), arg[1]->node_coord( k ), arg[2]->node_coord( k ) );
+    return fu->coord(arg[0]->node_coord(k), arg[1]->node_coord(k), arg[2]->node_coord(k));
 }
 
 //! Returns string representation of this node.
 
-string CNodeFun1::tree_info() const
-{
-    return fu->tag + "(" + arg[0]->tree_info() + ")";
-}
+string CNodeFun1::tree_info() const { return fu->tag + "(" + arg[0]->tree_info() + ")"; }
 
 //! Returns string representation of this node.
 
@@ -317,10 +301,8 @@ string CNodeFun2::tree_info() const
 
 string CNodeFun3::tree_info() const
 {
-    return fu->tag + "(" +
-        arg[0]->tree_info() + "," +
-        arg[1]->tree_info() + "," +
-        arg[2]->tree_info() + ")";
+    return fu->tag + "(" + arg[0]->tree_info() + "," + arg[1]->tree_info() + ","
+        + arg[2]->tree_info() + ")";
 }
 
 
@@ -331,54 +313,49 @@ string CNodeFun3::tree_info() const
 
 //! Evaluates the range in context, and returns a vector object pointer.
 
-RObj CNodeRange::tree_val( const CContext& ctx ) const
+RObj CNodeRange::tree_val(const CContext& ctx) const
 {
-     // evaluate arguments, determine types, assert they are scalar.
+    // evaluate arguments, determine types, assert they are scalar.
     vector<RObj> pa(narg);
     bool all_int = true;
-    for ( int iarg=0; iarg<narg; ++iarg ) {
-        if ( arg[iarg] )
-            pa[iarg] = arg[iarg]->tree_val( ctx );
-        else if ( iarg==0 )
-            pa[iarg] = RObj( new CObjInt( 0 ) ); // default begin
-        else if ( iarg==1 )
-            pa[iarg] = RObj( new CObjInt( ctx.nv-1 ) ); // default end
-        else if ( iarg==2 )
-            pa[iarg] = RObj( new CObjInt( 1 ) ); // default step
-        if( pa[iarg]->base_type()!='i' )
+    for (int iarg = 0; iarg < narg; ++iarg) {
+        if (arg[iarg])
+            pa[iarg] = arg[iarg]->tree_val(ctx);
+        else if (iarg == 0)
+            pa[iarg] = RObj(new CObjInt(0)); // default begin
+        else if (iarg == 1)
+            pa[iarg] = RObj(new CObjInt(ctx.nv - 1)); // default end
+        else if (iarg == 2)
+            pa[iarg] = RObj(new CObjInt(1)); // default step
+        if (pa[iarg]->base_type() != 'i')
             all_int = false;
-        if ( pa[iarg]->is_vec() )
+        if (pa[iarg]->is_vec())
             throw "vectorial argument in range " + tree_info();
     }
 
-    if ( all_int ) {
-        PObjVecInt ret( new CObjVecInt );
-        for ( int i = pa[0]->to_i();
-              ( inclusive_end ? i<=pa[1]->to_i() : i<pa[1]->to_i() );
-               i+=pa[2]->to_i() )
-            ret->v.push_back( i );
+    if (all_int) {
+        PObjVecInt ret(new CObjVecInt);
+        for (int i = pa[0]->to_i(); (inclusive_end ? i <= pa[1]->to_i() : i < pa[1]->to_i());
+             i += pa[2]->to_i())
+            ret->v.push_back(i);
         return ret;
     } else {
-        PObjVecDbl ret( new CObjVecDbl );
-        for ( double r = pa[0]->to_r();
-              ( inclusive_end ? r<=pa[1]->to_r() : r<pa[1]->to_r() );
-              r+=pa[2]->to_r() )
-            ret->v.push_back( r );
+        PObjVecDbl ret(new CObjVecDbl);
+        for (double r = pa[0]->to_r(); (inclusive_end ? r <= pa[1]->to_r() : r < pa[1]->to_r());
+             r += pa[2]->to_r())
+            ret->v.push_back(r);
         return ret;
     }
 }
 
-CCoord CNodeRange::node_coord( int k ) const {
-    return CCoord("range", "");
-}
+CCoord CNodeRange::node_coord(int k) const { return CCoord("range", ""); }
 
 //! Returns string representation of this node.
 
 string CNodeRange::tree_info() const
 {
-    return "range(" + (arg[0] ? arg[0]->tree_info() : "0") + "," +
-        (arg[1] ? arg[1]->tree_info() : "end") + "," +
-        (arg[2] ? arg[2]->tree_info() : "1" ) + ")";
+    return "range(" + (arg[0] ? arg[0]->tree_info() : "0") + ","
+        + (arg[1] ? arg[1]->tree_info() : "end") + "," + (arg[2] ? arg[2]->tree_info() : "1") + ")";
 }
 
 
@@ -387,74 +364,73 @@ string CNodeRange::tree_info() const
 //**************************************************************************************************
 
 
-CNodeList::CNodeList( RNode _incremand, RNode _increment )
-    : CNodeWithArgs(1)
+CNodeList::CNodeList(RNode _incremand, RNode _increment) : CNodeWithArgs(1)
 {
-    if ( auto old = PCAST<const CNodeList>(_incremand) ) {
+    if (auto old = PCAST<const CNodeList>(_incremand)) {
         arg = old->args();
     } else {
         arg[0] = _incremand;
     }
-    if ( _increment )
-        arg.push_back( _increment );
+    if (_increment)
+        arg.push_back(_increment);
     narg = arg.size();
 }
 
 
 //! Evaluates the range in context, and returns a vector object pointer.
 
-RObj CNodeList::tree_val( const CContext& ctx ) const
+RObj CNodeList::tree_val(const CContext& ctx) const
 {
-     // evaluate arguments, determine types
+    // evaluate arguments, determine types
     vector<RObj> pa(narg);
     bool all_int = true;
     bool all_dbl = true;
     bool has_enu = false;
-    for ( int iarg=0; iarg<narg; ++iarg ) {
-        if ( arg[iarg] )
-            pa[iarg] = arg[iarg]->tree_val( ctx );
+    for (int iarg = 0; iarg < narg; ++iarg) {
+        if (arg[iarg])
+            pa[iarg] = arg[iarg]->tree_val(ctx);
         char t = pa[iarg]->base_type();
-        if( t!='i' )
+        if (t != 'i')
             all_int = false;
-        if( t!='i' && t!='d' && t!='e' )
+        if (t != 'i' && t != 'd' && t != 'e')
             all_dbl = false;
-        if( t=='e' )
+        if (t == 'e')
             has_enu = true;
     }
 
-    if ( all_int ) {
-        PObjVecInt ret( new CObjVecInt );
-        for ( int iarg=0; iarg<narg; ++iarg ) {
-            if ( RObjVecInt rav = PCAST<const CObjVecInt>(pa[iarg]) )
-                for ( int i=0; i<rav->size(); ++i )
-                    ret->v.push_back( rav->to_i(i) );
+    if (all_int) {
+        PObjVecInt ret(new CObjVecInt);
+        for (int iarg = 0; iarg < narg; ++iarg) {
+            if (RObjVecInt rav = PCAST<const CObjVecInt>(pa[iarg]))
+                for (int i = 0; i < rav->size(); ++i)
+                    ret->v.push_back(rav->to_i(i));
             else
-                ret->v.push_back( pa[iarg]->to_i() );
+                ret->v.push_back(pa[iarg]->to_i());
         }
         return ret;
-    } else if ( all_dbl ) {
-        if ( has_enu ) {
-            PObjVecEnu ret( new CObjVecEnu );
-            for ( int iarg=0; iarg<narg; ++iarg ) {
-                if ( RObjVecNum rav = PCAST<const CObjVecNum>(pa[iarg]) ) {
-                    for ( int i=0; i<rav->size(); ++i ) {
-                        ret->v.push_back( rav->to_r(i) );
-                        ret->dv.push_back( rav->to_dr(i) );
+    } else if (all_dbl) {
+        if (has_enu) {
+            PObjVecEnu ret(new CObjVecEnu);
+            for (int iarg = 0; iarg < narg; ++iarg) {
+                if (RObjVecNum rav = PCAST<const CObjVecNum>(pa[iarg])) {
+                    for (int i = 0; i < rav->size(); ++i) {
+                        ret->v.push_back(rav->to_r(i));
+                        ret->dv.push_back(rav->to_dr(i));
                     }
                 } else {
-                    ret->v.push_back( pa[iarg]->to_r() );
-                    ret->dv.push_back( pa[iarg]->to_dr() );
+                    ret->v.push_back(pa[iarg]->to_r());
+                    ret->dv.push_back(pa[iarg]->to_dr());
                 }
             }
             return ret;
         } else {
-            PObjVecDbl ret( new CObjVecDbl );
-            for ( int iarg=0; iarg<narg; ++iarg ) {
-                if ( RObjVecNum rav = PCAST<const CObjVecNum>(pa[iarg]) )
-                    for ( int i=0; i<rav->size(); ++i )
-                        ret->v.push_back( rav->to_r(i) );
+            PObjVecDbl ret(new CObjVecDbl);
+            for (int iarg = 0; iarg < narg; ++iarg) {
+                if (RObjVecNum rav = PCAST<const CObjVecNum>(pa[iarg]))
+                    for (int i = 0; i < rav->size(); ++i)
+                        ret->v.push_back(rav->to_r(i));
                 else
-                    ret->v.push_back( pa[iarg]->to_r() );
+                    ret->v.push_back(pa[iarg]->to_r());
             }
             return ret;
         }
@@ -463,18 +439,16 @@ RObj CNodeList::tree_val( const CContext& ctx ) const
     }
 }
 
-CCoord CNodeList::node_coord( int k ) const {
-    return CCoord( "list", "" );
-}
+CCoord CNodeList::node_coord(int k) const { return CCoord("list", ""); }
 
 //! Returns string representation of this node.
 
 string CNodeList::tree_info() const
 {
     string ret = "list(";
-    for ( int iarg=0; iarg<narg; ++iarg ) {
+    for (int iarg = 0; iarg < narg; ++iarg) {
         ret += arg[iarg]->tree_info();
-        if ( iarg<narg-1 )
+        if (iarg < narg - 1)
             ret += ",";
     }
     return ret;
@@ -486,107 +460,106 @@ string CNodeList::tree_info() const
 //**************************************************************************************************
 
 
-CNodeGeni::CNodeGeni( const class CGeni *_geni, RRef _ref )
-    : CNodeWithArgs(_geni->narg), geni(_geni)
+CNodeGeni::CNodeGeni(const class CGeni* _geni, RRef _ref) : CNodeWithArgs(_geni->narg), geni(_geni)
 {
     arg.resize(narg);
-    for ( int iarg=0; iarg<narg; ++iarg ) {
-        RRef ref = _ref ? _ref : RRef( new CRef3() );
-        if      ( geni->default_args[iarg]=="x" )
-            arg[iarg] = RNode( new CNodePointX( ref ) );
-        else if ( geni->default_args[iarg]=="y" )
-            arg[iarg] = RNode( new CNodePointY( ref ) );
+    for (int iarg = 0; iarg < narg; ++iarg) {
+        RRef ref = _ref ? _ref : RRef(new CRef3());
+        if (geni->default_args[iarg] == "x")
+            arg[iarg] = RNode(new CNodePointX(ref));
+        else if (geni->default_args[iarg] == "y")
+            arg[iarg] = RNode(new CNodePointY(ref));
         else
             throw S("BUG: unexpected default arg");
     }
 }
 
-CNodeGeni::CNodeGeni( const class CGeni *_geni, RNode _a0 )
-    : CNodeWithArgs(1), geni(_geni)
+CNodeGeni::CNodeGeni(const class CGeni* _geni, RNode _a0) : CNodeWithArgs(1), geni(_geni)
 {
-    if ( geni->narg!=1 )
-        throw "syntax error: generalized integral '" + geni->name + "' needs " +
-            S(geni->narg) + " arguments, not 1";
+    if (geni->narg != 1)
+        throw "syntax error: generalized integral '" + geni->name + "' needs " + S(geni->narg)
+            + " arguments, not 1";
     arg[0] = _a0;
 }
 
-CNodeGeni::CNodeGeni( const class CGeni *_geni, RNode _a0, RNode _a1 )
-    : CNodeWithArgs(2), geni(_geni)
+CNodeGeni::CNodeGeni(const class CGeni* _geni, RNode _a0, RNode _a1) : CNodeWithArgs(2), geni(_geni)
 {
-    if ( geni->narg!=2 )
-        throw "syntax error: generalized integral '" + geni->name + "' needs " +
-            S(geni->narg) + " arguments, not 2";
+    if (geni->narg != 2)
+        throw "syntax error: generalized integral '" + geni->name + "' needs " + S(geni->narg)
+            + " arguments, not 2";
     arg[0] = _a0;
     arg[1] = _a1;
 }
 
 //! A functional of 1,2,.. arguments (including operators like +,-,.. ).
 
-RObj CNodeGeni::tree_val( const CContext& ctx ) const
+RObj CNodeGeni::tree_val(const CContext& ctx) const
 {
     try {
-        if( ctx.dim==CContext::_VT )
-            throw "Unexpected evaluation in curve context {context: " + ctx.context_info() +"}";
+        if (ctx.dim == CContext::_VT)
+            throw "Unexpected evaluation in curve context {context: " + ctx.context_info() + "}";
         CContext myctx(ctx);
         myctx.dim = CContext::_VI;
         myctx.nv = -1;
         // Evaluate arguments, and determine size of is_vec() arguments.
         vector<RObj> pa(narg);
         vector<RObjVecNum> pav(narg);
-        int n=0;
-        for ( int iarg=0; iarg<narg; ++iarg ) {
-            pa[iarg] = arg[iarg]->tree_val( myctx );
+        int n = 0;
+        for (int iarg = 0; iarg < narg; ++iarg) {
+            pa[iarg] = arg[iarg]->tree_val(myctx);
             pav[iarg] = PCAST<const CObjVecNum>(pa[iarg]);
-            if( !pav[iarg] )
-                throw "argument " + S(iarg) + " of generalized integral " +
-                    tree_info() + " is scalar: " + pa[iarg]->result_info();
-            if ( n==0 )
+            if (!pav[iarg])
+                throw "argument " + S(iarg) + " of generalized integral " + tree_info()
+                    + " is scalar: " + pa[iarg]->result_info();
+            if (n == 0)
                 n = pav[iarg]->size();
-            else if ( pav[iarg]->size() != n )
+            else if (pav[iarg]->size() != n)
                 throw S("vector arguments have different size");
         }
         // Now evaluate the function.
         double val;
-        geni->eval( &val, nullptr, n, pav ); // TODO: compute errors
-        if      ( ctx.dim==CContext::_1 )
-            return RObjDbl( new CObjDbl( val ) );
-        else if ( ctx.dim==CContext::_VI )
-            return RObjVecDbl( new CObjVecDbl( ctx.nv, val ) );
+        geni->eval(&val, nullptr, n, pav); // TODO: compute errors
+        if (ctx.dim == CContext::_1)
+            return RObjDbl(new CObjDbl(val));
+        else if (ctx.dim == CContext::_VI)
+            return RObjVecDbl(new CObjVecDbl(ctx.nv, val));
         else
-            throw "BUG: unforeseen dimension {context: " + ctx.context_info() +"}";
+            throw "BUG: unforeseen dimension {context: " + ctx.context_info() + "}";
 
-    } catch( string& ex ) {
-        throw ex+"\n called by integral node "+tree_info()+" {context: "+ctx.context_info()+"}";
+    } catch (string& ex) {
+        throw ex + "\n called by integral node " + tree_info() + " {context: " + ctx.context_info()
+            + "}";
     }
 }
 
-CCoord CNodeGeni::node_coord( int k ) const {
-    string rnam = geni->name+"(";
+CCoord CNodeGeni::node_coord(int k) const
+{
+    string rnam = geni->name + "(";
     vector<string> argunit;
-    for ( int iarg=0; iarg<narg; ++iarg ){
-        CCoord carg = arg[iarg]->node_coord( k );
-        argunit.push_back( carg.unit );
+    for (int iarg = 0; iarg < narg; ++iarg) {
+        CCoord carg = arg[iarg]->node_coord(k);
+        argunit.push_back(carg.unit);
         rnam += carg.name;
-        rnam += iarg==narg-1 ? ")" : ",";
+        rnam += iarg == narg - 1 ? ")" : ",";
     }
     string runit;
-    if        ( geni->unit_hint == "?" ) {
+    if (geni->unit_hint == "?") {
         runit = "";
         cout << "TODO: hard-code unit for this generalized integral\n";
-    } else if ( geni->unit_hint == "-" ) {
+    } else if (geni->unit_hint == "-") {
         runit = "";
-    } else if ( geni->unit_hint == "a" ) {
-        if ( narg<1 )
+    } else if (geni->unit_hint == "a") {
+        if (narg < 1)
             throw "BUG: unit hint '" + geni->unit_hint + "'  inconsistent with narg=" + S(narg);
         runit = argunit[0];
-    } else if ( geni->unit_hint == "ab" ) {
-        if ( narg<2 )
+    } else if (geni->unit_hint == "ab") {
+        if (narg < 2)
             throw "BUG: unit hint '" + geni->unit_hint + "'  inconsistent with narg=" + S(narg);
         runit = argunit[0] + "*" + argunit[1];
     } else {
-        throw  "BUG: unforeseen unit hint '" + geni->unit_hint + "'";
+        throw "BUG: unforeseen unit hint '" + geni->unit_hint + "'";
     }
-    return CCoord( rnam, runit );
+    return CCoord(rnam, runit);
 }
 
 
@@ -594,9 +567,9 @@ CCoord CNodeGeni::node_coord( int k ) const {
 
 string CNodeGeni::tree_info() const
 {
-    string ret = geni->name+"(";
-    for ( int iarg=0; iarg<narg; ++iarg )
-        ret += arg[iarg]->tree_info() + (iarg<narg-1 ? "," : ")" );
+    string ret = geni->name + "(";
+    for (int iarg = 0; iarg < narg; ++iarg)
+        ret += arg[iarg]->tree_info() + (iarg < narg - 1 ? "," : ")");
     return ret;
 }
 
@@ -606,72 +579,73 @@ string CNodeGeni::tree_info() const
 //**************************************************************************************************
 
 
-CNodeCvin::CNodeCvin( const class CCvin *_cvin, RRef _ref, RNode _a0, RNode _a1 )
+CNodeCvin::CNodeCvin(const class CCvin* _cvin, RRef _ref, RNode _a0, RNode _a1)
     : CNodeWithArgs(2), cvin(_cvin), ref(_ref)
 {
-    if ( cvin->narg!=2 )
-        throw "syntax error: curve functional '" + cvin->name + "' needs " +
-            S(cvin->narg) + " arguments, not 2";
+    if (cvin->narg != 2)
+        throw "syntax error: curve functional '" + cvin->name + "' needs " + S(cvin->narg)
+            + " arguments, not 2";
     arg[0] = _a0;
     arg[1] = _a1;
-    if( i_dependent() )
+    if (i_dependent())
         throw S("Invalid i dependence");
 }
 
-RObj CNodeCvin::tree_val( const CContext& ctx ) const
+RObj CNodeCvin::tree_val(const CContext& ctx) const
 {
     try {
-        if( ctx.dim!=CContext::_1 )
-            throw "Unexpected is_vec() {context: " + ctx.context_info() +"}";
+        if (ctx.dim != CContext::_1)
+            throw "Unexpected is_vec() {context: " + ctx.context_info() + "}";
         CContext myctx(ctx);
         myctx.dim = CContext::_1;
         // Evaluate arguments.
         vector<double> a(narg);
-        for ( int iarg=0; iarg<narg; ++iarg ) {
-            RObj pa = arg[iarg]->tree_val( myctx );
+        for (int iarg = 0; iarg < narg; ++iarg) {
+            RObj pa = arg[iarg]->tree_val(myctx);
             try {
                 a[iarg] = pa->to_r();
-            } catch( string& ex ) {
-                throw "argument " + S(iarg) + " of curve functional " + tree_info() +
-                    " is not a scalar number: " + pa->result_info() + " => " + ex;
+            } catch (string& ex) {
+                throw "argument " + S(iarg) + " of curve functional " + tree_info()
+                    + " is not a scalar number: " + pa->result_info() + " => " + ex;
             }
         }
-        int k = ref->get_k( ctx );
-        const COlo *f = SMem::instance()->mem_get(k);
-        const COlc *fc = dynamic_cast<const COlc*>( f );
-        if ( !fc )
+        int k = ref->get_k(ctx);
+        const COlo* f = SMem::instance()->mem_get(k);
+        const COlc* fc = dynamic_cast<const COlc*>(f);
+        if (!fc)
             throw S("This is not a curve file => cannot integrate");
-        int j = PCAST<const CRef2>(ref)->get_j( ctx, f->nJ() );
+        int j = PCAST<const CRef2>(ref)->get_j(ctx, f->nJ());
         // now evaluate the function
         double val;
-        cvin->eval( &val, nullptr, fc, k, j, a ); // TODO: compute errors?
-        return PObjDbl( new CObjDbl( val ) );
-    } catch( string& ex ) {
-        throw ex+" in NodeCvin "+tree_info()+" {context: "+ctx.context_info()+"}";
+        cvin->eval(&val, nullptr, fc, k, j, a); // TODO: compute errors?
+        return PObjDbl(new CObjDbl(val));
+    } catch (string& ex) {
+        throw ex + " in NodeCvin " + tree_info() + " {context: " + ctx.context_info() + "}";
     }
 }
 
-CCoord CNodeCvin::node_coord( int k ) const {
-//*
-//*     CCoord r[maxarg];
-//*     for ( int iarg=0; iarg<narg; ++iarg )
-//*         arg[iarg]->set_coord( r[iarg], k );
-//*     if      ( const CFunc1* fu = dynamic_cast<const CFunc1*>( fun ) )
-//*         ret = fu->coord( r+0);
-//*     else if ( const CFunc2* fu = dynamic_cast<const CFunc2*>( fun ) )
-//*         ret = fu->coord( r+0, r+1 );
-//*     else if ( const CFunc3* fu = dynamic_cast<const CFunc3*>( fun ) )
-//*         ret = fu->coord( r+0, r+1, r+2 );
-    return CCoord( "TODO:CvinCoord", "" );
+CCoord CNodeCvin::node_coord(int k) const
+{
+    //*
+    //*     CCoord r[maxarg];
+    //*     for ( int iarg=0; iarg<narg; ++iarg )
+    //*         arg[iarg]->set_coord( r[iarg], k );
+    //*     if      ( const CFunc1* fu = dynamic_cast<const CFunc1*>( fun ) )
+    //*         ret = fu->coord( r+0);
+    //*     else if ( const CFunc2* fu = dynamic_cast<const CFunc2*>( fun ) )
+    //*         ret = fu->coord( r+0, r+1 );
+    //*     else if ( const CFunc3* fu = dynamic_cast<const CFunc3*>( fun ) )
+    //*         ret = fu->coord( r+0, r+1, r+2 );
+    return CCoord("TODO:CvinCoord", "");
 }
 
 //! Returns string representation of this node.
 
 string CNodeCvin::tree_info() const
 {
-    string ret = cvin->name+"(..)";
-    for ( int iarg=0; iarg<narg; ++iarg )
-        ret += arg[iarg]->tree_info() + (iarg<narg-1 ? "," : ")" );
+    string ret = cvin->name + "(..)";
+    for (int iarg = 0; iarg < narg; ++iarg)
+        ret += arg[iarg]->tree_info() + (iarg < narg - 1 ? "," : ")");
     return ret;
 }
 
@@ -680,29 +654,17 @@ string CNodeCvin::tree_info() const
 //* CNodeVal: end node containing a numeric value
 //**************************************************************************************************
 
-CNodeVal::CNodeVal( double _val ) : val( PObjDbl( new CObjDbl( _val ) ) ) {}
+CNodeVal::CNodeVal(double _val) : val(PObjDbl(new CObjDbl(_val))) {}
 
-CNodeVal::CNodeVal( int _val ) : val( PObjInt( new CObjInt( _val ) ) ) {}
+CNodeVal::CNodeVal(int _val) : val(PObjInt(new CObjInt(_val))) {}
 
-bool CNodeVal::looks_like_indices() const
-{
-    return PCAST<const CObjInt>(val)!=nullptr;
-}
+bool CNodeVal::looks_like_indices() const { return PCAST<const CObjInt>(val) != nullptr; }
 
-RObj CNodeVal::tree_val( const CContext& ctx ) const
-{
-    return val;
-}
+RObj CNodeVal::tree_val(const CContext& ctx) const { return val; }
 
-CCoord CNodeVal::node_coord( int k ) const
-{
-    return CCoord(val->to_s(), "");
-}
+CCoord CNodeVal::node_coord(int k) const { return CCoord(val->to_s(), ""); }
 
-string CNodeVal::tree_info() const
-{
-    return "val(" + val->to_s() + ")";
-}
+string CNodeVal::tree_info() const { return "val(" + val->to_s() + ")"; }
 
 
 //**************************************************************************************************
@@ -710,15 +672,15 @@ string CNodeVal::tree_info() const
 //**************************************************************************************************
 
 
-RObj CNodeIdxI::tree_val( const CContext& ctx ) const
+RObj CNodeIdxI::tree_val(const CContext& ctx) const
 {
-    if          ( ctx.dim==CContext::_1 ) {
-        if ( ctx.i==-1 )
+    if (ctx.dim == CContext::_1) {
+        if (ctx.i == -1)
             throw S("missing index i");
-        return RObjInt( new CObjInt( ctx.i ) );
-    } else if ( ctx.dim==CContext::_VI ) {
-        PObjVecInt pret( new CObjVecInt( ctx.nv ) );
-        for( int i=0; i<ctx.nv; ++i )
+        return RObjInt(new CObjInt(ctx.i));
+    } else if (ctx.dim == CContext::_VI) {
+        PObjVecInt pret(new CObjVecInt(ctx.nv));
+        for (int i = 0; i < ctx.nv; ++i)
             pret->v[i] = i;
         return pret;
     } else
@@ -726,25 +688,19 @@ RObj CNodeIdxI::tree_val( const CContext& ctx ) const
 }
 
 
-RObj CNodeIdxJ::tree_val( const CContext& ctx ) const
-{
-    return RObjInt( new CObjInt( ctx.j ) );
-}
+RObj CNodeIdxJ::tree_val(const CContext& ctx) const { return RObjInt(new CObjInt(ctx.j)); }
 
 
-RObj CNodeIdxK::tree_val( const CContext& ctx ) const
-{
-    return RObjInt( new CObjInt( ctx.k ) );
-}
+RObj CNodeIdxK::tree_val(const CContext& ctx) const { return RObjInt(new CObjInt(ctx.k)); }
 
 
 //**************************************************************************************************
 //* CNodeSession: session-wide workspace information
 //**************************************************************************************************
 
-RObj CNodeSessionNK::tree_val( const CContext& ctx ) const
+RObj CNodeSessionNK::tree_val(const CContext& ctx) const
 {
-    return RObjInt( new CObjInt( SMem::instance()->mem_size() ) );
+    return RObjInt(new CObjInt(SMem::instance()->mem_size()));
 }
 
 
@@ -752,55 +708,55 @@ RObj CNodeSessionNK::tree_val( const CContext& ctx ) const
 //* CNodeFile: file-wide information
 //**************************************************************************************************
 
-RObj CNodeFile::tree_val( const CContext& ctx ) const
+RObj CNodeFile::tree_val(const CContext& ctx) const
 {
-    if  ( ctx.dim==CContext::_VI ) {
+    if (ctx.dim == CContext::_VI) {
         CContext myctx = ctx;
         myctx.dim = CContext::_1;
-        PObjVecObj pret( new CObjVecObj() );
-        for ( int ii=0; ii<ctx.nv; ++ii ) {
+        PObjVecObj pret(new CObjVecObj());
+        for (int ii = 0; ii < ctx.nv; ++ii) {
             myctx.i = ii;
-            pret->v.push_back( tree_val_scalar( myctx ) );
+            pret->v.push_back(tree_val_scalar(myctx));
         }
         return pret->to_vecnum();
     } else {
-        return tree_val_scalar( ctx );
+        return tree_val_scalar(ctx);
     }
 }
 
-CCoord CNodeFile::node_coord( int _k ) const
+CCoord CNodeFile::node_coord(int _k) const
 {
     int k;
     if (ref->tk) {
-        if ( ref->tk->i_dependent() || ref->tk->j_dependent() )
-            return CCoord( name()+ref->ref_info(), "" );
-        CContext ctx( _k );
-        k = ref->tk->tree_val_idx( ctx, "k" );
+        if (ref->tk->i_dependent() || ref->tk->j_dependent())
+            return CCoord(name() + ref->ref_info(), "");
+        CContext ctx(_k);
+        k = ref->tk->tree_val_idx(ctx, "k");
     } else {
         k = _k;
     }
-    const COlo *f = SMem::instance()->mem_get(k);
-    return file_coord( f );
+    const COlo* f = SMem::instance()->mem_get(k);
+    return file_coord(f);
 }
 
-RObj CNodeFileNJ::tree_val_scalar( const CContext& ctx ) const
+RObj CNodeFileNJ::tree_val_scalar(const CContext& ctx) const
 {
-    const COlo *f = SMem::instance()->mem_get( ref->get_k( ctx ) );
-    return RObjInt( new CObjInt( f->nJ() ) );
+    const COlo* f = SMem::instance()->mem_get(ref->get_k(ctx));
+    return RObjInt(new CObjInt(f->nJ()));
 }
 
-RObj CNodeFileR::tree_val_scalar( const CContext& ctx ) const
+RObj CNodeFileR::tree_val_scalar(const CContext& ctx) const
 {
-    const COlo *f = SMem::instance()->mem_get( ref->get_k( ctx ) );
-    if( num<0 || num>=f->RPar.size() )
-        throw "file has no parameter r"+S(num);
-    return RObjDbl( new CObjDbl( f->RPar[num].val ) );
+    const COlo* f = SMem::instance()->mem_get(ref->get_k(ctx));
+    if (num < 0 || num >= f->RPar.size())
+        throw "file has no parameter r" + S(num);
+    return RObjDbl(new CObjDbl(f->RPar[num].val));
 }
 
-CCoord CNodeFileR::file_coord( const COlo *f ) const
+CCoord CNodeFileR::file_coord(const COlo* f) const
 {
-    if( num<0 || num>=f->RPar.size() )
-        throw "file has no parameter r"+S(num);
+    if (num < 0 || num >= f->RPar.size())
+        throw "file has no parameter r" + S(num);
     return f->RPar[num].Co;
 }
 
@@ -810,206 +766,209 @@ CCoord CNodeFileR::file_coord( const COlo *f ) const
 //**************************************************************************************************
 
 
-RObj CNodeSliceZ::tree_val_scalar( const CContext& ctx ) const
+RObj CNodeSliceZ::tree_val_scalar(const CContext& ctx) const
 {
-    const COlo *f = SMem::instance()->mem_get( ref->get_k( ctx ) );
-    int j = PCAST<const CRef2>(ref)->get_j( ctx, f->nJ() );
-    const CSlice * s = f->V[j].get();
-    if ( num<0 || num>=s->z.size() )
-        throw "z"+S(num)+" requested, while only "+S(s->z.size())+" z entries are defined";
+    const COlo* f = SMem::instance()->mem_get(ref->get_k(ctx));
+    int j = PCAST<const CRef2>(ref)->get_j(ctx, f->nJ());
+    const CSlice* s = f->V[j].get();
+    if (num < 0 || num >= s->z.size())
+        throw "z" + S(num) + " requested, while only " + S(s->z.size()) + " z entries are defined";
     return s->z[num];
 }
 
-CCoord CNodeSliceZ::file_coord( const COlo *f ) const
+CCoord CNodeSliceZ::file_coord(const COlo* f) const
 {
-    if ( num<0 || num>=f->ZCo.size() )
-        throw "z"+S(num)+" requested, while only "+S(f->ZCo.size())+" z coordinates are defined";
+    if (num < 0 || num >= f->ZCo.size())
+        throw "z" + S(num) + " requested, while only " + S(f->ZCo.size())
+            + " z coordinates are defined";
     return f->ZCo[num];
 }
 
-RObj CNodeSpecNI::tree_val_scalar( const CContext& ctx ) const
+RObj CNodeSpecNI::tree_val_scalar(const CContext& ctx) const
 {
-    const COlo *f = SMem::instance()->mem_get( ref->get_k( ctx ) );
-    const COld *fd = dynamic_cast<const COld*>( f );
-    if ( !fd )
-        throw f->type()+" file has no property "+tree_info();
-    int j = PCAST<const CRef2>(ref)->get_j( ctx, f->nJ() );
-    return RObjInt( new CObjInt( fd->VS(j)->size() ) );
+    const COlo* f = SMem::instance()->mem_get(ref->get_k(ctx));
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd)
+        throw f->type() + " file has no property " + tree_info();
+    int j = PCAST<const CRef2>(ref)->get_j(ctx, f->nJ());
+    return RObjInt(new CObjInt(fd->VS(j)->size()));
 }
 
-RObj CNodeCurve::tree_val_scalar( const CContext& ctx ) const
+RObj CNodeCurve::tree_val_scalar(const CContext& ctx) const
 {
-    const COlo *f = SMem::instance()->mem_get( ref->get_k( ctx ) );
-    const COlc *fc = dynamic_cast<const COlc*>( f );
-    if ( !fc )
-        throw f->type()+" file has no property "+tree_info();
-    int j = PCAST<const CRef2>(ref)->get_j( ctx, f->nJ() );
-    return curve_val_scalar( fc->VC(j) );
+    const COlo* f = SMem::instance()->mem_get(ref->get_k(ctx));
+    const COlc* fc = dynamic_cast<const COlc*>(f);
+    if (!fc)
+        throw f->type() + " file has no property " + tree_info();
+    int j = PCAST<const CRef2>(ref)->get_j(ctx, f->nJ());
+    return curve_val_scalar(fc->VC(j));
 }
 
 
-RObj CNodeCurveP::curve_val_scalar( const CCurve * c ) const
+RObj CNodeCurveP::curve_val_scalar(const CCurve* c) const
 {
-    if ( num<0 || num>=c->P.size() )
-        throw "curve has no p"+S(num);
-    return RObjDbl( new CObjDbl( c->P[num] ) );
+    if (num < 0 || num >= c->P.size())
+        throw "curve has no p" + S(num);
+    return RObjDbl(new CObjDbl(c->P[num]));
 }
 
-CCoord CNodeCurveP::file_coord( const COlo *f ) const
+CCoord CNodeCurveP::file_coord(const COlo* f) const
 {
-    const COlc *fc = dynamic_cast<const COlc*>(f);
-    if ( !fc )
-        throw f->type()+" file has no property "+tree_info();
-    if ( num<0 || num>=fc->PCo.size() )
-        throw "p"+S(num)+" requested, while only "+S(fc->PCo.size())+" z coordinates are defined";
+    const COlc* fc = dynamic_cast<const COlc*>(f);
+    if (!fc)
+        throw f->type() + " file has no property " + tree_info();
+    if (num < 0 || num >= fc->PCo.size())
+        throw "p" + S(num) + " requested, while only " + S(fc->PCo.size())
+            + " z coordinates are defined";
     return fc->PCo[num];
 }
 
 
-RObj CNodeCurveOutcome::curve_val_scalar( const CCurve * c ) const
+RObj CNodeCurveOutcome::curve_val_scalar(const CCurve* c) const
 {
-    return RObjInt( new CObjInt( c->fitOutcome ) );
+    return RObjInt(new CObjInt(c->fitOutcome));
 }
 
-RObj CNodeCurveChi2::curve_val_scalar( const CCurve * c ) const
+RObj CNodeCurveChi2::curve_val_scalar(const CCurve* c) const
 {
-    return RObjDbl( new CObjDbl( c->fitChi2 ) );
+    return RObjDbl(new CObjDbl(c->fitChi2));
 }
 
-RObj CNodeCurveR2::curve_val_scalar( const CCurve * c ) const
+RObj CNodeCurveR2::curve_val_scalar(const CCurve* c) const
 {
-    return RObjDbl( new CObjDbl( c->fitR2 ) );
+    return RObjDbl(new CObjDbl(c->fitR2));
 }
 
 
-RObj CNodePoint::tree_val( const CContext& ctx ) const
+RObj CNodePoint::tree_val(const CContext& ctx) const
 {
     auto ref3 = PCAST<const CRef3>(ref);
-    if( !ref3 )
+    if (!ref3)
         throw S("BUG: NodePoint has no Ref3");
-    if ( ctx.dim==CContext::_VI ) {
-        if ( ref->k_depends_on_i() || ref3->j_depends_on_i() ) {
-            if ( ctx.nv<0 )
+    if (ctx.dim == CContext::_VI) {
+        if (ref->k_depends_on_i() || ref3->j_depends_on_i()) {
+            if (ctx.nv < 0)
                 throw S("BUG: i-dependent K or J with unspecified return array length");
             if (!ref3->ti) // Could be easily supported, but is forbidden to prevent accidental use
                 throw S("Explicit I required with i-dependent K or J");
-            PObjVecObj tmp( new CObjVecObj() );
+            PObjVecObj tmp(new CObjVecObj());
             CContext myctx(ctx);
             myctx.dim = CContext::_1;
-            for ( int i=0; i<ctx.nv; ++i ) {
+            for (int i = 0; i < ctx.nv; ++i) {
                 myctx.i = i;
-                tmp->v.push_back( tree_val_point ( myctx, ref3->ti->tree_val_idx( myctx, "i" ) ) );
+                tmp->v.push_back(tree_val_point(myctx, ref3->ti->tree_val_idx(myctx, "i")));
             }
             return tmp->to_vecnum();
-        } else if ( !ref3->ti || ref3->ti->i_dependent() ) {
-            return tree_val_vector( ctx );
+        } else if (!ref3->ti || ref3->ti->i_dependent()) {
+            return tree_val_vector(ctx);
         } else {
-            return tree_val_point( ctx, ref3->ti->tree_val_idx( ctx, "i" )  );
+            return tree_val_point(ctx, ref3->ti->tree_val_idx(ctx, "i"));
         }
     } else {
-        if ( ref3->ti ) {
-            return tree_val_point( ctx, ref3->ti->tree_val_idx( ctx, "i" )  );
+        if (ref3->ti) {
+            return tree_val_point(ctx, ref3->ti->tree_val_idx(ctx, "i"));
         } else {
-            return tree_val_point( ctx, ctx.i );
+            return tree_val_point(ctx, ctx.i);
         }
     }
 }
 
 
-RObj CNodePoint::tree_val_point( const CContext& ctx, int i ) const
+RObj CNodePoint::tree_val_point(const CContext& ctx, int i) const
 {
-    const COlo *f = SMem::instance()->mem_get( ref->get_k( ctx ) );
-    const COld *fd = dynamic_cast<const COld*>( f );
-    if ( !fd )
-        throw f->type()+" file has no property "+tree_info();
-    int j = PCAST<const CRef2>(ref)->get_j( ctx, f->nJ() );
-    const CSpec *s = fd->VS(j);
-    if ( i<0 || i>= s->size() )
-        throw "invalid data point index "+S(i)+", spectrum has length "+S(s->size());
-    return spec_val_point( s, i, ctx.want_error );
+    const COlo* f = SMem::instance()->mem_get(ref->get_k(ctx));
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd)
+        throw f->type() + " file has no property " + tree_info();
+    int j = PCAST<const CRef2>(ref)->get_j(ctx, f->nJ());
+    const CSpec* s = fd->VS(j);
+    if (i < 0 || i >= s->size())
+        throw "invalid data point index " + S(i) + ", spectrum has length " + S(s->size());
+    return spec_val_point(s, i, ctx.want_error);
 }
 
 
-RObj CNodePoint::tree_val_vector( const CContext& ctx ) const
+RObj CNodePoint::tree_val_vector(const CContext& ctx) const
 {
-    if ( ctx.dim!=CContext::_VI )
+    if (ctx.dim != CContext::_VI)
         throw S("BUG: unexpected context in tree_val_vector");
-    const COlo *f = SMem::instance()->mem_get( ref->get_k( ctx ) );
-    const COld *fd = dynamic_cast<const COld*>( f );
-    if ( !fd )
-        throw f->type()+" file has no property "+tree_info();
-    int j = PCAST<const CRef2>(ref)->get_j( ctx, f->nJ() );
-    const CSpec *s = fd->VS(j);
+    const COlo* f = SMem::instance()->mem_get(ref->get_k(ctx));
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd)
+        throw f->type() + " file has no property " + tree_info();
+    int j = PCAST<const CRef2>(ref)->get_j(ctx, f->nJ());
+    const CSpec* s = fd->VS(j);
     int n = ctx.nv;
-    if ( n<0 ) // ctx.nv=-1 is used in integral operations
+    if (n < 0) // ctx.nv=-1 is used in integral operations
         n = s->size();
-    else if ( n>s->size() )
-        throw "requested "+S(n)+" points while spectrum "+S(j)+" only has "+S(s->size())+" points";
-    return spec_val_vector( s, n, ctx.want_error );
+    else if (n > s->size())
+        throw "requested " + S(n) + " points while spectrum " + S(j) + " only has " + S(s->size())
+            + " points";
+    return spec_val_vector(s, n, ctx.want_error);
 }
 
 
-RObj CNodePointX::spec_val_point( const CSpec *s, int i, bool want_error ) const
+RObj CNodePointX::spec_val_point(const CSpec* s, int i, bool want_error) const
 {
-    return RObjDbl( new CObjDbl( s->x[i] ) );
+    return RObjDbl(new CObjDbl(s->x[i]));
 }
 
-RObj CNodePointX::spec_val_vector( const CSpec *s, int n, bool want_error ) const
+RObj CNodePointX::spec_val_vector(const CSpec* s, int n, bool want_error) const
 {
-    return RObjVecDbl( new CObjVecDbl( vector<double>(s->x.begin(), s->x.begin()+n ) ) );
+    return RObjVecDbl(new CObjVecDbl(vector<double>(s->x.begin(), s->x.begin() + n)));
 }
 
-CCoord CNodePointX::file_coord( const COlo *f ) const
+CCoord CNodePointX::file_coord(const COlo* f) const
 {
-    const COld *fd = dynamic_cast<const COld*>( f );
-    if ( !fd )
-        throw f->type()+" file has no property "+tree_info();
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd)
+        throw f->type() + " file has no property " + tree_info();
     return fd->xco;
 }
 
 
-RObj CNodePointY::spec_val_point( const CSpec *s, int i, bool want_error ) const
+RObj CNodePointY::spec_val_point(const CSpec* s, int i, bool want_error) const
 {
-    return want_error && s->has_dy() ?
-        RObjEnu( new CObjEnu( s->y[i], s->dy[i] ) ) :
-        RObjDbl( new CObjDbl( s->y[i] ) );
+    return want_error && s->has_dy() ? RObjEnu(new CObjEnu(s->y[i], s->dy[i]))
+                                     : RObjDbl(new CObjDbl(s->y[i]));
 }
 
-RObj CNodePointY::spec_val_vector( const CSpec *s, int n, bool want_error ) const
+RObj CNodePointY::spec_val_vector(const CSpec* s, int n, bool want_error) const
 {
-    return want_error && s->has_dy() ?
-        RObjVecEnu( new CObjVecEnu( vector<double>(s->y.begin(), s->y.begin()+n ),
-                                    vector<double>(s->dy.begin(), s->dy.begin()+n ) ) ) :
-        RObjVecDbl( new CObjVecDbl( vector<double>(s->y.begin(), s->y.begin()+n ) ) );
+    return want_error && s->has_dy()
+        ? RObjVecEnu(new CObjVecEnu(
+              vector<double>(s->y.begin(), s->y.begin() + n),
+              vector<double>(s->dy.begin(), s->dy.begin() + n)))
+        : RObjVecDbl(new CObjVecDbl(vector<double>(s->y.begin(), s->y.begin() + n)));
 }
 
-CCoord CNodePointY::file_coord( const COlo *f ) const
+CCoord CNodePointY::file_coord(const COlo* f) const
 {
-    const COld *fd = dynamic_cast<const COld*>( f );
-    if ( !fd )
-        throw f->type()+" file has no property "+tree_info();
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd)
+        throw f->type() + " file has no property " + tree_info();
     return fd->yco;
 }
 
 
-RObj CNodePointDY::spec_val_point( const CSpec *s, int i, bool want_error ) const
+RObj CNodePointDY::spec_val_point(const CSpec* s, int i, bool want_error) const
 {
-    return RObjDbl( new CObjDbl( s->dy[i] ) );
+    return RObjDbl(new CObjDbl(s->dy[i]));
 }
 
-RObj CNodePointDY::spec_val_vector( const CSpec *s, int n, bool want_error ) const
+RObj CNodePointDY::spec_val_vector(const CSpec* s, int n, bool want_error) const
 {
-    if ( !s->has_dy() )
+    if (!s->has_dy())
         throw S("requested dy does not exist");
-    return RObjVecDbl( new CObjVecDbl( vector<double>(s->dy.begin(), s->dy.begin()+n ) ) );
+    return RObjVecDbl(new CObjVecDbl(vector<double>(s->dy.begin(), s->dy.begin() + n)));
 }
 
-CCoord CNodePointDY::file_coord( const COlo *f ) const
+CCoord CNodePointDY::file_coord(const COlo* f) const
 {
-    const COld *fd = dynamic_cast<const COld*>( f );
-    if ( !fd )
-        throw f->type()+" file has no property "+tree_info();
-    return CCoord( "d"+fd->yco.name, fd->yco.unit );
+    const COld* fd = dynamic_cast<const COld*>(f);
+    if (!fd)
+        throw f->type() + " file has no property " + tree_info();
+    return CCoord("d" + fd->yco.name, fd->yco.unit);
 }
 
 
@@ -1017,20 +976,19 @@ CCoord CNodePointDY::file_coord( const COlo *f ) const
 //* CNodeIdf: identifier node
 //**************************************************************************************************
 
-CNodeIdf::CNodeIdf( string _idf )
-    : idf( _idf ) {}
+CNodeIdf::CNodeIdf(string _idf) : idf(_idf) {}
 
-RObj CNodeIdf::tree_val( const CContext& ctx ) const
+RObj CNodeIdf::tree_val(const CContext& ctx) const
 {
-    PObj ret = SVariRegistry::instance()->find( idf );
-    if ( !ret )
-        throw "uninitialized variable "+idf;
+    PObj ret = SVariRegistry::instance()->find(idf);
+    if (!ret)
+        throw "uninitialized variable " + idf;
     return ret;
 }
 
-CCoord CNodeIdf::node_coord( int k ) const
+CCoord CNodeIdf::node_coord(int k) const
 {
-    return CCoord( idf, "" );  // primitiver gehts nicht
+    return CCoord(idf, ""); // primitiver gehts nicht
 }
 
 
@@ -1038,11 +996,11 @@ CCoord CNodeIdf::node_coord( int k ) const
 //* CNodeDummy: function argument (t) node
 //**************************************************************************************************
 
-RObj CNodeDummy::tree_val( const CContext& ctx ) const
+RObj CNodeDummy::tree_val(const CContext& ctx) const
 {
-    if ( !(ctx.vt) )
+    if (!(ctx.vt))
         throw "BUG: tree_val with *vt=0";
-    RObjVecDbl pret( new CObjVecDbl( *(ctx.vt) ) );
+    RObjVecDbl pret(new CObjVecDbl(*(ctx.vt)));
     return pret;
 }
 
@@ -1053,64 +1011,63 @@ RObj CNodeDummy::tree_val( const CContext& ctx ) const
 
 //! A curve evaluation: fc[k,j](arg).
 
-RObj CNodeCev::tree_val( const CContext& ctx ) const
+RObj CNodeCev::tree_val(const CContext& ctx) const
 {
     try {
         // get k, curve, j from context:
-        int k = ref->get_k( ctx );
-        const COlc *fc = SMem::instance()->mem_get_C( k );
-        int j = PCAST<const CRef2>(ref)->get_j( ctx, fc->nJ() );
+        int k = ref->get_k(ctx);
+        const COlc* fc = SMem::instance()->mem_get_C(k);
+        int j = PCAST<const CRef2>(ref)->get_j(ctx, fc->nJ());
 
         // evaluate function argument:
-        RObj farg = arg->tree_val( ctx );
+        RObj farg = arg->tree_val(ctx);
 
         // evaluate the curve:
-        if ( RObjVecDbl pv_farg = PCAST<const CObjVecDbl>(farg) ) {
-            return fc->eval_curve( pv_farg->v, k, j, ctx.want_error );
-        } else if ( RObjNum pn_farg = PCAST<const CObjNum>(farg) ) {
-            return fc->eval_curve_scalar( pn_farg->to_r(), k, j, ctx.want_error );
+        if (RObjVecDbl pv_farg = PCAST<const CObjVecDbl>(farg)) {
+            return fc->eval_curve(pv_farg->v, k, j, ctx.want_error);
+        } else if (RObjNum pn_farg = PCAST<const CObjNum>(farg)) {
+            return fc->eval_curve_scalar(pn_farg->to_r(), k, j, ctx.want_error);
         } else
             throw S("unexpected argument type");
-    } catch( string& ex ) {
+    } catch (string& ex) {
         throw ex + " in NodeCev " + tree_info() + " {context: " + ctx.context_info() + "}";
     }
 }
 
-CCoord CNodeCev::node_coord( int k ) const {
-    return CCoord( "c", "" ); } // primitiver gehts nicht
+CCoord CNodeCev::node_coord(int k) const { return CCoord("c", ""); } // primitiver gehts nicht
 
 
 //**************************************************************************************************
 //* CNodeMixin: Base class for mixing in data from a "convolution" file
 //**************************************************************************************************
 
-RObj CNodeMixin::tree_val( const CContext& ctx ) const
+RObj CNodeMixin::tree_val(const CContext& ctx) const
 {
     // Shift:
-    RObj res_shift = shift->tree_val( ctx );
+    RObj res_shift = shift->tree_val(ctx);
     RObjNum par = PCAST<const CObjNum>(res_shift);
-    if( !par )
+    if (!par)
         throw S("shift is not a scalar");
     double theshift = par->to_r();
 
     // Resolution is given by context 'ctx':
     int kconv, jconv;
-    const CSpec *sv;
-    NCurveFile::get_conv( &sv, &kconv, &jconv, ctx.k, ctx.j );
+    const CSpec* sv;
+    NCurveFile::get_conv(&sv, &kconv, &jconv, ctx.k, ctx.j);
 
-    PObjVecDbl pret( ctx.want_error ? (new CObjVecDbl) : (new CObjVecEnu) );
+    PObjVecDbl pret(ctx.want_error ? (new CObjVecDbl) : (new CObjVecEnu));
 
-    if ( kconv==-1 ) {
-        return copy_theory( ctx, theshift );
+    if (kconv == -1) {
+        return copy_theory(ctx, theshift);
     } else {
         double conv_norm; // normalization constant (integral of resolution)
         double conv_step; // step in x/t, if equidistant
         string info = "resolution " + S(kconv) + ", spectrum " + S(jconv);
-        conv_norm = sv->norm( info );
-        conv_step = sv->has_step( ctx.vt_step ) ? ctx.vt_step : 0;
-        if( !conv_step && !allow_slow_conv )
+        conv_norm = sv->norm(info);
+        conv_step = sv->has_step(ctx.vt_step) ? ctx.vt_step : 0;
+        if (!conv_step && !allow_slow_conv)
             throw S("grid is not equidistant; slow convolution is not allowed");
-        return convolve( ctx, theshift, sv, conv_norm, conv_step );
+        return convolve(ctx, theshift, sv, conv_norm, conv_step);
     }
 }
 
@@ -1119,13 +1076,13 @@ RObj CNodeMixin::tree_val( const CContext& ctx ) const
 //* CNodeConv: convoluted function node
 //**************************************************************************************************
 
-RObj CNodeConv::copy_theory( const CContext& ctx, double theshift ) const
+RObj CNodeConv::copy_theory(const CContext& ctx, double theshift) const
 {
-    return theory->tree_val( ctx );
+    return theory->tree_val(ctx);
 }
 
-RObjVecDbl CNodeConv::convolve( const CContext& ctx, double theshift, const CSpec* sv,
-                                double conv_norm, double conv_step ) const
+RObjVecDbl CNodeConv::convolve(
+    const CContext& ctx, double theshift, const CSpec* sv, double conv_norm, double conv_step) const
 {
     int n = ctx.vt->size();
     int nv = sv->size();
@@ -1134,62 +1091,62 @@ RObjVecDbl CNodeConv::convolve( const CContext& ctx, double theshift, const CSpe
     cv_ctx.vt = &tt;
     PObjVecDbl ret;
     PObjVecEnu dret;
-    if ( ctx.want_error ) {
-       dret = PObjVecEnu( new CObjVecEnu(n) );
-       ret = dret;
+    if (ctx.want_error) {
+        dret = PObjVecEnu(new CObjVecEnu(n));
+        ret = dret;
     } else {
-        ret = PObjVecDbl( new CObjVecDbl(n) );
+        ret = PObjVecDbl(new CObjVecDbl(n));
         dret = nullptr;
     }
     // Convolute theory with resolution.
-    if( conv_step ){ // accelerated version with equidistant grids
+    if (conv_step) { // accelerated version with equidistant grids
         // precompute theory on unified grid
         int ntt = n + nv - 1;
         tt.resize(ntt);
-        double tt0 = (*(ctx.vt))[0] - sv->x[0] - theshift - (nv-1)*conv_step;
-        for ( int ii=0; ii<ntt; ++ii ) // ii=(nv-1)+i-iv
-            tt[ii] = tt0 + ii*conv_step;
-        RObj res_theory = theory->tree_val( cv_ctx );
+        double tt0 = (*(ctx.vt))[0] - sv->x[0] - theshift - (nv - 1) * conv_step;
+        for (int ii = 0; ii < ntt; ++ii) // ii=(nv-1)+i-iv
+            tt[ii] = tt0 + ii * conv_step;
+        RObj res_theory = theory->tree_val(cv_ctx);
         // now convolve
-        for ( int i=0; i<n; ++i ){
+        for (int i = 0; i < n; ++i) {
             ret->v[i] = 0;
-            if( dret )
+            if (dret)
                 dret->dv[i] = 0;
-            for ( int iv=0; iv<nv; ++iv ) {
-                ret->v[i] += res_theory->to_r(nv-1+i-iv) * sv->y[iv];
-                if( dret )
-                    dret->dv[i] += fabs(res_theory->to_r(nv-1+i-iv)) * SQR(sv->dy[iv]);
+            for (int iv = 0; iv < nv; ++iv) {
+                ret->v[i] += res_theory->to_r(nv - 1 + i - iv) * sv->y[iv];
+                if (dret)
+                    dret->dv[i] += fabs(res_theory->to_r(nv - 1 + i - iv)) * SQR(sv->dy[iv]);
             }
             ret->v[i] *= conv_step / conv_norm;
-            if( dret )
+            if (dret)
                 dret->dv[i] = sqrt(dret->dv[i]) * conv_step / conv_norm;
         }
     } else { // simplest version: non-equidistant x_out and x_res.
-        ret->v.assign( n, 0. );
-        if( dret )
-            dret->dv.assign( n, 0. );
+        ret->v.assign(n, 0.);
+        if (dret)
+            dret->dv.assign(n, 0.);
         tt.resize(n);
-        for ( int iv=0; iv<nv; ++iv ) {
+        for (int iv = 0; iv < nv; ++iv) {
             double dx; // variable step
-            if      ( iv==0 )
+            if (iv == 0)
                 dx = sv->x[1] - sv->x[0];
-            else if ( iv==nv-1 )
-                dx = sv->x[nv-1] - sv->x[nv-2];
+            else if (iv == nv - 1)
+                dx = sv->x[nv - 1] - sv->x[nv - 2];
             else
-                dx = ( sv->x[iv+1] - sv->x[iv-1] ) / 2;
-            for ( int i=0; i<n; ++i )
+                dx = (sv->x[iv + 1] - sv->x[iv - 1]) / 2;
+            for (int i = 0; i < n; ++i)
                 tt[i] = (*(ctx.vt))[i] - sv->x[iv] - theshift;
-            RObj res_theory = theory->tree_val( cv_ctx );
-            for ( int i=0; i<n; ++i ) {
+            RObj res_theory = theory->tree_val(cv_ctx);
+            for (int i = 0; i < n; ++i) {
                 ret->v[i] += res_theory->to_r(i) * sv->y[iv] * dx;
-                if( dret )
+                if (dret)
                     dret->dv[i] += res_theory->to_r(i) * SQR(sv->dy[iv]);
             }
         }
-        for ( int i=0; i<n; ++i ) {
+        for (int i = 0; i < n; ++i) {
             ret->v[i] /= conv_norm;
-            if( dret )
-                dret->dv[i] = sqrt(dret->dv[i])/conv_norm;
+            if (dret)
+                dret->dv[i] = sqrt(dret->dv[i]) / conv_norm;
         }
     }
     return ret;
@@ -1200,18 +1157,18 @@ RObjVecDbl CNodeConv::convolve( const CContext& ctx, double theshift, const CSpe
 //* CNodePConv: convolution with primitive
 //**************************************************************************************************
 
-RObj CNodePConv::copy_theory( const CContext& ctx, double theshift ) const
+RObj CNodePConv::copy_theory(const CContext& ctx, double theshift) const
 {
     throw "non-convolution not implemented for pconv";
     // to implement this efficiently, I would like to have CObj::operator+
     // for which we should go to shared pointers ...
 }
 
-RObjVecDbl CNodePConv::convolve( const CContext& ctx, double theshift, const CSpec* sv,
-                                 double conv_norm, double conv_step ) const
+RObjVecDbl CNodePConv::convolve(
+    const CContext& ctx, double theshift, const CSpec* sv, double conv_norm, double conv_step) const
 {
-    if( conv_norm <= 0 )
-        throw "BUG: pconv called with conv_norm="+S(conv_norm);
+    if (conv_norm <= 0)
+        throw "BUG: pconv called with conv_norm=" + S(conv_norm);
     int n = ctx.vt->size();
     int nv = sv->size();
     CContext cv_ctx(ctx);
@@ -1219,100 +1176,100 @@ RObjVecDbl CNodePConv::convolve( const CContext& ctx, double theshift, const CSp
     cv_ctx.vt = &tt;
     PObjVecDbl ret;
     PObjVecEnu dret;
-    if ( ctx.want_error ) {
-       dret = PObjVecEnu( new CObjVecEnu(n) );
-       ret = dret;
-       // A check. We don't care about the cost O(nv), since this node is O(n*nv).
-       for ( int iv=0; iv<nv; ++iv ) {
-           if ( !std::isfinite(sv->dy[iv]) )
-               throw S("resolution function contains non-finite error");
-           if ( sv->dy[iv]<0 )
-               throw S("resolution function contains negative error");
-       }
+    if (ctx.want_error) {
+        dret = PObjVecEnu(new CObjVecEnu(n));
+        ret = dret;
+        // A check. We don't care about the cost O(nv), since this node is O(n*nv).
+        for (int iv = 0; iv < nv; ++iv) {
+            if (!std::isfinite(sv->dy[iv]))
+                throw S("resolution function contains non-finite error");
+            if (sv->dy[iv] < 0)
+                throw S("resolution function contains negative error");
+        }
     } else {
-        ret = PObjVecDbl( new CObjVecDbl(n) );
+        ret = PObjVecDbl(new CObjVecDbl(n));
         dret = nullptr;
     }
     // Convolute theory with resolution.
-    if( conv_step ){ // accelerated version with equidistant grids
+    if (conv_step) { // accelerated version with equidistant grids
         // precompute primitive on unified grid
         int ntt = n + nv + 1;
         tt.resize(ntt);
-        double tt0 = (*(ctx.vt))[0] - sv->x[0] - theshift - (nv-0.5)*conv_step;
-        for ( int ii=0; ii<ntt; ++ii ) // ii=(nv-1)+i-iv
-            tt[ii] = tt0 + ii*conv_step;
-        RObj res_theory = theory->tree_val( cv_ctx );
-        if ( res_theory->size() != ntt )
+        double tt0 = (*(ctx.vt))[0] - sv->x[0] - theshift - (nv - 0.5) * conv_step;
+        for (int ii = 0; ii < ntt; ++ii) // ii=(nv-1)+i-iv
+            tt[ii] = tt0 + ii * conv_step;
+        RObj res_theory = theory->tree_val(cv_ctx);
+        if (res_theory->size() != ntt)
             throw S("BUG: unexpected size conflict");
-        for ( int it=0; it<ntt; ++it )
-            if ( !std::isfinite(res_theory->to_r(it)) )
+        for (int it = 0; it < ntt; ++it)
+            if (!std::isfinite(res_theory->to_r(it)))
                 throw S("theory returns infinite value");
-        for ( int it=0; it<ntt-1; ++it )
-            if( res_theory->to_r(it) > res_theory->to_r(it+1) )
-                throw "theory is decreasing from S(" + S(tt[it]) + "=" + S(res_theory->to_r(it)) +
-                    " to S(" + S(tt[it+1]) + "=" + S(res_theory->to_r(it+1));
+        for (int it = 0; it < ntt - 1; ++it)
+            if (res_theory->to_r(it) > res_theory->to_r(it + 1))
+                throw "theory is decreasing from S(" + S(tt[it]) + "=" + S(res_theory->to_r(it))
+                    + " to S(" + S(tt[it + 1]) + "=" + S(res_theory->to_r(it + 1));
         // now convolve resolution with differential of primitive
-        for ( int i=0; i<n; ++i ){
+        for (int i = 0; i < n; ++i) {
             ret->v[i] = 0;
-            if( dret )
+            if (dret)
                 dret->dv[i] = 0;
-            for ( int iv=0; iv<nv; ++iv ) {
-                double igral = res_theory->to_r(nv+i-iv) - res_theory->to_r(nv-1+i-iv);
+            for (int iv = 0; iv < nv; ++iv) {
+                double igral = res_theory->to_r(nv + i - iv) - res_theory->to_r(nv - 1 + i - iv);
                 ret->v[i] += igral * sv->y[iv];
-                if( dret )
+                if (dret)
                     dret->dv[i] += SQR(igral * sv->dy[iv]);
             }
             ret->v[i] /= conv_norm;
-            if ( !std::isfinite(ret->v[i]) )
+            if (!std::isfinite(ret->v[i]))
                 throw S("BUG: pconv result has nonfinite result");
-            if( dret ) {
-                if ( !std::isfinite(dret->dv[i]) )
+            if (dret) {
+                if (!std::isfinite(dret->dv[i]))
                     throw S("BUG: pconv result has nonfinite variance");
-                if ( dret->dv[i]<0 )
+                if (dret->dv[i] < 0)
                     throw S("BUG: pconv result has negative variance");
                 dret->dv[i] = sqrt(dret->dv[i]) / conv_norm;
-                if ( !std::isfinite(dret->dv[i]) )
+                if (!std::isfinite(dret->dv[i]))
                     throw S("BUG: pconv result has nonfinite error");
             }
         }
     } else { // simplest version: non-equidistant x_out and x_res.
         throw S("PCONV BROKEN");
-/*
-        ret->v.assign( n, 0. );
-        if( with_error )
-            ret->dv.assign( n, 0. );
-        tt.resize(n);
-        RObj res_theory_low;
-        RObj res_theory_hig;
-        double dx;
-        for ( int iv=0; iv<nv; ++iv ) {
-            if      ( iv==0 )
-                dx = sv->x[1] - sv->x[0];
-            else if ( iv==nv-1 )
-                dx = sv->x[nv-1] - sv->x[nv-2];
-            else
-                dx = ( sv->x[iv+1] - sv->x[iv-1] ) / 2;
-            for ( int i=0; i<n; ++i ) {
-                tt[i] = (*(ctx.vt))[i] - sv->x[iv] - theshift - dx/2;
-                theory->tree_val( res_theory_low, cv_ctx );
-            }
-            for ( int i=0; i<n; ++i ) {
-                tt[i] = (*(ctx.vt))[i] - sv->x[iv] - theshift + dx/2;
-                theory->tree_val( res_theory_hig, cv_ctx );
-            }
-            for ( int i=0; i<n; ++i ) {
-                double igral = res_theory_hig->to_r(i)-res_theory_low->to_r(i);
-                ret->v[i] += igral * sv->y[iv] * dx;
-                if ( with_error )
-                    ret->dv[i] += igral * SQR(sv->dy[iv]) * dx;
-            }
-        }
-        for ( int i=0; i<n; ++i ) {
-            ret->v[i] /= conv_norm;
-            if ( with_error )
-                ret->dv[i] = sqrt(ret->dv[i]) / conv_norm;
-        }
-*/
+        /*
+                ret->v.assign( n, 0. );
+                if( with_error )
+                    ret->dv.assign( n, 0. );
+                tt.resize(n);
+                RObj res_theory_low;
+                RObj res_theory_hig;
+                double dx;
+                for ( int iv=0; iv<nv; ++iv ) {
+                    if      ( iv==0 )
+                        dx = sv->x[1] - sv->x[0];
+                    else if ( iv==nv-1 )
+                        dx = sv->x[nv-1] - sv->x[nv-2];
+                    else
+                        dx = ( sv->x[iv+1] - sv->x[iv-1] ) / 2;
+                    for ( int i=0; i<n; ++i ) {
+                        tt[i] = (*(ctx.vt))[i] - sv->x[iv] - theshift - dx/2;
+                        theory->tree_val( res_theory_low, cv_ctx );
+                    }
+                    for ( int i=0; i<n; ++i ) {
+                        tt[i] = (*(ctx.vt))[i] - sv->x[iv] - theshift + dx/2;
+                        theory->tree_val( res_theory_hig, cv_ctx );
+                    }
+                    for ( int i=0; i<n; ++i ) {
+                        double igral = res_theory_hig->to_r(i)-res_theory_low->to_r(i);
+                        ret->v[i] += igral * sv->y[iv] * dx;
+                        if ( with_error )
+                            ret->dv[i] += igral * SQR(sv->dy[iv]) * dx;
+                    }
+                }
+                for ( int i=0; i<n; ++i ) {
+                    ret->v[i] /= conv_norm;
+                    if ( with_error )
+                        ret->dv[i] = sqrt(ret->dv[i]) / conv_norm;
+                }
+        */
     }
     return ret;
 }
@@ -1322,52 +1279,49 @@ RObjVecDbl CNodePConv::convolve( const CContext& ctx, double theshift, const CSp
 //* CNodeDirac: node that copies the resolution function
 //**************************************************************************************************
 
-RObj CNodeDirac::copy_theory( const CContext& ctx, double theshift ) const
+RObj CNodeDirac::copy_theory(const CContext& ctx, double theshift) const
 {
     // Naive representation of delta function,
     // for use when convolution is switched off.
-    PObjVecDbl ret( new CObjVecDbl( ctx.vt->size()));
-    for ( int i=0; i<ctx.vt->size(); ++i )
-        ret->v[i] = fabs((*(ctx.vt))[i]-theshift)<1e-2 ? 1e2 : 0;
+    PObjVecDbl ret(new CObjVecDbl(ctx.vt->size()));
+    for (int i = 0; i < ctx.vt->size(); ++i)
+        ret->v[i] = fabs((*(ctx.vt))[i] - theshift) < 1e-2 ? 1e2 : 0;
     return ret;
 }
 
 //! Convolution or Dirac function: conv(f, shift), dirac(shift).
 
-RObjVecDbl CNodeDirac::convolve( const CContext& ctx, double theshift, const CSpec* sv,
-                                 double conv_norm, double conv_step ) const
+RObjVecDbl CNodeDirac::convolve(
+    const CContext& ctx, double theshift, const CSpec* sv, double conv_norm, double conv_step) const
 {
     int n = ctx.vt->size();
     PObjVecDbl ret;
     PObjVecEnu dret;
-    if ( ctx.want_error ) {
-        dret = PObjVecEnu( new CObjVecEnu(n) );
+    if (ctx.want_error) {
+        dret = PObjVecEnu(new CObjVecEnu(n));
         ret = dret;
     } else {
-        ret = PObjVecDbl( new CObjVecDbl(n) );
+        ret = PObjVecDbl(new CObjVecDbl(n));
         dret = nullptr;
     }
     // Delta function copies resolution.
     vector<double> tt(n), yy(n), dd(n);
     // shift in t
-    for ( int i=0; i<n; ++i )
-        tt[i] = (*(ctx.vt))[i]-theshift;
+    for (int i = 0; i < n; ++i)
+        tt[i] = (*(ctx.vt))[i] - theshift;
     // interpolation
     try {
-        sv->intpol( tt, &yy, dret ? &dd : nullptr );
-    } catch( string& s ) {
-        throw "error while evaluating delta function with shift "+S(theshift)+": "+s;
+        sv->intpol(tt, &yy, dret ? &dd : nullptr);
+    } catch (string& s) {
+        throw "error while evaluating delta function with shift " + S(theshift) + ": " + s;
     }
     // normalization
-    for ( int i=0; i<n; ++i ) {
+    for (int i = 0; i < n; ++i) {
         ret->v[i] = yy[i] / conv_norm;
-        if( dret )
+        if (dret)
             dret->dv[i] = dd[i] / conv_norm;
     }
     return ret;
 }
 
-CCoord CNodeDirac::node_coord( int k ) const
-{
-    return CCoord("resol", "");
-}
+CCoord CNodeDirac::node_coord(int k) const { return CCoord("resol", ""); }
diff --git a/pub/lib/node.hpp b/pub/lib/node.hpp
index 4a49a812780c166365ffe4c0a36a1d578498f82f..d32103dbbefeb0f70d923d7679e3d80c229b4cda 100644
--- a/pub/lib/node.hpp
+++ b/pub/lib/node.hpp
@@ -12,76 +12,90 @@
 
 //! Node with a few arguments. Pure virtual base class.
 
-class CNodeWithArgs: public CNode {
- protected:
+class CNodeWithArgs : public CNode
+{
+protected:
     int narg;
     vector<RNode> arg;
- public:
-    CNodeWithArgs( int _narg ) : narg(_narg) { arg.resize(narg); }
+
+public:
+    CNodeWithArgs(int _narg) : narg(_narg) { arg.resize(narg); }
     int npar() const;
     bool k_dependent() const;
     bool j_dependent() const;
     bool i_dependent() const;
     bool has_dummy() const;
     bool has_conv() const;
-    virtual string tree_info() const =0;
+    virtual string tree_info() const = 0;
 };
 
 
 //! Generic function/operator node. Pure virtual base class.
 
-class CNodeFun: public CNodeWithArgs {
- protected:
+class CNodeFun : public CNodeWithArgs
+{
+protected:
     const class CFunc* fu;
- public:
-    CNodeFun( int _narg, const class CFunc* _fu ) : CNodeWithArgs(_narg), fu(_fu) {}
-    RObj tree_val( const CContext& ctx ) const;
-    virtual CCoord node_coord( int k ) const =0;
-    virtual string tree_info() const =0;
+
+public:
+    CNodeFun(int _narg, const class CFunc* _fu) : CNodeWithArgs(_narg), fu(_fu) {}
+    RObj tree_val(const CContext& ctx) const;
+    virtual CCoord node_coord(int k) const = 0;
+    virtual string tree_info() const = 0;
 };
 
 
 //! Function/operator node with one argument.
 
-class CNodeFun1: public CNodeFun {
- public:
-    CNodeFun1( const class CFunc *_fu, RNode a0 );
-    CCoord node_coord( int k ) const;
+class CNodeFun1 : public CNodeFun
+{
+public:
+    CNodeFun1(const class CFunc* _fu, RNode a0);
+    CCoord node_coord(int k) const;
     string tree_info() const;
 };
 
 
 //! Function/operator node with two arguments.
 
-class CNodeFun2: public CNodeFun {
- public:
-    CNodeFun2( const class CFunc *_fu, RNode a0, RNode a1 );
-    CCoord node_coord( int k ) const;
+class CNodeFun2 : public CNodeFun
+{
+public:
+    CNodeFun2(const class CFunc* _fu, RNode a0, RNode a1);
+    CCoord node_coord(int k) const;
     string tree_info() const;
 };
 
 
 //! Function/operator node with three arguments.
 
-class CNodeFun3: public CNodeFun {
- public:
-    CNodeFun3( const class CFunc *_fu, RNode a0, RNode a1, RNode a2 );
-    CCoord node_coord( int k ) const;
+class CNodeFun3 : public CNodeFun
+{
+public:
+    CNodeFun3(const class CFunc* _fu, RNode a0, RNode a1, RNode a2);
+    CCoord node_coord(int k) const;
     string tree_info() const;
 };
 
 
 //! Range node.
 
-class CNodeRange: public CNodeWithArgs {
- private:
+class CNodeRange : public CNodeWithArgs
+{
+private:
     bool inclusive_end;
- public:
-    CNodeRange( bool _inclusive_end, RNode _beg=nullptr, RNode _end=nullptr, RNode _step=nullptr )
+
+public:
+    CNodeRange(
+        bool _inclusive_end, RNode _beg = nullptr, RNode _end = nullptr, RNode _step = nullptr)
         : CNodeWithArgs(3), inclusive_end(_inclusive_end)
-        { arg[0] = _beg; arg[1] = _end; arg[2] = _step; }
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const;
+    {
+        arg[0] = _beg;
+        arg[1] = _end;
+        arg[2] = _step;
+    }
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const;
     string tree_info() const;
     bool looks_like_indices() const { return !arg[0] || arg[0]->looks_like_indices(); }
 };
@@ -89,12 +103,13 @@ class CNodeRange: public CNodeWithArgs {
 
 //! List node.
 
-class CNodeList: public CNodeWithArgs {
- public:
-    CNodeList( RNode _list, RNode _incr );
+class CNodeList : public CNodeWithArgs
+{
+public:
+    CNodeList(RNode _list, RNode _incr);
     vector<RNode> args() const { return arg; }
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const;
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const;
     string tree_info() const;
     bool looks_like_indices() const { return arg[0] && arg[0]->looks_like_indices(); }
 };
@@ -102,46 +117,52 @@ class CNodeList: public CNodeWithArgs {
 
 //! Generalized integral node.
 
-class CNodeGeni: public CNodeWithArgs {
- private:
+class CNodeGeni : public CNodeWithArgs
+{
+private:
     const class CGeni* geni;
- public:
-    CNodeGeni( const class CGeni *_geni, RRef _ref=nullptr );
-    CNodeGeni( const class CGeni *_geni, RNode a0 );
-    CNodeGeni( const class CGeni *_geni, RNode a0, RNode a1 );
+
+public:
+    CNodeGeni(const class CGeni* _geni, RRef _ref = nullptr);
+    CNodeGeni(const class CGeni* _geni, RNode a0);
+    CNodeGeni(const class CGeni* _geni, RNode a0, RNode a1);
     bool k_dependent() const { return true; }
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const;
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const;
     string tree_info() const;
 };
 
 
 //! Curve functional node.
 
-class CNodeCvin: public CNodeWithArgs {
- private:
+class CNodeCvin : public CNodeWithArgs
+{
+private:
     const class CCvin* cvin;
     RRef ref;
- public:
-    CNodeCvin( const class CCvin *_cvin, RRef _ref, RNode a0, RNode a1 );
+
+public:
+    CNodeCvin(const class CCvin* _cvin, RRef _ref, RNode a0, RNode a1);
     bool k_dependent() const { return true; }
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const;
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const;
     string tree_info() const;
 };
 
 
 //! End node with fixed numeric value.
 
-class CNodeVal: public CNode {
- private:
+class CNodeVal : public CNode
+{
+private:
     RObj val;
- public:
-    CNodeVal( RObj _val ) : val( _val ) {}
-    CNodeVal( double _val );
-    CNodeVal( int _val );
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const;
+
+public:
+    CNodeVal(RObj _val) : val(_val) {}
+    CNodeVal(double _val);
+    CNodeVal(int _val);
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const;
     string tree_info() const;
     bool looks_like_indices() const;
 };
@@ -149,18 +170,20 @@ class CNodeVal: public CNode {
 
 //! Index node base class.
 
-class CNodeIdx: public CNode {
- public:
+class CNodeIdx : public CNode
+{
+public:
     bool k_dependent() const { return true; }
 };
 
 
 //! Index i node.
 
-class CNodeIdxI: public CNodeIdx {
- public:
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const { return CCoord("i", ""); }
+class CNodeIdxI : public CNodeIdx
+{
+public:
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const { return CCoord("i", ""); }
     string tree_info() const { return "i"; }
     bool i_dependent() const { return true; }
 };
@@ -168,10 +191,11 @@ class CNodeIdxI: public CNodeIdx {
 
 //! Index j node.
 
-class CNodeIdxJ: public CNodeIdx {
- public:
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const { return CCoord("j", ""); }
+class CNodeIdxJ : public CNodeIdx
+{
+public:
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const { return CCoord("j", ""); }
     string tree_info() const { return "j"; }
     bool j_dependent() const { return true; }
 };
@@ -179,319 +203,368 @@ class CNodeIdxJ: public CNodeIdx {
 
 //! Index k node.
 
-class CNodeIdxK: public CNodeIdx {
- public:
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const { return CCoord("k", ""); }
+class CNodeIdxK : public CNodeIdx
+{
+public:
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const { return CCoord("k", ""); }
     string tree_info() const { return "k"; }
 };
 
 
 //! Session-wide workspace information: NK = number of online files.
 
-class CNodeSessionNK: public CNode {
- public:
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const { return CCoord("nk", ""); }
+class CNodeSessionNK : public CNode
+{
+public:
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const { return CCoord("nk", ""); }
     string tree_info() const { return "nk"; }
 };
 
 
 //! File-wide information.
 
-class CNodeFile: public CNode {
- private:
-    virtual RObj tree_val_scalar( const CContext& ctx ) const {
-        throw S("BUG: unforeseen call to CNodeFile::tree_val_scalar"); }
-    virtual CCoord file_coord( const COlo *f ) const { return CCoord(name(), ""); }
- protected:
+class CNodeFile : public CNode
+{
+private:
+    virtual RObj tree_val_scalar(const CContext& ctx) const
+    {
+        throw S("BUG: unforeseen call to CNodeFile::tree_val_scalar");
+    }
+    virtual CCoord file_coord(const COlo* f) const { return CCoord(name(), ""); }
+protected:
     RRef ref;
- public:
-    CNodeFile( RRef _ref ) : ref(_ref) {}
-    void set_ref( RRef& _ref ) { ref = _ref; };
+
+public:
+    CNodeFile(RRef _ref) : ref(_ref) {}
+    void set_ref(RRef& _ref) { ref = _ref; };
     bool k_dependent() const { return true; }
-    RObj tree_val( const CContext& ctx ) const;
+    RObj tree_val(const CContext& ctx) const;
     string tree_info() const { return name() + ref->ref_info(); }
-    CCoord node_coord( int k ) const;
+    CCoord node_coord(int k) const;
     virtual string name() const = 0;
 };
 
 
 //! File-wide information: NJ = number of slices.
 
-class CNodeFileNJ: public CNodeFile {
- public:
-    CNodeFileNJ( RRef _ref ) : CNodeFile( _ref) {}
+class CNodeFileNJ : public CNodeFile
+{
+public:
+    CNodeFileNJ(RRef _ref) : CNodeFile(_ref) {}
     string name() const { return "nj"; }
-    RObj tree_val_scalar( const CContext& ctx ) const;
+    RObj tree_val_scalar(const CContext& ctx) const;
 };
 
 
 //! File-wide information: R# = real parameter.
 
-class CNodeFileR: public CNodeFile {
- private:
+class CNodeFileR : public CNodeFile
+{
+private:
     int num;
- public:
-    CNodeFileR( int _num, RRef _ref ) : CNodeFile( _ref), num(_num) {}
-    CCoord file_coord( const COlo *f ) const;
+
+public:
+    CNodeFileR(int _num, RRef _ref) : CNodeFile(_ref), num(_num) {}
+    CCoord file_coord(const COlo* f) const;
     string name() const { return "r" + S(num); }
-    RObj tree_val_scalar( const CContext& ctx ) const;
+    RObj tree_val_scalar(const CContext& ctx) const;
 };
 
 
 //! Slice-wide information.
 
-class CNodeSlice: public CNodeFile {
- public:
-    CNodeSlice( RRef _ref ) : CNodeFile( _ref ) {}
+class CNodeSlice : public CNodeFile
+{
+public:
+    CNodeSlice(RRef _ref) : CNodeFile(_ref) {}
 };
 
 
 //! Slice-wide information: Z# = z coordinate.
 
-class CNodeSliceZ: public CNodeSlice {
- private:
+class CNodeSliceZ : public CNodeSlice
+{
+private:
     int num;
- public:
-    CNodeSliceZ( int _num, RRef _ref ) : CNodeSlice( _ref), num(_num) {}
-    CCoord file_coord( const COlo *f ) const;
+
+public:
+    CNodeSliceZ(int _num, RRef _ref) : CNodeSlice(_ref), num(_num) {}
+    CCoord file_coord(const COlo* f) const;
     string name() const { return "z" + S(num); }
-    RObj tree_val_scalar( const CContext& ctx ) const;
+    RObj tree_val_scalar(const CContext& ctx) const;
 };
 
 
 //! Spec-wide information: number of data points.
 
-class CNodeSpecNI: public CNodeSlice {
- public:
-    CNodeSpecNI( RRef _ref ) : CNodeSlice( _ref) {}
+class CNodeSpecNI : public CNodeSlice
+{
+public:
+    CNodeSpecNI(RRef _ref) : CNodeSlice(_ref) {}
     string name() const { return "ni"; }
-    RObj tree_val_scalar( const CContext& ctx ) const;
+    RObj tree_val_scalar(const CContext& ctx) const;
 };
 
 
 //! Curve-wide information.
 
-class CNodeCurve: public CNodeSlice {
- public:
-    CNodeCurve( RRef _ref ) : CNodeSlice( _ref ) {}
-    RObj tree_val_scalar( const CContext& ctx ) const;
-    virtual RObj curve_val_scalar( const CCurve * c ) const = 0;
+class CNodeCurve : public CNodeSlice
+{
+public:
+    CNodeCurve(RRef _ref) : CNodeSlice(_ref) {}
+    RObj tree_val_scalar(const CContext& ctx) const;
+    virtual RObj curve_val_scalar(const CCurve* c) const = 0;
 };
 
 
 //! Curve-wide information: P# = curve parameter.
 
-class CNodeCurveP: public CNodeCurve {
- private:
+class CNodeCurveP : public CNodeCurve
+{
+private:
     int num;
- public:
-    CNodeCurveP( int _num, RRef _ref ) : CNodeCurve( _ref), num(_num) {}
-    CCoord file_coord( const COlo *f ) const;
+
+public:
+    CNodeCurveP(int _num, RRef _ref) : CNodeCurve(_ref), num(_num) {}
+    CCoord file_coord(const COlo* f) const;
     string name() const { return "p" + S(num); }
-    RObj curve_val_scalar( const CCurve * c ) const;
-    int npar() const { return num+1; }
+    RObj curve_val_scalar(const CCurve* c) const;
+    int npar() const { return num + 1; }
 };
 
 
 //! Curve-wide information: fit outcome code.
 
-class CNodeCurveOutcome: public CNodeCurve {
- public:
-    CNodeCurveOutcome( RRef _ref ) : CNodeCurve( _ref) {}
+class CNodeCurveOutcome : public CNodeCurve
+{
+public:
+    CNodeCurveOutcome(RRef _ref) : CNodeCurve(_ref) {}
     string name() const { return "oc"; }
-    RObj curve_val_scalar( const CCurve * c ) const;
+    RObj curve_val_scalar(const CCurve* c) const;
 };
 
 
 //! Curve-wide information: fit outcome chi^2.
 
-class CNodeCurveChi2: public CNodeCurve {
- public:
-    CNodeCurveChi2( RRef _ref ) : CNodeCurve( _ref) {}
+class CNodeCurveChi2 : public CNodeCurve
+{
+public:
+    CNodeCurveChi2(RRef _ref) : CNodeCurve(_ref) {}
     string name() const { return "chi2"; }
-    RObj curve_val_scalar( const CCurve * c ) const;
+    RObj curve_val_scalar(const CCurve* c) const;
 };
 
 
 //! Curve-wide information: fit outcome R^2.
 
-class CNodeCurveR2: public CNodeCurve {
- public:
-    CNodeCurveR2( RRef _ref ) : CNodeCurve( _ref) {}
+class CNodeCurveR2 : public CNodeCurve
+{
+public:
+    CNodeCurveR2(RRef _ref) : CNodeCurve(_ref) {}
     string name() const { return "R2"; }
-    RObj curve_val_scalar( const CCurve * c ) const;
+    RObj curve_val_scalar(const CCurve* c) const;
 };
 
 
 //! Pointwise information.
 
-class CNodePoint: public CNodeSlice {
- private:
-    RObj tree_val_point( const CContext& ctx, int i ) const;
-    RObj tree_val_vector( const CContext& ctx ) const;
- protected:
-    virtual RObj spec_val_point( const CSpec *s, int i, bool want_error ) const = 0;
-    virtual RObj spec_val_vector( const CSpec *s, int n, bool want_error ) const = 0;
- public:
-    CNodePoint( RRef _ref ) : CNodeSlice( _ref ) {}
-    RObj tree_val( const CContext& ctx ) const;
+class CNodePoint : public CNodeSlice
+{
+private:
+    RObj tree_val_point(const CContext& ctx, int i) const;
+    RObj tree_val_vector(const CContext& ctx) const;
+
+protected:
+    virtual RObj spec_val_point(const CSpec* s, int i, bool want_error) const = 0;
+    virtual RObj spec_val_vector(const CSpec* s, int n, bool want_error) const = 0;
+
+public:
+    CNodePoint(RRef _ref) : CNodeSlice(_ref) {}
+    RObj tree_val(const CContext& ctx) const;
 };
 
 
 //! Pointwise information: X.
 
-class CNodePointX: public CNodePoint {
- public:
-    CNodePointX( RRef _ref ) : CNodePoint( _ref ) {}
-    CCoord file_coord( const COlo *f ) const;
+class CNodePointX : public CNodePoint
+{
+public:
+    CNodePointX(RRef _ref) : CNodePoint(_ref) {}
+    CCoord file_coord(const COlo* f) const;
     string name() const { return "x"; }
-    RObj spec_val_point( const CSpec *s, int i, bool want_error ) const;
-    RObj spec_val_vector( const CSpec *s, int n, bool want_error ) const;
+    RObj spec_val_point(const CSpec* s, int i, bool want_error) const;
+    RObj spec_val_vector(const CSpec* s, int n, bool want_error) const;
 };
 
 
 //! Pointwise information: Y.
 
-class CNodePointY: public CNodePoint {
- public:
-    CNodePointY( RRef _ref ) : CNodePoint( _ref ) {}
-    CCoord file_coord( const COlo *f ) const;
+class CNodePointY : public CNodePoint
+{
+public:
+    CNodePointY(RRef _ref) : CNodePoint(_ref) {}
+    CCoord file_coord(const COlo* f) const;
     string name() const { return "y"; }
-    RObj spec_val_point( const CSpec *s, int i, bool want_error ) const;
-    RObj spec_val_vector( const CSpec *s, int n, bool want_error ) const;
+    RObj spec_val_point(const CSpec* s, int i, bool want_error) const;
+    RObj spec_val_vector(const CSpec* s, int n, bool want_error) const;
 };
 
 
 //! Pointwise information: DY.
 
-class CNodePointDY: public CNodePoint {
- public:
-    CNodePointDY( RRef _ref ) : CNodePoint( _ref ) {}
-    CCoord file_coord( const COlo *f ) const;
+class CNodePointDY : public CNodePoint
+{
+public:
+    CNodePointDY(RRef _ref) : CNodePoint(_ref) {}
+    CCoord file_coord(const COlo* f) const;
     string name() const { return "dy"; }
-    RObj spec_val_point( const CSpec *s, int i, bool want_error ) const;
-    RObj spec_val_vector( const CSpec *s, int n, bool want_error ) const;
+    RObj spec_val_point(const CSpec* s, int i, bool want_error) const;
+    RObj spec_val_vector(const CSpec* s, int n, bool want_error) const;
 };
 
 
 //! Identifier node.
 
-class CNodeIdf: public CNode {
- private:
+class CNodeIdf : public CNode
+{
+private:
     string idf;
- public:
-    CNodeIdf( string _s );
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const;
+
+public:
+    CNodeIdf(string _s);
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const;
     string tree_info() const { return "$"; }
 };
 
 
 //! Function argument (t) node.
 
-class CNodeDummy: public CNode {
- public:
+class CNodeDummy : public CNode
+{
+public:
     CNodeDummy() {}
-    RObj tree_val( const CContext& ctx ) const;
+    RObj tree_val(const CContext& ctx) const;
     bool has_dummy() const { return true; } // this node _is_ t, so it has t
-    CCoord node_coord( int k ) const {
-        throw "BUG: CNodeDummy::node_coord not expected to be needed"; }
+    CCoord node_coord(int k) const
+    {
+        throw "BUG: CNodeDummy::node_coord not expected to be needed";
+    }
     string tree_info() const { return "farg"; }
 };
 
 
 //! Curve evaluation node.
 
-class CNodeCev: public CNode {
- private:
+class CNodeCev : public CNode
+{
+private:
     RRef ref;
     RNode arg;
- public:
-    CNodeCev( RRef _ref, RNode _arg ) : ref( _ref ), arg( _arg ) {}
+
+public:
+    CNodeCev(RRef _ref, RNode _arg) : ref(_ref), arg(_arg) {}
     bool k_dependent() const { return true; }
     bool has_dummy() const { return arg->has_dummy(); }
     bool has_conv() const { return arg->has_conv(); }
-    RObj tree_val( const CContext& ctx ) const;
-    CCoord node_coord( int k ) const;
+    RObj tree_val(const CContext& ctx) const;
+    CCoord node_coord(int k) const;
     string tree_info() const { return "c[" + ref->ref_info() + "]"; }
 };
 
 
 //! Base class for mixing in data from a "convolution" file
 
-class CNodeMixin: public CNode {
- protected:
+class CNodeMixin : public CNode
+{
+protected:
     RNode shift;
- public:
-    CNodeMixin( const RNode& _shift ) : shift(_shift) {}
+
+public:
+    CNodeMixin(const RNode& _shift) : shift(_shift) {}
     int npar() const { return shift->npar(); }
     bool k_dependent() const { return shift->k_dependent(); }
     bool j_dependent() const { return shift->j_dependent(); }
     bool i_dependent() const { return shift->i_dependent(); }
-    RObj tree_val( const CContext& ctx ) const;
-    virtual RObj copy_theory( const CContext& ctx, double theshift ) const =0;
-    virtual RObjVecDbl convolve( const CContext& ctx, double theshift, const CSpec* sv,
-                                 double conv_norm, double conv_step ) const =0;
+    RObj tree_val(const CContext& ctx) const;
+    virtual RObj copy_theory(const CContext& ctx, double theshift) const = 0;
+    virtual RObjVecDbl convolve(
+        const CContext& ctx, double theshift, const CSpec* sv, double conv_norm,
+        double conv_step) const = 0;
     bool has_conv() const { return true; }
 };
 
 //! Base class for convoluting a function with a spectrum.
 
-class CNodeConvBase: public CNodeMixin {
- protected:
+class CNodeConvBase : public CNodeMixin
+{
+protected:
     RNode theory;
- public:
-    CNodeConvBase( const RNode& _theory, const RNode& _shift )
-        : CNodeMixin( _shift ), theory(_theory) {}
+
+public:
+    CNodeConvBase(const RNode& _theory, const RNode& _shift) : CNodeMixin(_shift), theory(_theory)
+    {
+    }
     int npar() const { return std::max(shift->npar(), theory->npar()); }
     bool k_dependent() const { return theory->k_dependent() || shift->k_dependent(); }
     bool j_dependent() const { return theory->j_dependent() || shift->j_dependent(); }
     bool i_dependent() const { return theory->i_dependent() || shift->i_dependent(); }
     bool has_dummy() const { return theory->has_dummy(); }
-    CCoord node_coord( int k ) const { return theory->node_coord( k ); }
+    CCoord node_coord(int k) const { return theory->node_coord(k); }
 };
 
 
 //! Convolute a function with a spectrum.
 
-class CNodeConv: public CNodeConvBase {
- public:
-    CNodeConv( const RNode& _theory, const RNode& _shift=RNode( new CNodeVal( 0.0 ) ) )
-        : CNodeConvBase( _theory, _shift ) {}
-    RObj copy_theory( const CContext& ctx, double theshift ) const;
-    RObjVecDbl convolve( const CContext& ctx, double theshift, const CSpec *sv,
-                         double conv_norm, double conv_step ) const;
-    string tree_info() const {
-        return "conv(" + theory->tree_info() +","+ shift->tree_info() + ")"; }
+class CNodeConv : public CNodeConvBase
+{
+public:
+    CNodeConv(const RNode& _theory, const RNode& _shift = RNode(new CNodeVal(0.0)))
+        : CNodeConvBase(_theory, _shift)
+    {
+    }
+    RObj copy_theory(const CContext& ctx, double theshift) const;
+    RObjVecDbl convolve(
+        const CContext& ctx, double theshift, const CSpec* sv, double conv_norm,
+        double conv_step) const;
+    string tree_info() const
+    {
+        return "conv(" + theory->tree_info() + "," + shift->tree_info() + ")";
+    }
 };
 
 
 //! Convolution a function with a spectrum, using the function's primitive.
 
-class CNodePConv: public CNodeConvBase {
- public:
-    CNodePConv( const RNode& _theory, const RNode& _shift=RNode( new CNodeVal( 0.0 ) ) )
-        : CNodeConvBase( _theory, _shift ) {};
-    RObj copy_theory( const CContext& ctx, double theshift ) const;
-    RObjVecDbl convolve( const CContext& ctx, double theshift, const CSpec* sv,
-                         double conv_norm, double conv_step ) const;
-    string tree_info() const {
-        return "pconv(" + theory->tree_info() +","+ shift->tree_info() + ")"; }
+class CNodePConv : public CNodeConvBase
+{
+public:
+    CNodePConv(const RNode& _theory, const RNode& _shift = RNode(new CNodeVal(0.0)))
+        : CNodeConvBase(_theory, _shift){};
+    RObj copy_theory(const CContext& ctx, double theshift) const;
+    RObjVecDbl convolve(
+        const CContext& ctx, double theshift, const CSpec* sv, double conv_norm,
+        double conv_step) const;
+    string tree_info() const
+    {
+        return "pconv(" + theory->tree_info() + "," + shift->tree_info() + ")";
+    }
 };
 
 
 //! Dirac's delta function node, to request a copy of the resolution function.
 
-class CNodeDirac: public CNodeMixin {
- public:
-    CNodeDirac( const RNode& _shift=RNode( new CNodeVal( 0.0 ) ) )
-        : CNodeMixin( _shift ) {};
-    RObj copy_theory( const CContext& ctx, double theshift ) const;
-    RObjVecDbl convolve( const CContext& ctx, double theshift, const CSpec *sv,
-                         double conv_norm, double conv_step ) const;
+class CNodeDirac : public CNodeMixin
+{
+public:
+    CNodeDirac(const RNode& _shift = RNode(new CNodeVal(0.0))) : CNodeMixin(_shift){};
+    RObj copy_theory(const CContext& ctx, double theshift) const;
+    RObjVecDbl convolve(
+        const CContext& ctx, double theshift, const CSpec* sv, double conv_norm,
+        double conv_step) const;
     bool has_dummy() const { return true; } // has implicit t dependence
-    CCoord node_coord( int k ) const;
+    CCoord node_coord(int k) const;
     string tree_info() const { return "resol(" + shift->tree_info() + ")"; }
 };
diff --git a/pub/lib/obj.cpp b/pub/lib/obj.cpp
index 65d41740d5352efccb69398b8a71a2cc003c10ea..63d107d6989800f49d8b8da57af065fe58b7cd30 100644
--- a/pub/lib/obj.cpp
+++ b/pub/lib/obj.cpp
@@ -7,11 +7,11 @@
 //! \file  obj.cpp
 //! \brief Data containers: CObj and its children.
 
-#include <boost/format.hpp>
+#include "obj.hpp"
 #include "../trivia/string_ops.hpp"
 #include "defs.hpp"
 #include "ptr.hpp"
-#include "obj.hpp"
+#include <boost/format.hpp>
 
 using boost::format;
 
@@ -20,10 +20,10 @@ using boost::format;
 //  Static methods
 //**************************************************************************************************
 
-PObj CObj::objectify( int val ) { return PObjInt( new CObjInt(val) ); }
-PObj CObj::objectify( double val ) { return PObjDbl( new CObjDbl(val) ); }
-PObj CObj::objectify( double val, double err ) { return PObjEnu( new CObjEnu(val, err) ); }
-PObj CObj::objectify( string val ) { return PObjStr( new CObjStr(val) ); }
+PObj CObj::objectify(int val) { return PObjInt(new CObjInt(val)); }
+PObj CObj::objectify(double val) { return PObjDbl(new CObjDbl(val)); }
+PObj CObj::objectify(double val, double err) { return PObjEnu(new CObjEnu(val, err)); }
+PObj CObj::objectify(string val) { return PObjStr(new CObjStr(val)); }
 
 
 //**************************************************************************************************
@@ -32,11 +32,11 @@ PObj CObj::objectify( string val ) { return PObjStr( new CObjStr(val) ); }
 
 //! Returns string representation.
 
-string CObjInt::to_s( int maxlen, int minlen, int prec ) const
+string CObjInt::to_s(int maxlen, int minlen, int prec) const
 {
     // TODO: respect minlen
-    string form = str( format( "%%#%ii" ) % maxlen );
-    string ret = triv::strip( str( format( form ) % val ) );
+    string form = str(format("%%#%ii") % maxlen);
+    string ret = triv::strip(str(format(form) % val));
     return ret;
 }
 
@@ -47,11 +47,11 @@ string CObjInt::to_s( int maxlen, int minlen, int prec ) const
 
 //! Returns string representation.
 
-string CObjDbl::to_s( int maxlen, int minlen, int prec ) const
+string CObjDbl::to_s(int maxlen, int minlen, int prec) const
 {
     // TODO: respect minlen
-    string form = str( format( "%%#%i.%ig" ) % maxlen % prec );
-    string ret = triv::strip( str( format( form ) % val ) );
+    string form = str(format("%%#%i.%ig") % maxlen % prec);
+    string ret = triv::strip(str(format(form) % val));
     return ret;
 }
 
@@ -59,10 +59,10 @@ string CObjDbl::to_s( int maxlen, int minlen, int prec ) const
 
 string CObjDbl::result_info() const
 {
-    if( std::isnan(val) )
+    if (std::isnan(val))
         return "CObjDbl(no value assigned)";
     else
-        return "CObjDbl("+to_s()+")";
+        return "CObjDbl(" + to_s() + ")";
 }
 
 
@@ -72,19 +72,16 @@ string CObjDbl::result_info() const
 
 //! Returns string representation.
 
-string CObjEnu::to_s( int maxlen, int minlen, int prec ) const
-{
-    return S(val) + "+-" + S(err);
-}
+string CObjEnu::to_s(int maxlen, int minlen, int prec) const { return S(val) + "+-" + S(err); }
 
 //! Returns textual representation of the class instance, for debugging.
 
 string CObjEnu::result_info() const
 {
-    if( std::isnan(val) )
+    if (std::isnan(val))
         return "CObjEnu(no value assigned)";
     else
-        return "CObjDbl("+to_s()+")";
+        return "CObjDbl(" + to_s() + ")";
 }
 
 
@@ -101,43 +98,46 @@ string CObjEnu::result_info() const
 
 RObj CObjVecObj::to_vecnum() const
 {
-    if( v.size()<1 )
+    if (v.size() < 1)
         throw S("BUG: to_vecnum called for empty vector");
     try {
-        PObjVecInt ret( new CObjVecInt );
-        for( RObj ele: v ) {
-            ret->v.push_back( ele->to_i() );
+        PObjVecInt ret(new CObjVecInt);
+        for (RObj ele : v) {
+            ret->v.push_back(ele->to_i());
         }
         return ret;
-    } catch (... ) {}
+    } catch (...) {
+    }
     try {
-        PObjVecDbl ret( new CObjVecDbl );
-        for( RObj ele: v ) {
-            if ( ele->to_dr() )
+        PObjVecDbl ret(new CObjVecDbl);
+        for (RObj ele : v) {
+            if (ele->to_dr())
                 throw "would loose dr";
-            ret->v.push_back( ele->to_r() );
+            ret->v.push_back(ele->to_r());
         }
         return ret;
-    } catch (... ) {}
+    } catch (...) {
+    }
     try {
-        PObjVecEnu ret( new CObjVecEnu );
-        for( RObj ele: v ) {
-            ret->v.push_back( ele->to_r() );
-            ret->dv.push_back( ele->to_dr() );
+        PObjVecEnu ret(new CObjVecEnu);
+        for (RObj ele : v) {
+            ret->v.push_back(ele->to_r());
+            ret->dv.push_back(ele->to_dr());
         }
         return ret;
-    } catch (... ) {}
+    } catch (...) {
+    }
     throw S("vector has non-numeric elements");
 }
 
 //! Returns string representation.
 
-string CObjVecObj::to_s( int maxlen, int minlen, int prec ) const
+string CObjVecObj::to_s(int maxlen, int minlen, int prec) const
 {
     string ret;
-    for ( int i=0; i<v.size(); ++i ) {
+    for (int i = 0; i < v.size(); ++i) {
         ret += v[i]->to_s();
-        if ( i<v.size()-1 )
+        if (i < v.size() - 1)
             ret += ",";
     }
     return ret;
@@ -149,12 +149,12 @@ string CObjVecObj::to_s( int maxlen, int minlen, int prec ) const
 
 //! Returns string representation.
 
-string CObjVecInt::to_s( int maxlen, int minlen, int prec ) const
+string CObjVecInt::to_s(int maxlen, int minlen, int prec) const
 {
     string ret;
-    for ( int i=0; i<v.size(); ++i ) {
+    for (int i = 0; i < v.size(); ++i) {
         ret += S(v[i]);
-        if ( i<v.size()-1 )
+        if (i < v.size() - 1)
             ret += ",";
     }
     return ret;
@@ -163,10 +163,7 @@ string CObjVecInt::to_s( int maxlen, int minlen, int prec ) const
 
 //! Returns textual representation of the class instance, for debugging.
 
-string CObjVecInt::result_info() const
-{
-    return to_s();
-}
+string CObjVecInt::result_info() const { return to_s(); }
 
 
 //**************************************************************************************************
@@ -175,12 +172,12 @@ string CObjVecInt::result_info() const
 
 //! Returns string representation.
 
-string CObjVecDbl::to_s( int maxlen, int minlen, int prec ) const
+string CObjVecDbl::to_s(int maxlen, int minlen, int prec) const
 {
     string ret;
-    for ( int i=0; i<v.size(); ++i ) {
+    for (int i = 0; i < v.size(); ++i) {
         ret += S(v[i]);
-        if ( i<v.size()-1 )
+        if (i < v.size() - 1)
             ret += ",";
     }
     return ret;
@@ -189,10 +186,7 @@ string CObjVecDbl::to_s( int maxlen, int minlen, int prec ) const
 
 //! Returns textual representation of the class instance, for debugging.
 
-string CObjVecDbl::result_info() const
-{
-    return to_s();
-}
+string CObjVecDbl::result_info() const { return to_s(); }
 
 
 //**************************************************************************************************
@@ -202,14 +196,11 @@ string CObjVecDbl::result_info() const
 
 //! Returns string representation.
 
-string CObjVecEnu::to_s( int maxlen, int minlen, int prec ) const
+string CObjVecEnu::to_s(int maxlen, int minlen, int prec) const
 {
-    return "["+S(size())+" floating-point entries with errors]";
+    return "[" + S(size()) + " floating-point entries with errors]";
 }
 
 //! Returns textual representation of the class instance, for debugging.
 
-string CObjVecEnu::result_info() const
-{
-    return to_s();
-}
+string CObjVecEnu::result_info() const { return to_s(); }
diff --git a/pub/lib/obj.hpp b/pub/lib/obj.hpp
index e3910b60e21fc4e5085ad7de6f297e1eda650c53..e1d2e20ae4050c03734612499fa0dbf6200fced4 100644
--- a/pub/lib/obj.hpp
+++ b/pub/lib/obj.hpp
@@ -11,193 +11,204 @@
 
 //! Generic data container, pure virtual base class.
 
-class CObj {
- public:
+class CObj
+{
+public:
     virtual ~CObj() {}
     // virtual PObj clone() const =0;
-    virtual bool is_vec() const =0;
-    virtual bool has_err() const =0;
-    virtual char base_type() const =0;
-    virtual string result_info() const =0;
-    virtual int to_i( int i ) const { throw string("to_i(i) not available"); }
-    virtual double to_r( int i ) const { throw string("to_r(i) not available"); }
-    virtual double to_dr( int i ) const { throw string("to_dr(i) not available"); }
+    virtual bool is_vec() const = 0;
+    virtual bool has_err() const = 0;
+    virtual char base_type() const = 0;
+    virtual string result_info() const = 0;
+    virtual int to_i(int i) const { throw string("to_i(i) not available"); }
+    virtual double to_r(int i) const { throw string("to_r(i) not available"); }
+    virtual double to_dr(int i) const { throw string("to_dr(i) not available"); }
     virtual int to_i() const { throw string("to_i() not available"); }
     virtual double to_r() const { throw string("to_r() not available"); }
     virtual double to_dr() const { throw string("to_dr() not available"); }
-    virtual bool to_b() const =0;
-    virtual string to_s( int maxlen=12, int minlen=1, int prec=6 ) const =0;
+    virtual bool to_b() const = 0;
+    virtual string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const = 0;
     virtual int size() const { return 1; }
 
-    static PObj objectify( int val );
-    static PObj objectify( double val );
-    static PObj objectify( double val, double err );
-    static PObj objectify( string val );
+    static PObj objectify(int val);
+    static PObj objectify(double val);
+    static PObj objectify(double val, double err);
+    static PObj objectify(string val);
 };
 
 //! Data container holding a single number; virtual base class for CObjInt, CObjDble.
 
-class CObjNum : public CObj {
- public:
+class CObjNum : public CObj
+{
+public:
     CObjNum() : CObj() {}
     bool is_vec() const { return false; }
     virtual double to_dr() const { return 0.; }
-    virtual double to_dr( int i ) const { return 0. ; }
+    virtual double to_dr(int i) const { return 0.; }
 };
 
 //! Data container holding a single integer number.
 
-class CObjInt : public CObjNum {
- public:
-
-    int val;         //!< Scalar value.
-    CObjInt( int _val ) : CObjNum(), val(_val) {}
+class CObjInt : public CObjNum
+{
+public:
+    int val; //!< Scalar value.
+    CObjInt(int _val) : CObjNum(), val(_val) {}
     // PObj clone() const { return PObjInt( new CObjInt( *this ) ); }
     inline bool has_err() const { return false; }
     inline char base_type() const { return 'i'; }
-    string result_info() const { return "CObjInt("+S(val)+")"; }
+    string result_info() const { return "CObjInt(" + S(val) + ")"; }
     inline double to_r() const { return val; }
-    inline double to_r( int i ) const { return val; }
+    inline double to_r(int i) const { return val; }
     inline int to_i() const { return val; }
-    inline int to_i( int i ) const { return val; }
-    string to_s( int maxlen=12, int minlen=1, int prec=6 ) const;
+    inline int to_i(int i) const { return val; }
+    string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const;
     inline bool to_b() const { return val; }
 };
 
 //! Data container holding a single floating-point number.
 
-class CObjDbl : public CObjNum {
- public:
-    double val;         //!< Scalar value.
-    CObjDbl( double _val=NAN ) : CObjNum(), val(_val) {}
+class CObjDbl : public CObjNum
+{
+public:
+    double val; //!< Scalar value.
+    CObjDbl(double _val = NAN) : CObjNum(), val(_val) {}
     // PObj clone() const { return PObjDbl( new CObjDbl( *this ) ); }
     inline bool has_err() const { return false; }
     inline char base_type() const { return 'd'; }
     string result_info() const;
     inline double to_r() const { return val; }
-    inline double to_r( int i ) const { return val; }
-    string to_s( int maxlen=12, int minlen=1, int prec=6 ) const;
+    inline double to_r(int i) const { return val; }
+    string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const;
     bool to_b() const { return val; }
 };
 
 //! Data container holding a single floating-point number with its error bar.
 //  STILL UNUSED!
 
-class CObjEnu : public CObjDbl {
- public:
-    double err;         //!< Error of scalar value.
-    CObjEnu( double _val=NAN, double _err=NAN ) : CObjDbl(_val), err(_err) {}
+class CObjEnu : public CObjDbl
+{
+public:
+    double err; //!< Error of scalar value.
+    CObjEnu(double _val = NAN, double _err = NAN) : CObjDbl(_val), err(_err) {}
     // PObj clone() const { return PObjEnu( new CObjEnu( *this ) ); }
     inline bool has_err() const { return true; }
     inline char base_type() const { return 'e'; }
     string result_info() const;
     inline double to_r() const { return val; }
     inline double to_dr() const { return err; }
-    inline double to_r( int i ) const { return val; }
-    inline double to_dr( int i ) const { return err; }
-    string to_s( int maxlen=12, int minlen=1, int prec=6 ) const;
+    inline double to_r(int i) const { return val; }
+    inline double to_dr(int i) const { return err; }
+    string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const;
     bool to_b() const { return val; }
 };
 
 //! Data container holding a string.
 
-class CObjStr : public CObj {
- public:
+class CObjStr : public CObj
+{
+public:
     string val;
-    CObjStr( string _val ) : CObj(), val(_val) {}
+    CObjStr(string _val) : CObj(), val(_val) {}
     // PObj clone() const { return PObjStr( new CObjStr( *this ) ); }
     bool is_vec() const { return false; }
     bool has_err() const { return false; }
     char base_type() const { return 's'; }
-    string result_info() const { return "CObjStr("+val+")"; }
-    string to_s( int maxlen=12, int minlen=1, int prec=6 ) const { return val; }
+    string result_info() const { return "CObjStr(" + val + ")"; }
+    string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const { return val; }
     bool to_b() const { return val.size(); }
     int size() const { return val.size(); }
 };
 
 //! Data container holding a vector; virtual base class for different vector types.
 
-class CObjVec : public CObj {
- public:
+class CObjVec : public CObj
+{
+public:
     CObjVec() : CObj() {}
     bool is_vec() const { return true; }
     virtual int size() const = 0;
     inline bool to_b() const { return size(); }
-    virtual RObj to_obj( int i ) const = 0;
+    virtual RObj to_obj(int i) const = 0;
 };
 
 //! Data container holding a vector of objects.
 
-class CObjVecObj : public CObjVec {
- public:
+class CObjVecObj : public CObjVec
+{
+public:
     vector<RObj> v; //!< The data.
-    CObjVecObj( int n=0 ) : CObjVec(), v(n,nullptr) {}
+    CObjVecObj(int n = 0) : CObjVec(), v(n, nullptr) {}
     inline int size() const { return v.size(); }
     bool has_err() const { throw S("query has_err is ill-defined for generic vector"); }
     char base_type() const { throw S("query base_type is ill-defined for generic vector"); }
     inline string result_info() const { return to_s(); }
-    inline RObj to_obj( int i ) const { return v[i]; }
-    string to_s( int maxlen=12, int minlen=1, int prec=6 ) const;
+    inline RObj to_obj(int i) const { return v[i]; }
+    string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const;
     RObj to_vecnum() const;
 };
 
 //! Data container holding a vector of numbers.
 
-class CObjVecNum : public CObjVec {
- public:
+class CObjVecNum : public CObjVec
+{
+public:
     CObjVecNum() : CObjVec() {}
-    double to_dr( int i ) const { return 0; }
+    double to_dr(int i) const { return 0; }
 };
 
 
 //! Data container holding a vector of integer numbers.
 
-class CObjVecInt : public CObjVecNum {
- public:
-    vector<int> v;  //!< The data.
-    CObjVecInt( int n=0 ) : CObjVecNum(), v(n,-1) {}
-    CObjVecInt( const vector<int>& _v ) : CObjVecNum(), v(_v) {}
+class CObjVecInt : public CObjVecNum
+{
+public:
+    vector<int> v; //!< The data.
+    CObjVecInt(int n = 0) : CObjVecNum(), v(n, -1) {}
+    CObjVecInt(const vector<int>& _v) : CObjVecNum(), v(_v) {}
     inline int size() const { return v.size(); }
     // PObj clone() const { return PObjVecInt( new CObjVecInt( *this ) ); }
     bool has_err() const { return false; }
     char base_type() const { return 'i'; }
     string result_info() const;
-    inline RObj to_obj( int i ) const { return RObjInt( new CObjInt( v[i] ) ); }
-    inline int to_i( int i ) const { return v[i]; }
-    inline double to_r( int i ) const { return v[i]; }
-    string to_s( int maxlen=12, int minlen=1, int prec=6 ) const;
+    inline RObj to_obj(int i) const { return RObjInt(new CObjInt(v[i])); }
+    inline int to_i(int i) const { return v[i]; }
+    inline double to_r(int i) const { return v[i]; }
+    string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const;
 };
 
 //! Data container holding a vector of floating-point numbers.
 
-class CObjVecDbl : public CObjVecNum {
- public:
-    vector<double> v;  //!< Resulting vector.
-    CObjVecDbl( int n=0, double val=NAN ) : CObjVecNum(), v(n,val) {}
-    CObjVecDbl( const vector<double>& _v ) : CObjVecNum(), v(_v) {}
+class CObjVecDbl : public CObjVecNum
+{
+public:
+    vector<double> v; //!< Resulting vector.
+    CObjVecDbl(int n = 0, double val = NAN) : CObjVecNum(), v(n, val) {}
+    CObjVecDbl(const vector<double>& _v) : CObjVecNum(), v(_v) {}
     inline int size() const { return v.size(); }
     // PObj clone() const { return PObjVecDbl( new CObjVecDbl( *this ) ); }
     bool has_err() const { return false; }
     char base_type() const { return 'd'; }
     string result_info() const;
-    inline RObj to_obj( int i ) const { return RObjDbl( new CObjDbl( v[i] ) ); }
-    inline double to_r( int i ) const { return v[i]; }
-    string to_s( int maxlen=12, int minlen=1, int prec=6 ) const;
+    inline RObj to_obj(int i) const { return RObjDbl(new CObjDbl(v[i])); }
+    inline double to_r(int i) const { return v[i]; }
+    string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const;
 };
 
 //! Data container holding a vector of floating-point numbers.
 
-class CObjVecEnu : public CObjVecDbl {
- public:
+class CObjVecEnu : public CObjVecDbl
+{
+public:
     vector<double> dv; //!< Errors.
-    CObjVecEnu( int n=0 ) : CObjVecDbl( n ), dv(n,NAN) {}
-    CObjVecEnu( const vector<double>& _v, const vector<double>& _dv ) : CObjVecDbl(_v), dv(_dv) {}
+    CObjVecEnu(int n = 0) : CObjVecDbl(n), dv(n, NAN) {}
+    CObjVecEnu(const vector<double>& _v, const vector<double>& _dv) : CObjVecDbl(_v), dv(_dv) {}
     inline int size() const { return v.size(); }
     // PObj clone() const { return PObjVecEnu( new CObjVecEnu( *this ) ); }
     bool has_err() const { return true; }
     char base_type() const { return 'e'; }
     string result_info() const;
-    inline RObj to_obj( int i ) const { return RObjEnu( new CObjEnu( v[i], dv[i] ) ); }
-    inline double to_dr( int i ) const { return dv[i]; }
-    string to_s( int maxlen=12, int minlen=1, int prec=6 ) const;
+    inline RObj to_obj(int i) const { return RObjEnu(new CObjEnu(v[i], dv[i])); }
+    inline double to_dr(int i) const { return dv[i]; }
+    string to_s(int maxlen = 12, int minlen = 1, int prec = 6) const;
 };
diff --git a/pub/lib/olf.cpp b/pub/lib/olf.cpp
index d74fa3bdea09e97a4dc52fd51438aa174e1923f2..a6e3e5df1b879999dc0a16c14bd2a5ee99709e78 100644
--- a/pub/lib/olf.cpp
+++ b/pub/lib/olf.cpp
@@ -9,20 +9,20 @@
 
 #include "defs.hpp"
 
+#include <boost/format.hpp>
+#include <fcntl.h>
 #include <fstream>
 #include <sstream>
-#include <fcntl.h>
 #include <sys/stat.h>
-#include <boost/format.hpp>
 
-#include "../trivia/file_ops.hpp"
 #include "../readplus/ask.hpp"
+#include "../trivia/file_ops.hpp"
 
-#include "olf.hpp"
-#include "slice.hpp"
+#include "expr.hpp"
 #include "genus.hpp"
 #include "obj.hpp"
-#include "expr.hpp"
+#include "olf.hpp"
+#include "slice.hpp"
 #include "xax_lex.hpp"
 
 using boost::format;
@@ -43,7 +43,7 @@ COlo::~COlo() {}
 
 //! Copy meta data.
 
-void COlo::copy_meta_O_from_other( const COlo* other )
+void COlo::copy_meta_O_from_other(const COlo* other)
 {
     name = other->name;
     lDoc = other->lDoc;
@@ -57,30 +57,30 @@ void COlo::copy_meta_O_from_other( const COlo* other )
 
 //! Append a line to the log; set as_on_disk to false.
 
-void COlo::log_action( const string& line )
+void COlo::log_action(const string& line)
 {
-    lDoc.push_back( line );
+    lDoc.push_back(line);
     as_on_disk = false;
 }
 
 
 //! Remove one z.
 
-void COlo::remove_z( int iz )
+void COlo::remove_z(int iz)
 {
-    ZCo.erase( ZCo.begin()+iz );
-    for( int j=0; j<nJ(); ++j )
-        V[j]->z.erase( V[j]->z.begin()+iz );
+    ZCo.erase(ZCo.begin() + iz);
+    for (int j = 0; j < nJ(); ++j)
+        V[j]->z.erase(V[j]->z.begin() + iz);
 }
 
 
 //! Line containing z values and curve parameters.
 
-string COlo::info_line( int j ) const
+string COlo::info_line(int j) const
 {
-    const int LEN=15;
+    const int LEN = 15;
     char wrd[LEN];
-    snprintf( wrd, LEN, "%2i%c ", j, V[j]->frozen ? '/' : ' ' );
+    snprintf(wrd, LEN, "%2i%c ", j, V[j]->frozen ? '/' : ' ');
     string out = wrd;
     out += V[j]->info_line();
     return out;
@@ -91,19 +91,16 @@ string COlo::info_line( int j ) const
 
 void COlo::check_integrity() const
 {
-    if( nJ()<1 )
+    if (nJ() < 1)
         throw S("BUG: File has no slices");
-    if( nJ()>1 && nZ()<1 )
+    if (nJ() > 1 && nZ() < 1)
         throw S("BUG: File has several slices but no z coordinate");
 }
 
 
 //! Return value of iz-th z-variable for slice j.
 
-RObj COlo::z( int j, int iz ) const
-{
-    return V[j]->z[iz];
-}
+RObj COlo::z(int j, int iz) const { return V[j]->z[iz]; }
 
 
 //**************************************************************************************************
@@ -112,17 +109,14 @@ RObj COlo::z( int j, int iz ) const
 
 //! Copy meta data.
 
-void COld::copy_meta_D_from_other( const COld* other )
-{
-    copy_meta_O_from_other( other );
-}
+void COld::copy_meta_D_from_other(const COld* other) { copy_meta_O_from_other(other); }
 
 
 //! Copy meta data.
 
-void COlc::copy_meta_C_from_other( const COlc* other )
+void COlc::copy_meta_C_from_other(const COlc* other)
 {
-    copy_meta_O_from_other( other );
+    copy_meta_O_from_other(other);
     evaMode = other->evaMode;
     scrInpMode = other->scrInpMode;
     expr = other->expr;
@@ -141,43 +135,31 @@ void COlc::copy_meta_C_from_other( const COlc* other )
 
 //! Returns unique_ptr to new copy of spectrum j.
 
-PSlice COld::copy_slice( int j ) const
-{
-    return PSlice( new CSpec( *(VS(j)) ) );
-}
+PSlice COld::copy_slice(int j) const { return PSlice(new CSpec(*(VS(j)))); }
 
 
 //! Returns unique_ptr to new copy of curve j.
 
-PSlice COlc::copy_slice( int j ) const
-{
-    return PSlice( new CCurve( *(VC(j)) ) );
-}
+PSlice COlc::copy_slice(int j) const { return PSlice(new CCurve(*(VC(j)))); }
 
 
 //! Returns pointer to new copy of this.
 
-POlo COld::new_POlo() const
-{
-    return POlo( new_POld() );
-}
+POlo COld::new_POlo() const { return POlo(new_POld()); }
 
 
 //! Returns pointer to new copy of this.
 
-POlo COlc::new_POlo() const
-{
-    return POlo( new_POlc() );
-}
+POlo COlc::new_POlo() const { return POlo(new_POlc()); }
 
 
 //! Returns pointer to new copy of this.
 
 POld COld::new_POld() const
 {
-    COld *old = new COld();
-    old->copy_meta_D_from_other( this );
-    return POld( old );
+    COld* old = new COld();
+    old->copy_meta_D_from_other(this);
+    return POld(old);
 }
 
 
@@ -185,71 +167,71 @@ POld COld::new_POld() const
 
 POlc COlc::new_POlc() const
 {
-    COlc *olc = new COlc();
-    olc->copy_meta_C_from_other( this );
-    return POlc( olc );
+    COlc* olc = new COlc();
+    olc->copy_meta_C_from_other(this);
+    return POlc(olc);
 }
 
 
 //! Set main vector by copying from fin.
 
-void COld::copy_mainvec( const COlo *fin )
+void COld::copy_mainvec(const COlo* fin)
 {
-    const COld *fd = dynamic_cast<const COld*>( fin );
-    V.resize( fin->nJ() );
-    for( int j=0; j<fin->nJ(); ++j )
-        V[j] = PSlice( new CSpec( *(fd->VS(j)) ) );
+    const COld* fd = dynamic_cast<const COld*>(fin);
+    V.resize(fin->nJ());
+    for (int j = 0; j < fin->nJ(); ++j)
+        V[j] = PSlice(new CSpec(*(fd->VS(j))));
 }
 
 
 //! Set main vector by copying from fin.
 
-void COlc::copy_mainvec( const COlo *fin )
+void COlc::copy_mainvec(const COlo* fin)
 {
-    const COlc *fc = dynamic_cast<const COlc*>( fin );
-    V.resize( fin->nJ() );
-    for( int j=0; j<fin->nJ(); ++j )
-        V[j] = PSlice( new CCurve( *(fc->VC(j)) ) );
+    const COlc* fc = dynamic_cast<const COlc*>(fin);
+    V.resize(fin->nJ());
+    for (int j = 0; j < fin->nJ(); ++j)
+        V[j] = PSlice(new CCurve(*(fc->VC(j))));
 }
 
 
 //! Return pointer to selected main vector entry.
 
-CSpec* COld::VS( int j ) const
+CSpec* COld::VS(int j) const
 {
-    if( j<0 || j>=V.size() )
+    if (j < 0 || j >= V.size())
         throw "VS call with j=" + S(j) + " though V.size=" + S(V.size());
-    CSpec *s = dynamic_cast<class CSpec*>( V[j].get() );
-    if ( !s )
-        throw "BUG: file "+S(j)+" does not contain data";
+    CSpec* s = dynamic_cast<class CSpec*>(V[j].get());
+    if (!s)
+        throw "BUG: file " + S(j) + " does not contain data";
     return s;
 }
 
-CCurve* COlc::VC( int j ) const
+CCurve* COlc::VC(int j) const
 {
-    if( j<0 || j>=V.size() )
+    if (j < 0 || j >= V.size())
         throw "VC call with j=" + S(j) + " though V.size=" + S(V.size());
-    CCurve *c = dynamic_cast<class CCurve*>( V[j].get() );
-    if ( !c )
-        throw "BUG: file "+S(j)+" does not contain curves";
+    CCurve* c = dynamic_cast<class CCurve*>(V[j].get());
+    if (!c)
+        throw "BUG: file " + S(j) + " does not contain curves";
     return c;
 }
 
 
 //! Return one coordinate.
 
-CCoord COld::coord( const CGenus& genus ) const
+CCoord COld::coord(const CGenus& genus) const
 {
-    if        ( genus.categ==VCateg::X ) {
+    if (genus.categ == VCateg::X) {
         return xco;
-    } else if ( genus.categ==VCateg::Y ) {
+    } else if (genus.categ == VCateg::Y) {
         return yco;
-    } else if ( genus.categ==VCateg::Z ) {
-        if( genus.num >= nZ() )
+    } else if (genus.categ == VCateg::Z) {
+        if (genus.num >= nZ())
             throw "coordinate " + genus.genus_info() + " not defined";
         return ZCo[genus.num];
-    } else if ( genus.categ==VCateg::R ) {
-        if( genus.num >= RPar.size() )
+    } else if (genus.categ == VCateg::R) {
+        if (genus.num >= RPar.size())
             throw "coordinate " + genus.genus_info() + " not defined";
         return RPar[genus.num].Co;
     } else {
@@ -260,22 +242,22 @@ CCoord COld::coord( const CGenus& genus ) const
 
 //! Return one coordinate.
 
-CCoord COlc::coord( const CGenus& genus ) const
+CCoord COlc::coord(const CGenus& genus) const
 {
-    if        ( genus.categ==VCateg::X ) {
+    if (genus.categ == VCateg::X) {
         return xco;
-    } else if ( genus.categ==VCateg::Y ) {
+    } else if (genus.categ == VCateg::Y) {
         return yco;
-    } else if ( genus.categ==VCateg::Z ) {
-        if( genus.num >= nZ() )
+    } else if (genus.categ == VCateg::Z) {
+        if (genus.num >= nZ())
             throw "coordinate " + genus.genus_info() + " not defined";
         return ZCo[genus.num];
-    } else if ( genus.categ==VCateg::CP ) {
-        if( genus.num >= nP )
+    } else if (genus.categ == VCateg::CP) {
+        if (genus.num >= nP)
             throw "coordinate " + genus.genus_info() + " not defined";
         return PCo[genus.num];
-    } else if ( genus.categ==VCateg::R ) {
-        if( genus.num >= RPar.size() )
+    } else if (genus.categ == VCateg::R) {
+        if (genus.num >= RPar.size())
             throw "coordinate " + genus.genus_info() + " not defined";
         return RPar[genus.num].Co;
     } else {
@@ -286,18 +268,18 @@ CCoord COlc::coord( const CGenus& genus ) const
 
 //! Change one coordinate.
 
-void COld::set_coord( const CGenus& genus, CCoord& co )
+void COld::set_coord(const CGenus& genus, CCoord& co)
 {
-    if        ( genus.categ==VCateg::X ) {
+    if (genus.categ == VCateg::X) {
         xco = co;
-    } else if ( genus.categ==VCateg::Y ) {
+    } else if (genus.categ == VCateg::Y) {
         yco = co;
-    } else if ( genus.categ==VCateg::Z ) {
-        if( genus.num >= nZ() )
+    } else if (genus.categ == VCateg::Z) {
+        if (genus.num >= nZ())
             throw "coordinate " + genus.genus_info() + " not defined";
         ZCo[genus.num] = co;
-    } else if ( genus.categ==VCateg::R ) {
-        if( genus.num >= RPar.size() )
+    } else if (genus.categ == VCateg::R) {
+        if (genus.num >= RPar.size())
             throw "coordinate " + genus.genus_info() + " not defined";
         RPar[genus.num].Co = co;
     } else {
@@ -308,22 +290,22 @@ void COld::set_coord( const CGenus& genus, CCoord& co )
 
 //! Change one coordinate.
 
-void COlc::set_coord( const CGenus& genus, CCoord& co )
+void COlc::set_coord(const CGenus& genus, CCoord& co)
 {
-    if        ( genus.categ==VCateg::X ) {
+    if (genus.categ == VCateg::X) {
         xco = co;
-    } else if ( genus.categ==VCateg::Y ) {
+    } else if (genus.categ == VCateg::Y) {
         yco = co;
-    } else if ( genus.categ==VCateg::Z ) {
-        if( genus.num >= nZ() )
+    } else if (genus.categ == VCateg::Z) {
+        if (genus.num >= nZ())
             throw "coordinate " + genus.genus_info() + " not defined";
         ZCo[genus.num] = co;
-    } else if ( genus.categ==VCateg::CP ) {
-        if( genus.num >= nP )
+    } else if (genus.categ == VCateg::CP) {
+        if (genus.num >= nP)
             throw "coordinate " + genus.genus_info() + " not defined";
         PCo[genus.num] = co;
-    } else if ( genus.categ==VCateg::R ) {
-        if( genus.num >= RPar.size() )
+    } else if (genus.categ == VCateg::R) {
+        if (genus.num >= RPar.size())
             throw "coordinate " + genus.genus_info() + " not defined";
         RPar[genus.num] = co;
     } else {
@@ -339,7 +321,7 @@ void COlc::set_coord( const CGenus& genus, CCoord& co )
 
 //! Create data file based on curve file.
 
-COld::COld( class COlc const* c )
+COld::COld(class COlc const* c)
 {
     name = c->name;
     lDoc = c->lDoc;
@@ -354,25 +336,25 @@ COld::COld( class COlc const* c )
 
 void COld::purge_dy()
 {
-    for ( int j=0; j<nJ(); ++j ) {
-        if ( !VS(j)->has_dy() )
+    for (int j = 0; j < nJ(); ++j) {
+        if (!VS(j)->has_dy())
             return; // dy already absent, nothing to do
-        for ( int i=0; i<VS(j)->size(); ++i) {
-            if( VS(j)->dy[i] != 0 )
+        for (int i = 0; i < VS(j)->size(); ++i) {
+            if (VS(j)->dy[i] != 0)
                 return; // dy has at least one nonzero entry, nothing to do
         }
     }
-    for ( int j=0; j<nJ(); ++j )
-        VS( j )->dy.clear();
+    for (int j = 0; j < nJ(); ++j)
+        VS(j)->dy.clear();
 }
 
 
 //! Return number of points in spectrum j.
 
-int COld::nPts( int j ) const
+int COld::nPts(int j) const
 {
-    if ( !nJ() || j>=nJ() )
-        throw "BUG: nPts called with invalid j="+S(j);
+    if (!nJ() || j >= nJ())
+        throw "BUG: nPts called with invalid j=" + S(j);
     return VS(j)->size();
 }
 
@@ -381,11 +363,12 @@ int COld::nPts( int j ) const
 
 int COld::nPts() const
 {
-    if ( !nJ() )
+    if (!nJ())
         throw "BUG: nPts() called while nSpec=0";
     int np = VS(0)->size();
-    for ( int j=0; j<nJ(); ++j )
-        if (VS(j)->size()!=np) return 0;
+    for (int j = 0; j < nJ(); ++j)
+        if (VS(j)->size() != np)
+            return 0;
     return np;
 }
 
@@ -394,10 +377,9 @@ int COld::nPts() const
 
 bool COld::has_nonzero_dy() const
 {
-    return std::all_of(
-        V.cbegin(), V.cend(),
-        [](const PSlice& s){ return dynamic_cast<const CSpec*>(s.get())->has_nonzero_dy(); }
-        );
+    return std::all_of(V.cbegin(), V.cend(), [](const PSlice& s) {
+        return dynamic_cast<const CSpec*>(s.get())->has_nonzero_dy();
+    });
 }
 
 //**************************************************************************************************
@@ -408,54 +390,53 @@ string COlc::wgtNames[] = { "lin", "log", "var", "varc", "vard" };
 
 //! Converts weight from string to enum
 
-COlc::TWgt COlc::name2wgt( string name )
+COlc::TWgt COlc::name2wgt(string name)
 {
-    for ( int i=0; i<=_LAST_TWGT; ++i )
-        if( name==COlc::wgtNames[i] )
+    for (int i = 0; i <= _LAST_TWGT; ++i)
+        if (name == COlc::wgtNames[i])
             return (TWgt)i;
     throw "undefined weighing key '" + name + "'";
 }
 
 //! Prompt for curve description, and initialize things.
 
-void COlc::curve_query( const string& quest )
+void COlc::curve_query(const string& quest)
 { // EMBEDDED_DIALOG
- ask_again:
-    string resp = sask( quest+" (or e(c|i)(r|w); h for help)" );
-    if        ( resp=="h" ) {
-        cout <<
-            "curve definition:\n"
-            "- either an arithmetic expression,\n"
-            "    containing the running variable t,\n"
-            "    for instance: p0+p1*t\n"
-            "- or external evaluation mode e(c|i)(r|w)\n"
-            "       next question will ask for external program\n"
-            "    c: program reads pars from command line\n"
-            "    i: program reads #pars, pars from standard input\n"
-            "    r: program reads #points, points from standard input\n"
-            "    w: program writes default grid, Frida interpolates\n";
+ask_again:
+    string resp = sask(quest + " (or e(c|i)(r|w); h for help)");
+    if (resp == "h") {
+        cout << "curve definition:\n"
+                "- either an arithmetic expression,\n"
+                "    containing the running variable t,\n"
+                "    for instance: p0+p1*t\n"
+                "- or external evaluation mode e(c|i)(r|w)\n"
+                "       next question will ask for external program\n"
+                "    c: program reads pars from command line\n"
+                "    i: program reads #pars, pars from standard input\n"
+                "    r: program reads #points, points from standard input\n"
+                "    w: program writes default grid, Frida interpolates\n";
         goto ask_again;
-    } else if ( resp.size()==3 && resp[0]=='e' &&
-                ( resp[1]=='c' || resp[1]=='i' ) &&
-                ( resp[2]=='r' || resp[2]=='w' ) ) {
-        if      ( resp[1]=='c' )
+    } else if (
+        resp.size() == 3 && resp[0] == 'e' && (resp[1] == 'c' || resp[1] == 'i')
+        && (resp[2] == 'r' || resp[2] == 'w')) {
+        if (resp[1] == 'c')
             scrInpMode = COlc::_CMDLIN;
-        else if ( resp[1]=='i' )
+        else if (resp[1] == 'i')
             scrInpMode = COlc::_STDIN;
         else
             throw "BUG: impossible case";
-        if      ( resp[2]=='r' )
+        if (resp[2] == 'r')
             evaMode = COlc::_SCR;
-        else if ( resp[2]=='w' )
+        else if (resp[2] == 'w')
             evaMode = COlc::_SCR_INTP;
         else
             throw "BUG: impossible case";
-        expr = sask( "Curve evaluation command" );
-        nP = iask( "Number of parameters" );
+        expr = sask("Curve evaluation command");
+        nP = iask("Number of parameters");
     } else {
-        parse_function( resp );
+        parse_function(resp);
     }
-    if( nP>100 )
+    if (nP > 100)
         throw "PLAUSIBILITY CHECK FAILED: unexpected number of parameters np = " + S(nP);
 }
 
@@ -469,8 +450,8 @@ void COlc::curve_query( const string& quest )
 
 void COlc::curve_set_defaults()
 {
-    for( int ip=0; ip<nP; ip++ )
-        PCo.push_back( CCoord("p" + S(ip), "") );
+    for (int ip = 0; ip < nP; ip++)
+        PCo.push_back(CCoord("p" + S(ip), ""));
     weighing = COlc::_VAR;
 }
 
@@ -480,19 +461,19 @@ void COlc::curve_set_defaults()
 void COlc::clear_fits_outcome()
 {
     chi2 = 0;
-    for( int j=0; j<nJ(); ++j )
+    for (int j = 0; j < nJ(); ++j)
         VC(j)->clear_fit_outcome();
 }
 
 
 //! Parses function expression.
 
-void COlc::parse_function( const string& _expr )
+void COlc::parse_function(const string& _expr)
 {
     evaMode = COlc::_EXPR;
     expr = _expr;
-    T = user_xaxparse( expr.c_str() );
-    if( !T->has_dummy() )
+    T = user_xaxparse(expr.c_str());
+    if (!T->has_dummy())
         cout << "WARNING: curve has no formal argument t\n";
     nP = T->npar();
 }
@@ -505,18 +486,18 @@ void COlc::parse_function( const string& _expr )
 
 //! Vectorial evaluation of a curve given by an expression tree.
 
-RObjVec COlc::eval_curve_expr( const vector<double>& vt, int k, int j, bool want_error ) const
+RObjVec COlc::eval_curve_expr(const vector<double>& vt, int k, int j, bool want_error) const
 {
-    CContext ctx( k, j );
+    CContext ctx(k, j);
     ctx.want_error = want_error;
     RObj ret;
-    if        ( !T->has_dummy() ) {  // curve does not depend on t
-        ret = T->tree_val( ctx );
+    if (!T->has_dummy()) { // curve does not depend on t
+        ret = T->tree_val(ctx);
     } else {
-        ctx.request_VT( &vt );
-        ret = T->tree_val( ctx );
+        ctx.request_VT(&vt);
+        ret = T->tree_val(ctx);
     }
-    if ( !ret->is_vec() )
+    if (!ret->is_vec())
         throw S("BUG in eval_curve_expr: T->tree_val didn't return a vector");
     return PCAST<const CObjVec>(ret);
 }
@@ -524,14 +505,14 @@ RObjVec COlc::eval_curve_expr( const vector<double>& vt, int k, int j, bool want
 
 //! Vectorial evaluation of a curve given by a system call.
 
-RObjVec COlc::eval_curve_syscall( const vector<double>& vt, int k, int j,
-                                  bool want_error /* currently ignored */ ) const
+RObjVec COlc::eval_curve_syscall(
+    const vector<double>& vt, int k, int j, bool want_error /* currently ignored */) const
 {
     // Create FIFO to receive return values.
-          // TODO: choose name as: triv::next_tmp_file( "/tmp/frida.%i" );
-    string ret_fifonam = string("/tmp/ret-") + getenv( "LOGNAME" );
-    triv::system( "rm -f "+ret_fifonam );
-    if ( mkfifo( ret_fifonam.c_str(), 0666 ) )
+    // TODO: choose name as: triv::next_tmp_file( "/tmp/frida.%i" );
+    string ret_fifonam = string("/tmp/ret-") + getenv("LOGNAME");
+    triv::system("rm -f " + ret_fifonam);
+    if (mkfifo(ret_fifonam.c_str(), 0666))
         throw "SYSTEM ERROR cannot make " + ret_fifonam;
 
     string cmd = expr;
@@ -540,113 +521,113 @@ RObjVec COlc::eval_curve_syscall( const vector<double>& vt, int k, int j,
     string par_fifonam;
 
     // Create FIFO for passing pars or/and grid via stdin.
-    if ( scrInpMode==_STDIN || evaMode == _SCR ) {
-        par_fifonam = string("/tmp/par-") + getenv( "LOGNAME" );
-        triv::system( "rm -f "+par_fifonam );
-        if ( mkfifo( par_fifonam.c_str(), 0666 ) )
+    if (scrInpMode == _STDIN || evaMode == _SCR) {
+        par_fifonam = string("/tmp/par-") + getenv("LOGNAME");
+        triv::system("rm -f " + par_fifonam);
+        if (mkfifo(par_fifonam.c_str(), 0666))
             throw "SYSTEM ERROR cannot make " + par_fifonam;
         inp_fifo = " < " + par_fifonam;
     }
     // Parameters passed on command line.
-    if ( scrInpMode==_CMDLIN ){
+    if (scrInpMode == _CMDLIN) {
         string pars = "";
-        for ( int ip=0; ip<nP; ++ip )
-            pars += " " + str( format("%g ") % VC(j)->P[ip] );
+        for (int ip = 0; ip < nP; ++ip)
+            pars += " " + str(format("%g ") % VC(j)->P[ip]);
         cmd += pars;
     }
 
     // Start the external process.
     cmd += inp_fifo + " > " + ret_fifonam + " &";
     errmsg = "command '" + cmd + "'";
-    system( cmd.c_str() );
+    system(cmd.c_str());
 
     // Feed parameters and x values to FIFO.
-    if( inp_fifo!="" ){
+    if (inp_fifo != "") {
         int par_fifo;
         // we use open instead of fopen or ofstream,
         // because we need non-blocking mode.
-        if ( !( par_fifo = open( par_fifonam.c_str(), O_WRONLY ) ) )
+        if (!(par_fifo = open(par_fifonam.c_str(), O_WRONLY)))
             throw "SYSTEM ERROR cannot open " + par_fifonam;
-        fcntl( par_fifo, F_SETFL, O_NONBLOCK);
-
-        if ( scrInpMode==_STDIN ){
-            string out = str( format("%i ") % nP );
-            write( par_fifo, out.c_str(), out.size() );
-            for ( int ip=0; ip<nP; ++ip ) {
-                string out = str( format("%16.8g ") % VC(j)->P[ip] );
-                write( par_fifo, out.c_str(), out.size() );
+        fcntl(par_fifo, F_SETFL, O_NONBLOCK);
+
+        if (scrInpMode == _STDIN) {
+            string out = str(format("%i ") % nP);
+            write(par_fifo, out.c_str(), out.size());
+            for (int ip = 0; ip < nP; ++ip) {
+                string out = str(format("%16.8g ") % VC(j)->P[ip]);
+                write(par_fifo, out.c_str(), out.size());
             }
         }
-        if ( evaMode==_SCR ) {
-            string out = str( format("%i ") % vt.size() );
-            write( par_fifo, out.c_str(), out.size() );
-            for ( int i=0; i<vt.size(); ++i ) {
-                string out = str( format("%16.8g ") % vt[i] );
-                write( par_fifo, out.c_str(), out.size() );
+        if (evaMode == _SCR) {
+            string out = str(format("%i ") % vt.size());
+            write(par_fifo, out.c_str(), out.size());
+            for (int i = 0; i < vt.size(); ++i) {
+                string out = str(format("%16.8g ") % vt[i]);
+                write(par_fifo, out.c_str(), out.size());
             }
         }
-        close( par_fifo );
+        close(par_fifo);
     }
-    //cout << "DEB cvv: #vt=" << vt.size() << ", called " << errmsg << "\n";
+    // cout << "DEB cvv: #vt=" << vt.size() << ", called " << errmsg << "\n";
 
-    std::ifstream FF( ret_fifonam );
-    if( !FF.is_open() )
+    std::ifstream FF(ret_fifonam);
+    if (!FF.is_open())
         throw "BUG: cannot read results of system call from " + ret_fifonam;
 
-    vector<double> v( vt.size() );
+    vector<double> v(vt.size());
 
-    if        ( evaMode==_SCR ) {
-        for ( int i=0; i<vt.size(); ++i ) {
+    if (evaMode == _SCR) {
+        for (int i = 0; i < vt.size(); ++i) {
             string line;
-            if( !getline( FF, line ) )
+            if (!getline(FF, line))
                 throw "BUG: failed to read line " + S(i) + " from " + ret_fifonam;
             std::istringstream iss(line);
             double x;
             try {
                 iss >> x >> v[i];
-            } catch( std::exception &ex ) {
-                throw S(ex.what()) + ": returns no x y pair for t["+S(i)+"]="+
-                    S(vt[i])+" but '"+line+"'";
+            } catch (std::exception& ex) {
+                throw S(ex.what()) + ": returns no x y pair for t[" + S(i) + "]=" + S(vt[i])
+                    + " but '" + line + "'";
             }
-            if( fabs(x-vt[i])>1e-4*fabs(vt[i]+x) )
-                throw errmsg + " returns x=" + S(x) + " instead of " +
-                    S(vt[i]) + " in line '"+line+"'";
-            if ( !std::isfinite(v[i]) )
-                throw "infinite y value in line '"+line+"'";
+            if (fabs(x - vt[i]) > 1e-4 * fabs(vt[i] + x))
+                throw errmsg + " returns x=" + S(x) + " instead of " + S(vt[i]) + " in line '"
+                    + line + "'";
+            if (!std::isfinite(v[i]))
+                throw "infinite y value in line '" + line + "'";
         }
-    } else if ( evaMode==_SCR_INTP ) {
+    } else if (evaMode == _SCR_INTP) {
         CSpec S;
         double x, y;
         string line;
-        while( getline( FF, line ) ) {
+        while (getline(FF, line)) {
             std::istringstream iss(line);
             try {
                 iss >> x >> y;
-            } catch( std::exception &ex ) {
-                throw S(ex.what()) + ": invalid line '"+line+"'";
+            } catch (std::exception& ex) {
+                throw S(ex.what()) + ": invalid line '" + line + "'";
             }
-            S.push_xy( x, y );
+            S.push_xy(x, y);
         }
         // interpolation:
-        if ( S.size()<2 )
+        if (S.size() < 2)
             throw errmsg + " returns only " + S(S.size()) + " valid lines";
-        //cout << "DEB cvv: intpol "<<vt.front()<<" .. "<<vt.back()<<"\n";
-        S.intpol( vt, &v, nullptr );
+        // cout << "DEB cvv: intpol "<<vt.front()<<" .. "<<vt.back()<<"\n";
+        S.intpol(vt, &v, nullptr);
     } else
         throw S("BUG: invalid evaMode");
     FF.close();
-    return PObjVecDbl( new CObjVecDbl( v ) );
+    return PObjVecDbl(new CObjVecDbl(v));
 }
 
 
 //! Vectorial evaluation of a curve.
 
-RObjVec COlc::eval_curve( const vector<double>& vt, int k, int j, bool want_error ) const
+RObjVec COlc::eval_curve(const vector<double>& vt, int k, int j, bool want_error) const
 {
-    if ( evaMode==_EXPR )
-        return eval_curve_expr( vt, k, j, want_error );
-    else if ( evaMode==_SCR || evaMode==_SCR_INTP )
-        return eval_curve_syscall( vt, k, j, want_error );
+    if (evaMode == _EXPR)
+        return eval_curve_expr(vt, k, j, want_error);
+    else if (evaMode == _SCR || evaMode == _SCR_INTP)
+        return eval_curve_syscall(vt, k, j, want_error);
     else
         throw S("BUG: unexpected evaluation mode");
 }
@@ -654,12 +635,12 @@ RObjVec COlc::eval_curve( const vector<double>& vt, int k, int j, bool want_erro
 
 //! Scalar evaluation of a curve.
 
-RObj COlc::eval_curve_scalar( double arg, int k, int j, bool want_error ) const
+RObj COlc::eval_curve_scalar(double arg, int k, int j, bool want_error) const
 {
-    vector<double> vt( 1, arg );
-    RObjVec cu = eval_curve( vt, k, j, want_error );
-    if ( cu->size()!=1 )
-        throw "BUG: vector has "+S(cu->size())+" elements while exactly one was expected";
+    vector<double> vt(1, arg);
+    RObjVec cu = eval_curve(vt, k, j, want_error);
+    if (cu->size() != 1)
+        throw "BUG: vector has " + S(cu->size()) + " elements while exactly one was expected";
     return cu->to_obj(0);
 }
 
@@ -674,20 +655,20 @@ vector<string> COlc::info_settings() const
 {
     vector<string> ret;
     string out = "";
-    if      ( evaMode==_SCR )
+    if (evaMode == _SCR)
         out = "script: ";
-    else if ( evaMode==_SCR_INTP )
+    else if (evaMode == _SCR_INTP)
         out = "script (followed by interpolation): ";
-    ret.push_back( out + expr );
+    ret.push_back(out + expr);
     string txt = "";
-    if( kd!=-1 )
+    if (kd != -1)
         txt += "data file: " + S(kd) + ", ";
-    if( kconv!=-1 )
+    if (kconv != -1)
         txt += "conv file: " + S(kconv) + ", ";
     txt += "weighing: " + weight_str();
-    ret.push_back( txt );
-    if( chi2>0 )
-        ret.push_back( "global fit result: "+S(chi2));
+    ret.push_back(txt);
+    if (chi2 > 0)
+        ret.push_back("global fit result: " + S(chi2));
     return ret;
 }
 
@@ -697,10 +678,10 @@ vector<string> COlc::info_settings() const
 string COlc::info_table_header() const
 {
     string ret = "j ";
-    for ( int iz=0; iz<nZ(); iz++ )
-        ret += str( format( "  z%i          " ) % iz );
-    for ( int ip=0; ip<nP; ip++ )
-        ret += str( format( "  p%i           " ) % ip );
+    for (int iz = 0; iz < nZ(); iz++)
+        ret += str(format("  z%i          ") % iz);
+    for (int ip = 0; ip < nP; ip++)
+        ret += str(format("  p%i           ") % ip);
     ret += " oc chi^2       1-R^2";
     return ret;
 }
@@ -710,11 +691,11 @@ string COlc::info_table_header() const
 
 void COlc::print_info_table() const
 {
-    for( string line: info_settings() )
+    for (string line : info_settings())
         cout << line << "\n";
     cout << info_table_header() << "\n";
-    for( int j=0; j<nJ(); ++j )
-        cout << info_line( j ) << "\n";
+    for (int j = 0; j < nJ(); ++j)
+        cout << info_line(j) << "\n";
 }
 
 
@@ -722,8 +703,8 @@ void COlc::print_info_table() const
 
 bool COlc::has_global_par() const
 {
-    for ( int j=0; j<nJ(); ++j )
-        if ( VC(j)->has_global_par() )
+    for (int j = 0; j < nJ(); ++j)
+        if (VC(j)->has_global_par())
             return true;
     return false;
 }
@@ -733,7 +714,7 @@ bool COlc::has_global_par() const
 
 string COlc::weight_str() const
 {
-    switch ( weighing ) {
+    switch (weighing) {
     case _LIN:
         return "constant";
     case _LOG:
diff --git a/pub/lib/olf.hpp b/pub/lib/olf.hpp
index fbabb64a8b5a9aac64911f5fea898c1cb8f2be7b..77c4481aced30b7c11ba9366a2b981944615e750 100644
--- a/pub/lib/olf.hpp
+++ b/pub/lib/olf.hpp
@@ -7,15 +7,16 @@
 //! \file  olf.hpp
 //! \brief COlo, COld, COld online files
 
-#include "ptr.hpp"
 #include "coord.hpp"
+#include "ptr.hpp"
 
 class CGenus;
 
 //! Online object. Virtual base class for COld, COlc.
 
-class COlo {
- public:
+class COlo
+{
+public:
     // Meta data:
     string name;
     vector<string> lDoc;
@@ -28,47 +29,48 @@ class COlo {
     vector<PSlice> V;
 
     COlo();
-    COlo& operator=( const COlo& ) = delete;
+    COlo& operator=(const COlo&) = delete;
     COlo(const COlo&) = delete;
     virtual ~COlo(); ///< magic: makes dynamic_cast possible
 
-    void copy_meta_O_from_other( const COlo* from );
-    void log_action( const string& line );
-    void remove_z( int iz );
-    string info_line( int j ) const;
+    void copy_meta_O_from_other(const COlo* from);
+    void log_action(const string& line);
+    void remove_z(int iz);
+    string info_line(int j) const;
     void check_integrity() const;
 
-    virtual void copy_mainvec( const COlo *fin ) =0;
+    virtual void copy_mainvec(const COlo* fin) = 0;
 
     int nJ() const { return V.size(); }
     int nZ() const { return ZCo.size(); }
-    RObj z( int j, int iz ) const;
-    virtual PSlice copy_slice( int j ) const = 0;
+    RObj z(int j, int iz) const;
+    virtual PSlice copy_slice(int j) const = 0;
     virtual POlo new_POlo() const = 0;
-    virtual CCoord coord( const CGenus& genus ) const = 0;
-    virtual void set_coord( const CGenus& genus, CCoord& co ) = 0;
+    virtual CCoord coord(const CGenus& genus) const = 0;
+    virtual void set_coord(const CGenus& genus, CCoord& co) = 0;
     virtual string type() const = 0;
 };
 
 
 //! Online data file. This is Frida's data model.
 
-class COld : public COlo {
- public:
+class COld : public COlo
+{
+public:
     COld() : COlo() {}
-    explicit COld( class COlc const* fc );
+    explicit COld(class COlc const* fc);
 
     // Functions that exist similarly for COld and COlc:
-    void copy_meta_D_from_other( const COld* other );
-    CSpec* VS( int j ) const;
-    PSlice copy_slice( int j ) const;
+    void copy_meta_D_from_other(const COld* other);
+    CSpec* VS(int j) const;
+    PSlice copy_slice(int j) const;
     POlo new_POlo() const;
     POld new_POld() const;
-    void copy_mainvec( const COlo *fin );
+    void copy_mainvec(const COlo* fin);
 
     // Overloaded functions:
-    void set_coord( const CGenus& genus, CCoord& co );
-    CCoord coord( const CGenus& genus ) const;
+    void set_coord(const CGenus& genus, CCoord& co);
+    CCoord coord(const CGenus& genus) const;
 
     // Functions specific to data file:
     void purge_dy();
@@ -82,49 +84,65 @@ class COld : public COlo {
 
 //! Online curve file.
 
-class COlc : public COlo {
- private:
-    RObjVec eval_curve_expr( const vector<double>& vt, int k, int j, bool want_error ) const;
-    RObjVec eval_curve_syscall( const vector<double>& vt, int k, int j, bool want_error ) const;
+class COlc : public COlo
+{
+private:
+    RObjVec eval_curve_expr(const vector<double>& vt, int k, int j, bool want_error) const;
+    RObjVec eval_curve_syscall(const vector<double>& vt, int k, int j, bool want_error) const;
 
- public:
+public:
     // Function:
-    enum TEva    { _EXPR, _SCR, _SCR_INTP } evaMode; ///< How curve is defined
+    enum TEva { _EXPR, _SCR, _SCR_INTP } evaMode; ///< How curve is defined
     enum TScrInp { _STDIN, _CMDLIN } scrInpMode; ///< Where pars are read from
-    string expr;                ///< The curve's definition (input expression).
-    RNode T;                    ///< The curve's definition (parsed tree).
-    int kconv;                  ///< Index of resolution file to convolve with.
-    int nP;                     ///< Number of parameters.
+    string expr; ///< The curve's definition (input expression).
+    RNode T; ///< The curve's definition (parsed tree).
+    int kconv; ///< Index of resolution file to convolve with.
+    int nP; ///< Number of parameters.
 
     // Refined description:
-    vector<CCoord> PCo;         ///< Names and units of fit parameters.
+    vector<CCoord> PCo; ///< Names and units of fit parameters.
 
     // Fitting:
-    int           kd;           ///< Index of data file to be fitted.
-    enum TWgt { _LIN, _LOG, _VAR, _VARC, _VARD, _LAST_TWGT=_VARD }
-                  weighing;     ///< Weight mode for fitting.
+    int kd; ///< Index of data file to be fitted.
+    enum TWgt {
+        _LIN,
+        _LOG,
+        _VAR,
+        _VARC,
+        _VARD,
+        _LAST_TWGT = _VARD
+    } weighing; ///< Weight mode for fitting.
     static string wgtNames[];
-    static TWgt name2wgt( string name );
-    bool          plot_to_grid; ///< Use grid from file 'kd' ?
-    string        range_expr;   ///< Restricts points to be fitted.
-    RNode         range_T;      ///< Parsed range_expr.
-    double        chi2;         ///< Global chi^2
-
-    COlc() :
-        COlo(), evaMode(_EXPR), scrInpMode(_STDIN), kconv(-1), kd(-1), weighing( _VAR ),
-        plot_to_grid( false ), range_expr(""), chi2(0) {}
+    static TWgt name2wgt(string name);
+    bool plot_to_grid; ///< Use grid from file 'kd' ?
+    string range_expr; ///< Restricts points to be fitted.
+    RNode range_T; ///< Parsed range_expr.
+    double chi2; ///< Global chi^2
+
+    COlc()
+        : COlo()
+        , evaMode(_EXPR)
+        , scrInpMode(_STDIN)
+        , kconv(-1)
+        , kd(-1)
+        , weighing(_VAR)
+        , plot_to_grid(false)
+        , range_expr("")
+        , chi2(0)
+    {
+    }
 
     // Functions that exist similarly for COld and COlc:
-    void copy_meta_C_from_other( const COlc* other );
-    CCurve* VC( int j ) const;
-    PSlice copy_slice( int j ) const;
+    void copy_meta_C_from_other(const COlc* other);
+    CCurve* VC(int j) const;
+    PSlice copy_slice(int j) const;
     POlo new_POlo() const;
     POlc new_POlc() const;
-    void copy_mainvec( const COlo *fin );
+    void copy_mainvec(const COlo* fin);
 
     // Overloaded functions:
-    void set_coord( const CGenus& genus, CCoord& co );
-    CCoord coord( const CGenus& genus ) const;
+    void set_coord(const CGenus& genus, CCoord& co);
+    CCoord coord(const CGenus& genus) const;
 
     // Pertinent functions:
     bool has_global_par() const;
@@ -136,9 +154,9 @@ class COlc : public COlo {
     // The following nontrivial function are implemented in curve.cpp:
     void curve_set_defaults();
     void clear_fits_outcome();
-    void parse_function( const string& expr );
-    void curve_query( const string& quest );
-    RObjVec eval_curve( const vector<double>& vt, int k, int j, bool want_error ) const;
-    RObj eval_curve_scalar( double arg, int k, int j, bool want_error ) const;
+    void parse_function(const string& expr);
+    void curve_query(const string& quest);
+    RObjVec eval_curve(const vector<double>& vt, int k, int j, bool want_error) const;
+    RObj eval_curve_scalar(double arg, int k, int j, bool want_error) const;
     virtual string type() const { return "curve"; }
 };
diff --git a/pub/lib/opr.cpp b/pub/lib/opr.cpp
index 5aaf2b3471fde606023465ef41db654bdefb1353..fabae83fd1dc0b20fac1f8f96b753579715bf4ff 100644
--- a/pub/lib/opr.cpp
+++ b/pub/lib/opr.cpp
@@ -13,15 +13,15 @@
 
 #include "../readplus/ask.hpp"
 
-#include "olf.hpp"
-#include "mem.hpp"
+#include "expr.hpp"
 #include "fsel.hpp"
-#include "loop.hpp"
-#include "slice.hpp"
 #include "genus.hpp"
+#include "loop.hpp"
+#include "mem.hpp"
 #include "obj.hpp"
-#include "expr.hpp"
+#include "olf.hpp"
 #include "opr.hpp"
+#include "slice.hpp"
 #include "xax_lex.hpp"
 
 using boost::format;
@@ -34,58 +34,60 @@ using boost::format;
 
 //! Display data. Use boolean expression to display only a subset of the data.
 
-void NOperate::show( const string& subcmd )
+void NOperate::show(const string& subcmd)
 {
     FileIterator fiter(SFSel::instance()->selD());
 
     static string expr = "1";
-    expr = sask( "Show if", expr);
-    if (expr=="")
+    expr = sask("Show if", expr);
+    if (expr == "")
         return;
-    RNode T = user_xaxparse( expr.c_str() );
-    if( T->has_dummy() )
+    RNode T = user_xaxparse(expr.c_str());
+    if (T->has_dummy())
         throw S("dummy argument t not allowed when operating on data");
 
-    while( const COld *fin = fiter.nextD() ) {
-        if ( fiter.size()>1 )
-            printf( ".. file %i:\n", fiter.k() );
+    while (const COld* fin = fiter.nextD()) {
+        if (fiter.size() > 1)
+            printf(".. file %i:\n", fiter.k());
 
         string outj, outp;
 
         // determine length of longest spectrum:
         int ni = 0;
-        for ( int j=0; j<fin->nJ(); j++)
-            ni = std::max( ni, fin->VS(j)->size() );
+        for (int j = 0; j < fin->nJ(); j++)
+            ni = std::max(ni, fin->VS(j)->size());
 
         // printout by i:
-        for ( int i=0; i<ni; i++) {
+        for (int i = 0; i < ni; i++) {
             outj = "";
             outp = "";
 
-            for( int j=0; j<fin->nJ(); j++ ){
-                const CSpec *s = fin->VS(j);
-                if( i>= s->size() ) continue;
-                if ( ! T->tree_point_dbl( fiter.k(), j, i ) )
+            for (int j = 0; j < fin->nJ(); j++) {
+                const CSpec* s = fin->VS(j);
+                if (i >= s->size())
+                    continue;
+                if (!T->tree_point_dbl(fiter.k(), j, i))
                     continue;
                 outj += S(j) + " ";
-                if      ( subcmd=="xyd" )
-                    if( s->has_dy() )
-                        outp += str( format( "%- 12.5g %- 12.5g +- %- 12.5g" )
-                                     % s->x[i] % s->y[i] % s->dy[i] );
+                if (subcmd == "xyd")
+                    if (s->has_dy())
+                        outp += str(
+                            format("%- 12.5g %- 12.5g +- %- 12.5g") % s->x[i] % s->y[i] % s->dy[i]);
                     else
-                        outp += str( format( "%- 12.5g %- 12.5g" ) % s->x[i] % s->y[i] );
-                else if ( subcmd=="y" )
-                    outp += str( format( "%- 12.5g" ) % s->y[i] );
+                        outp += str(format("%- 12.5g %- 12.5g") % s->x[i] % s->y[i]);
+                else if (subcmd == "y")
+                    outp += str(format("%- 12.5g") % s->y[i]);
                 else
                     throw "invalid subcmd " + subcmd;
                 outp += " ";
             }
 
-            if( outp=="" )
+            if (outp == "")
                 continue;
 
-            printf( "%5i [%s] %s\n", i, outj.substr(0,outj.size()-1).c_str(),
-                    outp.substr(0,outp.size()-1).c_str() );
+            printf(
+                "%5i [%s] %s\n", i, outj.substr(0, outj.size() - 1).c_str(),
+                outp.substr(0, outp.size() - 1).c_str());
         }
     }
 }
@@ -93,163 +95,163 @@ void NOperate::show( const string& subcmd )
 
 //! Delete or retain data points according to a boolean expression.
 
-void NOperate::select( bool sel_del )
+void NOperate::select(bool sel_del)
 {
     FileIterator fiter(SFSel::instance()->sel());
     static string expr;
     expr = sask((sel_del ? "Delete if" : "Retain if"), expr);
-    if (expr=="")
+    if (expr == "")
         return;
-    RNode T = user_xaxparse( expr.c_str() );
-    if( T->has_dummy() )
+    RNode T = user_xaxparse(expr.c_str());
+    if (T->has_dummy())
         throw S("dummy argument t not allowed when operating on data");
 
-    while ( const COlo *fin = fiter.next() ) {
-        const COld *fd = dynamic_cast<const COld*>( fin );
-        const COlc *fc = dynamic_cast<const COlc*>( fin );
+    while (const COlo* fin = fiter.next()) {
+        const COld* fd = dynamic_cast<const COld*>(fin);
+        const COlc* fc = dynamic_cast<const COlc*>(fin);
 
-        POlo fout( fin->new_POlo() );
+        POlo fout(fin->new_POlo());
         fout->log_action((sel_del ? "md " : "mr ") + expr);
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            if ( fd ) {
-                const CSpec *sin = fd->VS(j);
-                PSpec sout = PSpec( new CSpec );
+        for (int j = 0; j < fin->nJ(); j++) {
+            if (fd) {
+                const CSpec* sin = fd->VS(j);
+                PSpec sout = PSpec(new CSpec);
                 sout->z = sin->z;
-                vector<double> lvec( sin->size() );
-                T->tree_vec_val( &lvec, 0, fiter.k(), j );
+                vector<double> lvec(sin->size());
+                T->tree_vec_val(&lvec, 0, fiter.k(), j);
                 bool with_dy = sin->has_dy();
-                for ( int i=0; i<sin->size(); i++ ) {
-                    if ( sel_del ^ (bool) lvec[i] ) {
-                        if( with_dy )
-                            sout->push_xyd( sin->x[i], sin->y[i], sin->dy[i] );
+                for (int i = 0; i < sin->size(); i++) {
+                    if (sel_del ^ (bool)lvec[i]) {
+                        if (with_dy)
+                            sout->push_xyd(sin->x[i], sin->y[i], sin->dy[i]);
                         else
-                            sout->push_xy( sin->x[i], sin->y[i] );
+                            sout->push_xy(sin->x[i], sin->y[i]);
                     }
                 }
-                if ( sout->size() )
-                    fout->V.push_back( move(sout) );
-            } else if ( fc ) {
-                PCurve sout = PCurve( new CCurve( *(fc->VC(j)) ) );
-                if ( sel_del ^ T->tree_point_val( fiter.k(), j )->to_b() )
-                    fout->V.push_back( move(sout) );
+                if (sout->size())
+                    fout->V.push_back(move(sout));
+            } else if (fc) {
+                PCurve sout = PCurve(new CCurve(*(fc->VC(j))));
+                if (sel_del ^ T->tree_point_val(fiter.k(), j)->to_b())
+                    fout->V.push_back(move(sout));
             }
         }
-        if( !fout->nJ() )
+        if (!fout->nJ())
             throw S("no data point left");
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
 
 //! Pointwise operation on x, y, or z<n>, according to arithmetic expression.
 
-void NOperate::Pointwise( string llabel )
+void NOperate::Pointwise(string llabel)
 {
     FileIterator fiter(SFSel::instance()->sel());
 
     CGenus lref(llabel);
 
     static string expr;
-    expr = sask("Set "+llabel, expr);
-    if (expr=="")
+    expr = sask("Set " + llabel, expr);
+    if (expr == "")
         return;
-    RNode T = user_xaxparse( expr.c_str() );
-    if( T->has_dummy() )
+    RNode T = user_xaxparse(expr.c_str());
+    if (T->has_dummy())
         throw S("dummy argument t not allowed when operating on data");
 
-    while( const COlo *fin = fiter.next() ){
+    while (const COlo* fin = fiter.next()) {
         int k = fiter.k();
-        const COld *fd = dynamic_cast<const COld*>( fin );
-        const COlc *fc = dynamic_cast<const COlc*>( fin );
+        const COld* fd = dynamic_cast<const COld*>(fin);
+        const COlc* fc = dynamic_cast<const COlc*>(fin);
 
-        if ( lref.pointwise() && !fd )
+        if (lref.pointwise() && !fd)
             throw S("no pointwise operation on curve");
-        if( lref.categ==VCateg::CP && !fc )
+        if (lref.categ == VCateg::CP && !fc)
             continue;
 
-        POlo fout( fin->new_POlo() );
-        if( lref.categ!=VCateg::CP )
-            fout->log_action( "o" + lref.genus_info() + " " + expr);
+        POlo fout(fin->new_POlo());
+        if (lref.categ != VCateg::CP)
+            fout->log_action("o" + lref.genus_info() + " " + expr);
         fout->as_on_disk = false;
 
-        CCoord co = T->node_coord( k );
-        if        ( lref.categ==VCateg::X ) {
+        CCoord co = T->node_coord(k);
+        if (lref.categ == VCateg::X) {
             fout->xco = co;
-        } else if ( lref.categ==VCateg::Y ) {
+        } else if (lref.categ == VCateg::Y) {
             fout->yco = co;
-        } else if ( lref.categ==VCateg::Z ) {
-            if( lref.num==-1 )
-                fout->ZCo.push_back( co );
-            else if( lref.num >= fin->ZCo.size() )
+        } else if (lref.categ == VCateg::Z) {
+            if (lref.num == -1)
+                fout->ZCo.push_back(co);
+            else if (lref.num >= fin->ZCo.size())
                 throw S("no such z coordinate to operate on");
             else
                 fout->ZCo[lref.num] = co;
-        } else if ( lref.categ==VCateg::R ) {
-            if( lref.num==-1 )
-                fout->RPar.push_back( CParam( co ) );
-            else if( lref.num >= fin->RPar.size() )
+        } else if (lref.categ == VCateg::R) {
+            if (lref.num == -1)
+                fout->RPar.push_back(CParam(co));
+            else if (lref.num >= fin->RPar.size())
                 throw S("no such real par to operate on");
             else
                 fout->RPar[lref.num].Co = co;
-        } else if ( lref.categ==VCateg::CP ) {
-            if( !fc )
+        } else if (lref.categ == VCateg::CP) {
+            if (!fc)
                 continue; // just ignore op operations on data files
-            if( lref.num>=fc->nP )
+            if (lref.num >= fc->nP)
                 throw S("no such parameter to operate on");
             SMem::instance()->overwrite = 1;
             dynamic_cast<COlc*>(fout.get())->clear_fits_outcome();
         }
 
-        if ( lref.categ==VCateg::R ) {
-            fout->copy_mainvec( fin );
-            double val = T->tree_point_val( k, 0 )->to_r();
-            if( lref.num==-1 )
+        if (lref.categ == VCateg::R) {
+            fout->copy_mainvec(fin);
+            double val = T->tree_point_val(k, 0)->to_r();
+            if (lref.num == -1)
                 fout->RPar.back().val = val;
             else
                 fout->RPar[lref.num].val = val;
         } else {
-            fout->V.resize( fin->nJ() );
-            for( int j=0; j<fin->nJ(); j++ ){
-                fout->V[j] = fin->copy_slice( j );
-                if ( fin->V[j]->frozen )
+            fout->V.resize(fin->nJ());
+            for (int j = 0; j < fin->nJ(); j++) {
+                fout->V[j] = fin->copy_slice(j);
+                if (fin->V[j]->frozen)
                     continue;
-                if ( lref.pointwise() ) {
-                    vector<double> vout( fd->nPts(j) );
+                if (lref.pointwise()) {
+                    vector<double> vout(fd->nPts(j));
                     COld* fdout = dynamic_cast<COld*>(fout.get());
-                    if ( lref.categ==VCateg::X || lref.categ==VCateg::DY ) {
-                        T->tree_vec_val( &vout, 0, k, j );
-                        if      ( lref.categ==VCateg::X )
+                    if (lref.categ == VCateg::X || lref.categ == VCateg::DY) {
+                        T->tree_vec_val(&vout, 0, k, j);
+                        if (lref.categ == VCateg::X)
                             fdout->VS(j)->x = move(vout);
-                        else if ( lref.categ==VCateg::DY )
+                        else if (lref.categ == VCateg::DY)
                             fdout->VS(j)->dy = move(vout);
                         else
                             throw S("BUG: unexpected lref");
-                    } else if ( lref.categ==VCateg::Y ) {
-                        vector<double> dvout( fd->nPts(j) );
-                        T->tree_vec_val( &vout, &dvout, k, j );
+                    } else if (lref.categ == VCateg::Y) {
+                        vector<double> dvout(fd->nPts(j));
+                        T->tree_vec_val(&vout, &dvout, k, j);
                         fdout->VS(j)->y = move(vout);
-                        if( dvout.size() )
+                        if (dvout.size())
                             fdout->VS(j)->dy = move(dvout);
                         else
                             fdout->VS(j)->dy.clear();
                     } else
                         throw S("BUG: unexpected lref");
-                } else if ( lref.categ==VCateg::Z ) {
-                    RObj pret = T->tree_point_val( k, j );
-                    if ( lref.num==-1 )
-                        fout->V[j]->z.push_back( pret );
+                } else if (lref.categ == VCateg::Z) {
+                    RObj pret = T->tree_point_val(k, j);
+                    if (lref.num == -1)
+                        fout->V[j]->z.push_back(pret);
                     else
                         fout->V[j]->z[lref.num] = pret;
-                } else if ( lref.categ==VCateg::CP ) {
+                } else if (lref.categ == VCateg::CP) {
                     COlc* fcout = dynamic_cast<COlc*>(fout.get());
-                    fcout->VC(j)->P[lref.num] = T->tree_point_val( k, j )->to_r();
+                    fcout->VC(j)->P[lref.num] = T->tree_point_val(k, j)->to_r();
                 } else {
                     throw S("BUG: invalid oxy");
                 }
             }
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -261,128 +263,129 @@ void NOperate::Integral()
     FileIterator fiter(SFSel::instance()->sel());
 
     static string expr;
-    expr = sask( "Functional", expr );
-    if ( expr=="" )
+    expr = sask("Functional", expr);
+    if (expr == "")
         return;
-    RNode T = user_xaxparse( expr.c_str() );
-    if( T->has_dummy() )
+    RNode T = user_xaxparse(expr.c_str());
+    if (T->has_dummy())
         throw S("dummy argument t not allowed when operating on data");
 
-    while( const COlo *fin = fiter.next() ) {
+    while (const COlo* fin = fiter.next()) {
         int k = fiter.k();
         int nz = fin->ZCo.size();
         bool savable = nz > 0;
 
         POld fout;
         PSpec sout;
-        if ( savable ) {
-            if      ( const COlc *fc = dynamic_cast<const COlc*>(fin) )
-                fout = POld( new COld( fc ) );
+        if (savable) {
+            if (const COlc* fc = dynamic_cast<const COlc*>(fin))
+                fout = POld(new COld(fc));
             else
-                fout = POld( (dynamic_cast<const COld*>(fin))->new_POld() );
-            fout->log_action( "oi " +expr );
+                fout = POld((dynamic_cast<const COld*>(fin))->new_POld());
+            fout->log_action("oi " + expr);
             fout->ZCo.pop_back();
             fout->xco = fin->ZCo.back();
-            fout->yco = T->node_coord( k );
-            sout = PSpec( new CSpec );
+            fout->yco = T->node_coord(k);
+            sout = PSpec(new CSpec);
             sout->z = fin->V[0]->z;
             sout->z.pop_back();
         }
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            if ( savable && fin->V[j]->frozen )
+        for (int j = 0; j < fin->nJ(); j++) {
+            if (savable && fin->V[j]->frozen)
                 continue;
             double xval;
-            RObj res = T->tree_point_val( k, j );
+            RObj res = T->tree_point_val(k, j);
             if (!savable) {
                 cout << "result: " << res->to_s() << "\n";
                 continue;
             }
-            xval = fin->V[j]->z[nz-1]->to_r();
-            sout->push_xyd( xval, res->to_r(), res->to_dr() );
-            if (nz>=2) { // new spectrum if jump in other z values
-                double zval = fin->V[j]->z[nz-2]->to_r();
-                if ( j+1 < fin->nJ() && fin->V[j+1]->z[nz-2]->to_r() != zval ) {
-                    fout->V.push_back( move(sout) );
-                    sout = PSpec( new CSpec );
-                    sout->z = fin->V[j+1]->z;
+            xval = fin->V[j]->z[nz - 1]->to_r();
+            sout->push_xyd(xval, res->to_r(), res->to_dr());
+            if (nz >= 2) { // new spectrum if jump in other z values
+                double zval = fin->V[j]->z[nz - 2]->to_r();
+                if (j + 1 < fin->nJ() && fin->V[j + 1]->z[nz - 2]->to_r() != zval) {
+                    fout->V.push_back(move(sout));
+                    sout = PSpec(new CSpec);
+                    sout->z = fin->V[j + 1]->z;
                     sout->z.pop_back();
                 }
             }
         }
-        if ( savable ) {
+        if (savable) {
             fout->purge_dy();
-            fout->V.push_back( move(sout) );
-            SMem::instance()->mem_store( move(fout), fiter.k() );
+            fout->V.push_back(move(sout));
+            SMem::instance()->mem_store(move(fout), fiter.k());
         }
-//      if ( !savable )
-//          NReg::lastresult = res;
+        //      if ( !savable )
+        //          NReg::lastresult = res;
     }
 }
 
 
 //! Integral operations to generate not only new y, but also new x.
 
-void NOperate::IntXY( string mode )
+void NOperate::IntXY(string mode)
 { // EMBEDDED_DIALOG
     FileIterator fiter(SFSel::instance()->selD());
 
     bool with_d;
-    if      ( mode=="xy" )
+    if (mode == "xy")
         with_d = false;
-    else if ( mode=="xyd" )
+    else if (mode == "xyd")
         with_d = true;
     else
         throw S("invalid command");
 
     static int icolx = 0, icoly = 1, icold = 2;
     static CCoord xco, yco;
-    icolx = iask( "x from column", icolx );
-    if( icolx<0) return;
-    icoly = iask( "y from column", icoly );
-    if( icoly<0) return;
-    if ( with_d ) {
-        icold = iask( "dy from column", icold );
-        if( icold<0) return;
+    icolx = iask("x from column", icolx);
+    if (icolx < 0)
+        return;
+    icoly = iask("y from column", icoly);
+    if (icoly < 0)
+        return;
+    if (with_d) {
+        icold = iask("dy from column", icold);
+        if (icold < 0)
+            return;
     }
-    xco = CCoord( "x", "" );
-    yco = CCoord( "y", "" );
+    xco = CCoord("x", "");
+    yco = CCoord("y", "");
 
-    while( const COld *fin = fiter.nextD() ) {
+    while (const COld* fin = fiter.nextD()) {
         int nz = fin->ZCo.size();
 
-        POld fout( fin->new_POld() );
+        POld fout(fin->new_POld());
         string lin = S("oi") + mode + " " + S(icolx) + " " + S(icoly);
-        if ( with_d )
+        if (with_d)
             lin += " " + S(icold);
-        fout->log_action( lin );
+        fout->log_action(lin);
 
         fout->xco = xco;
         fout->yco = yco;
 
-        PSpec sout( new CSpec );
+        PSpec sout(new CSpec);
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
+        for (int j = 0; j < fin->nJ(); j++) {
             int n = fin->nPts(j);
-            if( icolx>=n || icoly>=n || (with_d && icold>=n) )
+            if (icolx >= n || icoly >= n || (with_d && icold >= n))
                 throw "not enough columns in spectrum " + S(j);
-            if ( with_d )
-                sout->push_xyd( fin->VS(j)->y[icolx],
-                                fin->VS(j)->y[icoly],
-                                fin->VS(j)->y[icold] );
+            if (with_d)
+                sout->push_xyd(fin->VS(j)->y[icolx], fin->VS(j)->y[icoly], fin->VS(j)->y[icold]);
             else
-                sout->push_xy( fin->VS(j)->y[icolx],
-                               fin->VS(j)->y[icoly] );
+                sout->push_xy(fin->VS(j)->y[icolx], fin->VS(j)->y[icoly]);
             sout->z = fin->VS(j)->z;
-            if ( nz>2 ) { // new spectrum if jump in other z value
-                if ( j+1<fin->nJ() && fin->V[j+1]->z[nz-2]->to_r() != fin->V[j]->z[nz-2]->to_r() ) {
-                    fout->V.push_back( move(sout) );
-                    sout = PSpec( new CSpec );
+            if (nz > 2) { // new spectrum if jump in other z value
+                if (j + 1 < fin->nJ()
+                    && fin->V[j + 1]->z[nz - 2]->to_r() != fin->V[j]->z[nz - 2]->to_r()) {
+                    fout->V.push_back(move(sout));
+                    sout = PSpec(new CSpec);
                 }
             }
         }
-        fout->V.push_back( move(sout) );
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        fout->V.push_back(move(sout));
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
 
@@ -393,61 +396,60 @@ void NOperate::IntXY( string mode )
 
 //! Functional integration, derivation, ...
 
-void NOperate::Functional( const string& subcmd )
+void NOperate::Functional(const string& subcmd)
 {
     FileIterator fiter(SFSel::instance()->selD());
-    while ( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
-        fout->log_action( "of"+subcmd );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
+        fout->log_action("of" + subcmd);
 
-        if        ( subcmd=="i" ) { // integrate
+        if (subcmd == "i") { // integrate
             fout->yco.name = "Int d" + fin->xco.name + " " + fin->yco.name;
             fout->yco.unit = fin->xco.unit + " * " + fin->yco.unit;
-        } else if ( subcmd=="s" ) { // sum
+        } else if (subcmd == "s") { // sum
             fout->yco.name = "Sum_0^i " + fin->yco.name;
             fout->yco.unit = fin->yco.unit;
-        } else if ( subcmd=="d" ) { // derive
+        } else if (subcmd == "d") { // derive
             fout->yco.name = "d" + fin->yco.name + " / d" + fin->xco.name;
             fout->yco.unit = fin->yco.unit + " / " + fin->xco.unit;
-        } else if ( subcmd=="ac" ) { // autocorrelate
+        } else if (subcmd == "ac") { // autocorrelate
             fout->yco.name = "ac{" + fin->yco.name + "}";
             fout->yco.unit = fin->yco.unit + "^2";
         } else {
             throw S("invalid 'of' command");
         }
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
-            const CSpec *sin = fin->VS(j);
-            PSpec sout( new CSpec );
+        for (int j = 0; j < fin->nJ(); j++) {
+            const CSpec* sin = fin->VS(j);
+            PSpec sout(new CSpec);
             sout->z = sin->z;
             int n = sin->size();
 
-            if        ( subcmd=="i" ) { // integrate
+            if (subcmd == "i") { // integrate
                 sout->x = sin->x;
-                sout->y.resize( n );
+                sout->y.resize(n);
                 sout->y[0] = 0;
-                for ( int i=1; i<n; ++i )
-                    sout->y[i] = sout->y[i-1] +
-                        (sin->x[i] - sin->x[i-1]) *
-                        (sin->y[i] + sin->y[i-1]) / 2;
-            } else if ( subcmd=="s" ) { // sum
+                for (int i = 1; i < n; ++i)
+                    sout->y[i] = sout->y[i - 1]
+                        + (sin->x[i] - sin->x[i - 1]) * (sin->y[i] + sin->y[i - 1]) / 2;
+            } else if (subcmd == "s") { // sum
                 sout->x = sin->x;
-                sout->y.resize( n );
+                sout->y.resize(n);
                 sout->y[0] = sin->y[0];
-                for ( int i=1; i<n; ++i )
-                    sout->y[i] = sout->y[i-1] + sin->y[i];
-            } else if ( subcmd=="d" ) { // derive
-                for( int i=0; i<n-1; ++i ){
-                    double dx = sin->x[i+1] - sin->x[i];
+                for (int i = 1; i < n; ++i)
+                    sout->y[i] = sout->y[i - 1] + sin->y[i];
+            } else if (subcmd == "d") { // derive
+                for (int i = 0; i < n - 1; ++i) {
+                    double dx = sin->x[i + 1] - sin->x[i];
                     sout->push_xy(
-                        (sin->x[i+1] + sin->x[i] ) / 2,
-                        dx==0 ? 0 : (sin->y[i+1] - sin->y[i]) / dx );
+                        (sin->x[i + 1] + sin->x[i]) / 2,
+                        dx == 0 ? 0 : (sin->y[i + 1] - sin->y[i]) / dx);
                 }
-            } else if ( subcmd=="ac" ) { // autocorrelate
+            } else if (subcmd == "ac") { // autocorrelate
                 throw "currently disabled, old code in old/src-fragm/opr-func-ac.cpp";
             }
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout), fiter.k() );
+        SMem::instance()->mem_store(move(fout), fiter.k());
     }
 }
diff --git a/pub/lib/opr.hpp b/pub/lib/opr.hpp
index f51aa9d2b142692f4cb5e1feb43d12bd20b75062..0b47d44f690328f5f1bac3425d3162c0046b122f 100644
--- a/pub/lib/opr.hpp
+++ b/pub/lib/opr.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                         
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  opr.hpp
@@ -10,11 +10,12 @@
 
 //! Functional operations.
 
-namespace NOperate {
-    void show( const string& subcmd );
-    void select( bool askdelete );
-    void Pointwise( string llabel );
-    void Integral();
-    void IntXY( string mode );
-    void Functional( const string& subcmd );
+namespace NOperate
+{
+void show(const string& subcmd);
+void select(bool askdelete);
+void Pointwise(string llabel);
+void Integral();
+void IntXY(string mode);
+void Functional(const string& subcmd);
 }
\ No newline at end of file
diff --git a/pub/lib/plot.cpp b/pub/lib/plot.cpp
index 04cb04c5de16e39ab80c589da16b9dc4386d9f6d..098bca7a635d9ecefd2d9d18d08cc4c4dc64f2e8 100644
--- a/pub/lib/plot.cpp
+++ b/pub/lib/plot.cpp
@@ -10,18 +10,18 @@
 #include "defs.hpp"
 
 
-#include "../trivia/vector_ops.hpp"
 #include "../plot/dualplot.hpp"
+#include "../trivia/vector_ops.hpp"
 
-#include "olf.hpp"
-#include "mem.hpp"
+#include "curve.hpp"
 #include "fsel.hpp"
+#include "jsel.hpp"
 #include "loop.hpp"
+#include "mem.hpp"
 #include "obj.hpp"
-#include "jsel.hpp"
-#include "slice.hpp"
+#include "olf.hpp"
 #include "plot.hpp"
-#include "curve.hpp"
+#include "slice.hpp"
 
 
 //**************************************************************************************************
@@ -31,76 +31,80 @@
 
 //! Loop over selected data files to determine x range.
 
-void determine_Xrange( CPlot* plot, vector<int>& JSel )
+void determine_Xrange(CPlot* plot, vector<int>& JSel)
 {
     double inf, sup;
     FileIterator fiter(SFSel::instance()->selD());
-    const vector<double> *vx;
+    const vector<double>* vx;
     bool first = true;
-    while( const COld *fd = fiter.nextD() ) {
+    while (const COld* fd = fiter.nextD()) {
         // JSel->evaluate( 0, fd->nJ()-1 );
-        for ( int iv=0; iv<JSel.size(); ++iv ) {
-            vx = &( fd->VS( JSel[iv] )->x );
-            for ( int i=0; i<vx->size(); ++i ){
-                if ( plot->X.logflag && (*vx)[i]<=0 )
+        for (int iv = 0; iv < JSel.size(); ++iv) {
+            vx = &(fd->VS(JSel[iv])->x);
+            for (int i = 0; i < vx->size(); ++i) {
+                if (plot->X.logflag && (*vx)[i] <= 0)
                     continue;
-                if ( first ){
+                if (first) {
                     inf = (*vx)[i];
                     sup = (*vx)[i];
                     first = false;
                 } else {
-                    if ( (*vx)[i]<inf ) inf = (*vx)[i];
-                    if ( (*vx)[i]>sup ) sup = (*vx)[i];
+                    if ((*vx)[i] < inf)
+                        inf = (*vx)[i];
+                    if ((*vx)[i] > sup)
+                        sup = (*vx)[i];
                 }
             }
         }
     }
-    if ( first )
+    if (first)
         throw S("x range is empty");
-    plot->X.set_rounded_limits( inf, sup );
+    plot->X.set_rounded_limits(inf, sup);
 }
 
 
 //! Loop over selected files to determine y range for current x range.
 
-void determine_Yrange( CPlot* plot, vector<int>& JSel )
+void determine_Yrange(CPlot* plot, vector<int>& JSel)
 {
-    double inf=INFINITY, sup=-INFINITY;
+    double inf = INFINITY, sup = -INFINITY;
     FileIterator fiter(SFSel::instance()->sel());
-    while( const COlo *f = fiter.next() ){
+    while (const COlo* f = fiter.next()) {
         int k = fiter.k();
-        const COlc *fc = dynamic_cast<const COlc*>( f );
-        if ( fc && fc->kconv!=-1 )
+        const COlc* fc = dynamic_cast<const COlc*>(f);
+        if (fc && fc->kconv != -1)
             continue;
-        const COld *fd = dynamic_cast<const COld*>( f );
+        const COld* fd = dynamic_cast<const COld*>(f);
         // JSel->evaluate( 0, f->nJ()-1 );
-        for ( int iv=0; iv<JSel.size(); ++iv ){
+        for (int iv = 0; iv < JSel.size(); ++iv) {
             int j = JSel[iv];
             CSpec* s;
-            if ( fd ){
+            if (fd) {
                 s = fd->VS(j);
             } else {
-                PSpec tmp( new CSpec );
+                PSpec tmp(new CSpec);
                 s = tmp.get();
-                plot->X.set_xgrid( s->x, 97 );
-                RObjVec cu = fc->eval_curve( s->x, k, j, false );
+                plot->X.set_xgrid(s->x, 97);
+                RObjVec cu = fc->eval_curve(s->x, k, j, false);
                 s->y.resize(s->x.size());
-                for( int i=0; i<s->size(); ++i )
+                for (int i = 0; i < s->size(); ++i)
                     s->y[i] = cu->to_r(i);
             }
-            for ( int i=0; i<s->size(); i++ ) {
-                if ( !plot->X.contains( s->x[i] ) )
+            for (int i = 0; i < s->size(); i++) {
+                if (!plot->X.contains(s->x[i]))
                     continue;
-                if ( plot->Y.logflag && s->y[i]<=0 )
+                if (plot->Y.logflag && s->y[i] <= 0)
                     continue;
-                if (s->y[i]<inf) inf=s->y[i];
-                if (s->y[i]>sup) sup=s->y[i];
+                if (s->y[i] < inf)
+                    inf = s->y[i];
+                if (s->y[i] > sup)
+                    sup = s->y[i];
             }
         }
     }
-    if ( inf==INFINITY || sup==-INFINITY )
+    if (inf == INFINITY || sup == -INFINITY)
         throw S("y range is empty");
-    plot->Y.set_rounded_limits( inf, sup );
+    plot->Y.set_rounded_limits(inf, sup);
 }
 
 
@@ -111,67 +115,66 @@ void determine_Yrange( CPlot* plot, vector<int>& JSel )
 
 //! Plot scan j of data file fd; return number of points plotted.
 
-int plot_data( CPlot* plot, const COld *fd, int k, int j, int pstyle )
+int plot_data(CPlot* plot, const COld* fd, int k, int j, int pstyle)
 {
-    const CSpec *s = fd->VS(j);
-    int n=s->x.size();
-    if ( n!=s->y.size() )
+    const CSpec* s = fd->VS(j);
+    int n = s->x.size();
+    if (n != s->y.size())
         throw S("BUG: plot: x.size<>y.size");
     // Filter: x,y -> xp,yp if inside frame
-    int np=0, nxl=0, nxh=0, nyl=0, nyh=0;
+    int np = 0, nxl = 0, nxh = 0, nyl = 0, nyh = 0;
     vector<double> xp, yp, dyp;
-    for ( int i=0; i<n; i++ ) {
+    for (int i = 0; i < n; i++) {
         double x = s->x[i];
-        if ( !plot->X.contains(x) ) {
-            if ( x<=plot->X.inf ){
+        if (!plot->X.contains(x)) {
+            if (x <= plot->X.inf) {
                 x = plot->X.inf;
                 nxl++;
             }
-            if ( x>=plot->X.sup ){
+            if (x >= plot->X.sup) {
                 x = plot->X.sup;
                 nxh++;
             }
-            if ( !plot->X.force )
+            if (!plot->X.force)
                 continue;
         }
         double y = s->y[i];
-        if ( !plot->Y.contains(y) ) {
-            if ( y<=plot->Y.inf ){
+        if (!plot->Y.contains(y)) {
+            if (y <= plot->Y.inf) {
                 y = plot->Y.inf;
                 nyl++;
             }
-            if ( y>=plot->Y.sup ){
+            if (y >= plot->Y.sup) {
                 y = plot->Y.sup;
                 nyh++;
             }
-            if ( !plot->Y.force )
+            if (!plot->Y.force)
                 continue;
         }
-        if ( np==plot->maxpoints && np<n )
+        if (np == plot->maxpoints && np < n)
             cout << "reached maxpoints at " << s->x[i] << "\n";
-        xp.push_back( x );
-        yp.push_back( y );
-        if ( s->has_dy() )
-            dyp.push_back( s->dy[i] );
+        xp.push_back(x);
+        yp.push_back(y);
+        if (s->has_dy())
+            dyp.push_back(s->dy[i]);
         np = xp.size();
-        if ( np > plot->maxpoints ) // continue in large steps
+        if (np > plot->maxpoints) // continue in large steps
             i += plot->maxpoints;
     }
-    if ( np==0 ) {
-        cout << "file " << k << " spec " << j << " all " << n <<
-            " points outside plot range:\n";
-        if ( nxl )
+    if (np == 0) {
+        cout << "file " << k << " spec " << j << " all " << n << " points outside plot range:\n";
+        if (nxl)
             cout << "  " << nxl << " points < xmin\n";
-        if ( nxh )
+        if (nxh)
             cout << "  " << nxh << " points > xmax\n";
-        if ( nyl )
+        if (nyl)
             cout << "  " << nyl << " points < ymin\n";
-        if ( nyh )
+        if (nyh)
             cout << "  " << nyh << " points > ymax\n";
     } else {
-        plot->add_spec( false, true, pstyle, xp, yp, dyp, fd->V[j]->z_str(),
-                       fd->xco.str_std(), fd->yco.str_std(),
-                       "data file " + S(k) + " spectrum "+S(j) );
+        plot->add_spec(
+            false, true, pstyle, xp, yp, dyp, fd->V[j]->z_str(), fd->xco.str_std(),
+            fd->yco.str_std(), "data file " + S(k) + " spectrum " + S(j));
     }
     return np;
 }
@@ -179,92 +182,92 @@ int plot_data( CPlot* plot, const COld *fd, int k, int j, int pstyle )
 
 //! Plot scan j of convolved curve file fc; return number of points plotted.
 
-int plot_curve_convolved( CPlot* plot, const COlc *fc, int k, int j, int cstyle )
+int plot_curve_convolved(CPlot* plot, const COlc* fc, int k, int j, int cstyle)
 {
     vector<double> novec;
     int kconv, jconv;
-    const CSpec *sconv;
-    NCurveFile::get_conv( &sconv, &kconv, &jconv, k, j );
+    const CSpec* sconv;
+    NCurveFile::get_conv(&sconv, &kconv, &jconv, k, j);
     vector<double> xp;
-    for ( int i=0; i<sconv->size(); ++i ){
+    for (int i = 0; i < sconv->size(); ++i) {
         double x = sconv->x[i];
-        if ( plot->X.contains( x ) )
-            xp.push_back( x );
+        if (plot->X.contains(x))
+            xp.push_back(x);
     }
-    RObjVec cu = fc->eval_curve( xp, k, j, false );
+    RObjVec cu = fc->eval_curve(xp, k, j, false);
     vector<double> xo, yo;
-    for ( int i=0; i<xp.size(); ++i ){
+    for (int i = 0; i < xp.size(); ++i) {
         double yp = cu->to_r(i);
-        if ( !( plot->X.contains( xp[i] ) &&
-                plot->Y.contains( yp )   ) )
+        if (!(plot->X.contains(xp[i]) && plot->Y.contains(yp)))
             continue;
-        xo.push_back( xp[i] );
-        yo.push_back( yp );
+        xo.push_back(xp[i]);
+        yo.push_back(yp);
     }
-    if ( xo.size()==0 ){
-        cout << "curve k="<<S(k)<<", j="<<S(j)<< " has no points in plot window\n";
+    if (xo.size() == 0) {
+        cout << "curve k=" << S(k) << ", j=" << S(j) << " has no points in plot window\n";
     }
-    plot->add_spec( true, true, cstyle, xo, yo, novec, fc->V[j]->z_str(),
-                   fc->xco.str_std(), fc->yco.str_std(),
-                   "curve file "+S(k)+" spectrum "+S(j) );
+    plot->add_spec(
+        true, true, cstyle, xo, yo, novec, fc->V[j]->z_str(), fc->xco.str_std(), fc->yco.str_std(),
+        "curve file " + S(k) + " spectrum " + S(j));
     return xo.size();
 }
 
 //! Plot scan j of curve file fc, using grid from file kd.
 
-int plot_curve_to_grid( CPlot* plot, const COlc *fc, int k, int j, int cstyle )
+int plot_curve_to_grid(CPlot* plot, const COlc* fc, int k, int j, int cstyle)
 {
-    if( fc->kd==-1 )
+    if (fc->kd == -1)
         throw S("data reference not set, incompatible with cg+");
-    const COld *fd = SMem::instance()->mem_get_D(fc->kd);
-    if( !fd )
+    const COld* fd = SMem::instance()->mem_get_D(fc->kd);
+    if (!fd)
         throw S("data reference not found");
-    if( j>=fd->nJ() )
+    if (j >= fd->nJ())
         throw S("number of spectra does not match");
-    vector<double> *xc = &(fd->VS(j)->x);
+    vector<double>* xc = &(fd->VS(j)->x);
     vector<double> novec, xp, yp;
-    RObjVec cu = fc->eval_curve( *xc, k, j, false );
-    for ( int i=0; i<xc->size(); ++i ) {
+    RObjVec cu = fc->eval_curve(*xc, k, j, false);
+    for (int i = 0; i < xc->size(); ++i) {
         double yc = cu->to_r(i);
-        if ( plot->X.contains((*xc)[i]) && plot->Y.contains(yc) ) {
-            xp.push_back( (*xc)[i] );
-            yp.push_back( yc );
+        if (plot->X.contains((*xc)[i]) && plot->Y.contains(yc)) {
+            xp.push_back((*xc)[i]);
+            yp.push_back(yc);
         }
     }
-    plot->add_spec( true, true, cstyle, xp, yp, novec, fc->V[j]->z_str(),
-                   fc->xco.str_std(), fc->yco.str_std(),
-                   "curve file "+S(k)+" spectrum "+S(j) );
+    plot->add_spec(
+        true, true, cstyle, xp, yp, novec, fc->V[j]->z_str(), fc->xco.str_std(), fc->yco.str_std(),
+        "curve file " + S(k) + " spectrum " + S(j));
     return xp.size();
 }
 
 
 //! Plot scan j of non-convolved curve file fc on equidistant grid; return number of points plotted.
 
-int plot_curve_equidist( CPlot* plot, const COlc *fc, int k, int j, int cstyle )
+int plot_curve_equidist(CPlot* plot, const COlc* fc, int k, int j, int cstyle)
 {
     vector<double> novec;
     // equidistant grid
 
     int npts = plot->equipoints;
     vector<double> xc, xp, yp;
-    plot->X.set_xgrid( xc, npts );
-    RObjVec cu = fc->eval_curve( xc, k, j, false );
-    for ( int i=0; i<npts; ++i ) {
+    plot->X.set_xgrid(xc, npts);
+    RObjVec cu = fc->eval_curve(xc, k, j, false);
+    for (int i = 0; i < npts; ++i) {
         double yc = cu->to_r(i);
-        if ( plot->X.contains(xc[i]) && plot->Y.contains(yc) ) {
-            xp.push_back( xc[i] );
-            yp.push_back( yc );
+        if (plot->X.contains(xc[i]) && plot->Y.contains(yc)) {
+            xp.push_back(xc[i]);
+            yp.push_back(yc);
         }
     }
-    plot->add_spec( true, true, cstyle, xp, yp, novec, fc->V[j]->z_str(),
-                   fc->xco.str_std(), fc->yco.str_std(),
-                   "curve file "+S(k)+" spectrum "+S(j) );
+    plot->add_spec(
+        true, true, cstyle, xp, yp, novec, fc->V[j]->z_str(), fc->xco.str_std(), fc->yco.str_std(),
+        "curve file " + S(k) + " spectrum " + S(j));
     return xp.size();
 }
 
-//! Plots scan j of non-convolved curve file fc, refining the grid where necessary; return number of points plotted.
+//! Plots scan j of non-convolved curve file fc, refining the grid where necessary; return number of
+//! points plotted.
 
-int plot_curve_refine( CPlot* plot, const COlc *fc, int k, int j, int cstyle )
+int plot_curve_refine(CPlot* plot, const COlc* fc, int k, int j, int cstyle)
 {
     // refinement cares to:
     // - stop/start line when leaving/reentering/crossing(TODO) the frame
@@ -276,66 +279,68 @@ int plot_curve_refine( CPlot* plot, const COlc *fc, int k, int j, int cstyle )
 
     // start with equidistant grid:
     int npts = plot->equipoints;
-    plot->X.set_xgrid( xc, npts );
+    plot->X.set_xgrid(xc, npts);
 
     // refinement loop:
-    for ( int iref=0; ; ++iref ) {
-        if ( !xc.size() ){
-            if ( !iref )
+    for (int iref = 0;; ++iref) {
+        if (!xc.size()) {
+            if (!iref)
                 throw S("BUG: plot_curve_refine called with xc.size()=0");
             break; // regular exit
         }
         // evaluate curve for grid xc:
-        RObjVecDbl cu = PCAST<const CObjVecDbl>( fc->eval_curve( xc, k, j, false ) );
-        for ( int i=0; i<xc.size(); ++i )
+        RObjVecDbl cu = PCAST<const CObjVecDbl>(fc->eval_curve(xc, k, j, false));
+        for (int i = 0; i < xc.size(); ++i)
             yc = cu->v;
 
         // merge xc,yc and xn,yn:
-        if ( iref==0 ) {
-            xn = xc; yn = yc;
+        if (iref == 0) {
+            xn = xc;
+            yn = yc;
         } else {
             vector<double> xa, ya;
-            int ic=0, in=0;
-            for ( ; ic<xc.size() && in<xn.size(); ) {
-                if ( plot->X.close_enough( xc[ic], xn[ic], 1e-7 ) ){
+            int ic = 0, in = 0;
+            for (; ic < xc.size() && in < xn.size();) {
+                if (plot->X.close_enough(xc[ic], xn[ic], 1e-7)) {
                     ++in; // skip new point
-                } else if ( xc[ic]<xn[in] ) {
-                    xa.push_back( xc[ic] );
-                    ya.push_back( yc[ic] );
+                } else if (xc[ic] < xn[in]) {
+                    xa.push_back(xc[ic]);
+                    ya.push_back(yc[ic]);
                     ++ic;
                 } else {
-                    xa.push_back( xn[in] );
-                    ya.push_back( yn[in] );
+                    xa.push_back(xn[in]);
+                    ya.push_back(yn[in]);
                     ++in;
                 }
             }
-            for ( ; ic<xc.size(); ++ic ) {
-                xa.push_back( xc[ic] );
-                ya.push_back( yc[ic] );
+            for (; ic < xc.size(); ++ic) {
+                xa.push_back(xc[ic]);
+                ya.push_back(yc[ic]);
             }
-            for ( ; in<xn.size(); ++in ) {
-                xa.push_back( xn[in] );
-                ya.push_back( yn[in] );
+            for (; in < xn.size(); ++in) {
+                xa.push_back(xn[in]);
+                ya.push_back(yn[in]);
             }
-            xn = xa; yn = ya;
+            xn = xa;
+            yn = ya;
         }
-        if ( iref>=10 || xn.size()>=plot->maxpoints )
+        if (iref >= 10 || xn.size() >= plot->maxpoints)
             break; // alternate exit: too many refinements or too many points
 
         // eliminate points outside y range (except border points):
         vector<double> xa, ya;
-        xa.push_back( xn[0] );
-        ya.push_back( yn[0] );
-        for ( int i=1; i<xn.size()-1; ++i) {
+        xa.push_back(xn[0]);
+        ya.push_back(yn[0]);
+        for (int i = 1; i < xn.size() - 1; ++i) {
         new_segment:
-            xa.push_back( xn[i] );
-            ya.push_back( yn[i] );
-            if ( !plot->Y.contains(yn[i]) ) {
-                for ( int ii=i+1; ii<xn.size()-1; ++ii ) {
-                    if ( plot->Y.contains(yn[ii]) ) {
-                        if ( ii-1>i ) {
-                            xa.push_back( xn[ii-1] );
-                            ya.push_back( yn[ii-1] );
+            xa.push_back(xn[i]);
+            ya.push_back(yn[i]);
+            if (!plot->Y.contains(yn[i])) {
+                for (int ii = i + 1; ii < xn.size() - 1; ++ii) {
+                    if (plot->Y.contains(yn[ii])) {
+                        if (ii - 1 > i) {
+                            xa.push_back(xn[ii - 1]);
+                            ya.push_back(yn[ii - 1]);
                         }
                         i = ii;
                         goto new_segment;
@@ -343,58 +348,58 @@ int plot_curve_refine( CPlot* plot, const COlc *fc, int k, int j, int cstyle )
                 }
             }
         }
-        xa.push_back( xn.back() );
-        ya.push_back( yn.back() );
-        xn = xa; yn = ya;
+        xa.push_back(xn.back());
+        ya.push_back(yn.back());
+        xn = xa;
+        yn = ya;
 
         // set additional base points:
         bool insert_next = false;
         xc.clear();
-        for ( int i=1; i<xn.size()-1; ++i ) {
-            if ( i<xn.size()-2 ) {
-                double yi = ( (xn[i+1]-xn[i])*yn[i-1] +
-                              (xn[i]-xn[i-1])*yn[i+1] ) /
-                    (xn[i+1]-xn[i-1]);
-                if ( !plot->Y.close_enough( yn[i], yi, 0.005 ) ) {
-                    xc.push_back( (xn[i-1] + xn[i])/2 );
+        for (int i = 1; i < xn.size() - 1; ++i) {
+            if (i < xn.size() - 2) {
+                double yi = ((xn[i + 1] - xn[i]) * yn[i - 1] + (xn[i] - xn[i - 1]) * yn[i + 1])
+                    / (xn[i + 1] - xn[i - 1]);
+                if (!plot->Y.close_enough(yn[i], yi, 0.005)) {
+                    xc.push_back((xn[i - 1] + xn[i]) / 2);
                     insert_next = true;
                     continue;
                 }
             }
-            if ( insert_next ) {
-                xc.push_back( (xn[i-1] + xn[i])/2 );
+            if (insert_next) {
+                xc.push_back((xn[i - 1] + xn[i]) / 2);
                 insert_next = false;
                 continue;
             }
-            if ( ( plot->Y.contains(yn[i]) && !plot->Y.contains(yn[i-1]) ) ||
-                 ( !plot->Y.contains(yn[i]) && plot->Y.contains(yn[i-1]) ) ) {
-                xc.push_back( (xn[i-1] + xn[i])/2 );
+            if ((plot->Y.contains(yn[i]) && !plot->Y.contains(yn[i - 1]))
+                || (!plot->Y.contains(yn[i]) && plot->Y.contains(yn[i - 1]))) {
+                xc.push_back((xn[i - 1] + xn[i]) / 2);
                 continue;
             }
         }
         // temporary check
-        if( xc.size() )
-            for ( int i=0; i<xc.size()-1; ++i )
-                if ( xc[i+1]<=xc[i] )
-                    throw "BUG: new base points not sorted at "+S(i)+": "+S(xc[i])+" "+S(xc[i+1]);
+        if (xc.size())
+            for (int i = 0; i < xc.size() - 1; ++i)
+                if (xc[i + 1] <= xc[i])
+                    throw "BUG: new base points not sorted at " + S(i) + ": " + S(xc[i]) + " "
+                        + S(xc[i + 1]);
     }
 
     // divide into segments and plot:
     vector<double> xa, ya;
     bool first_seg = true;
     npts = 0;
-    for ( int i=0; i<xn.size(); ++i ) {
-        if ( plot->Y.contains(yn[i]) ) {
-            xa.push_back( xn[i] );
-            ya.push_back( yn[i] );
+    for (int i = 0; i < xn.size(); ++i) {
+        if (plot->Y.contains(yn[i])) {
+            xa.push_back(xn[i]);
+            ya.push_back(yn[i]);
         }
-        if ( !plot->Y.contains(yn[i]) || i==xn.size()-1 ) {
+        if (!plot->Y.contains(yn[i]) || i == xn.size() - 1) {
             npts += xa.size();
-            if ( xa.size() ){
+            if (xa.size()) {
                 plot->add_spec(
-                    true, first_seg, cstyle, xa, ya, novec, fc->V[j]->z_str(),
-                    fc->xco.str_std(), fc->yco.str_std(),
-                    "curve file "+S(k)+ " spectrum "+S(j) );
+                    true, first_seg, cstyle, xa, ya, novec, fc->V[j]->z_str(), fc->xco.str_std(),
+                    fc->yco.str_std(), "curve file " + S(k) + " spectrum " + S(j));
                 xa.clear();
                 ya.clear();
                 first_seg = false;
@@ -411,36 +416,36 @@ int plot_curve_refine( CPlot* plot, const COlc *fc, int k, int j, int cstyle )
 
 //! Plot set of spectra, or add to open plot.
 
-void NPlot::plot( class CPlot *plot, bool add, const string& mode )
+void NPlot::plot(class CPlot* plot, bool add, const string& mode)
 {
     FileIterator fiter(SFSel::instance()->sel());
 
     static vector<int> JSel;
-    static int pstyle=1, cstyle=1;
+    static int pstyle = 1, cstyle = 1;
     static string jSel = "";
 
 
-    if        ( mode=="ask" ) {
-        JSelAsk( "Plot which spectra", JSel );
+    if (mode == "ask") {
+        JSelAsk("Plot which spectra", JSel);
     } else {
-        if ( mode == "next" ) {
-            triv::increment_indices( JSel, +1, SFSel::instance()->nJ_max() );
-        } else if ( mode == "prev" ) {
-            triv::increment_indices( JSel, -1, SFSel::instance()->nJ_max() );
+        if (mode == "next") {
+            triv::increment_indices(JSel, +1, SFSel::instance()->nJ_max());
+        } else if (mode == "prev") {
+            triv::increment_indices(JSel, -1, SFSel::instance()->nJ_max());
         } else
             throw "unexpected mode " + mode;
-        if( !JSel.size() )
+        if (!JSel.size())
             throw S("no spectra in range");
         cout << "plotting spectra " << triv::indices_to_s(JSel) << "\n";
     }
 
-    if ( !add ) { // prepare frame (ranges, labels)
+    if (!add) { // prepare frame (ranges, labels)
         pstyle = 1;
         cstyle = 1;
         if (!plot->X.finite())
-            determine_Xrange( plot, JSel );
+            determine_Xrange(plot, JSel);
         if (!plot->Y.finite())
-            determine_Yrange( plot, JSel );
+            determine_Yrange(plot, JSel);
 
         // build label: (zur Zeit nur vom ersten File; definiere +=)
         CCoord xCo = SFSel::instance()->sel_first()->xco;
@@ -448,53 +453,53 @@ void NPlot::plot( class CPlot *plot, bool add, const string& mode )
 
         // draw new frame:
         plot->clear_frame();
-        plot->plot_frame( xCo.str_ps(), yCo.str_ps() );
+        plot->plot_frame(xCo.str_ps(), yCo.str_ps());
     }
 
     // plot:
-    while( const COlo *f = fiter.next() ){
+    while (const COlo* f = fiter.next()) {
         int k = fiter.k();
-        const COld *fd = dynamic_cast<const COld*>( f );
-        const COlc *fc = dynamic_cast<const COlc*>( f );
-
-        plot->doc_TxLine( f->name );
-        for (int i=0; i<f->lDoc.size(); i++)
-            plot->doc_TxLine( "  " + f->lDoc[i] );
-        if ( fc ) {
-            for ( string line: fc->info_settings() )
-                plot->doc_TxLine( "  " + line );
-            plot->doc_TxLine( "  " + fc->info_table_header() );
+        const COld* fd = dynamic_cast<const COld*>(f);
+        const COlc* fc = dynamic_cast<const COlc*>(f);
+
+        plot->doc_TxLine(f->name);
+        for (int i = 0; i < f->lDoc.size(); i++)
+            plot->doc_TxLine("  " + f->lDoc[i]);
+        if (fc) {
+            for (string line : fc->info_settings())
+                plot->doc_TxLine("  " + line);
+            plot->doc_TxLine("  " + fc->info_table_header());
         }
 
         // JSel.evaluate( 0, f->nJ()-1 );
-        for ( int iv=0; iv<JSel.size(); ++iv){
+        for (int iv = 0; iv < JSel.size(); ++iv) {
             int j = JSel[iv];
 
-            if        ( fd ) {
-                if ( !plot_data( plot, fd, k, j, pstyle ) )
+            if (fd) {
+                if (!plot_data(plot, fd, k, j, pstyle))
                     continue;
-            } else if ( fc ) {
-                if        ( fc->kconv!=-1 ) {
-                    if ( !plot_curve_convolved( plot, fc, k, j, cstyle ) )
+            } else if (fc) {
+                if (fc->kconv != -1) {
+                    if (!plot_curve_convolved(plot, fc, k, j, cstyle))
                         continue;
-                } else if ( fc->plot_to_grid ) {
-                    if ( !plot_curve_to_grid( plot, fc, k, j, cstyle ) )
+                } else if (fc->plot_to_grid) {
+                    if (!plot_curve_to_grid(plot, fc, k, j, cstyle))
                         continue;
-                } else if ( !plot->refine ) {
-                    if ( !plot_curve_equidist( plot, fc, k, j, cstyle ) )
+                } else if (!plot->refine) {
+                    if (!plot_curve_equidist(plot, fc, k, j, cstyle))
                         continue;
                 } else {
-                    if ( !plot_curve_refine( plot, fc, k, j, cstyle ) )
+                    if (!plot_curve_refine(plot, fc, k, j, cstyle))
                         continue;
                 }
             } else
                 throw S("PROGRAM ERROR plot: unexpected file type");
 
-            if        ( fd ) {
-                plot->doc_PtTxLine( "  " + f->info_line( j ), pstyle );
+            if (fd) {
+                plot->doc_PtTxLine("  " + f->info_line(j), pstyle);
                 ++pstyle;
-            } else if ( fc ) {
-                plot->doc_CvTxLine( "  " + f->info_line( j ), cstyle );
+            } else if (fc) {
+                plot->doc_CvTxLine("  " + f->info_line(j), cstyle);
                 ++cstyle;
             }
         }
diff --git a/pub/lib/plot.hpp b/pub/lib/plot.hpp
index 5a45ac2ae4957d9829c0993aceee0af8c426362d..5ff09a88f3dcbafaa26ff337e542e857e304a693 100644
--- a/pub/lib/plot.hpp
+++ b/pub/lib/plot.hpp
@@ -10,6 +10,7 @@
 
 //! Plot data and curves.
 
-namespace NPlot {
-    void plot( class CPlot *plot, bool add, const string& mode="ask" );
+namespace NPlot
+{
+void plot(class CPlot* plot, bool add, const string& mode = "ask");
 }
\ No newline at end of file
diff --git a/pub/lib/ptr.hpp b/pub/lib/ptr.hpp
index 0be917c61647d1d76d9cd18fb0c46ee4825c2427..7dbbd262d876194f3b408f15b1e45d975772af1a 100644
--- a/pub/lib/ptr.hpp
+++ b/pub/lib/ptr.hpp
@@ -11,31 +11,31 @@
 
 #define PCAST std::dynamic_pointer_cast
 
-#define DEF_PTR( C, P, R )                     \
-    using P = std::shared_ptr<      class C>;  \
+#define DEF_PTR(C, P, R)                                                                           \
+    using P = std::shared_ptr<class C>;                                                            \
     using R = std::shared_ptr<const class C>
 
-DEF_PTR( CObj,       PObj,       RObj );
-DEF_PTR( CObjNum,    PObjNum,    RObjNum );
-DEF_PTR( CObjInt,    PObjInt,    RObjInt );
-DEF_PTR( CObjDbl,    PObjDbl,    RObjDbl );
-DEF_PTR( CObjEnu,    PObjEnu,    RObjEnu );
-DEF_PTR( CObjStr,    PObjStr,    RObjStr );
-DEF_PTR( CObjVec,    PObjVec,    RObjVec );
-DEF_PTR( CObjVecObj, PObjVecObj, RObjVecObj );
-DEF_PTR( CObjVecNum, PObjVecNum, RObjVecNum );
-DEF_PTR( CObjVecInt, PObjVecInt, RObjVecInt );
-DEF_PTR( CObjVecDbl, PObjVecDbl, RObjVecDbl );
-DEF_PTR( CObjVecEnu, PObjVecEnu, RObjVecEnu );
+DEF_PTR(CObj, PObj, RObj);
+DEF_PTR(CObjNum, PObjNum, RObjNum);
+DEF_PTR(CObjInt, PObjInt, RObjInt);
+DEF_PTR(CObjDbl, PObjDbl, RObjDbl);
+DEF_PTR(CObjEnu, PObjEnu, RObjEnu);
+DEF_PTR(CObjStr, PObjStr, RObjStr);
+DEF_PTR(CObjVec, PObjVec, RObjVec);
+DEF_PTR(CObjVecObj, PObjVecObj, RObjVecObj);
+DEF_PTR(CObjVecNum, PObjVecNum, RObjVecNum);
+DEF_PTR(CObjVecInt, PObjVecInt, RObjVecInt);
+DEF_PTR(CObjVecDbl, PObjVecDbl, RObjVecDbl);
+DEF_PTR(CObjVecEnu, PObjVecEnu, RObjVecEnu);
 
 #undef DEF_PTR
 
-using POlo   = std::unique_ptr<class COlo>;
-using POld   = std::unique_ptr<class COld>;
-using POlc   = std::unique_ptr<class COlc>;
+using POlo = std::unique_ptr<class COlo>;
+using POld = std::unique_ptr<class COld>;
+using POlc = std::unique_ptr<class COlc>;
 using PSlice = std::unique_ptr<class CSlice>;
-using PSpec  = std::unique_ptr<class CSpec>;
+using PSpec = std::unique_ptr<class CSpec>;
 using PCurve = std::unique_ptr<class CCurve>;
 
-using RNode  = std::shared_ptr<const class CNode>;
-using RRef   = std::shared_ptr<const class CRef1>;
+using RNode = std::shared_ptr<const class CNode>;
+using RRef = std::shared_ptr<const class CRef1>;
diff --git a/pub/lib/reduce_curv.cpp b/pub/lib/reduce_curv.cpp
index 2b38ed0b068d149b32e52fd93c3a115fa75f7387..69fb19b9dad764d608d2bbb8cdcbf288257cbfcc 100644
--- a/pub/lib/reduce_curv.cpp
+++ b/pub/lib/reduce_curv.cpp
@@ -11,12 +11,12 @@
 
 #include <boost/format.hpp>
 
-#include "../trivia/string_ops.hpp"
-#include "../trivia/integrate.hpp"
 #include "../readplus/ask.hpp"
+#include "../trivia/integrate.hpp"
+#include "../trivia/string_ops.hpp"
 
-#include "olf.hpp"
 #include "obj.hpp"
+#include "olf.hpp"
 #include "reduce_curv.hpp"
 #include "xax_lex.hpp"
 
@@ -27,38 +27,40 @@ using boost::format;
 //**************************************************************************************************
 
 
-namespace NCvin {
-    // Tuning parameters:
-    int numint_mode=4;
-    double numint_epsabs=1e-10;
-    double numint_epsrel=1e-10;
-    // Auxiliary functions:
-    double NumericIntegral( const COlc *fc, int k, int j, double low, double hig );
+namespace NCvin
+{
+// Tuning parameters:
+int numint_mode = 4;
+double numint_epsabs = 1e-10;
+double numint_epsrel = 1e-10;
+// Auxiliary functions:
+double NumericIntegral(const COlc* fc, int k, int j, double low, double hig);
 }
 
 
 //! Set auxiliary parameters for integration. Directly called from main program.
 
-void NCvin::set_integration_tuning_pars( string which )
+void NCvin::set_integration_tuning_pars(string which)
 {
-    if      ( which=="?" )
-        printf( "Numeric integration setup:\n"
-                "  [cna] epsabs=%g\n"
-                "  [cnr] epsrel=%g\n"
-                "  [cnm] external integration mode: %i\n",
-                numint_epsabs, numint_epsrel, numint_mode );
-    else if ( which=="a" )
-        numint_epsabs = dask( "Espilon abs", numint_epsabs );
-    else if ( which=="r" )
-        numint_epsrel = dask( "Epsilon rel", numint_epsrel );
-    else if ( which=="m" ){
+    if (which == "?")
+        printf(
+            "Numeric integration setup:\n"
+            "  [cna] epsabs=%g\n"
+            "  [cnr] epsrel=%g\n"
+            "  [cnm] external integration mode: %i\n",
+            numint_epsabs, numint_epsrel, numint_mode);
+    else if (which == "a")
+        numint_epsabs = dask("Espilon abs", numint_epsabs);
+    else if (which == "r")
+        numint_epsrel = dask("Epsilon rel", numint_epsrel);
+    else if (which == "m") {
         cout << "Numeric integration modes (ignored for infinite intervals):\n"
-            "   0: non-adaptive Gauss-Kronod-87 for very smooth functions\n"
-            "   1: adaptive Gauss-Kronod-61 for smooth functions\n"
-            "   ...\n"
-            "   6: adaptive Gauss-Kronod-15 for not so smooth functions\n"
-            "   7: adaptive for functions with singularities\n";
-        numint_mode = iask( "Option", numint_mode );
+                "   0: non-adaptive Gauss-Kronod-87 for very smooth functions\n"
+                "   1: adaptive Gauss-Kronod-61 for smooth functions\n"
+                "   ...\n"
+                "   6: adaptive Gauss-Kronod-15 for not so smooth functions\n"
+                "   7: adaptive for functions with singularities\n";
+        numint_mode = iask("Option", numint_mode);
     } else {
         throw S("unexpected mode");
     }
@@ -73,7 +75,7 @@ void NCvin::set_integration_tuning_pars( string which )
 //! Data transfer between frida and gsl_function.
 
 typedef struct {
-    const COlc *fc;
+    const COlc* fc;
     int k;
     int j;
 } EvalDatTyp;
@@ -81,16 +83,16 @@ typedef struct {
 
 //! Generic callback routine for tree evaluation by gsl_function.
 
-double myeval( double x, void* data )
+double myeval(double x, void* data)
 {
-    EvalDatTyp *mydata = (EvalDatTyp*) data;
-    return mydata->fc->eval_curve_scalar( x, mydata->k, mydata->j, false )->to_r();
+    EvalDatTyp* mydata = (EvalDatTyp*)data;
+    return mydata->fc->eval_curve_scalar(x, mydata->k, mydata->j, false)->to_r();
 }
 
 
 //! Numeric integration of one curve.
 
-void cvin_integrate( double *r, double *dr, const COlc *fc, int k, int j, const vector<double>& args )
+void cvin_integrate(double* r, double* dr, const COlc* fc, int k, int j, const vector<double>& args)
 {
     EvalDatTyp data;
     data.fc = fc;
@@ -98,11 +100,9 @@ void cvin_integrate( double *r, double *dr, const COlc *fc, int k, int j, const
     data.j = j;
 
     *r = triv::integrate(
-        &myeval, &data, args[0], args[1],
-        NCvin::numint_mode,
-        NCvin::numint_epsabs,
-        NCvin::numint_epsrel );
-    if ( dr )
+        &myeval, &data, args[0], args[1], NCvin::numint_mode, NCvin::numint_epsabs,
+        NCvin::numint_epsrel);
+    if (dr)
         *dr = 0;
 }
 
@@ -112,27 +112,25 @@ void cvin_integrate( double *r, double *dr, const COlc *fc, int k, int j, const
 //**************************************************************************************************
 
 
-namespace NCvin { // internals:
-    map<string,const CCvin*> hmap; // unsorted hash, for expression evaluation
-    vector<const CCvin*> hlist;    // sorted array, for help text
+namespace NCvin
+{ // internals:
+map<string, const CCvin*> hmap; // unsorted hash, for expression evaluation
+vector<const CCvin*> hlist; // sorted array, for help text
 }
 
 
-CCvin::CCvin( string _name, int _narg, string _def, cvin_eval _eval, string _com )
+CCvin::CCvin(string _name, int _narg, string _def, cvin_eval _eval, string _com)
     : name(_name), narg(_narg), eval(_eval), com(_com)
 {
-    vector<string> def_expr = triv::split( _def, "," );
-    if ( def_expr.size()!=narg )
-        throw "BUG: invalid default "+_def+" for CCvin "+name;
+    vector<string> def_expr = triv::split(_def, ",");
+    if (def_expr.size() != narg)
+        throw "BUG: invalid default " + _def + " for CCvin " + name;
     def_arg.resize(narg);
-    for ( int iarg=0; iarg<narg; ++iarg )
-        def_arg[iarg] = user_xaxparse( def_expr[iarg].c_str() );
+    for (int iarg = 0; iarg < narg; ++iarg)
+        def_arg[iarg] = user_xaxparse(def_expr[iarg].c_str());
 }
 
-void CCvin::register_me() const
-{
-    SCvinRegistry::instance()->push_back( name, this );
-}
+void CCvin::register_me() const { SCvinRegistry::instance()->push_back(name, this); }
 
 void SCvinRegistry::display_entries() const
 {
@@ -141,17 +139,18 @@ void SCvinRegistry::display_entries() const
     cout << "  - most typically in command 'oi'\n";
     cout << "  - also directly at the command prompt (pocket-calculator mode, only for nj=1)\n";
     cout << "Implemented functionals:\n";
-    for( auto g: FList ) {
+    for (auto g : FList) {
         string s1 = g->name + "(a";
-        if( g->narg>1 )
+        if (g->narg > 1)
             s1 += ",b";
         s1 += ")";
-        cout << "  " << str( format("%-14s") % s1 ) << g->com << "\n";
+        cout << "  " << str(format("%-14s") % s1) << g->com << "\n";
     }
 }
 
 void SCvinRegistry::initialize()
 {
-    (new CCvin( "integrate", 2, "-inf,inf", cvin_integrate,
-                "numerical integration of curve from a to b" ))->register_me();
+    (new CCvin(
+         "integrate", 2, "-inf,inf", cvin_integrate, "numerical integration of curve from a to b"))
+        ->register_me();
 }
diff --git a/pub/lib/reduce_curv.hpp b/pub/lib/reduce_curv.hpp
index f5d4fc973febfa0cb10be87333f490968ee61e98..5233bc26fc742e26298d2b1deb798f5e83ab9256 100644
--- a/pub/lib/reduce_curv.hpp
+++ b/pub/lib/reduce_curv.hpp
@@ -11,38 +11,41 @@
 
 //!  Function type: Evaluate curve functional
 
-typedef void (*cvin_eval) (
-    double *r, double *dr, const COlc *fc, int k, int j, const vector<double>& args );
+typedef void (*cvin_eval)(
+    double* r, double* dr, const COlc* fc, int k, int j, const vector<double>& args);
 
 
 //! A wrapper holding a functional.
 
-class CCvin {
- public:
+class CCvin
+{
+public:
     string name;
     int narg;
     cvin_eval eval;
     string com;
     vector<RNode> def_arg;
-    class CCoord coord( class CCoord *co ) const;
-    class CCoord coord( class CCoord *co1, class CCoord *co2 ) const;
-    CCvin( string _name, int _narg, string _def, cvin_eval _eval, string _com="" );
+    class CCoord coord(class CCoord* co) const;
+    class CCoord coord(class CCoord* co1, class CCoord* co2) const;
+    CCvin(string _name, int _narg, string _def, cvin_eval _eval, string _com = "");
     void register_me() const;
 };
 
 
 //! Collection of function wrappers CFunc
 
-namespace NCvin { // public (short) interface
-    void set_integration_tuning_pars( string which );
+namespace NCvin
+{ // public (short) interface
+void set_integration_tuning_pars(string which);
 }
 
 //! A singleton class that holds a collection of curve functionals CCvin.
 
-class SCvinRegistry : public IRegistry<CCvin>, public triv::ISingleton<SCvinRegistry> {
- private:
+class SCvinRegistry : public IRegistry<CCvin>, public triv::ISingleton<SCvinRegistry>
+{
+private:
     virtual string type_name() const { return "curve functionals"; }
- public:
+public:
     void display_entries() const;
     static void initialize();
 };
diff --git a/pub/lib/reduce_spec.cpp b/pub/lib/reduce_spec.cpp
index 168787bbf99b1119b7e17d069117fea7842d9b9d..aa43360860855fccad2f20cb7ca44c2793bde774 100644
--- a/pub/lib/reduce_spec.cpp
+++ b/pub/lib/reduce_spec.cpp
@@ -14,8 +14,8 @@
 #include "../trivia/string_ops.hpp"
 
 #include "coord.hpp"
-#include "ptr.hpp"
 #include "obj.hpp"
+#include "ptr.hpp"
 #include "reduce_spec.hpp"
 
 using boost::format;
@@ -26,219 +26,219 @@ using boost::format;
 
 //! Compute minimum value of a vector.
 
-void geni_valmin( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_valmin(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     int idx = 0;
     *r = a[0]->to_r(0);
-    for ( int i=1; i<n; ++i ) {
-        if ( a[0]->to_r(i)<*r ) {
+    for (int i = 1; i < n; ++i) {
+        if (a[0]->to_r(i) < *r) {
             *r = a[0]->to_r(i);
             idx = i;
         }
     }
-    if( dr )
+    if (dr)
         *dr = a[0]->to_dr(idx);
 }
 
 //! Compute maximum value of a vector.
 
-void geni_valmax( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_valmax(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     int idx = 0;
     *r = a[0]->to_r(0);
-    for ( int i=1; i<n; ++i ) {
-        if ( a[0]->to_r(i)>*r ) {
+    for (int i = 1; i < n; ++i) {
+        if (a[0]->to_r(i) > *r) {
             *r = a[0]->to_r(i);
             idx = i;
         }
     }
-    if( dr )
+    if (dr)
         *dr = a[0]->to_dr(idx);
 }
 
 //! Return x[i] with i for which y[i] is minimal.
 
-void geni_argmin( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_argmin(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     int idx = 0;
     double extr = a[1]->to_r(0);
-    for ( int i=1; i<n; ++i ) {
-        if ( a[1]->to_r(i)<extr ) {
+    for (int i = 1; i < n; ++i) {
+        if (a[1]->to_r(i) < extr) {
             extr = a[1]->to_r(i);
             idx = i;
         }
     }
     *r = a[0]->to_r(idx);
-    if( dr )
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Return x[i] with i for which y[i] is maximal.
 
-void geni_argmax( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_argmax(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     int idx = 0;
     double extr = a[1]->to_r(0);
-    for ( int i=1; i<n; ++i ) {
-        if ( a[1]->to_r(i)>extr ) {
+    for (int i = 1; i < n; ++i) {
+        if (a[1]->to_r(i) > extr) {
             extr = a[1]->to_r(i);
             idx = i;
         }
     }
     *r = a[0]->to_r(idx);
-    if( dr )
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Return i for which x[i] is minimal.
 
-void geni_idxmin( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_idxmin(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     int idx = 0;
     double extr = a[0]->to_r(0);
-    for ( int i=1; i<n; ++i ) {
-        if ( a[0]->to_r(i)<extr ) {
+    for (int i = 1; i < n; ++i) {
+        if (a[0]->to_r(i) < extr) {
             extr = a[0]->to_r(i);
             idx = i;
         }
     }
     *r = idx;
-    if( dr )
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Return i for which x[i] is maximal.
 
-void geni_idxmax( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_idxmax(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     int idx = 0;
     double extr = a[0]->to_r(0);
-    for ( int i=1; i<n; ++i ) {
-        if ( a[0]->to_r(i)>extr ) {
+    for (int i = 1; i < n; ++i) {
+        if (a[0]->to_r(i) > extr) {
             extr = a[0]->to_r(i);
             idx = i;
         }
     }
     *r = idx;
-    if( dr )
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Sum.
 
-void geni_sum( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_sum(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     *r = 0;
-    for ( int i=0; i<n; i++ )
+    for (int i = 0; i < n; i++)
         *r += a[0]->to_r(i);
-    if( dr )
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Average.
 
-void geni_avge( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_avge(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     *r = 0;
-    if ( !n )
+    if (!n)
         throw S("Cannot compute average of empty vector");
-    for ( int i=0; i<n; i++ )
+    for (int i = 0; i < n; i++)
         *r += a[0]->to_r(i);
     *r /= n;
-    if( dr )
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Sample variance.
 
-void geni_variance( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_variance(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
-    if ( n<2 )
+    if (n < 2)
         throw S("Cannot compute sample variance for sample size < 2");
-    double p=0, pp=0, q=0;
-    for ( int i=0; i<n; i++ ) {
-        pp = p + ( a[0]->to_r(i) - p ) / (i+1);
-        q += ( a[0]->to_r(i) - p ) * ( a[0]->to_r(i) - pp );
+    double p = 0, pp = 0, q = 0;
+    for (int i = 0; i < n; i++) {
+        pp = p + (a[0]->to_r(i) - p) / (i + 1);
+        q += (a[0]->to_r(i) - p) * (a[0]->to_r(i) - pp);
         p = pp;
     }
-    *r = q / (n-1);
-    if( dr )
+    *r = q / (n - 1);
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Sample standard deviation.
 
-void geni_stdv( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_stdv(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
-    geni_variance( r, dr, n, a );
-    *r = sqrt( *r );
-    if( dr )
+    geni_variance(r, dr, n, a);
+    *r = sqrt(*r);
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Integral.
 
-void geni_integral( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_integral(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     *r = 0;
-    for ( int i=0; i<n-1; i++ ) {
-        if (a[0]->to_r(i+1)<=a[0]->to_r(i))
+    for (int i = 0; i < n - 1; i++) {
+        if (a[0]->to_r(i + 1) <= a[0]->to_r(i))
             throw S("a not sorted");
-        *r += (a[0]->to_r(i+1)-a[0]->to_r(i))*(a[1]->to_r(i+1)+a[1]->to_r(i))/2;
+        *r += (a[0]->to_r(i + 1) - a[0]->to_r(i)) * (a[1]->to_r(i + 1) + a[1]->to_r(i)) / 2;
     }
-    if( dr )
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Center of gravity in x, weighed by y.
 
-void geni_cog( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_cog(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     double r0 = 0, r1 = 0;
-    for ( int i=0; i<n; i++ ) {
+    for (int i = 0; i < n; i++) {
         r0 += a[1]->to_r(i);
         r1 += a[1]->to_r(i) * a[0]->to_r(i);
     }
-    *r = r0>0 ? r1/r0 : 0;
-    if( dr )
+    *r = r0 > 0 ? r1 / r0 : 0;
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Standard deviation in x, weighed by y.
 
-void geni_width( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_width(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     double r0 = 0, r1 = 0, r2 = 0;
-    for ( int i=0; i<n; i++ ) {
+    for (int i = 0; i < n; i++) {
         r0 += a[1]->to_r(i);
         r1 += a[1]->to_r(i) * a[0]->to_r(i);
     }
-    if( r0<=0 )
+    if (r0 <= 0)
         throw S("r0 <= 0");
-    double center = r1/r0;
-    for ( int i=0; i<n; i++ ) {
-        r2 += a[1]->to_r(i) * SQR(a[0]->to_r(i)-center);
+    double center = r1 / r0;
+    for (int i = 0; i < n; i++) {
+        r2 += a[1]->to_r(i) * SQR(a[0]->to_r(i) - center);
     }
-    *r = sqrt( r2/r0 );
-    if( dr )
+    *r = sqrt(r2 / r0);
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
 //! Correlation coefficient.
-void geni_corr( double* r, double* dr, int n, const vector<RObjVecNum>& a )
+void geni_corr(double* r, double* dr, int n, const vector<RObjVecNum>& a)
 {
     double r0 = 0, r1 = 0, s0 = 0, s1 = 0, v = 0;
-    for ( int i=0; i<n; i++ ) {
+    for (int i = 0; i < n; i++) {
         r0 += a[0]->to_r(i) / n;
         r1 += a[1]->to_r(i) / n;
     }
-    for ( int i=0; i<n; i++ ) {
-        s0 += SQR(a[0]->to_r(i)-r0) / n;
-        s1 += SQR(a[1]->to_r(i)-r1) / n;
-        v  += (a[0]->to_r(i)-r0) * (a[1]->to_r(i)-r1) / n;
+    for (int i = 0; i < n; i++) {
+        s0 += SQR(a[0]->to_r(i) - r0) / n;
+        s1 += SQR(a[1]->to_r(i) - r1) / n;
+        v += (a[0]->to_r(i) - r0) * (a[1]->to_r(i) - r1) / n;
     }
-    *r = v / sqrt(s0*s1);
-    if( dr )
+    *r = v / sqrt(s0 * s1);
+    if (dr)
         *dr = 0; // TODO better estimate
 }
 
@@ -247,24 +247,23 @@ void geni_corr( double* r, double* dr, int n, const vector<RObjVecNum>& a )
 //*   Registration and retrieval
 //**************************************************************************************************
 
-namespace NGeni { // internals:
-    map<string,const CGeni*> gmap; // unsorted hash, for expression evaluation
-    vector<const CGeni*> glist;    // sorted array, for help text
+namespace NGeni
+{ // internals:
+map<string, const CGeni*> gmap; // unsorted hash, for expression evaluation
+vector<const CGeni*> glist; // sorted array, for help text
 }
 
-CGeni::CGeni( string _name, int _narg, string _default_arg_str, geni_eval _eval,
-              string _unit_hint, string _com )
+CGeni::CGeni(
+    string _name, int _narg, string _default_arg_str, geni_eval _eval, string _unit_hint,
+    string _com)
     : name(_name), narg(_narg), eval(_eval), unit_hint(_unit_hint), com(_com)
 {
-    default_args = triv::split( _default_arg_str, "," );
-    if ( default_args.size()!=narg )
-        throw "BUG: invalid default "+_default_arg_str+" for CGeni "+name;
+    default_args = triv::split(_default_arg_str, ",");
+    if (default_args.size() != narg)
+        throw "BUG: invalid default " + _default_arg_str + " for CGeni " + name;
 }
 
-void CGeni::register_me() const
-{
-    SGeniRegistry::instance()->push_back( name, this );
-}
+void CGeni::register_me() const { SGeniRegistry::instance()->push_back(name, this); }
 
 void SGeniRegistry::display_entries() const
 {
@@ -279,41 +278,34 @@ void SGeniRegistry::display_entries() const
     cout << "  - list shows default arguments that are assumed when functional name is not\n";
     cout << "      followed by a parenthesis: 'integral' is shorthand for 'integral(x,y)'\n";
     cout << "Implemented functionals:\n";
-    for( const CGeni* g: FList ) {
-        string s1 = g->name + "(" + triv::join(g->default_args,",") + ")";
-        cout << "  " << str( format("%-14s") % s1 ) << g->com << "\n";
+    for (const CGeni* g : FList) {
+        string s1 = g->name + "(" + triv::join(g->default_args, ",") + ")";
+        cout << "  " << str(format("%-14s") % s1) << g->com << "\n";
     }
 }
 
 void SGeniRegistry::initialize()
 {
     // operators by precedence (as in xax_yacc.ypp):
-    (new CGeni( "valmin", 1, "y", geni_valmin, "a",
-                "minimum value of y" ))->register_me();
-    (new CGeni( "valmax", 1, "y", geni_valmax, "a",
-                "maximum value of y" ))->register_me();
-    (new CGeni( "argmin", 2, "x,y", geni_argmin, "a",
-                "value of x for which y is minimal" ))->register_me();
-    (new CGeni( "argmax", 2, "x,y", geni_argmax, "a",
-                "value of x for which y is maximal" ))->register_me();
-    (new CGeni( "idxmin", 1, "y", geni_idxmin, "-",
-                "index for which x is minimal" ))->register_me();
-    (new CGeni( "idxmax", 1, "y", geni_idxmax, "-",
-                "index for which y is maximal" ))->register_me();
-    (new CGeni( "sum", 1, "y", geni_sum, "a",
-                "sum of y" ))->register_me();
-    (new CGeni( "avge", 1, "y", geni_avge, "a",
-                "average of y" ))->register_me();
-    (new CGeni( "var", 1, "y", geni_variance, "a",
-                "sample variance of y" ))->register_me();
-    (new CGeni( "stdv", 1, "y", geni_stdv, "a",
-                "sample standard deviation of y" ))->register_me();
-    (new CGeni( "integral", 2, "x,y", geni_integral, "ab",
-                "integral d(x) of y" ))->register_me();
-    (new CGeni( "cog", 2, "x,y", geni_cog, "a",
-                "center of gravity of x weighed with y" ))->register_me();
-    (new CGeni( "width", 2, "x,y", geni_width, "a",
-                "standard variation in x weighed with y" ))->register_me();
-    (new CGeni( "corr", 2, "x,y", geni_corr, "?", // TODO: unit?
-                "correlation coefficient of x and y" ))->register_me();
+    (new CGeni("valmin", 1, "y", geni_valmin, "a", "minimum value of y"))->register_me();
+    (new CGeni("valmax", 1, "y", geni_valmax, "a", "maximum value of y"))->register_me();
+    (new CGeni("argmin", 2, "x,y", geni_argmin, "a", "value of x for which y is minimal"))
+        ->register_me();
+    (new CGeni("argmax", 2, "x,y", geni_argmax, "a", "value of x for which y is maximal"))
+        ->register_me();
+    (new CGeni("idxmin", 1, "y", geni_idxmin, "-", "index for which x is minimal"))->register_me();
+    (new CGeni("idxmax", 1, "y", geni_idxmax, "-", "index for which y is maximal"))->register_me();
+    (new CGeni("sum", 1, "y", geni_sum, "a", "sum of y"))->register_me();
+    (new CGeni("avge", 1, "y", geni_avge, "a", "average of y"))->register_me();
+    (new CGeni("var", 1, "y", geni_variance, "a", "sample variance of y"))->register_me();
+    (new CGeni("stdv", 1, "y", geni_stdv, "a", "sample standard deviation of y"))->register_me();
+    (new CGeni("integral", 2, "x,y", geni_integral, "ab", "integral d(x) of y"))->register_me();
+    (new CGeni("cog", 2, "x,y", geni_cog, "a", "center of gravity of x weighed with y"))
+        ->register_me();
+    (new CGeni("width", 2, "x,y", geni_width, "a", "standard variation in x weighed with y"))
+        ->register_me();
+    (new CGeni(
+         "corr", 2, "x,y", geni_corr, "?", // TODO: unit?
+         "correlation coefficient of x and y"))
+        ->register_me();
 }
diff --git a/pub/lib/reduce_spec.hpp b/pub/lib/reduce_spec.hpp
index 2a93e341526f82eb5f1c2ea2fb08083db70c0dba..31fdf90e365e5e4a25cecc8c2cb166f8ebb669b3 100644
--- a/pub/lib/reduce_spec.hpp
+++ b/pub/lib/reduce_spec.hpp
@@ -11,33 +11,36 @@
 
 //!  Function type: Evaluate generalized integral for given vector(s).
 
-typedef void (*geni_eval) (double*, double*, int, const vector<RObjVecNum>& );
+typedef void (*geni_eval)(double*, double*, int, const vector<RObjVecNum>&);
 
 
 //! A wrapper holding a functional.
 
-class CGeni {
- public:
+class CGeni
+{
+public:
     string name;
     int narg;
     geni_eval eval;
     string unit_hint;
     string com;
     vector<string> default_args;
-    class CCoord coord( class CCoord *co ) const;
-    class CCoord coord( class CCoord *co1, class CCoord *co2 ) const;
-    CGeni( string _txt, int _narg, string _default_arg_str, geni_eval _eval,
-           string _unit_hint, string _com="" );
+    class CCoord coord(class CCoord* co) const;
+    class CCoord coord(class CCoord* co1, class CCoord* co2) const;
+    CGeni(
+        string _txt, int _narg, string _default_arg_str, geni_eval _eval, string _unit_hint,
+        string _com = "");
     void register_me() const;
 };
 
 
 //! A singleton class that holds a collection of generalized integrals CGeni.
 
-class SGeniRegistry : public IRegistry<CGeni>, public triv::ISingleton<SGeniRegistry> {
- private:
+class SGeniRegistry : public IRegistry<CGeni>, public triv::ISingleton<SGeniRegistry>
+{
+private:
     virtual string type_name() const { return "generalized integrals"; }
- public:
+public:
     void display_entries() const;
     static void initialize();
 };
diff --git a/pub/lib/registry.hpp b/pub/lib/registry.hpp
index 2ceab37108a4bd3ab9e88a43d697c42587377cca..27eec53cf7e8b059f8d63774adf34b49fc0f3a73 100644
--- a/pub/lib/registry.hpp
+++ b/pub/lib/registry.hpp
@@ -14,54 +14,72 @@
 
 //! Mixin interface for registries holding objects of type T; temporary version for SFuncRegistry.
 
-template<class T>
-class IRegistryTmp {
- protected:
+template <class T> class IRegistryTmp
+{
+protected:
     virtual string type_name() const = 0;
-    map<string, /*const*/T*> FMap;       //! unsorted hash, for expression evaluation
-    vector<const T*> FList;    //! sorted array, for help text
- public:
-    virtual ~IRegistryTmp() { for ( const T* F: FList ) delete F; }
-    void push_back( const string& key, const T* val ){
-        if ( FMap.find(key) != FMap.end() )
+    map<string, /*const*/ T*> FMap; //! unsorted hash, for expression evaluation
+    vector<const T*> FList; //! sorted array, for help text
+public:
+    virtual ~IRegistryTmp()
+    {
+        for (const T* F : FList)
+            delete F;
+    }
+    void push_back(const string& key, const T* val)
+    {
+        if (FMap.find(key) != FMap.end())
             throw "Duplicate registry entry " + key;
-        FMap.insert( std::make_pair( key, val ) );
-        FList.push_back( val );
+        FMap.insert(std::make_pair(key, val));
+        FList.push_back(val);
     }
-    const T* find( const string& key ) const {
+    const T* find(const string& key) const
+    {
         auto pos = FMap.find(key);
-        return pos == FMap.end() ? nullptr : pos->second; }
-    const T* find_or_fail( const string& key ) const {
-        const T* ret = find( key );
-        if( !ret )
+        return pos == FMap.end() ? nullptr : pos->second;
+    }
+    const T* find_or_fail(const string& key) const
+    {
+        const T* ret = find(key);
+        if (!ret)
             throw "Cannot find '" + key + "' in " + type_name() + " registry";
-        return ret; }
+        return ret;
+    }
 };
 
 //! Mixin interface for registries holding objects of type T
 
-template<class T>
-class IRegistry {
- protected:
+template <class T> class IRegistry
+{
+protected:
     virtual string type_name() const = 0;
-    map<string, const T*> FMap;       //! unsorted hash, for expression evaluation
-    vector<const T*> FList;    //! sorted array, for help text
- public:
-    virtual ~IRegistry() { for ( const T* F: FList ) delete F; }
-    void push_back( const string& key, const T* val ){
-        if ( FMap.find(key) != FMap.end() )
+    map<string, const T*> FMap; //! unsorted hash, for expression evaluation
+    vector<const T*> FList; //! sorted array, for help text
+public:
+    virtual ~IRegistry()
+    {
+        for (const T* F : FList)
+            delete F;
+    }
+    void push_back(const string& key, const T* val)
+    {
+        if (FMap.find(key) != FMap.end())
             throw "Duplicate registry entry " + key;
-        FMap.insert( std::make_pair( key, val ) );
-        FList.push_back( val );
+        FMap.insert(std::make_pair(key, val));
+        FList.push_back(val);
     }
-    const T* find( const string& key ) const {
+    const T* find(const string& key) const
+    {
         auto pos = FMap.find(key);
-        return pos == FMap.end() ? nullptr : pos->second; }
-    const T* find_or_fail( const string& key ) const {
-        const T* ret = find( key );
-        if( !ret )
+        return pos == FMap.end() ? nullptr : pos->second;
+    }
+    const T* find_or_fail(const string& key) const
+    {
+        const T* ret = find(key);
+        if (!ret)
             throw "Cannot find '" + key + "' in " + type_name() + " registry";
-        return ret; }
+        return ret;
+    }
 };
 
 #endif // IREGISTRY_H
diff --git a/pub/lib/rssm.cpp b/pub/lib/rssm.cpp
index 916e89d86a967f9ddc1900c439b64e1345245dba..c45e4ae7e24fccbdf04efb83fd927eb552c63cb4 100644
--- a/pub/lib/rssm.cpp
+++ b/pub/lib/rssm.cpp
@@ -14,36 +14,37 @@
 
 #include <yaml-cpp/yaml.h>
 
-#include "../trivia/string_ops.hpp"
-#include "../trivia/file_ops.hpp"
 #include "../readplus/ask.hpp"
+#include "../trivia/file_ops.hpp"
+#include "../trivia/string_ops.hpp"
 
-#include "olf.hpp"
-#include "obj.hpp"
 #include "mem.hpp"
-#include "slice.hpp"
+#include "obj.hpp"
+#include "olf.hpp"
 #include "rssm.hpp"
+#include "slice.hpp"
 
 
 //! All relevant information extracted from one raw-data file from SPHERES.
 
-class CRawfileSpheres {
- public:
-    void RdRawYam( std::ifstream& F_in );
+class CRawfileSpheres
+{
+public:
+    void RdRawYam(std::ifstream& F_in);
     double daq_time_step;
     time_t measured_from;
     time_t measured_until;
-    int    measured_at;
+    int measured_at;
     double measured_during;
-    bool   incremental;
-    int   ndet;
+    bool incremental;
+    int ndet;
     vector<double> rawdata[6];
-    int    maj_syntax, min_syntax, maj_outform, min_outform;
+    int maj_syntax, min_syntax, maj_outform, min_outform;
 };
 
 //! Read raw data file, store contents as class variables
 
-void CRawfileSpheres::RdRawYam( std::ifstream& F_in )
+void CRawfileSpheres::RdRawYam(std::ifstream& F_in)
 {
     string key, val;
     CCoord co;
@@ -53,168 +54,166 @@ void CRawfileSpheres::RdRawYam( std::ifstream& F_in )
     maj_outform = 5;
     min_outform = 1;
 
-    //YAML::Parser parser(F_in);
+    // YAML::Parser parser(F_in);
     const YAML::Node& doc = YAML::Load(F_in);
 
     // read Meta:
-    if(!doc["Meta"])
+    if (!doc["Meta"])
         throw S("no Meta");
     try {
         YAML::NodeType::value Metatype = doc["Meta"].Type();
-        if ( Metatype != YAML::NodeType::Map && doc["Meta"].size() > 0)
+        if (Metatype != YAML::NodeType::Map && doc["Meta"].size() > 0)
             throw S("DATA BUG: Meta is not a MAP");
-        if(!doc["Meta"]["format"])
+        if (!doc["Meta"]["format"])
             throw S("DATA BUG: no format in Meta");
         string val;
-        val=doc["Meta"]["format"].as<string>();
-        if( strncmp( val.c_str(), "acq5.2 for yaml1", 16 ) )
+        val = doc["Meta"]["format"].as<string>();
+        if (strncmp(val.c_str(), "acq5.2 for yaml1", 16))
             throw "UNEXPECTED DATA: format: " + val + " instead of acq5.2";
-    } catch( std::exception& e) {
+    } catch (std::exception& e) {
         throw "failed to read Meta section: " + string(e.what());
     }
 
     // ignore History.
 
     // read Shortpar:
-    try{
+    try {
         const YAML::Node& spar = doc["Shortpar"];
-        if(!spar)
+        if (!spar)
             throw S("DATA BUG: no Shortpar");
 
-        if( !spar["incremental"] )
+        if (!spar["incremental"])
             throw S("DATA BUG: no Shortpar 'incremental'");
         string val = spar["incremental"].as<string>();
-        if      ( val=="true" )
+        if (val == "true")
             incremental = true;
-        else if ( val=="false" )
+        else if (val == "false")
             incremental = false;
         else
             throw "DATA BUG: invalid value [" + val + "] of 'incremental'";
 
-        if( !spar["subs_until"] )
+        if (!spar["subs_until"])
             throw S("DATA BUG: no Shortpar 'subs_until'");
         val = spar["subs_until"].as<string>();
         char date_string[24];
-        sscanf( val.c_str(), "%24c", date_string );
+        sscanf(val.c_str(), "%24c", date_string);
         struct tm date_broken;
-        strptime( date_string, "%F %A %H:%M:%S", &date_broken );
-        measured_until = mktime( &date_broken );
+        strptime(date_string, "%F %A %H:%M:%S", &date_broken);
+        measured_until = mktime(&date_broken);
 
-        if( !spar["ndet"] )
+        if (!spar["ndet"])
             throw S("DATA BUG: no Shortpar 'ndet'");
         ndet = spar["ndet"].as<int>();
 
-        if( !spar["daq_time_step"] )
+        if (!spar["daq_time_step"])
             throw S("DATA BUG: no Shortpar 'daq_time_step'");
         val = spar["daq_time_step"].as<string>();
         string numval, unit;
-        triv::string_extract_word( val, &numval, &unit );
-        if ( unit!="s" )
+        triv::string_extract_word(val, &numval, &unit);
+        if (unit != "s")
             throw "DATA BUG: daq_time_step has unexpected unit '" + unit + "'";
-        triv::any2dbl( numval, &daq_time_step );
+        triv::any2dbl(numval, &daq_time_step);
 
-    } catch( std::exception& e ) {
+    } catch (std::exception& e) {
         throw "DATA BUG: failed to read Shortpar section: " + string(e.what());
     }
 
     // read EnergyHistograms:
     try {
-        if( !doc["EnergyHistograms"] )
+        if (!doc["EnergyHistograms"])
             throw S("DATA BUG: no EnergyHistograms");
-        if ( doc["EnergyHistograms"].Type() != YAML::NodeType::Sequence )
+        if (doc["EnergyHistograms"].Type() != YAML::NodeType::Sequence)
             throw S("DATA BUG: EnergyHistograms is not a SEQUENCE");
         int nEne = doc["EnergyHistograms"].size();
-        for ( int iEne = 0; iEne<nEne; iEne++ ) {
-            if ( doc["EnergyHistograms"][iEne].Type() !=
-                 YAML::NodeType::Sequence )
+        for (int iEne = 0; iEne < nEne; iEne++) {
+            if (doc["EnergyHistograms"][iEne].Type() != YAML::NodeType::Sequence)
                 throw "DATA BUG: EnergyHistogram[" + S(iEne) + "] is not a SEQUENCE";
-            val=doc["EnergyHistograms"][iEne][0].as<string>();
-            if( !triv::any2dbl( val, &num ) )
+            val = doc["EnergyHistograms"][iEne][0].as<string>();
+            if (!triv::any2dbl(val, &num))
                 throw "E-Hist: invalid x-value " + val;
-            for( int i=0; i<4; ++i )
-                rawdata[i].push_back( num );
-            for( int i=0; i<4; ++i ){ // counts
-               // inline Node& Node::operator=(const T& rhs);
-
-                const YAML::Node arr = doc["EnergyHistograms"][iEne][i+1];
-                if( arr.Type() != YAML::NodeType::Sequence )
-                    throw "DATA BUG: EnergyHistogram[" + S(iEne) + "][" +
-                        S(i+1) + "] is not a SEQUENCE";
-                for( int j=0; j<ndet; ++j ) {
-                    val=(arr)[j].as<string>();
+            for (int i = 0; i < 4; ++i)
+                rawdata[i].push_back(num);
+            for (int i = 0; i < 4; ++i) { // counts
+                // inline Node& Node::operator=(const T& rhs);
+
+                const YAML::Node arr = doc["EnergyHistograms"][iEne][i + 1];
+                if (arr.Type() != YAML::NodeType::Sequence)
+                    throw "DATA BUG: EnergyHistogram[" + S(iEne) + "][" + S(i + 1)
+                        + "] is not a SEQUENCE";
+                for (int j = 0; j < ndet; ++j) {
+                    val = (arr)[j].as<string>();
                     //(*arr)[j] >> val;
-                    if( !triv::any2dbl( val, &num ) )
+                    if (!triv::any2dbl(val, &num))
                         throw "E-Hist: invalid count " + val;
-                    rawdata[i].push_back( num );
+                    rawdata[i].push_back(num);
                 }
             }
-            for( int i=0; i<4; ++i ){ // tsteps
-                const YAML::Node arr = (doc["EnergyHistograms"][iEne][i+1+4]);
-                if( arr.Type() != YAML::NodeType::Sequence )
-                    throw "DATA BUG: EnergyHistogram[" + S(iEne) + "][" +
-                        S(i+1+4) + "] is not a SEQUENCE";
-                for( int j=0; j<ndet; ++j ) {
-
-                    val=(arr)[j].as<string>();
-                    if( !triv::any2dbl( val, &num ) )
+            for (int i = 0; i < 4; ++i) { // tsteps
+                const YAML::Node arr = (doc["EnergyHistograms"][iEne][i + 1 + 4]);
+                if (arr.Type() != YAML::NodeType::Sequence)
+                    throw "DATA BUG: EnergyHistogram[" + S(iEne) + "][" + S(i + 1 + 4)
+                        + "] is not a SEQUENCE";
+                for (int j = 0; j < ndet; ++j) {
+
+                    val = (arr)[j].as<string>();
+                    if (!triv::any2dbl(val, &num))
                         throw "E-Hist: invalid tstep " + val;
-                    rawdata[i].push_back( num );
+                    rawdata[i].push_back(num);
                 }
             }
         }
-    } catch( std::exception& e) {
+    } catch (std::exception& e) {
         throw "BAD BUG: failed to read EnergyHistograms section: " + string(e.what());
     }
 
     // read ChopperHistograms:
     try {
-        if(!doc["ChopperHistograms"])
+        if (!doc["ChopperHistograms"])
             throw S("no ChopperHistograms");
-        if ( doc["ChopperHistograms"].Type() != YAML::NodeType::Sequence )
+        if (doc["ChopperHistograms"].Type() != YAML::NodeType::Sequence)
             throw S("DATA BUG: ChopperHistograms is not a SEQUENCE");
-        int nCho =  doc["ChopperHistograms"].size();
-        for (int iCho = 0; iCho<nCho; iCho++) {
-            if ( doc["ChopperHistograms"][iCho].Type()
-                 != YAML::NodeType::Sequence )
+        int nCho = doc["ChopperHistograms"].size();
+        for (int iCho = 0; iCho < nCho; iCho++) {
+            if (doc["ChopperHistograms"][iCho].Type() != YAML::NodeType::Sequence)
                 throw "DATA BUG: ChopperHistograms " + S(iCho) + " is not a SEQUENCE";
-            val=doc["ChopperHistograms"][iCho][0].as<string>();
-            if( !triv::any2dbl( val, &num ) )
+            val = doc["ChopperHistograms"][iCho][0].as<string>();
+            if (!triv::any2dbl(val, &num))
                 throw "DATA BUG: C-Hist: invalid x-value " + val;
-            for( int i=4; i<6; ++i )
-                rawdata[i].push_back( num );
-            for( int i=4; i<6; ++i ){                        // 2 cnts lines
-               const YAML::Node arr = (doc["ChopperHistograms"][iCho][i-4+1]);
-                if( arr.Type() != YAML::NodeType::Sequence )
-                    throw "DATA BUG: ChopperHistogram[" + S(iCho) + "][" +
-                        S(i-4+1) + "] is not a SEQUENCE";
-                for( int j=0; j<ndet; ++j ) {
-                    val=(arr)[j].as<string>();
-                    if( !triv::any2dbl( val, &num ) )
+            for (int i = 4; i < 6; ++i)
+                rawdata[i].push_back(num);
+            for (int i = 4; i < 6; ++i) { // 2 cnts lines
+                const YAML::Node arr = (doc["ChopperHistograms"][iCho][i - 4 + 1]);
+                if (arr.Type() != YAML::NodeType::Sequence)
+                    throw "DATA BUG: ChopperHistogram[" + S(iCho) + "][" + S(i - 4 + 1)
+                        + "] is not a SEQUENCE";
+                for (int j = 0; j < ndet; ++j) {
+                    val = (arr)[j].as<string>();
+                    if (!triv::any2dbl(val, &num))
                         throw "E-Hist: invalid count " + val;
-                    rawdata[i].push_back( num );
+                    rawdata[i].push_back(num);
                 }
             }
-            for( int i=4; i<6; ++i ){            // 2 time lines
-                const YAML::Node arr = (doc["ChopperHistograms"][iCho][i-4+1+2]);
-                if( arr.Type() != YAML::NodeType::Sequence )
-                    throw "DATA BUG: ChopperHistogram[" + S(iCho) + "][" +
-                        S(i-4+1+2) + "] is not a SEQUENCE";
-                for( int j=0; j<ndet; ++j ) {
-                    val=(arr)[j].as<string>();
-                    if( !triv::any2dbl( val, &num ) )
+            for (int i = 4; i < 6; ++i) { // 2 time lines
+                const YAML::Node arr = (doc["ChopperHistograms"][iCho][i - 4 + 1 + 2]);
+                if (arr.Type() != YAML::NodeType::Sequence)
+                    throw "DATA BUG: ChopperHistogram[" + S(iCho) + "][" + S(i - 4 + 1 + 2)
+                        + "] is not a SEQUENCE";
+                for (int j = 0; j < ndet; ++j) {
+                    val = (arr)[j].as<string>();
+                    if (!triv::any2dbl(val, &num))
                         throw "E-Hist: invalid count " + val;
-                    rawdata[i].push_back( num );
+                    rawdata[i].push_back(num);
                 }
             }
         }
-    } catch( std::exception& e ) {
+    } catch (std::exception& e) {
         throw "DATA BUG: failed to read ChopperHistograms section: " + string(e.what());
     }
 }
 
 //! Read one raw data file.
 
-void NRSSM::read_spec( int flag )
+void NRSSM::read_spec(int flag)
 
 // flag values (to be OR'ed):
 //    1 save also open
@@ -229,82 +228,83 @@ void NRSSM::read_spec( int flag )
     CRawfileSpheres R;
     std::ifstream F_in;
 
-    F_in.open( file_f.c_str(), std::fstream::in );
-    if( !(F_in.is_open()) )
+    F_in.open(file_f.c_str(), std::fstream::in);
+    if (!(F_in.is_open()))
         throw "Cannot read " + file_f;
-    R.RdRawYam( F_in );
+    R.RdRawYam(F_in);
 
     double tstep = R.daq_time_step;
-    vector<double> *raw = R.rawdata;
+    vector<double>* raw = R.rawdata;
     int ndet = R.ndet;
 
     // *** set file headers ***
 
     POld olf[8];
     int iolf;
-    for( iolf=0; iolf<8; ++iolf ){
-        olf[iolf] = POld( new COld );
-        olf[iolf]->xco = iolf<4 ||iolf>5 ?
-            CCoord( "E", "ueV" ) : CCoord( "phase", "deg" );
-        olf[iolf]->yco = CCoord( "cts", "sec-1" );
-        olf[iolf]->ZCo.push_back( CCoord( "det", "") );
+    for (iolf = 0; iolf < 8; ++iolf) {
+        olf[iolf] = POld(new COld);
+        olf[iolf]->xco = iolf < 4 || iolf > 5 ? CCoord("E", "ueV") : CCoord("phase", "deg");
+        olf[iolf]->yco = CCoord("cts", "sec-1");
+        olf[iolf]->ZCo.push_back(CCoord("det", ""));
     }
-    triv::fname_divide( file_f, 0, &name, 0 );
-    olf[0]->name = name+"left";
-    olf[1]->name = name+"right";
-    olf[2]->name = name+"open_left";
-    olf[3]->name = name+"open_right";
-    olf[4]->name = name+"chop_elast";
-    olf[5]->name = name+"chop_inela";
+    triv::fname_divide(file_f, 0, &name, 0);
+    olf[0]->name = name + "left";
+    olf[1]->name = name + "right";
+    olf[2]->name = name + "open_left";
+    olf[3]->name = name + "open_right";
+    olf[4]->name = name + "chop_elast";
+    olf[5]->name = name + "chop_inela";
     olf[6]->name = name;
-    olf[7]->name = name+"open";
-    string doc = "ry" + (flag==0 ? "" : S(flag+1)) + " " + file_f;
-    olf[0]->log_action( doc + " # refl, left halfspace" );
-    olf[1]->log_action( doc + " # refl, right halfspace" );
-    olf[2]->log_action( doc + " # open, left halfspace" );
-    olf[3]->log_action( doc + " # open, right halfspace" );
-    olf[4]->log_action( doc + " # elastic" );
-    olf[5]->log_action( doc + " # inelastic" );
-    olf[6]->log_action( doc + " # refl" );
-    olf[7]->log_action( doc + " # open" );
-
-    for( iolf=0; iolf<8; ++iolf ){
-        for( int j=0; j<ndet; ++j ){
-            PSpec s( new CSpec );
-            s->z.resize( 1 );
-            s->z[0] = PObjInt( new CObjInt( j ) );
-            olf[iolf]->V.push_back( move(s) );
+    olf[7]->name = name + "open";
+    string doc = "ry" + (flag == 0 ? "" : S(flag + 1)) + " " + file_f;
+    olf[0]->log_action(doc + " # refl, left halfspace");
+    olf[1]->log_action(doc + " # refl, right halfspace");
+    olf[2]->log_action(doc + " # open, left halfspace");
+    olf[3]->log_action(doc + " # open, right halfspace");
+    olf[4]->log_action(doc + " # elastic");
+    olf[5]->log_action(doc + " # inelastic");
+    olf[6]->log_action(doc + " # refl");
+    olf[7]->log_action(doc + " # open");
+
+    for (iolf = 0; iolf < 8; ++iolf) {
+        for (int j = 0; j < ndet; ++j) {
+            PSpec s(new CSpec);
+            s->z.resize(1);
+            s->z[0] = PObjInt(new CObjInt(j));
+            olf[iolf]->V.push_back(move(s));
         }
     }
 
-    if( R.maj_outform<=2 ){ // old data format
+    if (R.maj_outform <= 2) { // old data format
         double x, tmeas, count;
         // transfer data from raw arrays:
-        for( iolf=0; iolf<6; ++iolf ){
-            for( int iraw=0; iraw<raw[iolf].size(); iraw+=(ndet+2) ){
+        for (iolf = 0; iolf < 6; ++iolf) {
+            for (int iraw = 0; iraw < raw[iolf].size(); iraw += (ndet + 2)) {
                 x = raw[iolf][iraw];
-                tmeas = raw[iolf][iraw+ndet+1];
-                if( tmeas<1 ) continue;
-                for ( int j=0; j<ndet; ++j ){
-                    count = raw[iolf][iraw+1+j];
-                    olf[iolf]->VS(j)->push_xy( x, count/tmeas/tstep );
+                tmeas = raw[iolf][iraw + ndet + 1];
+                if (tmeas < 1)
+                    continue;
+                for (int j = 0; j < ndet; ++j) {
+                    count = raw[iolf][iraw + 1 + j];
+                    olf[iolf]->VS(j)->push_xy(x, count / tmeas / tstep);
                 }
             }
         }
         // sum over halfspaces:
-        for( int ichop=0; ichop<2; ++ichop ){
-            int iolf0 = ichop*2;
-            int iolf1 = ichop*2+1;
+        for (int ichop = 0; ichop < 2; ++ichop) {
+            int iolf0 = ichop * 2;
+            int iolf1 = ichop * 2 + 1;
             int nline = raw[iolf0].size();
-            if( raw[iolf1].size()!=nline )
+            if (raw[iolf1].size() != nline)
                 throw S("inconsistent raw array sizes");
-            for( int iraw=0; iraw<nline; iraw+=(ndet+2) ){
+            for (int iraw = 0; iraw < nline; iraw += (ndet + 2)) {
                 x = raw[iolf0][iraw];
-                tmeas = raw[iolf0][iraw+ndet+1]+raw[iolf1][iraw+ndet+1];
-                if( tmeas<1 ) continue;
-                for ( int j=0; j<ndet; ++j ){
-                    count = raw[iolf0][iraw+1+j] + raw[iolf1][iraw+1+j];
-                    olf[6+ichop]->VS(j)->push_xy( x, count/tmeas/tstep );
+                tmeas = raw[iolf0][iraw + ndet + 1] + raw[iolf1][iraw + ndet + 1];
+                if (tmeas < 1)
+                    continue;
+                for (int j = 0; j < ndet; ++j) {
+                    count = raw[iolf0][iraw + 1 + j] + raw[iolf1][iraw + 1 + j];
+                    olf[6 + ichop]->VS(j)->push_xy(x, count / tmeas / tstep);
                 }
             }
         }
@@ -312,66 +312,67 @@ void NRSSM::read_spec( int flag )
     } else { // as of 2008-03-03
         double x, tmeas, count;
         // transfer data from raw arrays:
-        for( iolf=0; iolf<6; ++iolf ){
-            for( int iraw=0; iraw<raw[iolf].size(); iraw+=(1+ndet*2) ){
+        for (iolf = 0; iolf < 6; ++iolf) {
+            for (int iraw = 0; iraw < raw[iolf].size(); iraw += (1 + ndet * 2)) {
                 x = raw[iolf][iraw];
-                for ( int j=0; j<ndet; ++j ){
-                    count = raw[iolf][iraw+1+j];
-                    if( !(flag&16) ){
-                        tmeas = raw[iolf][iraw+1+ndet+j];
-                        if( tmeas<1 ) continue;
-                        count /= (tmeas*tstep);
+                for (int j = 0; j < ndet; ++j) {
+                    count = raw[iolf][iraw + 1 + j];
+                    if (!(flag & 16)) {
+                        tmeas = raw[iolf][iraw + 1 + ndet + j];
+                        if (tmeas < 1)
+                            continue;
+                        count /= (tmeas * tstep);
                     }
-                    olf[iolf]->VS(j)->push_xy( x, count );
+                    olf[iolf]->VS(j)->push_xy(x, count);
                 }
             }
         }
         // sum over halfspaces:
-        for( int ichop=0; ichop<2; ++ichop ){
-            int iolf0 = ichop*2;
-            int iolf1 = ichop*2+1;
+        for (int ichop = 0; ichop < 2; ++ichop) {
+            int iolf0 = ichop * 2;
+            int iolf1 = ichop * 2 + 1;
             int nline = raw[iolf0].size();
-            if( raw[iolf1].size()!=nline )
+            if (raw[iolf1].size() != nline)
                 throw S("inconsistent raw array sizes");
-            for( int iraw=0; iraw<nline; iraw+=(1+ndet*2) ){
+            for (int iraw = 0; iraw < nline; iraw += (1 + ndet * 2)) {
                 x = raw[iolf0][iraw];
-                for ( int j=0; j<ndet; ++j ){
-                    count = raw[iolf0][iraw+1+j] + raw[iolf1][iraw+1+j];
-                    if( !(flag&16) ){
-                        tmeas = raw[iolf0][iraw+1+ndet+j] +
-                            raw[iolf1][iraw+1+ndet+j];
-                        if( tmeas<1 ) continue;
-                        count /= (tmeas*tstep);
+                for (int j = 0; j < ndet; ++j) {
+                    count = raw[iolf0][iraw + 1 + j] + raw[iolf1][iraw + 1 + j];
+                    if (!(flag & 16)) {
+                        tmeas = raw[iolf0][iraw + 1 + ndet + j] + raw[iolf1][iraw + 1 + ndet + j];
+                        if (tmeas < 1)
+                            continue;
+                        count /= (tmeas * tstep);
                     }
-                    olf[6+ichop]->VS(j)->push_xy( x, count );
+                    olf[6 + ichop]->VS(j)->push_xy(x, count);
                 }
             }
         }
     }
 
-    if( flag & 2 ){
-        SMem::instance()->mem_store( move(olf[4]) );
-        SMem::instance()->mem_store( move(olf[5]) );
+    if (flag & 2) {
+        SMem::instance()->mem_store(move(olf[4]));
+        SMem::instance()->mem_store(move(olf[5]));
     }
-    if( flag & 2 && flag & 4 ){
-        SMem::instance()->mem_store( move(olf[2]) );
-        SMem::instance()->mem_store( move(olf[3]) );
+    if (flag & 2 && flag & 4) {
+        SMem::instance()->mem_store(move(olf[2]));
+        SMem::instance()->mem_store(move(olf[3]));
     }
-    if( flag & 4 ){
-        SMem::instance()->mem_store( move(olf[0]) );
-        SMem::instance()->mem_store( move(olf[1]) );
+    if (flag & 4) {
+        SMem::instance()->mem_store(move(olf[0]));
+        SMem::instance()->mem_store(move(olf[1]));
     }
-    if( flag & 1 ){
-        SMem::instance()->mem_store( move(olf[7]) );
+    if (flag & 1) {
+        SMem::instance()->mem_store(move(olf[7]));
     }
-    if( ! (flag & 8 ) ){
-        SMem::instance()->mem_store( move(olf[6]) );
+    if (!(flag & 8)) {
+        SMem::instance()->mem_store(move(olf[6]));
     }
 }
 
 //! Read a series of raw data files.
 
-void NRSSM::read_series( int flag )
+void NRSSM::read_series(int flag)
 
 // flag values (to be OR'ed):
 //    1 save also open
@@ -385,98 +386,97 @@ void NRSSM::read_series( int flag )
 
     // Read consolidated files:
     fser = wask("Read SPHERES data from series");
-    for( isub=0; ; ++isub ){
-        fnam = fser+"a"+S(isub);
+    for (isub = 0;; ++isub) {
+        fnam = fser + "a" + S(isub);
         std::ifstream F_in;
-        F_in.open( fnam.c_str(), std::fstream::in );
-        if( !(F_in.is_open()) )
+        F_in.open(fnam.c_str(), std::fstream::in);
+        if (!(F_in.is_open()))
             break;
         // cout << "successfully opened "<<fnam<<"\n";
         CRawfileSpheres rf;
-        rf.RdRawYam( F_in );
-        RR.push_back( rf );
+        rf.RdRawYam(F_in);
+        RR.push_back(rf);
     }
 
     int nsub = RR.size();
-    if( nsub==0 )
+    if (nsub == 0)
         throw "could not open file " + fnam;
-    else if( nsub==1 )
+    else if (nsub == 1)
         throw S("series contains just one spectrum -> use a simpler method");
-    printf( "successfully read %i files\n", nsub );
+    printf("successfully read %i files\n", nsub);
 
     // Correct time:
-    double mean_time =
-        ( RR[nsub-1].measured_until - RR[0].measured_until ) / nsub;
-    printf( "mean measuring time %g seconds per file\n", mean_time );
-    t = (time_t) (RR[0].measured_until-mean_time);
+    double mean_time = (RR[nsub - 1].measured_until - RR[0].measured_until) / nsub;
+    printf("mean measuring time %g seconds per file\n", mean_time);
+    t = (time_t)(RR[0].measured_until - mean_time);
     struct tm tlocal;
-    strftime( tstrg, 30, "%F %b %H:%M:%S", localtime_r( &t, &tlocal ) );
-    printf( "measurement times relative to start time %s\n", tstrg );
-    for( isub=0; isub<nsub; ++isub )
-        RR[isub].measured_at = RR[isub].measured_until -
-            RR[0].measured_until + (int) (mean_time/2);
+    strftime(tstrg, 30, "%F %b %H:%M:%S", localtime_r(&t, &tlocal));
+    printf("measurement times relative to start time %s\n", tstrg);
+    for (isub = 0; isub < nsub; ++isub)
+        RR[isub].measured_at =
+            RR[isub].measured_until - RR[0].measured_until + (int)(mean_time / 2);
 
     // Get parameters, check consistency:
     int ndet = RR[0].ndet;
-    printf( "used %i detectors\n", ndet );
+    printf("used %i detectors\n", ndet);
     double tstep = RR[0].daq_time_step;
     bool incremental_in = RR[0].incremental;
 
-    for( isub=1; isub<nsub; ++isub ){
-        if( RR[isub].ndet!=ndet )
-            throw "inconsistent no of det: file " + S(isub)
-                + " has " + S(RR[isub].ndet) + " instead of " + S(ndet);
-        if( RR[isub].daq_time_step!=tstep )
+    for (isub = 1; isub < nsub; ++isub) {
+        if (RR[isub].ndet != ndet)
+            throw "inconsistent no of det: file " + S(isub) + " has " + S(RR[isub].ndet)
+                + " instead of " + S(ndet);
+        if (RR[isub].daq_time_step != tstep)
             throw S("inconsistent time step");
-        if( RR[isub].incremental!=incremental_in )
+        if (RR[isub].incremental != incremental_in)
             throw S("inconsistent increment status");
     }
 
     // Set file headers:
     POld olf[2];
     int iolf;
-    for( int iolf=0; iolf<2; ++iolf )
-        olf[iolf] = POld( new COld );
+    for (int iolf = 0; iolf < 2; ++iolf)
+        olf[iolf] = POld(new COld);
     int j, nE;
 
-    for( iolf=0; iolf<2; ++iolf ){
-        olf[iolf]->log_action( "acquire data from series"+fser );
-        olf[iolf]->xco = CCoord( "E", "ueV" );
-        olf[iolf]->yco = CCoord( "cts", "sec-1" );
-        olf[iolf]->ZCo.push_back( CCoord( "#sub", "") );
-        olf[iolf]->ZCo.push_back( CCoord( "det", "") );
+    for (iolf = 0; iolf < 2; ++iolf) {
+        olf[iolf]->log_action("acquire data from series" + fser);
+        olf[iolf]->xco = CCoord("E", "ueV");
+        olf[iolf]->yco = CCoord("cts", "sec-1");
+        olf[iolf]->ZCo.push_back(CCoord("#sub", ""));
+        olf[iolf]->ZCo.push_back(CCoord("det", ""));
     }
-    triv::fname_divide( fser, 0, &name, 0 );
+    triv::fname_divide(fser, 0, &name, 0);
     olf[0]->name = name;
-    olf[1]->name = name+"open";
-    olf[0]->log_action( "refl, average over both halfspaces" );
-    olf[1]->log_action( "open, average over both halfspaces" );
+    olf[1]->name = name + "open";
+    olf[0]->log_action("refl, average over both halfspaces");
+    olf[1]->log_action("open, average over both halfspaces");
 
 
-    for( isub=0; isub<nsub; ++isub ){
+    for (isub = 0; isub < nsub; ++isub) {
         // ? = (double)RR[isub].measured_at/3600;
-        for( j=0; j<ndet; ++j ){
-            PSpec s( new CSpec );
-            s->z.resize( 2 );
-            s->z[0] = PObjInt( new CObjInt (isub) );
-            s->z[1] = PObjInt( new CObjInt (j) );
-            for( iolf=0; iolf<2; ++iolf )
-                olf[iolf]->V.push_back( move(s) );
+        for (j = 0; j < ndet; ++j) {
+            PSpec s(new CSpec);
+            s->z.resize(2);
+            s->z[0] = PObjInt(new CObjInt(isub));
+            s->z[1] = PObjInt(new CObjInt(j));
+            for (iolf = 0; iolf < 2; ++iolf)
+                olf[iolf]->V.push_back(move(s));
         }
     }
 
-    if( RR[0].maj_outform>=3 ){
-        printf( "new format\n" );
-        nE = RR[0].rawdata[0].size()/(1+ndet*2);
+    if (RR[0].maj_outform >= 3) {
+        printf("new format\n");
+        nE = RR[0].rawdata[0].size() / (1 + ndet * 2);
         // Reverse incrementation?
-        if( incremental_in ){
-            printf( "reversing incrementation\n" );
-            for( isub=nsub-1; isub>=1; --isub ){
-                for( int iarr=0; iarr<4; ++iarr ){
-                    for( int iE=0; iE<nE; ++iE ){
-                        for( j=1; j<1+ndet*2; ++j ){
-                            RR[isub].rawdata[iarr][iE*(1+ndet*2)+j] -=
-                                RR[isub-1].rawdata[iarr][iE*(1+ndet*2)+j];
+        if (incremental_in) {
+            printf("reversing incrementation\n");
+            for (isub = nsub - 1; isub >= 1; --isub) {
+                for (int iarr = 0; iarr < 4; ++iarr) {
+                    for (int iE = 0; iE < nE; ++iE) {
+                        for (j = 1; j < 1 + ndet * 2; ++j) {
+                            RR[isub].rawdata[iarr][iE * (1 + ndet * 2) + j] -=
+                                RR[isub - 1].rawdata[iarr][iE * (1 + ndet * 2) + j];
                         }
                     }
                 }
@@ -484,44 +484,46 @@ void NRSSM::read_series( int flag )
         }
 
         // Transfer data from raw arrays, sum over halfspaces:
-        vector<double> *raw;
+        vector<double>* raw;
         double x, tmeas, count;
         int iraw;
-        for( isub=0; isub<nsub; ++isub ){
+        for (isub = 0; isub < nsub; ++isub) {
             raw = RR[isub].rawdata;
-            for( int ichop=0; ichop<2; ++ichop ){
-                int iolf0 = ichop*2;
-                int iolf1 = ichop*2+1;
-                if( raw[iolf1].size()/(1+ndet*2)!=nE ){
-                    printf( "inconsistent raw array sizes:\n  chop %i raw1 %i nE %i\n",
-                            ichop, (int)raw[iolf1].size(), nE );
+            for (int ichop = 0; ichop < 2; ++ichop) {
+                int iolf0 = ichop * 2;
+                int iolf1 = ichop * 2 + 1;
+                if (raw[iolf1].size() / (1 + ndet * 2) != nE) {
+                    printf(
+                        "inconsistent raw array sizes:\n  chop %i raw1 %i nE %i\n", ichop,
+                        (int)raw[iolf1].size(), nE);
                     return;
                 }
-                for( int iE=0; iE<nE; ++iE ){
-                    iraw = iE*(1+ndet*2);
+                for (int iE = 0; iE < nE; ++iE) {
+                    iraw = iE * (1 + ndet * 2);
                     x = raw[iolf0][iraw];
-                    for( j=0; j<ndet; ++j ){
-                        tmeas = raw[iolf0][iraw+ndet+1+j] + raw[iolf1][iraw+ndet+1+j];
-                        if( tmeas<1 ) continue;
-                        count = raw[iolf0][iraw+1+j] + raw[iolf1][iraw+1+j];
-                        olf[ichop]->VS( isub*ndet+j )->push_xy( x, count/tmeas/tstep );
+                    for (j = 0; j < ndet; ++j) {
+                        tmeas = raw[iolf0][iraw + ndet + 1 + j] + raw[iolf1][iraw + ndet + 1 + j];
+                        if (tmeas < 1)
+                            continue;
+                        count = raw[iolf0][iraw + 1 + j] + raw[iolf1][iraw + 1 + j];
+                        olf[ichop]->VS(isub * ndet + j)->push_xy(x, count / tmeas / tstep);
                     }
                 }
             }
         }
 
     } else {
-        printf( "old format\n" );
-        nE = RR[0].rawdata[0].size()/(ndet+2);
+        printf("old format\n");
+        nE = RR[0].rawdata[0].size() / (ndet + 2);
         // Reverse incrementation?
-        if( incremental_in ){
-            printf( "reversing incrementation\n" );
-            for( isub=nsub-1; isub>=1; --isub ){
-                for( int iarr=0; iarr<4; ++iarr ){
-                    for( int iE=0; iE<nE; ++iE ){
-                        for( j=1; j<ndet+2; ++j ){
-                            RR[isub].rawdata[iarr][iE*(ndet+2)+j] -=
-                                RR[isub-1].rawdata[iarr][iE*(ndet+2)+j];
+        if (incremental_in) {
+            printf("reversing incrementation\n");
+            for (isub = nsub - 1; isub >= 1; --isub) {
+                for (int iarr = 0; iarr < 4; ++iarr) {
+                    for (int iE = 0; iE < nE; ++iE) {
+                        for (j = 1; j < ndet + 2; ++j) {
+                            RR[isub].rawdata[iarr][iE * (ndet + 2) + j] -=
+                                RR[isub - 1].rawdata[iarr][iE * (ndet + 2) + j];
                         }
                     }
                 }
@@ -529,36 +531,37 @@ void NRSSM::read_series( int flag )
         }
 
         // Transfer data from raw arrays, sum over halfspaces:
-        vector<double> *raw;
+        vector<double>* raw;
         double x, tmeas, count;
         int iraw;
-        for( isub=0; isub<nsub; ++isub ){
+        for (isub = 0; isub < nsub; ++isub) {
             raw = RR[isub].rawdata;
-            for( int ichop=0; ichop<2; ++ichop ){
-                int iolf0 = ichop*2;
-                int iolf1 = ichop*2+1;
-                if( raw[iolf1].size()/(ndet+2)!=nE ){
-                    printf( "inconsistent raw array sizes\n" );
+            for (int ichop = 0; ichop < 2; ++ichop) {
+                int iolf0 = ichop * 2;
+                int iolf1 = ichop * 2 + 1;
+                if (raw[iolf1].size() / (ndet + 2) != nE) {
+                    printf("inconsistent raw array sizes\n");
                     return;
                 }
-                for( int iE=0; iE<nE; ++iE ){
-                    iraw = iE*(ndet+2);
+                for (int iE = 0; iE < nE; ++iE) {
+                    iraw = iE * (ndet + 2);
                     x = raw[iolf0][iraw];
-                    tmeas = raw[iolf0][iraw+ndet+1]+raw[iolf1][iraw+ndet+1];
-                    if( tmeas<1 ) continue;
-                    for( j=0; j<ndet; ++j ){
-                        count = raw[iolf0][iraw+1+j] + raw[iolf1][iraw+1+j];
-                        olf[ichop]->VS( isub*ndet+j )->push_xy( x, count/tmeas/tstep );
+                    tmeas = raw[iolf0][iraw + ndet + 1] + raw[iolf1][iraw + ndet + 1];
+                    if (tmeas < 1)
+                        continue;
+                    for (j = 0; j < ndet; ++j) {
+                        count = raw[iolf0][iraw + 1 + j] + raw[iolf1][iraw + 1 + j];
+                        olf[ichop]->VS(isub * ndet + j)->push_xy(x, count / tmeas / tstep);
                     }
                 }
             }
         }
     }
 
-    if( flag & 1 ){
-        SMem::instance()->mem_store( move(olf[1]) );
+    if (flag & 1) {
+        SMem::instance()->mem_store(move(olf[1]));
     }
-    if( 1 ){
-        SMem::instance()->mem_store( move(olf[0]) );
+    if (1) {
+        SMem::instance()->mem_store(move(olf[0]));
     }
 }
diff --git a/pub/lib/rssm.hpp b/pub/lib/rssm.hpp
index edf68dd7be04ae011f7cba0140c7c5b08d0062fd..fba21d189e36b8d97f7d6dd34b0c28273ab05210 100644
--- a/pub/lib/rssm.hpp
+++ b/pub/lib/rssm.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                         
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  rssm.hpp
@@ -9,8 +9,9 @@
 
 //! Directly read SPHERES raw data.
 
-namespace NRSSM {
-    void read_spec( int flag );
-    void read_series( int flag );
-    void read_series_to_histogram( int flag );
+namespace NRSSM
+{
+void read_spec(int flag);
+void read_series(int flag);
+void read_series_to_histogram(int flag);
 }
diff --git a/pub/lib/slice.cpp b/pub/lib/slice.cpp
index 5337f5d01c1dbbdde370a60c112167b0de0a05f7..4ca860e4a4e623bd67f82599539e32f1fc908406 100644
--- a/pub/lib/slice.cpp
+++ b/pub/lib/slice.cpp
@@ -13,8 +13,8 @@
 
 #include "../trivia/vector_ops.hpp"
 
-#include "ptr.hpp"
 #include "obj.hpp"
+#include "ptr.hpp"
 #include "slice.hpp"
 
 
@@ -28,8 +28,8 @@
 vector<string> CSlice::z_str() const
 {
     vector<string> ret;
-    for( RObj zi: z )
-        ret.push_back( zi->to_s() );
+    for (RObj zi : z)
+        ret.push_back(zi->to_s());
     return ret;
 }
 
@@ -41,7 +41,7 @@ vector<string> CSlice::z_str() const
 
 //! Append given data point.
 
-void CSpec::push_xy( double _x, double _y )
+void CSpec::push_xy(double _x, double _y)
 {
     x.push_back(_x);
     y.push_back(_y);
@@ -50,9 +50,9 @@ void CSpec::push_xy( double _x, double _y )
 
 //! Append given data point, with error.
 
-void CSpec::push_xyd( double _x, double _y, double _dy )
+void CSpec::push_xyd(double _x, double _y, double _dy)
 {
-    if( y.size()!=dy.size() )
+    if (y.size() != dy.size())
         throw S("cannot push_xyd since y and dy have different size");
     x.push_back(_x);
     y.push_back(_y);
@@ -62,12 +62,12 @@ void CSpec::push_xyd( double _x, double _y, double _dy )
 
 //! Remove data points according to given indices.
 
-void CSpec::remove( int from, int to )
+void CSpec::remove(int from, int to)
 {
-    x.erase( x.begin()+from, x.begin()+to );
-    y.erase( y.begin()+from, y.begin()+to );
-    if( has_dy() )
-        dy.erase( dy.begin()+from, dy.begin()+to );
+    x.erase(x.begin() + from, x.begin() + to);
+    y.erase(y.begin() + from, y.begin() + to);
+    if (has_dy())
+        dy.erase(dy.begin() + from, dy.begin() + to);
 }
 
 
@@ -84,11 +84,12 @@ void CSpec::clear()
 
 //! Resize x,y,dy.
 
-void CSpec::resize( int n, bool with_dy )
+void CSpec::resize(int n, bool with_dy)
 {
-    x.resize( n );
-    y.resize( n );
-    if( with_dy ) dy.resize( n );
+    x.resize(n);
+    y.resize(n);
+    if (with_dy)
+        dy.resize(n);
 }
 
 
@@ -96,47 +97,48 @@ void CSpec::resize( int n, bool with_dy )
 
 int CSpec::size() const
 {
-    if ( x.size()!=y.size() )
+    if (x.size() != y.size())
         throw "BUG detected by spec::size: #x [" + S(x.size()) + "] <> #y [" + S(y.size()) + "]\n";
-    if ( dy.size()!=y.size() && has_dy() )
-        throw "BUG detected by spec::size: #y [" + S(y.size()) + "] <> #dy [" + S(dy.size()) + "]\n";
+    if (dy.size() != y.size() && has_dy())
+        throw "BUG detected by spec::size: #y [" + S(y.size()) + "] <> #dy [" + S(dy.size())
+            + "]\n";
     return y.size();
 }
 
 
 //! For each xx[i], set yy[i] by interpolating in this.x -> this.y.
 
-void CSpec::intpol( const vector<double>& xx, vector<double>* yy, vector<double>* dd ) const
+void CSpec::intpol(const vector<double>& xx, vector<double>* yy, vector<double>* dd) const
 {
     int n = size();
-    if( n<2 )
+    if (n < 2)
         throw "invalid interpolation request: old grid has size " + S(n);
     int nn = xx.size();
-    if( nn<1 )
+    if (nn < 1)
         throw S("invalid interpolation request: new grid is empty");
-    yy->resize( nn, 0. );
-    if( dd )
-        dd->resize( nn, 0. );
+    yy->resize(nn, 0.);
+    if (dd)
+        dd->resize(nn, 0.);
 
-    if( !triv::is_ascending(x) )
+    if (!triv::is_ascending(x))
         throw S("cannot interpolate: old grid not sorted");
-    if( !triv::is_ascending(xx) )
+    if (!triv::is_ascending(xx))
         throw S("cannot interpolate: new grid not sorted");
 
-    if( n==nn ) { // test for equality
-        double span = x[n-1] - x[0];
-        for( int i=0; i<n; ++i ) {
-            if ( fabs(x[i]-xx[i])>1e-14*span )
+    if (n == nn) { // test for equality
+        double span = x[n - 1] - x[0];
+        for (int i = 0; i < n; ++i) {
+            if (fabs(x[i] - xx[i]) > 1e-14 * span)
                 goto scales_differ;
         }
-        for( int i=0; i<n; ++i ) {
+        for (int i = 0; i < n; ++i) {
             (*yy)[i] = y[i];
-            if( dd )
+            if (dd)
                 (*dd)[i] = dy[i];
         }
         return;
     }
- scales_differ:
+scales_differ:
 
     /*
     if( strict && ( xx[0]<x[0] || xx[nn-1]>x[n-1] ) )
@@ -144,32 +146,33 @@ void CSpec::intpol( const vector<double>& xx, vector<double>* yy, vector<double>
             " required, while available data only cover "+S(x[0])+" .. "+S(x[n-1]);
     */
 
-    for( int ii=0; ii<nn; ++ii ) {
+    for (int ii = 0; ii < nn; ++ii) {
         (*yy)[ii] = 0;
-        if(dd)
+        if (dd)
             (*dd)[ii] = 0;
     }
     int i = 0, ii = 0;
-    while( xx[ii]<x[0] ) {
+    while (xx[ii] < x[0]) {
         ++ii;
-        if( ii>=nn )
+        if (ii >= nn)
             return;
     }
-    while ( i<n-1 && xx[ii]<x[n-1] ) {
-        while ( xx[ii]>x[i+1] && i<n-1 )
+    while (i < n - 1 && xx[ii] < x[n - 1]) {
+        while (xx[ii] > x[i + 1] && i < n - 1)
             ++i;
-        if( i>=n-1 )
+        if (i >= n - 1)
             break;
-        if( ii>=nn )
+        if (ii >= nn)
             return;
-        (*yy)[ii] = ( (x[i+1]-xx[ii])*y[i] + (xx[ii]-x[i])*y[i+1] )/(x[i+1]-x[i]);
-        //std::cout << "DEBUG INTPOL i=" << i << " ii=" << ii << " x=" << x[i] << ".." << x[i+1] <<
+        (*yy)[ii] = ((x[i + 1] - xx[ii]) * y[i] + (xx[ii] - x[i]) * y[i + 1]) / (x[i + 1] - x[i]);
+        // std::cout << "DEBUG INTPOL i=" << i << " ii=" << ii << " x=" << x[i] << ".." << x[i+1] <<
         //    " xx=" << xx[ii] << " y=" << y[i] << ".." << y[i+1] << " -> " << (*yy)[ii] << "\n";
-        if( dd ) {
-            double genus = ( (x[i+1]-xx[ii])*SQR(dy[i]) + (xx[ii]-x[i])*SQR(dy[i+1]) ) / (x[i+1]-x[i]);
-            if ( genus< 0 )
+        if (dd) {
+            double genus = ((x[i + 1] - xx[ii]) * SQR(dy[i]) + (xx[ii] - x[i]) * SQR(dy[i + 1]))
+                / (x[i + 1] - x[i]);
+            if (genus < 0)
                 throw "interpolation failed: variance<0";
-            (*dd)[ii] = sqrt( genus );
+            (*dd)[ii] = sqrt(genus);
         }
         ++ii;
     }
@@ -177,46 +180,46 @@ void CSpec::intpol( const vector<double>& xx, vector<double>* yy, vector<double>
 
 //! Compute norm (trapezoidal sum?).
 
-double CSpec::norm( string info ) const
+double CSpec::norm(string info) const
 {
     int nv = size();
-    if ( nv < 2 )
+    if (nv < 2)
         throw "cannot compute norm of " + info + ": only " + S(nv) + " points";
     // Calculate normalization integral.
     // At this occasion, assert that x is ordered,
     double ret = 0;
     // special treatment for first and last step:
     double dx = x[1] - x[0];
-    if ( dx <= 0 )
+    if (dx <= 0)
         throw "cannot compute norm of " + info + ": not ordered in x";
     ret += y[0] * dx;
-    dx = x[nv-1] - x[nv-2];
-    if ( dx <= 0 )
+    dx = x[nv - 1] - x[nv - 2];
+    if (dx <= 0)
         throw "cannot compute norm of " + info + ": not ordered in x";
-    ret += y[nv-1] * dx;
+    ret += y[nv - 1] * dx;
     // the other steps:
-    for( int i=1; i<nv-1; ++i ) {
-        dx = ( x[i+1] - x[i-1] ) / 2;
-        if ( dx <= 0 )
+    for (int i = 1; i < nv - 1; ++i) {
+        dx = (x[i + 1] - x[i - 1]) / 2;
+        if (dx <= 0)
             throw "cannot compute norm of " + info + ": not ordered in x";
         ret += y[i] * dx;
     }
     // check result:
-    if      ( ret == 0 )
+    if (ret == 0)
         throw "norm of " + info + " is zero";
-    else if ( ret <= 0 )
+    else if (ret <= 0)
         throw "norm of " + info + " is negativ";
     return ret;
 }
 
 //! Is x equidistant with a given step?
 
-bool CSpec::has_step( double step ) const
+bool CSpec::has_step(double step) const
 {
-    if( !step )
+    if (!step)
         return false;
-    for( int i=0; i<size()-1; ++i ) {
-        if( fabs(x[i+1]-x[i]-step)>1e-12*step )
+    for (int i = 0; i < size() - 1; ++i) {
+        if (fabs(x[i + 1] - x[i] - step) > 1e-12 * step)
             return false;
     }
     return true;
@@ -226,13 +229,13 @@ bool CSpec::has_step( double step ) const
 
 string CSpec::info_line() const
 {
-    const int LEN=15;
+    const int LEN = 15;
     char wrd[LEN];
     string out = "";
-    for ( int iz=0; iz<z.size(); iz++ ) {
-        snprintf( wrd, LEN, "%-13.6g", z[iz]->to_r() );
+    for (int iz = 0; iz < z.size(); iz++) {
+        snprintf(wrd, LEN, "%-13.6g", z[iz]->to_r());
         out += wrd;
-        if( iz<z.size()-1 )
+        if (iz < z.size() - 1)
             out += " ";
     }
     return out;
@@ -242,36 +245,36 @@ string CSpec::info_line() const
 
 bool CSpec::has_nonzero_dy() const
 {
-    if( !has_dy() )
+    if (!has_dy())
         return false;
-    return std::all_of( dy.cbegin(), dy.cend(), [](double dv){ return dv>0; } );
+    return std::all_of(dy.cbegin(), dy.cend(), [](double dv) { return dv > 0; });
 }
 
-PSpec CSpec::binned( const vector<int>& breaks ) const
+PSpec CSpec::binned(const vector<int>& breaks) const
 {
-    PSpec sout( new CSpec() );
+    PSpec sout(new CSpec());
     sout->z = z;
-    for ( int iv=0; iv<breaks.size()-1; ++iv ) {
+    for (int iv = 0; iv < breaks.size() - 1; ++iv) {
         int igi = breaks[iv];
-        int igf = breaks[iv+1];
+        int igf = breaks[iv + 1];
         double xg = 0, yg = 0;
         int ng = igf - igi;
-        for ( int i=igi; i<igf; ++i ) {
+        for (int i = igi; i < igf; ++i) {
             xg += x[i];
             yg += y[i];
         }
         xg /= ng;
         yg /= ng;
         double vg_src = 0, vg_grp = 0;
-        for ( int i=igi; i<igf; ++i ) {
-            if ( has_dy() )
-                vg_src += SQR( dy[i] );
-            vg_grp += SQR( y[i]-yg );
+        for (int i = igi; i < igf; ++i) {
+            if (has_dy())
+                vg_src += SQR(dy[i]);
+            vg_grp += SQR(y[i] - yg);
         }
-        double vg = vg_src/ng/ng;
-        if( ng>1 )
-            vg += vg_grp / (ng-1);
-        sout->push_xyd(xg, yg, sqrt(vg) );
+        double vg = vg_src / ng / ng;
+        if (ng > 1)
+            vg += vg_grp / (ng - 1);
+        sout->push_xyd(xg, yg, sqrt(vg));
     }
     return sout;
 }
@@ -294,17 +297,17 @@ void CCurve::clear_fit_outcome()
 
 void CCurve::assert_attr() const
 {
-    for ( int ip=0; ip<P.size(); ip++ )
-        if( ! (ParAttr[ip]=='u' || ParAttr[ip]=='x' || ParAttr[ip]=='g') )
-            throw "BUG: ParAttr has invalid value '"+S(ParAttr[ip])+"'";
+    for (int ip = 0; ip < P.size(); ip++)
+        if (!(ParAttr[ip] == 'u' || ParAttr[ip] == 'x' || ParAttr[ip] == 'g'))
+            throw "BUG: ParAttr has invalid value '" + S(ParAttr[ip]) + "'";
 }
 
 //! Returns true if there is at least one global parameter.
 
 bool CCurve::has_global_par() const
 {
-    for( char c: ParAttr )
-        if( c=='g' )
+    for (char c : ParAttr)
+        if (c == 'g')
             return true;
     return false;
 }
@@ -313,27 +316,27 @@ bool CCurve::has_global_par() const
 
 string CCurve::info_line() const
 {
-    const int LEN=15;
+    const int LEN = 15;
     char wrd[LEN];
     string out = "";
-    for ( int iz=0; iz<z.size(); iz++ ) {
-        snprintf( wrd, LEN, "%-13.6g", z[iz]->to_r() );
+    for (int iz = 0; iz < z.size(); iz++) {
+        snprintf(wrd, LEN, "%-13.6g", z[iz]->to_r());
         out += wrd;
         out += " ";
     }
     assert_attr();
-    for ( int ip=0; ip<P.size(); ip++ ) {
-        out += (ParAttr[ip]=='u') ? ' ' : ParAttr[ip];
-        snprintf( wrd, LEN, "%-13.6g", P[ip] );
+    for (int ip = 0; ip < P.size(); ip++) {
+        out += (ParAttr[ip] == 'u') ? ' ' : ParAttr[ip];
+        snprintf(wrd, LEN, "%-13.6g", P[ip]);
         out += wrd;
-        if( ip<P.size()-1 )
+        if (ip < P.size() - 1)
             out += " ";
     }
-    snprintf( wrd, LEN, "%-2i ", fitOutcome );
+    snprintf(wrd, LEN, "%-2i ", fitOutcome);
     out += wrd;
-    snprintf( wrd, LEN, "%-12.6g", fitChi2 );
+    snprintf(wrd, LEN, "%-12.6g", fitChi2);
     out += wrd;
-    snprintf( wrd, LEN, "%-12.6g", 1-fitR2 );
+    snprintf(wrd, LEN, "%-12.6g", 1 - fitR2);
     out += wrd;
     return out;
 }
diff --git a/pub/lib/slice.hpp b/pub/lib/slice.hpp
index bcfe48caa5737d4eadf0edebef05f4c57d8899c0..527eb889c7a830ced2c140796fe4012635773910 100644
--- a/pub/lib/slice.hpp
+++ b/pub/lib/slice.hpp
@@ -10,8 +10,9 @@
 
 //! Virtual base class for CSpec and CCurve. Holds z dependent data.
 
-class CSlice {
- public:
+class CSlice
+{
+public:
     vector<RObj> z;
     bool frozen;
 
@@ -24,36 +25,38 @@ class CSlice {
 
 //! A CSlice within a data file, holds a x-y-dy data set.
 
-class CSpec: public CSlice {
- public:
+class CSpec : public CSlice
+{
+public:
     vector<double> x, y, dy;
 
     // modify:
-    void push_xy ( double _x, double _y );
-    void push_xyd( double _x, double _y, double _dy );
+    void push_xy(double _x, double _y);
+    void push_xyd(double _x, double _y, double _dy);
     void clear();
-    void remove( int begin, int end );
-    void resize( int n, bool with_dy );
+    void remove(int begin, int end);
+    void resize(int n, bool with_dy);
 
     // extract data:
     int size() const;
-    void intpol( const vector<double>& in_x, vector<double>* out_y, vector<double>* out_dy ) const;
-    double norm( string info ) const;
-    bool has_step( double step ) const;
+    void intpol(const vector<double>& in_x, vector<double>* out_y, vector<double>* out_dy) const;
+    double norm(string info) const;
+    bool has_step(double step) const;
     string info_line() const;
-    inline bool has_dy() const { return dy.size()!=0; }
+    inline bool has_dy() const { return dy.size() != 0; }
     bool has_nonzero_dy() const;
-    PSpec binned( const vector<int>& breaks ) const;
+    PSpec binned(const vector<int>& breaks) const;
 };
 
 
 //! A CSlice within a curve file, holds parameters and fit outcome.
 
-class CCurve: public CSlice {
- public:
+class CCurve : public CSlice
+{
+public:
     vector<double> P;
-    vector<char>   ParAttr;
-    int    fitOutcome;
+    vector<char> ParAttr;
+    int fitOutcome;
     double fitChi2;
     double fitR2;
 
diff --git a/pub/lib/special.cpp b/pub/lib/special.cpp
index 2e14e2095d90b7c10e9237c77e49900e18f04e26..cf8eba150c371b191203fbd038e3c0f6e71ebde9 100644
--- a/pub/lib/special.cpp
+++ b/pub/lib/special.cpp
@@ -13,19 +13,20 @@
 #include <fftw3.h>
 
 
-#include "olf.hpp"
-#include "mem.hpp"
 #include "fsel.hpp"
 #include "loop.hpp"
+#include "mem.hpp"
 #include "obj.hpp"
+#include "olf.hpp"
 #include "slice.hpp"
 #include "special.hpp"
 
-namespace NSpecial {
-    void q_eval( double *par, int m_dat, double *fvec, void *data, int *info);
-    void lm_print(int n_par, double *par, int m_dat, double *fvec,
-                  void *data, int iflag, int iter, int nfev);
-    double q_kernel( double t, double *p );
+namespace NSpecial
+{
+void q_eval(double* par, int m_dat, double* fvec, void* data, int* info);
+void lm_print(
+    int n_par, double* par, int m_dat, double* fvec, void* data, int iflag, int iter, int nfev);
+double q_kernel(double t, double* p);
 }
 
 void NSpecial::FourierCosine()
@@ -34,36 +35,34 @@ void NSpecial::FourierCosine()
     int n;
 
     FileIterator fiter(SFSel::instance()->selD());
-    while( const COld *fin = fiter.nextD() ) {
-        POld fout( fin->new_POld() );
+    while (const COld* fin = fiter.nextD()) {
+        POld fout(fin->new_POld());
         fout->log_action("Fourier Cosine");
 
         cout << "WARNING: coordinates not changed\n";
         cout << "WARNING: x not changed\n";
         cout << "WARNING: dy not calculated\n";
         // *** set coordinates ***
-//                olf.xco = CCoord("z", "m");
-//                olf.yco = CCoord("B_dim", "B-unit");
+        //                olf.xco = CCoord("z", "m");
+        //                olf.yco = CCoord("B_dim", "B-unit");
 
-        for ( int j=0; j<fin->nJ(); j++ ) {
+        for (int j = 0; j < fin->nJ(); j++) {
             CSpec* sin = fin->VS(j);
-            PSpec sout( new CSpec( *sin ) );
+            PSpec sout(new CSpec(*sin));
 
             n = sin->size();
 
-            plan = fftw_plan_r2r_1d(
-                n, &(sin->y[0]), &(sout->y[0]),
-                FFTW_REDFT00,  FFTW_ESTIMATE);
-            fftw_execute( plan );
+            plan = fftw_plan_r2r_1d(n, &(sin->y[0]), &(sout->y[0]), FFTW_REDFT00, FFTW_ESTIMATE);
+            fftw_execute(plan);
 
             sout->dy.clear();
-            for ( int i=0; i<n; ++i ) {
-                sout->y[i] /= sqrt(2.*n);
+            for (int i = 0; i < n; ++i) {
+                sout->y[i] /= sqrt(2. * n);
             }
 
-            fout->V.push_back( move(sout) );
+            fout->V.push_back(move(sout));
         }
-        SMem::instance()->mem_store( move(fout) );
+        SMem::instance()->mem_store(move(fout));
     }
 }
 
@@ -71,30 +70,30 @@ void NSpecial::Test()
 {
     // relative error in form factor
 
-    POld fout( new COld );
+    POld fout(new COld);
 
     fout->name = "TEST_";
     fout->xco = CCoord("a", "");
     fout->yco = CCoord("FF", "");
-    fout->ZCo.push_back( CCoord("b", "") );
+    fout->ZCo.push_back(CCoord("b", ""));
 
     static int Nj = 100;
     static int Ni = 1000;
-    
-    for ( int j=0; j<Nj; ++j ){
-        double b = pow( 1.5, j-Nj );
-        PSpec s( new CSpec );
-        s->z.push_back( PObjDbl( new CObjDbl (b) ) );
-        s->resize(Ni,false);
-        for ( int i=0; i<Ni; ++i ){
-            double a = b + pow( 1.2, i-Ni );
+
+    for (int j = 0; j < Nj; ++j) {
+        double b = pow(1.5, j - Nj);
+        PSpec s(new CSpec);
+        s->z.push_back(PObjDbl(new CObjDbl(b)));
+        s->resize(Ni, false);
+        for (int i = 0; i < Ni; ++i) {
+            double a = b + pow(1.2, i - Ni);
             s->x[i] = a;
-            complex<long double> ff1 = ff_test( (long double) a, (long double) b );
-            complex<double> ff2 = ff_test( a, b );
+            complex<long double> ff1 = ff_test((long double)a, (long double)b);
+            complex<double> ff2 = ff_test(a, b);
             complex<double> diff = (complex<double>)(ff1)-ff2;
-            s->y[i] = std::abs(diff)/std::abs(ff1);
+            s->y[i] = std::abs(diff) / std::abs(ff1);
         }
-        fout->V.push_back( move(s) );
+        fout->V.push_back(move(s));
     }
-    SMem::instance()->mem_store( move(fout) );
+    SMem::instance()->mem_store(move(fout));
 }
diff --git a/pub/lib/special.hpp b/pub/lib/special.hpp
index d23bff9c1e026734a1dad2fde99d181b2c685ddf..66bd960996d7c3c723ec674bc40e3b0ea7be0393 100644
--- a/pub/lib/special.hpp
+++ b/pub/lib/special.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                         
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  special.hpp
@@ -13,23 +13,22 @@
 using std::complex;
 
 
-namespace NSpecial {
-    void FourierCosine();
-    void Test();
+namespace NSpecial
+{
+void FourierCosine();
+void Test();
 
-    template<typename T>
-    complex<T> pssc( T z )
-    {
-        complex<T> ci( 0.L, 1.L );
-        complex<T> cone( 1.L, 0.L );
-        return z==0 ? -ci : (cone-std::exp(ci*z))/z;
-//        T z2 = z / (T)(2.L);
-//        return -ci * std::sin(z2) / (z2) * std::exp(ci*z2);
-    }
+template <typename T> complex<T> pssc(T z)
+{
+    complex<T> ci(0.L, 1.L);
+    complex<T> cone(1.L, 0.L);
+    return z == 0 ? -ci : (cone - std::exp(ci * z)) / z;
+    //        T z2 = z / (T)(2.L);
+    //        return -ci * std::sin(z2) / (z2) * std::exp(ci*z2);
+}
 
-    template<typename T>
-    complex<T> ff_test( T a, T b )
-    {
-        return complex<T>(T(1.L)/b,T(0.L)) * ( pssc(a+b) - pssc(a-b) );
-    }    
+template <typename T> complex<T> ff_test(T a, T b)
+{
+    return complex<T>(T(1.L) / b, T(0.L)) * (pssc(a + b) - pssc(a - b));
+}
 }
diff --git a/pub/lib/toplevel.cpp b/pub/lib/toplevel.cpp
index 73dae4aaeaa27710c7ca254d607efcf3fe40e7bf..98ce612ee6d8eecfb1278cdc0ad35deb3d6558af 100644
--- a/pub/lib/toplevel.cpp
+++ b/pub/lib/toplevel.cpp
@@ -12,23 +12,23 @@
 #include <fstream>
 #include <gsl/gsl_errno.h>
 
-#include "../trivia/vector_ops.hpp"
+#include "../plot/plowin.hpp"
 #include "../readplus/macro.hpp"
 #include "../readplus/readln.hpp"
-#include "../plot/plowin.hpp"
+#include "../trivia/vector_ops.hpp"
 
-#include "toplevel.hpp"
-#include "olf.hpp"
-#include "obj.hpp"
-#include "mem.hpp"
+#include "commands.hpp"
+#include "expr.hpp"
 #include "fsel.hpp"
-#include "loop.hpp"
-#include "variables.hpp"
 #include "func.hpp"
-#include "reduce_spec.hpp"
+#include "loop.hpp"
+#include "mem.hpp"
+#include "obj.hpp"
+#include "olf.hpp"
 #include "reduce_curv.hpp"
-#include "commands.hpp"
-#include "expr.hpp"
+#include "reduce_spec.hpp"
+#include "toplevel.hpp"
+#include "variables.hpp"
 #include "xax_lex.hpp"
 
 // Declarations.
@@ -43,78 +43,77 @@ void fstring_initialize(); // implemented in fstring.cpp; no .hpp file
 
 //! Error handler for C code from the GNU Scientific Library.
 
-void my_gsl_error_handler ( const char * reason, const char *file, int line, int gsl_errno )
+void my_gsl_error_handler(const char* reason, const char* file, int line, int gsl_errno)
 {
-    cout<<"GSL error "<<gsl_errno<<": "<<reason<<" in "<<file<<", line "<<line<<"\n";
+    cout << "GSL error " << gsl_errno << ": " << reason << " in " << file << ", line " << line
+         << "\n";
     // throw does not work (probably because GSL is in C, not in C++)
 }
 
 
 //! At exit, currently nothing to do.
 
-void atexit_handler()
-{
-}
+void atexit_handler() {}
 
 
 //! Executes one Frida command.
 
-void CFrida::execute_cmd( const string cmdline )
+void CFrida::execute_cmd(const string cmdline)
 {
     // Empty input, comment lines.
-    if ( cmdline=="" || cmdline[0]=='#' ) {
+    if (cmdline == "" || cmdline[0] == '#') {
         return;
     }
 
-    string::size_type j = cmdline.find_first_of( " \t" );
-    if ( j!=string::npos )
-        NMacro::push_remainder( cmdline.substr(j) );
-    string cmd = cmdline.substr( 0, j );
+    string::size_type j = cmdline.find_first_of(" \t");
+    if (j != string::npos)
+        NMacro::push_remainder(cmdline.substr(j));
+    string cmd = cmdline.substr(0, j);
 
     // function keys (TEMPORARY WORKAROUND)
-    if (cmd.substr(0,2)=="FK" && cmd.find("=")==string::npos) {
-        PObj ret = SVariRegistry::instance()->find( cmd );
-        if ( !ret )
-            throw "uninitialized function key "+cmd;
+    if (cmd.substr(0, 2) == "FK" && cmd.find("=") == string::npos) {
+        PObj ret = SVariRegistry::instance()->find(cmd);
+        if (!ret)
+            throw "uninitialized function key " + cmd;
         cmd = ret->to_s();
     }
 
     // Is it a command?
     clock_cmd_i = clock();
     if (cmd == "t") {
-        double time_total = ((double) (clock() - clock_start)) / CLOCKS_PER_SEC;
-        printf( "total frida CPU time now %g\n", time_total );
-        printf( "last command took %g\n", time_cmd );
+        double time_total = ((double)(clock() - clock_start)) / CLOCKS_PER_SEC;
+        printf("total frida CPU time now %g\n", time_total);
+        printf("last command took %g\n", time_cmd);
         return;
-    } else if ( frida_command( cmd ) ) {
+    } else if (frida_command(cmd)) {
         ;
     } else {
-        RNode T = user_xaxparse( cmd.c_str() );
-        if ( cmd[0]!='(' && T->looks_like_indices() ) {
-            RObjVecInt v = T->to_index_list( SMem::instance()->mem_size() );
+        RNode T = user_xaxparse(cmd.c_str());
+        if (cmd[0] != '(' && T->looks_like_indices()) {
+            RObjVecInt v = T->to_index_list(SMem::instance()->mem_size());
             if (!v)
                 throw S("not a valid index list");
-            SFSel::instance()->set_selection( v );
+            SFSel::instance()->set_selection(v);
         } else {
             // Pocket calculator
-            if( T->has_dummy() )
+            if (T->has_dummy())
                 throw S("dummy argument t not allowed outside curve definitions");
-            if( T->k_dependent() ) {
+            if (T->k_dependent()) {
                 FileIterator fiter(SFSel::instance()->sel());
-                while ( (fiter.next()) ) {
+                while ((fiter.next())) {
                     int k = fiter.k();
-                    if ( fiter.size()>1 )
-                        cout << "f" << k <<":";
-                    cout << T->tree_point_val( k )->to_s() << "\n";
+                    if (fiter.size() > 1)
+                        cout << "f" << k << ":";
+                    cout << T->tree_point_val(k)->to_s() << "\n";
                 }
             } else {
                 RObj ret = T->tree_point_val();
-                if( !CNode::eval( "defined (\"$silent\")" )->to_b() && ret->to_s() != "__nullptr__" )
+                if (!CNode::eval("defined (\"$silent\")")->to_b() && ret->to_s() != "__nullptr__")
                     cout << ret->to_s() << "\n";
             }
         }
     }
-    time_cmd = ((double) (clock() - clock_cmd_i)) / CLOCKS_PER_SEC;
+    time_cmd = ((double)(clock() - clock_cmd_i)) / CLOCKS_PER_SEC;
 }
 
 
@@ -129,21 +128,21 @@ CFrida::CFrida()
     // Initializations:
     NReadln::initialize(); // command-line dialog (readline and history)
     SPloWin::initialize(); // plot windows
-    gsl_set_error_handler( my_gsl_error_handler );
+    gsl_set_error_handler(my_gsl_error_handler);
     fbase_initialize();
     fassign_initialize();
     fstring_initialize();
     SGeniRegistry::initialize();
     SCvinRegistry::initialize();
 
-    if( std::atexit( atexit_handler ) ) {
+    if (std::atexit(atexit_handler)) {
         cout << "BUG: atexit registration failed\n";
         exit(EXIT_FAILURE);
     }
     // time monitor:
     clock_start = clock();
     clock_cmd_i = clock();
-    time_cmd=0;
+    time_cmd = 0;
 }
 
 
@@ -151,22 +150,22 @@ CFrida::CFrida()
 
 void CFrida::interactive()
 {
-    while(1) {
+    while (1) {
         string cmdline;
-        try{
-            cmdline = NMacro::readln( triv::indices_to_s(SFSel::instance()->sel()) + " > " );
-            execute_cmd( cmdline );
-        } catch( string& ex ) {
+        try {
+            cmdline = NMacro::readln(triv::indices_to_s(SFSel::instance()->sel()) + " > ");
+            execute_cmd(cmdline);
+        } catch (string& ex) {
             cout << "'" << cmdline << "' failed:\n  " << ex << "\n";
             NMacro::clear();
-        } catch( const char* ex ) {
+        } catch (const char* ex) {
             cout << "BUG: '" << cmdline << "' failed with unforeseen message:\n  " << ex << "\n";
             NMacro::clear();
-        } catch( std::exception& ex ) {
-            cout << "BUG: '" << cmdline << "' failed with unforeseen std exception:\n  " <<
-                ex.what() << "\n";
+        } catch (std::exception& ex) {
+            cout << "BUG: '" << cmdline << "' failed with unforeseen std exception:\n  "
+                 << ex.what() << "\n";
             NMacro::clear();
-        } catch( ... ) {
+        } catch (...) {
             cout << "BUG: '" << cmdline << "' failed with unforeseen exception\n";
             NMacro::clear();
         }
@@ -176,28 +175,28 @@ void CFrida::interactive()
 
 //! Reads a script file and executes it line by line.
 
-void CFrida::execute_file( const string fnam )
+void CFrida::execute_file(const string fnam)
 {
     int lineno = 0;
-    try{
+    try {
         cout << "executing " << fnam << "\n";
-        std::ifstream F( fnam );
-        while( true ) {
-            string cmdline = NMacro::readln( "", &F, &lineno );
-            if ( cmdline=="EOF" )
+        std::ifstream F(fnam);
+        while (true) {
+            string cmdline = NMacro::readln("", &F, &lineno);
+            if (cmdline == "EOF")
                 break;
             try {
-                execute_cmd( cmdline );
-            } catch( string& ex ) {
+                execute_cmd(cmdline);
+            } catch (string& ex) {
                 throw "'" + cmdline + "':\n  " + ex;
             }
         }
-    } catch( string& ex ) {
+    } catch (string& ex) {
         cout << "Error in script " << fnam << ", line " << lineno << ":\n  " << ex << "\n";
-    } catch( const char* ex ) {
-        cout << "BUG: char* error in script " << fnam << ", line " << lineno << ":\n  " <<
-            ex << "\n";
-    } catch( ... ) {
+    } catch (const char* ex) {
+        cout << "BUG: char* error in script " << fnam << ", line " << lineno << ":\n  " << ex
+             << "\n";
+    } catch (...) {
         cout << "BUG: catched invalid exception\n";
     }
 }
diff --git a/pub/lib/toplevel.hpp b/pub/lib/toplevel.hpp
index 3f5fdda0456af6e1cc9dcfa4156012eccba3506b..1e2fffcd347adeef1652746367552ad07056241d 100644
--- a/pub/lib/toplevel.hpp
+++ b/pub/lib/toplevel.hpp
@@ -10,16 +10,18 @@
 
 //! Execution context.
 
-class CFrida {
- private:
-    void execute_cmd( const std::string cmdline );
+class CFrida
+{
+private:
+    void execute_cmd(const std::string cmdline);
     // Time spent in frida, for optimizing numerical routines:
     clock_t clock_start;
     clock_t clock_cmd_i;
     double time_cmd;
- public:
+
+public:
     CFrida();
     static std::string prompt();
-    void execute_file( const std::string fname );
+    void execute_file(const std::string fname);
     void interactive();
 };
diff --git a/pub/lib/variables.cpp b/pub/lib/variables.cpp
index c3e6aa562ca8d66402ec73b920cbd571f3579cea..b7d5c761bd42fdc85c6bfb70e5477d3088d91ab6 100644
--- a/pub/lib/variables.cpp
+++ b/pub/lib/variables.cpp
@@ -7,21 +7,21 @@
 //! \file  variables.cpp
 //! \brief Implements class SVariRegistry.
 
+#include "variables.hpp"
 #include "defs.hpp"
 #include "ptr.hpp"
-#include "variables.hpp"
 
 
-PObj SVariRegistry::find( string key ) const
+PObj SVariRegistry::find(string key) const
 {
     auto pos = Map.find(key);
     return pos == Map.end() ? nullptr : pos->second;
 }
 
-PObj SVariRegistry::find_or_fail( string key ) const
+PObj SVariRegistry::find_or_fail(string key) const
 {
-    PObj ret = find( key );
-    if( !ret )
+    PObj ret = find(key);
+    if (!ret)
         throw "Cannot find variable '" + key + "'";
     return ret;
 }
@@ -52,18 +52,15 @@ void SVariRegistry::display_functions() const
     */
 }
 
-void SVariRegistry::register_scalar( string key, PObj val )
-{
-    Map[key] = val;
-}
+void SVariRegistry::register_scalar(string key, PObj val) { Map[key] = val; }
 
 //! Undefines a key (removes entry from registry); returns true unless the key wasn't defined.
 
-bool SVariRegistry::undef( string key )
+bool SVariRegistry::undef(string key)
 {
     auto pos = Map.find(key);
-    if( pos==Map.end() )
+    if (pos == Map.end())
         return false; // failure
-    Map.erase( pos );
+    Map.erase(pos);
     return true;
 }
diff --git a/pub/lib/variables.hpp b/pub/lib/variables.hpp
index 7fca8f7964a0ab2b5684989df9b88cec36801f7b..4334ab42be6bc50717aa398b1ba89d6ee09fcfc5 100644
--- a/pub/lib/variables.hpp
+++ b/pub/lib/variables.hpp
@@ -11,16 +11,17 @@
 
 //! Registry for variable objects.
 
-class SVariRegistry: public triv::ISingleton<SVariRegistry> {
- private:
-    map<string,PObj> Map;       //! unsorted hash, for expression evaluation
+class SVariRegistry : public triv::ISingleton<SVariRegistry>
+{
+private:
+    map<string, PObj> Map; //! unsorted hash, for expression evaluation
 
 public:
-    PObj find( string key ) const;
-    PObj find_or_fail( string key ) const;
+    PObj find(string key) const;
+    PObj find_or_fail(string key) const;
 
     void display_functions() const;
 
-    void register_scalar( string key, PObj val );
-    bool undef( string key );
+    void register_scalar(string key, PObj val);
+    bool undef(string key);
 };
diff --git a/pub/lib/xax_lex.hpp b/pub/lib/xax_lex.hpp
index 6454ea9b4ac22db969f1cbdefda96c7cb1c6fb90..30ef61e28525af1fc44b997e5972b8c19bb0a167 100644
--- a/pub/lib/xax_lex.hpp
+++ b/pub/lib/xax_lex.hpp
@@ -1,10 +1,10 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                         
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  xax_lex.hpp
 //! \brief Declares user_xaxparse, the parser call implented in xax_lex.lpp.
 
-RNode user_xaxparse(const char *lin);
+RNode user_xaxparse(const char* lin);
diff --git a/pub/plot/axis.cpp b/pub/plot/axis.cpp
index 5456698bf305bfe03c2b2eb8f89ae0aae5699f89..82dfe64c2a6e5e958d8be6f59e53c207f8ba1b35 100644
--- a/pub/plot/axis.cpp
+++ b/pub/plot/axis.cpp
@@ -7,14 +7,14 @@
 //! \file  axis.cpp
 //! \brief CAxis: One axis of a coordinate frame.
 
-#include <iostream>
+#include <cmath>
 #include <iomanip>
+#include <iostream>
 #include <vector>
-#include <cmath>
 
+#include "../readplus/macro.hpp"
 #include "../trivia/math.hpp"
 #include "../trivia/string_convs.hpp"
-#include "../readplus/macro.hpp"
 
 #include "axis.hpp"
 
@@ -36,12 +36,12 @@ void CAxis::set_auto()
 
 //! Sets limits to arguments.
 
-void CAxis::set_limits( double _inf, double _sup )
+void CAxis::set_limits(double _inf, double _sup)
 {
-    if( _inf>=_sup )
-        throw "Invalid limits "+S(_inf)+" .. "+S(_sup)+" for axis "+name;
-    if( logflag && _inf<=0 )
-        throw "Invalid nonpositive limit "+S(_inf)+" for axis " + name;
+    if (_inf >= _sup)
+        throw "Invalid limits " + S(_inf) + " .. " + S(_sup) + " for axis " + name;
+    if (logflag && _inf <= 0)
+        throw "Invalid nonpositive limit " + S(_inf) + " for axis " + name;
     inf = _inf;
     sup = _sup;
 }
@@ -49,7 +49,7 @@ void CAxis::set_limits( double _inf, double _sup )
 
 //! Sets log flag to argument, resets limits to infinite defaults.
 
-void CAxis::set_log( bool _log )
+void CAxis::set_log(bool _log)
 {
     logflag = _log;
     set_auto();
@@ -58,58 +58,57 @@ void CAxis::set_log( bool _log )
 
 //! Asks for new limits.
 
-void CAxis::ask_and_set( const string& quest )
+void CAxis::ask_and_set(const string& quest)
 {
-    for( ;; ) {
+    for (;;) {
         double inf_in, sup_in;
-        string resp1 = NMacro::readwd( quest + " [" + str() + "] ? " );
-        if        ( resp1 == "\\q" ) {
+        string resp1 = NMacro::readwd(quest + " [" + str() + "] ? ");
+        if (resp1 == "\\q") {
             throw S("user escape to main menu");
-        } else if ( resp1 == "" ) {
+        } else if (resp1 == "") {
             return; // don't change current value
-        } else if ( resp1 == "*" ) {
+        } else if (resp1 == "*") {
             set_auto();
             return;
-        } else if ( resp1 == "\\EOL" ) {
+        } else if (resp1 == "\\EOL") {
             inf_in = inf;
-        } else if( triv::any2dbl(resp1,&inf_in) ) {
+        } else if (triv::any2dbl(resp1, &inf_in)) {
             // ok
         } else {
             cout << "required input: plot axis range\n"
-                "examples:\n"
-                "    0.1 1000    two floating-point numbers\n"
-                "    \\   1000    let lower bond unchanged\n"
-                "    0.1  \\      let upper bound unchanged\n"
-                "    *           redetermine bounds from data\n"
-                "just press ENTER to let present range unchanged ["
+                    "examples:\n"
+                    "    0.1 1000    two floating-point numbers\n"
+                    "    \\   1000    let lower bond unchanged\n"
+                    "    0.1  \\      let upper bound unchanged\n"
+                    "    *           redetermine bounds from data\n"
+                    "just press ENTER to let present range unchanged ["
                  << str() << "]\n";
             continue;
         }
-        if ( logflag && inf_in<=0 ) {
+        if (logflag && inf_in <= 0) {
             cout << "log axis requires lower bound>0\n";
             continue;
         }
-        string resp2 = NMacro::readwd(
-            ".. and upper limit [" + S(sup) + "] ? " );
-        if        ( resp2 == "\\q" ) {
+        string resp2 = NMacro::readwd(".. and upper limit [" + S(sup) + "] ? ");
+        if (resp2 == "\\q") {
             throw S("user escape to main menu");
-        } else if ( resp2 == "" || resp2 == "\\EOL" ) {
+        } else if (resp2 == "" || resp2 == "\\EOL") {
             sup_in = sup;
-        } else if( triv::any2dbl(resp2,&sup_in) ) {
+        } else if (triv::any2dbl(resp2, &sup_in)) {
             // ok
         } else {
             cout << "invalid upper bound; use '?' for help\n";
             continue;
         }
-        if( sup_in<=inf_in ){
+        if (sup_in <= inf_in) {
             cout << "invalid input, does not fulfill lower<upper\n";
             continue;
         }
-        if( logflag && (sup_in>1e199 || inf_in<1e-199) ){
+        if (logflag && (sup_in > 1e199 || inf_in < 1e-199)) {
             cout << "log range currently restricted to 1E-199..1E199\n";
             continue;
         }
-        if( !logflag && (sup_in>3e38 || inf_in<-3e38) ){
+        if (!logflag && (sup_in > 3e38 || inf_in < -3e38)) {
             cout << "lin range currently restricted to -3e38..3e38\n";
             continue;
         }
@@ -122,31 +121,29 @@ void CAxis::ask_and_set( const string& quest )
 
 //! Sets limits to rounded values of arguments.
 
-void CAxis::set_rounded_limits( double _inf, double _sup )
+void CAxis::set_rounded_limits(double _inf, double _sup)
 {
     static double relmargin = 0.05;
     static double digits = 2;
 
-    if ( _inf==-INFINITY || _sup==+INFINITY )
+    if (_inf == -INFINITY || _sup == +INFINITY)
         throw "BUG: rounding " + name + " limits: unexpected inf limits";
-    if( _inf>_sup )
-        throw "BUG: rounding " + name + " limits: invalid plot range " +
-            S(_inf) + " > " + S(_sup);
-    if( logflag && _inf<=0 )
-        throw "BUG: rounding " + name + " limits: nonpositive log inf " +
-            S(_inf);
+    if (_inf > _sup)
+        throw "BUG: rounding " + name + " limits: invalid plot range " + S(_inf) + " > " + S(_sup);
+    if (logflag && _inf <= 0)
+        throw "BUG: rounding " + name + " limits: nonpositive log inf " + S(_inf);
 
     inf = _inf;
     sup = _sup;
 
-    if ( inf==sup ) {
-        if( logflag ){
+    if (inf == sup) {
+        if (logflag) {
             inf /= 10;
             sup *= 10;
-        } else if ( inf>0 ) {
+        } else if (inf > 0) {
             inf *= 0.9;
             sup *= 1.1;
-        } else if ( sup<0 ) {
+        } else if (sup < 0) {
             inf *= 1.1;
             sup *= 0.9;
         } else {
@@ -158,124 +155,122 @@ void CAxis::set_rounded_limits( double _inf, double _sup )
 
     double inf2, sup2;
     double mydigits = digits;
-    if ( !logflag ) { // lin limits
+    if (!logflag) { // lin limits
         double margin = relmargin * (sup - inf);
         do {
-            sup2 = triv::round_decimal( sup+margin, mydigits );
-            inf2 = triv::round_decimal( inf-margin, mydigits );
-            if(sup<0 && sup2>0) sup2 = 0;
-            if(inf2<0 && inf>0) inf2 = 0;
+            sup2 = triv::round_decimal(sup + margin, mydigits);
+            inf2 = triv::round_decimal(inf - margin, mydigits);
+            if (sup < 0 && sup2 > 0)
+                sup2 = 0;
+            if (inf2 < 0 && inf > 0)
+                inf2 = 0;
             mydigits += 0.1;
-            //printf("DEB [%g,%g] -> [%g,%g] (%g)\n", inf, sup, inf2, sup2, mydigits);
-            if( mydigits>17 ){
-                std::cerr << std::setprecision(17)<<
-                    "PLEASE REPORT THIS BUG: escaping from endless loop in Axis::"
-                    "set_rounded_limits("<<inf<<","<<sup<<")\n";
-                inf2 = inf-margin;
-                sup2 = sup-margin;
+            // printf("DEB [%g,%g] -> [%g,%g] (%g)\n", inf, sup, inf2, sup2, mydigits);
+            if (mydigits > 17) {
+                std::cerr << std::setprecision(17)
+                          << "PLEASE REPORT THIS BUG: escaping from endless loop in Axis::"
+                             "set_rounded_limits("
+                          << inf << "," << sup << ")\n";
+                inf2 = inf - margin;
+                sup2 = sup - margin;
                 break;
             }
-        } while ( inf2>inf || sup2<sup || (sup2-inf2)>(1.33*(sup-inf)+1e-14*(sup+inf) ) );
+        } while (inf2 > inf || sup2 < sup
+                 || (sup2 - inf2) > (1.33 * (sup - inf) + 1e-14 * (sup + inf)));
     } else { // log limits
         double ratio = sup / inf;
-        double margin = exp( relmargin*log(ratio) );
+        double margin = exp(relmargin * log(ratio));
         do {
-            sup2 = triv::round_decimal( sup*margin, mydigits );
-            inf2 = triv::round_decimal( inf/margin, mydigits );
+            sup2 = triv::round_decimal(sup * margin, mydigits);
+            inf2 = triv::round_decimal(inf / margin, mydigits);
             mydigits += 0.5;
-        } while ( !((inf2<inf) && (sup<sup2)) && mydigits<18 );
+        } while (!((inf2 < inf) && (sup < sup2)) && mydigits < 18);
     }
-    set_limits( inf2, sup2 );
+    set_limits(inf2, sup2);
 }
 
 
 //! Are both limits finite ?
 
-bool CAxis::finite() const
-{
-    return inf!=-INFINITY && sup!=+INFINITY;
-}
+bool CAxis::finite() const { return inf != -INFINITY && sup != +INFINITY; }
 
 
 //! Is argument val contained in present plot range?
 
-bool CAxis::contains(double val) const
-{
-    return inf<=val && val<=sup;
-}
+bool CAxis::contains(double val) const { return inf <= val && val <= sup; }
 
 
 //! Do arguments v1 and v2 agree within tolerance tol, relative to plot range?
 
-bool CAxis::close_enough( double v1, double v2, double tol ) const
+bool CAxis::close_enough(double v1, double v2, double tol) const
 {
-    if ( !finite() )
+    if (!finite())
         throw S("undefined plot range");
-    if ( logflag ) {
-        if ( v1<=0 || v2<=0 )
+    if (logflag) {
+        if (v1 <= 0 || v2 <= 0)
             return false;
-        return fabs(log(v1/v2)) <= tol*log(sup/inf);
+        return fabs(log(v1 / v2)) <= tol * log(sup / inf);
     } else {
-        return fabs(v1-v2) <= tol*(sup-inf);
+        return fabs(v1 - v2) <= tol * (sup - inf);
     }
 }
 
 
 //! Returns plot coordinate (between 0 and 1) of argument.
 
-double CAxis::value2plotcoord( double v ) const
+double CAxis::value2plotcoord(double v) const
 {
-    if ( !finite() )
+    if (!finite())
         throw S("undefined plot range");
-    if ( logflag ) {
-        if( inf<0 || v<0 )
+    if (logflag) {
+        if (inf < 0 || v < 0)
             throw S("negative value in log range");
-        return log(v/inf) / log(sup/inf);
+        return log(v / inf) / log(sup / inf);
     } else {
-        return (v-inf) / (sup-inf);
+        return (v - inf) / (sup - inf);
     }
 }
 
 
 //! Returns half length of error bar (in plot coordinates 0..1).
 
-double CAxis::value2ploterror( double v, double dv ) const
+double CAxis::value2ploterror(double v, double dv) const
 {
-    if ( !finite() )
+    if (!finite())
         throw S("undefined plot range");
-    if ( dv<0 )
+    if (dv < 0)
         throw S("negative error");
-    if ( dv==0 )
+    if (dv == 0)
         return 0;
-    if ( logflag ) {
-        if( inf<0 || v<0 )
+    if (logflag) {
+        if (inf < 0 || v < 0)
             throw S("negative value in log range");
-        return dv / v / log(sup/inf);
+        return dv / v / log(sup / inf);
     } else {
-        return dv / (sup-inf);
+        return dv / (sup - inf);
     }
 }
 
 
 //! Sets vector x such that its plot coordinates form an equidistent grid.
 
-void CAxis::set_xgrid( vector<double>& x, int n ) const
+void CAxis::set_xgrid(vector<double>& x, int n) const
 {
-    if ( !finite() )
+    if (!finite())
         throw S("undefined plot range");
-    if ( n<2 )
+    if (n < 2)
         throw S("call to set_xgrid with less than two points");
-    if ( inf>=sup )
+    if (inf >= sup)
         throw S("call to set_xgrid with invalid limits");
-    x.resize( n );
+    x.resize(n);
     x[0] = inf;
-    x[n-1] = sup;
-    for( int i=1; i<n-1; ++i ){
-        if ( logflag ) {
-            double c = ((double)(i)) / ((double)(n-1));
-            x[i] = pow( inf, 1-c ) * pow( sup, c );
+    x[n - 1] = sup;
+    for (int i = 1; i < n - 1; ++i) {
+        if (logflag) {
+            double c = ((double)(i)) / ((double)(n - 1));
+            x[i] = pow(inf, 1 - c) * pow(sup, c);
         } else {
-            x[i] = ( (n-1-i)*inf + i*sup ) / (n-1);
+            x[i] = ((n - 1 - i) * inf + i * sup) / (n - 1);
         }
     }
 }
@@ -285,7 +280,7 @@ void CAxis::set_xgrid( vector<double>& x, int n ) const
 
 string CAxis::str() const
 {
-    if( inf==-INFINITY || sup== +INFINITY )
+    if (inf == -INFINITY || sup == +INFINITY)
         return "*";
     else
         return S(inf) + " " + S(sup);
@@ -297,7 +292,7 @@ string CAxis::str() const
 string CAxis::info() const
 {
     string ret;
-    ret  =   logflag ? "log" : "lin";
+    ret = logflag ? "log" : "lin";
     ret += " " + S(inf);
     ret += " " + S(sup);
     return ret;
@@ -306,38 +301,31 @@ string CAxis::info() const
 
 //! Returns argument converted to my PostScript units (0..10).
 
-double CAxis::pc( double v ) const
-{
-    return 10 * value2plotcoord( v );
-}
+double CAxis::pc(double v) const { return 10 * value2plotcoord(v); }
 
 
 //! Returns half length of error bar (in my Postscript coordinates 0..10).
 
-double CAxis::pcerr( double v, double dv ) const
-{
-    return 10 * value2ploterror( v, dv );
-}
+double CAxis::pcerr(double v, double dv) const { return 10 * value2ploterror(v, dv); }
 
 
 //! Sets Tacks, *ntpt, *ticklim to a nice division of the plot range.
 
-void CAxis::calc_ticks( vector<double>& Tacks, int *ntpt, double *ticklim) const
+void CAxis::calc_ticks(vector<double>& Tacks, int* ntpt, double* ticklim) const
 {
-    if ( inf >= sup )
-        throw "BUG detected by calc_ticks: inf=" + S(inf) +
-            " >= sup=" + S(sup);
+    if (inf >= sup)
+        throw "BUG detected by calc_ticks: inf=" + S(inf) + " >= sup=" + S(sup);
     Tacks.clear();
 
     if (!logflag) {
         double r = log10(sup - inf);
-        int ir = (int) ((r<0) ? r-1 : r);
+        int ir = (int)((r < 0) ? r - 1 : r);
         double rd = r - ir; // fractional part of r
         double rdr = pow(10., rd);
         double dtack;
-        if        (rdr > 9.99999) {
+        if (rdr > 9.99999) {
             dtack = 2.5 * pow(10., ir); // spacing between tacks
-            *ntpt = 5;                // ticks per tack
+            *ntpt = 5; // ticks per tack
         } else if (rdr > 5.00001) {
             dtack = 2 * pow(10., ir);
             *ntpt = 4;
@@ -355,24 +343,24 @@ void CAxis::calc_ticks( vector<double>& Tacks, int *ntpt, double *ticklim) const
             *ntpt = 5;
         }
         double d = inf / dtack;
-        double tack0 = dtack * (int) (d<=0?d-1:d);
+        double tack0 = dtack * (int)(d <= 0 ? d - 1 : d);
         d = sup / dtack;
-        double tackn = dtack * ((int) (d<0?d-1:d) + 1);
-        double vsub = inf - (sup-inf)*1.e-4;
-        double vsup = sup + (sup-inf)*1.e-4;
-        int nt = (int) ((tackn-tack0) / dtack) + 3; // allocate enough
-        for (int i=0; i<nt; i++) {
-            d = tack0 + i*dtack;
-            if (vsub<=d && d<=vsup)
-                Tacks.push_back( d );
+        double tackn = dtack * ((int)(d < 0 ? d - 1 : d) + 1);
+        double vsub = inf - (sup - inf) * 1.e-4;
+        double vsup = sup + (sup - inf) * 1.e-4;
+        int nt = (int)((tackn - tack0) / dtack) + 3; // allocate enough
+        for (int i = 0; i < nt; i++) {
+            d = tack0 + i * dtack;
+            if (vsub <= d && d <= vsup)
+                Tacks.push_back(d);
         }
 
         int ntack = Tacks.size();
         ticklim[0] = tack0;
-        ticklim[1] = Tacks[ntack-1] + dtack;
+        ticklim[1] = Tacks[ntack - 1] + dtack;
 
     } else { // log scale
-        static double eins = 1+1e-6-1e-12;
+        static double eins = 1 + 1e-6 - 1e-12;
 
         if (inf <= 0)
             throw S("BUG in CAxis::calc_ticks: negative log argument");
@@ -385,17 +373,17 @@ void CAxis::calc_ticks( vector<double>& Tacks, int *ntpt, double *ticklim) const
 
         // incr := #decades per tack
         int incr;
-        if ( rlgrel <= 10 ) {
+        if (rlgrel <= 10) {
             incr = 1;
         } else {
-            incr = (int) (rlgrel / 7 + 1);
-            if (incr>3)
+            incr = (int)(rlgrel / 7 + 1);
+            if (incr > 3)
                 incr = 3 * (incr / 3); // preferred values 3, 6, ...
         }
 
         // first and last tack
-        int minexp = (int) (rlgmin>0 ? rlgmin+1e-6 : rlgmin-1e-6-1);
-        int maxexp = (int) (rlgmax>0 ? rlgmax+1e-6 : rlgmax-1e-6-1);
+        int minexp = (int)(rlgmin > 0 ? rlgmin + 1e-6 : rlgmin - 1e-6 - 1);
+        int maxexp = (int)(rlgmax > 0 ? rlgmax + 1e-6 : rlgmax - 1e-6 - 1);
         if (incr > 1) {
             minexp -= minexp % incr;
             maxexp -= maxexp % incr;
@@ -404,29 +392,29 @@ void CAxis::calc_ticks( vector<double>& Tacks, int *ntpt, double *ticklim) const
         // set Tacks
         double d1 = inf / eins;
         double d2 = sup * eins;
-        for ( int i=minexp; i<=maxexp; i+=incr ) {
+        for (int i = minexp; i <= maxexp; i += incr) {
             double r0 = pow(10., i);
-            if (d1<=r0 && r0<=d2)
-                Tacks.push_back( r0 );
+            if (d1 <= r0 && r0 <= d2)
+                Tacks.push_back(r0);
         }
 
         // set tick limits (may exceed actual tick range)
         int ntack = Tacks.size();
-        if ( ntack >= 1 ) {
-            ticklim[0] = Tacks[0]       / pow(10., incr);
-            ticklim[1] = Tacks[ntack-1] * pow(10., incr);
+        if (ntack >= 1) {
+            ticklim[0] = Tacks[0] / pow(10., incr);
+            ticklim[1] = Tacks[ntack - 1] * pow(10., incr);
         } else {
             // untested. just to allow plots when no tacks in window
-            ticklim[0] = pow( 10., minexp );
-            ticklim[1] = pow( 10., maxexp+1 );
+            ticklim[0] = pow(10., minexp);
+            ticklim[1] = pow(10., maxexp + 1);
         }
 
         // determine #ticks / tack
-        if        (incr==1 && rlgrel<=3) {
+        if (incr == 1 && rlgrel <= 3) {
             *ntpt = 9;
-        } else if (incr==1 && rlgrel<=7) {
+        } else if (incr == 1 && rlgrel <= 7) {
             *ntpt = 3; // 1-2-5-10 - Schritte
-        } else if (incr==1) {
+        } else if (incr == 1) {
             *ntpt = 1;
         } else {
             *ntpt = -incr;
diff --git a/pub/plot/axis.hpp b/pub/plot/axis.hpp
index f1d70920efabd9ac4f33049b467a28cf45cb1871..3aea8cdcb4db2a716d62a5b42c47d9494e1f3e48 100644
--- a/pub/plot/axis.hpp
+++ b/pub/plot/axis.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                        
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                               
-//*  http://apps.jcns.fz-juelich.de/frida                                  
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  axis.hpp
@@ -9,33 +9,36 @@
 
 //! One axis of a coordinate frame, for use in plotting.
 
-class CAxis {
- public:
-    std::string name;     //!< usually "x" or "y"
-    double inf;      //!< infimum: lower plot limit
-    double sup;      //!< supremum: upper plot limit
-    bool   logflag;  //!< is logarithmic ?
-    bool   force;    //!< force points into range ?
+class CAxis
+{
+public:
+    std::string name; //!< usually "x" or "y"
+    double inf; //!< infimum: lower plot limit
+    double sup; //!< supremum: upper plot limit
+    bool logflag; //!< is logarithmic ?
+    bool force; //!< force points into range ?
 
-    CAxis( const std::string _name, bool _log ) :
-        name(_name), logflag(_log), force(false) { set_auto(); }
+    CAxis(const std::string _name, bool _log) : name(_name), logflag(_log), force(false)
+    {
+        set_auto();
+    }
 
-    void set_log( bool _log );
+    void set_log(bool _log);
 
     void set_auto();
-    void set_limits( double _inf, double _sup );
-    void set_rounded_limits( double _inf, double _sup );
-    void ask_and_set( const std::string& quest );
+    void set_limits(double _inf, double _sup);
+    void set_rounded_limits(double _inf, double _sup);
+    void ask_and_set(const std::string& quest);
 
     std::string str() const;
     std::string info() const;
     bool finite() const;
-    bool contains( double val ) const;
-    bool close_enough( double v1, double v2, double tol ) const;
-    double value2plotcoord( double v ) const;
-    double value2ploterror( double v, double dv ) const;
-    void set_xgrid( std::vector<double>& x, int n ) const;
-    double pc( double v ) const;
-    double pcerr( double v, double dv ) const;
-    void calc_ticks( std::vector<double>& Tacks, int *ntpt, double *ticklim ) const;
+    bool contains(double val) const;
+    bool close_enough(double v1, double v2, double tol) const;
+    double value2plotcoord(double v) const;
+    double value2ploterror(double v, double dv) const;
+    void set_xgrid(std::vector<double>& x, int n) const;
+    double pc(double v) const;
+    double pcerr(double v, double dv) const;
+    void calc_ticks(std::vector<double>& Tacks, int* ntpt, double* ticklim) const;
 };
diff --git a/pub/plot/dualplot.cpp b/pub/plot/dualplot.cpp
index 64ef2765d7504708959b4751f8923ec8a21702be..a3fe542b9809422f082f680df3afb06c96daece4 100644
--- a/pub/plot/dualplot.cpp
+++ b/pub/plot/dualplot.cpp
@@ -7,12 +7,12 @@
 //! \file  dualplot.cpp
 //! \brief Collection NPlot of plot frames CPlot.
 
-#include <iostream>
+#include <boost/format.hpp>
 #include <cmath>
 #include <cstring>
 #include <fcntl.h>
+#include <iostream>
 #include <sys/stat.h>
-#include <boost/format.hpp>
 
 #include "../trivia/file_ops.hpp"
 #include "../trivia/string_convs.hpp"
@@ -31,39 +31,44 @@ static const int mLin = 80; // max num of chars in PostScript line
 
 //! Constructor for plot window: setup for gnuplot and postscript.
 
-CPlot::CPlot( int _iPlot, bool _logx, bool _logy ) :
-    iPlot( _iPlot ), X( "x", _logx ), Y( "y", _logy ),
-    maxpoints(20000), with_errors(true), equipoints(49), refine(true)
+CPlot::CPlot(int _iPlot, bool _logx, bool _logy)
+    : iPlot(_iPlot)
+    , X("x", _logx)
+    , Y("y", _logy)
+    , maxpoints(20000)
+    , with_errors(true)
+    , equipoints(49)
+    , refine(true)
 {
     // == Initialization for Gnuplot ==
 
     // Create a named pipe (FIFO) that will transmit our commands to Gnuplot.
-    string fn_fifo = string("/tmp/gnuplot-") + getenv( "LOGNAME" );
-    triv::system( "rm -f "+fn_fifo );
-    if (mkfifo( fn_fifo.c_str(), 0666 ))
-        throw "SYSTEM ERROR cannot make fifo "+fn_fifo+": will not be able to print";
+    string fn_fifo = string("/tmp/gnuplot-") + getenv("LOGNAME");
+    triv::system("rm -f " + fn_fifo);
+    if (mkfifo(fn_fifo.c_str(), 0666))
+        throw "SYSTEM ERROR cannot make fifo " + fn_fifo + ": will not be able to print";
 
     // Check that Gnuplot supports X11.
-    string out = triv::system_read( "gnuplot -e 'help X11' 2>&1 < /dev/null" );
-    if ( out.substr(0,5)=="Sorry" || out.length()<80 ) {
+    string out = triv::system_read("gnuplot -e 'help X11' 2>&1 < /dev/null");
+    if (out.substr(0, 5) == "Sorry" || out.length() < 80) {
         cout << "Gnuplot seems not to support X11\n";
         exit(1);
     }
 
     // Start a Gnuplot that will read from our pipe.
-    triv::system( "gnuplot -title "+S(iPlot)+" -noraise < "+fn_fifo+"&" );
+    triv::system("gnuplot -title " + S(iPlot) + " -noraise < " + fn_fifo + "&");
 
     // Open our pipe so that we can write commands to it
     //   (we use 'open' instead of 'fopen' or 'ofstream', because we need non-blocking mode).
-    if ( ( gp_fifo = open( fn_fifo.c_str(), O_WRONLY ) )==-1 )
-        throw "SYSTEM ERROR: cannot open fifo "+fn_fifo+" ("+strerror(errno)+")";
-    fcntl( gp_fifo, F_SETFL, O_NONBLOCK );
+    if ((gp_fifo = open(fn_fifo.c_str(), O_WRONLY)) == -1)
+        throw "SYSTEM ERROR: cannot open fifo " + fn_fifo + " (" + strerror(errno) + ")";
+    fcntl(gp_fifo, F_SETFL, O_NONBLOCK);
 
     // Now the initialization _within_ Gnuplot.
-    gp_write( string("set terminal x11") );
+    gp_write(string("set terminal x11"));
 
     // == Initialization for PostScript ==
-    ps_fnum=0;
+    ps_fnum = 0;
 }
 
 
@@ -78,7 +83,7 @@ void CPlot::clear_frame()
     // reset buffers for postscript output
     string cmd;
     ps_accu.clear();
-    ps_accu.push_back( "\n%% output created by frida2\n");
+    ps_accu.push_back("\n%% output created by frida2\n");
     ps_snum = 0;
     ps_pnum = 0;
     ps_cnum = 0;
@@ -88,41 +93,41 @@ void CPlot::clear_frame()
 
 //! Change one setup parameter per command.
 
-void CPlot::set_aux( const string& cmd )
+void CPlot::set_aux(const string& cmd)
 {
-    if ( cmd=="gxl" ) {
-        X.set_log( !X.logflag );
-        printf( "set x %s\n", X.logflag ? "log" : "lin" ); }
-    else if ( cmd=="gxl+" )
-        X.set_log( true );
-    else if ( cmd=="gxl-" )
-        X.set_log( false );
-    else if ( cmd=="gyl" ) {
-        Y.set_log( !Y.logflag );
-        printf( "set y %s\n", Y.logflag ? "log" : "lin" ); }
-    else if ( cmd=="gyl+" )
-        Y.set_log( true );
-    else if ( cmd=="gyl-" )
-        Y.set_log( false );
-    else if ( cmd=="gxf" ) {
+    if (cmd == "gxl") {
+        X.set_log(!X.logflag);
+        printf("set x %s\n", X.logflag ? "log" : "lin");
+    } else if (cmd == "gxl+")
+        X.set_log(true);
+    else if (cmd == "gxl-")
+        X.set_log(false);
+    else if (cmd == "gyl") {
+        Y.set_log(!Y.logflag);
+        printf("set y %s\n", Y.logflag ? "log" : "lin");
+    } else if (cmd == "gyl+")
+        Y.set_log(true);
+    else if (cmd == "gyl-")
+        Y.set_log(false);
+    else if (cmd == "gxf") {
         X.force = !X.force;
-        printf( "force x %s\n", X.force ? "on" : "off" ); }
-    else if ( cmd=="gxf+" )
+        printf("force x %s\n", X.force ? "on" : "off");
+    } else if (cmd == "gxf+")
         X.force = true;
-    else if ( cmd=="gxf-" )
+    else if (cmd == "gxf-")
         X.force = false;
-    else if ( cmd=="gyf" ) {
+    else if (cmd == "gyf") {
         Y.force = !Y.force;
-        printf( "force y %s\n", Y.force ? "on" : "off" ); }
-    else if ( cmd=="gyf+" )
+        printf("force y %s\n", Y.force ? "on" : "off");
+    } else if (cmd == "gyf+")
         Y.force = true;
-    else if ( cmd=="gyf-" )
+    else if (cmd == "gyf-")
         Y.force = false;
-    else if ( cmd=="ge" )
+    else if (cmd == "ge")
         with_errors = !with_errors;
-    else if ( cmd=="ge+" )
+    else if (cmd == "ge+")
         with_errors = true;
-    else if ( cmd=="ge-" )
+    else if (cmd == "ge-")
         with_errors = false;
     else
         throw "unknown command " + cmd;
@@ -131,154 +136,145 @@ void CPlot::set_aux( const string& cmd )
 
 //! Plot coordinate frame (axes, ticks, labels).
 
-void CPlot::plot_frame( const string& xlabel, const string& ylabel )
+void CPlot::plot_frame(const string& xlabel, const string& ylabel)
 {
-    gp_write( "set nologscale" );
-    string whichlog="";
-    if (X.logflag) whichlog += "x";
-    if (Y.logflag) whichlog += "y";
-    if (whichlog!="")
-        gp_write( "set logscale " + whichlog );
+    gp_write("set nologscale");
+    string whichlog = "";
+    if (X.logflag)
+        whichlog += "x";
+    if (Y.logflag)
+        whichlog += "y";
+    if (whichlog != "")
+        gp_write("set logscale " + whichlog);
 
     // wups:
-    char outlin[ mLin ];
-    snprintf( outlin, mLin, "\n%i %g %g xSetCoord\n",
-              X.logflag, X.inf, X.sup );
-    ps_accu.push_back( outlin );
-    snprintf( outlin, mLin, "%i %g %g ySetCoord\n",
-              Y.logflag, Y.inf, Y.sup );
-    ps_accu.push_back( outlin );
-    snprintf( outlin, mLin, "%% %i %g %g %i zSetCoord\n\n",
-              0, 0., 0., 0 );
-    ps_accu.push_back( outlin );
+    char outlin[mLin];
+    snprintf(outlin, mLin, "\n%i %g %g xSetCoord\n", X.logflag, X.inf, X.sup);
+    ps_accu.push_back(outlin);
+    snprintf(outlin, mLin, "%i %g %g ySetCoord\n", Y.logflag, Y.inf, Y.sup);
+    ps_accu.push_back(outlin);
+    snprintf(outlin, mLin, "%% %i %g %g %i zSetCoord\n\n", 0, 0., 0., 0);
+    ps_accu.push_back(outlin);
 
     int ntpt;
     double ticklim[2];
     vector<double> Tacks;
-    ps_accu.push_back( "\n/xPlotFrame {\n" );
-    if ( X.logflag && X.inf<= 0 )
+    ps_accu.push_back("\n/xPlotFrame {\n");
+    if (X.logflag && X.inf <= 0)
         throw "BUG: x log incompatible with limits " + X.str();
-    X.calc_ticks( Tacks, &ntpt, ticklim );
-    ps_ticktack( Tacks, ntpt, ticklim, &X);
-    snprintf( outlin, mLin-4, "  {(%s", xlabel.c_str() );
-    strncat( outlin, ")}\n", mLin );
-    ps_accu.push_back( outlin );
-    ps_accu.push_back( "   0 10   0  0     0  90 "
-                       "OneAxx Axx Tic Tac xNumL %% low x axis\n" );
-    ps_accu.push_back( "   0 10   0 10     0 270 "
-                       "OneAxx Axx Tic Tac       %% top x axis\n" );
-    ps_accu.push_back( "  xCL\n" );
-    ps_accu.push_back( "} def\n" );
-
-    ps_accu.push_back( "\n/yPlotFrame {\n" );
-    if ( Y.logflag && Y.inf<= 0 )
+    X.calc_ticks(Tacks, &ntpt, ticklim);
+    ps_ticktack(Tacks, ntpt, ticklim, &X);
+    snprintf(outlin, mLin - 4, "  {(%s", xlabel.c_str());
+    strncat(outlin, ")}\n", mLin);
+    ps_accu.push_back(outlin);
+    ps_accu.push_back("   0 10   0  0     0  90 "
+                      "OneAxx Axx Tic Tac xNumL %% low x axis\n");
+    ps_accu.push_back("   0 10   0 10     0 270 "
+                      "OneAxx Axx Tic Tac       %% top x axis\n");
+    ps_accu.push_back("  xCL\n");
+    ps_accu.push_back("} def\n");
+
+    ps_accu.push_back("\n/yPlotFrame {\n");
+    if (Y.logflag && Y.inf <= 0)
         throw "BUG: y log incompatible with limits " + Y.str();
-    Y.calc_ticks( Tacks, &ntpt, ticklim );
-    ps_ticktack( Tacks, ntpt, ticklim, &Y);
-    snprintf( outlin, mLin-4, "   {(%s", ylabel.c_str() );
-    strncat( outlin, ")}\n", mLin );
-    ps_accu.push_back( outlin );
-    ps_accu.push_back( "   0 10   0  0    90   0 "
-                       "OneAxx Axx Tic Tac yNumL %% left y axis\n" );
-    ps_accu.push_back( "   0 10  10  0    90 180 "
-                       "OneAxx Axx Tic Tac       %% right y axis\n" );
-    ps_accu.push_back( "  yCL\n" );
-    ps_accu.push_back( "} def\n" );
-    ps_accu.push_back( "\n%% modeDD\nplotbefore\n" );
+    Y.calc_ticks(Tacks, &ntpt, ticklim);
+    ps_ticktack(Tacks, ntpt, ticklim, &Y);
+    snprintf(outlin, mLin - 4, "   {(%s", ylabel.c_str());
+    strncat(outlin, ")}\n", mLin);
+    ps_accu.push_back(outlin);
+    ps_accu.push_back("   0 10   0  0    90   0 "
+                      "OneAxx Axx Tic Tac yNumL %% left y axis\n");
+    ps_accu.push_back("   0 10  10  0    90 180 "
+                      "OneAxx Axx Tic Tac       %% right y axis\n");
+    ps_accu.push_back("  yCL\n");
+    ps_accu.push_back("} def\n");
+    ps_accu.push_back("\n%% modeDD\nplotbefore\n");
 }
 
 
 //! Plot one spectrum.
 
-void CPlot::add_spec( bool as_line, bool new_style, int style_no,
-                     const vector<double>& xp,
-                     const vector<double>& yp, const vector<double>& dyp,
-                     const vector<string>& z,
-                     const string& xco,
-                     const string& yco,
-                     const string& info
-    )
+void CPlot::add_spec(
+    bool as_line, bool new_style, int style_no, const vector<double>& xp, const vector<double>& yp,
+    const vector<double>& dyp, const vector<string>& z, const string& xco, const string& yco,
+    const string& info)
 {
     static const int mColor = 6;
-    static int color[mColor] = { 0x880000, 0x008800, 0x000088,
-                                 0x006666, 0x660066, 0x666600 };
+    static int color[mColor] = { 0x880000, 0x008800, 0x000088, 0x006666, 0x660066, 0x666600 };
     // Checks:
-    int np=xp.size();
-    if ( !np )
+    int np = xp.size();
+    if (!np)
         throw S("invalid call to CPLot::addSpec: no data points");
-    if ( np!=yp.size() )
+    if (np != yp.size())
         throw S("invalid call to CPLot::addSpec: x.size<>y.size");
 
     // Prepare for live display, to be shown by showSpecs():
-    string gp_fnam = str( format( "/tmp/%s-%i-%03i.gnu" )
-                          % getenv("LOGNAME") % iPlot % gp_fno++ );
-    if (gp_fnames!="") gp_fnames += ", ";
+    string gp_fnam = str(format("/tmp/%s-%i-%03i.gnu") % getenv("LOGNAME") % iPlot % gp_fno++);
+    if (gp_fnames != "")
+        gp_fnames += ", ";
     gp_fnames += string("\"") + gp_fnam + "\" notitle";
-    if ( as_line )
-        gp_fnames += str( format( " with lines lt 1 lc rgb \"#%6x\"" )
-                          % color[ style_no % mColor ] );
-    else if( with_errors && dyp.size() )
+    if (as_line)
+        gp_fnames += str(format(" with lines lt 1 lc rgb \"#%6x\"") % color[style_no % mColor]);
+    else if (with_errors && dyp.size())
         gp_fnames += " with errorbars";
-    FILE *gp_fd;
+    FILE* gp_fd;
     if (!(gp_fd = fopen(gp_fnam.c_str(), "w")))
         throw "cannot save gnuplot data to " + gp_fnam;
     int nout = 0;
     try {
-        for (int i=0; i<np; i++){
-            if( std::isinf(xp[i]) || std::isinf(yp[i]) )
-                throw "Data point number " + S(i) + " is invalid: x=" +
-                    S(xp[i]) + ", y=" + S(yp[i]);
-            if( xp[i]<X.inf || xp[i]>X.sup )
-                throw "CPlot::addSpec: x["+S(i)+"]="+S(xp[i])+" out of range";
-            if( yp[i]<Y.inf || yp[i]>Y.sup )
-                throw "CPlot::addSpec: y["+S(i)+"]="+S(yp[i])+" out of range";
-            if( with_errors && dyp.size() )
-                fprintf(gp_fd, "%20.13g %20.13g %20.13g\n", xp[i], yp[i], dyp[i] );
+        for (int i = 0; i < np; i++) {
+            if (std::isinf(xp[i]) || std::isinf(yp[i]))
+                throw "Data point number " + S(i) + " is invalid: x=" + S(xp[i]) + ", y="
+                    + S(yp[i]);
+            if (xp[i] < X.inf || xp[i] > X.sup)
+                throw "CPlot::addSpec: x[" + S(i) + "]=" + S(xp[i]) + " out of range";
+            if (yp[i] < Y.inf || yp[i] > Y.sup)
+                throw "CPlot::addSpec: y[" + S(i) + "]=" + S(yp[i]) + " out of range";
+            if (with_errors && dyp.size())
+                fprintf(gp_fd, "%20.13g %20.13g %20.13g\n", xp[i], yp[i], dyp[i]);
             else
                 fprintf(gp_fd, "%20.13g %20.13g\n", xp[i], yp[i]);
             nout++;
         }
-    } catch ( string &s ) {
+    } catch (string& s) {
         fclose(gp_fd);
         throw s;
-    } catch ( ... ) {
+    } catch (...) {
         fclose(gp_fd);
         throw "BUG: unexpected exception type";
     }
     fclose(gp_fd);
-    if( !nout )
+    if (!nout)
         throw "no points in frame: " + info;
 
     // Postscript copy:
-    char outlin[ mLin ];
-    if ( new_style ) {
-        snprintf( outlin, mLin, "\n%3u [", ++ps_snum );
-        ps_accu.push_back( outlin );
-        for (int i=0; i<z.size(); i++){
-            snprintf( outlin, mLin, " %s", z[i].c_str() );
-            ps_accu.push_back( outlin );
+    char outlin[mLin];
+    if (new_style) {
+        snprintf(outlin, mLin, "\n%3u [", ++ps_snum);
+        ps_accu.push_back(outlin);
+        for (int i = 0; i < z.size(); i++) {
+            snprintf(outlin, mLin, " %s", z[i].c_str());
+            ps_accu.push_back(outlin);
         }
-        snprintf( outlin, mLin, " ] zValues\n" );
-        ps_accu.push_back( outlin );
-        if ( as_line )
-            snprintf( outlin, mLin, "%2i cstyle", style_no );
+        snprintf(outlin, mLin, " ] zValues\n");
+        ps_accu.push_back(outlin);
+        if (as_line)
+            snprintf(outlin, mLin, "%2i cstyle", style_no);
         else
-            snprintf( outlin, mLin, "%2i pstyle", style_no );
-        ps_accu.push_back( outlin );
-        snprintf( outlin, mLin-2, " %% (%s -> %s)", xco.c_str(), yco.c_str() );
-        strncat( outlin, "\n", mLin );
-        ps_accu.push_back( outlin );
+            snprintf(outlin, mLin, "%2i pstyle", style_no);
+        ps_accu.push_back(outlin);
+        snprintf(outlin, mLin - 2, " %% (%s -> %s)", xco.c_str(), yco.c_str());
+        strncat(outlin, "\n", mLin);
+        ps_accu.push_back(outlin);
     } else {
-        ps_accu.push_back( "\n" );
+        ps_accu.push_back("\n");
     }
-    for (int i=0; i<np; i++) {
-        snprintf( outlin, mLin,
-                  "%8.5f %8.5f %8.5f t%c %% %13.7g wx %13.7g wy\n",
-                  X.pc(xp[i]), Y.pc(yp[i]),
-                  dyp.size() ? Y.pcerr(yp[i],dyp[i]) : 0,
-                  i==0 ? 'i' : i==np-1 ? 'f' : ' ',
-                  xp[i], yp[i] );
-        ps_accu.push_back( outlin );
+    for (int i = 0; i < np; i++) {
+        snprintf(
+            outlin, mLin, "%8.5f %8.5f %8.5f t%c %% %13.7g wx %13.7g wy\n", X.pc(xp[i]),
+            Y.pc(yp[i]), dyp.size() ? Y.pcerr(yp[i], dyp[i]) : 0,
+            i == 0 ? 'i' : i == np - 1 ? 'f' : ' ', xp[i], yp[i]);
+        ps_accu.push_back(outlin);
     }
 }
 
@@ -287,81 +283,76 @@ void CPlot::add_spec( bool as_line, bool new_style, int style_no,
 
 void CPlot::show_specs()
 {
-    if ( gp_fnames!="" )
-        gp_write( "plot " +
-                  str( format( "[%12.8g:%12.8g] [%12.8g:%12.8g] " )
-                       % X.inf % X.sup % Y.inf % Y.sup ) +
-                  gp_fnames );
+    if (gp_fnames != "")
+        gp_write(
+            "plot "
+            + str(format("[%12.8g:%12.8g] [%12.8g:%12.8g] ") % X.inf % X.sup % Y.inf % Y.sup)
+            + gp_fnames);
 }
 
 
 //! Add documentation line to postscript output.
 
-void CPlot::doc_TxLine( const string& line )
-{
-    ps_Doc.push_back( "  {("+line+")} TxLine" );
-}
+void CPlot::doc_TxLine(const string& line) { ps_Doc.push_back("  {(" + line + ")} TxLine"); }
 
 
 //! Add documentation line explaining a plot symbol to postscript output.
 
-void CPlot::doc_PtTxLine( const string& line, int num )
+void CPlot::doc_PtTxLine(const string& line, int num)
 {
-    ps_Doc.push_back( "  " + S(num) + " {("+line+")} PtTxLine" );
+    ps_Doc.push_back("  " + S(num) + " {(" + line + ")} PtTxLine");
 }
 
 
 //! Add documentation line explaining a curve style to postscript output.
 
-void CPlot::doc_CvTxLine( const string& line, int num )
+void CPlot::doc_CvTxLine(const string& line, int num)
 {
-    ps_Doc.push_back( "  " + S(num) + " {("+line+")} CvTxLine" );
+    ps_Doc.push_back("  " + S(num) + " {(" + line + ")} CvTxLine");
 }
 
 
 //! Write buffered plot to postscript file.
 
-void CPlot::write_postscript(
-    const string& ps_outdir, const string& ps_head, const string& ps_dict )
+void CPlot::write_postscript(const string& ps_outdir, const string& ps_head, const string& ps_dict)
 {
     // construct output file name:
-    FILE *pssav;
+    FILE* pssav;
     string cmd, outf;
-    while(1) {
-        if (ps_fnum>=999)
+    while (1) {
+        if (ps_fnum >= 999)
             throw S("graph file number overflow");
         outf = triv::wordexp_unique(
-            ps_outdir + str( format( "l%i" ) % ++ps_fnum ) + "." + ( ps_dict=="" ? "psa" : "ps" ) );
-        if( !triv::file_exists( outf.c_str() ) )
+            ps_outdir + str(format("l%i") % ++ps_fnum) + "." + (ps_dict == "" ? "psa" : "ps"));
+        if (!triv::file_exists(outf.c_str()))
             break; // legal exit
     }
     cout << "save plot in " << outf << "\n";
 
     // copy headers to output file:
-    cmd = string("cat ") +
-        ps_dict + " " + // ps_dict may be ""
-        ps_head + " > " +
-        outf + "\n";
-    triv::system( cmd );
+    cmd = string("cat ") + ps_dict + " " + // ps_dict may be ""
+        ps_head + " > " + outf + "\n";
+    triv::system(cmd);
 
     // append specific output to output file:
-    if ( !(pssav = fopen( outf.c_str(), "a+" )) )
+    if (!(pssav = fopen(outf.c_str(), "a+")))
         throw "cannot append contents to file " + outf;
-    for( string lin: ps_accu ){
+    for (string lin : ps_accu) {
         // fprintf does not work here because output line may contain "%"
-        fwrite( lin.c_str(), 1, lin.size(), pssav );
+        fwrite(lin.c_str(), 1, lin.size(), pssav);
     }
 
     // additional output (do not append this to ps_accu to allow
     // further incrementation of ps_accu):
-    fprintf( pssav, "\n{ black 0 -4 13 1.65 NewList\n" );
-    for ( string lin: ps_Doc )
-        fprintf( pssav, "%s\n", lin.c_str() );
-    fprintf( pssav, "} oooinfo 1 eq { exec } { pop } ifelse\n" );
+    fprintf(pssav, "\n{ black 0 -4 13 1.65 NewList\n");
+    for (string lin : ps_Doc)
+        fprintf(pssav, "%s\n", lin.c_str());
+    fprintf(pssav, "} oooinfo 1 eq { exec } { pop } ifelse\n");
 
-    fprintf( pssav,
-             "\n{(%s)}  /filename exch def 10 -2.8 18 showfilename\n\n"
-            " EndFrame\n", outf.c_str() );
+    fprintf(
+        pssav, "\n{(%s)}  /filename exch def 10 -2.8 18 showfilename\n\n"
+               " EndFrame\n",
+        outf.c_str());
 
     // output completed:
     fclose(pssav);
@@ -373,7 +364,7 @@ void CPlot::write_postscript(
 string CPlot::info() const
 {
     string ret;
-    ret  =   "x: " + X.info();
+    ret = "x: " + X.info();
     ret += "  y: " + Y.info();
     return ret;
 }
@@ -381,43 +372,42 @@ string CPlot::info() const
 
 //! Send one line to gnuplot fifo.
 
-void CPlot::gp_write( const string& in )
+void CPlot::gp_write(const string& in)
 {
     string out = in + "\n";
     // cout << "monitor gnuplot driver: '" << out << "'\n";
-    if( write( gp_fifo, out.c_str(), out.size() ) <= 0 )
+    if (write(gp_fifo, out.c_str(), out.size()) <= 0)
         throw S("could not write to gp_fifo");
 }
 
 
 //! Format ticks and tacks for postscript file.
 
-void CPlot::ps_ticktack( const vector<double>& Tacks, int ntpt,
-                         const double *ticklim, const CAxis *A )
+void CPlot::ps_ticktack(
+    const vector<double>& Tacks, int ntpt, const double* ticklim, const CAxis* A)
 {
-    char outlin[ mLin ];
+    char outlin[mLin];
     int i, ntack;
     ntack = Tacks.size();
-    if (ntack > 0 ) {
-        ps_accu.push_back( "  [\n" );
-        if (A->logflag && ( Tacks[0]<1e-3 || Tacks[ntack-1]>1e3 )) {
-            for (i=0; i<ntack; i++) {
-                snprintf( outlin, mLin,
-                          "   %9.6f {(10)(%i)sp()} %%{(%g)}\n",
-                          A->pc(Tacks[i]), (int)(log10(Tacks[i])), (float) Tacks[i]);
-                ps_accu.push_back( outlin );
+    if (ntack > 0) {
+        ps_accu.push_back("  [\n");
+        if (A->logflag && (Tacks[0] < 1e-3 || Tacks[ntack - 1] > 1e3)) {
+            for (i = 0; i < ntack; i++) {
+                snprintf(
+                    outlin, mLin, "   %9.6f {(10)(%i)sp()} %%{(%g)}\n", A->pc(Tacks[i]),
+                    (int)(log10(Tacks[i])), (float)Tacks[i]);
+                ps_accu.push_back(outlin);
             }
         } else {
-            for (i=0; i<ntack; i++) {
-                snprintf( outlin, mLin, "   %9.6f {(%g)}\n",
-                          A->pc(Tacks[i]), (float) Tacks[i]);
-                ps_accu.push_back( outlin );
+            for (i = 0; i < ntack; i++) {
+                snprintf(outlin, mLin, "   %9.6f {(%g)}\n", A->pc(Tacks[i]), (float)Tacks[i]);
+                ps_accu.push_back(outlin);
             }
         }
-        ps_accu.push_back( "  ] SetTacVec\n" );
+        ps_accu.push_back("  ] SetTacVec\n");
     }
-    snprintf( outlin, mLin, "  %g %g %i %i SetTicVec%s\n",
-              A->pc(ticklim[0]), A->pc(ticklim[1]), ntack+2, ntpt,
-              (A->logflag? "Log" : "Lin"));
-    ps_accu.push_back( outlin );
+    snprintf(
+        outlin, mLin, "  %g %g %i %i SetTicVec%s\n", A->pc(ticklim[0]), A->pc(ticklim[1]),
+        ntack + 2, ntpt, (A->logflag ? "Log" : "Lin"));
+    ps_accu.push_back(outlin);
 }
diff --git a/pub/plot/dualplot.hpp b/pub/plot/dualplot.hpp
index 771b0bdf7e1afaf50cc83e28ed3b8d975aabf38e..ad1bc784fa5a43d48db4a182c8a04bcf140729d5 100644
--- a/pub/plot/dualplot.hpp
+++ b/pub/plot/dualplot.hpp
@@ -1,7 +1,7 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                        
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  dualplot.hpp
@@ -12,54 +12,51 @@
 
 //! One plot frame.
 
-class CPlot {
- public:
-    int iPlot;             //!< The index of this frame in NPloWin::Plots.
-    CAxis X;               //!< Limits, log flag &c for x axis.
-    CAxis Y;               //!< Limits, log flag &c for y axis.
+class CPlot
+{
+public:
+    int iPlot; //!< The index of this frame in NPloWin::Plots.
+    CAxis X; //!< Limits, log flag &c for x axis.
+    CAxis Y; //!< Limits, log flag &c for y axis.
     // For data plotting:
-    int maxpoints;         //!< Maximum # points to be plotted without reduction.
-    bool with_errors;      //!< Plot error bars?
+    int maxpoints; //!< Maximum # points to be plotted without reduction.
+    bool with_errors; //!< Plot error bars?
     // For curve plotting:
-    int equipoints;        //!< Start curve plot with this # grid points.
-    bool refine;           //!< Refine curve plot when appropriate?
+    int equipoints; //!< Start curve plot with this # grid points.
+    bool refine; //!< Refine curve plot when appropriate?
 
-    CPlot( int _iPlot, bool _logx, bool _logy );
+    CPlot(int _iPlot, bool _logx, bool _logy);
 
-    void gp_write( const std::string& in );
+    void gp_write(const std::string& in);
     void clear_frame();
-    void plot_frame( const std::string& xlabel, const std::string& ylabel );
-    void add_spec( bool as_line, bool new_style, int style_no,
-                  const std::vector<double>& xp,
-                  const std::vector<double>& yp,
-                  const std::vector<double>& dyp,
-                  const std::vector<std::string>& z,
-                  const std::string& xco,
-                  const std::string& yco,
-                  const std::string& info );
+    void plot_frame(const std::string& xlabel, const std::string& ylabel);
+    void add_spec(
+        bool as_line, bool new_style, int style_no, const std::vector<double>& xp,
+        const std::vector<double>& yp, const std::vector<double>& dyp,
+        const std::vector<std::string>& z, const std::string& xco, const std::string& yco,
+        const std::string& info);
     void show_specs();
-    void doc_TxLine( const std::string& line );
-    void doc_PtTxLine( const std::string& line, int num );
-    void doc_CvTxLine( const std::string& line, int num );
-    void write_postscript( const std::string& ps_outdir,
-                          const std::string& ps_head,
-                          const std::string& ps_dict );
-    void set_aux( const std::string& cmd );
+    void doc_TxLine(const std::string& line);
+    void doc_PtTxLine(const std::string& line, int num);
+    void doc_CvTxLine(const std::string& line, int num);
+    void write_postscript(
+        const std::string& ps_outdir, const std::string& ps_head, const std::string& ps_dict);
+    void set_aux(const std::string& cmd);
     std::string info() const;
 
 private:
     // TODO: some of this could be made local static, if class instances
     // are created anew instead of calling clearFrame().
-    int gp_fifo;      //!< Pipe to Gnuplot.
-    int gp_fno;       //!< Number of Gnuplot input file.
+    int gp_fifo; //!< Pipe to Gnuplot.
+    int gp_fno; //!< Number of Gnuplot input file.
     std::string gp_fnames; //!< List of currently plotted Gnuplot input file names.
 
-    int ps_fnum;      //!< Postscript output file number.
-    int ps_snum;      //!< Slice number in Postscript file.
-    int ps_pnum;      //!< Spectrum number, for setting pstyle.
-    int ps_cnum;      //!< Curve number, for setting cstyle.
-    void ps_ticktack( const std::vector<double>& Tacks, int ntpt,
-                      const double *ticklim, const CAxis *A );
+    int ps_fnum; //!< Postscript output file number.
+    int ps_snum; //!< Slice number in Postscript file.
+    int ps_pnum; //!< Spectrum number, for setting pstyle.
+    int ps_cnum; //!< Curve number, for setting cstyle.
+    void
+    ps_ticktack(const std::vector<double>& Tacks, int ntpt, const double* ticklim, const CAxis* A);
     std::vector<std::string> ps_accu; //!< Main Postscript cache.
-    std::vector<std::string> ps_Doc;  //!< Special Postscript cache for doc lines ?.
+    std::vector<std::string> ps_Doc; //!< Special Postscript cache for doc lines ?.
 };
diff --git a/pub/plot/plowin.cpp b/pub/plot/plowin.cpp
index 1a7619a1a37525a32b511460343774a1886c9150..9bba7e13504091af26cedcca980888aeda1bc68e 100644
--- a/pub/plot/plowin.cpp
+++ b/pub/plot/plowin.cpp
@@ -12,7 +12,7 @@
 
 SPloWin::~SPloWin()
 {
-    for ( auto* pw: Plots )
+    for (auto* pw : Plots)
         delete pw;
 }
 
@@ -21,28 +21,30 @@ SPloWin::~SPloWin()
 void SPloWin::initialize()
 {
     auto m = instance();
-    m->Plots.push_back( new CPlot( m->nPlot(), false, false ) );
-    m->Plots.push_back( new CPlot( m->nPlot(), true,  false ) );
-    m->Plots.push_back( new CPlot( m->nPlot(), false, true ) );
-    m->Plots.push_back( new CPlot( m->nPlot(), true,  true ) );
+    m->Plots.push_back(new CPlot(m->nPlot(), false, false));
+    m->Plots.push_back(new CPlot(m->nPlot(), true, false));
+    m->Plots.push_back(new CPlot(m->nPlot(), false, true));
+    m->Plots.push_back(new CPlot(m->nPlot(), true, true));
     m->iPlot = 0; // current plot window
 }
 
 //! Select default window.
 
-void SPloWin::select( int i ) {
-    if( i<nPlot() )
+void SPloWin::select(int i)
+{
+    if (i < nPlot())
         iPlot = i;
-    else if ( i==nPlot() ){
+    else if (i == nPlot()) {
         iPlot = i;
-        Plots.push_back( new CPlot( nPlot(), false, false ) );
+        Plots.push_back(new CPlot(nPlot(), false, false));
     } else
         throw std::string("invalid graphic window number");
 }
 
 //! List available windows.
 
-void SPloWin::display_list() const {
-    for( int i=0; i<nPlot(); ++i )
-        printf( " %c %1i %s\n", i==iPlot ? '*' : ' ', i, Plots[i]->info().c_str() );
+void SPloWin::display_list() const
+{
+    for (int i = 0; i < nPlot(); ++i)
+        printf(" %c %1i %s\n", i == iPlot ? '*' : ' ', i, Plots[i]->info().c_str());
 }
diff --git a/pub/plot/plowin.hpp b/pub/plot/plowin.hpp
index 08267a4488bc8562166e9cc527a4c0eacf5f1b58..c9d64c36225f038ba44dc4209fb872d67c91def9 100644
--- a/pub/plot/plowin.hpp
+++ b/pub/plot/plowin.hpp
@@ -1,27 +1,28 @@
 //**************************************************************************************************
-//*  FRIDA: fast reliable interactive data analysis                        
-//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-                                
-//*  http://apps.jcns.fz-juelich.de/frida                                   
+//*  FRIDA: fast reliable interactive data analysis
+//*  (C) Joachim Wuttke 1990-, v2(C++) 2001-
+//*  http://apps.jcns.fz-juelich.de/frida
 //**************************************************************************************************
 
 //! \file  plowin.hpp
 //! \brief declares SPloWin, to administer plot windows
 
-#include<vector>
-#include <memory>
 #include "../trivia/singleton.hpp"
+#include <memory>
+#include <vector>
 
 class CPlot;
 
-class SPloWin : public triv::ISingleton<SPloWin> {
- private:
+class SPloWin : public triv::ISingleton<SPloWin>
+{
+private:
     std::vector<CPlot*> Plots;
     int iPlot; //!< current plot window
- public:
+public:
     ~SPloWin();
     static void initialize();
     CPlot* current() { return Plots[iPlot]; }
-    void select( int i );
+    void select(int i);
     int nPlot() const { return Plots.size(); }
     void display_list() const;
 };
diff --git a/pub/readplus/ask.cpp b/pub/readplus/ask.cpp
index bb23b6c8202983e12fad7bcc223f052dbccdce3e..626b382d2fa6be902020bf310904e54e9da9b622 100644
--- a/pub/readplus/ask.cpp
+++ b/pub/readplus/ask.cpp
@@ -5,10 +5,10 @@
 //* http://apps.jcns.fz-juelich.de                                          *//
 //***************************************************************************//
 
+#include <boost/format.hpp>
 #include <cmath>
 #include <cstdio> // for scanf (need detected by g++ 4.x)
 #include <readline/readline.h>
-#include <boost/format.hpp>
 
 #include <iostream>
 
@@ -22,177 +22,180 @@ using std::cout;
 //*  Low-level implementation                                               *//
 //***************************************************************************//
 
-#define ASK_DEF_GIVEN     1
-#define ASK_DEF_NOT_SHOW  2
-#define ASK_WORD          4
+#define ASK_DEF_GIVEN 1
+#define ASK_DEF_NOT_SHOW 2
+#define ASK_WORD 4
 
 //! Retrieve or query a Boolean value.
-bool bask( const string& quest, const int flags, const bool& defval)
+bool bask(const string& quest, const int flags, const bool& defval)
 {
     string defstr("");
-    if( flags & ASK_DEF_GIVEN )
+    if (flags & ASK_DEF_GIVEN)
         defstr = defval ? "y" : "n";
 
     string prompt = quest;
-    if ( defstr!="" && !(flags & ASK_DEF_NOT_SHOW) )
+    if (defstr != "" && !(flags & ASK_DEF_NOT_SHOW))
         prompt += " [" + defstr + "]";
     prompt += " ";
 
-    for( ;; ) {
+    for (;;) {
         string resp = NMacro::readwd(prompt);
-        if        ( resp == "" || resp == "\\DEFAULT" ) {
-            if ( defstr!="" )
+        if (resp == "" || resp == "\\DEFAULT") {
+            if (defstr != "")
                 return defval;
             cout << "no default available\n";
-        } else if ( resp == "y" ) {
+        } else if (resp == "y") {
             return true;
-        } else if ( resp == "n" ) {
+        } else if (resp == "n") {
             return false;
         } else {
             cout << "required input type: boolean ('y' or 'n')\n";
-            if( defstr!="" )
-                cout << "just press ENTER to accept default [" <<
-                    defstr << "]\n";
+            if (defstr != "")
+                cout << "just press ENTER to accept default [" << defstr << "]\n";
         }
     }
 }
 
 //! Retrieve or query an integer value.
-int iask( const string& quest, const int flags, const int& defval)
+int iask(const string& quest, const int flags, const int& defval)
 {
     string defstr("");
-    if( flags & ASK_DEF_GIVEN )
-        defstr = str( format( "%i" ) % defval );
+    if (flags & ASK_DEF_GIVEN)
+        defstr = str(format("%i") % defval);
 
     string prompt = quest;
-    if ( defstr!="" && !(flags & ASK_DEF_NOT_SHOW) )
+    if (defstr != "" && !(flags & ASK_DEF_NOT_SHOW))
         prompt += " [" + defstr + "] ?";
     prompt += " ";
 
-    for( ;; ) {
+    for (;;) {
         string resp = NMacro::readwd(prompt);
         int rexp, i;
         int val;
-        if        ( resp == "" || resp == "\\DEFAULT" ) {
-            if ( defstr!="" )
+        if (resp == "" || resp == "\\DEFAULT") {
+            if (defstr != "")
                 return defval;
             cout << "no default available\n";
-        } else if (( sscanf(resp.c_str(), "%ie%i", &val, &rexp)==2 ||
-                     sscanf(resp.c_str(), "%iE%i", &val, &rexp)==2 ) &&
-                   rexp>=0 ) {
-            for ( i=0; i<rexp; ++i ) { val *= 10; }
+        } else if (
+            (sscanf(resp.c_str(), "%ie%i", &val, &rexp) == 2
+             || sscanf(resp.c_str(), "%iE%i", &val, &rexp) == 2)
+            && rexp >= 0) {
+            for (i = 0; i < rexp; ++i) {
+                val *= 10;
+            }
             return val;
-        } else if (sscanf(resp.c_str(), "%i", &val)==1) {
+        } else if (sscanf(resp.c_str(), "%i", &val) == 1) {
             return val;
         } else {
             cout << "required input type: integer\n";
-            if( defstr!="" )
-                cout << "just press ENTER to accept default [" <<
-                    defstr << "]\n";
+            if (defstr != "")
+                cout << "just press ENTER to accept default [" << defstr << "]\n";
         }
     }
 }
 
 //! Retrieve or query an index value.
-size_t zask( const string& quest, const int flags, const size_t& defval)
+size_t zask(const string& quest, const int flags, const size_t& defval)
 {
     string defstr("");
-    if( flags & ASK_DEF_GIVEN )
-        defstr = str( format( "%zu" ) % defval );
+    if (flags & ASK_DEF_GIVEN)
+        defstr = str(format("%zu") % defval);
 
     string prompt = quest;
-    if ( defstr!="" && !(flags & ASK_DEF_NOT_SHOW) )
+    if (defstr != "" && !(flags & ASK_DEF_NOT_SHOW))
         prompt += " [" + defstr + "] ?";
     prompt += " ";
 
-    for( ;; ) {
+    for (;;) {
         string resp = NMacro::readwd(prompt);
         int val;
-        if        ( resp == "" || resp == "\\DEFAULT" ) {
-            if ( defstr!="" )
+        if (resp == "" || resp == "\\DEFAULT") {
+            if (defstr != "")
                 return defval;
             cout << "no default available\n";
-        } else if (sscanf(resp.c_str(), "%i", &val)==1) {
-            if( val >= 0 )
+        } else if (sscanf(resp.c_str(), "%i", &val) == 1) {
+            if (val >= 0)
                 return val;
             cout << "nonnegative integer requested (or \\q to escape)\n";
         } else {
             cout << "required input type: unsigned integer\n";
-            if( defstr!="" )
-                cout << "just press ENTER to accept default [" <<
-                    defstr << "]\n";
+            if (defstr != "")
+                cout << "just press ENTER to accept default [" << defstr << "]\n";
         }
     }
 }
 
 //! Retrieve or query an double value.
-double dask( const string& quest, const int flags, const double& defval)
+double dask(const string& quest, const int flags, const double& defval)
 {
     string defstr("");
-    if( flags & ASK_DEF_GIVEN )
-        defstr = str( format( "%g" ) % defval );
+    if (flags & ASK_DEF_GIVEN)
+        defstr = str(format("%g") % defval);
 
     string prompt = quest;
-    if ( defstr!="" && !(flags & ASK_DEF_NOT_SHOW) )
+    if (defstr != "" && !(flags & ASK_DEF_NOT_SHOW))
         prompt += " [" + defstr + "] ?";
     prompt += " ";
 
-    for( ;; ) {
+    for (;;) {
         string resp = NMacro::readwd(prompt);
-        if        ( resp == "" || resp == "\\DEFAULT" ) {
-            if ( defstr!="" )
+        if (resp == "" || resp == "\\DEFAULT") {
+            if (defstr != "")
                 return defval;
             cout << "no default available\n";
-        } else if( resp=="-inf" || resp=="-oo" ){
+        } else if (resp == "-inf" || resp == "-oo") {
             return -INFINITY;
-        } else if( resp=="inf" || resp=="oo" || resp=="+inf" || resp=="+oo" ){
+        } else if (resp == "inf" || resp == "oo" || resp == "+inf" || resp == "+oo") {
             return INFINITY;
-        } else if( strchr("+-0123456789.", resp[0])) {
+        } else if (strchr("+-0123456789.", resp[0])) {
             int rexp;
             double val, mant;
-            if ( sscanf(resp.c_str(), "%lgm%i", &mant, &rexp)==2 )
+            if (sscanf(resp.c_str(), "%lgm%i", &mant, &rexp) == 2)
                 return mant * pow(10.e0, (double)(-rexp));
-            else if ( sscanf(resp.c_str(), "%lg", &val)==1 )
+            else if (sscanf(resp.c_str(), "%lg", &val) == 1)
                 return val;
         } else {
             cout << "required input type: floating-point\n";
-            if( defstr!="" )
-                cout << "just press ENTER to accept default [" <<
-                    defstr << "]\n";
+            if (defstr != "")
+                cout << "just press ENTER to accept default [" << defstr << "]\n";
         }
     }
 }
 
 //! Retrieve or query a word (a string without whitespace or in quotes[nyi]).
-string wask( const string& quest, const int flags, const string& defval)
+string wask(const string& quest, const int flags, const string& defval)
 {
     string defstr("");
-    if( flags & ASK_DEF_GIVEN )
+    if (flags & ASK_DEF_GIVEN)
         defstr = defval;
 
     string prompt = quest;
-    if ( defstr!="" && !(flags & ASK_DEF_NOT_SHOW) )
+    if (defstr != "" && !(flags & ASK_DEF_NOT_SHOW))
         prompt += " [" + defstr + "] ?";
     prompt += " ";
 
-    for( ;; ) {
+    for (;;) {
         string resp = NMacro::readwd(prompt);
-        if        ( resp == "" || resp == "\\DEFAULT" ) {
-            if ( defstr!="" )
+        if (resp == "" || resp == "\\DEFAULT") {
+            if (defstr != "")
                 return defval;
             else
                 return "";
-        } else if ( resp == "\\EMPTYSTRING" ) {
+        } else if (resp == "\\EMPTYSTRING") {
             return "";
-        } else if ( resp == "?" ) {
+        } else if (resp == "?") {
             cout << "required input type: word (string without blanks)\n";
-            if( defstr!="" ){
-                cout << "just press ENTER to accept default [" <<
-                    defstr << "]\n";
+            if (defstr != "") {
+                cout << "just press ENTER to accept default [" << defstr << "]\n";
                 cout << "use \\ to enter an empty word\n";
             }
-            cout << "use ""?"" to escape this help\n";
-        } else if ( resp == """?""" ) {
+            cout << "use "
+                    "?"
+                    " to escape this help\n";
+        } else if (
+            resp == ""
+                    "?"
+                    "") {
             return "?";
         } else {
             return resp;
@@ -201,35 +204,39 @@ string wask( const string& quest, const int flags, const string& defval)
 }
 
 //! Retrieve or query a string (consume input up to end of line).
-string sask( const string& quest, const int flags, const string& defval)
+string sask(const string& quest, const int flags, const string& defval)
 {
     string defstr("");
-    if( flags & ASK_DEF_GIVEN )
+    if (flags & ASK_DEF_GIVEN)
         defstr = defval;
 
     string prompt = quest;
-    if ( defstr!="" && !(flags & ASK_DEF_NOT_SHOW) )
+    if (defstr != "" && !(flags & ASK_DEF_NOT_SHOW))
         prompt += " [" + defstr + "] ?";
     prompt += " ";
 
-    for( ;; ) {
+    for (;;) {
         string resp = NMacro::readln(prompt);
-        if        ( resp == "" || resp == "\\DEFAULT" ) {
-            if ( defstr!="" )
+        if (resp == "" || resp == "\\DEFAULT") {
+            if (defstr != "")
                 return defval;
             else
                 return "";
-        } else if ( resp == "\\EMPTYSTRING" ) {
+        } else if (resp == "\\EMPTYSTRING") {
             return "";
-        } else if ( resp == "?" ) {
+        } else if (resp == "?") {
             cout << "required input type: string\n";
-            if( defstr!="" ){
-                cout << "just press ENTER to accept default [" <<
-                    defstr << "]\n";
+            if (defstr != "") {
+                cout << "just press ENTER to accept default [" << defstr << "]\n";
                 cout << "use \\ to enter an empty word\n";
             }
-            cout << "use ""?"" to escape this help\n";
-        } else if ( resp == """?""" ) {
+            cout << "use "
+                    "?"
+                    " to escape this help\n";
+        } else if (
+            resp == ""
+                    "?"
+                    "") {
             return "?";
         } else {
             return resp;
@@ -243,27 +250,27 @@ string sask( const string& quest, const int flags, const string& defval)
 //***************************************************************************//
 
 //! Retrieve or query a Boolean value, no default.
-bool   bask( const string& quest) { return bask(quest, 0, 0); }
+bool bask(const string& quest) { return bask(quest, 0, 0); }
 //! Retrieve or query an integer value, no default.
-int    iask( const string& quest) { return iask(quest, 0, 0); }
+int iask(const string& quest) { return iask(quest, 0, 0); }
 //! Retrieve or query an index value, no default.
-size_t zask( const string& quest) { return zask(quest, 0, 0); }
+size_t zask(const string& quest) { return zask(quest, 0, 0); }
 //! Retrieve or query a double value, no default.
-double dask( const string& quest) { return dask(quest, 0, 0); }
+double dask(const string& quest) { return dask(quest, 0, 0); }
 //! Retrieve or query a word, no default.
-string wask( const string& quest) { return wask(quest, 0, ""); }
+string wask(const string& quest) { return wask(quest, 0, ""); }
 //! Retrieve or query a string, no default.
-string sask( const string& quest) { return sask(quest, 0, ""); }
+string sask(const string& quest) { return sask(quest, 0, ""); }
 
 //! Retrieve or query a Boolean value, with default.
-bool   bask( const string& quest, const bool&   v) { return bask(quest, 1, v); }
+bool bask(const string& quest, const bool& v) { return bask(quest, 1, v); }
 //! Retrieve or query an integer value, with default.
-int    iask( const string& quest, const int&    v) { return iask(quest, 1, v); }
+int iask(const string& quest, const int& v) { return iask(quest, 1, v); }
 //! Retrieve or query an index value, with default.
-size_t zask( const string& quest, const int&    v) { return zask(quest, 1, v); }
+size_t zask(const string& quest, const int& v) { return zask(quest, 1, v); }
 //! Retrieve or query a double value, with default.
-double dask( const string& quest, const double& v) { return dask(quest, 1, v); }
+double dask(const string& quest, const double& v) { return dask(quest, 1, v); }
 //! Retrieve or query a word, with default.
-string wask( const string& quest, const string& v) { return wask(quest, 1, v); }
+string wask(const string& quest, const string& v) { return wask(quest, 1, v); }
 //! Retrieve or query a string, with default.
-string sask( const string& quest, const string& v) { return sask(quest, 1, v); }
+string sask(const string& quest, const string& v) { return sask(quest, 1, v); }
diff --git a/pub/readplus/ask.hpp b/pub/readplus/ask.hpp
index 34ab44ed7856bcbb9f11be2e7cec5ae93fb9e963..fb06d8487d93e08c3a1bd52db8784029e9d82bbb 100644
--- a/pub/readplus/ask.hpp
+++ b/pub/readplus/ask.hpp
@@ -6,27 +6,27 @@
 //***************************************************************************//
 
 //! Retrieve or query a Boolean value, no default.
-bool   bask( const std::string& quest);
+bool bask(const std::string& quest);
 //! Retrieve or query an integer value, no default.
-int    iask( const std::string& quest);
+int iask(const std::string& quest);
 //! Retrieve or query an index value, no default.
-size_t zask( const std::string& quest);
+size_t zask(const std::string& quest);
 //! Retrieve or query a double value, no default.
-double dask( const std::string& quest);
+double dask(const std::string& quest);
 //! Retrieve or query a word, no default.
-std::string wask( const std::string& quest);
+std::string wask(const std::string& quest);
 //! Retrieve or query a std::string, no default.
-std::string sask( const std::string& quest);
+std::string sask(const std::string& quest);
 
 //! Retrieve or query a Boolean value, with default.
-bool   bask( const std::string& quest, const bool&   v);
+bool bask(const std::string& quest, const bool& v);
 //! Retrieve or query an integer value, with default.
-int    iask( const std::string& quest, const int&    v);
+int iask(const std::string& quest, const int& v);
 //! Retrieve or query an index value, with default.
-size_t zask( const std::string& quest, const size_t& v);
+size_t zask(const std::string& quest, const size_t& v);
 //! Retrieve or query a double value, with default.
-double dask( const std::string& quest, const double& v);
+double dask(const std::string& quest, const double& v);
 //! Retrieve or query a word, with default.
-std::string wask( const std::string& quest, const std::string& v);
+std::string wask(const std::string& quest, const std::string& v);
 //! Retrieve or query a std::string, with default.
-std::string sask( const std::string& quest, const std::string& v);
+std::string sask(const std::string& quest, const std::string& v);
diff --git a/pub/readplus/macro.cpp b/pub/readplus/macro.cpp
index aeb0db686828992555f95cf91e03efc257febaf2..839391176b75be7b4b5dbfd328f55d951b4aab01 100644
--- a/pub/readplus/macro.cpp
+++ b/pub/readplus/macro.cpp
@@ -5,34 +5,36 @@
 //* http://apps.jcns.fz-juelich.de
 //**************************************************************************************************
 
-#include <wordexp.h>
 #include <boost/algorithm/string/trim.hpp>
+#include <wordexp.h>
 
-#include <iostream>
+#include <deque>
 #include <fstream>
+#include <iostream>
 #include <map>
-#include <deque>
+#include <vector>
 
-#include "../trivia/string_ops.hpp"
 #include "../trivia/file_ops.hpp"
-#include "readln.hpp"
+#include "../trivia/string_ops.hpp"
 #include "macro.hpp"
+#include "readln.hpp"
 
 using std::string;
 using std::ifstream;
 using std::cout;
 
-namespace NMacro {
-    // internals, used only in this file:
-    std::deque<string> stack;
+namespace NMacro
+{
+// internals, used only in this file:
+std::deque<string> stack;
 
-    // the following are only called indirectly through macros:
-    void metacmd_incl( string r );
+// the following are only called indirectly through macros:
+void metacmd_incl(string r);
 
-    // auxiliary:
-    string wordexp_cpp_unique( const string& s );
-    string string_extract_quoted( string *in );
-    bool is_separator( char c );
+// auxiliary:
+string wordexp_cpp_unique(const string& s);
+string string_extract_quoted(string* in);
+bool is_separator(char c);
 }
 
 
@@ -43,33 +45,33 @@ namespace NMacro {
 
 //! Take a line from the stack, for use in readln or readwd.
 
-string NMacro::readln( const string& prompt, ifstream* F, int* lineno )
+string NMacro::readln(const string& prompt, ifstream* F, int* lineno)
 {
     // Obtain input line.
     string in;
-    if ( stack.empty() ) {
-        if( F ) {
+    if (stack.empty()) {
+        if (F) {
             ++(*lineno);
-            if( !(getline(*F, in)) )
+            if (!(getline(*F, in)))
                 return "EOF";
         } else {
-            in = NReadln::readline( prompt );
+            in = NReadln::readline(prompt);
         }
     } else {
         in = *(stack.begin());
         stack.pop_front();
     }
-    boost::trim( in );
-    if      ( in=="" ) {
+    boost::trim(in);
+    if (in == "") {
         return "";
-    } else if ( in[0]=='#' ) {
+    } else if (in[0] == '#') {
         return "";
-    } else if ( in[0]=='\\' ) {  // macro \..
-        return exemac( in );
-    } else if ( in=="''" ) { // needed ?
-        return "\\EMPTYSTRING";  // explicit empty string, not default
+    } else if (in[0] == '\\') { // macro \..
+        return exemac(in);
+    } else if (in == "''") { // needed ?
+        return "\\EMPTYSTRING"; // explicit empty string, not default
     }
-    if ( is_separator( in[0] ) )
+    if (is_separator(in[0]))
         throw "BUG: invalid leading space in input [" + in + "]";
     return in;
 }
@@ -77,13 +79,13 @@ string NMacro::readln( const string& prompt, ifstream* F, int* lineno )
 
 //! Take word from stack. Prompt for input if stack is empty.
 
-string NMacro::readwd( const string& prompt )
+string NMacro::readwd(const string& prompt)
 {
-    string in = readln( prompt );
-    string::size_type j = in.find_first_of( " \t" );
-    if ( j!=string::npos ) {
-        push_remainder( in.substr(j) );
-        return in.substr( 0, j );
+    string in = readln(prompt);
+    string::size_type j = in.find_first_of(" \t");
+    if (j != string::npos) {
+        push_remainder(in.substr(j));
+        return in.substr(0, j);
     }
     return in;
 }
@@ -91,37 +93,33 @@ string NMacro::readwd( const string& prompt )
 
 //! Clear input stack.
 
-void NMacro::clear()
-{
-    stack.clear();
-}
+void NMacro::clear() { stack.clear(); }
 
 
 //! Execute metacommand or substitute macro.
 
-string NMacro::exemac( const string& in )
+string NMacro::exemac(const string& in)
 {
     string cmd, arg;
-    triv::string_extract_word( in, &cmd, &arg );
-    std::map<string,string>::iterator pos2;
-    if        ( cmd=="\\?" || cmd=="\\h" ) {
-        cout <<
-            "  meta commands:\n"
-            "    \\i <file>               include file\n"
-            "    \\q                      escape to main menu\n"
-            "    \\wh                     write history\n";
+    triv::string_extract_word(in, &cmd, &arg);
+    std::map<string, string>::iterator pos2;
+    if (cmd == "\\?" || cmd == "\\h") {
+        cout << "  meta commands:\n"
+                "    \\i <file>               include file\n"
+                "    \\q                      escape to main menu\n"
+                "    \\wh                     write history\n";
         return "";
-    } else if ( cmd=="\\" ) {
-        push_remainder( arg );
+    } else if (cmd == "\\") {
+        push_remainder(arg);
         return "\\DEFAULT";
-    } else if ( in=="\\q" ) {
-        throw string( "user escape to main menu" );
-    } else if ( cmd=="\\wh" ) {
-        NReadln::write_history( "history" );
-        push_remainder( arg );
+    } else if (in == "\\q") {
+        throw string("user escape to main menu");
+    } else if (cmd == "\\wh") {
+        NReadln::write_history("history");
+        push_remainder(arg);
         return "";
-    } else if ( cmd=="\\i" ) {
-        metacmd_incl( arg );
+    } else if (cmd == "\\i") {
+        metacmd_incl(arg);
         return "";
     }
     throw "macro " + cmd + " undefined";
@@ -135,29 +133,29 @@ string NMacro::exemac( const string& in )
 
 //! Push _rem_ back on the input stack.
 
-void NMacro::push_remainder( const string& rem )
+void NMacro::push_remainder(const string& rem)
 {
-    if ( rem=="" )
+    if (rem == "")
         return; // nothing to do
-    if ( !is_separator( rem[0] ) )
+    if (!is_separator(rem[0]))
         throw "missing separator at beginning of [" + rem + "]";
-    string::size_type j = rem.find_first_not_of( " \t" );
-    if ( j!=string::npos )
-        stack.push_front( rem.substr(j) );
+    string::size_type j = rem.find_first_not_of(" \t");
+    if (j != string::npos)
+        stack.push_front(rem.substr(j));
 }
 
 
 //! Returns one file name, obtained by bash expansion of argument.
 
-string NMacro::wordexp_cpp_unique( const string& s )
+string NMacro::wordexp_cpp_unique(const string& s)
 {
     wordexp_t p;
-    if( wordexp(s.c_str(), &p, 0) )
+    if (wordexp(s.c_str(), &p, 0))
         throw "cannot expand " + s;
-    if( p.we_wordc!=1 )
+    if (p.we_wordc != 1)
         throw "expansion of " + s + " not unique";
     string ret = p.we_wordv[0];
-    wordfree( &p );
+    wordfree(&p);
     return ret;
 }
 
@@ -167,20 +165,20 @@ string NMacro::wordexp_cpp_unique( const string& s )
 //! Input:  command stack r, with script filename on top.
 //! Output: command stack, with script filename substituted by script contents.
 
-void NMacro::metacmd_incl( string r )
+void NMacro::metacmd_incl(string r)
 {
     string ftxt;
-    triv::string_extract_word( r, &ftxt, &r );
-    if( r!="" )
-        stack.push_front( r );
-    string fnam = NMacro::wordexp_cpp_unique( ftxt );
-    FILE *fd;
-    if( !(fd = fopen( fnam.c_str(), "r" )) )
+    triv::string_extract_word(r, &ftxt, &r);
+    if (r != "")
+        stack.push_front(r);
+    string fnam = NMacro::wordexp_cpp_unique(ftxt);
+    FILE* fd;
+    if (!(fd = fopen(fnam.c_str(), "r")))
         throw "cannot open file " + fnam;
     string s;
-    while ( triv::freadln( fd, &s ) )
-        stack.push_back( s );
-    fclose( fd );
+    while (triv::freadln(fd, &s))
+        stack.push_back(s);
+    fclose(fd);
 }
 
 
@@ -190,7 +188,4 @@ void NMacro::metacmd_incl( string r )
 
 //! Test whether argument is a blank or a tab.
 
-bool NMacro::is_separator( char c )
-{
-    return string(" \t").find_first_of( c )!=string::npos;
-}
+bool NMacro::is_separator(char c) { return string(" \t").find_first_of(c) != string::npos; }
diff --git a/pub/readplus/macro.hpp b/pub/readplus/macro.hpp
index fa6e894d7f18d4d69eeb43f6cec4946bdbc93302..79d1268c647f8254814652630bac8d18b9761774 100644
--- a/pub/readplus/macro.hpp
+++ b/pub/readplus/macro.hpp
@@ -7,10 +7,11 @@
 
 //! Outer readline wrapper, input stack, macro engine.
 
-namespace NMacro {
-    std::string exemac(const std::string& in);
-    std::string readln(const std::string& prompt, std::ifstream* F=NULL, int* lineno=nullptr);
-    std::string readwd(const std::string& prompt);
-    void clear();
-    void push_remainder( const std::string& rem );
+namespace NMacro
+{
+std::string exemac(const std::string& in);
+std::string readln(const std::string& prompt, std::ifstream* F = NULL, int* lineno = nullptr);
+std::string readwd(const std::string& prompt);
+void clear();
+void push_remainder(const std::string& rem);
 }
diff --git a/pub/readplus/readln.cpp b/pub/readplus/readln.cpp
index 5c857d4bad10f5607356eeb5efb5650c4367c626..52f62087a75864f0412f6438159f7a824e2f0fc7 100644
--- a/pub/readplus/readln.cpp
+++ b/pub/readplus/readln.cpp
@@ -6,8 +6,8 @@
 //**************************************************************************************************
 
 #include <iostream>
-#include <readline/readline.h>
 #include <readline/history.h>
+#include <readline/readline.h>
 
 #include "readln.hpp"
 
@@ -19,68 +19,69 @@ using std::cout;
 //**************************************************************************************************
 
 
-namespace NReadln {
-    int PF1( int c, int k );
-    int PF2( int c, int k );
-    int PF3( int c, int k );
-    int PF4( int c, int k );
-    int F05( int c, int k );
-    int F06( int c, int k );
-    int F07( int c, int k );
-    int F08( int c, int k );
-    int F09( int c, int k );
-    int F10( int c, int k );
-    int F11( int c, int k );
-    int F12( int c, int k );
-    int function_key( int num );
+namespace NReadln
+{
+int PF1(int c, int k);
+int PF2(int c, int k);
+int PF3(int c, int k);
+int PF4(int c, int k);
+int F05(int c, int k);
+int F06(int c, int k);
+int F07(int c, int k);
+int F08(int c, int k);
+int F09(int c, int k);
+int F10(int c, int k);
+int F11(int c, int k);
+int F12(int c, int k);
+int function_key(int num);
 }
 
 
 //! Executed when readline encounters a function key (PF1 ... F12).
 
-int NReadln::function_key( int num )
+int NReadln::function_key(int num)
 {
     cout << "\n"; // the user did not terminate with \n, so we have to do it
     char out[5];
-    sprintf( out, "FK%02i", num );
-    rl_insert_text( out );
+    sprintf(out, "FK%02i", num);
+    rl_insert_text(out);
     rl_done = 1;
-    rl_on_new_line ();
+    rl_on_new_line();
     return 0;
 }
 
 // Functions readln_PF1 etc just call readln_function_key.
 
-int NReadln::PF1( int c, int k ) { return NReadln::function_key( 1); }
-int NReadln::PF2( int c, int k ) { return NReadln::function_key( 2); }
-int NReadln::PF3( int c, int k ) { return NReadln::function_key( 3); }
-int NReadln::PF4( int c, int k ) { return NReadln::function_key( 4); }
-int NReadln::F05( int c, int k ) { return NReadln::function_key( 5); }
-int NReadln::F06( int c, int k ) { return NReadln::function_key( 6); }
-int NReadln::F07( int c, int k ) { return NReadln::function_key( 7); }
-int NReadln::F08( int c, int k ) { return NReadln::function_key( 8); }
-int NReadln::F09( int c, int k ) { return NReadln::function_key( 9); }
-int NReadln::F10( int c, int k ) { return NReadln::function_key(10); }
-int NReadln::F11( int c, int k ) { return NReadln::function_key(11); }
-int NReadln::F12( int c, int k ) { return NReadln::function_key(12); }
+int NReadln::PF1(int c, int k) { return NReadln::function_key(1); }
+int NReadln::PF2(int c, int k) { return NReadln::function_key(2); }
+int NReadln::PF3(int c, int k) { return NReadln::function_key(3); }
+int NReadln::PF4(int c, int k) { return NReadln::function_key(4); }
+int NReadln::F05(int c, int k) { return NReadln::function_key(5); }
+int NReadln::F06(int c, int k) { return NReadln::function_key(6); }
+int NReadln::F07(int c, int k) { return NReadln::function_key(7); }
+int NReadln::F08(int c, int k) { return NReadln::function_key(8); }
+int NReadln::F09(int c, int k) { return NReadln::function_key(9); }
+int NReadln::F10(int c, int k) { return NReadln::function_key(10); }
+int NReadln::F11(int c, int k) { return NReadln::function_key(11); }
+int NReadln::F12(int c, int k) { return NReadln::function_key(12); }
 
 
 //! Bind function keys.
 
 int NReadln::set_bindings()
 {
-    rl_bind_keyseq( "\\eOP",   NReadln::PF1 );
-    rl_bind_keyseq( "\\eOQ",   NReadln::PF2 );
-    rl_bind_keyseq( "\\eOR",   NReadln::PF3 );
-    rl_bind_keyseq( "\\eOS",   NReadln::PF4 );
-    rl_bind_keyseq( "\\e[15~", NReadln::F05 );
-    rl_bind_keyseq( "\\e[17~", NReadln::F06 );
-    rl_bind_keyseq( "\\e[18~", NReadln::F07 );
-    rl_bind_keyseq( "\\e[19~", NReadln::F08 );
-    rl_bind_keyseq( "\\e[20~", NReadln::F09 );
-    rl_bind_keyseq( "\\e[21~", NReadln::F10 );
-    rl_bind_keyseq( "\\e[23~", NReadln::F11 );
-    rl_bind_keyseq( "\\e[24~", NReadln::F12 );
+    rl_bind_keyseq("\\eOP", NReadln::PF1);
+    rl_bind_keyseq("\\eOQ", NReadln::PF2);
+    rl_bind_keyseq("\\eOR", NReadln::PF3);
+    rl_bind_keyseq("\\eOS", NReadln::PF4);
+    rl_bind_keyseq("\\e[15~", NReadln::F05);
+    rl_bind_keyseq("\\e[17~", NReadln::F06);
+    rl_bind_keyseq("\\e[18~", NReadln::F07);
+    rl_bind_keyseq("\\e[19~", NReadln::F08);
+    rl_bind_keyseq("\\e[20~", NReadln::F09);
+    rl_bind_keyseq("\\e[21~", NReadln::F10);
+    rl_bind_keyseq("\\e[23~", NReadln::F11);
+    rl_bind_keyseq("\\e[24~", NReadln::F12);
     return 0;
 }
 
@@ -92,29 +93,26 @@ int NReadln::set_bindings()
 
 //! Initializes readline and history.
 
-void NReadln::initialize()
-{
-    NReadln::set_bindings();
-}
+void NReadln::initialize() { NReadln::set_bindings(); }
 
 
 //! Get interactive input via the readline/history API.
 
-string NReadln::readline( const string& prompt )
+string NReadln::readline(const string& prompt)
 {
-    char *inp;
+    char* inp;
     string ret;
-    inp = ::readline( prompt.c_str() ); // from libreadline
-    if( inp && *inp )
-        add_history( inp );  // from libhistory
+    inp = ::readline(prompt.c_str()); // from libreadline
+    if (inp && *inp)
+        add_history(inp); // from libhistory
     ret = inp;
-    free( inp );
+    free(inp);
     return ret;
 }
 
-void NReadln::write_history( const string& fname )
+void NReadln::write_history(const string& fname)
 {
-    remove_history( where_history() );
-    ::write_history( fname.c_str() );
+    remove_history(where_history());
+    ::write_history(fname.c_str());
     cout << "saved history to file '" << fname << "'\n";
 }
diff --git a/pub/readplus/readln.hpp b/pub/readplus/readln.hpp
index b4e3230cc8d877dcd21c8b1312000eace95e472b..71c3471ef4ce1bdcbe49136b730109056ec89386 100644
--- a/pub/readplus/readln.hpp
+++ b/pub/readplus/readln.hpp
@@ -5,11 +5,10 @@
 //* http://apps.jcns.fz-juelich.de
 //**************************************************************************************************
 
-namespace NReadln {
-    void initialize();
-    int set_bindings();
-    std::string readline( const std::string& );
-    void write_history( const std::string& fname );
+namespace NReadln
+{
+void initialize();
+int set_bindings();
+std::string readline(const std::string&);
+void write_history(const std::string& fname);
 }
-
-
diff --git a/pub/trivia/file_ops.cpp b/pub/trivia/file_ops.cpp
index 1e0c15622aadd90b39166dee16759902e2c070db..3e43738c95454a8bbaf09fbf449eda8ccbd8d5f7 100644
--- a/pub/trivia/file_ops.cpp
+++ b/pub/trivia/file_ops.cpp
@@ -18,9 +18,9 @@ using std::vector;
 using std::cout;
 using std::cerr;
 
+#include "file_ops.hpp"
 #include "string_convs.hpp"
 #include "string_ops.hpp"
-#include "file_ops.hpp"
 
 
 //**************************************************************************************************
@@ -29,31 +29,31 @@ using std::cerr;
 
 //! Execute operation system call, and assert return code 0.
 
-void triv::system( string cmd, bool debug )
+void triv::system(string cmd, bool debug)
 {
-    if( debug )
+    if (debug)
         cout << "DEBUG system call '" + cmd + "'\n";
-    int ret = ::system( cmd.c_str() );
-    if( ret )
+    int ret = ::system(cmd.c_str());
+    if (ret)
         throw "Command '" + cmd + "' returned error code " + strg(ret);
-    else if ( debug )
+    else if (debug)
         cout << "DEBUG system call -> return value " << ret << "\n";
 }
 
 //! Execute operation system call, and return its stdout.
 
-string triv::system_read( string cmd, bool debug )
+string triv::system_read(string cmd, bool debug)
 {
-    if( debug )
+    if (debug)
         cout << "DEBUG system call '" + cmd + "'\n";
-    FILE *f = ::popen( cmd.c_str(), "r" );
+    FILE* f = ::popen(cmd.c_str(), "r");
 
     string ret;
     char buf[1024];
-    while( fgets( buf, 1024, f ) )
+    while (fgets(buf, 1024, f))
         ret += buf;
 
-    pclose( f );
+    pclose(f);
     return ret;
 }
 
@@ -64,15 +64,13 @@ string triv::system_read( string cmd, bool debug )
 
 //! Test whether file exists.
 
-bool triv::file_exists( const string& path )
+bool triv::file_exists(const string& path)
 {
     struct stat fileStat;
-    if ( stat(path.c_str(), &fileStat) )
-    {
+    if (stat(path.c_str(), &fileStat)) {
         return 0;
     }
-    if ( !S_ISREG(fileStat.st_mode) )
-    {
+    if (!S_ISREG(fileStat.st_mode)) {
         return 0;
     }
     return 1;
@@ -80,79 +78,84 @@ bool triv::file_exists( const string& path )
 
 //! Analyses a file name: divides "dir/short.ext" into "dir", "short", "ext".
 
-void triv::fname_divide( const string& fname, string *fdir, string *fshort, string *fext )
+void triv::fname_divide(const string& fname, string* fdir, string* fshort, string* fext)
 // each of the three output arguments, when called with a nullptr, will not be computed
 {
     size_t idir = fname.rfind("/") + 1;
-    if( fdir ) *fdir = fname.substr( 0, idir );
+    if (fdir)
+        *fdir = fname.substr(0, idir);
 
     size_t iext = fname.rfind(string(".")) + 1;
-    if ( iext<=idir ) {
-        if( fext ) *fext = "";
-        if( fshort ) *fshort = fname.substr( idir );
+    if (iext <= idir) {
+        if (fext)
+            *fext = "";
+        if (fshort)
+            *fshort = fname.substr(idir);
     } else {
-        if( fext ) *fext = fname.substr( iext );
-        if( fshort ) *fshort = fname.substr( idir, iext-idir-1 );
+        if (fext)
+            *fext = fname.substr(iext);
+        if (fshort)
+            *fshort = fname.substr(idir, iext - idir - 1);
     }
 }
 
 
 //! Returns a unique file name obtained by Posix shell expansion of a given pattern.
 
-string triv::wordexp_unique( const string& s )
+string triv::wordexp_unique(const string& s)
 {
     wordexp_t p;
-    int err = wordexp( s.c_str(), &p, 0 );
-    switch(err) {
+    int err = wordexp(s.c_str(), &p, 0);
+    switch (err) {
     case 0:
         break;
     case WRDE_BADCHAR:
-        throw "illegal character in '" + s +"'";
+        throw "illegal character in '" + s + "'";
     case WRDE_BADVAL:
-        throw "undefined shell variable in '" + s +"'";
+        throw "undefined shell variable in '" + s + "'";
     case WRDE_SYNTAX:
-        throw "shell syntax error in '" + s +"'";
+        throw "shell syntax error in '" + s + "'";
     default:
         throw "completely unexpected error in '" + s + "'";
     }
-    if( p.we_wordc!=1 )
+    if (p.we_wordc != 1)
         throw "expansion of " + s + " not unique";
     string ret = p.we_wordv[0];
-    wordfree( &p );
+    wordfree(&p);
     return ret;
 }
 
 
 //! Returns a list of file names obtained by Posix shell expansion of a given pattern.
 
-vector<string> triv::wordexp_multi( const string& s )
+vector<string> triv::wordexp_multi(const string& s)
 {
     wordexp_t p;
-    if( wordexp( s.c_str(), &p, 0 ) )
+    if (wordexp(s.c_str(), &p, 0))
         throw "cannot expand " + s;
-    if( p.we_wordc==0 )
+    if (p.we_wordc == 0)
         throw "expansion of " + s + " is empty";
     vector<string> ret;
-    for ( size_t i=0; i<p.we_wordc; ++i )
-        if( file_exists( p.we_wordv[i] ) )
-            ret.push_back( p.we_wordv[i] );
-    wordfree( &p );
+    for (size_t i = 0; i < p.we_wordc; ++i)
+        if (file_exists(p.we_wordv[i]))
+            ret.push_back(p.we_wordv[i]);
+    wordfree(&p);
     return ret;
 }
 
 
 //! Construct tmp file name that is not currently in use.
 
-string triv::next_tmp_file( const string& path_format )
+string triv::next_tmp_file(const string& path_format)
 {
-    const int tmpmax=1024;
-    for( int i=0; i<tmpmax; ++i ){
-        string fname = str( format( path_format ) % i );
-        if ( !triv::file_exists( fname ) )
+    const int tmpmax = 1024;
+    for (int i = 0; i < tmpmax; ++i) {
+        string fname = str(format(path_format) % i);
+        if (!triv::file_exists(fname))
             return fname;
-        if( i==tmpmax/2 )
-            cerr << "WARNING: there more than " << i << " temporay files of form " << path_format <<
-                "; please clean up soon\n";
+        if (i == tmpmax / 2)
+            cerr << "WARNING: there more than " << i << " temporay files of form " << path_format
+                 << "; please clean up soon\n";
     }
     throw "Too many temporary files in use";
 }
@@ -164,18 +167,18 @@ string triv::next_tmp_file( const string& path_format )
 //! Extensions is a blank-separated list of strings to be appended to subpatterns that have
 //! no extension.
 
-vector<string> triv::glob_file_list( const string& patterns, const string& extensions)
+vector<string> triv::glob_file_list(const string& patterns, const string& extensions)
 {
     string extended_patterns = "";
-    vector<string> vPattern = split( patterns );
-    if ( !vPattern.size() )
-        throw string( "empty file list" );
-    vector<string> vExtension = split( extensions );
-    for ( string pat: vPattern ) {
+    vector<string> vPattern = split(patterns);
+    if (!vPattern.size())
+        throw string("empty file list");
+    vector<string> vExtension = split(extensions);
+    for (string pat : vPattern) {
         string fmain, fext;
-        fname_divide( pat, nullptr, &fmain, &fext );
-        if ( fext=="" && vExtension.size() ) {
-            for( string ext: vExtension )
+        fname_divide(pat, nullptr, &fmain, &fext);
+        if (fext == "" && vExtension.size()) {
+            for (string ext : vExtension)
                 extended_patterns += pat + "." + ext + " ";
         } else {
             extended_patterns += pat + " ";
@@ -192,21 +195,21 @@ vector<string> triv::glob_file_list( const string& patterns, const string& exten
 
 //! Reads a line from file; returns true unless end-of-file.
 
-bool triv::freadln( FILE *fd, string* s )
+bool triv::freadln(FILE* fd, string* s)
 {
     char c;
     *s = "";
     while (1) {
-        c = (char) fgetc(fd);
-        if      ( c==EOF && *s=="" )
+        c = (char)fgetc(fd);
+        if (c == EOF && *s == "")
             return false;
-        else if ( c=='\n' || c==EOF )
+        else if (c == '\n' || c == EOF)
             return true;
-        else if ( c=='\r' ){
-            if( fgetc(fd)=='\n' )
+        else if (c == '\r') {
+            if (fgetc(fd) == '\n')
                 return true;
             else
-                throw string( "CR not followed by LF" );
+                throw string("CR not followed by LF");
         }
         *s += c;
     }
diff --git a/pub/trivia/file_ops.hpp b/pub/trivia/file_ops.hpp
index cd9373d22b8469eeb677565bc349fcdc9f73bde9..e61e7bca470a170c9c009d8ec2db632dfb57ec69 100644
--- a/pub/trivia/file_ops.hpp
+++ b/pub/trivia/file_ops.hpp
@@ -5,22 +5,22 @@
 //* http://apps.jcns.fz-juelich.de
 //**************************************************************************************************
 
-namespace triv {
+namespace triv
+{
 
-    // Improved libc calls:
-    void system( std::string cmd, bool debug=false );
-    std::string system_read( std::string cmd, bool debug=false );
+// Improved libc calls:
+void system(std::string cmd, bool debug = false);
+std::string system_read(std::string cmd, bool debug = false);
 
-    // File names, globbing:
-    bool file_exists( const std::string& fname );
-    void fname_divide( const std::string& fname, std::string *fdir,
-                       std::string *fshort, std::string *fext);
-    std::vector<std::string> glob_file_list(
-        const std::string& patterns, const std::string& extensions);
-    std::string wordexp_unique( const std::string& s );
-    std::vector<std::string> wordexp_multi( const std::string& s );
-    std::string next_tmp_file( const std::string& path_format );
+// File names, globbing:
+bool file_exists(const std::string& fname);
+void fname_divide(
+    const std::string& fname, std::string* fdir, std::string* fshort, std::string* fext);
+std::vector<std::string> glob_file_list(const std::string& patterns, const std::string& extensions);
+std::string wordexp_unique(const std::string& s);
+std::vector<std::string> wordexp_multi(const std::string& s);
+std::string next_tmp_file(const std::string& path_format);
 
-    // File read:
-    bool freadln( FILE *fd, std::string *s );
+// File read:
+bool freadln(FILE* fd, std::string* s);
 }
diff --git a/pub/trivia/integrate.cpp b/pub/trivia/integrate.cpp
index 630a50b3da81f0bdf5f6d608ef99876d36c5aa67..3993cfb16bd72710eb7a79751441d0e8e4311a7f 100644
--- a/pub/trivia/integrate.cpp
+++ b/pub/trivia/integrate.cpp
@@ -5,51 +5,62 @@
 //* http://apps.jcns.fz-juelich.de                                          *//
 //***************************************************************************//
 
-#include <gsl/gsl_integration.h>
 #include "integrate.hpp"
+#include <gsl/gsl_integration.h>
 
 //! Compute integral of func() from low to high, using a GSL routine.
 
-double triv::integrate( double (*func_) (double, void*), void *data_,
-                        double low, double hig, int mode,
-                        double epsabs, double epsrel )
+double triv::integrate(
+    double (*func_)(double, void*), void* data_, double low, double hig, int mode, double epsabs,
+    double epsrel)
 {
     gsl_function F;
     F.function = func_;
     F.params = data_;
 #define nwork 20000
-    gsl_integration_workspace *work = gsl_integration_workspace_alloc( nwork );
+    gsl_integration_workspace* work = gsl_integration_workspace_alloc(nwork);
     double val, err;
     size_t neval;
 
-    if        ( isinf(low) && isinf(hig) ) {
-        gsl_integration_qagi( &F, epsabs, epsrel, nwork, work, &val, &err );
-    } else if ( isinf(low) ) {
-        gsl_integration_qagil( &F, hig, epsabs, epsrel, nwork, work, &val, &err );
-    } else if ( isinf(hig) ) {
-        gsl_integration_qagiu( &F, low, epsabs, epsrel, nwork, work, &val, &err );
-    } else if ( mode==0 ) {
+    if (isinf(low) && isinf(hig)) {
+        gsl_integration_qagi(&F, epsabs, epsrel, nwork, work, &val, &err);
+    } else if (isinf(low)) {
+        gsl_integration_qagil(&F, hig, epsabs, epsrel, nwork, work, &val, &err);
+    } else if (isinf(hig)) {
+        gsl_integration_qagiu(&F, low, epsabs, epsrel, nwork, work, &val, &err);
+    } else if (mode == 0) {
         // QNG non-adaptive Gauss-Kronrod integration
-        gsl_integration_qng( &F, low, hig, epsabs, epsrel,
-                             &val, &err, &neval );
-    } else if ( mode>0 && mode<7 ) {
+        gsl_integration_qng(&F, low, hig, epsabs, epsrel, &val, &err, &neval);
+    } else if (mode > 0 && mode < 7) {
         int rule;
-        switch( mode ){
-        case 1: rule = GSL_INTEG_GAUSS61; break;
-        case 2: rule = GSL_INTEG_GAUSS51; break;
-        case 3: rule = GSL_INTEG_GAUSS41; break;
-        case 4: rule = GSL_INTEG_GAUSS31; break;
-        case 5: rule = GSL_INTEG_GAUSS21; break;
-        case 6: rule = GSL_INTEG_GAUSS15; break;
+        switch (mode) {
+        case 1:
+            rule = GSL_INTEG_GAUSS61;
+            break;
+        case 2:
+            rule = GSL_INTEG_GAUSS51;
+            break;
+        case 3:
+            rule = GSL_INTEG_GAUSS41;
+            break;
+        case 4:
+            rule = GSL_INTEG_GAUSS31;
+            break;
+        case 5:
+            rule = GSL_INTEG_GAUSS21;
+            break;
+        case 6:
+            rule = GSL_INTEG_GAUSS15;
+            break;
         }
         // QAG adaptive integration
-        gsl_integration_qag( &F, low, hig, epsabs, epsrel, nwork, rule, work, &val, &err );
-    } else if ( mode==7 ) {
+        gsl_integration_qag(&F, low, hig, epsabs, epsrel, nwork, rule, work, &val, &err);
+    } else if (mode == 7) {
         // QAGS adaptive integration with singularities
-        gsl_integration_qags( &F, low, hig, epsabs, epsrel, nwork, work, &val, &err );
+        gsl_integration_qags(&F, low, hig, epsabs, epsrel, nwork, work, &val, &err);
     } else {
         throw "invalid mode in mystd::Integrate";
     }
-    gsl_integration_workspace_free( work );
+    gsl_integration_workspace_free(work);
     return val;
 }
diff --git a/pub/trivia/integrate.hpp b/pub/trivia/integrate.hpp
index f4416048b01d352fef5e5131cb882455c6131df1..264cc39420963395d923c264fddd1b68f60462c4 100644
--- a/pub/trivia/integrate.hpp
+++ b/pub/trivia/integrate.hpp
@@ -5,9 +5,10 @@
 //* http://apps.jcns.fz-juelich.de                                          *//
 //***************************************************************************//
 
-namespace triv {
+namespace triv
+{
 
-    double integrate( double (*func_) (double, void*), void *data_, 
-                      double low, double hig,
-                      int mode, double epsabs, double epsrel );
+double integrate(
+    double (*func_)(double, void*), void* data_, double low, double hig, int mode, double epsabs,
+    double epsrel);
 }
diff --git a/pub/trivia/math.cpp b/pub/trivia/math.cpp
index 408c2e4a457bfe9ccaef010c2707d86ec9888824..4116df2d1f4f3794cae36d3a716158cefa42ddd3 100644
--- a/pub/trivia/math.cpp
+++ b/pub/trivia/math.cpp
@@ -5,8 +5,8 @@
 //* http://apps.jcns.fz-juelich.de                                          *//
 //***************************************************************************//
 
-#include <cmath>
 #include "math.hpp"
+#include <cmath>
 
 //***************************************************************************//
 //*  rounding                                                               *//
@@ -14,13 +14,14 @@
 
 //! Round given value to given number of digits.
 
-double triv::round_decimal( double val, double digits )
+double triv::round_decimal(double val, double digits)
 {
-    if (val==0 || digits<=0) return 0;
+    if (val == 0 || digits <= 0)
+        return 0;
     double v = fabs(val);
-    int n = (int) floor ( digits - log10(v));
+    int n = (int)floor(digits - log10(v));
     // cout << " n=" << n;
     double p = pow(10., n);
-    double r = round(v*p) / p;
-    return (val<0 ? -1 : +1) * r;
+    double r = round(v * p) / p;
+    return (val < 0 ? -1 : +1) * r;
 }
diff --git a/pub/trivia/math.hpp b/pub/trivia/math.hpp
index 714c9b35f39b850710fe743033696970666f0797..b75315223e0c2467b1caeb4844abe3769b7c65b4 100644
--- a/pub/trivia/math.hpp
+++ b/pub/trivia/math.hpp
@@ -5,6 +5,7 @@
 //* http://apps.jcns.fz-juelich.de                                          *//
 //***************************************************************************//
 
-namespace triv {
-    double round_decimal( double val, double digits );
+namespace triv
+{
+double round_decimal(double val, double digits);
 }
diff --git a/pub/trivia/rng.cpp b/pub/trivia/rng.cpp
index 4b2769545a977a399163723315a4ad41e6faee5c..c5a5c871480008a01c15d1fcddef369fbe2cfd1c 100644
--- a/pub/trivia/rng.cpp
+++ b/pub/trivia/rng.cpp
@@ -5,8 +5,8 @@
 //* http://apps.jcns.fz-juelich.de                                           *//
 //****************************************************************************//
 
-#include <gsl/gsl_randist.h>
 #include <chrono>
+#include <gsl/gsl_randist.h>
 #include <math.h>
 
 #include "rng.hpp"
@@ -17,77 +17,60 @@ using namespace triv;
 //  Implementation class
 //****************************************************************************//
 
-class triv::RandomNumberImplementation {
- public:
-    RandomNumberImplementation() {
-        r = gsl_rng_alloc( gsl_rng_default ); }
-    ~RandomNumberImplementation() {
-        gsl_rng_free( r ); }
-    void reseed( unsigned long seed ) {
-        gsl_rng_set( r, seed ); }
-    double uniform() {
-        return gsl_rng_uniform( r ); }
-    double gaussian( double stdv ) {
-        return gsl_ran_gaussian ( r, stdv ); }
-    double cauchy( double width ) {
-        return gsl_ran_cauchy ( r, width ); }
- private:
-    gsl_rng *r;
+class triv::RandomNumberImplementation
+{
+public:
+    RandomNumberImplementation() { r = gsl_rng_alloc(gsl_rng_default); }
+    ~RandomNumberImplementation() { gsl_rng_free(r); }
+    void reseed(unsigned long seed) { gsl_rng_set(r, seed); }
+    double uniform() { return gsl_rng_uniform(r); }
+    double gaussian(double stdv) { return gsl_ran_gaussian(r, stdv); }
+    double cauchy(double width) { return gsl_ran_cauchy(r, width); }
+private:
+    gsl_rng* r;
 };
 
 //****************************************************************************//
 //  Interface class
 //****************************************************************************//
 
-RandomNumberGenerator::RandomNumberGenerator()
-{
-    pimpl = new triv::RandomNumberImplementation();
-}
+RandomNumberGenerator::RandomNumberGenerator() { pimpl = new triv::RandomNumberImplementation(); }
 
-RandomNumberGenerator::~RandomNumberGenerator()
-{
-    delete pimpl;
-}
+RandomNumberGenerator::~RandomNumberGenerator() { delete pimpl; }
 
 //! Set new random seed.
 
-void RandomNumberGenerator::reseed( unsigned long seed )
-{
-    pimpl->reseed( seed );
-}
+void RandomNumberGenerator::reseed(unsigned long seed) { pimpl->reseed(seed); }
 
 //! Set new random seed from clock's nsec.
 
 void RandomNumberGenerator::reseed_from_clock()
 {
     std::chrono::nanoseconds time = std::chrono::system_clock::now().time_since_epoch();
-    reseed( (unsigned long) time.count() );
+    reseed((unsigned long)time.count());
 }
 
-double RandomNumberGenerator::uniform()
-{
-    return pimpl->uniform();
-}
+double RandomNumberGenerator::uniform() { return pimpl->uniform(); }
 
-double RandomNumberGenerator::uniform( double rmin, double rmax )
+double RandomNumberGenerator::uniform(double rmin, double rmax)
 {
-    return rmin + (rmax-rmin)*uniform();
+    return rmin + (rmax - rmin) * uniform();
 }
 
-double RandomNumberGenerator::gaussian( double stdv, double cutoff )
+double RandomNumberGenerator::gaussian(double stdv, double cutoff)
 {
     double ret;
     do {
-        ret = pimpl->gaussian( stdv );
-    } while( cutoff && fabs(ret)>cutoff );
+        ret = pimpl->gaussian(stdv);
+    } while (cutoff && fabs(ret) > cutoff);
     return ret;
 }
 
-double RandomNumberGenerator::cauchy( double width, double cutoff )
+double RandomNumberGenerator::cauchy(double width, double cutoff)
 {
     double ret;
     do {
-        ret = pimpl->cauchy( width );
-    } while( cutoff && fabs(ret)>cutoff );
+        ret = pimpl->cauchy(width);
+    } while (cutoff && fabs(ret) > cutoff);
     return ret;
 }
diff --git a/pub/trivia/rng.hpp b/pub/trivia/rng.hpp
index 877bb70b2fbffcb0aed6bd8fb949986bc510a8e0..5c445c06a3d6c36d0b03ab0c9197de232ecaa4dc 100644
--- a/pub/trivia/rng.hpp
+++ b/pub/trivia/rng.hpp
@@ -8,21 +8,24 @@
 #ifndef TRIVIA_RNG_H
 #define TRIVIA_RNG_H
 
-namespace triv {
-    class RandomNumberGenerator {
-    public:
-        //! Initialize with given seed.
-        RandomNumberGenerator();
-        ~RandomNumberGenerator();
-        void reseed( unsigned long seed );
-        void reseed_from_clock();
-        double uniform();
-        double uniform( const double rmin, const double rmax );
-        double gaussian( const double stdv, const double cutoff=0 );
-        double cauchy( const double width, const double cutoff=0 );
-    private:
-        class RandomNumberImplementation* pimpl;
-    };
+namespace triv
+{
+class RandomNumberGenerator
+{
+public:
+    //! Initialize with given seed.
+    RandomNumberGenerator();
+    ~RandomNumberGenerator();
+    void reseed(unsigned long seed);
+    void reseed_from_clock();
+    double uniform();
+    double uniform(const double rmin, const double rmax);
+    double gaussian(const double stdv, const double cutoff = 0);
+    double cauchy(const double width, const double cutoff = 0);
+
+private:
+    class RandomNumberImplementation* pimpl;
+};
 }
 
 #endif // TRIVIA_RNG_H
diff --git a/pub/trivia/singleton.hpp b/pub/trivia/singleton.hpp
index cd61011c560898fb294ddf6a66299a3660f9c79e..d23db42766cf1e8c41870272e8938584efe04331 100644
--- a/pub/trivia/singleton.hpp
+++ b/pub/trivia/singleton.hpp
@@ -10,20 +10,25 @@
 #ifndef ISINGLETON_H
 #define ISINGLETON_H
 
-namespace triv {
+namespace triv
+{
 
 //! Mixin interface for singleton classes.
 
-template<class T>
-class ISingleton {
- private:
-    ISingleton(ISingleton const&) = delete;  //! To prevent copying
+template <class T> class ISingleton
+{
+private:
+    ISingleton(ISingleton const&) = delete; //! To prevent copying
     void operator=(ISingleton const&) = delete; //! To prevent copying
- protected:
-    ~ISingleton() {};
+protected:
+    ~ISingleton(){};
     ISingleton() {}
- public:
-    static T* instance() { static T* instance = new T(); return instance; }
+public:
+    static T* instance()
+    {
+        static T* instance = new T();
+        return instance;
+    }
 };
 
 } // namespace triv
diff --git a/pub/trivia/string_convs.cpp b/pub/trivia/string_convs.cpp
index 746f891ab198c7dc1e17a8617a213447374fddb4..398b45d397ab68ff28ec05f6964cc2943da121a2 100644
--- a/pub/trivia/string_convs.cpp
+++ b/pub/trivia/string_convs.cpp
@@ -24,49 +24,37 @@ using boost::format;
 
 //! Convert bool to "y" or "n".
 
-string triv::strg( bool val ) {
-    return val ? "y" : "n";
-}
+string triv::strg(bool val) { return val ? "y" : "n"; }
 
 //! Convert double to string.
 
-string triv::strg( double val )
+string triv::strg(double val)
 {
-    string ret = str( format( "%g" ) % val );
-    if( ret.find_first_of(".eE")==string::npos )
+    string ret = str(format("%g") % val);
+    if (ret.find_first_of(".eE") == string::npos)
         ret += '.';
     return ret;
 }
 
 //! Convert int to string.
 
-string triv::strg( int val )
-{
-    return str( format( "%i" ) % val );
-}
+string triv::strg(int val) { return str(format("%i") % val); }
 
 //! Convert size_t to string.
 
-string triv::strg( std::size_t val )
-{
-    return str( format( "%i" ) % ((int)val) );
-}
+string triv::strg(std::size_t val) { return str(format("%i") % ((int)val)); }
 
 //! Convert char to string.
 
-string triv::strg( char val )
-{
-    return string(1, val);
-}
+string triv::strg(char val) { return string(1, val); }
 
 //! Return time in SPHERES standard form.
 
-string triv::time2strg( long seconds_since_the_epoch )
+string triv::time2strg(long seconds_since_the_epoch)
 {
     char buf[40];
     struct tm tlocal;
-    strftime( buf, 40, "%Y-%m-%d %a %H:%M:%S %Z",
-              localtime_r(&seconds_since_the_epoch, &tlocal) );
+    strftime(buf, 40, "%Y-%m-%d %a %H:%M:%S %Z", localtime_r(&seconds_since_the_epoch, &tlocal));
     return buf;
 }
 
@@ -76,30 +64,31 @@ string triv::time2strg( long seconds_since_the_epoch )
 
 //! Try converting string to double.
 
-bool triv::any2dbl( const string& inp, double *val )
+bool triv::any2dbl(const string& inp, double* val)
 {
-    if( !inp.size() ) {
+    if (!inp.size()) {
         cout << "expecting double, found empty input\n";
         return false;
     }
-    if( inp=="-inf" || inp=="-oo" ) {
+    if (inp == "-inf" || inp == "-oo") {
         *val = -INFINITY;
         return true;
     }
-    if( inp=="inf" || inp=="oo" || inp=="+inf" || inp=="+oo" ) {
+    if (inp == "inf" || inp == "oo" || inp == "+inf" || inp == "+oo") {
         *val = INFINITY;
         return true;
     }
-    if(!strchr("+-0123456789.", inp[0])) {
+    if (!strchr("+-0123456789.", inp[0])) {
         cout << "expecting double, found bad char[0] in [" << inp << "]\n";
         return false;
     }
-    double mant; int expt;
-    if (sscanf(inp.c_str(), "%lgm%i", &mant, &expt)==2) {
+    double mant;
+    int expt;
+    if (sscanf(inp.c_str(), "%lgm%i", &mant, &expt) == 2) {
         *val = mant * pow(10.e0, (double)(-expt));
         return true;
     }
-    if (sscanf(inp.c_str(), "%lg", val)==1)
+    if (sscanf(inp.c_str(), "%lg", val) == 1)
         return true;
     cout << "expecting double, sscanf failed\n";
     return false;
@@ -107,17 +96,18 @@ bool triv::any2dbl( const string& inp, double *val )
 
 //! Try converting string to integer.
 
-bool triv::any2int( const string& inp, int *val )
+bool triv::any2int(const string& inp, int* val)
 {
-    if(!inp.size()) {
+    if (!inp.size()) {
         cout << "expecting integer, found empty input\n";
         return false;
     }
-    if(!strchr("+-0123456789", inp[0])) {
+    if (!strchr("+-0123456789", inp[0])) {
         cout << "expecting integer, found bad char[0] in [" << inp << "]\n";
         return false;
     }
-    if (sscanf(inp.c_str(), "%i", val)==1) return true;
+    if (sscanf(inp.c_str(), "%i", val) == 1)
+        return true;
     cout << "expecting integer, sscanf failed\n";
     return false;
 }
diff --git a/pub/trivia/string_convs.hpp b/pub/trivia/string_convs.hpp
index 55ea2558aeed7ee8d99ac11be9574a1bda63f559..36e90e2153ca009a454f75f6b34e8068d06dc8b1 100644
--- a/pub/trivia/string_convs.hpp
+++ b/pub/trivia/string_convs.hpp
@@ -5,19 +5,20 @@
 //* http://apps.jcns.fz-juelich.de                                          *//
 //***************************************************************************//
 
-namespace triv {
+namespace triv
+{
 
-    // Convert to string:
-    inline std::string strg( std::string val ) { return val; } //!< Returns input C++ string
-    inline std::string strg( const char* val ) { return val; } //!< Returns input as C++ string
-    std::string strg( bool val );
-    std::string strg( int val );
-    std::string strg( std::size_t val );
-    std::string strg( char val );
-    std::string strg( double val );
-    std::string time2strg( long seconds_since_the_epoch );
+// Convert to string:
+inline std::string strg(std::string val) { return val; } //!< Returns input C++ string
+inline std::string strg(const char* val) { return val; } //!< Returns input as C++ string
+std::string strg(bool val);
+std::string strg(int val);
+std::string strg(std::size_t val);
+std::string strg(char val);
+std::string strg(double val);
+std::string time2strg(long seconds_since_the_epoch);
 
-    // Convert from string:
-    bool any2dbl( const std::string& inp, double *val );
-    bool any2int( const std::string& inp, int *val );
+// Convert from string:
+bool any2dbl(const std::string& inp, double* val);
+bool any2int(const std::string& inp, int* val);
 }
diff --git a/pub/trivia/string_ops.cpp b/pub/trivia/string_ops.cpp
index 18260fe8fe6e204939df0d44d33fd950c51b0808..4299b8347918feccdecb623b97089a1cad7146d1 100644
--- a/pub/trivia/string_ops.cpp
+++ b/pub/trivia/string_ops.cpp
@@ -16,43 +16,42 @@ using namespace std;
 
 //! Extract floating-point numbers from string.
 
-bool triv::str2vec( string inp, vector<double> *V, size_t nmax, bool force )
+bool triv::str2vec(string inp, vector<double>* V, size_t nmax, bool force)
 // ------ TODO: convert to void, throwing errors -------
 {
 
     // cout << "DEBUG mystd [" << inp << "]\n";
     V->clear();
 
-    while(inp.size() && isspace(inp[0]))
+    while (inp.size() && isspace(inp[0]))
         inp.erase(inp.begin());
     // while(inp.size() && strchr(" \t.\n",inp[inp.size()-1]))
     //    inp.erase(inp.end()-1);
 
     // cout << "DEBUG  core [" << inp << "]\n";
-    if (inp==string("")) {
+    if (inp == string("")) {
         // cout << "DEBUG  empty\n";
         return true;
     }
     // cout << "DEBUG  nonempty\n";
 
-    string::size_type ji=0, jf;
+    string::size_type ji = 0, jf;
     double val;
     char dummy;
-    while (ji<inp.size()) {
-        if(inp[ji]=='#')
+    while (ji < inp.size()) {
+        if (inp[ji] == '#')
             break;
-        if ((jf=inp.find_first_of(", \t\n", ji)) == string::npos)
+        if ((jf = inp.find_first_of(", \t\n", ji)) == string::npos)
             jf = inp.size();
         // cout << " look until " << jf << "\n";
-        if (sscanf(inp.substr(ji,jf-ji).c_str(), "%lg%c", &val, &dummy)==1) {
+        if (sscanf(inp.substr(ji, jf - ji).c_str(), "%lg%c", &val, &dummy) == 1) {
             V->push_back(val);
-        } else if ( force ) {
-            cout << "! str2vec: invalid value ["
-                 << inp.substr(ji,jf-ji) << "] at pos " << ji
+        } else if (force) {
+            cout << "! str2vec: invalid value [" << inp.substr(ji, jf - ji) << "] at pos " << ji
                  << " in [" << inp << "]\n";
             return false;
         }
-        if (nmax && V->size()>=nmax)
+        if (nmax && V->size() >= nmax)
             break; // do not decode the tail
         // cout << " found "<<ji<<":"<<jf<<" value "<<val<<"\n";
         ji = inp.find_first_not_of(", \t\n", jf);
@@ -67,12 +66,12 @@ bool triv::str2vec( string inp, vector<double> *V, size_t nmax, bool force )
 string triv::strip(
     string const& str, ///< the original string
     char const* sepSet ///< C string with characters to be dropped
-)
+    )
 {
     string::size_type const first = str.find_first_not_of(sepSet);
-    return ( first==std::string::npos )
+    return (first == std::string::npos)
         ? std::string()
-        : str.substr(first, str.find_last_not_of(sepSet)-first+1);
+        : str.substr(first, str.find_last_not_of(sepSet) - first + 1);
 }
 
 //! Split string at first non-leading whitespace, ignoring whitespace in  `..`.
@@ -82,20 +81,20 @@ string triv::strip(
 //! "\n" starts always a new word.
 //! leading "`" makes *out1 go to next "`" or to end of line.
 
-void triv::string_extract_word( const string& in, string *out1, string *out2 )
+void triv::string_extract_word(const string& in, string* out1, string* out2)
 {
-    string::size_type j0=0, j1, j2, jf=in.size();
+    string::size_type j0 = 0, j1, j2, jf = in.size();
 
     // handle special case "`"
-    if (in[0]=='`') {
+    if (in[0] == '`') {
         j1 = in.find_first_of('`', 1);
-        if (j1==string::npos) {
+        if (j1 == string::npos) {
             *out1 = in.substr(1);
             *out2 = "";
         } else {
-            *out1 = in.substr(1, j1-1);
-            j2 = in.find_first_not_of(" \t", j1+1);
-            if (j2!=string::npos)
+            *out1 = in.substr(1, j1 - 1);
+            j2 = in.find_first_not_of(" \t", j1 + 1);
+            if (j2 != string::npos)
                 *out2 = in.substr(j2);
             else
                 *out2 = "";
@@ -103,13 +102,16 @@ void triv::string_extract_word( const string& in, string *out1, string *out2 )
         return;
     }
 
-    while (j0<jf && strchr(" \t",in[j0])) j0++;
-    j1=j0+1;
-    while (j1<jf && !strchr(" \t\n",in[j1])) j1++;
-    j2=j1;
-    while (j2<jf && strchr(" \t",in[j2])) j2++;
-    *out1 = in.substr(0,j1);
-    if (j2<jf)
+    while (j0 < jf && strchr(" \t", in[j0]))
+        j0++;
+    j1 = j0 + 1;
+    while (j1 < jf && !strchr(" \t\n", in[j1]))
+        j1++;
+    j2 = j1;
+    while (j2 < jf && strchr(" \t", in[j2]))
+        j2++;
+    *out1 = in.substr(0, j1);
+    if (j2 < jf)
         *out2 = in.substr(j2);
     else
         *out2 = string("");
@@ -117,35 +119,35 @@ void triv::string_extract_word( const string& in, string *out1, string *out2 )
 
 //! Split string at first linebreak.
 
-void triv::string_extract_line( const string& in, string *out1, string *out2 )
+void triv::string_extract_line(const string& in, string* out1, string* out2)
 {
     string line;
     string::size_type i = in.find('\n');
-    if (i==string::npos) {
+    if (i == string::npos) {
         *out1 = in;
         *out2 = string("");
     } else {
-        *out1 = in.substr(0,i);
-        *out2 = in.substr(i+1);
+        *out1 = in.substr(0, i);
+        *out2 = in.substr(i + 1);
     }
 }
 
 //! Split string at given delimiters, return vector of tokens.
 
-vector<string> triv::split( const string& in, const string& delimiters )
+vector<string> triv::split(const string& in, const string& delimiters)
 {
     vector<string> out;
     // skip delimiters at beginning:
-    string::size_type lastPos = in.find_first_not_of( delimiters, 0 );
+    string::size_type lastPos = in.find_first_not_of(delimiters, 0);
     // find first non-delimiter:
-    string::size_type pos = in.find_first_of( delimiters, lastPos );
-    while ( pos!=string::npos || lastPos!=string::npos ) {
+    string::size_type pos = in.find_first_of(delimiters, lastPos);
+    while (pos != string::npos || lastPos != string::npos) {
         // found a token, add it to the vector:
-        out.push_back( in.substr(lastPos, pos-lastPos) );
+        out.push_back(in.substr(lastPos, pos - lastPos));
         // skip delimiters:
-        lastPos = in.find_first_not_of( delimiters, pos );
+        lastPos = in.find_first_not_of(delimiters, pos);
         // find next non-delimiter:
-        pos = in.find_first_of( delimiters, lastPos );
+        pos = in.find_first_of(delimiters, lastPos);
     }
     return out;
 }
diff --git a/pub/trivia/string_ops.hpp b/pub/trivia/string_ops.hpp
index 1fab9882d6092f098a7d77b1e798669644308834..a692b023f10e803d12117c3e6e0b9b23233f36d1 100644
--- a/pub/trivia/string_ops.hpp
+++ b/pub/trivia/string_ops.hpp
@@ -8,22 +8,23 @@
 #include <sstream>
 #include <vector>
 
-namespace triv {
+namespace triv
+{
 
-    bool str2vec( std::string inp, std::vector<double> *V, size_t nmax=0, bool force=true );
-    void string_extract_word( const std::string& in, std::string *out1, std::string *out2 );
-    void string_extract_line( const std::string& in, std::string *out1, std::string *out2 );
-    std::vector<std::string> split( const std::string& in, const std::string& delimiters = " \t" );
-    std::string strip( const std::string& str, const char* sepSet=" \n" );
+bool str2vec(std::string inp, std::vector<double>* V, size_t nmax = 0, bool force = true);
+void string_extract_word(const std::string& in, std::string* out1, std::string* out2);
+void string_extract_line(const std::string& in, std::string* out1, std::string* out2);
+std::vector<std::string> split(const std::string& in, const std::string& delimiters = " \t");
+std::string strip(const std::string& str, const char* sepSet = " \n");
 
-    template <class T>
-    std::string join( const std::vector<T>& v, const std::string& separator ){
-        std::ostringstream result;
-        for (auto i = v.begin(); i != v.end(); i++){
-            if (i != v.begin())
-                result << separator;
-            result << *i;
-        }
-        return result.str();
+template <class T> std::string join(const std::vector<T>& v, const std::string& separator)
+{
+    std::ostringstream result;
+    for (auto i = v.begin(); i != v.end(); i++) {
+        if (i != v.begin())
+            result << separator;
+        result << *i;
     }
+    return result.str();
+}
 }
diff --git a/pub/trivia/vector_ops.cpp b/pub/trivia/vector_ops.cpp
index 77bb698660921193235b0f83d8409914b0b77a5e..2994c9f0d86968676609a324c1d02f6cf122d131 100644
--- a/pub/trivia/vector_ops.cpp
+++ b/pub/trivia/vector_ops.cpp
@@ -5,16 +5,16 @@
 //* http://apps.jcns.fz-juelich.de                                          *//
 //***************************************************************************//
 
+#include <algorithm>
 #include <cmath>
+#include <numeric>
 #include <string>
 #include <vector>
-#include <algorithm>
-#include <numeric>
 
 using namespace std;
 
-#include "vector_ops.hpp"
 #include "string_convs.hpp"
+#include "vector_ops.hpp"
 
 
 //***************************************************************************//
@@ -23,12 +23,14 @@ using namespace std;
 
 //! Inserts val into vector *V, presuming the latter is sorted.
 
-void triv::insert_in_sorted( vector<double> *V, double val )
+void triv::insert_in_sorted(vector<double>* V, double val)
 {
-    for (size_t i=0; i<V->size(); ++i) {
-        if (val>(*V)[i]) continue;
-        if (val==(*V)[i]) return;
-        V->insert(V->begin()+i, val);
+    for (size_t i = 0; i < V->size(); ++i) {
+        if (val > (*V)[i])
+            continue;
+        if (val == (*V)[i])
+            return;
+        V->insert(V->begin() + i, val);
         return;
     }
     V->push_back(val);
@@ -36,39 +38,40 @@ void triv::insert_in_sorted( vector<double> *V, double val )
 
 //! Eliminates double entries from vector V.
 
-void triv::make_unique( vector<double> *V, double tolabs, double tolrel )
+void triv::make_unique(vector<double>* V, double tolabs, double tolrel)
 {
     // tolrel z.Zt. nicht benutzt
     vector<double> aux;
     double diff;
-    if (!V->size()) return;
+    if (!V->size())
+        return;
     aux.push_back((*V)[0]);
-    for (size_t ii=1; ii<V->size(); ++ii)
-        if((diff=fabs((*V)[ii]-aux.back()))>tolabs)
+    for (size_t ii = 1; ii < V->size(); ++ii)
+        if ((diff = fabs((*V)[ii] - aux.back())) > tolabs)
             aux.push_back((*V)[ii]);
     *V = aux;
 }
 
 //! Returns rue unless V[i]<=V[i-1] for some i.
 
-bool triv::is_ascending( const vector<double>& V )
+bool triv::is_ascending(const vector<double>& V)
 {
-    for( size_t i=2; i<V.size(); ++i )
-        if ( V[i] <= V[i-1] )
+    for (size_t i = 2; i < V.size(); ++i)
+        if (V[i] <= V[i - 1])
             return false;
     return true;
 }
 
 //! Returns true if grid is equidistant, sets *step.
 
-bool triv::is_equidist( double *step, const vector<double>& V )
+bool triv::is_equidist(double* step, const vector<double>& V)
 {
     size_t n = V.size();
-    if( n < 2 )
-        return false;  // vector too short to determine equidistance
-    *step = ( V[n-1] - V[0] ) / (n-1);
-    for ( size_t i=1; i<n-1; ++i )
-        if( fabs( V[i] - (V[0]+i*(*step)) ) > 1e-12*fabs(*step)+1e-200 )
+    if (n < 2)
+        return false; // vector too short to determine equidistance
+    *step = (V[n - 1] - V[0]) / (n - 1);
+    for (size_t i = 1; i < n - 1; ++i)
+        if (fabs(V[i] - (V[0] + i * (*step))) > 1e-12 * fabs(*step) + 1e-200)
             return false;
     return true;
 }
@@ -81,34 +84,34 @@ vector<size_t> triv::sorted_indices(vector<double> const& V)
     // C++11, not yet supported by gcc-4.4:
     // iota(begin(I), end(I), 0);
     // workaround:
-    for( size_t i=0; i<I.size(); ++i )
-	I[i] = i;
+    for (size_t i = 0; i < I.size(); ++i)
+        I[i] = i;
     // end workaround.
-    sort( begin(I), end(I), [&](size_t a, size_t b) { return V[a] < V[b]; } );
+    sort(begin(I), end(I), [&](size_t a, size_t b) { return V[a] < V[b]; });
     return I;
 }
 
 
 //! Returns list 0,1,...,number_of_entries-1.
 
-vector<int> triv::iota_list( int number_of_entries )
+vector<int> triv::iota_list(int number_of_entries)
 {
-    vector<int> ret( number_of_entries );
-    iota( ret.begin(), ret.end(), 0 );
+    vector<int> ret(number_of_entries);
+    iota(ret.begin(), ret.end(), 0);
     return ret;
 }
 
 
 //! Increments all members, provided they remain in the range 0...siz.
 
-void triv::increment_indices( vector<int>& v, int incr, int siz )
+void triv::increment_indices(vector<int>& v, int incr, int siz)
 {
     vector<int> ret;
-    for( int k: v ){
-        int kout = k+incr;
-        if ( kout<0 || kout>=siz )
+    for (int k : v) {
+        int kout = k + incr;
+        if (kout < 0 || kout >= siz)
             return; // leave v unchanged
-        ret.push_back( kout );
+        ret.push_back(kout);
     }
     v = ret;
 }
@@ -119,21 +122,21 @@ string triv::indices_to_s(const vector<int>& v)
 {
     string ret;
     int n = v.size();
-    if( !n )
+    if (!n)
         return "";
     int iout = 0; // next to be written
-    while( true ) {
-        if ( iout+2<n ) {
-            int step = v[iout+1]-v[iout];
-            int i=iout+1;
-            for ( ; i<n-1; ++i )
-                if( v[i+1]-v[i]!=step )
+    while (true) {
+        if (iout + 2 < n) {
+            int step = v[iout + 1] - v[iout];
+            int i = iout + 1;
+            for (; i < n - 1; ++i)
+                if (v[i + 1] - v[i] != step)
                     break;
-            if( i>iout+1 ) {
+            if (i > iout + 1) {
                 ret += strg(v[iout]) + ":" + strg(v[i]);
-                if( step!=1 )
+                if (step != 1)
                     ret += ":" + strg(step);
-                iout = i+1;
+                iout = i + 1;
             } else {
                 ret += strg(v[iout]);
                 iout++;
@@ -142,7 +145,7 @@ string triv::indices_to_s(const vector<int>& v)
             ret += strg(v[iout]);
             iout++;
         }
-        if ( iout>=n )
+        if (iout >= n)
             break;
         ret += ",";
     }
diff --git a/pub/trivia/vector_ops.hpp b/pub/trivia/vector_ops.hpp
index c3b5e4f239d64d258fb17f82961e38b8ae982f6d..16d3f1824d1b5a199222e69ec8044d24c3ade8c5 100644
--- a/pub/trivia/vector_ops.hpp
+++ b/pub/trivia/vector_ops.hpp
@@ -5,19 +5,21 @@
 //* http://apps.jcns.fz-juelich.de
 //**************************************************************************************************
 
-namespace triv {
+namespace triv
+{
 
-    void insert_in_sorted( std::vector<double> *V, double val );
-    void make_unique( std::vector<double> *V, double tolabs=1e-100, double tolrel=1e-10 );
-    bool is_ascending( const std::vector<double>& V );
-    bool is_equidist( double *step, const std::vector<double>& V );
-    std::vector<size_t> sorted_indices( std::vector<double> const& V );
-    vector<int> iota_list( int number_of_entries );
+void insert_in_sorted(std::vector<double>* V, double val);
+void make_unique(std::vector<double>* V, double tolabs = 1e-100, double tolrel = 1e-10);
+bool is_ascending(const std::vector<double>& V);
+bool is_equidist(double* step, const std::vector<double>& V);
+std::vector<size_t> sorted_indices(std::vector<double> const& V);
+vector<int> iota_list(int number_of_entries);
 
-    void increment_indices( std::vector<int>& v, int incr, int siz );
-    std::string indices_to_s( const std::vector<int>& v );
+void increment_indices(std::vector<int>& v, int incr, int siz);
+std::string indices_to_s(const std::vector<int>& v);
 
-    template<class A>
-    bool contains( const std::vector<A>& v, const A e )
-    { return std::find( v.begin(), v.end(), e ) != v.end(); }
+template <class A> bool contains(const std::vector<A>& v, const A e)
+{
+    return std::find(v.begin(), v.end(), e) != v.end();
+}
 }
diff --git a/pub/trivia/yaml_out.cpp b/pub/trivia/yaml_out.cpp
index 00a3afa982b58ceddf8c1b507a5c7b56cb7de014..d1c6853449348eae5efb01071b79a67354399faf 100644
--- a/pub/trivia/yaml_out.cpp
+++ b/pub/trivia/yaml_out.cpp
@@ -5,41 +5,29 @@
 //* http://apps.jcns.fz-juelich.de                                          *//
 //***************************************************************************//
 
-#include <string>
 #include "yaml_out.hpp"
 using namespace std;
 
 //! Wrap string for yaml output.
 
-string triv::yaml( const string s )
+string triv::yaml(const string s)
 {
-    if ( s=="" )
+    if (s == "")
         return "\"\"";
     string out = s;
     size_t i = 0;
     // escape "
-    while( i < out.size() ){
-        if( ( out[i]=='"' || out[i]=='\'' ) && (i==0 || out[i-1]!='\\') )
-            out.insert( i, "\\" );
+    while (i < out.size()) {
+        if ((out[i] == '"' || out[i] == '\'') && (i == 0 || out[i - 1] != '\\'))
+            out.insert(i, "\\");
         ++i;
     }
     // if there are special characters, put "" around
-    if( s.find( '"' )!=string::npos ||
-        s.find( '\'' )!=string::npos ||
-        s.find( '\\' )!=string::npos ||
-        s.find( '-' )!=string::npos ||
-        s.find( ':' )!=string::npos ||
-        s.find( '*' )!=string::npos ||
-        s.find( '&' )!=string::npos ||
-        s.find( '#' )!=string::npos ||
-        s.find( '>' )!=string::npos ||
-        s.find( '<' )!=string::npos ||
-        s.find( '[' )!=string::npos ||
-        s.find( ']' )!=string::npos ||
-        s.find( '{' )!=string::npos ||
-        s.find( '}' )!=string::npos
-        )
+    if (s.find('"') != string::npos || s.find('\'') != string::npos || s.find('\\') != string::npos
+        || s.find('-') != string::npos || s.find(':') != string::npos || s.find('*') != string::npos
+        || s.find('&') != string::npos || s.find('#') != string::npos || s.find('>') != string::npos
+        || s.find('<') != string::npos || s.find('[') != string::npos || s.find(']') != string::npos
+        || s.find('{') != string::npos || s.find('}') != string::npos)
         out = '"' + out + '"';
     return out;
 }
-
diff --git a/pub/trivia/yaml_out.hpp b/pub/trivia/yaml_out.hpp
index 5fdb4df426a94ada6bac05ee1123d0daf2307800..22df49e2841fca9d21cc75c26140ad6ca8e0c51f 100644
--- a/pub/trivia/yaml_out.hpp
+++ b/pub/trivia/yaml_out.hpp
@@ -5,7 +5,9 @@
 //* http://apps.jcns.fz-juelich.de                                         *//
 //**************************************************************************//
 
-namespace triv {
+#include <string>
 
-    std::string yaml( const std::string );
+namespace triv
+{
+std::string yaml(const std::string);
 }