[cpl-plugin-kmos] 01/03: New upstream version 1.3.0

Ole Streicher olebole-guest at moszumanska.debian.org
Mon Mar 10 12:23:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

olebole-guest pushed a commit to tag debian/1.3.0+dfsg-1
in repository cpl-plugin-kmos.

commit a8099382f4cbfe7462dedbe3c847dd890786f0c8
Author: Ole Streicher <debian at liska.ath.cx>
Date:   Mon Mar 10 11:06:43 2014 +0100

    New upstream version 1.3.0
---
 Makefile.am                                  |    2 +-
 Makefile.in                                  |    2 +-
 calib/dic/ESO-DFS-DIC.KMOS_QC                |   18 +
 calib/dic/ESO-VLT-DIC.NGCCON                 |  238 --
 calib/dic/ESO-VLT-DIC.NGCDCS                 | 5117 --------------------------
 calib/gasgano/config/KMOS.prefs              |    2 +-
 calib/gasgano/config/kmos.oca                |    3 +-
 configure                                    |   51 +-
 configure.ac                                 |    6 +-
 irplib/tests/irplib_polynomial-test.c        |    7 +
 irplib/tests/irplib_strehl-test.c            |  226 +-
 kmclipm/include/kmclipm_functions.h          |    2 -
 kmclipm/src/kmclipm_functions.c              |  125 +-
 kmclipm/test/kmclipm_test_functions.c        |    2 +-
 kmclipm/test/kmclipm_test_math.c             |    2 +-
 kmclipm/test/kmclipm_test_priv_constants.c   |    2 +-
 kmclipm/test/kmclipm_test_priv_functions.c   |    2 +-
 kmclipm/test/kmclipm_test_priv_reconstruct.c |    3 +-
 kmclipm/test/kmclipm_test_priv_splines.c     |    2 +-
 kmclipm/test/kmclipm_test_rtd.c              |    2 +-
 kmclipm/test/kmclipm_test_vector.c           |    2 +-
 kmos/kmo_dfs.c                               | 3962 +++++++++-----------
 kmos/kmo_dfs.h                               |   15 +
 kmos/kmo_error.h                             |   12 +-
 kmos/kmo_priv_combine.c                      |   24 +-
 kmos/kmo_priv_dark.c                         |  151 +-
 kmos/kmo_priv_dark.h                         |   32 +-
 kmos/kmo_priv_extract_spec.c                 |    3 +-
 kmos/kmo_priv_flat.c                         | 1501 ++++----
 kmos/kmo_priv_flat.h                         |   16 -
 kmos/kmo_priv_functions.c                    | 1918 ++++------
 kmos/kmo_priv_functions.h                    |    4 +
 kmos/kmo_priv_make_image.c                   |  220 +-
 kmos/kmo_priv_make_image.h                   |   33 +-
 kmos/kmo_priv_sky_tweak.c                    |   48 +-
 kmos/kmo_priv_wave_cal.c                     | 2753 ++++++--------
 kmos/kmo_priv_wave_cal.h                     |    3 +-
 kmos/kmo_utils.c                             |  605 ++-
 kmos/kmo_utils.h                             |  146 +-
 kmos/tests/create_data_kmos.c                |   55 +-
 kmos/tests/kmo_cpl_extensions-test.c         |   12 +-
 kmos/tests/kmo_debug-test.c                  |   14 +-
 kmos/tests/kmo_dfs-test.c                    |   30 +-
 kmos/tests/kmo_functions-test.c              |   12 +-
 kmos/tests/kmo_priv_arithmetic-test.c        |   18 +-
 kmos/tests/kmo_priv_combine-test.c           |   12 +-
 kmos/tests/kmo_priv_copy-test.c              |   12 +-
 kmos/tests/kmo_priv_dark-test.c              |   12 +-
 kmos/tests/kmo_priv_extract_spec-test.c      |   12 +-
 kmos/tests/kmo_priv_fit_profile-test.c       |   12 +-
 kmos/tests/kmo_priv_fits_check-test.c        |   12 +-
 kmos/tests/kmo_priv_fits_stack-test.c        |   12 +-
 kmos/tests/kmo_priv_flat-test.c              |   12 +-
 kmos/tests/kmo_priv_functions-test.c         |   12 +-
 kmos/tests/kmo_priv_lcorr-test.c             |   12 +-
 kmos/tests/kmo_priv_make_image-test.c        |   38 +-
 kmos/tests/kmo_priv_noise_map-test.c         |   12 +-
 kmos/tests/kmo_priv_reconstruct-test.c       |   12 +-
 kmos/tests/kmo_priv_rotate-test.c            |   12 +-
 kmos/tests/kmo_priv_shift-test.c             |   12 +-
 kmos/tests/kmo_priv_sky_mask-test.c          |   12 +-
 kmos/tests/kmo_priv_sky_tweak-test.c         |   19 +-
 kmos/tests/kmo_priv_stats-test.c             |   12 +-
 kmos/tests/kmo_priv_std_star-test.c          |   12 +-
 kmos/tests/kmo_priv_wave_cal-test.c          |   12 +-
 kmos/tests/kmo_utils-test.c                  |   16 +-
 recipes/Makefile.am                          |   18 +-
 recipes/Makefile.in                          |  249 +-
 recipes/kmo_arithmetic.c                     |   14 +-
 recipes/kmo_combine.c                        |   35 +-
 recipes/kmo_copy.c                           |   12 +-
 recipes/kmo_dark.c                           |  668 ++--
 recipes/kmo_dev_setup.c                      | 1244 -------
 recipes/kmo_extract_spec.c                   |   30 +-
 recipes/kmo_fit_profile.c                    |   12 +-
 recipes/kmo_fits_check.c                     |   12 +-
 recipes/kmo_fits_stack.c                     |   12 +-
 recipes/kmo_fits_strip.c                     |   12 +-
 recipes/kmo_flat.c                           | 1476 +++-----
 recipes/kmo_illumination.c                   |   21 +-
 recipes/kmo_illumination_flat.c              |   32 +-
 recipes/kmo_make_image.c                     |  449 +--
 recipes/kmo_multi_reconstruct.c              |   20 +-
 recipes/kmo_noise_map.c                      |   12 +-
 recipes/kmo_reconstruct.c                    |  352 +-
 recipes/kmo_rotate.c                         |   12 +-
 recipes/kmo_sci_red.c                        | 2488 ++++++-------
 recipes/kmo_shift.c                          |   12 +-
 recipes/kmo_sky_mask.c                       |   26 +-
 recipes/kmo_sky_tweak.c                      |  280 +-
 recipes/kmo_stats.c                          |   12 +-
 recipes/kmo_std_star.c                       |   21 +-
 recipes/kmo_wave_cal.c                       |  829 ++---
 recipes/tests/Makefile.am                    |  180 -
 recipes/tests/Makefile.in                    | 1045 ------
 recipes/tests/create_data_recipes.c          | 2349 ------------
 recipes/tests/kmo_arithmetic-test.c          |  508 ---
 recipes/tests/kmo_combine-test.c             | 1082 ------
 recipes/tests/kmo_copy-test.c                |  455 ---
 recipes/tests/kmo_dark-test.c                |  503 ---
 recipes/tests/kmo_dev_setup-test.c           |  139 -
 recipes/tests/kmo_extract_spec-test.c        |  447 ---
 recipes/tests/kmo_final-test.c               |   69 -
 recipes/tests/kmo_final_test.sh              |   29 -
 recipes/tests/kmo_fit_profile-test.c         |  822 -----
 recipes/tests/kmo_fits_check-test.c          |  115 -
 recipes/tests/kmo_fits_stack-test.c          |  347 --
 recipes/tests/kmo_fits_strip-test.c          |  114 -
 recipes/tests/kmo_flat-test.c                |  775 ----
 recipes/tests/kmo_illumination-test.c        |  170 -
 recipes/tests/kmo_illumination_flat-test.c   |  168 -
 recipes/tests/kmo_init-test.c                |   39 -
 recipes/tests/kmo_make_image-test.c          |  362 --
 recipes/tests/kmo_multi_reconstruct-test.c   |  175 -
 recipes/tests/kmo_noise_map-test.c           |  211 --
 recipes/tests/kmo_reconstruct-test.c         |  165 -
 recipes/tests/kmo_rotate-test.c              |  469 ---
 recipes/tests/kmo_sci_red-test.c             |  201 -
 recipes/tests/kmo_shift-test.c               |  418 ---
 recipes/tests/kmo_sky_mask-test.c            |  257 --
 recipes/tests/kmo_stats-test.c               |  526 ---
 recipes/tests/kmo_std_star-test.c            |  270 --
 recipes/tests/kmo_wave_cal-test.c            |  216 --
 reflex/Makefile.am                           |    4 +-
 reflex/Makefile.in                           |    4 +-
 reflex/kmo_sci_red.py                        |  336 ++
 reflex/kmo_std_star.py                       |  245 ++
 reflex/kmo_wave_cal.py                       |  218 +-
 reflex/kmos.xml.in                           | 4390 +++++++++++++++++-----
 reflex/kmos_wkf.oca                          |    3 +-
 regtests/tests/Makefile.am                   |   16 +
 regtests/tests/Makefile.in                   |   16 +
 tools/easySPARK/Makefile                     |   38 +-
 133 files changed, 12373 insertions(+), 31575 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c3d41e5..aafd8cd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -36,7 +36,7 @@ DOXYGEN_SUBDIRS =
 SUBDIRS = $(COMPILE_FIRST) $(TOPSUBDIRS) $(COMPILE_LAST)
 
 EXTRA_DIST = catalogs tools m4macros/eso.m4 m4macros/cpl.m4 admin/doxygen.am \
-	     doxygen/Doxyfile.in setup recipes/tests/kmo_final_test.sh
+	     doxygen/Doxyfile.in setup 
 
 
 pipedocs_DATA = ChangeLog AUTHORS NEWS README TODO 
diff --git a/Makefile.in b/Makefile.in
index 3db968d..a65f3a8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -312,7 +312,7 @@ COMPILE_LAST =
 DOXYGEN_SUBDIRS = 
 SUBDIRS = $(COMPILE_FIRST) $(TOPSUBDIRS) $(COMPILE_LAST)
 EXTRA_DIST = catalogs tools m4macros/eso.m4 m4macros/cpl.m4 admin/doxygen.am \
-	     doxygen/Doxyfile.in setup recipes/tests/kmo_final_test.sh
+	     doxygen/Doxyfile.in setup 
 
 pipedocs_DATA = ChangeLog AUTHORS NEWS README TODO 
 @MAINTAINER_MODE_TRUE at MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.h.in configure stamp-h.in
diff --git a/calib/dic/ESO-DFS-DIC.KMOS_QC b/calib/dic/ESO-DFS-DIC.KMOS_QC
index d6ceab5..59aac31 100644
--- a/calib/dic/ESO-DFS-DIC.KMOS_QC
+++ b/calib/dic/ESO-DFS-DIC.KMOS_QC
@@ -269,6 +269,15 @@ Unit:              km/s
 Comment Field:     [km/s] mean 95%ile of fwhm for Ar ref. line.
 Description:       Mean 95%ile of FWHM for Argon reference line.
 
+Parameter Name:    QC ARC AR VSCALE
+Class:             header|qc-log
+Context:           process
+Type:              double
+Value Format:      %e
+Unit:              km/s
+Comment Field:     [km/s] velocity scale used for conversion
+Description:       Velocity scale used for conversion
+
 Parameter Name:    QC ARC NE POS MEAN
 Class:             header|qc-log
 Context:           process
@@ -341,6 +350,15 @@ Unit:              km/s
 Comment Field:     [km/s] mean 95%ile of fwhm for Ne ref. line.
 Description:       Mean 95%ile of FWHM for Neon reference line.
 
+Parameter Name:    QC ARC NE VSCALE
+Class:             header|qc-log
+Context:           process
+Type:              double
+Value Format:      %e
+Unit:              km/s
+Comment Field:     [km/s] velocity scale used for conversion
+Description:       Velocity scale used for conversion
+
 ###################################################################
 # kmo_illumination
 Parameter Name:    QC SPAT UNIF
diff --git a/calib/dic/ESO-VLT-DIC.NGCCON b/calib/dic/ESO-VLT-DIC.NGCCON
deleted file mode 100644
index ac6fbb4..0000000
--- a/calib/dic/ESO-VLT-DIC.NGCCON
+++ /dev/null
@@ -1,238 +0,0 @@
-Dictionary Name:   ESO-VLT-DIC.NGCCON
-Scope:             ESO NGC DCS
-Source:            jstegmei at eso.org
-Version Control:   "@(#) $Id: ESO-VLT-DIC.NGCCON,v 1.1 2012-01-31 13:46:39 yjung Exp $"
-Revision:          2.51
-Date:              2010-09-24
-Status:            draft
-Description:       Created.
-
-
-# Recommended max. comment length ---------|
-#                                          V
-# -----------------------------------------+------------------
-
-Parameter Name:    DETi CON AUTONLIN
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Go online after start
-Description:       When set to TRUE, the DCS goes automatically to ONLINE
-                   state at system startup. 
-
-Parameter Name:    DETi CON AUTOSTRT
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Auto-start at online
-Description:       When set to TRUE, the sequencers will automatically
-                   be started when the system goes to ONLINE state.
-
-Parameter Name:    DETi CON DATABASE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Database point
-Description:       Defines the NGC database point to be used for this
-                   detector system instance (without <alias> and 
-                   instance label).
-
-Parameter Name:    DETi CON DETIDX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     DET category index
-Description:       Defines the index for the DET category to be used
-                   to forward SETUP/STATUS commands to this instance.
-
-Parameter Name:    DETi CON OPMODE
-Class:             config | header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Operational mode
-Description:       Defines the operational mode for the detector front end
-                   system after starting up. Valid values for are:
-                     NORMAL  - Normal Operational Mode
-                     HW-SIM  - Simulate hardware
-                     LCU-SIM - Simulate hardware + LCU
-
-Parameter Name:    DETi CON DICT
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Dictionary list
-Description:       Defines the additional dictionaries to be loaded.
-                   The common ESO-VLT-DIC.NGCDCS ditcionary is always 
-                   loaded by default even if nothing is specified herein. 
-                   The entries are separated by white-space. Only the last 
-                   descriptor of the full dictionary name is needed here 
-                   (i.e. "NGCDCS STOO_CFG ..."). 
-
-Parameter Name:    DETi CON ENV
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Local online database environment
-Description:       Defines the local online database environment name.
-                   If not set, the RTAPENV environment variable is used.
-
-Parameter Name:    DETi CON GUI
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     GUI Name
-Description:       Defines the name of the control panel (GUI) to be used
-                   for the NGC DCS.
-
-Parameter Name:    DETi CON INSTANCE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Instance label
-Description:       Defines the instance label for server and OLDB. The label
-                   becomes an appendix to the server name when registering
-                   with the CCS environment. It is also appended to the
-                   database point defined by the DET.CON.DATABASE keyword.
-                   Actual point will be <alias>point_<label>. Actual
-                   name registered with CCS will be <control server>_<label>.
-
-Parameter Name:    DETi CON INSTi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Subsytem instance label
-Description:       Defines the instance label for subsystem servers and OLDBs
-                   (in case more independent subsystems are used).
-
-Parameter Name:    DETi CON LENV
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Remote online database environment
-Description:       Defines the remote online database environment name.
-                   "0" means "no remote environment".
-                   If not set, the CCDLENV environment variable is used.
-
-Parameter Name:    DETi CON LOG
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Logging level
-Description:       Defines the level of detail for log-messages.
-
-Parameter Name:    DETi CON POLL
-Class:             config|setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Enable sub-system status polling
-Description:       When set to TRUE, the system will by default
-                   query the sub-system status periodically
-
-Parameter Name:    DETi CON POLLINT
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              msec
-Comment Field:     Status polling interval
-Description:       Status polling interval in milliseconds.
-
-Parameter Name:    DETi CON SERVER
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Control-server name
-Description:       Defines the name of the control server to be used
-                   for the NGC DCS.
-
-Parameter Name:    DETi CON SYSCFG
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     HW system configuration file
-Description:       Defines the NGC hardware system configuration file to
-                   load after startup. If the parameter is set to "NONE"
-                   then a built-in default configuration is used.
-
-Parameter Name:    DETi CON VERBOSE
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Verbose level
-Description:       Defines the level of detail for verbose messages on
-                   standard output stream.
-
-Parameter Name:    DETi CON XTERM
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Start in new terminal
-Description:       Start (sub-)processes in new terminal. 
-
-Parameter Name:    DETi CON ITCPROC
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Image Transfer Client name
-Description:       Defines the name of the Image Transfer Client
-                   process to be used for the optical NGC. If
-		   not defined, "ngcoitc" is used.
-
-Parameter Name:    DETi CON OSCPROC
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Super Control process name
-Description:       Defines the name of the Super Control
-                   process to be used for the optical NGC. If
-		   not defined, "ngcosc" is used.
-
-Parameter Name:    DETi CON SRVPORT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Server port number
-Description:       Defines the server port number for NOCCS stand alone
-                   operation.
-
-# --- oOo ---
diff --git a/calib/dic/ESO-VLT-DIC.NGCDCS b/calib/dic/ESO-VLT-DIC.NGCDCS
deleted file mode 100644
index c62286a..0000000
--- a/calib/dic/ESO-VLT-DIC.NGCDCS
+++ /dev/null
@@ -1,5117 +0,0 @@
-#******************************************************************************
-# E.S.O. - VLT project
-#
-# "@(#) $Id: ESO-VLT-DIC.NGCDCS,v 1.1 2012-01-31 13:46:39 yjung Exp $"
-#
-# who       when      what
-# --------  --------  ----------------------------------------------
-# abalestr  11/09/06  created 
-#************************************************************************
-#   NAME
-#   ESO-VLT-DIC.NGCDCS - Data Interface Dictionary for NGC Detector Control Sw
-# 
-#   DESCRIPTION
-#
-#------------------------------------------------------------------------
-
-Dictionary Name:   ESO-VLT-DIC.NGCDCS
-Scope:             GENERIC
-Source:            ESO INS
-Version Control:   "@(#) $Id: ESO-VLT-DIC.NGCDCS,v 1.1 2012-01-31 13:46:39 yjung Exp $"
-Revision:          2.51
-Date:              2010-09-24
-Status:            draft
-Description:       Data Interface Dictionary for NGC Detector Control Sw
-
-
-Parameter Name:    DETi DID
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    NGCDCS dictionary
-Description:       Name-version of ESO DID to which NGC keywords comply
-
-
-#
-# Basic and Mandatory Primary FITS keywords included from 
-# ESO-VLT-DIC.PRIMARY-FITS. See also Data Interface Control Document
-# Doc. No.: GEN-SPE-ESO-19400-0794 Issue: 3, Appendix B
-#
-Parameter Name:    SIMPLE
-Class:             header
-Context:           FITS
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    Standard FITS (NOST-100-2.0)
-Description:       SIMPLE must be equal to 'T' to conform to FITS.
-
-
-Parameter Name:    BITPIX
-Class:             header
-Context:           FITS
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    # of bits per pix value
-Description:       Number of bits used to store pixel values 
-                   Standard values are defined in NOST-100.0
-                   The only valid values are:
-                   8   character of unsigned binary integer
-                   16  16-bit twos-complement binary integer
-                   32  32-bit twos-complement binary integer
-                  -32  IEEE single precision floating point
-                  -64  IEEE double precision floating point
-
-
-Parameter Name:    NAXIS
-Class:             header
-Context:           FITS
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    # of axes in data array
-Description:       Number of axes of the data array (limited to less than 999). 
-                   A value of 0 signifies that no data follow the 
-                   header in the HDU (header and data unit).
-
-
-Parameter Name:    NAXISi
-Class:             header
-Context:           FITS
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    # of pixels in <axis direction>
-Description:       Number of pixels along the n axis in the array.
-                   Possible values for <axis direction> are:
-                   rows (1), columns (2), frame (3)
-
-
-Parameter Name:    CTYPEi
-Class:             header
-Context:           FITS
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Pixel coordinate system
-Description:       Defines the coordinate system for CRPIXi. CTYPEi for
-                   raw frames is 'PIXEL'.
-
-
-Parameter Name:    CRPIXi
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %f
-Unit:              
-Comment Format:    Ref. pixel in <axis direction>
-Description:       Position of the reference pixel of the detector matrix
-                   relative to the coordinate frame of the readout window.
-
-
-Parameter Name:    CRVALi
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %f
-Unit:              
-Comment Format:    Coordinate value of ref. pixel
-Description:	   Value of pixel CRPIXi.
-
-
-Parameter Name:    CDn_m
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %f
-Unit:              
-Comment Format:    Transformation matrix element
-Description:       Elements of the coordinate transformation matrix.
-
-
-Parameter Name:    BZERO
-Class:             setup|header
-Context:           FITS
-Type:              double
-Value Format:      %.1f
-Unit:              
-Comment Format:    pixel=FITS*BSCALE+BZERO
-Description:	   Offset to be applied to values in the frame to
-		   obtain original pixel values. See BSCALE.
-		   BZERO is only included when not equal 0.
-
-
-Parameter Name:    BSCALE
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %.1f
-Unit:              
-Comment Format:    pixel=FITS*BSCALE+BZERO
-Description:	   Scale to be applied to values in the frame to
-		   obtain original pixel values. See BZERO.
-		   BSCALE is only included when not equal 1.  
-
-
-Parameter Name:    CDELTi
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %.1f
-Unit:              
-Comment Format:    Binning factor
-Description:	   Number of detector pixels per data pixels, also known
-                   as binning factor
-
-
-Parameter Name:    EXTEND
-Class:             header
-Context:           FITS
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    FITS Extension may be present
-Description:       Set to T when extension used. 
-                   This keyword has to appear in the primary header
-                   immediately after the last NAXISn card image, or, 
-                   if NAXIS=0, the NAXIS card image.
-
-
-Parameter Name:    ORIGIN
-Class:             header
-Context:           FITS
-Type:              string
-Value Format:      %30s
-Unit:              
-Comment Format:    European Southern Observatory
-Description:       Observatory source of this file.
-                   The value is either 'ESO-LASILLA' or
-                   'ESO-PARANAL'.
-
-
-Parameter Name:    DATE
-Class:             header
-Context:           FITS
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Date this file was written
-Description:       UTC date on which this file was written.
-                   The following format shall be used:
-                   YYYY-MM-DDThh:mm:ss.sss
-
-
-Parameter Name:    DATE-OBS
-Class:             header
-Context:           FITS
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Observing date
-Description:       UTC date on which the data of this file were obtained.
-                   The format used is
-                   YYYY-MM-DDThh:mm:ss.sss
-
-
-Parameter Name:    MJD-OBS
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %.8f
-Unit:              
-Comment Format:    Obs start
-Description:       Modified Julian Day of the start of the exposure.
-                   The MJD is related to the Julian Day (JD) via the
-                   formula: MJD = JD-2400000.5
-                   The comment includes a civil representation of 
-                   the date and time. 8 decimals are required 
-                   for a precision of one millisecond, 5 decimals 
-                   for a precision of one second.
-
-
-Parameter Name:    EXPTIME
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %.7f
-Unit:              s
-Comment Format:    Integration time
-Description:       The integration time for a single observation (in the
-                   infrared this corresponds to DIT).
-
-
-Parameter Name:    EXTNAME
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Extension name
-Description:       Extension name
-
-
-Parameter Name:    ORIGFILE
-Class:             header
-Context:           archive
-Type:              string
-Value Format:      %40s
-Unit:              
-Comment Format:    Original File Name 
-Description:       Name of the frame when it was generated on 
-                   instrument workstation. 
-
-
-Parameter Name:    TIMESYS
-Class:             header
-Context:           FITS
-Type:              string
-Value Format:      %s
-Unit: 
-Comment Format:    Time system used
-Description:       Lists the standard abbreviation of the principal
-                   time system used for the time-related keywords and
-                   the data. This keyword needs to be present only if
-                   the system used is other than UTC. Allowed values
-                   are listed in http://tycho.usno.navy.mil/systime.html
-
-
-Parameter Name:    INHERIT
-Class:             header
-Context:           FITS
-Type:              logical
-Value Format:      %c
-Unit:
-Comment Format:    denotes the INHERIT keyword convention
-Description:       The presence of this keyword with a value=T in an
-                   extension header indicates that the keywords
-                   contained in the primary header (except the FITS
-                   Mandatory keywords, and any COMMENT, HISTORY or
-                   'blank' keywords) are to be inherited, or logically
-                   included in that extension header
-
-
-Parameter Name:    GCOUNT
-Class:             header
-Context:           FITS
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of groups
-Description:	   
-
-
-Parameter Name:    PCOUNT
-Class:             header
-Context:           FITS
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of parameters per group
-Description:	   
-
-
-Parameter Name:    XTENSION
-Class:             header
-Context:           FITS
-Type:              string
-Value Format:      %8s
-Unit:              
-Comment Format:    FITS Extension first keyword
-Description:       Indicates start of an extension block in the FITS file.
-                   This keyword is mandatory for an extension header and
-                   must not appear in the primary header.
-                   Possible values are:
-                   'TABLE   '    for ASCII tables
-                   'BINTABLE'    for binary tables
-                   'IMAGE   '    for image extensions
-
-
-#
-# DETi keywords
-#
-
-#
-# Mandatory DETi keywords (see Data Interface Control Document Doc. No.: 
-# GEN-SPE-ESO-19400-0794 Issue: 3, Appendix B)
-# Note: mandatory REQTIM and DKTIM has been proposed as EXPTIME and DARKTIME
-#
-
-Parameter Name:    DETi ID
-Class:             header|config
-Context:           Detector
-Type:              string
-Value Format:      %30s
-Unit:              
-Comment Format:    Detector system Id
-Description:       Specifies the some unique identification for the detector
-                   system.
-
-Parameter Name:    DETi DATE
-Class:             header|config
-Context:           Detector
-Type:              string
-Value Format:      %30s
-Unit:              
-Comment Format:    Installation date
-Description:       Gives the installation date of the DCS software.
-
-Parameter Name:    DETi NAME
-Class:             header|config
-Context:           Detector
-Type:              string
-Value Format:      %30s
-Unit:              
-Comment Format:    Name of detector system
-Description:       ESO name of the detector system.
-
-Parameter Name:    DETi CHIPS
-Class:             header|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of chips in the mosaic
-Description:       Number of chips in the mosaic.
-
-Parameter Name:    DETi WINDOWS
-Class:             header|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of windows readout
-Description:       Total number of windows which are readout.
-
-Parameter Name:    DETi RA
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.9f
-Unit:              deg
-Comment Format:    Apparent %HOURANG RA at start
-Description:       Center right ascension in degrees
-
-Parameter Name:    DETi DEC
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.9f
-Unit:              deg
-Comment Format:    Apparent %DEGREE DEC at start
-Description:       Center declination in degrees
-
-Parameter Name:    DETi REV BASESW
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %30s
-Unit:              
-Comment Format:    Base software version
-Description:       Version of the installed NGC base software
-
-Parameter Name:    DETi REV OPTSW
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %30s
-Unit:              
-Comment Format:    Optical software version
-Description:       Version of the installed NGC optical software
-
-Parameter Name:    DETi REV DETMOD
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %30s
-Unit:              
-Comment Format:    Detector module revision
-Description:       Version of the used detector configuration
-                   module (configuration, voltages, sequences)
-
-
-#
-# operational mode
-#
-Parameter Name:    DETi SOFW MODE
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %16s
-Unit:              
-Comment Format:    CCD sw operational mode
-Description:       CCD sw operational mode
-
-
-#
-# Mandatory DETi CHIPi keywords (see Data Interface Control Document Doc. No.: 
-# GEN-SPE-ESO-19400-0794 Issue: 3, Appendix B)
-#
-
-Parameter Name:    DETi CHIPi ID
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %30s
-Unit:              
-Comment Format:    Detector chip identification
-Description:       Specifies the hardware identification of the chip.
-		   Suggested format: SER-NO=xxxxx
-
-Parameter Name:    DETi CHIPi NAME
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %16s
-Unit:              
-Comment Format:    Detector chip name
-Description:       Name commonly used by ESO maintenance staff
-
-Parameter Name:    DETi CHIPi DATE
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %10s
-Unit:              
-Comment Format:    Date of installation [YYYY-MM-DD]
-Description:       Date when chip has been installed and tested on the camera
-
-Parameter Name:    DETi CHIPi NX
-Class:             config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Physical active pixels in X
-Description:       Number of physical active pixels on the chip in x direction
-                   (excluding the prescan or overscan pixels).
-
-Parameter Name:    DETi CHIPi NY
-Class:             config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Physical active pixels in Y
-Description:       Number of physical active pixels on the chip in x direction
-                   (excluding the prescan or overscan pixels).
-
-Parameter Name:    DETi CHIPi PRSCX
-Class:             header|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Physical prescan pixels in X
-Description:       Number of physical prescan pixels in X.
-
-Parameter Name:    DETi CHIPi PRSCY
-Class:             header|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Physical prescan pixels in Y
-Description:       Number of physical prescan pixels in Y.
-
-Parameter Name:    DETi CHIPi OVSCX
-Class:             header|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Physical overscan pixels in X
-Description:       Number of physical overscan pixels in X.
-
-Parameter Name:    DETi CHIPi OVSCY
-Class:             header|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Physical overscan pixels in Y
-Description:       Number of physical overscan pixels in Y.
-
-Parameter Name:    DETi CHIPi PSZX
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %.1f
-Unit:              um
-Comment Format:    Size of pixel in X (mu)
-Description:       Physical extent of a pixel in X direction.
-
-Parameter Name:    DETi CHIPi PSZY
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %.1f
-Unit:              um
-Comment Format:    Size of pixel in Y (mu)
-Description:       Physical extent of a pixel in Y direction.
-
-Parameter Name:    DETi CHIPi OUTPUTS
-Class:             config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of outputs
-Description:       Number of output ports per chip. On IR detector the name
-                   "channels" may be more appropriated.
-
-Parameter Name:    DETi CHIPi OUTi NAME
-Class:             header|config
-Context:           Detector
-Type:              string
-Value Format:      %16s
-Unit:              
-Comment Format:    Description of output
-Description:       The name should help maintenance staff to recognise the
-                   output on chip (e.g. through location, characteristics)
-
-Parameter Name:    DETi CHIPi OUTi ID
-Class:             header|config
-Context:           Detector
-Type:              string
-Value Format:      %16s
-Unit:              
-Comment Format:    Output ID as from manufacturer
-Description:       Unique identifier of the output. Normally the ID
-                   used by the manufacturer is defined here.
-
-Parameter Name:    DETi CHIPi OUTi X
-Class:             header|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    X location of output
-Description:       Location along X axis in the frame of the chip.
-		   The output located at the lower left corner of the
-		   chip is numbered 1. The numbering scheme goes 
-		   counter clockwise.
-
-Parameter Name:    DETi CHIPi OUTi Y
-Class:             header|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Y location of output
-Description:       Location along Y axis in the frame of the chip.
-		   The output located at the lower left corner of the
-		   chip is numbered 1. The numbering scheme goes 
-		   counter clockwise.
-
-Parameter Name:    DETi CHIPi OUTi INDEX
-Class:             config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output index
-Description:       Index addressing an output on a chip. Lower left output is
-                   number one and numbering scheme goes counter clockwise.
-
-#
-# Not mandatory DETi CHIPi keywords
-#
-
-Parameter Name:    DETi CHIPi X
-Class:             config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    X location in array
-Description:       X location of the chip within the mosaic.
-		   The chip located at the lower left corner of the
-		   mosaic is numbered 1. The numbering scheme goes 
-		   counter clockwise.
-
-Parameter Name:    DETi CHIPi Y
-Class:             config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Y location in array
-Description:       Y location of the chip within the mosaic.
-		   The chip located at the lower left corner of the
-		   mosaic is numbered 1. The numbering scheme goes 
-		   counter clockwise.
-
-Parameter Name:    DETi CHIPi XGAP
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %f
-Unit:              
-Comment Format:    Gap after chips along x
-Description:       microns to the next chip to the right
-
-Parameter Name:    DETi CHIPi YGAP
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %f
-Unit:              
-Comment Format:    Gap after chip along y
-Description:       microns to the next chip upwards
-
-Parameter Name:    DETi CHIPi RGAP
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %f
-Unit:              degrees
-Comment Format:    Angle of gap between chips
-Description:       rotation angle from one chip to next to the right
-
-Parameter Name:    DETi CHIPi INDEX
-Class:             config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Chip index
-Description:       Index addressing a chip in the mosaic. Lower left chip is
-                   number one and numbering scheme goes counter clockwise.
-
-Parameter Name:    DETi CHIPi LIVE
-Class:             config|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Detector alive
-Description:       Marks a detector as alive (='T') or faulty (='F'). The
-                   keyword is only used for detector mosaics. Must be
-                   specified in the Detector Configuration File. Default
-                   value is 'T' for all chips.
-
-Parameter Name:    DETi CHIPi TYPE
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     The Type of detector chip
-Description:       Detector could be CCD, CMOS etc.
-
-Parameter Name:    DETi CHIPi PXSPACE
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3E
-Unit:              m
-Comment Field:     Pixel-Pixel Spacing
-Description:       Spacing between pixel for the chip. Is given in meters. 
-
-Parameter Name:    DETi CHIPi GAIN
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              
-Comment Field:     Gain in e-/ADU
-Description:       Global gain of the chip. 
-
-Parameter Name:    DETi CHIPi RON
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              
-Comment Field:     Read-out noise in e
-Description:       Read-out noise of the chip. 
-
-Parameter Name:    DETi CHIPi OUTi NX
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output data pixels in X
-Description:       Number of data pixels in X direction, in the
-                   delivered image data
-
-Parameter Name:    DETi CHIPi OUTi NY
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output data pixels in Y
-Description:       Number of data pixels in Y direction, in the
-                   delivered image data
-
-Parameter Name:    DETi CHIPi OUTi PRSCX
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output prescan pixels in X
-Description:       Number of prescan pixels in X direction, in the
-                   delivered image data
-
-Parameter Name:    DETi CHIPi OUTi PRSCY
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output prescan pixels in Y
-Description:       Number of prescand pixels in Y direction, in the
-                   delivered image data
-
-Parameter Name:    DETi CHIPi OUTi OVSCX
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output overscan pixels in X
-Description:       Number of overscan pixels in X direction, in the
-                   delivered image data
-
-Parameter Name:    DETi CHIPi OUTi OVSCY
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output overscan pixels in Y
-Description:       Number of overscan pixels in Y direction, in the
-                   delivered image data
-
-Parameter Name:    DETi CHIPi OUTi READX
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Horizontal readout direction.
-Description:       Horizontal readout direction: 
-                   +1 means that - to be read - the charges are moved
-                      towards the negative horizontal direction
-                      (i.e., the output is on the left side of a chip)
-                   -1 means that - to be read - the charges are moved
-                      towards the positive horizontal direction
-                      (i.e., the output is on the right side of a chip)
-
-Parameter Name:    DETi CHIPi OUTi READY
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Vertical readout direction.
-Description:       Vertical readout direction: 
-                   +1 means that - to be read - the charges are moved
-                      towards the negative vertical direction
-                      (i.e., the output is on the bottom side of a chip)
-                   -1 means that - to be read - the charges are moved
-                      towards the positive vertical direction
-                      (i.e., the output is on the upper side of a chip)
-
-Parameter Name:    DETi CHIPi OUTi GAIN
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              ADU/e-
-Comment Format:    Conversion from electrons to ADU
-Description:       The gain to which the amplifier output has been set.
-
-Parameter Name:    DETi CHIPi OUTi CONAD
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              e-/ADU
-Comment Format:    Conversion from ADUs to electrons
-Description:       The conversion factor which translates ADU
-		   to photonic electrons.
-
-Parameter Name:    DETi CHIPi OUTi RON
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              e-
-Comment Format:    Readout noise per output (e-)
-Description:       Readout noise per output (e-)
-
-
-Parameter Name:    DETi CHIPi CRPIXi
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %f
-Unit:              
-Comment Format:    Ref. pixel in <axis direction> for CHIPi in mosaic.
-Description:       Position of the reference pixel of the detector matrix
-                   relative to the coordinate frame of the readout window.
-
-
-#
-# Mandatory DETi EXP keywords (see Data Interface Control Document Doc. No.: 
-# GEN-SPE-ESO-19400-0794 Issue: 3, Appendix B)
-#
-
-Parameter Name:    DETi EXP TYPE
-Class:             setup|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Exposure type
-Description:       Possible values:
-                   'Normal'     one integration, shutter (if any) open
-                   'Dark'       one integration, shutter (if any) closed
-                   'Bias'       one integration, 0 integration time,
-		                shutter (if any) closed
-                   'Flat'       one integration, shutter (if any) open
-                   'Led'        one integration, shutter (if any) closed, LED
-		                light source on
-                   'LedShut'    one integration, shutter (if any) open, LED
-		                light source on
-                   'Multiple'   DETi.WIN1.NDIT sub-integrations, shutter 
-		                (if any) open for each integration
-                   'Burst'      Multiple frames are read out, shutter (if any) 
-		                always open
-
-Parameter Name:    DETi EXP ID
-Class:             header|ops-log
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Unique exposure ID
-Description:       Unique exposure ID
-
-Parameter Name:    DETi EXP DUMDIT
-Class:             header|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of dummy readouts
-Description:       Total number of dummy readouts (aka number of wipes) per 
-                   exposure. Not necessary or set to 0 for infrared exposures.
-
-#
-# Not mandatory DETi EXP keywords
-#
-
-Parameter Name:    DETi EXP STATUS
-Class:             private|ops-log
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Exposure status changed
-Description:       The exposure status has changed (PENDING, INTEGRATING, 
-                   READING...)
-
-Parameter Name:    DETi EXP TIMEABS
-Class:             setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    Interpretation of setup keyword MJD-OBS for start time
-Description:       T = absolute time
-                   F = relative to now (0. = start now)
-
-Parameter Name:    DETi EXP UTC
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Exposure has finished "photon collection" phase.
-Description:       Time when DCS has finished the "photon collection" phase
-                   and it is ready to send data to the IWS. 
-                   For visual exposures this time is the same as 
-                   DETi SHUTi TMCLOS.
-
-Parameter Name:    DETi EXP NO
-Class:             header|ops-log
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Unique exposure ID number
-Description:       When a new exposure is started, the DCS assigns a
-                   unique identifier to it. The id is a positive integer 
-                   number. The id can be passed as expoId parameter to 
-                   the START command. If no expoId parameter is passed 
-                   to the START command, the id value is calculated by 
-                   increasing by 1 the id of the previous exposure.
-
-Parameter Name:    DETi EXP NREP
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    number of repeated exposures
-Description:       Number of time the same exposure must be repeated.
-                   If <= 0 --> repeat forever (infinite loop)
-
-Parameter Name:    DETi EXP WIPETIM
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    wipe before starting exposure in a loop
-Description:       This keyword is used for CCD only.
-                   This setup keyword indicates if a wipe is wished or not
-                   for exposures in a loop. The wipe for the first exposure
-                   is always done. Meaning:
-                     n < 0: never wipe
-                     n = 0: always wipe
-                     n > 0: wipe if (now - last readout) > n (in msec)
-                   For frame transfer chips (e.g TCCDS), if no wipe is 
-		   performed, readout and next integration overlap.
-
-Parameter Name:    DETi EXP TIMEREP
-Class:             setup
-Context:           Detector
-Type:              double
-Value Format:      %.6f
-Unit:              s
-Comment Format:    Time between two repeated exposures
-Description:       Sometimes one wants to execute n exposures with the same
-                   interval of time between each.
-
-Parameter Name:    DETi EXP RDTTIME
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              s
-Comment Format:    image readout time
-Description:	   time needed to performed the requested readout
-
-Parameter Name:    DETi EXP PROCTIM
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              s
-Comment Format:    image processing time
-Description:	   time needed by the real-time image processing to
-                   execute the requested computations on the frame
-
-Parameter Name:    DETi EXP XFERTIM
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              s
-Comment Format:    image transfer time
-Description:	   time needed to transfer the frame to the workstation.
-                   This includes, whenever requested, the writing on disk
-                   of the FITS file.
-                   Note that read-out and image transfer are performed in
-                   parallel. The image transfer is started as soon the first
-                   image data with the final orientation are available on
-                   LCU. In general therefore the image transfer starts after
-                   the read-out and may take less or more time than the 
-                   read-out, depending on the read-out mode used (speed and
-                   location of outputs used) and on the network bandwith and
-                   load.
-
-#
-# Mandatory DETi WINi keywords (see Data Interface Control Document Doc. No.: 
-# GEN-SPE-ESO-19400-0794 Issue: 3, Appendix B)
-#
-
-Parameter Name:    DETi WINi STRX
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Lower left pixel in X
-Description:       First window pixel in X direction within the
-                   detector physical system.
-
-Parameter Name:    DETi WINi STRY
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Lower left pixel in Y
-Description:       First window pixel in Y direction within the
-                   detector physical system.
-
-Parameter Name:    DETi WINi NX
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of pixels along X
-Description:       The total number of columns in the window.
-
-Parameter Name:    DETi WINi NY
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of pixels along Y
-Description:       The total number of rows in the window.
-
-Parameter Name:    DETi WINi BINX
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Binning factor along X
-Description:       Numbers of pixels combined into one in X 
-		   direction on chip.
-
-Parameter Name:    DETi WINi BINY
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Binning factor along Y
-Description:       Numbers of pixels combined into one in Y 
-		   direction on chip.
-
-Parameter Name:    DETi WINi NDIT
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of subintegrations
-Description:       In case several integrations are recorded in the same
-                   exposure the number of individual integrations is 
-		   indicated.
-
-Parameter Name:    DETi WINi UITi
-Class:             setup|header
-Context:           Detector
-Type:              double
-Value Format:      %.6f
-Unit:              s
-Comment Format:    user defined subintegration time (sec)
-Description:       User defined integration time for each exposure step.
-                   For single step exposures, index 1 only is used (UIT1).
-                   Indexes higher than 1 are used only for multi-steps
-                   exposures.
-                   After the exposure has been performed, the values
-                   of DETi WINi UITi and DETi WINi DITi should be the same
-                   (within tolerances).
-
-Parameter Name:    DETi WINi DITi
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.6f
-Unit:              s
-Comment Format:    actual subintegration time (sec)
-Description:       Actual integration time for each exposure step.
-                   For single step exposures the value of DETi WINi DITi
-                   must be the same as EXPTIME.
-                   For multi-step exposures EXPTIME = sum(DITi)
-
-#
-# Not mandatory DETi WINi keywords
-#
-
-Parameter Name:    DETi WINi ST 
-Class:             setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    If T, window enabled
-Description:       T if enabled
-
-Parameter Name:    DETi WINi DKTM
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.4f
-Unit:              s
-Comment Format:    Dark current time
-Description:       Time between end of previous wipe (or read-out) and 
-                   start of read-out.
-
-Parameter Name:    DETi WINi RMS
-Class:             header|setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    Image RMS calculation performed
-Description:       The image RMS is calculated
-                   by the image processing task on NGC server.
-
-Parameter Name:    DETi WINi MINMAX
-Class:             setup|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    image extrema search performed
-Description:       The image extrema are defined
-                   by the real-time image processing task on LCU.
-
-Parameter Name:    DETi WINi BIAS
-Class:             setup|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    bias frame subtraction performed
-Description:       This frame is the result of a bias frame subtraction
-                   done by the real-time image processing task on LCU.
-
-Parameter Name:    DETi WINi FLATF
-Class:             setup|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    flat field division performed
-Description:       This frame is the result of a flat field division
-                   done by the real-time image processing task on LCU.
-
-Parameter Name:    DETi WINi CENTROID
-Class:             setup|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    type of centroiding calculation
-Description:       On this frame a centroiding calculation is
-                   done by the real-time image processing task on LCU.
-                   Possible values:
-                   'none'    (setup only)
-                   'standard'   
-                   'threshold'   
-
-Parameter Name:    DETi WINi REFX
-Class:             setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              pixel
-Comment Format:    X position of reference 
-Description:       Meaningful only if CENTROID is computed. This point allows
-	   	   the computation of the error vector.
-
-Parameter Name:    DETi WINi REFY
-Class:             setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              pixel
-Comment Format:    Y position of reference 
-Description:       Meaningful only if CENTROID is computed. This point allows
-	   	   the computation of the error vector.
-
-Parameter Name:    DETi WINi IPLLX
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              pixel
-Comment Format:    X offset from bottom left for proc. sub-window
-Description:       Relative location of processing sub-window inside 
-                   the readout window (offset in pixel along X-axis from
-                   the Lower Left corner)
-
-Parameter Name:    DETi WINi IPLLY
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              pixel
-Comment Format:    Y offset from bottom left for proc. sub-window
-Description:       Relative location of processing sub-window inside 
-                   the readout window (offset in pixel along Y-axis from
-                   the Lower Left corner)
-
-Parameter Name:    DETi WINi IPURX
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              pixel
-Comment Format:    X offset from top right for proc. sub-window
-Description:       Relative location of processing sub-window inside 
-                   the readout window (offset in pixel along X-axis from
-                   the Upper Right corner)
-
-Parameter Name:    DETi WINi IPURY
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              pixel
-Comment Format:    Y offset from top right for proc. sub-window
-Description:       Relative location of processing sub-window inside 
-                   the readout window (offset in pixel along Y-axis from
-                   the Upper Right corner)
-
-Parameter Name:    DETi WINi BACKGND
-Class:             setup 
-Context:           Detector
-Type:              double
-Value Format:      %f
-Unit:              ADU
-Comment Format:    sky background
-Description:       When positive, this value will be substracted from each pixel
-	           In addition, this parameter can take the values:
-	             0 : no background correction
-	            -1 : The background is set to the average intensity 
-			 computed on 4 subwindows located at the 4 corners 
-			 of this image.
-                   -11 : The background is set to the average intensity over
-	                 the previous window (valid only for the 2nd window)
-		   Note: when CENTROID is 'standard':	
-	            	 this value is forced to 2 * the average intensity
-                   	 over this image.
-
-Parameter Name:    DETi WINi THRMIN
-Class:             setup 
-Context:           Detector
-Type:              double
-Value Format:      %f
-Unit:              ADU
-Comment Format:    lower threshold
-Description:       All pixels below or equal this positive value will be set to zero.
-	           In addition, this parameter can take the value -N:
-		   N =  1 to  9 : The threshold is set to N * the intensity 
-			standard deviation over this image
-		   N = 11 to 19 : The threshold is set to N * the intensity 
-			standard deviation over the first window 
-	                (valid only for the 2nd window)
-		   Note: when CENTROID is 'standard':	
-	           	 This value is forced to zero.
-
-Parameter Name:    DETi WINi THRMAX
-Class:             setup 
-Context:           Detector
-Type:              double
-Value Format:      %f
-Unit:              ADU
-Comment Format:    upper threshold
-Description:       Not implemented yet
-
-
-#
-# DEVice subsystem
-#
-
-Parameter Name:    DETi NUMDEV
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Number of devices
-Description:       Number of interface devices in the system.
-
-Parameter Name:    DETi DEVi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Device name
-Description:       Device name of the physical interface device. Typically
-                   this is "/dev/ngc<i>_com".
-
-Parameter Name:    DETi DEVi HOST
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Host of interface device
-Description:       Host name of the NGC-LCU where the physical interface 
-                   resides.
-
-Parameter Name:    DETi DEVi ENV
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Environment name of device
-Description:       Name of the CCS environment on the NGC-LCU where the
-                   driver interface process is launched.
-
-Parameter Name:    DETi DEVi SRV
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Driver interface process name
-Description:       Server name of the driver interface process (optional). 
-                   Usually this is "ngcb2Drv".
-
-Parameter Name:    DETi DEVi TYPE
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Interface type
-Description:       Describes the interface type (optional).
-
-Parameter Name:    DETi DEVi REV
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Revision
-Description:       Revision number of the device.
-
-Parameter Name:    DETi DEVi SERNO
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Serial no
-Description:       Serial number of the device.
-
-Parameter Name:    DETi DEVi BACKPLN
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Back-plane ID
-Description:       Back-plane ID of this device.
-
-Parameter Name:    DETi DEVi SIDELINK
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Control via sidelink
-Description:       When set to TRUE valaue, this instance is controlled 
-                   via its side-link instead of its up-link. This requires
-                   a master and a configuration route to be sepcified.
-
-Parameter Name:    DETi DEVi MASTER
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Master device index
-Description:       Index of the master device of this instance. Only
-                   applicable when the side-link is used.
-
-Parameter Name:    DETi DEVi CFGROUTE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Route to device
-Description:       Link route leading from the master device to this
-                   instance. Only applicable when the side-link is used.
-
-Parameter Name:    DETi DEVi PMC
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     PMC module installed
-Description:       When set to TRUE valaue, this instance is connected 
-                   via PMC module to the DFE. The system will then 
-                   automatically adjust the routing tables accordingly.
-
-Parameter Name:    DETi DEVi NUMBOARD
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Number of boards
-Description:       Number of boards addressed via this interface device.
-
-Parameter Name:    DETi DEVi BOARDi TYPE
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Type
-Description:       Board type.
-
-Parameter Name:    DETi DEVi BOARDi VERSION
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Version
-Description:       Board version (sub-type).
-
-Parameter Name:    DETi DEVi BOARDi REV
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Revision
-Description:       Revision number of the board.
-
-Parameter Name:    DETi DEVi BOARDi SERNO
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Serial no (board)
-Description:       Serial number of the board.
-
-Parameter Name:    DETi DEVi BOARDi TRANS
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Serial no (trans.-board)
-Description:       Serial number of the transition board.
-
-Parameter Name:    DETi DEVi BOARDi BCKPL
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Serial no (backplane)
-Description:       Serial number of the backplane where the board is
-                   installed.
-
-#
-# SEQuencer subsystem
-#
-
-Parameter Name:    DETi SEQ BREAK
-Class:             setup|config|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Break enabled
-Description:       When set to TRUE value, the system will use the break
-                   command for stopping the sequencers instead of the 
-                   (immediate) stop command.
-
-Parameter Name:    DETi SEQ BREAKTMO
-Class:             setup|config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              s
-Comment Field:     Break timeout
-Description:       Sequencer break command timeout (in seconds). When set
-                   zero the system will automatically compute a value.
-                   When no value can be found (e.g. when there are no
-                   break-points in the sequencer program then the
-                   system will skip the break-command and issue
-                   a stop command instead.
-
-Parameter Name:    DETi SEQ RESTART
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Auto-restart
-Description:       When set to TRUE value, the system will implement the
-                   automatic sequencer restart mechanism: When a parameter
-                   is set which enforces a sequencer to stop then the
-                   sequencer is autoamtically restarted after the setup 
-                   has been done.
-
-Parameter Name:    DETi SEQi DEVIDX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Device index
-Description:       Index of the physical device used by this sequencer
-                   module instance.
-
-Parameter Name:    DETi SEQi ROUTE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Route to module
-Description:       Link route leading to this sequencer module instance.
-
-Parameter Name:    DETi SEQi CLOCK
-Class:             config
-Context:           Detector
-Type:              double
-Value Format:      %.3E
-Unit:              s
-Comment Field:     Clock speed
-Description:       Time of one sequencer clock tick.
-
-Parameter Name:    DETi SEQi SOFTMON
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Soft-monitor
-Description:       When set to TRUE value, the sequencer will use the
-                   soft-monitor for the digital clocks instead of
-                   the multiplexor built in the firmware.
-
-Parameter Name:    DETi SEQi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional module name
-Description:       Optional name for this sequencer module.
-
-Parameter Name:    DETi SEQi GROUP
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional group name
-Description:       Optional group assignment for this sequencer module.
-
-Parameter Name:    DETi SEQi STATUS
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Sequencer status
-Description:       The keyword is used to query the sequencer status. It can
-                   be one of "idle"|"runnning"|"waiting"|"failure".
-
-Parameter Name:    DETi SEQi REGSTAT
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     Sequencer status register
-Description:       Content of the sequencer status register (read-only).
-
-Parameter Name:    DETi SEQi WAITING
-Class:             private
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Waiting for trigger
-Description:       The keyword is used to query the sequencer waiting
-                   state.
-
-Parameter Name:    DETi SEQi RUNCTRL
-Class:             setup|config|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Run-control active
-Description:       When set to TRUE value, the sequencer will start
-                   synchronously with the other sequencers in the
-                   system via the external run-ctrl signal.
-
-Parameter Name:    DETi SEQi CVTEXT
-Class:             setup|config|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     External convert active
-Description:       When set to TRUE value, the external convert 
-                   control is enabled.
-
-Parameter Name:    DETi SEQi CONT
-Class:             setup|config|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Continuous mode active
-Description:       The keyword indicates if the sequencer is running in
-                   continuous mode. Default is FALSE.
-
-Parameter Name:    DETi SEQi TRIGGER
-Class:             setup|config|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Trigger mode active
-Description:       The keyword specifies whether the sequencer is running in
-                   triggered mode. Default is FALSE.
-
-Parameter Name:    DETi SEQi TRIGMODE
-Class:             setup|config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Trigger mode (0=direct,1=shutter)
-Description:       The keyword sepcifies the sequencer trigger mode. Valid
-                   values are 0 (direct, default) or 1 (by shutter).
-
-Parameter Name:    DETi SEQi TIMEFAC
-Class:             setup|config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Dwell-time factor
-Description:       Global factor for the pattern state dwell time
-
-Parameter Name:    DETi SEQi TIMEADD
-Class:             setup|config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Dwell-time add value
-Description:       Global value to add to the pattern state dwell time
-
-Parameter Name:    DETi SEQi MONi
-Class:             setup|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Digital monitor clock
-Description:       This parameter selects the sequencer clock to be monitored
-                   on the digital clock-monitor 1 or 2.
-
-Parameter Name:    DETi SEQi CLKFILE
-Class:             setup|config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Clock-pattern file
-Description:       Clock-pattern configuration file name
-
-Parameter Name:    DETi SEQi PRGFILE 
-Class:             setup|config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Sequencer program file
-Description:       Sequencer program file
-
-Parameter Name:    DETi SEQi PATi CLKi
-Class:             setup
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     New state vector
-Description:       This keyword directly sets a new state vector on a certain 
-                   clock in a certain pattern 
-
-Parameter Name:    DETi SEQi AUTOINIT
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Pattern auto-init
-Description:       When set to TRUE value, the sequencer will automatically
-                   initialize the clock-states at next reset with last 
-                   executed state.
-
-Parameter Name:    DETi SEQi INIT FIRST
-Class:             setup|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Init with 1st state.
-Description:       Initialize the sequencer after reset with the first state 
-                   of the pattern defined by this keyword.
-
-Parameter Name:    DETi SEQi INIT LAST
-Class:             setup|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Init with last state.
-Description:       Initialize the sequencer after reset with the last state 
-                   of the pattern defined by this keyword.
-
-Parameter Name:    DETi SEQi INITPAT
-Class:             setup|config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Initial state vector
-Description:       The keyword directly sets the default initial clock pattern
-                   state vector to be applied after sequencer program reset. 
-                   The format is a binary string with max. 64 characters (0|1).
-                   When the system is in ONLINE state the default pattern
-                   is also applied immediately.
-
-Parameter Name:    DETi SEQi INITLOW
-Class:             setup|config
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     Initial pattern low
-Description:       The keyword directly sets the default initial clock pattern
-                   low word to be applied after sequencer program reset.
-                   When the system is in ONLINE state the default pattern
-                   is also applied immediately.
-
-Parameter Name:    DETi SEQi INITHIGH
-Class:             setup|config
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     Initial pattern high
-Description:       The keyword directly sets the default initial clock pattern
-                   high word to be applied after sequencer program reset.
-                   When the system is in ONLINE state the default pattern
-                   is also applied immediately.
-
-Parameter Name:    DETi SEQi LASTPAT
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Last state vector
-Description:       The keyword returns the last clock state vector executed 
-                   by the currently loaded sequencer program. The format
-                   is a binary string with 64 characters (0|1).
-
-Parameter Name:    DETi SEQi FIRSTPAT
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     First state vector
-Description:       The keyword returns the first clock state vector executed 
-                   by the currently loaded sequencer program. The format
-                   is a binary string with 64 characters (0|1).
-
-Parameter Name:    DETi SEQi PATi STATLOWi
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     Pattern state low
-Description:       The keyword returns the low RAM clock state of a pattern.
-
-Parameter Name:    DETi SEQi PATi STATHIGHi
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     Pattern state high
-Description:       The keyword returns the high RAM clock state of a pattern.
-
-Parameter Name:    DETi SEQi DIT
-Class:             header|setup
-Context:           Detector
-Type:              double
-Value Format:      %.7f
-Unit:              s
-Comment Field:     Integration Time
-Description:       Time in seconds of each integration ramp. 
-
-Parameter Name:    DETi SEQi DITDELAY
-Class:             header|setup
-Context:           Detector
-Type:              double
-Value Format:      %.7f
-Unit:              s
-Comment Field:     Delay before integration
-Description:       Sets a delay (in seconds) before the integration starts. 
-
-Parameter Name:    DETi SEQi EXPTIME
-Class:             setup
-Context:           Detector
-Type:              double
-Value Format:      %.1f
-Unit:              s
-Comment Field:     Exposure Time Estimation (sec)
-Description:       Used by IR only.
-                   Estimated value for the exposure duration (in seconds). 
-                   The DCS exposure countdown will be loaded with this 
-                   value.
-
-Parameter Name:    DETi SEQi MINDIT
-Class:             setup|header
-Context:           Detector
-Type:              double
-Value Format:      %.7f
-Unit:              s
-Comment Field:     Minimum DIT
-Description:       The minimum detector integration time.
-
-Parameter Name:    DETi SEQi WIN STRX
-Class:             setup|header 
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Read-out window start-x
-Description:       Defines the lower left corner corner x-coordinate of
-                   read-out window within the detector coordinate system. 
-                   It does not necessarily need to be identical with the 
-                   the acquisition processing window but will always be 
-                   used as default for this.
-
-Parameter Name:    DETi SEQi WIN STRY
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Read-out window start-y
-Description:       Defines the lower left corner corner y-coordinate of
-                   read-out window within the detector coordinate system. 
-                   It does not necessarily need to be identical with the 
-                   the acquisition processing window but will always be 
-                   used as default for this.
-
-Parameter Name:    DETi SEQi WIN NX
-Class:             setup|header 
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Read-out window NX
-Description:       Defines the number of pixels in x-direction of the
-                   read-out window. It does not necessarily need to be 
-                   identical with the the acquisition processing window 
-                   but will always be used as default for this. A zero 
-                   value indicates full-frame.
-
-Parameter Name:    DETi SEQi WIN NY
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Read-out window NY
-Description:       Defines the number of pixels in y-direction of the
-                   read-out window. It does not necessarily need to be 
-                   identical with the the acquisition processing window 
-                   but will always be used as default for this. A zero 
-                   value indicates full-frame.
-
-
-#
-# PATterns subsystem
-#
-
-Parameter Name:    DETi PATi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Clock pattern name 
-Description:       Clock pattern name. 
-
-Parameter Name:    DETi PATi NSTAT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of states
-Description:       Number of states in the pattern.
-
-Parameter Name:    DETi PAT INITi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Initial state for each clock
-Description:       Initial state (0|1) for each clock.
-
-Parameter Name:    DETi PATi CLKi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     State vector for each clock
-Description:       State vector for each clock.
-
-Parameter Name:    DETi PATi DTV
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     State dwell-time vector
-Description:       State dwell-time vector.
-
-Parameter Name:    DETi PATi DTM
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Dell-Time modification flags
-Description:       State dwell-Time modification flags vector.
-
-
-#
-# CLock and DC (aka bias) subsystem
-#
-
-Parameter Name:    DETi CLDCi DEVIDX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Device index
-Description:       Index of the physical device used by this CLDC
-                   module instance.
-
-Parameter Name:    DETi CLDCi ROUTE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Route to module
-Description:       Link route leading to this CLDC module instance.
-
-Parameter Name:    DETi CLDCi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional module name
-Description:       Optional name for this CLDC module.
-
-Parameter Name:    DETi CLDCi GROUP
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional group name
-Description:       Optional group assignment for this CLDC module.
-
-Parameter Name:    DETi CLDCi STATUS
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Output status
-Description:       Status ("enabled" or "disabled").
-
-Parameter Name:    DETi CLDCi MAXCLK
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Maximum number of clocks
-Description:       Maximum number of clock voltages on board.
-
-Parameter Name:    DETi CLDCi MAXDC
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Maximum number of biases
-Description:       Maximum number of bias voltages on board.
-
-Parameter Name:    DETi CLDCi FILE
-Class:             setup|config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Voltage configuration file
-Description:       Voltage configuration file loaded into this module.
-
-Parameter Name:    DETi CLDCi MARGIN
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Margin for telemetry
-Description:       The keyword specifies a maximum value the telemtry
-                   measurement may deviate from the setup value. A margin
-                   of 0.0 Volts disables the telemetry check. 
-
-Parameter Name:    DETi CLDCi DACTIME
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.1f
-Unit:              s
-Comment Field:     DAC settling time
-Description:       DAC settling time (in seconds).
-
-Parameter Name:    DETi CLDCi CALMAX
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Voltage calibration limit
-Description:       The keyword specifies the limit for automatic voltage
-                   calibration. A limit of 0.0 Volts disables the 
-                   calibration. The value will internally be multiplied
-                   with the actual gain value to have this normalized
-                   for all DAC output channels.
-
-Parameter Name:    DETi CLDCi PREAMP
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Preamplifier offset (volt)
-Description:       Preamplifier offset.
-
-Parameter Name:    DETi CLDCi DIODE
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Diode bias (volt)
-Description:       Diode bias on CLDC module.
-
-Parameter Name:    DETi CLDCi CLKOFF
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Clock voltage offset (volt)
-Description:       Clock voltage offset.
-
-Parameter Name:    DETi CLDCi DCOFF
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Bias voltage offset (volt)
-Description:       Bias voltage offset.
-
-Parameter Name:    DETi CLDCi CLKLONMi
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Name of clock low
-Description:       Name of clock low.
-
-Parameter Name:    DETi CLDCi CLKHINMi
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Name of clock high
-Description:       Name of clock high.
-
-Parameter Name:    DETi CLDCi DCNMi
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Name of bias voltage
-Description:       Name of bias voltage.
-
-Parameter Name:    DETi CLDCi CLKLOi
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Clock voltage setup value (volt)
-Description:       Setup value for clock low.
-
-Parameter Name:    DETi CLDCi CLKLOXi
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %x
-Unit:              
-Comment Field:     Clock voltage register value
-Description:       Register value for clock low. The keyword is
-                   interpreted as hexadecimal value.
-
-Parameter Name:    DETi CLDCi CLKHIi
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Clock voltage setup value (volt)
-Description:       Setup value for clock high.
-
-Parameter Name:    DETi CLDCi CLKHIXi
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %x
-Unit:              
-Comment Field:     Clock voltage register value
-Description:       Register value for clock high. The keyword is
-                   interpreted as hexadecimal value.
-
-Parameter Name:    DETi CLDCi CLKGNi
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Gain for clock
-Description:       Gain value of all DAC channels associated to this clock.
-
-Parameter Name:    DETi CLDCi CLKLOGNi
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Gain for clock low
-Description:       Gain value of associated DAC channel.
-
-Parameter Name:    DETi CLDCi CLKHIGNi
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Gain for clock high
-Description:       Gain value of associated DAC channel.
-
-Parameter Name:    DETi CLDCi DCGNi
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Gain for bias voltage
-Description:       Gain value of associated DAC channel.
-
-Parameter Name:    DETi CLDCi CLKLOi MARGIN
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Margin for clock low
-Description:       Telemetry check margin. A margin of 0.0 disabled the
-                   check for this channel. A negative value will apply
-                   the global value (DET CLDCi MARGIN).
-
-Parameter Name:    DETi CLDCi CLKHIi MARGIN
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Margin for clock high
-Description:       Telemetry check margin. A margin of 0.0 disabled the
-                   check for this channel. A negative value will apply
-                   the global value (DET CLDCi MARGIN).
-
-Parameter Name:    DETi CLDCi DCi MARGIN
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Margin for bias voltage
-Description:       Telemetry check margin. A margin of 0.0 disabled the
-                   check for this channel. A negative value will apply
-                   the global value (DET CLDCi MARGIN).
-
-Parameter Name:    DETi CLDCi CLKLOERRi
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Error compensation (volt)
-Description:       Error compensation for clock low. The value is 
-                   subtracted from the setup value up to a limit
-                   as given by the DET.CLDC.CALMAX keyword.
-
-Parameter Name:    DETi CLDCi CLKHIERRi
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Error compensation (volt)
-Description:       Error compensation for clock high. The value is 
-                   subtracted from the setup value up to a limit
-                   as given by the DET.CLDC.CALMAX keyword.
-
-Parameter Name:    DETi CLDCi DCERRi
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Error compensation (volt)
-Description:       Error compensation for bias voltage. The value is 
-                   subtracted from the setup value up to a limit
-                   as given by the DET.CLDC.CALMAX keyword.
-
-Parameter Name:    DETi CLDCi DCi
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Bias voltage setup value (volt)
-Description:       Setup value for bias voltage.
-
-Parameter Name:    DETi CLDCi DCXi
-Class:             setup|config|header
-Context:           Detector
-Type:              double
-Value Format:      %x
-Unit:              
-Comment Field:     Bias voltage register value
-Description:       Register value for bias voltage. The keyword is
-                   interpreted as hexadecimal value.
-
-Parameter Name:    DETi CLDCi CLKLOTi
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Telemetry value (volt)
-Description:       Telemetry value for clock low.
-
-Parameter Name:    DETi CLDCi CLKHITi
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Telemetry value (volt)
-Description:       Telemetry value for clock high.
-
-Parameter Name:    DETi CLDCi DCTi
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Telemetry value (volt)
-Description:       Telemetry value for bias voltage.
-
-Parameter Name:    DETi CLDCi CLKLORAi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              V
-Comment Field:     Clock voltage range
-Description:       Range for setup values of clock low.
-
-Parameter Name:    DETi CLDCi CLKHIRAi
-Class:             config
-Context:           Detector
-Type:              double
-Value Format:      %s
-Unit:              V
-Comment Field:     Clock voltage range
-Description:       Range for setup values of clock high.
-
-Parameter Name:    DETi CLDCi DCRAi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              V
-Comment Field:     Bias voltage range
-Description:       Range for setup values of bias voltage.
-
-Parameter Name:    DETi CLDC CLKLODACi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Dac channel
-Description:       Dac channel number of clock low (optional).
-
-Parameter Name:    DETi CLDC CLKHIDACi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Dac channel
-Description:       Dac channel number of clock high (optional).
-
-Parameter Name:    DETi CLDC DCDACi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Dac channel
-Description:       Dac channel number of bias voltage (optional).
-
-Parameter Name:    DETi CLDC CLKLOTELi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Telemetry channel
-Description:       Telemetry channel number of clock low (optional).
-
-Parameter Name:    DETi CLDC CLKHITELi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Telemetry channel
-Description:       Telemetry channel number of clock high (optional).
-
-Parameter Name:    DETi CLDC DCTELi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Telemetry channel
-Description:       Telemetry channel number of bias voltage (optional).
-
-Parameter Name:    DETi CLDCi TELGN
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Telemtry gain
-Description:       Global gain factor for bias- and clock-voltage telemetry.
-                   This sets both TELDCGAIN and TELCLKGN to the same value.
-
-Parameter Name:    DETi CLDCi TELDCGN
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Telemetry gain (biases)
-Description:       Global gain factor for bias-voltage telemetry (default 
-                   value is 1.0).
-
-Parameter Name:    DETi CLDCi TELCLKGN
-Class:             config|setup
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              
-Comment Field:     Telemetry gain (clocks)
-Description:       Global gain factor for clock-voltage telemetry (default 
-                   value is 1.0).
-
-Parameter Name:    DETi CLDCi AUTOENA
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Enable CLDC at ONLINE
-Description:       The keyword indicates for DCS if it should enable the
-                   CLDC DAC output automatically when the ONLINE command
-                   is issued. If this flag is set to F (false), the user
-                   must himself enable the DAC output manually after
-                   DCS has entered the On-Line/Idle State. The default
-                   value is F (false).
-
-Parameter Name:    DETi CLDCi AUTOCTRL
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     CLDC-output auto-ctrl
-Description:       The keyword indicates for DCS that it should disable
-                   the CLDC DAC output during voltage setup and re-enable it
-                   afterwards. The default value is T (true).
-
-Parameter Name:    DETi CLDCi AUTOCAL
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Calibrate CLDC at ONLINE
-Description:       The keyword indicates for DCS if it should calibrate the
-                   CLDC DAC output automatically when the ONLINE command
-                   is issued. The default value is F (false).
-
-Parameter Name:    DETi CLDCi MONi
-Class:             setup|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Analog monitor clock
-Description:       This parameter selects the analog clock to be monitored
-                   on clock-monitor 1 or 2.
-
-
-#
-# ADC subsystem
-#
-
-Parameter Name:    DETi ADCi DEVIDX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Device index
-Description:       Index of the physical device used by this ADC
-                   module instance.
-
-Parameter Name:    DETi ADCi ROUTE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Route to module
-Description:       Link route leading to this ADC module instance.
-
-Parameter Name:    DETi ADCi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional module name
-Description:       Optional name for this ADC module.
-
-Parameter Name:    DETi ADCi GROUP
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional group name
-Description:       Optional group assignment for this ADC module.
-
-Parameter Name:    DETi ADCi NUM
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of ADCs on board
-Description:       This parameter specifies the number of ADCs on an 
-                   ADC module.
-
-Parameter Name:    DETi ADCi BITPIX 
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of bits per pixel
-Description:       This parameter specifies the number of bits per pixel
-                   for the ADC (e.g. 16 or 18). 
-
-Parameter Name:    DETi ADCi ENABLE 
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of enabled ADCs on board
-Description:       This parameter specifies the number of ADCs on an 
-                   ADC module that should be enabled when going to 
-		   ONLINE/Idle state.
-
-Parameter Name:    DETi ADCi FILTER
-Class:             config|setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Filter (0 = 0.5us, 1 = 5us)
-Description:       This parameter selects a filter on the board: 
-                   0 = 0.5us, 1 = 5us
-
-Parameter Name:    DETi ADCi CLAMP
-Class:             config|setup|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Clamp-and-Sample
-Description:       Select clamp-and-sample instead of filter.
-
-Parameter Name:    DETi ADCi FIRST
-Class:             config|setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     First in chain
-Description:       The keyword marks this ADC module to be the first 
-                   in chain.
-
-Parameter Name:    DETi ADCi PKTCNT 
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Packet routing length
-Description:       The keyword specifies the number of packets to
-                   be received from the down-link(s) before the own 
-                   data is transferred.
-
-Parameter Name:    DETi ADCi PKTSIZE
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Packet size
-Description:       The keyword specifies the data packet size in 
-                   words (32-bit).
-
-Parameter Name:    DETi ADCi CONVERTi
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Convert on strobe
-Description:       This keywords enables/disables the conversion on the
-                   given convert strobe. Convert strobe index is either
-                   1 or 2.
-
-Parameter Name:    DETi ADCi DELAY
-Class:             setup|config|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Conv.-strobe delay (ticks)
-Description:       Conversion strobe delay on ADC-module (in ticks).
-
-Parameter Name:    DETi ADCi OFFSET
-Class:             config|setup|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Offset value for ADC (volt)
-Description:       Offset value for ADC.
-
-Parameter Name:    DETi ADCi BWi
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Bandwith value for ADC.
-Description:       Bandwith value for ADC.
-
-Parameter Name:    DETi ADCi SIMMODE
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     ADC simulation mode
-Description:       Simulation mode (0 = numbers, 1 = counter).
-
-Parameter Name:    DETi ADCi OPMODE
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     ADC operational mode
-Description:       Operational mode (0 = normal, 1 = simulation).
-
-Parameter Name:    DETi ADCi MONi
-Class:             setup|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     ADC channel to monitor
-Description:       This parameter selects the video channel to be monitored
-                   on video monitor 1 or 2.
-
-Parameter Name:    DETi ADCi HWSTAT
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     ADC status register
-Description:       Content of the ADC-module status register (read-only).
-
-Parameter Name:    DETi ADCi SWSTAT
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     ADC soft status
-Description:       Software mirror of the ADC-module control register.
-
-#
-# ACQuisition process subsystem
-#
-
-Parameter Name:    DETi ACQi DEVi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     DMA device name
-Description:       DMA device name.
-
-Parameter Name:    DETi ACQi HOST
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Acq.-process host
-Description:       Hostname where the acquisition process is launched.
-
-Parameter Name:    DETi ACQi CMDPORT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Acq.-process command port
-Description:       Command port number of the acquisition process.
-
-Parameter Name:    DETi ACQi DATAPORT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Acq.-process data port
-Description:       Data port number of the acquisition process.
-
-Parameter Name:    DETi ACQi NCLIENT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of clients
-Description:       Maximum number of data server clients. The keyword
-                   is needed in order to limit the allocated resources.
-                   The typical value is 2.
-
-Parameter Name:    DETi ACQi SEQIDX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     SEQ index
-Description:       Index of the sequencer module which is associated
-                   the this acquisition module. The default is 1 (first
-                   sequencer.
-
-Parameter Name:    DETi ACQi BURST NUM
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of bursts
-Description:       When this parameter is set to a value > 0, then the burst
-                   mode is enabled and the specified number of data bursts
-                   are taken and stored in raw format, whenever a new expsoure 
-                   is started. A zero value disables the burst mode and the
-                   original acquisition task is restored. A value < 0 enables
-                   a lower level DMA-burst (i.e. the DMA-size increases by
-                   a factor given by this parameter and queued signals are
-                   issued instead to the acquisition task). This may help
-                   to overcome the 1 ms frame rate limitation but may slow
-                   down overall computing performance.
-
-Parameter Name:    DETi ACQi BURST PROC
-Class:             setup
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Burst process name
-Description:       Name of the acquisition process to be used when the burst
-                   mode is selected (default is ngcppBurst).
-
-Parameter Name:    DETi ACQi BURST SKIP
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of bursts to skip
-Description:       When burst mode is enabled (i.e. DET.ACQ.BURST.NUM > 0)
-                   then this parameters set the number of bursts to be
-                   be skipped after exposure start before data taking and
-                   storage takes effect.
-
-Parameter Name:    DETi ACQi PROC
-Class:             setup|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Process name
-Description:       Name of the current acquisition process.
-
-Parameter Name:    DETi ACQi PID
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Acq.-process id
-Description:       Process id of the acquisition process.
-
-Parameter Name:    DETi ACQi CONT
-Class:             setup|config|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Acq.-process continuous mode
-Description:       This parameter sets the acquisition process to
-                   continuous mode (i.e. the internal counters are not
-                   reset when starting a new exposure). In this case the 
-                   calling application has to take care, that the field
-                   of view did not change since the last integration.
-
-Parameter Name:    DETi ACQi CONNECT
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Enable data connection
-Description:       This parameter enables the data connection
-                   to the acquisition process. By default the data
-                   connection is always enabled. When disabled no
-                   transfer, no guiding and no exposure can be done.
-
-Parameter Name:    DETi ACQi EXP
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Enable exposure
-Description:       This parameter enables the exposures on the
-                   acquisition module. By default the exposures are
-                   always enabled. When disabled no exposure data
-                   will be received from the acquisition process.
-
-Parameter Name:    DETi ACQi MAXOVHD
-Class:             private
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              s
-Comment Field:     Maximum Transfer Overhead
-Description:       Maximum value of the measured data transfer overhead 
-                   (in seconds).
-
-Parameter Name:    DETi ACQi MEANOVHD
-Class:             private
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              s
-Comment Field:     Mean Transfer Overhead
-Description:       Mean value of the measured data transfer overhead
-                   (in seconds).
-
-Parameter Name:    DETi ACQi TRANSFER
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Acq.-process sustained transfer
-Description:       This parameter enables/disables a sustained data transfer
-                   from the acquisition process to the IWS. It is intended to
-                   do continuous post-processing of some acquisition process
-                   data within the processing call-back (i.e. data are 
-                   transferred always and not only when an exposure is 
-                   started). Mainly used for (slow) control loops.
-
-Parameter Name:    DETi ACQi GUIDING
-Class:             setup|config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Acq.-process guiding mode
-Description:       This parameter enables the guiding mode on the given
-                   acquisition process. When enabled the offset correction 
-                   vector for secondary auto-guiding is transferred from 
-                   the acquisition process to the database.
-
-Parameter Name:    DETi ACQi WIN STRX
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Acq.-window start-x
-Description:       Defines the lower left corner corner x-coordinate of
-                   acquisition processing window within detector coordinate
-                   system. It does not necessarily need to be identical 
-                   with the read-out window, but the read-out window will 
-                   always be used as default.
-
-Parameter Name:    DETi ACQi WIN STRY
-Class:             setup|header 
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Acq.-window start-y
-Description:       Defines the lower left corner corner y-coordinate of
-                   acquisition processing window within detector coordinate
-                   system. It does not necessarily need to be identical 
-                   with the read-out window, but the read-out window will 
-                   always be used as default.
-
-Parameter Name:    DETi ACQi WIN NX
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Acq.-window NX
-Description:       Defines the number of pixels in x-direction of the
-                   acquisition processing window. This will be the overall
-                   x dimension of the produced data. This does not
-                   necessarily need to be identical with the read-out window,
-                   but the read-out window will always be used as default.
-                   A zero value indicates full-frame.
-
-Parameter Name:    DETi ACQi WIN NY
-Class:             setup|header 
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Acq.-window NY
-Description:       Defines the number of pixels in y-direction of the
-                   acquisition processing window. This does not
-                   necessarily need to be identical with the read-out window,
-                   but the read-out window will always be used as default.
-                   A zero value indicates full-frame.
-
-Parameter Name:    DETi ACQi SPLITX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of chips in X
-Description:       This parameter specifies how many chips are mapped 
-                   into the NGC raw image in X-direction. The raw image
-                   will be splitted into DETi.ACQi.SPLITX * DETi.ACQi.SPLITY 
-                   image extensions. Must be specified in the Detector 
-                   Configuration File.
-
-
-Parameter Name:    DETi ACQi SPLITY
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of chips in Y
-Description:       This parameter specifies how many chips are mapped 
-                   into the NGC raw image in Y-direction. The raw image
-                   will be splitted into DETi.ACQi.SPLITX * DETi.ACQi.SPLITY 
-                   image extensions. Must be specified in the Detector 
-                   Configuration File.
-#
-# WIPE subsystem
-#
-
-Parameter Name:    DETi WIPE AVAIL
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Wipe sequences Available
-Description:       CCD only.
-                   The keyword is used to retrieve a list of the various
-                   wipe sequences available from the current detector
-                   setup. The format of the returned list is:
-                   <WIPE SEQUENCES>:<wipe sequence name>|...
-
-Parameter Name:    DETi WIPEi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Wipe sequence name
-Description:       CCD only.
-                   Name of the wipe sequence
-
-Parameter Name:    DETi WIPEi DESC
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Wipe sequence description
-Description:       CCD only.
-                   Description of the wipe sequence
-
-Parameter Name:    DETi WIPEi DSUP
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Parameter setup filename
-Description:       CCD only.
-                   This parameter specifies the name of the default
-                   parameter setup file for the wipe sequence defined by
-                   the wipe sequence index.
-
-Parameter Name:    DETi WIPEi SEQi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Sequencer program name
-Description:       CCD only.
-                   This parameter specifies the name of the sequencer
-                   program(s) for the wipe sequence defined by the wipe
-		   sequence index.
-
-Parameter Name:    DETi WIPE DEFAULT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Default wipe sequence
-Description:       CCD only.
-                   This parameter specifies the id of the default (if
-                   any) wipe sequence for the detector.
-
-
-
-#
-# PREINTG subsystem
-#
-
-Parameter Name:    DETi PREINTG AVAIL
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Preintegration sequences available
-Description:       CCD only.
-                   The keyword is used to retrieve a list of the various
-                   preintegration sequences available from the current
-                   detector setup.
-                   The format of the returned list is:
-                   <PREINTG SEQUENCES>:<preintegration name>|...
-
-Parameter Name:    DETi PREINTGi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Preintegration name
-Description:       CCD only.
-                   Name of the preintegration sequence
-
-Parameter Name:    DETi PREINTGi DESC
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Preintegration description
-Description:       CCD only.
-                   Description of the preintegration sequence
-
-Parameter Name:    DETi PREINTGi DSUP
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Parameter setup filename
-Description:       CCD only.
-                   This parameter specifies the name of the default
-                   parameter setup file for the preintegration sequence
-                   defined by the preintegration sequence index.
-
-Parameter Name:    DETi PREINTGi SEQi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Sequencer program name
-Description:       CCD only.
-                   This parameter specifies the name of the sequencer
-                   program(s) for the preintegration sequence defined by
-                   the preintegration sequence index.
-
-Parameter Name:    DETi PREINTG DEFAULT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Default preintegration sequence
-Description:       CCD only.
-                   This parameter specifies the id of the default (if
-                   any) preintegration sequence for the detector.
-
-#
-# DURINTG subsystem
-#
-
-Parameter Name:    DETi DURINTG AVAIL
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Preintegration sequences available
-Description:       CCD only.
-                   The keyword is used to retrieve a list of the various
-                   preintegration sequences available from the current
-                   detector setup.
-                   The format of the returned list is:
-                   <DURINTG SEQUENCES>:<during integration name>|...
-
-Parameter Name:    DETi DURINTG SHIFT
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Format:    Lines shifted during integration
-Description:       CCD only.
-                   Meaningful only for exposures where the charges are
-                   moved on the detector while integrating (e.g.,
-                   CCD HIT sequences).
-		   The direction is indicated by the sign: 
-		   negative is up, positive is down,
-		   where down means towards the readout port.
-
-Parameter Name:    DETi DURINTG NREP
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Format:    Number of line shift operations
-Description:       CCD only.
-                   It defines how many times the charges on the detector
-                   must be shifted by the amount of lines specified
-                   by SHIFT.
-                   NREP=1 is for OS-HIT or drift-scanning: the charges
-                          are moved as specified by SHIFT1 and then
-                          readout
-                   NREP>1 is for PS-HIT: the charges are moved back and
-                          forth by the specified number of times
-                          - starting with the direction specified by
-                          SHIFT1 - and then readout
-
-Parameter Name:    DETi DURINTG DELSTRT
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Format:    ns delay before starting line shift operations
-Description:       CCD only.
-                   Interval time (in ns) before starting the line
-                   shift operations.
-
-Parameter Name:    DETi DURINTG DELPOS
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Format:    ns delay after a positive line shift operation
-Description:       CCD only. HIT sequences only.
-                   Quiet time (in ns) at the end of a positive line
-                   shift operation (i.e., towards the readout port).
-
-Parameter Name:    DETi DURINTG DELNEG
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Format:    ns delay after a negative line shift operation
-Description:       CCD only. HIT sequences only.
-                   Quiet time (in ns) at the end of a negative line
-                   shift operation (i.e., from the readout port).
-
-Parameter Name:    DETi DURINTG TIMEFAC
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     dwell time for during integration sequence execution
-Description:       CCD only.
-                   Dwell time for during integration sequence execution.
-
-Parameter Name:    DETi DURINTGi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     during integration name
-Description:       CCD only.
-                   Name of the during integration sequence
-
-Parameter Name:    DETi DURINTGi DESC
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     during integration description
-Description:       CCD only.
-                   Description of the during integration sequence
-
-Parameter Name:    DETi DURINTGi DSUP
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Parameter setup filename
-Description:       CCD only.
-                   This parameter specifies the name of the default
-                   parameter setup file for the during integration
-                   sequence defined by the during integration
-                   sequence index.
-
-Parameter Name:    DETi DURINTGi SEQi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Sequencer program name
-Description:       CCD only.
-                   This parameter specifies the name of the sequencer
-                   program(s) for the during integration sequence
-                   defined by the during integration sequence index.
-
-Parameter Name:    DETi DURINTG DEFAULT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Default during integration sequence
-Description:       CCD only.
-                   This parameter specifies the id of the default (if
-                   any) during integration sequence for the detector.
-
-#
-# READ subsystem
-#
-
-Parameter Name:    DETi READ CURID
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Used readout mode id
-Description:       IR only.
-                   Id of the readout mode to be used for current
-                   exposure. The readout modes supported for one
-                   detectored are defined in the detector configuration
-                   file. A unique number is allocated for each
-                   readout mode.
-
-Parameter Name:    DETi READ CURNAME
-Class:             setup|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Used readout mode name
-Description:       IR only.
-                   Name of the readout mode to be used for current
-                   exposure
-
-Parameter Name:    DETi READ DESC
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Used readout mode description
-Description:       IR only.
-                   Description of the readout mode to be used for
-                   current exposure
-
-Parameter Name:    DETi READ AVAIL
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Readout Modes Available
-Description:       The keyword is used to retrieve a list of the various
-                   readout modes available fro the current detector
-                   setup. The format of the returned list is:
-                   <READOUT MODES>:<readout mode name>|...
-
-Parameter Name:    DETi READ FRAMES
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Frames Available
-Description:       IR only.
-                   Used to query the list of Frames currently
-                   available for the readout Mode in use. The format
-                   of the returned list is:
-                   <frame name>: <gen (0|1)> <store (0|1)>
-                                 <break counter> |...
-
-Parameter Name:    DETi READ NFRAM
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Format:    Number of readouts buffered in single read
-Description:       CCD only.
-                   Used for very fast frame rate applications, allows
-                   a number of individual CCD readouts to be stored
-                   as a single "frame".
-
-Parameter Name:    DETi READ SHIFTi
-Class:             setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Format:    Lines shifted between integration
-Description:       Meaningful only for exposures consisting of several
-                   integrations. In some cases (e.g. for focus exposures
-                   or for 'alternate' readout method) one wants charges
-                   to be automatically shifted at the end of each
-                   integration. The direction is indicated by the sign:
-           negative is up, positive is down
-           where down means towards the readout port.
-
-Parameter Name:    DETi READ SHIFTYP
-Class:             setup|header
-Context:           Detector
-Type:              string
-Value Format:      %16s
-Unit:
-Comment Format:    Line shift type
-Description:       The line shift may be defined for all sub-integration:
-                     'alternate'   : alternate +SHIFT1,-SHIFT1
-                     'idem'        : as SHIFT1
-                     'list'        : as defined in list SHIFTi
-
-Parameter Name:    DETi READi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Readout mode name
-Description:       Name of the read out mode
-
-Parameter Name:    DETi READi DESC
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Readout mode description
-Description:       Description of the read out
-
-Parameter Name:    DETi READi DSUP
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Parameter setup filename
-Description:       This parameter specifies the name of the default
-                   parameter setup file for the readout mode defined by
-                   the readout mode index.
-
-Parameter Name:    DETi READi ACQi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Acquisition Proc. Name
-Description:       IR only.
-                   This parameter specifies the name(s) of the
-                   acquisition process(es) for the readout mode defined
-                   by the readout mode index.
-                   The ACQ-index defines the acquisition device for the
-                   process. The devices (hostname, port numbers, device
-                   name) are configured in the system Configuration
-                   File.
-
-Parameter Name:    DETi READi SEQi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Sequencer Prog. Name
-Description:       This parameter specifies the name of the sequencer
-                   program(s) for the readout mode defined by the
-                   readout mode index.
-
-Parameter Name:    DETi READ DEFAULT
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Default readout mode
-Description:       This parameter specifies the id of the default (if
-                   any) readout mode for the detector.
-
-Parameter Name:    DETi READ DUMMY
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Dummy pixels per output to be generated by sequence.
-Description:       Number of dummy pixels per output to be generated by
-                   the readout sequence. Meaningful only if DFE PaketSize 
-                   is not 2. Default value is 0.
-
-
-#
-# MODE subsystem
-#
-
-Parameter Name:    DETi MODE CURID
-Class:             config|setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Used exposure mode id
-Description:       CCD only.
-                   Id of the exposure mode to be used for
-                   current exposure. A unique Id is allocated for each
-                   exposure mode.
-
-Parameter Name:    DETi MODEi NAME
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Exposure mode name
-Description:       CCD only.
-                   Name of the exposure mode.
-
-Parameter Name:    DETi MODEi DESC
-Class:             config|header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Exposure mode description
-Description:       CCD only.
-                   Description of the exposure mode.
-
-Parameter Name:    DETi MODEi TRIGGER
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Enable trigger
-Description:       Let the sequencer go to the waiting state
-                   when the WaitForTrigger bit is set in a pattern,
-		   by sending the setup keyword DETi SEQi TRIGGER 
-		   to the sequencer.
-
-Parameter Name:    DETi MODEi GAINi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Gain used for the exposure mode
-Description:       CCD only.
-                   Description of the gain used for the exposure mode.
-
-Parameter Name:    DETi MODEi BNDWTHi
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Bandwidth used for the exposure mode
-Description:       CCD only.
-                   Description of the bandwidth used for the exposure mode.
-
-Parameter Name:    DETi MODEi SHMODE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Shutter mode
-Description:       Type of shutter operational mode, for "ngc" shutter
-                   controller only. Accepted values:
-                   "Normal", "Direct", "Sequencer1", "Sequencer2"
-
-Parameter Name:    DETi MODEi SHACTHI
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    Shutter open command is active high
-Description:       Open command for shutter is active high.
-
-Parameter Name:    DETi MODEi SHDEL
-Class:             config
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              ms
-Comment Format:    Millisecond delay between shutter close and readout
-Description:       Define the delay (in ms) between shutter close and
-                   readout start. If not defined, readout is started
-                   immediately after shutter has been closed.
-
-Parameter Name:    DETi MODEi WREP
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Wipe sequence repetition number.
-Description:       CCD only.
-                   Number of times the sequence must be repeated in MODEi.
-                   0 means no sequence execution at all.
-
-Parameter Name:    DETi MODEi WCLDFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi CLDCi FILE for wipe.
-Description:       CCD only.
-                   Voltage configuration file name for CLDC-module
-                   used for wiping in MODEi.
-
-Parameter Name:    DETi MODEi WCLKFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi CLKFILE for wipe.
-Description:       CCD only.
-                   Clock-pattern configuration file
-                   used for wiping in MODEi.
-
-Parameter Name:    DETi MODEi WPRGFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi PRGFILE for wipe.
-Description:       CCD only.
-                   Sequencer program file used for wiping in MODEi.
-
-Parameter Name:    DETi MODEi XREP
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Second wipe sequence repetition number.
-Description:       CCD only.
-                   Number of times the sequence must be repeated in MODEi.
-                   0 means no sequence execution at all.
-
-Parameter Name:    DETi MODEi XCLDFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi CLDCi FILE for second wipe.
-Description:       CCD only.
-                   Voltage configuration file name for CLDC-module
-                   used for second wiping in MODEi.
-
-Parameter Name:    DETi MODEi XCLKFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi CLKFILE for second wipe.
-Description:       CCD only.
-                   Clock-pattern configuration file
-                   used for second wiping in MODEi.
-
-Parameter Name:    DETi MODEi XPRGFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi PRGFILE for second wipe.
-Description:       CCD only.
-                   Sequencer program file used for second wiping in MODEi.
-
-Parameter Name:    DETi MODEi PREP
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Preintegration sequence repetition number.
-Description:       CCD only.
-                   Number of times the sequence must be repeated in MODEi.
-                   0 means no sequence execution at all.
-
-Parameter Name:    DETi MODEi PCLDFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi CLDCi FILE for preintegration.
-Description:       CCD only.
-                   Voltage configuration file name for CLDC-module
-                   used for preintegration in MODEi.
-
-Parameter Name:    DETi MODEi PCLKFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi CLKFILE for preintegration.
-Description:       CCD only.
-                   Clock-pattern configuration file
-                   used for preintegration in MODEi.
-
-Parameter Name:    DETi MODEi PPRGFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi PRGFILE for preintegration.
-Description:       CCD only.
-                   Sequencer program file used for preintegration in MODEi.
-
-Parameter Name:    DETi MODEi DREP
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     During integration sequence repetition number.
-Description:       CCD only.
-                   Number of times the sequence must be repeated in MODEi.
-                   0 means no sequence execution at all.
-
-Parameter Name:    DETi MODEi DCLDFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Index of DETi CLDCi FILE to be used during integration.
-Description:       CCD only.
-                   Voltage configuration file name for CLDC-module
-                   used for during integration in MODEi.
-
-Parameter Name:    DETi MODEi DCLKFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi CLKFILE to be used during integration.
-Description:       CCD only.
-                   Clock-pattern configuration file
-                   used for during integration in MODEi.
-
-Parameter Name:    DETi MODEi DPRGFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi PRGFILE to be used during integration.
-Description:       CCD only.
-                   Sequencer program file 
-                   used for during integration in MODEi.
-
-Parameter Name:    DETi MODEi MCLDFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Index of DETi CLDCi FILE to be used for MultiStep exposure.
-Description:       CCD only.
-                   Voltage configuration file name for CLDC-module
-                   used for during integration in MODEi.
-
-Parameter Name:    DETi MODEi MCLKFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi CLKFILE to be used for MultiStep exposure.
-Description:       CCD only.
-                   Clock-pattern configuration file
-                   used for during integration in MODEi.
-
-Parameter Name:    DETi MODEi MPRGFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi PRGFILE to be used for MultiStep exposure.
-Description:       CCD only.
-                   Sequencer program file 
-                   used for during integration in MODEi.
-
-Parameter Name:    DETi MODEi RREP
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Field:     Readout sequence repetition number.
-Description:       CCD only.
-                   Number of times the sequence must be repeated in MODEi.
-                   0 means no sequence execution at all.
-
-Parameter Name:    DETi MODEi RCLDFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi CLDCi FILE for readout.
-Description:       CCD only.
-                   Voltage configuration file name for CLDC-module
-                   used for readout in MODEi.
-
-Parameter Name:    DETi MODEi RCLKFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi CLKFILE for readout.
-Description:       CCD only.
-                   Clock-pattern configuration file
-                   used for readout in MODEi.
-
-Parameter Name:    DETi MODEi RPRGFILi
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Name of DETi SEQi PRGFILE for readout.
-Description:       CCD only.
-                   Sequencer program file used for readout in MODEi.
-
-Parameter Name:    DETi MODEi RTYPE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Readout type.
-Description:       CCD only.
-                   Readout type: "Standard", "FastACS" or "SlowMosaic".
-
-Parameter Name:    DETi MODEi BINXRNG
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     X-Binning range.
-Description:       CCD only.
-                   String containing accepted values for binning.
-		   Values can be separated by ":" or ";".
-		   Values ranges are defined by "-".
-		   Example: "1,3;6-10,12".
-		   If no BINXRNG is defined for a mode, all binning
-		   values are accepted. 
-
-Parameter Name:    DETi MODEi BINYRNG
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:
-Comment Field:     Y-Binning range.
-Description:       CCD only.
-                   String containing accepted values for binning.
-		   Values can be separated by ":" or ";".
-		   Values ranges are defined by "-".
-		   Example: "1,3;6-10,12".
-		   If no BINYRNG is defined for a mode, all binning
-		   values are accepted. 
-
-Parameter Name:    DETi MODEi WINSUP
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:
-Comment Field:     Readout mode supports windowing.
-Description:       CCD only.
-                   Flag to define if the readout mode supports or
-                   not windowing.
-                   Default value is "F", i.e., windowing is not supported
-                   for a mode, unless WINSUP is defined as "T".
-
-Parameter Name:    DETi MODEi OUTPUTS
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Number of outputs used for readout.
-Description:       Number of outputs used for readout in MODEi.
-
-Parameter Name:    DETi MODEi ADCMOD
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Number of ADC modules used for readout.
-Description:       String of indexes of ADC modules used for readout in
-                   MODEi on ADCi module.
-                   Indexes are integers (1,2,...) separated by a comma.
-
-Parameter Name:    DETi MODEi ADCi ADCS
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    ADCs used for readout.
-Description:       String of indexes of ADCs channels used for readout in
-                   MODEi on ADCi module.
-                   Indexes are integers (1,2,3,4,...) separated by a comma.
-		   The number of channels used on all ADCi modules
-		   must be equal to DETi MODEi OUTPUTS.
-
-Parameter Name:    DETi MODEi OUTi CHIP
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Index of chip the output belongs to
-Description:       Index of chip the output belongs to.
-
-Parameter Name:    DETi MODEi OUTi INDEX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output index on the chip
-Description:       Output index on the chip the output belongs to.
-
-Parameter Name:    DETi MODEi OUTi XIMA
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Pixel block horizontal coordinate
-Description:       Horizontal coordinate in the (mosaic) detector
-                   reference frame of the location of the pixel block
-                   produced by the output. Positive integer index of 
-                   the output with respect to the horizontal position 
-                   in the image space. It is used to reconstruct the image.
-
-Parameter Name:    DETi MODEi OUTi YIMA
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Pixel block vertical coordinate
-Description:       Vertical coordinate in the (mosaic) detector
-                   reference frame of the location of the pixel block
-                   produced by the output. Positive integer index of the 
-                   output with respect to the vertical position in the 
-                   image space. It is used to reconstruct the image.
-
-Parameter Name:    DETi MODEi OUTi NX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Image pixels in X
-Description:       Number of image data pixels in X.
-                   Its value goes in the header, as DETi CHIPi OUTi NX
-
-Parameter Name:    DETi MODEi OUTi NY
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Image pixels in Y
-Description:       Number of image data pixels in Y.
-                   Its value goes in the header, as DETi CHIPi OUTi NY
-
-Parameter Name:    DETi MODEi OUTi PRSCX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output prescan region in X
-Description:       Number of pixels in X read before real data arrives.
-                   Its value goes in the header, as DETi CHIPi OUTi PRSCX
-
-Parameter Name:    DETi MODEi OUTi PRSCY
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output prescan region in Y
-Description:       Number of pixels in Y read before real data arrives.
-                   Its value goes in the header, as DETi CHIPi OUTi PRSCY
-
-Parameter Name:    DETi MODEi OUTi OVSCX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output overscan region in X
-Description:       Number of pixels in X read as overscan.
-                   Its value goes in the header, as DETi CHIPi OUTi OVSCX
-
-Parameter Name:    DETi MODEi OUTi OVSCY
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output overscan region in Y
-Description:       Number of pixels in Y read as overscan.
-                   Its value goes in the header, as DETi CHIPi OUTi OVSCY
-
-Parameter Name:    DETi MODEi OUTi GAIN
-Class:             config
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              ADU/e-
-Comment Format:    Conversion from electrons to ADU
-Description:       The gain to which the amplifier output has been set.
-                   Its value goes in the header, as DETi CHIPi OUTi GAIN
-
-Parameter Name:    DETi MODEi OUTi CONAD
-Class:             config
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              e-/ADU
-Comment Format:    Conversion from ADUs to electrons
-Description:       The conversion factor which translates ADU
-		   to photonic electrons.
-                   Its value goes in the header, as DETi CHIPi OUTi ADU
-
-Parameter Name:    DETi MODEi OUTi RON
-Class:             config
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              e-
-Comment Format:    Readout noise per output (e-)
-Description:       Readout noise per output (e-)
-                   Its value goes in the header, as DETi CHIPi OUTi RON
-
-Parameter Name:    DETi MODEi ADCSAMPL
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    ADC data sampling factors
-Description:       Array of multiplicative factors (float) to be applied to
-                   the data samples from the different ADCs. 
-                   Multiplicative factors are signed float numbers separated 
-                   by a comma (e.g.:-1.5,0,0,0,1.5,0,0,0)
-
-Parameter Name:    DETi MODEi OFFSET
-Class:             config
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Offset value for ADC
-Description:       ADC offset value to be used for the readout, i.e.,
-                   DETi ADCi OFFSET value to be set for the readout
-
-Parameter Name:    DETi MODEi CHAN
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Video channels used for readout
-Description:       List of channels used for readout. Channel identifiers
-                   are positive integer numbers separated by a comma 
-                   (e.g.: 1,2,3,4)
-
-
-
-#
-# Infra Red subsystem
-#
-Parameter Name:    DETi DETCFG
-Class:             setup|config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Detector configuration
-Description:       Name of the detector configuration file.
-
-Parameter Name:    DETi DITDELAY
-Class:             header|setup
-Context:           Detector
-Type:              double
-Value Format:      %.7f
-Unit:              s
-Comment Field:     Delay before integration
-Description:       Sets a delay (in seconds) before the integration starts. 
-
-Parameter Name:    DETi NDIT
-Class:             header|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     # of Sub-Integrations
-Description:       Number of times to perform an integration for each INT.
-
-
-Parameter Name:    DETi NDITSKIP
-Class:             header|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     DITs skipped at 1st.INT
-Description:       Indicates how many DITs should be skipped when starting
-                   on a new integration.
-
-Parameter Name:    DETi NDSAMPLES
-Class:             header|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     # of Non-Dest. Samples
-Description:       Number of Non-Destructive Samples per DIT.
-                   Only relevant whe using Non-Destructive Sampling.
-
-
-Parameter Name:    DETi NDSKIP
-Class:             header|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Samples skipped per DIT
-Description:       Indicates how many ND Read-Outs to skip for every DIT.
-
-Parameter Name:    DETi NSAMPPIX 
-Class:             header|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Number of samples on each pixel
-Description:       Indicates the number of samples for each pixel.
-
-#
-# Detector FRAMe information
-#
-
-Parameter Name:    DETi FRAM ID
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Image sequencial number
-Description:       Sequencial number identifying the frame
-
-Parameter Name:    DETi FRAM STRX
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Frame window start-x
-Description:       Defines the lower left corner corner x-coordinate of
-                   this data frame within detector coordinate system. 
-
-Parameter Name:    DETi FRAM STRY
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:               
-Comment Field:     Frame window start-y
-Description:       Defines the lower left corner corner y-coordinate of
-                   this data frame within detector coordinate system. 
-
-Parameter Name:    DETi FRAM XFERSYN
-Class:             setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    If T, image transfer occurs synchronously
-Description:       If T, the system waits for the image transfer to WS
-                   to be completed before running the next exposure in a
-                   loop, otherwise it starts the next exposure as soon the
-                   readout and image processing are ready.
-                   The value of this keyword has no influence on single
-                   exposures and the last exposure in a loop: for them
-                   the transfer is always synchronous.
-                   It is recommended to set this keyword always to T,
-                   except special applications requiring high performances
-                   at LCU level and using the image transfer just for
-                   real-time display of the image (e.g. field stabilisation 
-                   fast loop)
-
-Parameter Name:    DETi FRAM SAMPLE
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Image sampling on workstation
-Description:       The value N indicates:
-                   - when positive that one image out of N
-                   has to be transferred to workstation; 
-		   - when negative the time in milliseconds between 2 transfers
-		   to workstation;
-		   Used mainly for high speed loops (e.g. autoguiding cameras).
-		   Default is 1.
-
-Parameter Name:    DETi FRAM FILENAME
-Class:             setup|ops-log
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    File name for exposure data
-Description:       base name for FITS-file to be used at next exposure. It may
-                   already exist, created by OS.
-
-Parameter Name:    DETi FRAM NAMING
-Class:             setup
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     File Naming Scheme
-Description:       The default naming scheme to be used with DCS. The value
-                   must be either "Request" or  "Sequence" or "Auto". When
-                   using Request-naming a name must be given in before each
-		   exposure. For Sequence-naming a basename is given and an
-		   index is subsequently added. It is possible to specify a
-		   start value for the index.  Auto-naming will determine the
-		   sequence index by parsing the content of the data target
-		   directory.
-
-Parameter Name:    DETi FRAM MULTFILE
-Class:             setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Store multiple files
-Description:       By default this keyword is set to F and extensions are
-                   stored in one single file. However, for performance
-		   reasons, it may desirable to have more than one file
-                   (e.g. one per acquisition process).
-		   
-Parameter Name:    DETi FRAM FORMAT
-Class:             setup
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     FITS file format
-Description:       In special cases like "burst mode" it is desirable to have
-                   data stored in cubes than in normal 2D frames. By default
-		   the value is "extension".
-
-Parameter Name:    DETi FRAM NUMBLOCK
-Class:             setup|config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Number of header blocks
-Description:       The keyword specifies the number of FITS-header blocks
-                   to be reserved for the keywords.
-
-Parameter Name:    DETi FRAM TYPE
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Frame type
-Description:       The keyword specifies the name of the data frame
-                   type.
-
-Parameter Name:    DETi FRAM NO
-Class:             header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Frame number
-Description:       The keyword specifies the number of a data frame
-                   of a given tpye during an exposure.
-
-Parameter Name:    DETi FRAM UTC
-Class:             header
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     Time when DCS has saved image to disk.
-Description:       Time when DCS has saved image to disk and therefore the 
-                   exposure is "completed".
-
-Parameter Name:    DETi FRAMi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Frame declaration
-Description:       Declare a new frame type by its NAME to be controlled
-                   via setup commands. To be specified in the system
-                   configuration file.
-
-Parameter Name:    DETi FRAMi ACQ
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Acq.-process list for declared type
-Description:       Defines the acquisition process list where the set
-                   of frame control keywords refers to. A "0" in the
-                   the list indicates that the frame control keywords
-                   refer to all acquisition processes (that is the
-                   default if the keyword is not specified in the
-                   system configuration file).
-
-Parameter Name:    DETi FRAMi PARAM
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Parameter base name 
-Description:       Defines an optional base name for the frame control
-                   setup parameters. Normally the frame control is done
-                   via the DETi.FRAMi.GEN/STORE/BREAK/STRX/STRY/NX/NY
-                   commands. Declaring a new base name will allow to
-                   extend the numbered assignment with a named assignment
-                   like <DETi.FRAMi.PARAM>.GEN/STORE/BREAK etc.
-
-Parameter Name:    DETi FRAMi GEN
-Class:             setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Generate frame type
-Description:       Generate a certain frame type. The referred frame 
-                   is given in DETi.FRAMi.NAME.
-
-Parameter Name:    DETi FRAMi STORE
-Class:             setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Store frame type
-Description:       Store a certain frame type to disk during exposure. 
-                   The referred frame is given in DETi.FRAMi.NAME.
-
-Parameter Name:    DETi FRAMi BREAK
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Frame break counter
-Description:       Exposure break counter for a certain frame type. The 
-                   referred frame is given in DETi.FRAMi.NAME.
-
-Parameter Name:    DETi FRAMi STRX
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Frame SW window
-Description:       SW window for a certain frame type (lower left corner).
-                   The referred frame is given in DETi.FRAMi.NAME.
-
-Parameter Name:    DETi FRAMi STRY
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Frame SW window
-Description:       SW window for a certain frame type (lower left corner).
-                   The referred frame is given in DETi.FRAMi.NAME.
-
-Parameter Name:    DETi FRAMi NX
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Frame SW window
-Description:       SW window for a certain frame type (x-dimension).
-                   The referred frame is given in DETi.FRAMi.NAME.
-
-Parameter Name:    DETi FRAMi NY
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Frame SW window
-Description:       SW window for a certain frame type (y-dimension).
-                   The referred frame is given in DETi.FRAMi.NAME.
-
-Parameter Name:    DETi FRAM FITSMTD
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:
-Comment Format:    Data storage method
-Description:       Possible values:
-                   0 = 'none'    (image is not saved on disk)
-                   1 = 'compressed'
-                   2 = 'uncompressed'
-                   3 = 'both'
-
-Parameter Name:    DETi FRAM MERGE
-Class:             setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Merge multiple files at the end of an exposure
-Description:       Used in systems controlling more LLCUs.
-                   If set, the image data produced by the subsystems
-		   are merged into a unique FITS file.
-
-#
-# PREAMPlifier subsystem
-#
-
-Parameter Name:    DETi PREAMPi DEVIDX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Device index
-Description:       Index of the physical device used by this preamplifier
-                   module instance.
-
-Parameter Name:    DETi PREAMPi ROUTE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Route to module
-Description:       Link route leading to this preamplifier module instance.
-
-Parameter Name:    DETi PREAMPi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional module name
-Description:       Optional name for this preamplifier module.
-
-Parameter Name:    DETi PREAMPi GROUP
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional group name
-Description:       Optional group assignment for this preamplifier module.
-
-Parameter Name:    DETi PREAMPi REV
-Class:             config|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:               
-Comment Field:     Revision
-Description:       Preamplifier revision (format = revision.subrevision)
-
-Parameter Name:    DETi PREAMPi NUMCHAN
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Number of channels
-Description:       Number of channels in use. One preamplifier module
-                   can control up to 8 channels. The default value is 4.
-
-Parameter Name:    DETi PREAMPi INVERT
-Class:             config|setup|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Invert signals
-Description:       Invert signals.
-
-Parameter Name:    DETi PREAMPi GAINi
-Class:             config|setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Gain
-Description:       Preamplifier gain (4-bit integer value).
-
-Parameter Name:    DETi PREAMPi BWi
-Class:             config|setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Bandwidth
-Description:       Preamplifier bandwidth (4-bit integer value).
-
-Parameter Name:    DETi PREAMPi SHORTi
-Class:             config|setup|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Short input
-Description:       Short input.
-
-Parameter Name:    DETi PREAMPi ATTNi
-Class:             config|setup|header
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Attenuation
-Description:       Attenuation.
-
-Parameter Name:    DETi PREAMPi VREFi
-Class:             config|setup|header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              V
-Comment Field:     Reference voltage (volt)
-Description:       Preamplifier reference voltage.
-
-Parameter Name:    DETi PREAMPi VREFCMD
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     VREF DAC command
-Description:       Preamplifier reference voltage DAC control command.
-                   This is a 4-bit integer value to setup the DAC. The
-                   control command is common to all reference voltages
-                   of one preamplifier module.
-
-Parameter Name:    DETi PREAMPi BUSCMD
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     I2C-bus command
-Description:       I2C-bus control command. This is a 16-bit integer value 
-                   to setup the I2C-bus. Ig goes directly into the upper
-                   16 bits of the I2C port address. The control command is 
-                   common to all register accesses through the I2C-bus of one
-                   preamplifier module.
-
-#
-# AO-head subsystem
-#
-
-Parameter Name:    DETi AOi DEVIDX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Device index
-Description:       Index of the physical device used by this AO-head
-                   module instance.
-
-Parameter Name:    DETi AOi ROUTE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Route to module
-Description:       Link route leading to this AO-head module instance.
-
-Parameter Name:    DETi AOi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional module name
-Description:       Optional name for this AO-head module.
-
-Parameter Name:    DETi AOi DELAYi
-Class:             config|setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Delay (ticks)
-Description:       Clock delay in ticks.
-
-Parameter Name:    DETi AOi IOLVLi
-Class:             config|setup|header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              V
-Comment Field:     IO-phase level (volt)
-Description:       Four voltage levels of IO phase.
-
-Parameter Name:    DETi AOi SOLVLi
-Class:             config|setup|header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              V
-Comment Field:     SO-phase level (volt)
-Description:       Four voltage levels of SO phase.
-
-Parameter Name:    DETi AOi GAIN
-Class:             config|setup|header
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Gain step
-Description:       Amplification gain step.
-
-Parameter Name:    DETi AOi RHUM
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              
-Comment Field:     Relative humidity (%)
-Description:       Value of the relative humidity sensor (percent).
-
-Parameter Name:    DETi AOi TEMP
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              C
-Comment Field:     Temperature
-Description:       Value of the temperature sensor (deg C).
-
-Parameter Name:    DETi AOi PRES
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.2f
-Unit:              hPa
-Comment Field:     Pressure
-Description:       Value of the pressure sensor (hectopascal).
-
-Parameter Name:    DETi AOi OVRILLUM
-Class:             private
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Overillumination
-Description:       Overillumination alert (T|F).
-
-#
-# SHUTter subsystem
-#
-
-Parameter Name:    DETi SHUTi DEVIDX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Device index
-Description:       Index of the physical device used by this shutter
-                   module instance.
-
-Parameter Name:    DETi SHUTi ROUTE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Route to module
-Description:       Link route leading to this shutter module instance.
-
-Parameter Name:    DETi SHUTi NAME
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Optional module name
-Description:       Optional name for this shutter module.
-
-Parameter Name:    DETi SHUTi EXPTIME
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %u
-Unit:              ms
-Comment Field:     Shutter exposure time
-Description:       Content of the shutter exposure time register. The Value
-                   is given in milliseconds.
-
-Parameter Name:    DETi SHUTi REGCTRL
-Class:             config|setup
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     Shutter control register
-Description:       Content of the shutter control register.
-
-Parameter Name:    DETi SHUTi REGSTAT
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %x
-Unit:              
-Comment Field:     Shutter status register
-Description:       Content of the shutter status register (read-only).
-
-Parameter Name:    DETi SHUTi EVTCNTi
-Class:             private
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Event counter register
-Description:       Content of the shutter event counter register (read-only).
-
-Parameter Name:    DETi SHUTi EVTEDGi
-Class:             private
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Field:     Event counter is rising edge.
-Description:       Event counter is rising edge. "T" means rising
-                   edge event, "F" means falling edge event.
-
-Parameter Name:    DETi SHUTi OPACTHI
-Class:             private
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    Shutter open command is active high
-Description:       Open command for shutter is active high.
-
-Parameter Name:    DETi SHUTi AVAIL
-Class:             config
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:              
-Comment Format:    Shutter available
-Description:       Some CCD systems (e.g. technical CCDs) have no shutter.
-
-Parameter Name:    DETi SHUTi CTRL
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Shutter controller
-Description:       Type of shutter controller ("ngc" or "pulpo")
-
-Parameter Name:    DETi SHUTi TYPE
-Class:             header|config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Shutter type
-Description:       Possible values TBD
-
-Parameter Name:    DETi SHUTi MODE
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Shutter operational mode
-Description:       Type of shutter operational mode, for
-                   "ngc" shutter controller only.
-                   Accepted values: "Normal", "Direct", "Sequencer1",
-                   "Sequencer2"
-
-Parameter Name:    DETi SHUTi ID
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Shutter unique identifier
-Description:       Manufacturer, model, serial number
-
-Parameter Name:    DETi SHUTi TMOPEN
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              s
-Comment Format:    Time taken to open shutter
-Description:       Time required by the shutter to open completely.
-
-Parameter Name:    DETi SHUTi TMCLOS
-Class:             header
-Context:           Detector
-Type:              double
-Value Format:      %.3f
-Unit:              s
-Comment Format:    Time taken to close shutter
-Description:       Time required by the shutter to close completely.
-
-Parameter Name:    DETi SHUTi SYNC
-Class:             config
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Format:    Shutter synchronisation mode
-Description:       Type of shutter synchronisation mode, meaningful
-                   for multi DCS systems.
-                   Accepted values: "Single" (for single DCS systems),
-                   "Master", "Slave".
-                   If this keyword is not defined, the default value
-                   is "Single".
-
-#
-# Optical subsystems
-#
-
-Parameter Name:    DETi VIS EXPTIME
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %.4f
-Unit:              s
-Comment Format:    Total integration time (sec)
-Description:	   This keyword makes sense for visual detectors only.
-                   between shutter open and shutter closed. The shutter
-                   open/closed instants are calculated as the average
-                   between the times when the action is started and
-                   finished.
-                   For systems without shutter or dark exposures, it is
-                   the time interval between the end of previous wipe
-                   (or read-out) and start of read-out (see
-                   DETi WINi DKTM).
-                   For multi-steps exposures it is the sum of the actual
-                   integration time of all steps performed (see
-                   DETi WINi DITi)
-
-Parameter Name:    DETi VIS DARKTIME
-Class:             header
-Context:           FITS
-Type:              double
-Value Format:      %.4f
-Unit:              s
-Comment Format:    Total dark time (sec)
-Description:	   This keyword makes sense for visual detectors only.
-                   For systems with shutter it is the time interval 
-                   between end of wipe and open shutter time.
-                   For systems without shutter or dark exposures,
-                   it is the time interval between the end of previous
-                   wipe (or read-out) and start of read-out (see
-                   DETi WINi DKTM).
-                   For multi-steps exposures it is the sum of the
-                   actual integration time of all steps performed
-                   (see DETi WINi DITi)
-
-Parameter Name:    DETi OPT NX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Image pixels in X
-Description:       Number of image data pixels in X.
-                   This keyword is available for usage in the detector
-                   sequences.
-
-Parameter Name:    DETi OPT NY
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Image pixels in Y
-Description:       Number of image data pixels in Y.
-                   This keyword is available for usage in the detector
-                   sequences.
-
-Parameter Name:    DETi OPT PRSCX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output prescan region in X
-Description:       Number of pixels in X read before real data arrives.
-                   This keyword is available for usage in the detector
-                   sequences.
-
-Parameter Name:    DETi OPT PRSCY
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output prescan region in Y
-Description:       Number of pixels in Y read before real data arrives.
-                   This keyword is available for usage in the detector
-                   sequences.
-
-Parameter Name:    DETi OPT OVSCX
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output overscan region in X
-Description:       Number of pixels in X read as overscan.
-                   This keyword is available for usage in the detector
-                   sequences.
-
-Parameter Name:    DETi OPT OVSCY
-Class:             config
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Format:    Output overscan region in Y
-Description:       Number of pixels in Y read as overscan.
-                   This keyword is available for usage in the detector
-                   sequences.
-
-
-
-#
-# RTD subsystem
-#
-
-Parameter Name:    DETi RTDi FRAME
-Class:             setup
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Selected frame
-Description:       Select frame type to be installed.
-
-Parameter Name:    DETi RTDi CAMERA
-Class:             setup
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Camera name
-Description:       Set the RTD camera name to which the data-transfer-task
-                   should send the image events.
-
-Parameter Name:    DETi RTDi NX
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Max. X-dimension
-Description:       Maximum image dimension in x-direction.
-
-Parameter Name:    DETi RTDi NY
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Max. Y-dimension
-Description:       Maximum image dimension in y-direction.
-
-Parameter Name:    DETi RTDi ACQHOST
-Class:             setup
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:              
-Comment Field:     Acq.-process host
-Description:       Acquisition process host name.
-
-Parameter Name:    DETi RTDi ACQPORT
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Acq.-process data port
-Description:       Acquisition process data port number.
-
-Parameter Name:    DETi RTDi INVERT
-Class:             setup
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Invert image
-Description:       When set to TRUE value the real-time image data will 
-                   be inverted by the data transfer task before the image
-                   event is issued.
-
-Parameter Name:    DETi RTDi WIN STRX
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Window start-x
-Description:       Window request lower left x-coordinate.
-
-Parameter Name:    DETi RTDi WIN STRY
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Window start-y
-Description:       Window request lower left y-coordinate.
-
-Parameter Name:    DETi RTDi WIN NX
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Window size in X
-Description:       Window request size in x-direction.
-
-Parameter Name:    DETi RTDi WIN NY
-Class:             setup
-Context:           Detector
-Type:              integer
-Value Format:      %d
-Unit:              
-Comment Field:     Window size in Y
-Description:       Window request size in y-direction.
-
-Parameter Name:    DETi RTDi CONNECT
-Class:             private
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Connected status
-Description:       When set to TRUE value the data-transfer-task is
-                   connected to an acquisition process.
-
-Parameter Name:    DETi RTDi ENABLED
-Class:             private
-Context:           Detector
-Type:              logical
-Value Format:      %c
-Unit:               
-Comment Field:     Enabled status
-Description:       When set to TRUE value the data-transfer from the
-                   acquisition process to the data-transfer-task is
-                   enabled.
-
-Parameter Name:    DETi RTDi STATE
-Class:             private
-Context:           Detector
-Type:              string
-Value Format:      %s
-Unit:               
-Comment Field:     DTT status
-Description:       Actual status of the data-transfer-task process. This 
-                   is either ONLINE of OFF.
-
diff --git a/calib/gasgano/config/KMOS.prefs b/calib/gasgano/config/KMOS.prefs
index 1022f5a..2137299 100644
--- a/calib/gasgano/config/KMOS.prefs
+++ b/calib/gasgano/config/KMOS.prefs
@@ -41,7 +41,7 @@ PRINTER_NAME=lp
 PRINT_FONT=Monospaced:16
 PRINT_ORIENTATION=P
 RADEC_CONVERSION=true
-RECIPE_SET=kmo_arithmetic=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.2.8/kmo_arithmetic.so;kmo_combine=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.2.8/kmo_combine.so;kmo_copy=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.2.8/kmo_copy.so;kmo_dark=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.2.8/kmo_dark.so;kmo_extract_spec=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.2.8/kmo_extract_spec.so;kmo_fit_profile=/home/quality/pipelin [...]
+RECIPE_SET=kmo_arithmetic=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.3.0/kmo_arithmetic.so;kmo_combine=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.3.0/kmo_combine.so;kmo_copy=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.3.0/kmo_copy.so;kmo_dark=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.3.0/kmo_dark.so;kmo_extract_spec=/home/quality/pipelines/kmos/lib/esopipes-plugins/kmos-1.3.0/kmo_extract_spec.so;kmo_fit_profile=/home/quality/pipelin [...]
 SCRIPTS_DIR=gasgano/scripts
 SHORTEN_FILES_PATH=true
 SHORT_FILENAME=true
diff --git a/calib/gasgano/config/kmos.oca b/calib/gasgano/config/kmos.oca
index 9bf8bd0..ceae187 100644
--- a/calib/gasgano/config/kmos.oca
+++ b/calib/gasgano/config/kmos.oca
@@ -162,8 +162,7 @@ recipe kmo_wave_cal;
 action kmos_illumination_calibration
 {
 minRet = 1; maxRet = 1;
-select file as MASTER_DARK from calibFiles where DO.CATG == "MASTER_DARK"
-    and EXPTIME >= 30.0 and EXPTIME <= 100.0 ;
+select file as MASTER_DARK from calibFiles where DO.CATG == "MASTER_DARK" ;
 minRet = 1; maxRet = 1;
 select file as MASTER_FLAT from calibFiles where DO.CATG == "MASTER_FLAT"
     and inputFile.INS.GRAT1.ID==INS.GRAT1.ID ;
diff --git a/configure b/configure
index ba3c7b4..e8ff89d 100755
--- a/configure
+++ b/configure
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for KMOS Instrument Pipeline 1.2.8.
+# Generated by GNU Autoconf 2.68 for KMOS Instrument Pipeline 1.3.0.
 #
-# Report bugs to <kmos-spark at mpe.mpg.de>.
+# Report bugs to <usd-help at eso.org>.
 #
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -246,11 +246,11 @@ fi
     $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
     $as_echo "$0: be upgraded to zsh 4.3.4 or later."
   else
-    $as_echo "$0: Please tell bug-autoconf at gnu.org and
-$0: kmos-spark at mpe.mpg.de about your system, including any
-$0: error possibly output before this message. Then install
-$0: a modern shell, or manually run the script under such a
-$0: shell if you do have one."
+    $as_echo "$0: Please tell bug-autoconf at gnu.org and usd-help at eso.org
+$0: about your system, including any error possibly output
+$0: before this message. Then install a modern shell, or
+$0: manually run the script under such a shell if you do
+$0: have one."
   fi
   exit 1
 fi
@@ -570,9 +570,9 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='KMOS Instrument Pipeline'
 PACKAGE_TARNAME='kmos'
-PACKAGE_VERSION='1.2.8'
-PACKAGE_STRING='KMOS Instrument Pipeline 1.2.8'
-PACKAGE_BUGREPORT='kmos-spark at mpe.mpg.de'
+PACKAGE_VERSION='1.3.0'
+PACKAGE_STRING='KMOS Instrument Pipeline 1.3.0'
+PACKAGE_BUGREPORT='usd-help at eso.org'
 PACKAGE_URL=''
 
 ac_unique_file="Makefile.am"
@@ -1352,7 +1352,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures KMOS Instrument Pipeline 1.2.8 to adapt to many kinds of systems.
+\`configure' configures KMOS Instrument Pipeline 1.3.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1423,7 +1423,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of KMOS Instrument Pipeline 1.2.8:";;
+     short | recursive ) echo "Configuration of KMOS Instrument Pipeline 1.3.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1431,7 +1431,7 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --enable-maintainer-mode  enable make rules and dependencies not useful
+  --disable-maintainer-mode  disable make rules and dependencies not useful
 			  (and sometimes confusing) to the casual installer
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
@@ -1481,7 +1481,7 @@ Some influential environment variables:
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
-Report bugs to <kmos-spark at mpe.mpg.de>.
+Report bugs to <usd-help at eso.org>.
 _ACEOF
 ac_status=$?
 fi
@@ -1544,7 +1544,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-KMOS Instrument Pipeline configure 1.2.8
+KMOS Instrument Pipeline configure 1.3.0
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1889,9 +1889,9 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
 $as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-( $as_echo "## ------------------------------------ ##
-## Report this to kmos-spark at mpe.mpg.de ##
-## ------------------------------------ ##"
+( $as_echo "## ------------------------------- ##
+## Report this to usd-help at eso.org ##
+## ------------------------------- ##"
      ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
@@ -1959,7 +1959,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by KMOS Instrument Pipeline $as_me 1.2.8, which was
+It was created by KMOS Instrument Pipeline $as_me 1.3.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -2889,7 +2889,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='kmos'
- VERSION='1.2.8'
+ VERSION='1.3.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2939,7 +2939,7 @@ $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles
 if test "${enable_maintainer_mode+set}" = set; then :
   enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
 else
-  USE_MAINTAINER_MODE=no
+  USE_MAINTAINER_MODE=yes
 fi
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5
@@ -13611,7 +13611,7 @@ fi
 
 
 
-ac_config_files="$ac_config_files Makefile Makefile.purify doxygen/Doxyfile kmos/Makefile kmos/tests/Makefile tools/easySPARK/Makefile reflex/Makefile reflex/kmos.xml recipes/Makefile recipes/tests/Makefile regtests/Makefile regtests/tests/Makefile irplib/Makefile irplib/tests/Makefile kmclipm/Makefile kmclipm/test/Makefile"
+ac_config_files="$ac_config_files Makefile Makefile.purify doxygen/Doxyfile kmos/Makefile kmos/tests/Makefile tools/easySPARK/Makefile reflex/Makefile reflex/kmos.xml recipes/Makefile regtests/Makefile regtests/tests/Makefile irplib/Makefile irplib/tests/Makefile kmclipm/Makefile kmclipm/test/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -14155,7 +14155,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by KMOS Instrument Pipeline $as_me 1.2.8, which was
+This file was extended by KMOS Instrument Pipeline $as_me 1.3.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14215,13 +14215,13 @@ $config_headers
 Configuration commands:
 $config_commands
 
-Report bugs to <kmos-spark at mpe.mpg.de>."
+Report bugs to <usd-help at eso.org>."
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-KMOS Instrument Pipeline config.status 1.2.8
+KMOS Instrument Pipeline config.status 1.3.0
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
@@ -14639,7 +14639,6 @@ do
     "reflex/Makefile") CONFIG_FILES="$CONFIG_FILES reflex/Makefile" ;;
     "reflex/kmos.xml") CONFIG_FILES="$CONFIG_FILES reflex/kmos.xml" ;;
     "recipes/Makefile") CONFIG_FILES="$CONFIG_FILES recipes/Makefile" ;;
-    "recipes/tests/Makefile") CONFIG_FILES="$CONFIG_FILES recipes/tests/Makefile" ;;
     "regtests/Makefile") CONFIG_FILES="$CONFIG_FILES regtests/Makefile" ;;
     "regtests/tests/Makefile") CONFIG_FILES="$CONFIG_FILES regtests/tests/Makefile" ;;
     "irplib/Makefile") CONFIG_FILES="$CONFIG_FILES irplib/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index f629c1e..f9f6e1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,6 @@
 # Process this file with autoconf to produce a configure script.
 
-AC_INIT([KMOS Instrument Pipeline], [1.2.8], [kmos-spark at mpe.mpg.de],
-[kmos])
+AC_INIT([KMOS Instrument Pipeline], [1.3.0], [usd-help at eso.org], [kmos])
 AC_PREREQ([2.59])
 
 AC_CONFIG_SRCDIR([Makefile.am])
@@ -13,7 +12,7 @@ AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE
 AC_CONFIG_HEADER([config.h])
 
-AM_MAINTAINER_MODE
+AM_MAINTAINER_MODE([enable])
 
 KMOS_SET_PREFIX(${PIPE_HOME:-/usr/local})
 
@@ -89,7 +88,6 @@ AC_CONFIG_FILES(Makefile
                 reflex/Makefile
                 reflex/kmos.xml
                 recipes/Makefile
-                recipes/tests/Makefile
                 regtests/Makefile
                 regtests/tests/Makefile
                 irplib/Makefile
diff --git a/irplib/tests/irplib_polynomial-test.c b/irplib/tests/irplib_polynomial-test.c
index 2fa19c2..46f38d6 100644
--- a/irplib/tests/irplib_polynomial-test.c
+++ b/irplib/tests/irplib_polynomial-test.c
@@ -36,6 +36,7 @@
 #include <irplib_polynomial.h>
 #include <math.h>
 #include <float.h>
+#include <stdint.h>
 
 /*-----------------------------------------------------------------------------
                                    Defines
@@ -202,11 +203,17 @@ static void irplib_polynomial_solve_1d_all_test(void)
                                         DBL_EPSILON, 2.0*DBL_EPSILON);
 
         /* A more extreme case: Same with negative roots */
+#if defined SIZE_MAX && SIZE_MAX <= 4294967295
+        /* Fails on 32-bit - also w. -0.1 * FLT_EPSILON */
+#else
         (void)cpl_vector_fill(xtrue, -0.2 * FLT_EPSILON);
+
         (void)cpl_vector_set(xtrue, 0, -1.0);
 
         irplib_polynomial_test_root_all(xtrue, nreal, CPL_MATH_PI,
                                         FLT_EPSILON, 3.0*DBL_EPSILON);
+#endif
+
 
         if (nreal != 3) {
             /* The most extreme case: Same with negative roots */
diff --git a/irplib/tests/irplib_strehl-test.c b/irplib/tests/irplib_strehl-test.c
index 103fd5b..bdcdd1c 100644
--- a/irplib/tests/irplib_strehl-test.c
+++ b/irplib/tests/irplib_strehl-test.c
@@ -33,6 +33,9 @@
 #endif
 
 #include "irplib_strehl.h"
+#include "irplib_utils.h"
+
+#include <string.h>
 
 /*-----------------------------------------------------------------------------
                                    Defines
@@ -63,25 +66,153 @@ static void irplib_psf_test(void);
 static cpl_image * irplib_strehl_create(cpl_size, cpl_size, cpl_type,
                                         double, double, double);
 static void irplib_strehl_test(const cpl_image *, double, double,
-                               double, double, double);
+                               double, double, double, double, double,
+                               const char *);
+
+static void irplib_strehl_test_fits(const char *, double, double, double,
+                                    double, double, cpl_size);
 
-static void irplib_strehl_test_fits(const char *, double, double, double);
+static const char * irplib_get_base_name(const char *);
 
+struct fitsinfo {
+    const char *bname; /* filename with extension, but without path */
+    double pixscale; /* Arcseconds per pixel */
+    double cwlen;    /* micron */
+    double dwlen;    /* micron */
+    double m1;       /* The diameter of the primary mirror [m] */
+    double m2;       /* The diameter of the secondary mirror [m] */
+    cpl_size iplane;
+};
 
 /*-----------------------------------------------------------------------------
                                   Main
  -----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------*/
+/**
+  @brief  Test the strehl estimation, optionally with FITS data from disk
+  @param  argc The number of FITS files + 1
+  @param  argv The name of the exectuable and optionally any FITS-data to test
+  @return Zero, iff successful
+
+ */
+/*----------------------------------------------------------------------------*/
 int main (int argc, char * argv[])
 {
-
+    /* Support the Strehl-method evaluation effort by Enrico Marchetti */
+    const struct fitsinfo suite[] = {
+        {"Berlin.fits",     12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Frankfurt.fits",  12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Hamburg.fits",    12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Koeln.fits",      12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Muenchen.fits",   12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Stuttgart.fits",  12.25e-3, 1.6, 0.060, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+
+        {"Torino_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Trieste_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Bologna_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Cagliari_2.fits", 0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Catania_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Firenze_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Lapalma_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Milano_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Napoli_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Padova_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Palermo_2.fits",  0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Roma_2.fits",     0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Teramo_2.fits",   0.0331932, 1.635, 0.0001, 5.0800, 1.8288, 0},
+
+        {"Bologna_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Cagliari_4.fits", 0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Catania_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Firenze_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Lapalma.fits",    0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Milano_4.fits",   0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Naoli_4.fits",    0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Padova_4.fits",   0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Palermo_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Roma_4.fits",     0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Teramo_4.fits",   0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Torino_4.fits",   0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+        {"Trieste_4.fits",  0.0165966, 1.635, 0.0001, 5.0800, 1.8288, 0},
+
+        {"Antofagasta.fits", 0.17678, 2.2  , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Bordeaux.fits",    0.01327, 2.166, 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Concepcion.fits",  0.01768, 2.2  , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Grenoble.fits",    0.02715, 2.15 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"LeHavre.fits",     0.01327, 1.65 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Lille.fits",       0.01327, 1.04 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 8},
+        {"Lyon.fits",        0.01327, 2.15 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Marseille.fits",   0.02715, 4.05 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Nantes.fits",      0.0546 , 2.15 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Nice.fits",        0.02715, 4.78 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Paris.fits",       0.0033 , 2.18 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Santiago.fits",    0.01768, 2.2  , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Strasbourg.fits",  0.01327, 2.166, 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Toulouse.fits",    0.02715, 2.15 , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0},
+        {"Valdivia.fits",    0.07071, 2.2  , 0.05, IRPLIB_STREHL_M1,
+         IRPLIB_STREHL_M2, 0}};
+
+    const size_t suitesz = sizeof(suite) / sizeof(*suite);
     int iarg;
 
     cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
 
+    cpl_msg_info("Strehl-testing with star with ",
+                 IRPLIB_XSTRINGIFY(IRPLIB_STREHL_STAR_RADIUS) " = "
+                 IRPLIB_STRINGIFY(IRPLIB_STREHL_STAR_RADIUS) ". "
+                 IRPLIB_XSTRINGIFY(IRPLIB_STREHL_BACKGROUND_R1) " = "
+                 IRPLIB_STRINGIFY(IRPLIB_STREHL_BACKGROUND_R1) ". "
+                 IRPLIB_XSTRINGIFY(IRPLIB_STREHL_BACKGROUND_R2) " = "
+                 IRPLIB_STRINGIFY(IRPLIB_STREHL_BACKGROUND_R2) ".");
+
     irplib_strehl_test_one();
 
     for (iarg = 1; iarg < argc; iarg++) {
-        irplib_strehl_test_fits(argv[iarg], PIXSCALE, CWLEN, DWLEN);
+        const char * basename = irplib_get_base_name(argv[iarg]);
+        double       pixscale = PIXSCALE;
+        double       cwlen    = CWLEN;
+        double       dwlen    = DWLEN;
+        double       m1       = IRPLIB_STREHL_M1;
+        double       m2       = IRPLIB_STREHL_M2;
+        cpl_size     iplane   = 0;
+        size_t       i;
+
+        cpl_test_assert(basename != NULL);
+
+        for (i = 0; i < suitesz; i++) {
+            if (!strcmp(basename, suite[i].bname)) {
+                pixscale = suite[i].pixscale;
+                cwlen    = suite[i].cwlen;
+                dwlen    = suite[i].dwlen;
+                m1       = suite[i].m1;
+                m2       = suite[i].m2;
+                iplane   = suite[i].iplane;
+                break;
+            }
+        }
+
+        irplib_strehl_test_fits(argv[iarg], pixscale, cwlen, dwlen, m1, m2,
+                                iplane);
     }
 
     irplib_psf_test();
@@ -98,27 +229,28 @@ int main (int argc, char * argv[])
   @param  pixscale The pixel scale [Arcsecond]
   @param  lam      The central wavelength [micron]
   @param  dlam     The filter bandwidth [micron]
+  @param  m1       The M1 diameter [m]
+  @param  m2       The M2 diameter [m]
+  @param  iplane   The plane number
 
  */
 /*----------------------------------------------------------------------------*/
 static void irplib_strehl_test_fits(const char * file, double pixscale,
-                                    double lam, double dlam)
+                                    double lam, double dlam, double m1,
+                                    double m2, cpl_size iplane)
 {
 
     cpl_type type = CPL_TYPE_DOUBLE;
     int i;
 
-    for (i = 0; i < 2; i++, type = CPL_TYPE_FLOAT) {
+    for (i = 0; i < 1; i++, type = CPL_TYPE_FLOAT) {
 
-        cpl_image * img = cpl_image_load(file, type, 0, 0);
+        cpl_image * img = cpl_image_load(file, type, iplane, 0);
 
         cpl_test_error(CPL_ERROR_NONE);
         cpl_test_nonnull(img);
 
-        cpl_msg_info(cpl_func, "Testing %s with pixel scale=%g, lam=%g, dlam=%g",
-                     file, pixscale, lam, dlam);
-
-        irplib_strehl_test(img, 0.0, 10.0, pixscale, lam, dlam);
+        irplib_strehl_test(img, 0.0, 10.0, pixscale, lam, dlam, m1, m2, file);
 
         cpl_image_delete(img);
     }
@@ -200,7 +332,8 @@ static void irplib_strehl_test_one(void)
                                                1000.0, 1.0, 1.0);
 
         irplib_strehl_test(img, 1000.0, 1.0, 0.03,
-                           2.18, 0.35); /* NACO values */
+                           2.18, 0.35, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+                           "Synthetic image"); /* NACO values */
 
         cpl_image_delete(img);
     }
@@ -261,13 +394,18 @@ static cpl_image * irplib_strehl_create(cpl_size nx, cpl_size ny,
   @param    pixscale    The pixel scale (arcsecs/pixel)
   @param    lam         Central wavelength [micron]
   @param    dlam        Filter bandwidth [micron]
+  @param    m1          The M1 diameter [m]
+  @param    m2          The M2 diameter [m]
+  @param    label       Image label for messaging
   @return   void
 
  */
 /*----------------------------------------------------------------------------*/
 static void irplib_strehl_test(const cpl_image * im1, double norm,
                                double sigma,
-                               double pixscale, double lam, double dlam)
+                               double pixscale, double lam, double dlam,
+                               double m1, double m2,
+                               const char * label)
 {
 
     const cpl_size nx = cpl_image_get_size_x(im1);
@@ -324,7 +462,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
                   background_2 / pixscale);
 
 
-    imgpsf = irplib_strehl_generate_psf(IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    imgpsf = irplib_strehl_generate_psf(m1, m2,
                                         lam, dlam, pixscale,
                                         IRPLIB_STREHL_BOX_SIZE);
     cpl_test_error(CPL_ERROR_NONE);
@@ -335,9 +473,12 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq(cpl_image_get_size_x(imgpsf),
                 IRPLIB_STREHL_BOX_SIZE);
 
+    if (cpl_msg_get_level() <= CPL_MSG_DEBUG) {
+        cpl_plot_image("", "", "", imgpsf);
+    }
     cpl_image_delete(imgpsf);
 
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE,
                                  mx, my,
@@ -366,10 +507,14 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
                  strehl, strehl_err, star_bg, bg_noise, star_peak, star_flux,
                  psf_peak, psf_flux);
 
+    cpl_msg_info(cpl_func, "%-16s %-10.9g %-8.6g %-8.6g %-8.6g %-8.6g "
+                 "%-8.4g %-8.4g", label, pixscale, lam, dlam, m1, m2,
+                 strehl, strehl_err);
+
     /* Test for various errors */
 
     /* M2 < 0*/
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, 0.0,
+    code = irplib_strehl_compute(im1, m1, 0.0,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -389,7 +534,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
 
 
     /* M1 < M2 */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M2, IRPLIB_STREHL_M1,
+    code = irplib_strehl_compute(im1, m2, m1,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -409,7 +554,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
 
 
     /* lam = 0 */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  0.0, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -428,7 +573,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
 
     /* dlam = 0 */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, 0.0, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -447,7 +592,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
 
     /* pixscale = 0 */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, 0.0,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -466,7 +611,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
 
     /* IRPLIB_STREHL_BOX_SIZE = 0 */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  0, 
                                  nx/2, ny/2,
@@ -485,7 +630,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
 
     /* star_radius = 0 */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -504,7 +649,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
 
     /* background_1 = 0 */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -523,7 +668,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
 
     /* background_2 too small */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -542,7 +687,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_ILLEGAL_INPUT);
 
     /* strehl pointer is NULL */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -561,7 +706,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
 
     /* strehl_err pointer is NULL */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -580,7 +725,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
 
     /* star_bg pointer is NULL */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -599,7 +744,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
 
     /* star_peak pointer is NULL */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -618,7 +763,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
 
     /* psf_peak pointer is NULL */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -637,7 +782,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
 
     /* psf_flux pointer is NULL */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -657,7 +802,7 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
 
 
     /* bg_noise pointer is NULL */
-    code = irplib_strehl_compute(im1, IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
+    code = irplib_strehl_compute(im1, m1, m2,
                                  lam, dlam, pixscale,
                                  IRPLIB_STREHL_BOX_SIZE, 
                                  nx/2, ny/2,
@@ -675,3 +820,22 @@ static void irplib_strehl_test(const cpl_image * im1, double norm,
                                  NULL);
     cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);
 }
+
+
+/*----------------------------------------------------------------------------*/
+/**
+  @internal
+  @brief  Return a pointer to the basename of a full-path filename
+  @param  self   The filename
+  @return The pointer (possibly self, which may be NULL)
+  @note   The pointer returned by this function may not be used after self is
+          de/re-allocated, nor after a call of the function with another string.
+  @see cpl_get_base_name()
+ */
+/*----------------------------------------------------------------------------*/
+static const char * irplib_get_base_name(const char * self)
+{
+    const char * p = self ? strrchr(self, '/') : NULL;
+
+    return p ? p + 1 : self;
+}
diff --git a/kmclipm/include/kmclipm_functions.h b/kmclipm/include/kmclipm_functions.h
index 6cd8f7c..927ce3c 100644
--- a/kmclipm/include/kmclipm_functions.h
+++ b/kmclipm/include/kmclipm_functions.h
@@ -266,9 +266,7 @@ cpl_error_code  kmclipm_setup_grid(
 
 cpl_error_code kmclipm_setup_grid_band_lcal(
                             gridDefinition *gd,
-                            const cpl_image *lcal,
                             const char *filter_id,
-                            int bandwith_method,
                             const cpl_table *tbl);
 /*
 cpl_error_code  kmclipm_setup_grid_band_auto(
diff --git a/kmclipm/src/kmclipm_functions.c b/kmclipm/src/kmclipm_functions.c
index 721aa5a..287985b 100644
--- a/kmclipm/src/kmclipm_functions.c
+++ b/kmclipm/src/kmclipm_functions.c
@@ -2314,35 +2314,22 @@ cpl_error_code kmclipm_setup_grid(gridDefinition *gd,
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Setup the band start and end of the grid definition for reconstruction
-        automatically using lcal calibration frame.
-
-    This setup applies to every detector individually.
-
-    @param gd               (Updated) Pointer to the grid definition to configure.
-    @param lcal             The spectral calibration frame.
-    @param filter_id        The filter ID ("H", "K", "HK", IZ"!, "YJ").
-    @param bandwidth_method 0: 2460pix with start and end hard coded
-                            1: 2048pix with start and end from lcal (overrides
-                               previously set gd.l.dim)
-    @param tbl              The table containing the wave start and end values
-                            for all bands.
-
-    @return
-        The function returns CPL_ERROR_NONE on success or a CPL error code
-        otherwise.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT     if @c gd or @c lcal is NULL.
+  @brief Setup the band start and end of the grid definition for reconstruction
+            This setup applies to every detector individually.
+  @param gd         (Updated) Pointer to the grid definition to configure.
+  @param filter_id  The filter ID ("H", "K", "HK", IZ"!, "YJ").
+  @param tbl        The table containing the wave start and end for all bands.
+  @return CPL_ERROR_NONE on success or a CPL error code 
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT     if @c gd is NULL.
 */
-cpl_error_code kmclipm_setup_grid_band_lcal(gridDefinition *gd,
-                                            const cpl_image *lcal,
-                                            const char *filter_id,
-                                            int bandwidth_method,
-                                            const cpl_table *tbl)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmclipm_setup_grid_band_lcal(
+        gridDefinition  *   gd,
+        const char      *   filter_id,
+        const cpl_table *   tbl)
 {
     cpl_error_code  ret_error   = CPL_ERROR_NONE;
     double          tol         = 0.001;
@@ -2353,81 +2340,43 @@ cpl_error_code kmclipm_setup_grid_band_lcal(gridDefinition *gd,
     KMCLIPM_TRY
     {
         /* Check inputs */
-        KMCLIPM_TRY_CHECK((gd != NULL) &&
-                          (tbl != NULL),
-                          CPL_ERROR_NULL_INPUT,
-                          NULL,
-                          "Not all input data is provided!");
+        KMCLIPM_TRY_CHECK((gd != NULL) && (tbl != NULL), CPL_ERROR_NULL_INPUT,
+                NULL, "Not all input data is provided!");
 
         KMCLIPM_TRY_EXIT_IFN(
             ptbl = cpl_table_get_data_float_const(tbl, filter_id));
 
-        if (bandwidth_method == 0) {
-            /* set band start */
-            if (fabs(kmclipm_band_start + 1.0) < tol) {
-                /* set default start value */
-                tmp_start = ptbl[0];
-            } else {
-                /* set custom value from global variable (it is set via recipe) */
-                tmp_start = kmclipm_band_start;
-            }
-
-            /* set band end */
-            if (fabs(kmclipm_band_end + 1.0) < tol) {
-                /* set default end value */
-                tmp_end = ptbl[1];
-            } else {
-                /* set custom value from global variable (it is set via recipe) */
-                tmp_end = kmclipm_band_end;
-            }
-
-            /* set nr of samples */
-            gd->l.start = tmp_start;
-            gd->l.delta = (tmp_end - tmp_start) / kmclipm_band_samples;
+        /* set band start */
+        if (fabs(kmclipm_band_start + 1.0) < tol) {
+            /* set default start value */
+            tmp_start = ptbl[0];
+        } else {
+            /* set custom value from global variable (it is set via recipe) */
+            tmp_start = kmclipm_band_start;
         }
-        else if (bandwidth_method == 1) {
-            KMCLIPM_TRY_CHECK(lcal != NULL,
-                              CPL_ERROR_NULL_INPUT,
-                              NULL,
-                              "Not all input data is provided!");
-
-            /* set band start */
-            if (fabs(kmclipm_band_start + 1.0) < tol) {
-                /* set default value */
-                tmp_start = cpl_image_get_min(lcal);
-            } else {
-                /* set custom value from global variable (it is set via recipe) */
-                tmp_start = kmclipm_band_start;
-            }
 
-            /* set band end */
-            if (fabs(kmclipm_band_end + 1.0) < tol) {
-                /* set default value */
-                tmp_end = cpl_image_get_max(lcal);
-            } else {
-                /* set custom value from global variable (it is set via recipe) */
-                tmp_end = kmclipm_band_end;
-            }
-
-            /* set nr of samples */
-            gd->l.dim = KMOS_DETECTOR_SIZE;
-            gd->l.delta = (tmp_end - tmp_start) / (gd->l.dim - 2*KMOS_BADPIX_BORDER);
-            gd->l.start = tmp_start - KMOS_BADPIX_BORDER*gd->l.delta;
+        /* set band end */
+        if (fabs(kmclipm_band_end + 1.0) < tol) {
+            /* set default end value */
+            tmp_end = ptbl[1];
+        } else {
+            /* set custom value from global variable (it is set via recipe) */
+            tmp_end = kmclipm_band_end;
         }
 
+        /* set nr of samples */
+        gd->l.start = tmp_start;
+        gd->l.delta = (tmp_end - tmp_start) / kmclipm_band_samples;
+
         /* print band info */
-        cpl_msg_info("",
-                     "Resampled wavelength range for this detector: "
-                     "%5.4g-%5.4gum with %d samples",
-                     gd->l.start,
-                     gd->l.start + gd->l.dim * gd->l.delta,
-                     gd->l.dim);
+        cpl_msg_info("", "Resampled wavelength range for this detector: "
+                "%5.4g-%5.4gum with %d samples",
+                gd->l.start, gd->l.start + gd->l.dim * gd->l.delta, gd->l.dim);
     }
     KMCLIPM_CATCH
     {
         ret_error = cpl_error_get_code();
     }
-
     return ret_error;
 }
 
diff --git a/kmclipm/test/kmclipm_test_functions.c b/kmclipm/test/kmclipm_test_functions.c
index 83b5ab4..cfe8973 100644
--- a/kmclipm/test/kmclipm_test_functions.c
+++ b/kmclipm/test/kmclipm_test_functions.c
@@ -3574,7 +3574,7 @@ int main()
      *  (or export CPL_MSG_LEVEL=warning)
      */
 
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", my_level);
+    cpl_test_init("<usd-help at eso.org>", my_level);
 
     char *my_path = cpl_sprintf("%s/test_data", ".");
     mkdir(my_path, 0777);
diff --git a/kmclipm/test/kmclipm_test_math.c b/kmclipm/test/kmclipm_test_math.c
index 2a7bbb6..a994a2c 100644
--- a/kmclipm/test/kmclipm_test_math.c
+++ b/kmclipm/test/kmclipm_test_math.c
@@ -198,7 +198,7 @@ int main()
      *  (or export CPL_MSG_LEVEL=warning)
      */
 
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", my_level);
+    cpl_test_init("<usd-help at eso.org>", my_level);
 
     char *my_path = cpl_sprintf("%s/test_data", ".");
     mkdir(my_path, 0777);
diff --git a/kmclipm/test/kmclipm_test_priv_constants.c b/kmclipm/test/kmclipm_test_priv_constants.c
index 0e3763e..d48476e 100644
--- a/kmclipm/test/kmclipm_test_priv_constants.c
+++ b/kmclipm/test/kmclipm_test_priv_constants.c
@@ -157,7 +157,7 @@ int main()
      *  (or export CPL_MSG_LEVEL=warning)
      */
 
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", my_level);
+    cpl_test_init("<usd-help at eso.org>", my_level);
 
     char *my_path = cpl_sprintf("%s/test_data", ".");
     mkdir(my_path, 0777);
diff --git a/kmclipm/test/kmclipm_test_priv_functions.c b/kmclipm/test/kmclipm_test_priv_functions.c
index fab801d..ec46130 100644
--- a/kmclipm/test/kmclipm_test_priv_functions.c
+++ b/kmclipm/test/kmclipm_test_priv_functions.c
@@ -1086,7 +1086,7 @@ int main()
      *  (or export CPL_MSG_LEVEL=warning)
      */
 
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", my_level);
+    cpl_test_init("<usd-help at eso.org>", my_level);
 
     char *my_path = cpl_sprintf("%s/test_data", ".");
     mkdir(my_path, 0777);
diff --git a/kmclipm/test/kmclipm_test_priv_reconstruct.c b/kmclipm/test/kmclipm_test_priv_reconstruct.c
index f8d14ce..781310b 100644
--- a/kmclipm/test/kmclipm_test_priv_reconstruct.c
+++ b/kmclipm/test/kmclipm_test_priv_reconstruct.c
@@ -25,6 +25,7 @@
  *----------------------------------------------------------------------------*/
 #include <math.h>
 #include <sys/stat.h>
+#include <sys/wait.h>
 
 #include "kmclipm_constants.h"
 #include "kmclipm_priv_reconstruct.h"
@@ -526,7 +527,7 @@ int main()
      *  (or export CPL_MSG_LEVEL=warning)
      */
 
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", my_level);
+    cpl_test_init("<usd-help at eso.org>", my_level);
 
     char *my_path = cpl_sprintf("%s/test_data", ".");
     mkdir(my_path, 0777);
diff --git a/kmclipm/test/kmclipm_test_priv_splines.c b/kmclipm/test/kmclipm_test_priv_splines.c
index 7088b06..dd22bd4 100644
--- a/kmclipm/test/kmclipm_test_priv_splines.c
+++ b/kmclipm/test/kmclipm_test_priv_splines.c
@@ -228,7 +228,7 @@ int main()
      *  (or export CPL_MSG_LEVEL=warning)
      */
 
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", my_level);
+    cpl_test_init("<usd-help at eso.org>", my_level);
 
     char *my_path = cpl_sprintf("%s/test_data", ".");
     mkdir(my_path, 0777);
diff --git a/kmclipm/test/kmclipm_test_rtd.c b/kmclipm/test/kmclipm_test_rtd.c
index 483f75c..0138093 100644
--- a/kmclipm/test/kmclipm_test_rtd.c
+++ b/kmclipm/test/kmclipm_test_rtd.c
@@ -1842,7 +1842,7 @@ int main(int argc, char *argv[])
      *  (or export CPL_MSG_LEVEL=warning)
      */
 
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", my_level);
+    cpl_test_init("<usd-help at eso.org>", my_level);
 
     char  *raw_obj_path       = cpl_sprintf("%s/test_data/raw_image_obj.fits", ".");
     char  *raw_sky_path       = cpl_sprintf("%s/test_data/raw_image_sky.fits", ".");
diff --git a/kmclipm/test/kmclipm_test_vector.c b/kmclipm/test/kmclipm_test_vector.c
index 2b739a6..eca6c12 100644
--- a/kmclipm/test/kmclipm_test_vector.c
+++ b/kmclipm/test/kmclipm_test_vector.c
@@ -1674,7 +1674,7 @@ int main()
      *  (or export CPL_MSG_LEVEL=warning)
      */
 
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", my_level);
+    cpl_test_init("<usd-help at eso.org>", my_level);
 
     char *my_path = cpl_sprintf("%s/test_data", ".");
     mkdir(my_path, 0777);
diff --git a/kmos/kmo_dfs.c b/kmos/kmo_dfs.c
index 60c1daa..85ec201 100644
--- a/kmos/kmo_dfs.c
+++ b/kmos/kmo_dfs.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_dfs.c,v 1.48 2013/10/21 13:44:53 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,12 +17,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013/10/21 13:44:53 $
- * $Revision: 1.48 $
- * $Name:  $
- */
+/*-----------------------------------------------------------------------------
+ *                                 Includes
+ *----------------------------------------------------------------------------*/
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -45,15 +41,12 @@
 
 /*----------------------------------------------------------------------------*/
 /**
-    @defgroup kmos_dfs kmos_dfs DFS related functions
-
-        The module kmos_dfs collects medium level functions related to
-        DFS data IO.
-
-    @{
+  @defgroup kmos_dfs    DFS related functions
  */
 /*----------------------------------------------------------------------------*/
 
+/**@{*/
+
 int override_err_msg            = FALSE;
 int print_cal_angle_msg_once    = TRUE;
 int print_xcal_angle_msg_once   = TRUE;
@@ -61,230 +54,146 @@ int cal_load_had_xcal           = FALSE;
 int cal_load_had_ycal           = FALSE;
 double cal_load_first_angle     = -1.0;
 double cal_load_second_angle    = -1.0;
-//int sat_mode_msg            = FALSE;
-//int sat_mode_last_device_nr = -1;
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Convert all charachters in input string @c s to lower case.
-
-    @param s The input string.
-
-    @return
-        The converted string.
+  @brief Convert all charachters in input string @c s to lower case.
+  @param s The input string.
+  @return The converted string.
 */
+/*----------------------------------------------------------------------------*/
 const char *strlower(char *s)
 {
     char *t = s;
-
     while (*t) {
         *t = tolower(*t);
         t++;
     }
-
     return s;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Remove problematic characters from string
-
-    @param str  The string to clean
+  @brief Remove problematic characters from string
+  @param str  The string to clean
 */
+/*----------------------------------------------------------------------------*/
 void kmo_clean_string(char *str)
 {
     char    *s = NULL,
             *d = NULL;
-
     for (s=d=str; (*d=*s); d+=(*s++!='['));
     for (s=d=str; (*d=*s); d+=(*s++!=']'));
-//    for (s=d=str; (*d=*s); d+=(*s++!='{'));
-//    for (s=d=str; (*d=*s); d+=(*s++!='}'));
-//    for (s=d=str; (*d=*s); d+=(*s++!=':'));
-//    for (s=d=str; (*d=*s); d+=(*s++!=';'));
-//    for (s=d=str; (*d=*s); d+=(*s++!='*'));
-//    for (s=d=str; (*d=*s); d+=(*s++!='/'));
-//    for (s=d=str; (*d=*s); d+=(*s++!='|'));
-//    for (s=d=str; (*d=*s); d+=(*s++!='\\'));
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Fetching a frame of a certain category or of a certain position.
-
-    @param frameset The input set-of-frames
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-
-    @return The desired frame.
-
-    When the frames in a framset are tagged with a category, they can be
-    retrieved by supplying this category-keyword.
-    But for basic recipes ignoring category-keywords (which rather take account
-    of the order of the frames in a frameset, like @c kmo_arithmetic), a string
-    containing an integer value can be supplied. The string is then converted to
-    an integer and the corresponding frame will be returned.
-
-    This function is just a wrapper to the basic CPL function
-    @c cpl_frameset_find() , as it is called every time an image should be
-    loaded by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL function. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading primary header associated to data of given category.
+  @param frameset The input set-of-frames
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @return The loaded primary header
+
+  This function is just a wrapper to the basic CPL functions 
+  @c cpl_frameset_find() and @c cpl_propertylist_load(), as they typically are 
+  called every time a header should be loaded by a recipe. Error checking and 
+  proper messaging are also included here, to give a more readable look to the 
+  main recipe code.
+
+  In case of any error, a @c NULL pointer is returned. The error codes that 
+  are set in this case are the same set by the above mentioned CPL functions. 
+  The "where" string (accessible via a call to @c cpl_error_get_where() ) is
+  not modified by this function, and therefore the function where the failure 
+  occurred is also reported.
 */
-cpl_frame* kmo_dfs_get_frame(cpl_frameset *frameset,
-                               const char *category)
+/*----------------------------------------------------------------------------*/
+cpl_propertylist* kmo_dfs_load_primary_header(
+        cpl_frameset    *   frameset,
+        const char      *   category)
 {
-    cpl_frame           *frame = NULL;   /* must not be deleted at the end */
-    int                 nr     = 0;
+    cpl_frame           *frame      = NULL;
+    cpl_propertylist    *header     = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
-        KMO_TRY_ASSURE(cpl_frameset_get_size(frameset) != 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Empty frameset provided!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
 
-        if (category == NULL) {
-            // didn't catch sometimes even when last frame was reached ?!?
-//            KMO_TRY_EXIT_IF_NULL(
-//                frame = cpl_frameset_find(frameset, NULL));
-            frame = cpl_frameset_find(frameset, NULL);
-        } else {
-            nr = atoi(category);
-            if ((nr == 0) && (strlen(category) > 1)) {
-                if (cpl_frameset_count_tags(frameset,category) == 0) {
-//                    KMO_TRY_ERROR_SET_MSG(CPL_ERROR_DATA_NOT_FOUND,
-//                                    "Specified tag was not found in frameset!");
-                } else {
-                    KMO_TRY_EXIT_IF_NULL(
-                        frame = cpl_frameset_find(frameset, category));
-                }
-            } else {
-#if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(6, 3, 0)
-                KMO_TRY_EXIT_IF_NULL(
-                    frame = cpl_frameset_get_position(frameset, nr));
-#else
-                KMO_TRY_EXIT_IF_NULL(
-                    frame = cpl_frameset_get_frame(frameset, nr));
-#endif
-            }
+        frame = kmo_dfs_get_frame(frameset, category);
+        if (frame != NULL) {
+            KMO_TRY_EXIT_IF_NULL(
+                header = kmclipm_propertylist_load(
+                    cpl_frame_get_filename(frame), 0));
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
-        frame = NULL;
+        cpl_propertylist_delete(header); header = NULL;
     }
-
-    return frame;
+    return header;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Loading primary header associated to data of given category.
-
-    @param frameset The input set-of-frames
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-
-    @return The loaded primary header
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_propertylist_load(), as they
-    typically are called every time a header should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief    Loading header from a specific device 
+  @param frame    The input frame
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    TRUE:  the noise extension of the device is used
+                  FALSE: the data extension of the device is used
+  @return   The loaded header
 */
-
-cpl_propertylist* kmo_dfs_load_primary_header(cpl_frameset *frameset,
-                                      const char *category)
+/*----------------------------------------------------------------------------*/
+cpl_propertylist * kmos_dfs_load_sub_header(
+        cpl_frame       *   frame,
+        int                 device,
+        int                 noise)
 {
-    cpl_frame           *frame      = NULL;
-    cpl_propertylist    *header     = NULL;
+    cpl_propertylist    *header   = NULL;
+    int                 index     = 0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT, "Null Inputs");
+        KMO_TRY_ASSURE(device>=0, CPL_ERROR_ILLEGAL_INPUT,"Device is negative");
 
-        frame = kmo_dfs_get_frame(frameset, category);
-        if (frame != NULL) {
-            KMO_TRY_EXIT_IF_NULL(
-                header = kmclipm_propertylist_load(cpl_frame_get_filename(frame),
-                                                   0));
-        }
+        index = kmo_identify_index(cpl_frame_get_filename(frame),device, noise);
+        KMO_TRY_CHECK_ERROR_STATE();
+
+        header = kmclipm_propertylist_load(cpl_frame_get_filename(frame),index);
+        KMO_TRY_EXIT_IF_NULL(header) ;
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_propertylist_delete(header); header = NULL;
     }
-
     return header;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Loading sub-header associated to data of given category.
-
-    @param frameset The input set-of-frames
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    TRUE:  the noise frame of the device is returned
-                    FALSE: the data frame of the device is returned
-
-    @return The loaded sub header.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_propertylist_load(), as they
-    typically are called every time a header should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading sub-header associated to data of given category.
+  @param frameset The input set-of-frames
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    TRUE:  the noise frame of the device is returned
+                  FALSE: the data frame of the device is returned
+  @return The loaded sub header.
 */
-
-cpl_propertylist* kmo_dfs_load_sub_header(cpl_frameset *frameset,
-                                      const char *category,
-                                      int device,
-                                      int noise)
+/*----------------------------------------------------------------------------*/
+cpl_propertylist* kmo_dfs_load_sub_header(
+        cpl_frameset    *   frameset,
+        const char      *   category,
+        int                 device,
+        int                 noise)
 {
     cpl_frame           *frame    = NULL;   /* must not be deleted at the end */
     cpl_propertylist    *header   = NULL;
@@ -292,72 +201,93 @@ cpl_propertylist* kmo_dfs_load_sub_header(cpl_frameset *frameset,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT, 
+                "Not all input data provided!");
 
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "device number is negative!");
 
         frame = kmo_dfs_get_frame(frameset, category);
-
         if (frame != NULL) {
-            index = kmo_identify_index(cpl_frame_get_filename(frame),
-                                        device, noise);
+            index = kmo_identify_index(cpl_frame_get_filename(frame), device,
+                    noise);
             KMO_TRY_CHECK_ERROR_STATE();
 
             KMO_TRY_EXIT_IF_NULL(
-                header = kmclipm_propertylist_load(cpl_frame_get_filename(frame),
-                                                   index));
+                header = kmclipm_propertylist_load(
+                    cpl_frame_get_filename(frame), index));
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_propertylist_delete(header); header = NULL;
     }
-
     return header;
 }
 
+/*----------------------------------------------------------------------------*/
+/**
+  @brief    Load vector data (F1I) 
+  @param frame  The frame to load from
+  @param device The device number (IFU or detector) to access (first = 1)
+  @param noise  TRUE:  the noise extension of the device is used
+                FALSE: the data extension of the device is used
+  @return   The loaded vector
+  Data type of CPL_TYPE_FLOAT is assumed.
+ */
+/*----------------------------------------------------------------------------*/
+kmclipm_vector * kmos_dfs_load_vector(
+        cpl_frame       *   frame,
+        int                 device,
+        int                 noise)
+{
+    kmclipm_vector  *   vec   = NULL;
+    int                 index  = 0;
+
+    KMO_TRY
+    {
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT, "NULL Frame");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT, 
+                "Device number is negative");
+        KMO_TRY_ASSURE((noise == 0) || (noise == 1), CPL_ERROR_ILLEGAL_INPUT,
+                "Noise must be 0 or 1!");
+
+        index = kmo_identify_index(cpl_frame_get_filename(frame), device,noise);
+        KMO_TRY_CHECK_ERROR_STATE();
+
+        vec = kmclipm_vector_load(cpl_frame_get_filename(frame), index);
+        KMO_TRY_EXIT_IF_NULL(vec) ;
+    }
+    KMO_CATCH
+    {
+        KMO_CATCH_MSG();
+        kmclipm_vector_delete(vec); vec = NULL;
+    }
+    return vec;
+}
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading vector data (F1I) of given category.
-
-    @param frameset The input set-of-frames
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    TRUE:  the noise frame of the device is returned
-                    FALSE: the data frame of the device is returned
-
-    @return The loaded vector.
-
-    Data type of CPL_TYPE_FLOAT is assumed.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_vector_load(), as they
-    typically are called every time an image should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading vector data (F1I) of given category.
+  @param frameset The input set-of-frames
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    TRUE:  the noise frame of the device is returned
+                  FALSE: the data frame of the device is returned
+
+  @return The loaded vector.
+  Data type of CPL_TYPE_FLOAT is assumed.
  */
-kmclipm_vector* kmo_dfs_load_vector(cpl_frameset *frameset,
-                                const char *category,
-                                int device,
-                                int noise)
+/*----------------------------------------------------------------------------*/
+kmclipm_vector* kmo_dfs_load_vector(
+        cpl_frameset    *   frameset,
+        const char      *   category,
+        int                 device,
+        int                 noise)
 {
     cpl_frame       *frame = NULL;   /* must not be deleted at the end */
     kmclipm_vector  *vec   = NULL;
@@ -365,100 +295,73 @@ kmclipm_vector* kmo_dfs_load_vector(cpl_frameset *frameset,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
-        KMO_TRY_ASSURE((noise == 0) || (noise == 1),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "noise must be 0 or 1!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT, 
+                "device number is negative!");
+        KMO_TRY_ASSURE((noise == 0) || (noise == 1), CPL_ERROR_ILLEGAL_INPUT,
+                "noise must be 0 or 1!");
 
         frame = kmo_dfs_get_frame(frameset, category);
         KMO_TRY_CHECK_ERROR_STATE();
-
         if (frame != NULL) {
             index = kmo_identify_index(cpl_frame_get_filename(frame), device,
                                        noise);
             KMO_TRY_CHECK_ERROR_STATE();
 
             KMO_TRY_EXIT_IF_NULL(
-                vec = kmclipm_vector_load(cpl_frame_get_filename(frame), index));
+                vec = kmclipm_vector_load(cpl_frame_get_filename(frame), 
+                    index));
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         kmclipm_vector_delete(vec); vec = NULL;
     }
-
     return vec;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading image data (F2I or F2D) of a given category.
-
-    @param frameset The input set-of-frames.
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    0: the data frame of the device is returned
-                    1: the noise frame of the device is returned
-                    2: the badpix frame of the device is returned
-    @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
-                    mode should be rejected, FALSE otherwise.
-    @param nr_sat   Pass an integer if the number of saturated pixels should be
-                    returned or NULL otherwise.
-
-    @return The loaded image.
-
-    Data type of CPL_TYPE_FLOAT is assumed.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_image_load(), as they
-    typically are called every time an image should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading image data (F2I or F2D) of a given category.
+  @param frameset The input set-of-frames.
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    0: the data frame of the device is returned
+                  1: the noise frame of the device is returned
+                  2: the badpix frame of the device is returned
+  @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
+                  mode should be rejected, FALSE otherwise.
+  @param nr_sat   Pass an integer if the number of saturated pixels should be
+                  returned or NULL otherwise.
+  @return The loaded image.
+  Data type of CPL_TYPE_FLOAT is assumed.
 */
-cpl_image* kmo_dfs_load_image(cpl_frameset *frameset,
-                              const char *category,
-                              int device,
-                              int noise,
-                              int sat_mode,
-                              int *nr_sat)
+/*----------------------------------------------------------------------------*/
+cpl_image* kmo_dfs_load_image(
+        cpl_frameset    *   frameset,
+        const char      *   category,
+        int                 device,
+        int                 noise,
+        int                 sat_mode,
+        int             *   nr_sat)
 {
     cpl_frame   *frame  = NULL;   /* must not be deleted at the end */
     cpl_image   *img    = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
-        KMO_TRY_ASSURE((noise >= 0) || (noise <= 2),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "noise must be 0, 1 or 2!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT, 
+                "Not all input data is provided!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT, 
+                "device number is negative!");
+        KMO_TRY_ASSURE((noise >= 0) || (noise <= 2), CPL_ERROR_ILLEGAL_INPUT,
+                "noise must be 0, 1 or 2!");
 
         frame = kmo_dfs_get_frame(frameset, category);
         KMO_TRY_CHECK_ERROR_STATE();
@@ -466,91 +369,71 @@ cpl_image* kmo_dfs_load_image(cpl_frameset *frameset,
         if (frame != NULL) {
             if (!override_err_msg) {
                 KMO_TRY_EXIT_IF_NULL(
-                    img = kmo_dfs_load_image_frame(frame, device, noise, sat_mode, nr_sat));
+                    img = kmo_dfs_load_image_frame(frame, device, noise, 
+                        sat_mode, nr_sat));
             } else {
-                img = kmo_dfs_load_image_frame(frame, device, noise, sat_mode, nr_sat);
+                img = kmo_dfs_load_image_frame(frame, device, noise, sat_mode,
+                        nr_sat);
             }
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_image_delete(img); img = NULL;
         if (nr_sat != NULL) {
             nr_sat = 0;
         }
     }
-
     return img;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading cal image data of a given category.
-
-    @param frameset The input set-of-frames.
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    0: the data frame of the device is returned
-                    1: the noise frame of the device is returned
-                    2: the badpix frame of the device is returned
-                    -1: don't care
-    @param angle        NAANGLE
-    @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
-                    mode should be rejected, FALSE otherwise.
-    @param nr_sat   Pass an integer if the number of saturated pixels should be
-                    returned or NULL otherwise.
-    @param angle_found  NAANGLE of returned cal image
-
-    @return The loaded image.
-
-    Data type of CPL_TYPE_FLOAT is assumed.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_image_load(), as they
-    typically are called every time an image should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading cal image data of a given category.
+  @param frameset The input set-of-frames.
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    0: the data frame of the device is returned
+                  1: the noise frame of the device is returned
+                  2: the badpix frame of the device is returned
+                  -1: don't care
+  @param angle        NAANGLE
+  @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
+                  mode should be rejected, FALSE otherwise.
+  @param nr_sat   Pass an integer if the number of saturated pixels should be
+                  returned or NULL otherwise.
+  @param angle_found  NAANGLE of returned cal image
+  @return The loaded image.
+  Data type of CPL_TYPE_FLOAT is assumed.
 */
-cpl_image* kmo_dfs_load_cal_image(cpl_frameset *frameset,
-                              const char *category,
-                              int device,
-                              int noise,
-                              double angle,
-                              int sat_mode,
-                              int *nr_sat,
-                              double *angle_found,
-                              int ifu_nr,
-                              int low_bound,
-                              int high_bound)
+/*----------------------------------------------------------------------------*/
+cpl_image* kmo_dfs_load_cal_image(
+        cpl_frameset    *   frameset,
+        const char      *   category,
+        int                 device,
+        int                 noise,
+        double              angle,
+        int                 sat_mode,
+        int             *   nr_sat,
+        double          *   angle_found,
+        int                 ifu_nr,
+        int                 low_bound,
+        int                 high_bound)
 {
     cpl_frame   *frame  = NULL;   /* must not be deleted at the end */
     cpl_image   *img    = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
-
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "device number is negative!");
         frame = kmo_dfs_get_frame(frameset, category);
         KMO_TRY_CHECK_ERROR_STATE();
 
@@ -558,183 +441,138 @@ cpl_image* kmo_dfs_load_cal_image(cpl_frameset *frameset,
             if (!override_err_msg) {
                 KMO_TRY_EXIT_IF_NULL(
                     img = kmo_dfs_load_cal_image_frame(frame, device, noise,
-                            angle, sat_mode, nr_sat, angle_found, ifu_nr, low_bound, high_bound));
+                        angle, sat_mode, nr_sat, angle_found, ifu_nr, 
+                        low_bound, high_bound));
             } else {
                 img = kmo_dfs_load_cal_image_frame(frame, device, noise,
-                            angle, sat_mode, nr_sat, angle_found, ifu_nr, low_bound, high_bound);
+                        angle, sat_mode, nr_sat, angle_found, ifu_nr, 
+                        low_bound, high_bound);
             }
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_image_delete(img); img = NULL;
         if (nr_sat != NULL) {
             nr_sat = 0;
         }
     }
-
     return img;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading image data window (F2I or F2D) of a given category.
-
-    @param frameset The input set-of-frames.
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    0: the data frame of the device is returned
-                    1: the noise frame of the device is returned
-                    2: the badpix frame of the device is returned
-    @param llx      Lower left x position (FITS convention, 1 for leftmost)
-    @param lly      Lower left y position (FITS convention, 1 for lowest)
-    @param urx      Upper right x position (FITS convention)
-    @param ury      Upper right y position (FITS convention)
-    @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
-                    mode should be rejected, FALSE otherwise.
-    @param nr_sat   Pass an integer if the number of saturated pixels should be
-                    returned or NULL otherwise.
-
-    @return The loaded image window.
-
-    Data type of CPL_TYPE_FLOAT is assumed.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_image_load_window(), as they
-    typically are called every time an image should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading image data window (F2I or F2D) of a given category.
+  @param frameset The input set-of-frames.
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    0: the data frame of the device is returned
+                  1: the noise frame of the device is returned
+                  2: the badpix frame of the device is returned
+  @param llx      Lower left x position (FITS convention, 1 for leftmost)
+  @param lly      Lower left y position (FITS convention, 1 for lowest)
+  @param urx      Upper right x position (FITS convention)
+  @param ury      Upper right y position (FITS convention)
+  @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
+                  mode should be rejected, FALSE otherwise.
+  @param nr_sat   Pass an integer if the number of saturated pixels should be
+                  returned or NULL otherwise.
+  @return The loaded image window.
+  Data type of CPL_TYPE_FLOAT is assumed.
 */
-cpl_image* kmo_dfs_load_image_window(cpl_frameset *frameset,
-                                     const char *category,
-                                     int device,
-                                     int noise,
-                                     int llx,
-                                     int lly,
-                                     int urx,
-                                     int ury,
-                                     int sat_mode,
-                                     int *nr_sat)
+/*----------------------------------------------------------------------------*/
+cpl_image* kmo_dfs_load_image_window(
+        cpl_frameset    *   frameset,
+        const char      *   category,
+        int                 device,
+        int                 noise,
+        int                 llx,
+        int                 lly,
+        int                 urx,
+        int                 ury,
+        int                 sat_mode,
+        int             *   nr_sat)
 {
     cpl_frame   *frame  = NULL;   /* must not be deleted at the end */
     cpl_image   *img    = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
-        KMO_TRY_ASSURE((noise >= 0) || (noise <= 2),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "noise must be 0, 1 or 2!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "device number is negative!");
+        KMO_TRY_ASSURE((noise >= 0) || (noise <= 2), CPL_ERROR_ILLEGAL_INPUT,
+                "noise must be 0, 1 or 2!");
 
         frame = kmo_dfs_get_frame(frameset, category);
         KMO_TRY_CHECK_ERROR_STATE();
-
         if (frame != NULL) {
             if (!override_err_msg) {
                 KMO_TRY_EXIT_IF_NULL(
                     img = kmo_dfs_load_image_frame_window(frame, device, noise,
-                                                          llx, lly, urx, ury,
-                                                          sat_mode, nr_sat));
+                        llx, lly, urx, ury, sat_mode, nr_sat));
             } else {
                 img = kmo_dfs_load_image_frame_window(frame, device, noise,
-                                                      llx, lly, urx, ury,
-                                                      sat_mode, nr_sat);
+                        llx, lly, urx, ury, sat_mode, nr_sat);
             }
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_image_delete(img); img = NULL;
         if (nr_sat != NULL) {
             nr_sat = 0;
         }
     }
-
     return img;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading image data (F2I or F2D) from a given frame.
-
-    @param frame    The input frames.
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    0: the data frame of the device is returned
-                    1: the noise frame of the device is returned
-                    2: the badpix frame of the device is returned
-    @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
-                    mode should be rejected, FALSE otherwise.
-    @param nr_sat   Pass an integer if the number of saturated pixels should be
-                    returned or NULL otherwise.
-
-    @return The loaded image.
-
-    Data type of CPL_TYPE_FLOAT is assumed.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_image_load(), as they
-    typically are called every time an image should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading image data (F2I or F2D) from a given frame.
+  @param frame    The input frames.
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    0: the data frame of the device is returned
+                  1: the noise frame of the device is returned
+                  2: the badpix frame of the device is returned
+  @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
+                  mode should be rejected, FALSE otherwise.
+  @param nr_sat   Pass an integer if the number of saturated pixels should be
+                  returned or NULL otherwise.
+  @return The loaded image.
+  Data type of CPL_TYPE_FLOAT is assumed.
 */
-cpl_image* kmo_dfs_load_image_frame(cpl_frame *frame,
-                                    int device,
-                                    int noise,
-                                    int sat_mode,
-                                    int *nr_sat)
+/*----------------------------------------------------------------------------*/
+cpl_image* kmo_dfs_load_image_frame(
+        cpl_frame   *   frame,
+        int             device,
+        int             noise,
+        int             sat_mode,
+        int         *   nr_sat)
 {
     cpl_image           *img         = NULL;
     int                 index        = 0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frame != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
-        KMO_TRY_ASSURE((noise >= 0) || (noise <= 2),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "noise must be 0, 1 or 2!");
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "device number is negative!");
+        KMO_TRY_ASSURE((noise >= 0) || (noise <= 2), CPL_ERROR_ILLEGAL_INPUT,
+                "noise must be 0, 1 or 2!");
 
         index = kmo_identify_index(cpl_frame_get_filename(frame), device,
                                    noise);
@@ -743,17 +581,12 @@ cpl_image* kmo_dfs_load_image_frame(cpl_frame *frame,
         if (!override_err_msg) {
             KMO_TRY_EXIT_IF_NULL(
                 img = kmclipm_image_load(cpl_frame_get_filename(frame),
-                                         CPL_TYPE_FLOAT,
-                                         0,
-                                         index));
+                    CPL_TYPE_FLOAT, 0, index));
         } else {
                 img = kmclipm_image_load(cpl_frame_get_filename(frame),
-                                         CPL_TYPE_FLOAT,
-                                         0,
-                                         index);
+                        CPL_TYPE_FLOAT, 0, index);
                 cpl_error_reset();
         }
-
         if (sat_mode && (cpl_frame_get_group(frame) == CPL_FRAME_GROUP_RAW)) {
             KMO_TRY_EXIT_IF_ERROR(
                 kmo_dfs_check_saturation(frame, img, TRUE, nr_sat));
@@ -762,7 +595,6 @@ cpl_image* kmo_dfs_load_image_frame(cpl_frame *frame,
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_image_delete(img); img = NULL;
         if (nr_sat != NULL) {
             nr_sat = 0;
@@ -772,51 +604,37 @@ cpl_image* kmo_dfs_load_image_frame(cpl_frame *frame,
     return img;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading cal image data from a given frame.
-
-    @param frame    The input frames.
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    0: the data frame of the device is returned
-                    1: the noise frame of the device is returned
-                    2: the badpix frame of the device is returned
-                    -1: don't care
-    @param angle        NAANGLE
-    @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
-                    mode should be rejected, FALSE otherwise.
-    @param nr_sat   Pass an integer if the number of saturated pixels should be
-                    returned or NULL otherwise.
-    @param angle_found  NAANGLE of returned cal image
-
-    @return The loaded image.
-
-    Data type of CPL_TYPE_FLOAT is assumed.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_image_load(), as they
-    typically are called every time an image should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading cal image data from a given frame.
+  @param frame    The input frames.
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    0: the data frame of the device is returned
+                  1: the noise frame of the device is returned
+                  2: the badpix frame of the device is returned
+                  -1: don't care
+  @param angle        NAANGLE
+  @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
+                  mode should be rejected, FALSE otherwise.
+  @param nr_sat   Pass an integer if the number of saturated pixels should be
+                  returned or NULL otherwise.
+  @param angle_found  NAANGLE of returned cal image
+
+  @return The loaded image.
+  Data type of CPL_TYPE_FLOAT is assumed.
 */
-cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
-                                    int device,
-                                    int noise,
-                                    double angle,
-                                    int sat_mode,
-                                    int *nr_sat,
-                                    double *angle_found,
-                                    int ifu_nr,
-                                    int low_bound,
-                                    int high_bound)
+/*----------------------------------------------------------------------------*/
+cpl_image* kmo_dfs_load_cal_image_frame(
+        cpl_frame   *   frame,
+        int             device,
+        int             noise,
+        double          angle,
+        int             sat_mode,
+        int         *   nr_sat,
+        double      *   angle_found,
+        int             ifu_nr,
+        int             low_bound,
+        int             high_bound)
 {
     cpl_image           *img         = NULL,
                         *img2        = NULL;
@@ -843,34 +661,26 @@ cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frame != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "device number is negative!");
 
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
+        KMO_TRY_EXIT_IF_NULL(tag = cpl_frame_get_tag(frame));
 
-        KMO_TRY_EXIT_IF_NULL(
-            tag = cpl_frame_get_tag(frame));
-
-        if (strcmp(tag, XCAL) == 0) {
-            cal_load_had_xcal = TRUE;
-        }
-        if (strcmp(tag, YCAL) == 0) {
-            cal_load_had_ycal = TRUE;
-        }
+        if (strcmp(tag, XCAL) == 0)     cal_load_had_xcal = TRUE;
+        if (strcmp(tag, YCAL) == 0)     cal_load_had_ycal = TRUE;
 
         if (!override_err_msg) {
             KMO_TRY_EXIT_IF_NULL(
                 img = kmclipm_cal_image_load(cpl_frame_get_filename(frame),
-                                             CPL_TYPE_FLOAT, 0, device, noise,
-                                             angle, angle_found, &secondClosestAngle));
+                    CPL_TYPE_FLOAT, 0, device, noise, angle, angle_found, 
+                    &secondClosestAngle));
             cal_load_first_angle = *angle_found;
         } else {
             img = kmclipm_cal_image_load(cpl_frame_get_filename(frame),
-                                         CPL_TYPE_FLOAT, 0, device, noise,
-                                         angle, angle_found, &secondClosestAngle);
+                    CPL_TYPE_FLOAT, 0, device, noise, angle, angle_found, 
+                    &secondClosestAngle);
             cal_load_first_angle = *angle_found;
             cpl_error_reset();
         }
@@ -880,11 +690,10 @@ cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
                 kmo_dfs_check_saturation(frame, img, TRUE, nr_sat));
         }
 
-        //
-        // load next closest image to interpolate between them
-        //
+        /* Load next closest image to interpolate between them */
         if (ifu_nr > 0 && fabs(*angle_found-secondClosestAngle) > 1.) {
-            if (kmclipm_diff_angle(*angle_found, secondClosestAngle) > 65.) { // 60deg is in fact max. diff
+            if (kmclipm_diff_angle(*angle_found, secondClosestAngle) > 65.) {
+                /* 60deg is in fact max. diff */
                 if (print_xcal_angle_msg_once) {
                     cpl_msg_warning("","************************************************************");
                     cpl_msg_warning("","* xcal-interpolation has been switched off, because the    *");
@@ -897,39 +706,37 @@ cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
                 }
                 ifu_nr = -1;
             } else {
-                // apply xcal-interpolation
+                /* Apply xcal-interpolation */
                 cal_load_second_angle = secondClosestAngle;
 
                 if (!override_err_msg) {
                     KMO_TRY_EXIT_IF_NULL(
-                        img2 = kmclipm_cal_image_load(cpl_frame_get_filename(frame),
-                                                      CPL_TYPE_FLOAT, 0, device, noise,
-                                                      secondClosestAngle, &angle_found2, NULL));
+                        img2 = kmclipm_cal_image_load(
+                            cpl_frame_get_filename(frame), CPL_TYPE_FLOAT, 0, 
+                            device, noise, secondClosestAngle, &angle_found2, 
+                            NULL));
                 } else {
-                    img2 = kmclipm_cal_image_load(cpl_frame_get_filename(frame),
-                                                  CPL_TYPE_FLOAT, 0, device, noise,
-                                                  secondClosestAngle, &angle_found2, NULL);
+                    img2 = kmclipm_cal_image_load(
+                            cpl_frame_get_filename(frame), CPL_TYPE_FLOAT, 0, 
+                            device, noise, secondClosestAngle, &angle_found2, 
+                            NULL);
                     cpl_error_reset();
                 }
 
                 y_img_size = cpl_image_get_size_y(img);
-                KMO_TRY_EXIT_IF_NULL(
-                    img_ptr = cpl_image_get_data_float(img));
-                KMO_TRY_EXIT_IF_NULL(
-                    img2_ptr = cpl_image_get_data_float(img2));
+                KMO_TRY_EXIT_IF_NULL(img_ptr = cpl_image_get_data_float(img));
+                KMO_TRY_EXIT_IF_NULL(img2_ptr = cpl_image_get_data_float(img2));
                 itmp = (high_bound - low_bound + 1) * y_img_size;
                 KMO_TRY_EXIT_IF_NULL(
                     vector_data = cpl_malloc(itmp * sizeof(double)));
 
                 ifu_id = ifu_nr % KMOS_IFUS_PER_DETECTOR;
-                if (ifu_id == 0) {
-                    ifu_id = KMOS_IFUS_PER_DETECTOR;
-                }
+                if (ifu_id == 0)    ifu_id = KMOS_IFUS_PER_DETECTOR;
                 vx =0;
                 for (ix=low_bound; ix <= high_bound; ix++) {
                     for (iy=0; iy < y_img_size; iy++) {
                         kx = iy * y_img_size + ix;
-                        ifu_ix = 10.f * fabsf(img_ptr[kx] - (int)(img_ptr[kx])) + .1f;
+                        ifu_ix=10.f*fabsf(img_ptr[kx]-(int)(img_ptr[kx]))+.1f;
                         if (ifu_id == ifu_ix) {
                             tmp = (int)img_ptr[kx] - (int)img2_ptr[kx];
                             if (!kmclipm_is_nan_or_inf(tmp)) {
@@ -951,7 +758,8 @@ cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
                 if ((angle_found2-angle_x) < -180.) {
                     angle_found2 += 360.;
                 }
-                delta = diff_median * (angle_x - angle_found1) / (angle_found2 - angle_found1);
+                delta = diff_median * (angle_x - angle_found1) / 
+                    (angle_found2 - angle_found1);
                 cpl_msg_debug(__func__,
                         "IFU %2d , valid pixels %d, min %.5g, max %.5g, sigma %.5g, mean %.5g, median %.5g, ang1 %.4g, ang2 %.4g, ang_in %.4g, ang %.4g, delta %.4g",
                         ifu_nr, vx+1,
@@ -965,7 +773,7 @@ cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
                 for (iy=0; iy < y_img_size; iy++) {
                     for (ix=low_bound; ix <= high_bound; ix++) {
                         kx = iy * y_img_size + ix;
-                        ifu_ix = 10.f * fabsf(img_ptr[kx] - (int)(img_ptr[kx])) + .1f;
+                        ifu_ix=10.f*fabsf(img_ptr[kx]-(int)(img_ptr[kx]))+.1f;
                         if (ifu_id == ifu_ix) {
                             if (!kmclipm_is_nan_or_inf(img_ptr[kx])) {
                                 img_ptr[kx] = rintf((int)img_ptr[kx] - delta);
@@ -1007,7 +815,8 @@ cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
                     print_cal_angle_msg_once = FALSE;
                 }
                 if (print_xcal_angle_msg_once) {
-                    cpl_msg_info("", "Loading all calibration frames with angle %ddeg (input: %ddeg)",
+                    cpl_msg_info(__func__, 
+            "Loading all calibration frames with angle %ddeg (input: %ddeg)",
                                  (int)rint(*angle_found), (int)angle);
                     print_xcal_angle_msg_once = FALSE;
                 }
@@ -1017,13 +826,11 @@ cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_image_delete(img); img = NULL;
         if (nr_sat != NULL) {
             nr_sat = 0;
         }
     }
-
     if (img2 != NULL) {cpl_image_delete(img2); img2 = NULL;}
     if (vector != NULL) {cpl_vector_unwrap(vector); vector = NULL;}
     if (vector_data != NULL) {cpl_free(vector_data); vector_data = NULL;}
@@ -1031,91 +838,64 @@ cpl_image* kmo_dfs_load_cal_image_frame(cpl_frame *frame,
     return img;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading image data window (F2I or F2D) from a given frame.
-
-    @param frame    The input frames.
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    0: the data frame of the device is returned
-                    1: the noise frame of the device is returned
-                    2: the badpix frame of the device is returned
-    @param llx      Lower left x position (FITS convention, 1 for leftmost)
-    @param lly      Lower left y position (FITS convention, 1 for lowest)
-    @param urx      Upper right x position (FITS convention)
-    @param ury      Upper right y position (FITS convention)
-    @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
-                    mode should be rejected, FALSE otherwise.
-    @param nr_sat   Pass an integer if the number of saturated pixels should be
-                    returned or NULL otherwise.
-
-    @return The loaded image.
-
-    Data type of CPL_TYPE_FLOAT is assumed.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_image_load(), as they
-    typically are called every time an image should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading image data window (F2I or F2D) from a given frame.
+  @param frame    The input frames.
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    0: the data frame of the device is returned
+                  1: the noise frame of the device is returned
+                  2: the badpix frame of the device is returned
+  @param llx      Lower left x position (FITS convention, 1 for leftmost)
+  @param lly      Lower left y position (FITS convention, 1 for lowest)
+  @param urx      Upper right x position (FITS convention)
+  @param ury      Upper right y position (FITS convention)
+  @param sat_mode TRUE: if saturated pixels in NDR non-destructive readout
+                  mode should be rejected, FALSE otherwise.
+  @param nr_sat   Pass an integer if the number of saturated pixels should be
+                  returned or NULL otherwise.
+  @return The loaded image.
+  Data type of CPL_TYPE_FLOAT is assumed.
 */
-cpl_image* kmo_dfs_load_image_frame_window(cpl_frame *frame,
-                                           int device,
-                                           int noise,
-                                           int llx,
-                                           int lly,
-                                           int urx,
-                                           int ury,
-                                           int sat_mode,
-                                           int *nr_sat)
+/*----------------------------------------------------------------------------*/
+cpl_image* kmo_dfs_load_image_frame_window(
+        cpl_frame   *   frame,
+        int             device,
+        int             noise,
+        int             llx,
+        int             lly,
+        int             urx,
+        int             ury,
+        int             sat_mode,
+        int         *   nr_sat)
 {
     cpl_image   *img    = NULL;
     int         index   = 0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frame != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
-        KMO_TRY_ASSURE((noise >= 0) || (noise <= 2),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "noise must be 0, 1 or 2!");
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "device number is negative!");
+        KMO_TRY_ASSURE((noise >= 0) || (noise <= 2), CPL_ERROR_ILLEGAL_INPUT,
+                "noise must be 0, 1 or 2!");
 
-        index = kmo_identify_index(cpl_frame_get_filename(frame), device,
-                                   noise);
+        index = kmo_identify_index(cpl_frame_get_filename(frame), device,noise);
         KMO_TRY_CHECK_ERROR_STATE();
 
         if (!override_err_msg) {
             KMO_TRY_EXIT_IF_NULL(
                 img = kmclipm_image_load_window(cpl_frame_get_filename(frame),
-                                         CPL_TYPE_FLOAT,
-                                         0,
-                                         index,
-                                         llx, lly, urx, ury));
+                    CPL_TYPE_FLOAT, 0, index, llx, lly, urx, ury));
         } else {
                 img = kmclipm_image_load_window(cpl_frame_get_filename(frame),
-                                         CPL_TYPE_FLOAT,
-                                         0,
-                                         index,
-                                         llx, lly, urx, ury);
+                        CPL_TYPE_FLOAT, 0, index, llx, lly, urx, ury);
                 cpl_error_reset();
         }
 
@@ -1127,7 +907,6 @@ cpl_image* kmo_dfs_load_image_frame_window(cpl_frame *frame,
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_image_delete(img); img = NULL;
         if (nr_sat != NULL) {
             nr_sat = 0;
@@ -1137,42 +916,68 @@ cpl_image* kmo_dfs_load_image_frame_window(cpl_frame *frame,
     return img;
 }
 
+/*----------------------------------------------------------------------------*/
+/**
+  @brief    Load cube data (F3I) 
+  @param frame  The input frame
+  @param device The device number (IFU or detector) to access (first = 1)
+  @param noise  TRUE:  the noise frame of the device is returned
+                FALSE: the data frame of the device is returned
+  @return   The loaded imagelist.
+  Data type of CPL_TYPE_FLOAT is assumed
+ */
+/*----------------------------------------------------------------------------*/
+cpl_imagelist * kmos_dfs_load_cube(
+        cpl_frame   *   frame,
+        int             device,
+        int             noise)
+{
+    cpl_imagelist   *   imglist    = NULL;
+    int                 index       = 0;
+
+    KMO_TRY
+    {
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT, "Null Input");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "Device number is negative");
+        KMO_TRY_ASSURE((noise == 0) || (noise == 1), CPL_ERROR_ILLEGAL_INPUT,
+                "Noise must be 0 or 1");
+
+        index = kmo_identify_index(cpl_frame_get_filename(frame), device,noise);
+        KMO_TRY_CHECK_ERROR_STATE();
+        KMO_TRY_EXIT_IF_NULL(
+            imglist = kmclipm_imagelist_load(cpl_frame_get_filename(frame),
+                CPL_TYPE_FLOAT, index));
+    }
+    KMO_CATCH
+    {
+        if (!override_err_msg)  KMO_CATCH_MSG();
+        cpl_imagelist_delete(imglist); imglist = NULL;
+    }
+    return imglist;
+}
+
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading cube data (F3I) of a given category.
-
-    @param frameset The input set-of-frames
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    TRUE:  the noise frame of the device is returned
-                    FALSE: the data frame of the device is returned
-
-    @return The loaded imagelist.
-
-    Data type of CPL_TYPE_FLOAT is assumed.1
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_imagelist_load(), as they
-    typically are called every time an imagelist should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading cube data (F3I) of a given category.
+  @param frameset The input set-of-frames
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    TRUE:  the noise frame of the device is returned
+                  FALSE: the data frame of the device is returned
+  @return The loaded imagelist.
+  Data type of CPL_TYPE_FLOAT is assumed.1
  */
-cpl_imagelist *kmo_dfs_load_cube(cpl_frameset *frameset,
-                                 const char *category,
-                                 int device,
-                                 int noise)
+/*----------------------------------------------------------------------------*/
+cpl_imagelist *kmo_dfs_load_cube(
+        cpl_frameset    *   frameset,
+        const char      *   category,
+        int                 device,
+        int                 noise)
 {
     cpl_frame       *frame      = NULL;   /* must not be deleted at the end */
     cpl_imagelist   *imglist    = NULL;
@@ -1180,79 +985,55 @@ cpl_imagelist *kmo_dfs_load_cube(cpl_frameset *frameset,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
 
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
-        KMO_TRY_ASSURE((noise == 0) || (noise == 1),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "noise must be 0 or 1!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "device number is negative!");
+        KMO_TRY_ASSURE((noise == 0) || (noise == 1), CPL_ERROR_ILLEGAL_INPUT,
+                "noise must be 0 or 1!");
 
         frame = kmo_dfs_get_frame(frameset, category);
-
         if (frame != NULL) {
             index = kmo_identify_index(cpl_frame_get_filename(frame), device,
-                                    noise);
+                    noise);
             KMO_TRY_CHECK_ERROR_STATE();
 
             KMO_TRY_EXIT_IF_NULL(
                 imglist = kmclipm_imagelist_load(cpl_frame_get_filename(frame),
-                                                 CPL_TYPE_FLOAT,
-                                                 index));
+                    CPL_TYPE_FLOAT, index));
         }
     }
     KMO_CATCH
     {
-        if (!override_err_msg) {
-            KMO_CATCH_MSG();
-        }
-
+        if (!override_err_msg)  KMO_CATCH_MSG();
         cpl_imagelist_delete(imglist); imglist = NULL;
     }
-
     return imglist;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Loading table of a given category.
-
-    @param frameset The input set-of-frames
-    @param category The category of the image to load. Either a keyword or a
-                    string containing an integer designating the position of the
-                    frame in the frameset to load (first = "0"). If NULL, the
-                    next frame with same keyword as accessed right before will
-                    be returned
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    TRUE:  the noise frame of the device is returned
-                    FALSE: the data frame of the device is returned
-
-    @return The loaded imagelist.
-
-    Data type of CPL_TYPE_FLOAT is assumed.1
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_frameset_find() and @c cpl_imagelist_load(), as they
-    typically are called every time an imagelist should be loaded
-    by a recipe. Error checking and proper messaging are also
-    included here, to give a more readable look to the main
-    recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Loading table of a given category.
+  @param frameset The input set-of-frames
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    TRUE:  the noise frame of the device is returned
+                  FALSE: the data frame of the device is returned
+
+  @return The loaded imagelist.
+  Data type of CPL_TYPE_FLOAT is assumed.1
  */
-cpl_table *kmo_dfs_load_table(cpl_frameset *frameset,
-                                 const char *category,
-                                 int device,
-                                 int noise)
+/*----------------------------------------------------------------------------*/
+cpl_table * kmo_dfs_load_table(
+        cpl_frameset    *   frameset,
+        const char      *   category,
+        int                 device,
+        int                 noise)
 {
     cpl_frame       *frame      = NULL;   /* must not be deleted at the end */
     cpl_table       *table    = NULL;
@@ -1260,100 +1041,84 @@ cpl_table *kmo_dfs_load_table(cpl_frameset *frameset,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
-        KMO_TRY_ASSURE(device >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
-        KMO_TRY_ASSURE((noise == 0) || (noise == 1),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "noise must be 0 or 1!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
+        KMO_TRY_ASSURE(device >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                "device number is negative!");
+        KMO_TRY_ASSURE((noise == 0) || (noise == 1), CPL_ERROR_ILLEGAL_INPUT,
+                "noise must be 0 or 1!");
 
         frame = kmo_dfs_get_frame(frameset, category);
-
         if (frame != NULL) {
             index = kmo_identify_index(cpl_frame_get_filename(frame), device,
-                                    noise);
+                    noise);
             KMO_TRY_CHECK_ERROR_STATE();
 
             KMO_TRY_EXIT_IF_NULL(
                 table = kmclipm_table_load(cpl_frame_get_filename(frame),
-                                           index,
-                                           0));
+                    index, 0));
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
         cpl_table_delete(table); table = NULL;
     }
-
     return table;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Generate output filename..
-
-    Add suffix, category etc..
-
-    @param path      The path to save the file to
-    @param category  The category to save the file with.
-    @param suffix    Any suffix to the category.
-
-    @return the filename, has to be deallocated again.
+  @brief Generate output filename..
+  @param path      The path to save the file to
+  @param category  The category to save the file with.
+  @param suffix    Any suffix to the category.
+  @return the filename, has to be deallocated again.
+  Add suffix, category etc..
 */
-char* kmo_dfs_create_filename(const char *path,
-                              const char *category,
-                              const char *suffix)
+/*----------------------------------------------------------------------------*/
+char* kmo_dfs_create_filename(
+        const char  *   path,
+        const char  *   category,
+        const char  *   suffix)
 {
     char             *filename  = NULL,
                      *tmpstr    = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((path != NULL) &&
-                       (category != NULL) &&
-                       (suffix != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((path != NULL) && (category != NULL) && (suffix != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         // setup path
-        KMO_TRY_EXIT_IF_NULL(
-            tmpstr = cpl_sprintf("%s", category));
+        KMO_TRY_EXIT_IF_NULL(tmpstr = cpl_sprintf("%s", category));
         strlower(tmpstr);
         KMO_TRY_EXIT_IF_NULL(
             filename = cpl_sprintf("%s%s%s%s", path, tmpstr, suffix, ".fits"));
         cpl_free(tmpstr); tmpstr = NULL;
         KMO_TRY_CHECK_ERROR_STATE();
-
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
         cpl_free(filename); filename = NULL;
     }
-
     return filename;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Generate suffix for output filename.
-
-    @param frame   The frame to get the grating and rotator angle from.
-    @param grating TRUE if grating information should be added, FALSE otherwise.
-    @param angle   TRUE if angle information should be added, FALSE otherwise.
-
-    @return the resulting filename suffix, has to be deallocated again.
+  @brief Generate suffix for output filename.
+  @param frame   The frame to get the grating and rotator angle from.
+  @param grating TRUE if grating information should be added, FALSE otherwise.
+  @param angle   TRUE if angle information should be added, FALSE otherwise.
+  @return the resulting filename suffix, has to be deallocated again.
 */
-char* kmo_dfs_get_suffix(const cpl_frame *frame,
-                         int grating,
-                         int angle)
+/*----------------------------------------------------------------------------*/
+char* kmo_dfs_get_suffix(
+        const cpl_frame     *   frame,
+        int                     grating,
+        int                     angle)
 {
     cpl_propertylist    *main_header    = NULL;
     const char          *tmp_str        = NULL;
@@ -1364,25 +1129,23 @@ char* kmo_dfs_get_suffix(const cpl_frame *frame,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frame != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         KMO_TRY_ASSURE(((grating == FALSE)||(grating == TRUE)) &&
-                       ((angle == FALSE)||(angle == TRUE)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "grating and angle must be either TRUE or FALSE!");
+                ((angle == FALSE)||(angle == TRUE)), CPL_ERROR_ILLEGAL_INPUT,
+                "grating and angle must be either TRUE or FALSE!");
 
         // load primary header
-        main_header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
+        main_header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 
+                0);
         if (cpl_error_get_code() != CPL_ERROR_NONE) {
-            cpl_msg_error("","File not found: %s!",
-                          cpl_frame_get_filename(frame));
+            cpl_msg_error(__func__,"File not found: %s!",
+                    cpl_frame_get_filename(frame));
             KMO_TRY_CHECK_ERROR_STATE();
         }
 
-        KMO_TRY_EXIT_IF_NULL(
-            suffix = cpl_calloc(256, sizeof(char)));
+        KMO_TRY_EXIT_IF_NULL(suffix = cpl_calloc(256, sizeof(char)));
         strcpy(suffix, "");
 
         if (grating) {
@@ -1391,12 +1154,12 @@ char* kmo_dfs_get_suffix(const cpl_frame *frame,
             int i = 0;
             for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
                 KMO_TRY_EXIT_IF_NULL(
-                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, i, IFU_GRATID_POSTFIX));
+                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, i, 
+                        IFU_GRATID_POSTFIX));
                 tmp_str = cpl_propertylist_get_string(main_header, keyword);
-                KMO_TRY_ASSURE(tmp_str != NULL,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, cpl_frame_get_filename(frame));
+                KMO_TRY_ASSURE(tmp_str != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!", keyword, 
+                        cpl_frame_get_filename(frame));
                 cpl_free(keyword); keyword = NULL;
 
                 // add grating to suffix
@@ -1411,10 +1174,9 @@ char* kmo_dfs_get_suffix(const cpl_frame *frame,
                 keyword = cpl_sprintf("%s", ROTANGLE));
             tmp_dbl = cpl_propertylist_get_double(main_header, keyword);
             if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                KMO_TRY_ASSURE(1 == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, cpl_frame_get_filename(frame));
+                KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!", keyword, 
+                        cpl_frame_get_filename(frame));
             }
 
             // strip angles below 0 deg and above 360 deg
@@ -1439,44 +1201,30 @@ char* kmo_dfs_get_suffix(const cpl_frame *frame,
     return suffix;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Saving a propertylist as (empty) header.
-
-    @param frameset   The input set-of-frames (to be upgraded)
-    @param filename   The filename of the image to save
-    @param suffix     The filter/grating-suffix to append to filename.
-    @param frame      The frame to inherit the header from.
-    @param header     Heaqder to append
-    @param parlist    The parlist
-    @param recipename The name of the recipe
-
-    @return CPL_ERROR_NONE in case of success.
-
-    This function is just a wrapper to the basic CPL functions
-    that are routinely called every time an image product must
-    be saved to disk by a recipe. Error checking and proper
-    messaging are also included here, to give a more readable
-    look to the main recipe code.
-
-    The output file name will be derived from the specified
-    filename by lowercasing it and by appending the suffix ".fits".
-    The new image is properly logged in the input set-of-frames
-    in case of success.
-
-    The error codes that are set in this case are the same set
-    by the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Saving a propertylist as (empty) header.
+  @param frameset   The input set-of-frames (to be upgraded)
+  @param filename   The filename of the image to save
+  @param suffix     The filter/grating-suffix to append to filename.
+  @param frame      The frame to inherit the header from.
+  @param header     Heaqder to append
+  @param parlist    The parlist
+  @param recipename The name of the recipe
+  @return CPL_ERROR_NONE in case of success.
+  The output file name will be derived from the specified filename by 
+  lowercasing it and by appending the suffix ".fits".  The new image is 
+  properly logged in the input set-of-frames in case of success.
 */
-cpl_error_code kmo_dfs_save_main_header(cpl_frameset *frameset,
-                                        const char *filename,
-                                        const char *suffix,
-                                        const cpl_frame *frame,
-                                        const cpl_propertylist *header,
-                                        const cpl_parameterlist *parlist,
-                                        const char *recipename)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_dfs_save_main_header(
+        cpl_frameset            *   frameset,
+        const char              *   filename,
+        const char              *   suffix,
+        const cpl_frame         *   frame,
+        const cpl_propertylist  *   header,
+        const cpl_parameterlist *   parlist,
+        const char              *   recipename)
 {
     char                *filenameAll    = NULL,
                         *clean_suffix   = NULL;
@@ -1485,18 +1233,12 @@ cpl_error_code kmo_dfs_save_main_header(cpl_frameset *frameset,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((frameset != NULL) &&
-                       (filename != NULL) &&
-                       (suffix != NULL) &&
-                       (parlist != NULL) &&
-                       (recipename != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((frameset != NULL) && (filename != NULL) && 
+                (suffix != NULL) && (parlist != NULL) && (recipename != NULL), 
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         // remove unwanted characters from suffix
-        KMO_TRY_EXIT_IF_NULL(
-            clean_suffix = cpl_sprintf("%s", suffix));
-
+        KMO_TRY_EXIT_IF_NULL(clean_suffix = cpl_sprintf("%s", suffix));
         kmo_clean_string(clean_suffix);
 
         // setup path
@@ -1505,32 +1247,22 @@ cpl_error_code kmo_dfs_save_main_header(cpl_frameset *frameset,
 
         // add PRO.CATG keyword
         if (header == NULL) {
-            KMO_TRY_EXIT_IF_NULL(
-                tmp_header = cpl_propertylist_new());
+            KMO_TRY_EXIT_IF_NULL(tmp_header = cpl_propertylist_new());
         } else {
-            KMO_TRY_EXIT_IF_NULL(
-                tmp_header = cpl_propertylist_duplicate(header));
+            KMO_TRY_EXIT_IF_NULL(tmp_header=cpl_propertylist_duplicate(header));
         }
 
         KMO_TRY_EXIT_IF_ERROR(
             cpl_propertylist_update_string(tmp_header, CPL_DFS_PRO_CATG,
-                                           filename));
+                filename));
 
         KMO_TRY_EXIT_IF_ERROR(
-            cpl_propertylist_update_string(tmp_header, INSTRUMENT,
-                                           "KMOS"));
-        // save first empty primary header
+            cpl_propertylist_update_string(tmp_header, INSTRUMENT, "KMOS"));
+
+        /* Save first empty primary header */
         KMO_TRY_EXIT_IF_ERROR(
-            cpl_dfs_save_propertylist(frameset,
-                                      NULL,
-                                      parlist,
-                                      frameset,
-                                      frame,
-                                      recipename,
-                                      tmp_header,
-                                      NULL,
-                                      VERSION,
-                                      filenameAll));
+            cpl_dfs_save_propertylist(frameset, NULL, parlist, frameset, frame,
+                recipename, tmp_header, NULL, VERSION, filenameAll));
 
         cpl_propertylist_delete(tmp_header); tmp_header = NULL;
     }
@@ -1539,43 +1271,24 @@ cpl_error_code kmo_dfs_save_main_header(cpl_frameset *frameset,
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_free(filenameAll); filenameAll = NULL;
     cpl_free(clean_suffix); clean_suffix = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Saving a propertylist as extension header.
-
-    @param category   The category of the image to save (is also name of file)
-    @param suffix     The filter/grating-suffix to append to filename.
-    @param header     The header to save.
-
-    @return CPL_ERROR_NONE in case of success.
-
-    This function is just a wrapper to the basic CPL functions
-    that are routinely called every time an image product must
-    be saved to disk by a recipe. Error checking and proper
-    messaging are also included here, to give a more readable
-    look to the main recipe code.
-
-    The output file name will be derived from the specified
-    category by lowercasing it and by appending the suffix ".fits".
-    The new image is properly logged in the input set-of-frames
-    in case of success.
-
-    The error codes that are set in this case are the same set
-    by the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Saving a propertylist as extension header.
+  @param category   The category of the image to save (is also name of file)
+  @param suffix     The filter/grating-suffix to append to filename.
+  @param header     The header to save.
+  @return CPL_ERROR_NONE in case of success.
 */
-cpl_error_code kmo_dfs_save_sub_header(const char *category,
-                                       const char *suffix,
-                                       const cpl_propertylist *header)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_dfs_save_sub_header(
+        const char              *   category,
+        const char              *   suffix,
+        const cpl_propertylist  *   header)
 {
     char            *filename       = NULL,
                     *clean_suffix   = NULL;
@@ -1583,16 +1296,12 @@ cpl_error_code kmo_dfs_save_sub_header(const char *category,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((category != NULL) &&
-                       (suffix != NULL) &&
-                       (header != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((category != NULL) && (suffix != NULL) &&
+                (header != NULL), CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         // remove unwanted characters from suffix
-        KMO_TRY_EXIT_IF_NULL(
-            clean_suffix = cpl_sprintf("%s", suffix));
-
+        KMO_TRY_EXIT_IF_NULL(clean_suffix = cpl_sprintf("%s", suffix));
         kmo_clean_string(clean_suffix);
 
         // setup path
@@ -1607,51 +1316,31 @@ cpl_error_code kmo_dfs_save_sub_header(const char *category,
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_free(filename); filename = NULL;
     cpl_free(clean_suffix); clean_suffix = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Saving vector data of given category.
-
-    @param vec        The vector to save
-    @param category   The category of the image to save (is also name of file)
-    @param suffix     The filter/grating-suffix to append to filename.
-    @param header     Header to save with vector.
-    @param rej_val    The rejected values are filled with this value.
-                      If -1 is provided, the rejected values in the internal
-                      cpl-bad pixel mask are ignored.
-
-    @return CPL_ERROR_NONE in case of success.
-
-    Data type is always CPL_TYPE_FLOAT.
-
-    This function is just a wrapper to the basic CPL functions
-    that are routinely called every time an image product must
-    be saved to disk by a recipe. Error checking and proper
-    messaging are also included here, to give a more readable
-    look to the main recipe code.
-
-    The output file name will be derived from the specified
-    category by lowercasing it and by appending the suffix ".fits".
-    The new image is properly logged in the input set-of-frames
-    in case of success.
-
-    The error codes that are set in this case are the same set
-    by the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Saving vector data of given category.
+  @param vec        The vector to save
+  @param category   The category of the image to save (is also name of file)
+  @param suffix     The filter/grating-suffix to append to filename.
+  @param header     Header to save with vector.
+  @param rej_val    The rejected values are filled with this value.
+                    If -1 is provided, the rejected values in the internal
+                    cpl-bad pixel mask are ignored.
+  @return CPL_ERROR_NONE in case of success.
+  Data type is always CPL_TYPE_FLOAT.
 */
-cpl_error_code     kmo_dfs_save_vector(kmclipm_vector *vec,
-                                       const char *category,
-                                       const char *suffix,
-                                       cpl_propertylist *header,
-                                       double rej_val)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_dfs_save_vector(
+        kmclipm_vector      *   vec,
+        const char          *   category,
+        const char          *   suffix,
+        cpl_propertylist    *   header,
+        double                  rej_val)
 {
     char            *filename       = NULL,
                     *clean_suffix   = NULL;
@@ -1659,15 +1348,11 @@ cpl_error_code     kmo_dfs_save_vector(kmclipm_vector *vec,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((category != NULL) &&
-                       (suffix != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((category != NULL) && (suffix != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         // remove unwanted characters from suffix
-        KMO_TRY_EXIT_IF_NULL(
-            clean_suffix = cpl_sprintf("%s", suffix));
-
+        KMO_TRY_EXIT_IF_NULL(clean_suffix = cpl_sprintf("%s", suffix));
         kmo_clean_string(clean_suffix);
 
         // setup path
@@ -1683,7 +1368,7 @@ cpl_error_code     kmo_dfs_save_vector(kmclipm_vector *vec,
             // save subsequent data
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_vector_save(vec, filename, CPL_BPP_IEEE_FLOAT, header,
-                                    CPL_IO_EXTEND, rej_val));
+                    CPL_IO_EXTEND, rej_val));
         }
     }
     KMO_CATCH
@@ -1691,51 +1376,31 @@ cpl_error_code     kmo_dfs_save_vector(kmclipm_vector *vec,
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_free(filename); filename = NULL;
     cpl_free(clean_suffix); clean_suffix = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Saving image data of given category.
-
-    @param image      The image to save
-    @param category   The category of the image to save (is also name of file)
-    @param suffix     The filter/grating-suffix to append to filename.
-    @param header     Header to save image with.
-    @param rej_val    The rejected values are filled with this value.
-                      If -1 is provided, the rejected values in the internal
-                      cpl-bad pixel mask are ignored.
-
-    @return CPL_ERROR_NONE in case of success.
-
-    Data type is always CPL_TYPE_FLOAT.
-
-    This function is just a wrapper to the basic CPL functions
-    that are routinely called every time an image product must
-    be saved to disk by a recipe. Error checking and proper
-    messaging are also included here, to give a more readable
-    look to the main recipe code.
-
-    The output file name will be derived from the specified
-    category by lowercasing it and by appending the suffix ".fits".
-    The new image is properly logged in the input set-of-frames
-    in case of success.
-
-    The error codes that are set in this case are the same set
-    by the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Saving image data of given category.
+  @param image      The image to save
+  @param category   The category of the image to save (is also name of file)
+  @param suffix     The filter/grating-suffix to append to filename.
+  @param header     Header to save image with.
+  @param rej_val    The rejected values are filled with this value.
+                    If -1 is provided, the rejected values in the internal
+                    cpl-bad pixel mask are ignored.
+  @return CPL_ERROR_NONE in case of success.
+  Data type is always CPL_TYPE_FLOAT.
 */
-cpl_error_code kmo_dfs_save_image(cpl_image *image,
-                                  const char *category,
-                                  const char *suffix,
-                                  cpl_propertylist *header,
-                                  double rej_val)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_dfs_save_image(
+        cpl_image           *   image,
+        const char          *   category,
+        const char          *   suffix,
+        cpl_propertylist    *   header,
+        double                  rej_val)
 {
     char            *filename       = NULL,
                     *clean_suffix   = NULL;
@@ -1743,15 +1408,11 @@ cpl_error_code kmo_dfs_save_image(cpl_image *image,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((category != NULL) &&
-                       (suffix != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((category != NULL) && (suffix != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         // remove unwanted characters from suffix
-        KMO_TRY_EXIT_IF_NULL(
-            clean_suffix = cpl_sprintf("%s", suffix));
-
+        KMO_TRY_EXIT_IF_NULL(clean_suffix = cpl_sprintf("%s", suffix));
         kmo_clean_string(clean_suffix);
 
         // setup path
@@ -1767,7 +1428,7 @@ cpl_error_code kmo_dfs_save_image(cpl_image *image,
             // save subsequent data
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_image_save(image, filename, CPL_BPP_IEEE_FLOAT, header,
-                                   CPL_IO_EXTEND, rej_val));
+                    CPL_IO_EXTEND, rej_val));
         }
     }
     KMO_CATCH
@@ -1775,51 +1436,31 @@ cpl_error_code kmo_dfs_save_image(cpl_image *image,
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_free(filename); filename = NULL;
     cpl_free(clean_suffix); clean_suffix = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Saving imagelist data of given category.
-
-    @param imglist    The imagelist to save
-    @param category   The category of the image to save (is also name of file)
-    @param suffix     The filter/grating-suffix to append to filename.
-    @param header     Header to save cube with.
-    @param rej_val    The rejected values are filled with this value.
-                      If -1 is provided, the rejected values in the internal
-                      cpl-bad pixel mask are ignored.
-
-    @return CPL_ERROR_NONE in case of success.
-
-    Data type is always CPL_TYPE_FLOAT.
-
-    This function is just a wrapper to the basic CPL functions
-    that are routinely called every time an image product must
-    be saved to disk by a recipe. Error checking and proper
-    messaging are also included here, to give a more readable
-    look to the main recipe code.
-
-    The output file name will be derived from the specified
-    category by lowercasing it and by appending the suffix ".fits".
-    The new image is properly logged in the input set-of-frames
-    in case of success.
-
-    The error codes that are set in this case are the same set
-    by the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Saving imagelist data of given category.
+  @param imglist    The imagelist to save
+  @param category   The category of the image to save (is also name of file)
+  @param suffix     The filter/grating-suffix to append to filename.
+  @param header     Header to save cube with.
+  @param rej_val    The rejected values are filled with this value.
+                    If -1 is provided, the rejected values in the internal
+                    cpl-bad pixel mask are ignored.
+  @return CPL_ERROR_NONE in case of success.
+  Data type is always CPL_TYPE_FLOAT.
 */
-cpl_error_code kmo_dfs_save_cube(cpl_imagelist *imglist,
-                                 const char *category,
-                                 const char *suffix,
-                                 cpl_propertylist *header,
-                                 double rej_val)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_dfs_save_cube(
+        cpl_imagelist       *   imglist,
+        const char          *   category,
+        const char          *   suffix,
+        cpl_propertylist    *   header,
+        double                  rej_val)
 {
     char            *filename       = NULL,
                     *clean_suffix   = NULL;
@@ -1827,15 +1468,11 @@ cpl_error_code kmo_dfs_save_cube(cpl_imagelist *imglist,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((category != NULL) &&
-                       (suffix != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((category != NULL) && (suffix != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         // remove unwanted characters from suffix
-        KMO_TRY_EXIT_IF_NULL(
-            clean_suffix = cpl_sprintf("%s", suffix));
-
+        KMO_TRY_EXIT_IF_NULL(clean_suffix = cpl_sprintf("%s", suffix));
         kmo_clean_string(clean_suffix);
 
         // setup path
@@ -1851,7 +1488,7 @@ cpl_error_code kmo_dfs_save_cube(cpl_imagelist *imglist,
             // save subsequent data
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_imagelist_save(imglist, filename, CPL_BPP_IEEE_FLOAT,
-                                       header, CPL_IO_EXTEND, rej_val));
+                    header, CPL_IO_EXTEND, rej_val));
         }
     }
     KMO_CATCH
@@ -1859,47 +1496,27 @@ cpl_error_code kmo_dfs_save_cube(cpl_imagelist *imglist,
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_free(filename); filename = NULL;
     cpl_free(clean_suffix); clean_suffix = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Saving table of given category.
-
-    @param table      The table to save
-    @param category   The category of the image to save (is also name of file)
-    @param suffix     The filter/grating-suffix to append to filename.
-    @param header     Header to save table with
-
-    @return CPL_ERROR_NONE in case of success.
-
-    Data type is always CPL_TYPE_FLOAT.
-
-    This function is just a wrapper to the basic CPL functions
-    that are routinely called every time an image product must
-    be saved to disk by a recipe. Error checking and proper
-    messaging are also included here, to give a more readable
-    look to the main recipe code.
-
-    The output file name will be derived from the specified
-    category by lowercasing it and by appending the suffix ".fits".
-    The new image is properly logged in the input set-of-frames
-    in case of success.
-
-    The error codes that are set in this case are the same set
-    by the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
+  @brief Saving table of given category.
+  @param table      The table to save
+  @param category   The category of the image to save (is also name of file)
+  @param suffix     The filter/grating-suffix to append to filename.
+  @param header     Header to save table with
+  @return CPL_ERROR_NONE in case of success.
+  Data type is always CPL_TYPE_FLOAT.
 */
-cpl_error_code kmo_dfs_save_table(cpl_table *table,
-                                  const char *category,
-                                  const char *suffix,
-                                  cpl_propertylist *header)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_dfs_save_table(
+        cpl_table           *   table,
+        const char          *   category,
+        const char          *   suffix,
+        cpl_propertylist    *   header)
 {
     char            *filename       = NULL,
                     *clean_suffix   = NULL;
@@ -1907,15 +1524,11 @@ cpl_error_code kmo_dfs_save_table(cpl_table *table,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((category != NULL) &&
-                       (suffix != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((category != NULL) && (suffix != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         // remove unwanted characters from suffix
-        KMO_TRY_EXIT_IF_NULL(
-            clean_suffix = cpl_sprintf("%s", suffix));
-
+        KMO_TRY_EXIT_IF_NULL(clean_suffix = cpl_sprintf("%s", suffix));
         kmo_clean_string(clean_suffix);
 
         // setup path
@@ -1938,1499 +1551,1296 @@ cpl_error_code kmo_dfs_save_table(cpl_table *table,
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_free(filename); filename = NULL;
     cpl_free(clean_suffix); clean_suffix = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Reading a recipe boolean parameter value.
-
-    @param parlist   The input parameter list.
-    @param name      The parameter name.
-
-    @return The parameter value.
-
-    This function is just a wrapper to the basic CPL function
-    @c cpl_parameter_get_bool() .
+  @brief Prints the actual value of the property together with the help string
+  @param parlist   The input parameter list.
+  @param name      The parameter name.
 */
-int kmo_dfs_get_parameter_bool(cpl_parameterlist *parlist, const char *name)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_dfs_print_parameter_help(
+        cpl_parameterlist   *   parlist,
+        const char          *   name)
 {
     cpl_parameter   *param      = NULL;
-    int             ret_val     = INT_MIN;
+    cpl_error_code  ret_err     = CPL_ERROR_NONE;
+    const char      *alias      = NULL;
 
     KMO_TRY
     {
         KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
-        KMO_TRY_EXIT_IF_NULL(
-            param = cpl_parameterlist_find(parlist, name));
+                CPL_ERROR_NULL_INPUT, "Not all input data provided!");
+        KMO_TRY_EXIT_IF_NULL(param = cpl_parameterlist_find(parlist, name));
 
-        KMO_TRY_ASSURE(cpl_parameter_get_type(param) == CPL_TYPE_BOOL,
-                       CPL_ERROR_INVALID_TYPE,
-                       "Unexpected type for parameter %s: it should be boolean",
-                       name);
+        alias = cpl_parameter_get_alias(param, CPL_PARAMETER_MODE_CLI);
+        KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_EXIT_IF_ERROR(
-            ret_val = cpl_parameter_get_bool(param));
+        if (cpl_parameter_get_type(param) == CPL_TYPE_STRING) {
+            cpl_msg_info(__func__, "%s: %s (%s)", alias,
+                    cpl_parameter_get_string(param),
+                    cpl_parameter_get_help(param));
+        } else if (cpl_parameter_get_type(param) == CPL_TYPE_INT) {
+            cpl_msg_info(__func__, "%s: %d (%s)", alias,
+                    cpl_parameter_get_int(param),
+                    cpl_parameter_get_help(param));
+        } else if (cpl_parameter_get_type(param) == CPL_TYPE_DOUBLE) {
+            cpl_msg_info(__func__, "%s: %g (%s)", alias,
+                    cpl_parameter_get_double(param),
+                    cpl_parameter_get_help(param));
+        } else if (cpl_parameter_get_type(param) == CPL_TYPE_BOOL) {
+            cpl_msg_info(__func__, "%s: %d (%s)", alias,
+                    cpl_parameter_get_bool(param),
+                    cpl_parameter_get_help(param));
+        } else {
+            KMO_TRY_ERROR_SET_MSG(CPL_ERROR_INVALID_TYPE,
+                    "Unhandled parameter type.");
+        }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
-        ret_val = INT_MIN;
+        ret_err = cpl_error_get_code();
     }
-
-    return ret_val;
+    return ret_err;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Reading a recipe integer parameter value.
-
-    @param parlist   The input parameter list.
-    @param name      The parameter name.
-
-    @return The parameter value.
-
-    This function is just a wrapper to the basic CPL function
-    @c cpl_parameter_get_int() .
+  @brief Extracts type, id and content of an EXTNAME keyword.
+  @param extname    The EXTNAME keyword.
+  @param type       (Output) Frame type (ifu_frame or detector_frame)
+  @param id         (Output) The number of the device (first = 1).
+  @param content    (Output) The content of the data section belonging to 
+                    the header which will be updated with the resulting string.
+                    Valid values are DATA, NOISE or BADPIX.
+  @return CPL_ERROR_NONE in case of success.
+  Possible error codes:
+  CPL_ERROR_NULL_INPUT  if any of the inputs are NULL
 */
-int kmo_dfs_get_parameter_int(cpl_parameterlist *parlist, const char *name)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_extname_extractor(
+        const char          *   extname,
+        enum kmo_frame_type *   type,
+        int                 *   id,
+        char                *   content)
 {
-    cpl_parameter   *param      = NULL;
-    int             ret_val     = INT_MIN;
+    cpl_error_code  ret_error       = CPL_ERROR_NONE;
+    char            **split_values  = NULL;
+    int             size            = 0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
-        KMO_TRY_EXIT_IF_NULL(
-            param = cpl_parameterlist_find(parlist, name));
-
-        KMO_TRY_ASSURE(cpl_parameter_get_type(param) == CPL_TYPE_INT,
-                       CPL_ERROR_INVALID_TYPE,
-                       "Unexpected type for parameter %s: it should be integer",
-                       name);
-
-        KMO_TRY_EXIT_IF_ERROR(
-            ret_val = cpl_parameter_get_int(param));
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-
-        ret_val = INT_MIN;
-    }
-
-    return ret_val;
-}
-
-/**
-    @brief
-      Reading a recipe double parameter value.
+        KMO_TRY_ASSURE((extname != NULL) && (strcmp(extname, "") != 0) &&
+                (type != NULL) && (id != NULL) && (content != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data are provided!");
 
-    @param parlist   The input parameter list.
-    @param name      The parameter name.
-
-    @return The parameter value.
+        // Split
+        KMO_TRY_EXIT_IF_NULL(split_values = kmo_strsplit(extname, ".", &size));
 
-    This function is just a wrapper to the basic CPL function
-    @c cpl_parameter_get_double() .
-*/
-double kmo_dfs_get_parameter_double(cpl_parameterlist *parlist,
-                                    const char *name)
-{
-    cpl_parameter   *param      = NULL;
-    double          ret_val     = -DBL_MAX;
+        if (strcmp(split_values[0], "LIST_IFU") == 0) {
+            strcpy(split_values[0], EXT_LIST);
+            size = 1;
+        }
 
-    KMO_TRY
-    {
-        KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+        // Extract
+        switch (size) {
+        case 1:
+            *id = -1;
+            *type = list_frame;
+            strcpy(content, split_values[0]);
 
-        KMO_TRY_EXIT_IF_NULL(
-            param = cpl_parameterlist_find(parlist, name));
+            KMO_TRY_ASSURE(strcmp(content, EXT_LIST) == 0,
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "EXTNAME has bad content: %s (must be LIST!)", content);
+            break;
+        case 2:
+            *id = 1;
+            strcpy(content, split_values[1]);
+            KMO_TRY_ASSURE((strcmp(content, EXT_DATA) == 0) ||
+                    (strcmp(content, EXT_NOISE) == 0), CPL_ERROR_ILLEGAL_INPUT,
+                    "EXTNAME has bad content: %s (either DATA or NOISE!",
+                    content);
+            break;
+        case 3:
+            *id = atoi(split_values[1]);
+            strcpy(content, split_values[2]);
+            KMO_TRY_ASSURE((strcmp(content, EXT_DATA) == 0) ||
+                    (strcmp(content, EXT_NOISE) == 0) ||
+                    (strcmp(content, EXT_BADPIX) == 0),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "EXTNAME has bad content: %s (DATA, NOISE or BADPIX)!", 
+                    content);
+            break;
+        default:
+            KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "EXTNAME must have 3 fields like \"IFU.3.DATA\" or 2 fields like \"IFU.NOISE\"!");
+            break;
+        }
 
-        KMO_TRY_ASSURE(cpl_parameter_get_type(param) == CPL_TYPE_DOUBLE,
-                       CPL_ERROR_INVALID_TYPE,
-                       "Unexpected type for parameter %s: it should be double",
-                       name);
+        if (size > 1) {
+            if (strcmp(split_values[0], "DET") == 0) {
+                *type = detector_frame;
 
-        KMO_TRY_EXIT_IF_ERROR(
-            ret_val = cpl_parameter_get_double(param));
+                KMO_TRY_ASSURE((*id >=1) && (*id <= KMOS_NR_DETECTORS),
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "A detector frame can only have an ID between 1 and 3");
+            } else if (strcmp(split_values[0], "IFU") == 0) {
+                *type = ifu_frame;
+                if ((*id < 1) || (*id > KMOS_NR_IFUS)) {
+                    *type = illegal_frame;
+                    /* Try to recover from this afterwards */
+                }
+            } else {
+                *type = illegal_frame;
+            }
+        }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
-        ret_val = -DBL_MAX;
+        ret_error = cpl_error_get_code();
+        cpl_free(content); content = NULL;
+        *type = illegal_frame;
+        *id = -1;
     }
-
-    return ret_val;
+    kmo_strfreev(split_values); split_values = NULL;
+    return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Reading a recipe string parameter value.
-
-    @param parlist   The input parameter list.
-    @param name      The parameter name.
-
-    @return The parameter value.
-
-    This function is just a wrapper to the basic CPL function
-    @c cpl_parameter_get_string() .
+  @brief Creates the string needed to write into EXTNAME keyword.
+  @param type         Frame type (ifu_frame or detector_frame)
+  @param device_nr    The number of the device (first = 1).
+  @param content      The content of the data section belonging to the header
+                      which will be updated with the resulting string. Valid
+                      values are DATA, NOISE or BADPIX.
+  @return The EXTNAME string in case of success, NULL, otherwise.
+                      Must be freed!
 */
-const char* kmo_dfs_get_parameter_string(cpl_parameterlist *parlist,
-                                         const char *name)
+/*----------------------------------------------------------------------------*/
+char * kmo_extname_creator(
+        enum kmo_frame_type     type,
+        int                     device_nr,
+        const char          *   content)
 {
-    cpl_parameter   *param      = NULL;
-    const char      *ret_val    = NULL;
-
+    char            *ret_string     = NULL;
     KMO_TRY
     {
-        KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+        KMO_TRY_ASSURE(content != NULL, CPL_ERROR_NULL_INPUT,
+                "No input data is provided!");
 
-        KMO_TRY_EXIT_IF_NULL(
-            param = cpl_parameterlist_find(parlist, name));
+        KMO_TRY_ASSURE((type == detector_frame) || (type == ifu_frame) ||
+                (type == spectrum_frame) || (type == list_frame),
+                CPL_ERROR_ILLEGAL_INPUT, "Wrong frame type");
 
-        KMO_TRY_ASSURE(cpl_parameter_get_type(param) == CPL_TYPE_STRING,
-                       CPL_ERROR_INVALID_TYPE,
-                       "Unexpected type for parameter %s: it should be string",
-                       name);
+        KMO_TRY_ASSURE(((strcmp(content, EXT_DATA) == 0) ||
+                    (strcmp(content, EXT_NOISE) == 0) ||
+                    (strcmp(content, EXT_BADPIX) == 0) ||
+                    (strcmp(content, EXT_LIST) == 0) ||
+                    (strcmp(content, EXT_SPEC) == 0)),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "content must be either DATA, NOISE, BADPIX, LIST or SPEC");
 
-        KMO_TRY_EXIT_IF_ERROR(
-            ret_val = cpl_parameter_get_string(param));
+        if ((type == detector_frame) || (type == ifu_frame)) {
+            if (type == detector_frame) {
+                KMO_TRY_ASSURE((device_nr > 0) && 
+                        (device_nr <= KMOS_NR_DETECTORS),
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "dev_nr must be greater than 0 and smaller than 3");
+                KMO_TRY_EXIT_IF_NULL(
+                    ret_string = cpl_sprintf("DET.%d.%s", device_nr, content));
+            } else {
+                KMO_TRY_ASSURE((device_nr > 0) && (device_nr <= KMOS_NR_IFUS),
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "dev_nr must be greater than 0 and smaller than 24");
+                KMO_TRY_EXIT_IF_NULL(
+                    ret_string = cpl_sprintf("IFU.%d.%s", device_nr, content));
+            }
+        } else if (type == spectrum_frame) {
+            KMO_TRY_EXIT_IF_NULL(ret_string = cpl_sprintf("%s", EXT_SPEC));
+        } else if (type == list_frame) {
+            KMO_TRY_EXIT_IF_NULL(ret_string = cpl_sprintf("%s", EXT_LIST));
+        } else {
+            KMO_TRY_ASSURE(1==0, CPL_ERROR_ILLEGAL_INPUT,
+                    "frame type not supported");
+        }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
-        ret_val = NULL;
+        cpl_free(ret_string); ret_string = NULL;
     }
-
-    return ret_val;
+    return ret_string;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Prints the actual value of the property together with the help string.
-
-    @param parlist   The input parameter list.
-    @param name      The parameter name.
-
+  @brief Updates the fits-keywords of subsequent extensions after the primary
+      (empty) extension.
+  @param pl           The propertylist to update.
+  @param is_noise     TRUE if extension contains noise,
+                      FALSE if it containsdata.
+  @param is_badpix    TRUE if extension contains badpix-frame,
+                      FALSE if it containsdata.
+  @param type         Frame type (ifu_frame or detector_frame)
+  @param device_nr    The number of the device (first = 1).
+
+  @return CPL_ERROR_NONE in case of success.
+
+  This function updates (or creates) the keywords needed in extensions to
+  vectors, images and imagelists in this pipeline.
+
+  This function is just a wrapper to the basic CPL functions
+  @c cpl_propertylist_update_bool() and @c cpl_propertylist_update_int() .
+  Error checking and proper messaging are also included here, to give
+  a more readable look to the main recipe code.
 */
-cpl_error_code kmo_dfs_print_parameter_help(cpl_parameterlist *parlist,
-                                            const char *name)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_update_sub_keywords(
+        cpl_propertylist    *   pl,
+        int                     is_noise,
+        int                     is_badpix,
+        enum kmo_frame_type     type,
+        int                     device_nr)
 {
-    cpl_parameter   *param      = NULL;
-    cpl_error_code  ret_err     = CPL_ERROR_NONE;
-    const char      *alias      = NULL;
+    cpl_error_code  ret_error   = CPL_ERROR_NONE;
+    char            *extname = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
-        KMO_TRY_EXIT_IF_NULL(
-            param = cpl_parameterlist_find(parlist, name));
+        KMO_TRY_ASSURE(pl != NULL, CPL_ERROR_NULL_INPUT,
+                "No input data is provided!");
 
-        alias = cpl_parameter_get_alias(param, CPL_PARAMETER_MODE_CLI);
-        KMO_TRY_CHECK_ERROR_STATE();
+        KMO_TRY_ASSURE((is_noise == TRUE) || (is_noise == FALSE),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "is_noise must be TRUE or FALSE (1 or 0)!");
+        KMO_TRY_ASSURE((is_badpix == TRUE) || (is_badpix == FALSE),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "is_badpix must be TRUE or FALSE (1 or 0)!");
+        KMO_TRY_ASSURE(!(is_noise && is_badpix), CPL_ERROR_ILLEGAL_INPUT,
+                "Badpix and noise can't be TRUE at the same time!");
 
-        if (cpl_parameter_get_type(param) == CPL_TYPE_STRING) {
-            cpl_msg_info("", "%s: %s (%s)", alias,
-                         cpl_parameter_get_string(param),
-                         cpl_parameter_get_help(param));
-        } else if (cpl_parameter_get_type(param) == CPL_TYPE_INT) {
-            cpl_msg_info("", "%s: %d (%s)", alias,
-                         cpl_parameter_get_int(param),
-                         cpl_parameter_get_help(param));
-        } else if (cpl_parameter_get_type(param) == CPL_TYPE_DOUBLE) {
-            cpl_msg_info("", "%s: %g (%s)", alias,
-                         cpl_parameter_get_double(param),
-                         cpl_parameter_get_help(param));
-        } else if (cpl_parameter_get_type(param) == CPL_TYPE_BOOL) {
-            cpl_msg_info("", "%s: %d (%s)", alias,
-                         cpl_parameter_get_bool(param),
-                         cpl_parameter_get_help(param));
+        if (is_noise == TRUE) {
+            KMO_TRY_EXIT_IF_NULL(
+                extname = kmo_extname_creator(type, device_nr, EXT_NOISE));
+        } else if (is_badpix == TRUE) {
+            KMO_TRY_EXIT_IF_NULL(
+                extname = kmo_extname_creator(type, device_nr, EXT_BADPIX));
         } else {
-            KMO_TRY_ERROR_SET_MSG(CPL_ERROR_INVALID_TYPE,
-                                  "Unhandled parameter type.");
+            KMO_TRY_EXIT_IF_NULL(
+                extname = kmo_extname_creator(type, device_nr, EXT_DATA));
         }
+
+        KMO_TRY_EXIT_IF_ERROR(
+            cpl_propertylist_update_string(pl, EXTNAME, extname));
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-        ret_err = cpl_error_get_code();
+        ret_error = cpl_error_get_code();
     }
-
-    return ret_err;
+    cpl_free(extname); extname = NULL;
+    return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Reading a propertylists boolean parameter value.
+  @brief Gets the number of the ifu of a specified frame by OCS target name.
+  @param frame    The input frame to examine.
+  @param ocs_name The target name as assigned by the OCS.
+  @return The extracted IFU number.
+  There will only be a valid output if there exists a corresponding IFU number
+  in EXTNAME and ESO OCS ARMx NAME.
+ */
+/*----------------------------------------------------------------------------*/
+int kmo_get_index_from_ocs_name(
+        const cpl_frame     *   frame,
+        const char          *   ocs_name)
+{
+    int                 i       = 1,
+                        found   = FALSE,
+                        id      = -1,
+                        is_raw  = 1,
+                        j       = 0;
+
+    cpl_propertylist    *pl     = NULL;
 
-    @param header    The property list of a frame.
-    @param keyword   The property keyword.
+    const char          *fname  = NULL,
+                        *extname= NULL;
 
-    @return The property value.
+    char                *tmp_ocs = NULL,
+                        content[256];
 
-    This function is just a wrapper to the basic CPL function
-    @c cpl_property_get_bool() .
-*/
-int kmo_dfs_get_property_bool(cpl_propertylist *header, const char *keyword)
-{
-    int         ret_val = INT_MIN;
+    enum kmo_frame_type ft      = illegal_frame;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((header != NULL) && (keyword != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
+        KMO_TRY_ASSURE(cpl_frame_get_nextensions(frame) > 0, 
+                CPL_ERROR_ILLEGAL_INPUT, 
+                "Frame must have at least one extension!");
+        KMO_TRY_EXIT_IF_NULL(fname = cpl_frame_get_filename(frame));
 
-        KMO_TRY_ASSURE(cpl_propertylist_has(header, keyword) != 0,
-                       CPL_ERROR_DATA_NOT_FOUND,
-                       "Wrong property keyword: %s", keyword);
+        // check if it is a RAW frame or an already processed frame
+        KMO_TRY_EXIT_IF_NULL(pl = kmclipm_propertylist_load(fname, 0));
 
-        KMO_TRY_ASSURE(cpl_propertylist_get_type(header, keyword) ==
-                                                               CPL_TYPE_BOOL,
-                       CPL_ERROR_INVALID_TYPE,
-                       "Unexpected type for property %s: it should be boolean",
-                       keyword);
-
-        KMO_TRY_EXIT_IF_ERROR(
-            ret_val = cpl_propertylist_get_bool(header, keyword));
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-
-        ret_val = INT_MIN;
-    }
-
-    return ret_val;
-}
+        if (cpl_propertylist_has(pl, CPL_DFS_PRO_CATG))     is_raw = 0;
+        cpl_propertylist_delete(pl); pl = NULL;
 
-/**
-    @brief
-      Reading a propertylists integer parameter value.
+        if (!is_raw) {
+            /* Frame is already processed */
+            while ((!found) && (i <= cpl_frame_get_nextensions(frame))) {
+                KMO_TRY_EXIT_IF_NULL(pl = kmclipm_propertylist_load(fname, i));
+                KMO_TRY_EXIT_IF_NULL(
+                    extname = cpl_propertylist_get_string(pl, EXTNAME));
+                KMO_TRY_EXIT_IF_ERROR(
+                    kmo_extname_extractor(extname, &ft, &id, content));
+                KMO_TRY_EXIT_IF_NULL(
+                    tmp_ocs = cpl_sprintf("%s%d%s", IFU_NAME_PREFIX, id, 
+                        IFU_NAME_POSTFIX));
 
-    @param header    The property list of a frame.
-    @param keyword   The property keyword.
+                if (cpl_propertylist_has(pl, tmp_ocs)) {
+                    KMO_TRY_EXIT_IF_NULL(
+                        extname = cpl_propertylist_get_string(pl, tmp_ocs));
 
-    @return The property value.
+                    if (strcmp(extname, ocs_name) == 0)     found = TRUE;
+                    else                                    id = -1;
+                }
+                cpl_free(tmp_ocs); tmp_ocs = NULL;
+                cpl_propertylist_delete(pl); pl = NULL;
+                i++;
+            }
+        } else {
+            /* Frame is a RAW frame */
+            KMO_TRY_EXIT_IF_NULL(pl = kmclipm_propertylist_load(fname, 0));
 
-    This function is just a wrapper to the basic CPL function
-    @c cpl_property_get_int() .
-*/
-int kmo_dfs_get_property_int(cpl_propertylist *header, const char *keyword)
-{
-    int         ret_val = INT_MIN;
+            id = 1;
+            for (j = 1; j <= KMOS_NR_IFUS; j++) {
+                KMO_TRY_EXIT_IF_NULL(
+                    tmp_ocs = cpl_sprintf("%s%d%s", IFU_NAME_PREFIX, id, 
+                        IFU_NAME_POSTFIX));
 
-    KMO_TRY
-    {
-        KMO_TRY_ASSURE((header != NULL) && (keyword != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+                KMO_TRY_ASSURE(cpl_propertylist_has(pl, tmp_ocs) == 1,
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "Primary header of frame %s doesn't have keyword '%s'!",
+                        fname, tmp_ocs);
 
-        KMO_TRY_ASSURE(cpl_propertylist_has(header, keyword) != 0,
-                       CPL_ERROR_DATA_NOT_FOUND,
-                       "Wrong property keyword: %s", keyword);
+                KMO_TRY_EXIT_IF_NULL(
+                    extname = cpl_propertylist_get_string(pl, tmp_ocs));
 
-        KMO_TRY_ASSURE(cpl_propertylist_get_type(header, keyword) ==
-                                                               CPL_TYPE_INT,
-                       CPL_ERROR_INVALID_TYPE,
-                       "Unexpected type for property %s: it should be integer",
-                       keyword);
+                cpl_free(tmp_ocs); tmp_ocs = NULL;
 
-        KMO_TRY_EXIT_IF_ERROR(
-            ret_val = cpl_propertylist_get_int(header, keyword));
+                if (strcmp(extname, ocs_name) == 0) {
+                    found = TRUE;
+                    break;
+                } else {
+                    id++;
+                }
+            }
+            if (!found)     id = -1;
+            cpl_propertylist_delete(pl); pl = NULL;
+        }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
-        ret_val = INT_MIN;
+        id = -1;
+        cpl_free(tmp_ocs); tmp_ocs = NULL;
     }
-
-    return ret_val;
+    cpl_propertylist_delete(pl); pl = NULL;
+    return id;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Reading a propertylists double parameter value.
+  @brief Gets the name of the ifu of a specified frame by OCS IFUnr.
+  @param frame    The input frame to examine.
+  @param ifu_nr   The IFU to investigate.
+  @return The extracted IFU number.
+  There will only be a valid output if there exists a corresponding IFU number
+  in EXTNAME and ESO OCS ARMx NAME.
+ */
+/*----------------------------------------------------------------------------*/
+char* kmo_get_name_from_ocs_ifu(
+        const cpl_frame     *   frame,
+        int                     ifu_nr)
+{
+    int                 is_raw  = 1;
 
-    @param header    The property list of a frame.
-    @param keyword   The property keyword.
+    cpl_propertylist    *pl     = NULL;
 
-    @return The property value.
+    const char          *fname  = NULL,
+                        *extname= NULL;
 
-    This function is just a wrapper to the basic CPL function
-    @c cpl_property_get_double() .
-*/
-double kmo_dfs_get_property_double(const cpl_propertylist *header,
-                                   const char *keyword)
-{
-    double      ret_val = -DBL_MAX;
+    char                *tmp_ocs = NULL,
+                        content[256],
+                        *id      = NULL;
+
+    enum kmo_frame_type ft      = illegal_frame;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((header != NULL) && (keyword != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+        KMO_TRY_ASSURE(frame != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
+        KMO_TRY_ASSURE(cpl_frame_get_nextensions(frame) > 0,
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Frame must have at least one extension!");
 
-        KMO_TRY_ASSURE(cpl_propertylist_has(header, keyword) != 0,
-                       CPL_ERROR_DATA_NOT_FOUND,
-                       "Wrong property keyword: %s", keyword);
+        KMO_TRY_EXIT_IF_NULL(fname = cpl_frame_get_filename(frame));
 
-        KMO_TRY_ASSURE(cpl_propertylist_get_type(header, keyword) ==
-                                                               CPL_TYPE_DOUBLE,
-                       CPL_ERROR_INVALID_TYPE,
-                       "Unexpected type for property %s: it should be double",
-                       keyword);
+        // check if it is a RAW frame or an already processed frame
+        KMO_TRY_EXIT_IF_NULL(pl = kmclipm_propertylist_load(fname, 0));
 
-        KMO_TRY_EXIT_IF_ERROR(
-            ret_val = cpl_propertylist_get_double(header, keyword));
+        if (cpl_propertylist_has(pl, CPL_DFS_PRO_CATG))     is_raw = 0;
+        cpl_propertylist_delete(pl); pl = NULL;
+
+        if (!is_raw) {
+            // frame is already processed
+            KMO_TRY_EXIT_IF_NULL(pl = kmclipm_propertylist_load(fname, ifu_nr));
+            KMO_TRY_EXIT_IF_NULL(
+                extname = cpl_propertylist_get_string(pl, EXTNAME));
+            KMO_TRY_EXIT_IF_ERROR(
+                kmo_extname_extractor(extname, &ft, &ifu_nr, content));
+            KMO_TRY_EXIT_IF_NULL(tmp_ocs = cpl_sprintf("%s%d%s", 
+                        IFU_NAME_PREFIX, ifu_nr, IFU_NAME_POSTFIX));
+
+            if (cpl_propertylist_has(pl, tmp_ocs)) {
+                KMO_TRY_EXIT_IF_NULL(
+                    extname = cpl_propertylist_get_string(pl, tmp_ocs));
+                KMO_TRY_EXIT_IF_NULL(id = cpl_sprintf("%s", extname));
+            }
+            cpl_free(tmp_ocs); tmp_ocs = NULL;
+            cpl_propertylist_delete(pl); pl = NULL;
+        } else {
+            // frame is a RAW frame
+            KMO_TRY_EXIT_IF_NULL(pl = kmclipm_propertylist_load(fname, 0));
+            KMO_TRY_EXIT_IF_NULL( tmp_ocs = cpl_sprintf("%s%d%s",
+                        IFU_NAME_PREFIX, ifu_nr, IFU_NAME_POSTFIX));
+
+            if (cpl_propertylist_has(pl, tmp_ocs)) {
+                KMO_TRY_EXIT_IF_NULL(
+                    extname = cpl_propertylist_get_string(pl, tmp_ocs));
+                KMO_TRY_EXIT_IF_NULL(id = cpl_sprintf("%s", extname));
+            }
+            cpl_free(tmp_ocs); tmp_ocs = NULL;
+            cpl_propertylist_delete(pl); pl = NULL;
+        }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
-        ret_val = -DBL_MAX;
+        id = NULL;
     }
-
-    return ret_val;
+    cpl_free(tmp_ocs); tmp_ocs = NULL;
+    cpl_propertylist_delete(pl); pl = NULL;
+    return id;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-      Reading a propertylists string parameter value.
-
-    @param header    The property list of a frame.
-    @param keyword   The property keyword.
-
-    @return The property value.
-
-    This function is just a wrapper to the basic CPL function
-    @c cpl_property_get_int() .
+  @brief Identifies the extension with given noise and device number.
+  @param filename The filename of a fits file to examine.
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    0: the data frame of the device is returned
+                  1:  the noise frame of the device is returned
+                  2: the bad pixel mask of the device  is returned
+  @return The index of the extension to load.
+  This is a helper function needed in kmo_dfs_load_vector, kmo_dfs_load_image,
+  kmo_dfs_load_cube.
 */
-const char* kmo_dfs_get_property_string(cpl_propertylist *header,
-                                        const char *keyword)
+/*----------------------------------------------------------------------------*/
+int kmo_identify_index(const char *filename, int device, int noise)
 {
-    const char  *ret_val = NULL;
+    main_fits_desc  desc;
+    int             index       = -1;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((header != NULL) && (keyword != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
-        KMO_TRY_ASSURE(cpl_propertylist_has(header, keyword) != 0,
-                       CPL_ERROR_DATA_NOT_FOUND,
-                       "Wrong property keyword: %s", keyword);
-
-        KMO_TRY_ASSURE(cpl_propertylist_get_type(header, keyword) ==
-                                                               CPL_TYPE_STRING,
-                       CPL_ERROR_INVALID_TYPE,
-                       "Unexpected type for property %s: it should be string",
-                       keyword);
-
-        KMO_TRY_EXIT_IF_NULL(
-            ret_val = cpl_propertylist_get_string(header, keyword));
+        kmo_init_fits_desc(&desc);
+        desc = kmo_identify_fits_header(filename);
+        KMO_TRY_CHECK_ERROR_STATE();
+        index = kmo_identify_index_desc(desc, device, noise);
+        KMO_TRY_CHECK_ERROR_STATE();
     }
     KMO_CATCH
     {
-        KMO_CATCH_MSG();
-
-        ret_val = NULL;
+        if (!override_err_msg) {
+            KMO_CATCH_MSG();
+        }
+        index = -1;
     }
-
-    return ret_val;
+    kmo_free_fits_desc(&desc);
+    return index;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Extracts type, id and content of an EXTNAME keyword.
-
-    @param extname      The EXTNAME keyword.
-    @param type         (Output) Frame type (ifu_frame or detector_frame)
-    @param id           (Output) The number of the device (first = 1).
-    @param content      (Output) The content of the data section belonging to the header
-                        which will be updated with the resulting string. Valid
-                        values are DATA, NOISE or BADPIX.
-
-    @return CPL_ERROR_NONE in case of success.
-
-    Possible error codes:
-    CPL_ERROR_NULL_INPUT  if any of the inputs are NULL
-
+  @brief Identifies the extension with given noise and device number.
+  @param desc     The fits descriptor to examine.
+  @param device   The device number (IFU or detector) to access (first = 1)
+  @param noise    0: the data frame of the device is returned
+                  1:  the noise frame of the device is returned
+                  2: the bad pixel mask of the device  is returned
+  @return The index of the extension to load.
+  This is a helper function.
 */
-cpl_error_code kmo_extname_extractor(const char *extname,
-                                     enum kmo_frame_type *type,
-                                     int *id,
-                                     char *content)
+/*----------------------------------------------------------------------------*/
+int kmo_identify_index_desc(const main_fits_desc desc, int device, int noise)
 {
-    cpl_error_code  ret_error       = CPL_ERROR_NONE;
-
-    char            **split_values  = NULL;
-
-    int             size            = 0;
-
+    int             i           = 0,
+                    index       = -1;
     KMO_TRY
     {
-        KMO_TRY_ASSURE((extname != NULL) &&
-                       (strcmp(extname, "") != 0) &&
-                       (type != NULL) &&
-                       (id != NULL) &&
-                       (content != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data are provided!");
-
-        // Split
-        KMO_TRY_EXIT_IF_NULL(
-            split_values = kmo_strsplit(extname, ".", &size));
-
-        if (strcmp(split_values[0], "LIST_IFU") == 0) {
-            strcpy(split_values[0], EXT_LIST);
-            size = 1;
-        }
-
-        // Extract
-        switch (size) {
-        case 1:
-            *id = -1;
-            *type = list_frame;
-            strcpy(content, split_values[0]);
-
-            KMO_TRY_ASSURE(strcmp(content, EXT_LIST) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "EXTNAME has bad content: %s (must be LIST!)",
-                           content);
-            break;
-        case 2:
-            *id = 1;
-
-            strcpy(content, split_values[1]);
-
-            KMO_TRY_ASSURE((strcmp(content, EXT_DATA) == 0) ||
-                           (strcmp(content, EXT_NOISE) == 0),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "EXTNAME has bad content: %s (either DATA or NOISE!",
-                           content);
-            break;
-        case 3:
-            *id = atoi(split_values[1]);
-
-            strcpy(content, split_values[2]);
-
-            KMO_TRY_ASSURE((strcmp(content, EXT_DATA) == 0) ||
-                           (strcmp(content, EXT_NOISE) == 0) ||
-                           (strcmp(content, EXT_BADPIX) == 0),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "EXTNAME has bad content: %s (either DATA, NOISE or "
-                           "BADPIX)!", content);
-            break;
-        default:
-            KMO_TRY_ASSURE(1 == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "EXTNAME must have 3 fields like \"IFU.3.DATA\" or "
-                           "2 fields like \"IFU.NOISE\"!");
-            break;
+        if (noise == 2) {
+            KMO_TRY_ASSURE(desc.ex_badpix != 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "The fits-descriptor doesn't contain any badpixel mask");
         }
 
-        if (size > 1) {
-            if (strcmp(split_values[0], "DET") == 0) {
-                *type = detector_frame;
-
-                KMO_TRY_ASSURE((*id >=1) && (*id <= KMOS_NR_DETECTORS),
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "A detector frame can only have an ID between 1 and 3!");
-            } else if (strcmp(split_values[0], "IFU") == 0) {
-                *type = ifu_frame;
-                if ((*id < 1) || (*id > KMOS_NR_IFUS)) {
-                    *type = illegal_frame;
-                                    // try to recover from this afterwards
-                }
-//                KMO_TRY_ASSURE((*id >=1) && (*id <= KMOS_NR_IFUS),
-//                               CPL_ERROR_ILLEGAL_INPUT,
-//                               "An ifu frame can only have an ID between 1 and 24!");
+        if (((desc.fits_type == f2d_fits)||(desc.fits_type == b2d_fits)) &&
+                (((desc.nr_ext > 3) && (desc.ex_noise==0)) ||
+                 ((desc.nr_ext > 6) && (desc.ex_noise==1)) ||
+                 ((desc.nr_ext > 3) && (desc.ex_badpix==1)))) {
+            // handling calibration format with all rotator angles in one file
+            // Attention, here we depend on the order of data and noise frames!
+            if ((desc.ex_noise == 0) || (desc.ex_badpix == 1)){
+                index = device;
             } else {
-                *type = illegal_frame;
-                // try to recover from this afterwards
-//                KMO_TRY_ERROR_SET_MSG(CPL_ERROR_ILLEGAL_INPUT,
-//                                      "Type in EXTNAME is wrong (either DET or IFU)!");
-            }
-        }
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-        ret_error = cpl_error_get_code();
-        cpl_free(content); content = NULL;
-        *type = illegal_frame;
-        *id = -1;
-//        kmo_strfreev(split_values);
-    }
+                if (noise) {
+                    index = 2*device;
+                } else {
+                    index = 2*device-1;
+                }
+            }
+            switch (noise) {
+                case 0:         // data
+                    if ((desc.sub_desc[i].is_noise == 0) &&
+                        (desc.sub_desc[i].is_badpix == 0)) {
+                        index = device;
+                    }
+                    break;
+                case 1:         // noise
+                    if ((desc.sub_desc[i].is_noise == 1) &&
+                        (desc.sub_desc[i].is_badpix == 0)) {
+                        index = desc.sub_desc[i].ext_nr;
+                    }
+                    break;
+                case 2:         // badpix
+                    if ((desc.sub_desc[i].is_noise == 0) &&
+                        (desc.sub_desc[i].is_badpix == 1)) {
+                        index = desc.sub_desc[i].ext_nr;
+                    }
+                    break;
+            }
+        } else {
+            // old way...
+            // search for matching device_nr
+            for (i = 0; i < desc.nr_ext; i++) {
+                if (desc.sub_desc[i].device_nr == device) {
+                    switch (noise) {
+                        case 0:         // data
+                            if ((desc.sub_desc[i].is_noise == 0) &&
+                                (desc.sub_desc[i].is_badpix == 0)) {
+                                index = desc.sub_desc[i].ext_nr;
+                            }
+                            break;
+                        case 1:         // noise
+                            if ((desc.sub_desc[i].is_noise == 1) &&
+                                (desc.sub_desc[i].is_badpix == 0)) {
+                                index = desc.sub_desc[i].ext_nr;
+                            }
+                            break;
+                        case 2:         // badpix
+                            if ((desc.sub_desc[i].is_noise == 0) &&
+                                (desc.sub_desc[i].is_badpix == 1)) {
+                                index = desc.sub_desc[i].ext_nr;
+                            }
+                            break;
+                    }
 
-    kmo_strfreev(split_values); split_values = NULL;
+                    if (index > -1) {
+                        break;
+                    }
+                }
+            } // end for (i)
 
-    return ret_error;
-}
+            if (index == -1) {
+                // index is still invalid, try to search for matching ext_nr
+                // (works, if device=1)
+                for (i = 0; i < desc.nr_ext; i++) {
+                    if (desc.sub_desc[i].ext_nr == device) {
+                        switch (noise) {
+                            case 0:         // data
+                                if ((desc.sub_desc[i].is_noise == 0) &&
+                                    (desc.sub_desc[i].is_badpix == 0)) {
+                                    index = desc.sub_desc[i].ext_nr;
+                                }
+                                break;
+                            case 1:         // noise
+                                if ((desc.sub_desc[i].is_noise == 1) &&
+                                    (desc.sub_desc[i].is_badpix == 0)) {
+                                    index = desc.sub_desc[i].ext_nr;
+                                }
+                                break;
+                            case 2:         // badpix
+                                if ((desc.sub_desc[i].is_noise == 0) &&
+                                    (desc.sub_desc[i].is_badpix == 1)) {
+                                    index = desc.sub_desc[i].ext_nr;
+                                }
+                                break;
+                        }
 
-/**
-    @brief
-        Creates the string needed to write into EXTNAME keyword.
+                        if (index > -1) {
+                            break;
+                        }
+                    }
+                } // end for (i)
+
+                if (index == -1) {
+                    // index is still invalid, try to search for matching ext_nr
+                    // (works, if device=1 AND noise = 1)
+                    for (i = 0; i < desc.nr_ext; i++) {
+                        if (desc.sub_desc[i].ext_nr == device+noise) {
+                            switch (noise) {
+                                case 0:         // data
+                                    if ((desc.sub_desc[i].is_noise == 0) &&
+                                        (desc.sub_desc[i].is_badpix == 0)) {
+                                        index = desc.sub_desc[i].ext_nr;
+                                    }
+                                    break;
+                                case 1:         // noise
+                                    if ((desc.sub_desc[i].is_noise == 1) &&
+                                        (desc.sub_desc[i].is_badpix == 0)) {
+                                        index = desc.sub_desc[i].ext_nr;
+                                    }
+                                    break;
+                                case 2:         // badpix
+                                    if ((desc.sub_desc[i].is_noise == 0) &&
+                                        (desc.sub_desc[i].is_badpix == 1)) {
+                                        index = desc.sub_desc[i].ext_nr;
+                                    }
+                                    break;
+                            }
 
-    @param type         Frame type (ifu_frame or detector_frame)
-    @param device_nr    The number of the device (first = 1).
-    @param content      The content of the data section belonging to the header
-                        which will be updated with the resulting string. Valid
-                        values are DATA, NOISE or BADPIX.
+                            if (index > -1) {
+                                break;
+                            }
+                        }
+                    } // end for (i)
+                } // end if (index)
+            } // end if (index)
+        }
 
-    @return The EXTNAME string in case of success, NULL, otherwise.
-                        Must be freed!
-*/
-char* kmo_extname_creator(enum kmo_frame_type type,
-                          int device_nr,
-                          const char *content)
+        KMO_TRY_ASSURE(index != -1, CPL_ERROR_ILLEGAL_INPUT,
+                "The provided device-number is greater than the actual "
+                "number of devices (%d, %d)!", device, desc.nr_ext);
+    }
+    KMO_CATCH
+    {
+        if (!override_err_msg) {
+            KMO_CATCH_MSG();
+        }
+        index = -1;
+    }
+    return index;
+}
+
+/*----------------------------------------------------------------------------*/
+/**
+  @brief    Set the group as RAW or CALIB in a frameset
+  @param    frameset         the input frameset
+  @param    recipe_name      the recipe name
+  @return   TRUE if ok, FALSE in error case
+ */
+/*----------------------------------------------------------------------------*/
+int kmo_dfs_set_groups(cpl_frameset *frameset, const char *recipe_name)
 {
-    char            *ret_string     = NULL;
+    int             ret         = FALSE,
+                    nframes     = 0,
+                    i           = 0;
+    cpl_frame       *cur_frame  = NULL;
+    const char      *tag        = NULL;
+    main_fits_desc  desc;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(content != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
+        KMO_TRY_ASSURE((frameset != NULL) || (recipe_name != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all data provided");
 
-        KMO_TRY_ASSURE((type == detector_frame) ||
-                       (type == ifu_frame) ||
-                       (type == spectrum_frame) ||
-                       (type == list_frame),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "wrong frame type!");
+        // Initialize
+        nframes = cpl_frameset_get_size(frameset) ;
 
-        KMO_TRY_ASSURE(((strcmp(content, EXT_DATA) == 0) ||
-                        (strcmp(content, EXT_NOISE) == 0) ||
-                        (strcmp(content, EXT_BADPIX) == 0) ||
-                        (strcmp(content, EXT_LIST) == 0) ||
-                        (strcmp(content, EXT_SPEC) == 0)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "content must be either DATA, NOISE, BADPIX, LIST "
-                       "or SPEC!");
+        // Loop on frames
+        for (i = 0 ; i < nframes ; i++) {
+            cur_frame = cpl_frameset_get_position(frameset, i);
+            tag = cpl_frame_get_tag(cur_frame);
+            if (!strcmp(tag, COMMANDLINE)               ||
+                !strcmp(recipe_name, "kmo_arithmetic")  ||
+                !strcmp(recipe_name, "kmo_reconstruct") ||
+                !strcmp(recipe_name, "kmo_stats")) {
+                 kmo_init_fits_desc(&desc);
+                 desc = kmo_identify_fits_header(
+                         cpl_frame_get_filename(cur_frame));
+                 KMO_TRY_CHECK_ERROR_STATE_MSG("Wrong File Format") ;
 
-        if ((type == detector_frame) || (type == ifu_frame)) {
-            if (type == detector_frame) {
-                KMO_TRY_ASSURE((device_nr > 0) && (device_nr <= KMOS_NR_DETECTORS),
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "dev_nr must be greater than 0 and smaller than 3!");
-                KMO_TRY_EXIT_IF_NULL(
-                    ret_string = cpl_sprintf("DET.%d.%s", device_nr, content));
-            } else {
-                KMO_TRY_ASSURE((device_nr > 0) && (device_nr <= KMOS_NR_IFUS),
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "dev_nr must be greater than 0 and smaller than 24!");
-                KMO_TRY_EXIT_IF_NULL(
-                    ret_string = cpl_sprintf("IFU.%d.%s", device_nr, content));
+                 if (desc.fits_type == raw_fits) {
+                     cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_RAW);
+                 } else {
+                     // should in fact be CPL_FRAME_GROUP_PRODUCT, but then
+                     // cpl_dfs_save_propertylist() fails...
+                     cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_CALIB);
+                 }
+                 ret = TRUE;
+                 kmo_free_fits_desc(&desc);
+            } else if (!strcmp(recipe_name, "kmo_combine")      ||
+                       !strcmp(recipe_name, "kmo_copy")         ||
+                       !strcmp(recipe_name, "kmo_extract_spec") ||
+                       !strcmp(recipe_name, "kmo_fit_profile")  ||
+                       !strcmp(recipe_name, "kmo_fits_strip")  ||
+                       !strcmp(recipe_name, "kmo_make_image")   ||
+                       !strcmp(recipe_name, "kmo_rotate")       ||
+                       !strcmp(recipe_name, "kmo_shift")        ||
+                       !strcmp(recipe_name, "kmo_sky_tweak")    ||
+                       !strcmp(recipe_name, "kmo_sky_mask")) {
+                // should in fact be CPL_FRAME_GROUP_PRODUCT, but then
+                // cpl_dfs_save_propertylist() fails...
+                cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_CALIB);
+                ret = TRUE;
+            } else if (!strcmp(recipe_name, "kmo_noise_map")) {
+                  cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_RAW);
+                  ret = TRUE;
+            } else if (!strcmp(tag, DARK)  || !strcmp(tag, FLAT_ON)  ||
+                    !strcmp(tag, FLAT_OFF) || !strcmp(tag, ARC_ON)   ||
+                    !strcmp(tag, ARC_OFF)  || !strcmp(tag, FLAT_SKY) ||
+                    !strcmp(tag, STD)      || !strcmp(tag, SCIENCE)) { 
+                 // set group as RAW
+                 cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_RAW);
+                 ret = TRUE;
+
+                // Check if the RAW file is valid for the current recipe
+                if (!strcmp(recipe_name, "kmo_dark") && strcmp(tag, DARK)) {
+                    cpl_msg_error(__func__, 
+                            "The tag %s is invalid for the recipe %s",
+                            tag, recipe_name) ;
+                    ret = FALSE;
+                }
+                if (!strcmp(recipe_name, "kmo_flat") &&
+                        (strcmp(tag, FLAT_ON) != 0) &&
+                        (strcmp(tag, FLAT_OFF) != 0)) {
+                    cpl_msg_error(__func__, 
+                            "The tag %s is invalid for the recipe %s",
+                            tag, recipe_name) ;
+                    ret = FALSE;
+                }
+                if (!strcmp(recipe_name, "kmo_wave_cal") &&
+                    (strcmp(tag, ARC_ON) != 0) &&
+                    (strcmp(tag, ARC_OFF) != 0)) {
+                    cpl_msg_error(__func__, 
+                            "The tag %s is invalid for the recipe %s", 
+                            tag, recipe_name) ;
+                    ret = FALSE;
+                }
+                if (!strcmp(recipe_name, "kmo_illumination") &&
+                    strcmp(tag, FLAT_SKY)) {
+                    cpl_msg_error(__func__, 
+                            "The tag %s is invalid for the recipe %s", 
+                            tag, recipe_name) ;
+                    ret = FALSE;
+                }
+                if (!strcmp(recipe_name, "kmo_std_star") && strcmp(tag, STD)) {
+                    cpl_msg_error(__func__, 
+                            "The tag %s is invalid for the recipe %s", 
+                            tag, recipe_name) ;
+                    ret = FALSE;
+                }
+                if (!strcmp(recipe_name,"kmo_sci_red") && strcmp(tag,SCIENCE)){
+                    cpl_msg_error(__func__, 
+                            "The tag %s is invalid for the recipe %s", 
+                            tag, recipe_name) ;
+                    ret = FALSE;
+                }
+            // CALIB frames
+            } else if (!strcmp(tag, BADPIXEL_DARK)    ||
+                       !strcmp(tag, MASTER_FLAT)      ||
+                       !strcmp(tag, XCAL)             ||
+                       !strcmp(tag, YCAL)             ||
+                       !strcmp(tag, LCAL)             ||
+                       !strcmp(tag, BADPIXEL_FLAT)    ||
+                       !strcmp(tag, ARC_LIST)         ||
+                       !strcmp(tag, FLAT_EDGE)        ||
+                       !strcmp(tag, REF_LINES)        ||
+                       !strcmp(tag, MASTER_DARK)      ||
+                       !strcmp(tag, ILLUM_CORR)       ||
+                       !strcmp(tag, ILLUM_CORR_FLAT)  ||
+                       !strcmp(tag, SOLAR_SPEC)       ||
+                       !strcmp(tag, ATMOS_MODEL)      ||
+                       !strcmp(tag, SPEC_TYPE_LOOKUP) ||
+                       !strcmp(tag, TELLURIC) ||
+                       !strcmp(tag, WAVE_BAND)) {
+                // set group as CALIB
+                cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_CALIB);
+                ret = TRUE;
             }
+             KMO_TRY_CHECK_ERROR_STATE();
+        } // end for i = nframes
 
-        } else if (type == spectrum_frame) {
-            KMO_TRY_EXIT_IF_NULL(
-                ret_string = cpl_sprintf("%s", EXT_SPEC));
-        } else if (type == list_frame) {
-            KMO_TRY_EXIT_IF_NULL(
-                ret_string = cpl_sprintf("%s", EXT_LIST));
-        } else {
-            KMO_TRY_ASSURE(1==0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "frame type not supported!");
-        }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-        cpl_free(ret_string); ret_string = NULL;
+        ret = FALSE;
     }
-
-    return ret_string;
+    return ret;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Updates the fits-keywords of subsequent extensions after the primary
-        (empty) extension.
-
-    @param pl           The propertylist to update.
-    @param is_noise     TRUE if extension contains noise,
-                        FALSE if it containsdata.
-    @param is_badpix    TRUE if extension contains badpix-frame,
-                        FALSE if it containsdata.
-    @param type         Frame type (ifu_frame or detector_frame)
-    @param device_nr    The number of the device (first = 1).
-
-    @return CPL_ERROR_NONE in case of success.
-
-    This function updates (or creates) the keywords needed in extensions to
-    vectors, images and imagelists in this pipeline.
-
-    This function is just a wrapper to the basic CPL functions
-    @c cpl_propertylist_update_bool() and @c cpl_propertylist_update_int() .
-    Error checking and proper messaging are also included here, to give
-    a more readable look to the main recipe code.
-
-    In case of any error, a @c NULL pointer is returned. The error codes that
-    are set in this case are the same set by the above mentioned CPL functions.
-    The "where" string (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function where the failure
-    occurred is also reported.
+  @brief Checks if a bool keyword has the right value in the provided header.
+  @param header   The header to check.
+  @param bool_id  The keyword of the lamp to check for.
+  @return TRUE if condition is fulfilled, FALSE otherwise.
+  The point is, that the lamp keywords are (should) only present when they are
+  set to TRUE, when they are not present this equals a FALSE.
+  This behaviour is checked with this function. A simple call
+  to cpl_property_get_bool() isn't sufficent.
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT     if @c header is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT  if @c bool_id isn't a bool keyword.
 */
-cpl_error_code kmo_update_sub_keywords(cpl_propertylist *pl,
-                                       int is_noise,
-                                       int is_badpix,
-                                       enum kmo_frame_type type,
-                                       int device_nr)
+/*----------------------------------------------------------------------------*/
+int kmo_check_lamp(
+        const cpl_propertylist  *   header,
+        const char              *   bool_id)
 {
-    cpl_error_code  ret_error   = CPL_ERROR_NONE;
-
-    char            *extname = NULL;
+    int ret_val = FALSE;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(pl != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
-
-        KMO_TRY_ASSURE((is_noise == TRUE) ||
-                       (is_noise == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "is_noise must be TRUE or FALSE (1 or 0)!");
+        KMO_TRY_ASSURE((header != NULL) && (bool_id != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all data provided!");
 
-        KMO_TRY_ASSURE((is_badpix == TRUE) ||
-                       (is_badpix == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "is_badpix must be TRUE or FALSE (1 or 0)!");
+        if (cpl_propertylist_has(header, bool_id) == 1) {
+            KMO_TRY_ASSURE(
+                    cpl_propertylist_get_type(header, bool_id) == CPL_TYPE_BOOL,
+                    CPL_ERROR_ILLEGAL_INPUT, 
+                    "Only bool keywords can be checked!");
+        }
+        KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_ASSURE(!(is_noise && is_badpix),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Badpix and noise can't be TRUE at the same time!");
+        ret_val = cpl_propertylist_get_bool(header, bool_id);
 
-        if (is_noise == TRUE) {
-            KMO_TRY_EXIT_IF_NULL(
-                extname = kmo_extname_creator(type, device_nr, EXT_NOISE));
-        } else if (is_badpix == TRUE) {
-            KMO_TRY_EXIT_IF_NULL(
-                extname = kmo_extname_creator(type, device_nr, EXT_BADPIX));
+        if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
+            cpl_error_reset();
+            // bool_id keyword isn't present, so it is interpreted as FALSE
+            ret_val = FALSE;
+        } else if (cpl_error_get_code() == CPL_ERROR_NONE) {
+            // bool_id keyword is present
         } else {
-            KMO_TRY_EXIT_IF_NULL(
-                extname = kmo_extname_creator(type, device_nr, EXT_DATA));
+            // other error code, just propagate it
+            KMO_TRY_CHECK_ERROR_STATE();
         }
-
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_propertylist_update_string(pl, EXTNAME, extname));
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-        ret_error = cpl_error_get_code();
+        ret_val = FALSE;
     }
-
-    cpl_free(extname); extname = NULL;
-
-    return ret_error;
+    return ret_val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Gets the number of the ifu of a specified frame by OCS target name.
-
-    @param frame    The input frame to examine.
-    @param ocs_name The target name as assigned by the OCS.
-
-    @return The extracted IFU number.
-
-    There will only be a valid output if there exists a corresponding IFU number
-    in EXTNAME and ESO OCS ARMx NAME.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
- */
-int kmo_get_index_from_ocs_name(const cpl_frame *frame,
-                                const char *ocs_name)
+  @brief    Reject saturated pixels if wanted
+  @param frame    The frame the img belongs to
+  @param img      the image to check
+  @param sat_mode FALSE: do nothing,
+                  TRUE:  reject all zero values
+  @param nr_sat   Pass an integer if the number of saturated pixels should be
+                  returned or NULL otherwise.
+  @return   An error code
+  In a special readout mode, saturated pixels are set to zero. Here they
+  can be rejected.
+*/
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_dfs_check_saturation(
+        cpl_frame   *   frame,
+        cpl_image   *   img,
+        int             sat_mode,
+        int         *   nr_sat)
 {
-    int                 i       = 1,
-                        found   = FALSE,
-                        id      = -1,
-                        is_raw  = 1,
-                        j       = 0;
-
-    cpl_propertylist    *pl     = NULL;
-
-    const char          *fname  = NULL,
-                        *extname= NULL;
-
-    char                *tmp_ocs = NULL,
-                        content[256];
-
-    enum kmo_frame_type ft      = illegal_frame;
+    cpl_error_code      ret             = CPL_ERROR_NONE;
+    cpl_propertylist    *main_header    = NULL;
+    int                 tmp_nr_sat      = 0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frame != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
-        KMO_TRY_ASSURE(cpl_frame_get_nextensions(frame) > 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Frame must have at least one extension!");
-
-        KMO_TRY_EXIT_IF_NULL(
-            fname = cpl_frame_get_filename(frame));
-
-        // check if it is a RAW frame or an already processed frame
-        KMO_TRY_EXIT_IF_NULL(
-            pl = kmclipm_propertylist_load(fname, 0));
-
-        if (cpl_propertylist_has(pl, CPL_DFS_PRO_CATG)) {
-            is_raw = 0;
-        }
+        KMO_TRY_ASSURE(img != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all data provided!");
 
-        cpl_propertylist_delete(pl); pl = NULL;
-
-        if (!is_raw) {
-            // frame is already processed
-            while ((!found) &&
-                   (i <= cpl_frame_get_nextensions(frame)))
-            {
-                KMO_TRY_EXIT_IF_NULL(
-                    pl = kmclipm_propertylist_load(fname, i));
-
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = cpl_propertylist_get_string(pl, EXTNAME));
-
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmo_extname_extractor(extname, &ft, &id, content));
-
-                KMO_TRY_EXIT_IF_NULL(
-                    tmp_ocs = cpl_sprintf("%s%d%s",
-                                      IFU_NAME_PREFIX, id, IFU_NAME_POSTFIX));
-
-                if (cpl_propertylist_has(pl, tmp_ocs)) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        extname = cpl_propertylist_get_string(pl, tmp_ocs));
-
-                    if (strcmp(extname, ocs_name) == 0) {
-                        found = TRUE;
-                    } else {
-                        id = -1;
-                    }
-                }
-                cpl_free(tmp_ocs); tmp_ocs = NULL;
-                cpl_propertylist_delete(pl); pl = NULL;
+        KMO_TRY_ASSURE((sat_mode == FALSE) || (sat_mode <= TRUE),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "sat_mode must be either TRUE or FALSE!");
 
-                i++;
-            }
-        } else {
-            // frame is a RAW frame
+        if (sat_mode) {
             KMO_TRY_EXIT_IF_NULL(
-                pl = kmclipm_propertylist_load(fname, 0));
-
-            id = 1;
-            for (j = 1; j <= KMOS_NR_IFUS; j++) {
-                KMO_TRY_EXIT_IF_NULL(
-                    tmp_ocs = cpl_sprintf("%s%d%s",
-                                      IFU_NAME_PREFIX, id, IFU_NAME_POSTFIX));
-
-                KMO_TRY_ASSURE(cpl_propertylist_has(pl, tmp_ocs) == 1,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "Primary header of frame %s doesn't have "
-                               "keyword '%s'!",
-                               fname, tmp_ocs);
-
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = cpl_propertylist_get_string(pl, tmp_ocs));
-
-                cpl_free(tmp_ocs); tmp_ocs = NULL;
-
-                if (strcmp(extname, ocs_name) == 0) {
-                    found = TRUE;
-                    break;
-                } else {
-                    id++;
+                main_header = kmclipm_propertylist_load(
+                    cpl_frame_get_filename(frame), 0));
+            if (strcmp(cpl_propertylist_get_string(main_header, READMODE), 
+                        "Nondest") == 0) {
+                KMO_TRY_EXIT_IF_ERROR(
+                    kmclipm_reject_saturated_pixels(img, 1, &tmp_nr_sat));
+                if (nr_sat != NULL) {
+                    *nr_sat = tmp_nr_sat;
                 }
             }
-            if (!found) {
-                id = -1;
-            }
-
-            cpl_propertylist_delete(pl); pl = NULL;
+            cpl_propertylist_delete(main_header); main_header = NULL;
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-        id = -1;
-        cpl_free(tmp_ocs); tmp_ocs = NULL;
+        ret = FALSE;
+        if (nr_sat != NULL) {
+            nr_sat = 0;
+        }
     }
-
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    return id;
+    return ret;
 }
 
-/**
-    @brief
-        Gets the name of the ifu of a specified frame by OCS IFUnr.
-
-    @param frame    The input frame to examine.
-    @param ifu_nr   The IFU to investigate.
-
-    @return The extracted IFU number.
-
-    There will only be a valid output if there exists a corresponding IFU number
-    in EXTNAME and ESO OCS ARMx NAME.
-
-    In case of any error, a @c NULL pointer is returned. The
-    error codes that are set in this case are the same set by
-    the above mentioned CPL functions. The "where" string
-    (accessible via a call to @c cpl_error_get_where() ) is
-    not modified by this function, and therefore the function
-    where the failure occurred is also reported.
- */
-char* kmo_get_name_from_ocs_ifu(const cpl_frame *frame,
-                               int ifu_nr)
+/* TODO : THE FOLLOWING FUNTIONS NEED TO BE REMOVED */
+int kmo_dfs_get_parameter_bool(cpl_parameterlist *parlist, const char *name)
 {
-    int                 is_raw  = 1;
+    cpl_parameter   *param      = NULL;
+    int             ret_val     = INT_MIN;
 
-    cpl_propertylist    *pl     = NULL;
+    KMO_TRY
+    {
+        KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data provided!");
 
-    const char          *fname  = NULL,
-                        *extname= NULL;
+        KMO_TRY_EXIT_IF_NULL(param = cpl_parameterlist_find(parlist, name));
 
-    char                *tmp_ocs = NULL,
-                        content[256],
-                        *id      = NULL;
+        KMO_TRY_ASSURE(cpl_parameter_get_type(param) == CPL_TYPE_BOOL,
+                CPL_ERROR_INVALID_TYPE,
+                "Unexpected type for parameter %s: it should be boolean",
+                name);
 
-    enum kmo_frame_type ft      = illegal_frame;
+        KMO_TRY_EXIT_IF_ERROR(ret_val = cpl_parameter_get_bool(param));
+    }
+    KMO_CATCH
+    {
+        KMO_CATCH_MSG();
+        ret_val = INT_MIN;
+    }
+    return ret_val;
+}
+
+int kmo_dfs_get_parameter_int(cpl_parameterlist *parlist, const char *name)
+{
+    cpl_parameter   *param      = NULL;
+    int             ret_val     = INT_MIN;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frame != NULL,
+        KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
                        CPL_ERROR_NULL_INPUT,
                        "Not all input data provided!");
 
-        KMO_TRY_ASSURE(cpl_frame_get_nextensions(frame) > 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Frame must have at least one extension!");
-
-        KMO_TRY_EXIT_IF_NULL(
-            fname = cpl_frame_get_filename(frame));
-
-        // check if it is a RAW frame or an already processed frame
         KMO_TRY_EXIT_IF_NULL(
-            pl = kmclipm_propertylist_load(fname, 0));
-
-        if (cpl_propertylist_has(pl, CPL_DFS_PRO_CATG)) {
-            is_raw = 0;
-        }
-
-        cpl_propertylist_delete(pl); pl = NULL;
-
-        if (!is_raw) {
-            // frame is already processed
-            KMO_TRY_EXIT_IF_NULL(
-                pl = kmclipm_propertylist_load(fname, ifu_nr));
-            KMO_TRY_EXIT_IF_NULL(
-                extname = cpl_propertylist_get_string(pl, EXTNAME));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_extname_extractor(extname, &ft, &ifu_nr, content));
-            KMO_TRY_EXIT_IF_NULL(
-                tmp_ocs = cpl_sprintf("%s%d%s",
-                                  IFU_NAME_PREFIX, ifu_nr, IFU_NAME_POSTFIX));
+            param = cpl_parameterlist_find(parlist, name));
 
-            if (cpl_propertylist_has(pl, tmp_ocs)) {
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = cpl_propertylist_get_string(pl, tmp_ocs));
-                KMO_TRY_EXIT_IF_NULL(
-                    id = cpl_sprintf("%s", extname));
-            }
-            cpl_free(tmp_ocs); tmp_ocs = NULL;
-            cpl_propertylist_delete(pl); pl = NULL;
-        } else {
-            // frame is a RAW frame
-            KMO_TRY_EXIT_IF_NULL(
-                pl = kmclipm_propertylist_load(fname, 0));
-            KMO_TRY_EXIT_IF_NULL(
-                tmp_ocs = cpl_sprintf("%s%d%s",
-                                  IFU_NAME_PREFIX, ifu_nr, IFU_NAME_POSTFIX));
+        KMO_TRY_ASSURE(cpl_parameter_get_type(param) == CPL_TYPE_INT,
+                       CPL_ERROR_INVALID_TYPE,
+                       "Unexpected type for parameter %s: it should be integer",
+                       name);
 
-            if (cpl_propertylist_has(pl, tmp_ocs)) {
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = cpl_propertylist_get_string(pl, tmp_ocs));
-                KMO_TRY_EXIT_IF_NULL(
-                    id = cpl_sprintf("%s", extname));
-            }
-            cpl_free(tmp_ocs); tmp_ocs = NULL;
-            cpl_propertylist_delete(pl); pl = NULL;
-        }
+        KMO_TRY_EXIT_IF_ERROR(
+            ret_val = cpl_parameter_get_int(param));
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-        id = NULL;
-    }
 
-    cpl_free(tmp_ocs); tmp_ocs = NULL;
-    cpl_propertylist_delete(pl); pl = NULL;
+        ret_val = INT_MIN;
+    }
 
-    return id;
+    return ret_val;
 }
 
-/**
-    @brief
-        Identifies the extension with given noise and device number.
-
-    @param filename The filename of a fits file to examine.
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    0: the data frame of the device is returned
-                    1:  the noise frame of the device is returned
-                    2: the bad pixel mask of the device  is returned
-
-    @return The index of the extension to load.
-
-    This is a helper function needed in kmo_dfs_load_vector, kmo_dfs_load_image,
-    kmo_dfs_load_cube.
-*/
-int kmo_identify_index(const char *filename,
-                       int device,
-                       int noise)
+double kmo_dfs_get_parameter_double(cpl_parameterlist *parlist,
+                                    const char *name)
 {
-    main_fits_desc  desc;
-    int             index       = -1;
+    cpl_parameter   *param      = NULL;
+    double          ret_val     = -DBL_MAX;
 
     KMO_TRY
     {
-        kmo_init_fits_desc(&desc);
+        KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
+                       CPL_ERROR_NULL_INPUT,
+                       "Not all input data provided!");
 
-        desc = kmo_identify_fits_header(filename);
-        KMO_TRY_CHECK_ERROR_STATE();
+        KMO_TRY_EXIT_IF_NULL(
+            param = cpl_parameterlist_find(parlist, name));
 
-        index = kmo_identify_index_desc(desc, device, noise);
-        KMO_TRY_CHECK_ERROR_STATE();
+        KMO_TRY_ASSURE(cpl_parameter_get_type(param) == CPL_TYPE_DOUBLE,
+                       CPL_ERROR_INVALID_TYPE,
+                       "Unexpected type for parameter %s: it should be double",
+                       name);
+
+        KMO_TRY_EXIT_IF_ERROR(
+            ret_val = cpl_parameter_get_double(param));
     }
     KMO_CATCH
     {
-        if (!override_err_msg) {
-            KMO_CATCH_MSG();
-        }
-        index = -1;
-    }
+        KMO_CATCH_MSG();
 
-    kmo_free_fits_desc(&desc);
+        ret_val = -DBL_MAX;
+    }
 
-    return index;
+    return ret_val;
 }
 
-/**
-    @brief
-        Identifies the extension with given noise and device number.
-
-    @param desc     The fits descriptor to examine.
-    @param device   The device number (IFU or detector) to access (first = 1)
-    @param noise    0: the data frame of the device is returned
-                    1:  the noise frame of the device is returned
-                    2: the bad pixel mask of the device  is returned
-
-    @return The index of the extension to load.
-
-    This is a helper function.
-*/
-int kmo_identify_index_desc(const main_fits_desc desc,
-                            int device,
-                            int noise)
+const char* kmo_dfs_get_parameter_string(cpl_parameterlist *parlist,
+                                         const char *name)
 {
-    int             i           = 0,
-                    index       = -1;
+    cpl_parameter   *param      = NULL;
+    const char      *ret_val    = NULL;
 
     KMO_TRY
     {
-        if (noise == 2) {
-            KMO_TRY_ASSURE(desc.ex_badpix != 0,
-                        CPL_ERROR_ILLEGAL_INPUT,
-                        "The fits-descriptor doesn't contain any badpixel mask "
-                        "information!");
-        }
-
-        if (((desc.fits_type == f2d_fits)||(desc.fits_type == b2d_fits)) &&
-            (((desc.nr_ext > 3) && (desc.ex_noise==0)) ||
-             ((desc.nr_ext > 6) && (desc.ex_noise==1)) ||
-             ((desc.nr_ext > 3) && (desc.ex_badpix==1))))
-        {
-            // handling new calibration format with all rotator angles in one file
-            // Attention, here we depend on the order of data and noise frames!
-            if ((desc.ex_noise == 0) || (desc.ex_badpix == 1)){
-                index = device;
-            } else {
-                if (noise) {
-                    index = 2*device;
-                } else {
-                    index = 2*device-1;
-                }
-            }
-            switch (noise) {
-                case 0:         // data
-                    if ((desc.sub_desc[i].is_noise == 0) &&
-                        (desc.sub_desc[i].is_badpix == 0))
-                    {
-                        index = device;
-                    }
-                    break;
-                case 1:         // noise
-                    if ((desc.sub_desc[i].is_noise == 1) &&
-                        (desc.sub_desc[i].is_badpix == 0))
-                    {
-                        index = desc.sub_desc[i].ext_nr;
-                    }
-                    break;
-                case 2:         // badpix
-                    if ((desc.sub_desc[i].is_noise == 0) &&
-                        (desc.sub_desc[i].is_badpix == 1))
-                    {
-                        index = desc.sub_desc[i].ext_nr;
-                    }
-                    break;
-            }
-        } else {
-            // old way...
-            // search for matching device_nr
-            for (i = 0; i < desc.nr_ext; i++) {
-                if (desc.sub_desc[i].device_nr == device) {
-                    switch (noise) {
-                        case 0:         // data
-                            if ((desc.sub_desc[i].is_noise == 0) &&
-                                (desc.sub_desc[i].is_badpix == 0))
-                            {
-                                index = desc.sub_desc[i].ext_nr;
-                            }
-                            break;
-                        case 1:         // noise
-                            if ((desc.sub_desc[i].is_noise == 1) &&
-                                (desc.sub_desc[i].is_badpix == 0))
-                            {
-                                index = desc.sub_desc[i].ext_nr;
-                            }
-                            break;
-                        case 2:         // badpix
-                            if ((desc.sub_desc[i].is_noise == 0) &&
-                                (desc.sub_desc[i].is_badpix == 1))
-                            {
-                                index = desc.sub_desc[i].ext_nr;
-                            }
-                            break;
-                    }
-
-                    if (index > -1) {
-                        break;
-                    }
-                }
-            } // end for (i)
-
-            if (index == -1) {
-                // index is still invalid, try to search for matching ext_nr
-                // (works, if device=1)
-                for (i = 0; i < desc.nr_ext; i++) {
-                    if (desc.sub_desc[i].ext_nr == device) {
-                        switch (noise) {
-                            case 0:         // data
-                                if ((desc.sub_desc[i].is_noise == 0) &&
-                                    (desc.sub_desc[i].is_badpix == 0))
-                                {
-                                    index = desc.sub_desc[i].ext_nr;
-                                }
-                                break;
-                            case 1:         // noise
-                                if ((desc.sub_desc[i].is_noise == 1) &&
-                                    (desc.sub_desc[i].is_badpix == 0))
-                                {
-                                    index = desc.sub_desc[i].ext_nr;
-                                }
-                                break;
-                            case 2:         // badpix
-                                if ((desc.sub_desc[i].is_noise == 0) &&
-                                    (desc.sub_desc[i].is_badpix == 1))
-                                {
-                                    index = desc.sub_desc[i].ext_nr;
-                                }
-                                break;
-                        }
-
-                        if (index > -1) {
-                            break;
-                        }
-                    }
-                } // end for (i)
+        KMO_TRY_ASSURE((parlist != NULL) && (name != NULL),
+                       CPL_ERROR_NULL_INPUT,
+                       "Not all input data provided!");
 
-                if (index == -1) {
-                    // index is still invalid, try to search for matching ext_nr
-                    // (works, if device=1 AND noise = 1)
-                    for (i = 0; i < desc.nr_ext; i++) {
-                        if (desc.sub_desc[i].ext_nr == device+noise) {
-                            switch (noise) {
-                                case 0:         // data
-                                    if ((desc.sub_desc[i].is_noise == 0) &&
-                                        (desc.sub_desc[i].is_badpix == 0))
-                                    {
-                                        index = desc.sub_desc[i].ext_nr;
-                                    }
-                                    break;
-                                case 1:         // noise
-                                    if ((desc.sub_desc[i].is_noise == 1) &&
-                                        (desc.sub_desc[i].is_badpix == 0))
-                                    {
-                                        index = desc.sub_desc[i].ext_nr;
-                                    }
-                                    break;
-                                case 2:         // badpix
-                                    if ((desc.sub_desc[i].is_noise == 0) &&
-                                        (desc.sub_desc[i].is_badpix == 1))
-                                    {
-                                        index = desc.sub_desc[i].ext_nr;
-                                    }
-                                    break;
-                            }
+        KMO_TRY_EXIT_IF_NULL(
+            param = cpl_parameterlist_find(parlist, name));
 
-                            if (index > -1) {
-                                break;
-                            }
-                        }
-                    } // end for (i)
-                } // end if (index)
-            } // end if (index)
-        }
+        KMO_TRY_ASSURE(cpl_parameter_get_type(param) == CPL_TYPE_STRING,
+                       CPL_ERROR_INVALID_TYPE,
+                       "Unexpected type for parameter %s: it should be string",
+                       name);
 
-        KMO_TRY_ASSURE(index != -1,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "The provided device-number is greater than the actual "
-                       "number of devices (%d, %d)!", device, desc.nr_ext);
+        KMO_TRY_EXIT_IF_ERROR(
+            ret_val = cpl_parameter_get_string(param));
     }
     KMO_CATCH
     {
-        if (!override_err_msg) {
-            KMO_CATCH_MSG();
-        }
-        index = -1;
+        KMO_CATCH_MSG();
+
+        ret_val = NULL;
     }
 
-    return index;
+    return ret_val;
 }
 
-/**
-    @brief
-        Checks if a bool keyword has the right value in the provided header.
+int kmo_dfs_get_property_bool(cpl_propertylist *header, const char *keyword)
+{
+    int         ret_val = INT_MIN;
+
+    KMO_TRY
+    {
+        KMO_TRY_ASSURE((header != NULL) && (keyword != NULL),
+                       CPL_ERROR_NULL_INPUT,
+                       "Not all input data provided!");
 
-    The point is, that the lamp keywords are (should) only present when they are
-    set to TRUE, when they are not present this equals a FALSE.
-    This behaviour is checked with this function. A simple call
-    to cpl_property_get_bool() isn't sufficent.
+        KMO_TRY_ASSURE(cpl_propertylist_has(header, keyword) != 0,
+                       CPL_ERROR_DATA_NOT_FOUND,
+                       "Wrong property keyword: %s", keyword);
 
-    @param header   The header to check.
-    @param bool_id  The keyword of the lamp to check for.
+        KMO_TRY_ASSURE(cpl_propertylist_get_type(header, keyword) ==
+                                                               CPL_TYPE_BOOL,
+                       CPL_ERROR_INVALID_TYPE,
+                       "Unexpected type for property %s: it should be boolean",
+                       keyword);
 
-    @return TRUE if condition is fulfilled, FALSE otherwise.
+        KMO_TRY_EXIT_IF_ERROR(
+            ret_val = cpl_propertylist_get_bool(header, keyword));
+    }
+    KMO_CATCH
+    {
+        KMO_CATCH_MSG();
 
-    Possible cpl_error_code set in this function:
+        ret_val = INT_MIN;
+    }
 
-    @li CPL_ERROR_NULL_INPUT     if @c header is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT  if @c bool_id isn't a bool keyword.
+    return ret_val;
+}
 
-*/
-int kmo_check_lamp(const cpl_propertylist *header,
-                   const char *bool_id)
+int kmo_dfs_get_property_int(cpl_propertylist *header, const char *keyword)
 {
-    int ret_val = FALSE;
+    int         ret_val = INT_MIN;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((header != NULL) &&
-                       (bool_id != NULL),
+        KMO_TRY_ASSURE((header != NULL) && (keyword != NULL),
                        CPL_ERROR_NULL_INPUT,
-                       "Not all data provided!");
+                       "Not all input data provided!");
 
-        if (cpl_propertylist_has(header, bool_id) == 1) {
-            KMO_TRY_ASSURE(cpl_propertylist_get_type(header, bool_id)
-                                                               == CPL_TYPE_BOOL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Only bool keywords can be checked!");
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
+        KMO_TRY_ASSURE(cpl_propertylist_has(header, keyword) != 0,
+                       CPL_ERROR_DATA_NOT_FOUND,
+                       "Wrong property keyword: %s", keyword);
 
-        ret_val = cpl_propertylist_get_bool(header, bool_id);
+        KMO_TRY_ASSURE(cpl_propertylist_get_type(header, keyword) ==
+                                                               CPL_TYPE_INT,
+                       CPL_ERROR_INVALID_TYPE,
+                       "Unexpected type for property %s: it should be integer",
+                       keyword);
 
-        if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
-            cpl_error_reset();
-            // bool_id keyword isn't present, so it is interpreted as FALSE
-            ret_val = FALSE;
-        } else if (cpl_error_get_code() == CPL_ERROR_NONE) {
-            // bool_id keyword is present
-        } else {
-            // other error code, just propagate it
-            KMO_TRY_CHECK_ERROR_STATE();
-        }
+        KMO_TRY_EXIT_IF_ERROR(
+            ret_val = cpl_propertylist_get_int(header, keyword));
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-        ret_val = FALSE;
+
+        ret_val = INT_MIN;
     }
 
     return ret_val;
 }
 
-/**
-  @brief    Set the group as RAW or CALIB in a frameset
-  @param    frameset         the input frameset
-  @param    recipe_name      the recipe name
-  @return   TRUE if ok, FALSE in error case
- */
-int kmo_dfs_set_groups(cpl_frameset *frameset, const char *recipe_name)
+double kmo_dfs_get_property_double(const cpl_propertylist *header,
+                                   const char *keyword)
 {
-    int             ret         = FALSE,
-                    nframes     = 0,
-                    i           = 0;
-    cpl_frame       *cur_frame  = NULL;
-    const char      *tag        = NULL;
-    main_fits_desc  desc;
+    double      ret_val = -DBL_MAX;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((frameset != NULL) ||
-                       (recipe_name != NULL),
+        KMO_TRY_ASSURE((header != NULL) && (keyword != NULL),
                        CPL_ERROR_NULL_INPUT,
-                       "Not all data provided!");
+                       "Not all input data provided!");
 
-        // Initialize
-        nframes = cpl_frameset_get_size(frameset) ;
+        KMO_TRY_ASSURE(cpl_propertylist_has(header, keyword) != 0,
+                       CPL_ERROR_DATA_NOT_FOUND,
+                       "Wrong property keyword: %s", keyword);
 
-        // Loop on frames
-        for (i = 0 ; i < nframes ; i++) {
-#if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(6, 3, 0)
-            cur_frame = cpl_frameset_get_position(frameset, i);
-#else
-            cur_frame = cpl_frameset_get_frame(frameset, i);
-#endif
-            tag = cpl_frame_get_tag(cur_frame);
-            if (!strcmp(tag, COMMANDLINE)               ||
-                !strcmp(recipe_name, "kmo_arithmetic")  ||
-                !strcmp(recipe_name, "kmo_reconstruct") ||
-                !strcmp(recipe_name, "kmo_stats"))
-            {
-                 kmo_init_fits_desc(&desc);
+        KMO_TRY_ASSURE(cpl_propertylist_get_type(header, keyword) ==
+                                                               CPL_TYPE_DOUBLE,
+                       CPL_ERROR_INVALID_TYPE,
+                       "Unexpected type for property %s: it should be double",
+                       keyword);
 
-                 desc = kmo_identify_fits_header(cpl_frame_get_filename(cur_frame));
-                 KMO_TRY_CHECK_ERROR_STATE_MSG("Provided fits file doesn't seem "
-                                               "to be in KMOS-format!");
+        KMO_TRY_EXIT_IF_ERROR(
+            ret_val = cpl_propertylist_get_double(header, keyword));
+    }
+    KMO_CATCH
+    {
+        KMO_CATCH_MSG();
 
-                 if (desc.fits_type == raw_fits) {
-                     cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_RAW);
-                 } else {
-                     // should in fact be CPL_FRAME_GROUP_PRODUCT, but then
-                     // cpl_dfs_save_propertylist() fails...
-                     cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_CALIB);
-                 }
-                 ret = TRUE;
-                 kmo_free_fits_desc(&desc);
-            } else if (!strcmp(recipe_name, "kmo_combine")      ||
-                       !strcmp(recipe_name, "kmo_copy")         ||
-                       !strcmp(recipe_name, "kmo_extract_spec") ||
-                       !strcmp(recipe_name, "kmo_fit_profile")  ||
-                       !strcmp(recipe_name, "kmo_make_image")   ||
-                       !strcmp(recipe_name, "kmo_rotate")       ||
-                       !strcmp(recipe_name, "kmo_shift")        ||
-                       !strcmp(recipe_name, "kmo_sky_tweak")    ||
-                       !strcmp(recipe_name, "kmo_sky_mask"))
-            {
-                // should in fact be CPL_FRAME_GROUP_PRODUCT, but then
-                // cpl_dfs_save_propertylist() fails...
-                cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_CALIB);
-                ret = TRUE;
-            } else if (!strcmp(recipe_name, "kmo_noise_map"))
-            {
-                  cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_RAW);
-                  ret = TRUE;
-            } else if (!strcmp(tag, DARK)     ||      // kmo_dark
-                       !strcmp(tag, FLAT_ON)  ||      // kmo_flat
-                       !strcmp(tag, FLAT_OFF) ||
-                       !strcmp(tag, ARC_ON)   ||      // kmo_wave_cal
-                       !strcmp(tag, ARC_OFF)  ||
-                       !strcmp(tag, FLAT_SKY) ||      // kmo_illumination
-                       !strcmp(tag, STD)      ||      // kmo_std_star
-                       !strcmp(tag, SCIENCE))         // kmo_reconstruct
-            {
-                 // set group as RAW
-                 cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_RAW);
-                 ret = TRUE;
+        ret_val = -DBL_MAX;
+    }
 
+    return ret_val;
+}
 
-                // Check if the RAW file is valid for the current recipe
-                if (!strcmp(recipe_name, "kmo_dark") &&
-                    strcmp(tag, DARK))
-                {
-                    cpl_msg_error("", "The tag %s is invalid for the recipe %s",
-                                  tag, recipe_name) ;
-                    ret = FALSE;
-                }
-                if (!strcmp(recipe_name, "kmo_flat") &&
-                    (strcmp(tag, FLAT_ON) != 0) &&
-                    (strcmp(tag, FLAT_OFF) != 0))
-                {
-                    cpl_msg_error("", "The tag %s is invalid for the recipe %s",
-                                  tag, recipe_name) ;
-                    ret = FALSE;
-                }
-                if (!strcmp(recipe_name, "kmo_wave_cal") &&
-                    (strcmp(tag, ARC_ON) != 0) &&
-                    (strcmp(tag, ARC_OFF) != 0))
-                {
-                    cpl_msg_error("", "The tag %s is invalid for the "
-                                  "recipe %s", tag, recipe_name) ;
-                    ret = FALSE;
-                }
-                if (!strcmp(recipe_name, "kmo_illumination") &&
-                    strcmp(tag, FLAT_SKY))
-                {
-                    cpl_msg_error("", "The tag %s is invalid for the "
-                                  "recipe %s", tag, recipe_name) ;
-                    ret = FALSE;
-                }
-                if (!strcmp(recipe_name, "kmo_std_star") &&
-                    strcmp(tag, STD))
-                {
-                    cpl_msg_error("", "The tag %s is invalid for the "
-                                  "recipe %s", tag, recipe_name) ;
-                    ret = FALSE;
-                }
-                if (!strcmp(recipe_name, "kmo_sci_red") &&
-                    strcmp(tag, SCIENCE))
-                {
-                    cpl_msg_error("", "The tag %s is invalid for the "
-                                  "recipe %s", tag, recipe_name) ;
-                    ret = FALSE;
-                }
-            // CALIB frames
-            } else if (!strcmp(tag, BADPIXEL_DARK)    ||
-                       !strcmp(tag, MASTER_FLAT)      ||
-                       !strcmp(tag, XCAL)             ||
-                       !strcmp(tag, YCAL)             ||
-                       !strcmp(tag, LCAL)             ||
-                       !strcmp(tag, BADPIXEL_FLAT)    ||
-                       !strcmp(tag, ARC_LIST)         ||
-                       !strcmp(tag, FLAT_EDGE)        ||
-                       !strcmp(tag, REF_LINES)        ||
-                       !strcmp(tag, MASTER_DARK)      ||
-                       !strcmp(tag, ILLUM_CORR)       ||
-                       !strcmp(tag, ILLUM_CORR_FLAT)  ||
-                       !strcmp(tag, SOLAR_SPEC)       ||
-                       !strcmp(tag, ATMOS_MODEL)      ||
-                       !strcmp(tag, SPEC_TYPE_LOOKUP) ||
-                       !strcmp(tag, TELLURIC) ||
-                       !strcmp(tag, WAVE_BAND))
-            {
-                // set group as CALIB
-                cpl_frame_set_group(cur_frame, CPL_FRAME_GROUP_CALIB);
-                ret = TRUE;
-            }
-             KMO_TRY_CHECK_ERROR_STATE();
-        } // end for i = nframes
+const char* kmo_dfs_get_property_string(cpl_propertylist *header,
+                                        const char *keyword)
+{
+    const char  *ret_val = NULL;
+
+    KMO_TRY
+    {
+        KMO_TRY_ASSURE((header != NULL) && (keyword != NULL),
+                       CPL_ERROR_NULL_INPUT,
+                       "Not all input data provided!");
+
+        KMO_TRY_ASSURE(cpl_propertylist_has(header, keyword) != 0,
+                       CPL_ERROR_DATA_NOT_FOUND,
+                       "Wrong property keyword: %s", keyword);
+
+        KMO_TRY_ASSURE(cpl_propertylist_get_type(header, keyword) ==
+                                                               CPL_TYPE_STRING,
+                       CPL_ERROR_INVALID_TYPE,
+                       "Unexpected type for property %s: it should be string",
+                       keyword);
 
+        KMO_TRY_EXIT_IF_NULL(
+            ret_val = cpl_propertylist_get_string(header, keyword));
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-        ret = FALSE;
+
+        ret_val = NULL;
     }
 
-    return ret;
+    return ret_val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-  @brief    Reject saturated pixels if wanted
-
-  In a special readout mode, saturated pixels are set to zero. Here they
-  can be rejected.
-
-  @param frame    The frame the img belongs to
-  @param img      the image to check
-  @param sat_mode FALSE: do nothing,
-                  TRUE:  reject all zero values
-  @param nr_sat   Pass an integer if the number of saturated pixels should be
-                  returned or NULL otherwise.
-
-  @return   An error code
+  @brief Fetching a frame of a certain category or of a certain position.
+  @param frameset The input set-of-frames
+  @param category The category of the image to load. Either a keyword or a
+                  string containing an integer designating the position of the
+                  frame in the frameset to load (first = "0"). If NULL, the
+                  next frame with same keyword as accessed right before will
+                  be returned
+  @return The desired frame.
+
+  When the frames in a framset are tagged with a category, they can be
+  retrieved by supplying this category-keyword.
+  But for basic recipes ignoring category-keywords (which rather take account
+  of the order of the frames in a frameset, like @c kmo_arithmetic), a string
+  containing an integer value can be supplied. The string is then converted to
+  an integer and the corresponding frame will be returned.
+
+  This function is just a wrapper to the basic CPL function
+  @c cpl_frameset_find() , as it is called every time an image should be loaded
+  by a recipe. Error checking and proper messaging are also included here, to 
+  give a more readable look to the main recipe code.
+
+  In case of any error, a @c NULL pointer is returned. The error codes that 
+  are set in this case are the same set by the above mentioned CPL function. 
+  The "where" string (accessible via a call to @c cpl_error_get_where() ) is
+  not modified by this function, and therefore the function where the failure 
+  occurred is also reported.
 */
-cpl_error_code kmo_dfs_check_saturation(cpl_frame* frame,
-                                        cpl_image *img,
-                                        int sat_mode,
-                                        int *nr_sat)
+/*----------------------------------------------------------------------------*/
+cpl_frame* kmo_dfs_get_frame(
+        cpl_frameset    *   frameset,
+        const char      *   category)
 {
-    cpl_error_code      ret             = CPL_ERROR_NONE;
-    cpl_propertylist    *main_header    = NULL;
-    int                 tmp_nr_sat      = 0;
+    cpl_frame           *frame = NULL;   /* must not be deleted at the end */
+    int                 nr     = 0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(img != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all data provided!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
 
-        KMO_TRY_ASSURE((sat_mode == FALSE) || (sat_mode <= TRUE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "sat_mode must be either TRUE or FALSE!");
+        KMO_TRY_ASSURE(cpl_frameset_get_size(frameset) != 0, 
+                CPL_ERROR_ILLEGAL_INPUT, "Empty frameset provided!");
 
-        if (sat_mode) {
-            KMO_TRY_EXIT_IF_NULL(
-                main_header = kmclipm_propertylist_load(
-                                             cpl_frame_get_filename(frame), 0));
-            if (strcmp(cpl_propertylist_get_string(main_header, READMODE), "Nondest") == 0) {
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_reject_saturated_pixels(img, 1, &tmp_nr_sat));
-//                if (!sat_mode_msg) {
-//                    cpl_msg_info("","Readmode: NDR, #rejected pixels: %d "
-//                                    "(Saturated pixels were set to zero and "
-//                                    "are rejected here)", tmp_nr_sat);
-//                }
-                if (nr_sat != NULL) {
-                    *nr_sat = tmp_nr_sat;
+        if (category == NULL) {
+            frame = cpl_frameset_find(frameset, NULL);
+        } else {
+            nr = atoi(category);
+            if ((nr == 0) && (strlen(category) > 1)) {
+                if (cpl_frameset_count_tags(frameset,category) != 0) {
+                    KMO_TRY_EXIT_IF_NULL(frame = cpl_frameset_find(frameset, 
+                                category));
                 }
+            } else {
+                KMO_TRY_EXIT_IF_NULL(frame = cpl_frameset_get_position(frameset,
+                            nr));
             }
-            cpl_propertylist_delete(main_header); main_header = NULL;
         }
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-        ret = FALSE;
-        if (nr_sat != NULL) {
-            nr_sat = 0;
-        }
+        frame = NULL;
     }
-
-    return ret;
+    return frame;
 }
 
+
 /** @} */
diff --git a/kmos/kmo_dfs.h b/kmos/kmo_dfs.h
index 08da64d..9add014 100644
--- a/kmos/kmo_dfs.h
+++ b/kmos/kmo_dfs.h
@@ -227,6 +227,7 @@
 #define QC_ARC_AR_FWHM_MEAN      "ESO QC ARC AR FWHM MEAN"
 #define QC_ARC_AR_FWHM_STDEV     "ESO QC ARC AR FWHM STDEV"
 #define QC_ARC_AR_FWHM_95ILE     "ESO QC ARC AR FWHM 95%ILE"
+#define QC_ARC_AR_VSCALE         "ESO QC ARC AR VSCALE"
 #define QC_ARC_NE_POS_MEAN       "ESO QC ARC NE POS MEAN"
 #define QC_ARC_NE_POS_MAXDIFF    "ESO QC ARC NE POS MAXDIFF"
 #define QC_ARC_NE_POS_MAXDIFF_ID "ESO QC ARC NE POS MAXDIFF ID"
@@ -235,6 +236,7 @@
 #define QC_ARC_NE_FWHM_MEAN      "ESO QC ARC NE FWHM MEAN"
 #define QC_ARC_NE_FWHM_STDEV     "ESO QC ARC NE FWHM STDEV"
 #define QC_ARC_NE_FWHM_95ILE     "ESO QC ARC NE FWHM 95%ILE"
+#define QC_ARC_NE_VSCALE         "ESO QC ARC NE VSCALE"
 
 // kmo_illumination
 #define QC_SPAT_UNIF             "ESO QC SPAT UNIF"
@@ -298,11 +300,20 @@ cpl_propertylist*  kmo_dfs_load_primary_header(
                                        cpl_frameset *frameset,
                                        const char *category);
 
+cpl_propertylist * kmos_dfs_load_sub_header(
+        cpl_frame       *   frame,
+        int                 device,
+        int                 noise) ;
+
 cpl_propertylist*  kmo_dfs_load_sub_header(
                                        cpl_frameset *frameset,
                                        const char *category,
                                        int device,
                                        int noise);
+kmclipm_vector * kmos_dfs_load_vector(
+        cpl_frame       *   frame,
+        int                 device,
+        int                 noise) ;
 
 kmclipm_vector*    kmo_dfs_load_vector(cpl_frameset *frameset,
                                        const char *category,
@@ -369,6 +380,10 @@ cpl_image*         kmo_dfs_load_image_frame_window(
                                        int ury,
                                        int sat_mode,
                                        int *nr_sat);
+cpl_imagelist * kmos_dfs_load_cube(
+        cpl_frame   *   frame,
+        int             device,
+        int             noise) ;
 
 cpl_imagelist*     kmo_dfs_load_cube(cpl_frameset *frameset,
                                        const char *category,
diff --git a/kmos/kmo_error.h b/kmos/kmo_error.h
index d2924e6..8740f8e 100644
--- a/kmos/kmo_error.h
+++ b/kmos/kmo_error.h
@@ -1,5 +1,4 @@
-/* $Id: kmo_error.h,v 1.1.1.1 2012-01-18 09:31:59 yjung Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: yjung $
- * $Date: 2012-01-18 09:31:59 $
- * $Revision: 1.1.1.1 $
- * $Name: not supported by cvs2svn $
- */
-
 /**
  * @internal
  * @defgroup kmo_error   Private Error Handling Macros
@@ -65,7 +57,7 @@
 #endif
 
 /*-----------------------------------------------------------------------------
-    Functional Macros
+                                Functional Macros
  -----------------------------------------------------------------------------*/
 
 /*----------------------------------------------------------------------------*/
diff --git a/kmos/kmo_priv_combine.c b/kmos/kmo_priv_combine.c
index 49fe2a6..197c835 100644
--- a/kmos/kmo_priv_combine.c
+++ b/kmos/kmo_priv_combine.c
@@ -107,22 +107,22 @@ char* kmo_shorten_ifu_string(const char* in)
             }
             strncpy(substr, in, lensubstr);
 
-            // replace all ; with _
-            found = strstr(substr, ";");
-            while (found != NULL) {
-                strncpy(found, "_", 1);
-                found = strstr(substr, ";");
-            }
+//            // replace all ; with _
+//            found = strstr(substr, ";");
+//            while (found != NULL) {
+//                strncpy(found, "_", 1);
+//                found = strstr(substr, ";");
+//            }
 
             KMO_TRY_EXIT_IF_NULL(
                 retstr = cpl_sprintf("_%s_etc", substr));
         } else {
-            // replace all ; with _
-            found = strstr(substr, ";");
-            while (found != NULL) {
-                strncpy(found, "_", 1);
-                found = strstr(substr, ";");
-            }
+//            // replace all ; with _
+//            found = strstr(substr, ";");
+//            while (found != NULL) {
+//                strncpy(found, "_", 1);
+//                found = strstr(substr, ";");
+//            }
 
             KMO_TRY_EXIT_IF_NULL(
                 retstr = cpl_sprintf("_%s", substr));
diff --git a/kmos/kmo_priv_dark.c b/kmos/kmo_priv_dark.c
index f382922..f072c90 100644
--- a/kmos/kmo_priv_dark.c
+++ b/kmos/kmo_priv_dark.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_dark.c,v 1.4 2013-06-17 07:52:26 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-06-17 07:52:26 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -48,70 +40,59 @@
 #include "kmo_cpl_extensions.h"
 #include "kmo_debug.h"
 
-/*----------------------------------------------------------------------------*/
 /**
-    @defgroup kmos_priv_dark     Helper functions for kmo_dark
-
-    @{
+ * @defgroup kmos_priv_dark    Helper functions for kmo_dark
  */
-/*----------------------------------------------------------------------------*/
-
-/**
-    @brief
-        Calculate the bad pixel mask from data frames.
-
-    @param data            Image to be examined.
-    @param bias            The previously calculated bias (mean or whatever).
-    @param readnoise       The previously calculated readnoise (stddev or
-                           whatever).
-    @param pos_bad_pix_rej Positive rejection threshold.
-    @param neg_bad_pix_rej Negative rejection threshold.
-    @param bad_pix_mask    Output: The calculated bad pixel mask.
-
-    @return
-        The number of bad pixels in the input data image.
-
-    All values in @c data which lie outside the interval
-    [bias - neg_bad_pix_rej * readnoise, bias + pos_bad_pix_rej * readnoise]
-    are marked as bad pixels.
-    Bad pixels are 0.0, valid pixels are 1.0.
-    @c data will contain rejected pixels afterwards.
-
 
-    Possible cpl_error_code set in this function:
+/**@{*/
 
-    @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if any of the values is less than zero.
+/*----------------------------------------------------------------------------*/
+/**
+  @brief    Calculate the bad pixel mask from data frames.
+  @param data            Image to be examined.
+  @param bias            The previously calculated bias (mean or whatever).
+  @param readnoise       The previously calculated readnoise (stddev or
+                         whatever).
+  @param pos_bad_pix_rej Positive rejection threshold.
+  @param neg_bad_pix_rej Negative rejection threshold.
+  @param bad_pix_mask    Output: The calculated bad pixel mask.
+  @return The number of bad pixels in the input data image.
+
+  All values in @c data which lie outside the interval
+  [bias - neg_bad_pix_rej * readnoise, bias + pos_bad_pix_rej * readnoise]
+  are marked as bad pixels.
+  Bad pixels are 0.0, valid pixels are 1.0.
+  @c data will contain rejected pixels afterwards.
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if any of the values is less than zero.
 */
-int kmo_create_bad_pix_dark(cpl_image* data,
-                            double bias,
-                            double readnoise,
-                            double pos_bad_pix_rej,
-                            double neg_bad_pix_rej,
-                            cpl_image **bad_pix_mask)
+/*----------------------------------------------------------------------------*/
+int kmo_create_bad_pix_dark(
+        cpl_image   *   data,
+        double          bias,
+        double          readnoise,
+        double          pos_bad_pix_rej,
+        double          neg_bad_pix_rej,
+        cpl_image   **  bad_pix_mask)
 {
     int     nr_bad_pix      = 0,
             nx              = 0,
             ny              = 0;
-
     float   *pbad_pix_mask  = NULL,
             *pdata          = NULL;
-
     double  high_thresh     = 0.0,
             low_thresh      = 0.0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (bad_pix_mask != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
+        KMO_TRY_ASSURE((data != NULL) && (bad_pix_mask != NULL),
+                CPL_ERROR_NULL_INPUT, "No input data is provided!");
 
-        KMO_TRY_ASSURE((readnoise > 0) &&
-                       (pos_bad_pix_rej > 0) &&
-                       (neg_bad_pix_rej > 0),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Values must be greater than 0!");
+        KMO_TRY_ASSURE((readnoise > 0) && (pos_bad_pix_rej > 0) && 
+                (neg_bad_pix_rej > 0), CPL_ERROR_ILLEGAL_INPUT,
+                "Values must be greater than 0!");
 
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
@@ -154,23 +135,23 @@ int kmo_create_bad_pix_dark(cpl_image* data,
     return nr_bad_pix;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief Add badpixel border around image.
-
-    The newly added badpixel border will also be rejected.
-
-    @param data   Image to be added the badpixel border.
-    @param reject TRUE if newly added border should be rejected (e.g. data
-                  frames), FALSE otherwise (e.g. badpixel maps)
-
-    @return       Image with added badpixel border.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c reject isn't TRUE or FALSE.
+  @brief    Add badpixel border around image.
+  @param data   Image to be added the badpixel border.
+  @param reject TRUE if newly added border should be rejected (e.g. data
+                frames), FALSE otherwise (e.g. badpixel maps)
+  @return   Image with added badpixel border.
+
+  The newly added badpixel border will also be rejected.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c reject isn't TRUE or FALSE.
 */
-cpl_image*      kmo_add_bad_pix_border(const cpl_image *data, int reject)
+/*----------------------------------------------------------------------------*/
+cpl_image * kmo_add_bad_pix_border(
+        const cpl_image     *   data, 
+        int                     reject)
 {
     int             nx_old      = 0,
                     ny_old      = 0,
@@ -178,23 +159,16 @@ cpl_image*      kmo_add_bad_pix_border(const cpl_image *data, int reject)
                     ny_new      = 0,
                     ix_old      = 0,
                     iy_old      = 0;
-
     const float     *pdata      = NULL;
     float           *pdata_out  = NULL;
-
     cpl_image       *data_out   = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(data != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
-
+        KMO_TRY_ASSURE(data != NULL, CPL_ERROR_NULL_INPUT, 
+                "No input data is provided!");
         KMO_TRY_ASSURE((reject == TRUE) || (reject == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "reject must be TRUE or FALSE!");
-
-
+                CPL_ERROR_ILLEGAL_INPUT, "reject must be TRUE or FALSE!");
         nx_old = cpl_image_get_size_x(data);
         ny_old = cpl_image_get_size_y(data);
         nx_new = nx_old + 2*KMOS_BADPIX_BORDER;
@@ -202,14 +176,13 @@ cpl_image*      kmo_add_bad_pix_border(const cpl_image *data, int reject)
 
         KMO_TRY_EXIT_IF_NULL(
             data_out = cpl_image_new(nx_new, ny_new, CPL_TYPE_FLOAT));
-
         KMO_TRY_EXIT_IF_NULL(
             pdata = cpl_image_get_data_const(data));
         KMO_TRY_EXIT_IF_NULL(
             pdata_out = cpl_image_get_data(data_out));
 
-        // create 4 pixel border around image (these pixels are used internally
-        // in KMOS for some electronic calibrations)
+        /* Create 4 pixel border around image (these pixels are used */
+         /* internally in KMOS for some electronic calibrations) */
         int iy_new = 0, ix_new = 0;
         for (iy_new = 0; iy_new < ny_new; iy_new++) {
             iy_old = iy_new - KMOS_BADPIX_BORDER;
@@ -220,17 +193,18 @@ cpl_image*      kmo_add_bad_pix_border(const cpl_image *data, int reject)
                     (iy_new < KMOS_BADPIX_BORDER) ||
                     (iy_new >= ny_new - KMOS_BADPIX_BORDER))
                 {
-                    // new badpixel border
+                    /* New badpixel border */
                     pdata_out[ix_new+iy_new*nx_new] = 0.0;
                     if (reject) {
                         cpl_image_reject(data_out, ix_new+1, iy_new+1);
                     }
                 } else {
-                    // inside the image data
+                    /* Inside the image data */
                     if (cpl_image_is_rejected(data, ix_old+1, iy_old+1)) {
                         cpl_image_reject(data_out, ix_new+1, iy_new+1);
                     } else {
-                        pdata_out[ix_new+iy_new*nx_new] = pdata[ix_old+iy_old*nx_old];
+                        pdata_out[ix_new+iy_new*nx_new] = 
+                            pdata[ix_old+iy_old*nx_old];
                     }
                 }
             }
@@ -241,9 +215,6 @@ cpl_image*      kmo_add_bad_pix_border(const cpl_image *data, int reject)
         KMO_CATCH_MSG();
         cpl_image_delete(data_out); data_out = NULL;
     }
-
     return data_out;
 }
-
 /** @} */
-
diff --git a/kmos/kmo_priv_dark.h b/kmos/kmo_priv_dark.h
index cf10642..c70282b 100644
--- a/kmos/kmo_priv_dark.h
+++ b/kmos/kmo_priv_dark.h
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_dark.h,v 1.1.1.1 2012-01-18 09:31:59 yjung Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: yjung $
- * $Date: 2012-01-18 09:31:59 $
- * $Revision: 1.1.1.1 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifndef KMOS_PRIV_DARK_H
 #define KMOS_PRIV_DARK_H
 
@@ -38,16 +30,16 @@
  *                        Prototypes
  *----------------------------------------------------------------------------*/
 
-int                 kmo_create_bad_pix_dark(
-                                cpl_image* data,
-                                double bias,
-                                double readnoise,
-                                double pos_bad_pix_rej,
-                                double neg_bad_pix_rej,
-                                cpl_image **bad_pix_mask);
-
-cpl_image*          kmo_add_bad_pix_border(
-                                const cpl_image *data,
-                                int reject);
+int kmo_create_bad_pix_dark(
+        cpl_image   *   data,
+        double          bias,
+        double          readnoise,
+        double          pos_bad_pix_rej,
+        double          neg_bad_pix_rej,
+        cpl_image   **  bad_pix_mask) ;
+
+cpl_image * kmo_add_bad_pix_border(
+        const cpl_image     *   data,
+        int                     reject) ;
 
 #endif
diff --git a/kmos/kmo_priv_extract_spec.c b/kmos/kmo_priv_extract_spec.c
index 8e3136c..4c2044e 100644
--- a/kmos/kmo_priv_extract_spec.c
+++ b/kmos/kmo_priv_extract_spec.c
@@ -39,6 +39,7 @@
 
 #include "kmclipm_constants.h"
 #include "kmclipm_functions.h"
+#include "kmclipm_math.h"
 
 #include "kmo_debug.h"
 #include "kmo_utils.h"
@@ -177,7 +178,7 @@ cpl_error_code kmo_priv_extract_spec(const cpl_imagelist *data_in,
             for (j = 0; j < ny; j++) {
                 for (i = 0; i < nx; i++) {
                     // sum weighted pixels in spatial plane
-                    if (bpm_data[i+j*nx] == CPL_BINARY_0) {
+                    if ((bpm_data[i+j*nx] == CPL_BINARY_0) && !kmclipm_is_nan_or_inf(ptmp_img[i+j*nx])) {
                         if (mask != NULL) {
                             sum += ptmp_img[i+j*nx] * pmask[i+j*nx];
                             weights += pmask[i+j*nx];
diff --git a/kmos/kmo_priv_flat.c b/kmos/kmo_priv_flat.c
index a08506d..cfa16e7 100644
--- a/kmos/kmo_priv_flat.c
+++ b/kmos/kmo_priv_flat.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_flat.c,v 1.34 2013-10-11 08:00:26 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-11 08:00:26 $
- * $Revision: 1.34 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -52,125 +44,123 @@
 
 double slit_tol        = 2.0;
 
+/*-----------------------------------------------------------------------------
+                                Functions prototypes
+ -----------------------------------------------------------------------------*/
+
+static int kmo_find_first_non_rejected(const kmclipm_vector *, int) ;
+static int kmo_validate_nr_edges(int, int, int) ;
+static cpl_array ** kmo_analize_ifu_edges(kmclipm_vector *, cpl_array *,
+        int, int, int) ;
+
 /*----------------------------------------------------------------------------*/
 /**
     @defgroup kmos_priv_flat     Helper functions for kmo_flat
-
-    @{
  */
 /*----------------------------------------------------------------------------*/
 
-/**
-    @brief
-        Calculate the bad pixel mask from flat frames using local level estimation.
-
-    @param data               Image to be examined.
-    @param surrounding_pixels Number of surrounding pixels. Between 0 and 8.
-                              Default is 6.
-    @param badpix_thresh      Thereshold level in % to declare pixels as bad.
-
-
-    @return
-        The calculated bad pixel mask.
-
-    To determine the threshold level to apply for badpixel detection, the input
-    image is sliced horizontally and examined individually. Variation of
-    illumination level between IFUs is far smaller than the vaariation along the
-    spectral axis. This could anyway be implemented if desired.
-
-    A slice of height "slice_height" is taken and collapsed along the spatial
-    axis, resulting in a vector of length "slice_height". The median of this
-    vector is calculated and multiplied with the @li badpix_thresh. Values in
-    the input frame below this level are marked as bad.
-
-    Then all pixels are examined by how many bad pixels they are
-    surrounded (8 surrounding pixels) of. If this number is at least the same as
-    @c surrounding_pixels, then this pixel is also marked as bad.
+/**@{*/
 
-    The internal badpixel mask is set as well here.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data or @c badpix_thresh is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if any of the values is less than zero.
+/*----------------------------------------------------------------------------*/
+/**
+  @brief Calculate the bad pixel mask from flat frames using local level 
+            estimation.
+  @param    data               Image to be examined.
+  @param    surrounding_pixels Number of surrounding pixels. Between 0 and 8.
+  @param    badpix_thresh      Thereshold level in % to declare pixels as bad.
+  @return   The calculated bad pixel mask.
+
+  The input image border KMOS_BADPIX_BORDER (4) pixels are ignored.
+
+  To determine the threshold level to apply for badpixel detection, the input
+  image is sliced horizontally and each slice examined individually. 
+  Variation of illumination level between IFUs is far smaller than the 
+  variation along the spectral axis.
+  
+  A slice of height "slice_height" is taken and collapsed along the spatial
+  axis, resulting in a vector of length "slice_height". The median of this
+  vector is calculated and multiplied with the @li badpix_thresh. Values in
+  the input frame below this level are marked as bad.
+  
+  Then all pixels are examined by how many bad pixels they are
+  surrounded (8 surrounding pixels) of. If this number is at least the same as
+  @c surrounding_pixels, then this pixel is also marked as bad.
+  The internal badpixel mask is set as well here.
+  
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data or @c badpix_thresh is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if any of the values is less than zero.
 */
-cpl_image* kmo_create_bad_pix_flat_thresh(const cpl_image* data,
-                                          int surrounding_pixels,
-                                          int badpix_thresh)
+/*----------------------------------------------------------------------------*/
+/* TODO: This function should return a cpl_mask */
+cpl_image * kmo_create_bad_pix_flat_thresh(
+        const cpl_image *   data,
+        int                 surrounding_pixels,
+        int                 badpix_thresh)
 {
-    int             nx                      = 0,
-                    ny                      = 0,
-                    slice_height            = 20,
-                    ix                      = 0,
-                    iy                      = 0,
-                    i                       = 0;
-
-    double          thresh                  = badpix_thresh / 100.,
-                    level                   = 0.0,
-                    min_level               = 0.0;
-
-    cpl_image       *tmp_img                = NULL,
-                    *bad_pix_mask           = NULL,
-                    *tmp_bad_pix_mask       = NULL;
-
-    float           *pbad_pix_mask          = NULL,
-                    *ptmp_bad_pix_mask      = NULL;
-
-    const float     *pdata                  = NULL;
+    int             nx                   = 0,
+                    ny                   = 0,
+                    slice_height         = 20,
+                    ix                   = 0,
+                    iy                   = 0,
+                    i                    = 0;
+    double          thresh               = badpix_thresh / 100.,
+                    level                = 0.0,
+                    min_level            = 0.0;
+    cpl_image   *   tmp_img             = NULL,
+                *   bad_pix_mask        = NULL,
+                *   tmp_bad_pix_mask    = NULL;
+    float       *   pbad_pix_mask       = NULL,
+                *   ptmp_bad_pix_mask   = NULL;
+    const float *   pdata               = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(data != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
-
-        KMO_TRY_ASSURE((surrounding_pixels >= 0) &&
-                       (surrounding_pixels <= 8),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "surrounding_pixels must be between 0 and 8!");
-
-        KMO_TRY_ASSURE((badpix_thresh >= 0) &&
-                       (badpix_thresh <= 100),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "badpix_thresh must be between 0 and 100%%!");
-
+        /* Check Entries */
+        KMO_TRY_ASSURE(data != NULL, CPL_ERROR_NULL_INPUT, 
+                "No input data is provided!");
+        KMO_TRY_ASSURE((surrounding_pixels >= 0) && (surrounding_pixels <= 8),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "surrounding_pixels must be between 0 and 8!");
+        KMO_TRY_ASSURE((badpix_thresh >= 0) && (badpix_thresh <= 100),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "badpix_thresh must be between 0 and 100%%!");
         KMO_TRY_ASSURE(fabs(
-                           ((double)KMOS_DETECTOR_SIZE-2*KMOS_BADPIX_BORDER)/(double)slice_height -
-                           (int)((KMOS_DETECTOR_SIZE-2*KMOS_BADPIX_BORDER)/slice_height)
-                           ) < 1e-6,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "slice_height (is %d) must divide 2040 as integer result!",
-                       slice_height);
+        ((double)KMOS_DETECTOR_SIZE-2*KMOS_BADPIX_BORDER)/(double)slice_height -
+        (int)((KMOS_DETECTOR_SIZE-2*KMOS_BADPIX_BORDER)/slice_height)) < 1e-6,
+                CPL_ERROR_ILLEGAL_INPUT,
+                "slice_height (is %d) must divide 2040 as integer result!",
+                slice_height);
 
+        /* Initialise */
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
+
         KMO_TRY_CHECK_ERROR_STATE();
 
-        // figure out the minimum level
+        /* Collapse (mean) along x, excluding the 4 pixels BORDER */
         tmp_img = cpl_image_collapse_window_create(data,
-                                                   KMOS_BADPIX_BORDER+1,
-                                                   KMOS_BADPIX_BORDER+1,
-                                                   nx-KMOS_BADPIX_BORDER,
-                                                   ny-KMOS_BADPIX_BORDER,
-                                                   1);
+                KMOS_BADPIX_BORDER+1, KMOS_BADPIX_BORDER+1,
+                nx-KMOS_BADPIX_BORDER, ny-KMOS_BADPIX_BORDER, 1);
         cpl_image_divide_scalar(tmp_img, nx-2*KMOS_BADPIX_BORDER);
+        
+        /* min_level is 5% of the median */
         min_level = cpl_image_get_median(tmp_img)/20; // 5%
+
+        /* Cleanup */
         cpl_image_delete(tmp_img); tmp_img = NULL;
-        KMO_TRY_CHECK_ERROR_STATE();
 
-        // create internal preliminary badpixel_flat, based on badpixel_dark
-        // already present in data
-        KMO_TRY_EXIT_IF_NULL(
-            tmp_bad_pix_mask = cpl_image_new(nx, ny, CPL_TYPE_FLOAT));
-        KMO_TRY_EXIT_IF_NULL(
-            ptmp_bad_pix_mask = cpl_image_get_data_float(tmp_bad_pix_mask));
-        KMO_TRY_EXIT_IF_NULL(
-            pdata = cpl_image_get_data_float_const(data));
+        KMO_TRY_CHECK_ERROR_STATE();
 
+        /* Create FLOAT image tmp_bad_pix_mask from the input image BPM */
+        /* TODO : Replace the following by */
+        /* cpl_image_duplicate()/cpl_image_fill()/cpl_image_fill_rejected() */
+        tmp_bad_pix_mask    = cpl_image_new(nx, ny, CPL_TYPE_FLOAT);
+        ptmp_bad_pix_mask   = cpl_image_get_data_float(tmp_bad_pix_mask);
+        pdata               = cpl_image_get_data_float_const(data);
         for (ix = 0; ix < nx; ix++) {
             for (iy = 0; iy < ny; iy++) {
-                if (cpl_image_is_rejected(data, ix+1, iy+1))
-                {
+                if (cpl_image_is_rejected(data, ix+1, iy+1)) {
                     ptmp_bad_pix_mask[ix+iy*nx] = 0.0;
                     cpl_image_reject(tmp_bad_pix_mask, ix+1, iy+1);
                 } else {
@@ -184,14 +174,10 @@ cpl_image* kmo_create_bad_pix_flat_thresh(const cpl_image* data,
         // set everything as bad below
         for (i = KMOS_BADPIX_BORDER+1;
              i <= nx-KMOS_BADPIX_BORDER-slice_height+1;
-             i += slice_height)
-        {
+             i += slice_height) {
             tmp_img = cpl_image_collapse_window_create(data,
-                                                       KMOS_BADPIX_BORDER+1,
-                                                       i,
-                                                       nx-KMOS_BADPIX_BORDER,
-                                                       i+slice_height-1,
-                                                       1);
+                    KMOS_BADPIX_BORDER+1, i, nx-KMOS_BADPIX_BORDER,
+                    i+slice_height-1, 1);
             cpl_image_divide_scalar(tmp_img, nx-2*KMOS_BADPIX_BORDER);
             KMO_TRY_CHECK_ERROR_STATE();
 
@@ -200,17 +186,16 @@ cpl_image* kmo_create_bad_pix_flat_thresh(const cpl_image* data,
 
             // in case IFUs are shifted too much (e.g. in kmosp-test-case at
             // top border) the level is about 0.2 and way too low
-            if (level < min_level) {
-                level = min_level;
-            }
+            if (level < min_level) level = min_level;
 
+            /* Cleanup */
             cpl_image_delete(tmp_img); tmp_img = NULL;
-//            cpl_msg_debug(cpl_func, "y: %d, level: %g", i, level);
+
+            // cpl_msg_debug(cpl_func, "y: %d, level: %g", i, level);
             for (ix = KMOS_BADPIX_BORDER; ix < nx-KMOS_BADPIX_BORDER; ix++) {
                 for (iy = i-1; iy <= i+slice_height-2; iy++) {
                     if ((ptmp_bad_pix_mask[ix+iy*nx] == 1.) &&
-                        (pdata[ix+iy*nx] < level))
-                    {
+                        (pdata[ix+iy*nx] < level)) {
                         ptmp_bad_pix_mask[ix+iy*nx] = 0.0;
                         cpl_image_reject(tmp_bad_pix_mask, ix+1, iy+1);
                     }
@@ -229,11 +214,10 @@ cpl_image* kmo_create_bad_pix_flat_thresh(const cpl_image* data,
         for (iy = 1; iy < ny - 1; iy++) {
             for (ix = 1; ix < nx - 1; ix++) {
                 if ((8 - surrounding_pixels) >=
-                     (ptmp_bad_pix_mask[ix-1+iy*nx] + ptmp_bad_pix_mask[ix+1+iy*nx] +
-                      ptmp_bad_pix_mask[ix-1+(iy-1)*nx] + ptmp_bad_pix_mask[ix+(iy-1)*nx] +
-                      ptmp_bad_pix_mask[ix+1+(iy-1)*nx] + ptmp_bad_pix_mask[ix-1+(iy+1)*nx] +
-                      ptmp_bad_pix_mask[ix+(iy+1)*nx] + ptmp_bad_pix_mask[ix+1+(iy+1)*nx]))
-                {
+     (ptmp_bad_pix_mask[ix-1+iy*nx] + ptmp_bad_pix_mask[ix+1+iy*nx] +
+      ptmp_bad_pix_mask[ix-1+(iy-1)*nx] + ptmp_bad_pix_mask[ix+(iy-1)*nx] +
+      ptmp_bad_pix_mask[ix+1+(iy-1)*nx] + ptmp_bad_pix_mask[ix-1+(iy+1)*nx] +
+      ptmp_bad_pix_mask[ix+(iy+1)*nx] + ptmp_bad_pix_mask[ix+1+(iy+1)*nx])) {
                     pbad_pix_mask[ix+iy*nx] = 0.0;
                     cpl_image_reject(bad_pix_mask, ix+1, iy+1);
                 }
@@ -258,158 +242,33 @@ cpl_image* kmo_create_bad_pix_flat_thresh(const cpl_image* data,
     return bad_pix_mask;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Returns the index to the first non-rejected element
-
-    @param vec          The vector to examine
-    @param from left    TRUE if the vector should be examioned from the left,
-                        FALSE otherwise
-    @return
-        The found index
-*/
-int  kmo_find_first_non_rejected(const kmclipm_vector *vec,
-                                 int from_left)
-{
-    int index   = -1,
-        size    = 0,
-        i       = 0;
-
-    KMO_TRY
-    {
-        size = kmclipm_vector_get_size(vec);
-
-        if (from_left) {
-            i = 0;
-            while ((i < size) && (kmclipm_vector_is_rejected(vec, i))) {
-                i++;
-            }
-            if (i < size) {
-                index = i;
-            }
-        } else {
-            i = size-1;
-            while ((i >= 0) && (kmclipm_vector_is_rejected(vec, i))) {
-                i--;
-            }
-            if (i >= 0) {
-                index = i;
-            }
-        }
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-        index = -1;
-    }
-
-    return index;
-}
-
-/**
-    @brief
-        Validate the number of slitlet edges
-
-    @param nr_edges     The number of found edges
-    @param cut_left     TRUE if the leftmost slitlet is cut halfways
-    @param cut_right    TRUE if the rightmost slitlet is cut halfways
-
-    @return
-        TRUE if valid, FALSE otherwise
-*/
-int  kmo_validate_nr_edges(int nr_edges,
-                           int cut_left,
-                           int cut_right)
-{
-    int ret = FALSE;
-
-    if (!cut_left && !cut_right) {
-        // normal case
-        switch(nr_edges) {
-        case 28:
-        case 56:
-        case 84:
-        case 112:
-        case 140:
-        case 168:
-        case 196:
-        case 224:
-            ret = TRUE;
-            break;
-        default:
-            break;
-        }
-    }
-
-    if (cut_left && cut_right) {
-        // first AND last slitlet cut halfways
-        switch(nr_edges) {
-        case 24:
-        case 52:
-        case 80:
-        case 108:
-        case 136:
-        case 164:
-        case 192:
-        case 220:
-            ret = TRUE;
-            break;
-        default:
-            break;
-        }
-    } else {
-        // first OR last slitlet cut halfways
-        switch(nr_edges) {
-        case 26:
-        case 54:
-        case 82:
-        case 110:
-        case 138:
-        case 166:
-        case 194:
-        case 222:
-            ret = TRUE;
-            break;
-        default:
-            break;
-        }
-    }
-
-    return ret;
-}
-
-/**
-    @brief
-        Calculate threshold for flat frame.
-
-    @param midline             The cut across the middle of the detector image.
-    @param thresh estimate     The initial threshold estimate.
-    @param t_value             (Output) Contains the number of detected edges at
-                               different threshold levels
-    @param t_level             (Output) Contains the threshold level at
-                               different threshold levels
-    @param t_pos               (Output) Contains the index to t_value and t_level
-                               used to determine the retuned value
-
-    @return
-        A robust threshold value
-
-    Taking a simple histogram of the @c midline isn't sufficient, since the
-    detector image can be vignetted, therefore some of the slitlets can lie
-    below the estimated threshold. <br>
-    Here we additionally count the number of detected slitlets edges. If this
-    number isn't a multiple of expected IFU-slitlet-edges, we lower the threshold
-    and count again. At the end the most reasonable value is returned.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c midline is NULL.
+  @brief Calculate threshold for flat frame.
+  @param    midline     The cut across the middle of the detector image.
+  @param    thresh_estimate The initial threshold estimate.
+  @param    t_value     (Out) Nb of detected edges at diff. thresh. levels
+  @param    t_level     (Out) Thresh. level at different threshold levels
+  @param    t_pos       (Out) index to t_value and t_level 
+  @return A robust threshold value
+    
+  Taking a simple histogram of the @c midline isn't sufficient, since the
+  detector image can be vignetted, therefore some of the slitlets can lie
+  below the estimated threshold. <br>
+  Here we additionally count the number of detected slitlets edges. If this
+  number isn't a multiple of expected IFU-slitlet-edges, we lower the threshold
+  and count again. At the end the most reasonable value is returned.
+  
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c midline is NULL.
 */
-kmclipm_vector*  kmo_analize_slitedges(const kmclipm_vector *midline,
-                                       double thresh_estimate,
-                                       kmclipm_vector **t_value,
-                                       kmclipm_vector **t_level,
-                                       int *t_pos)
+/*----------------------------------------------------------------------------*/
+kmclipm_vector * kmo_analize_slitedges(
+        const kmclipm_vector    *   midline,
+        double                      thresh_estimate,
+        kmclipm_vector          **  t_value,
+        kmclipm_vector          **  t_level,
+        int                     *   t_pos)
 {
     int             t_cnt           = 20,
                     start           = 0,
@@ -427,20 +286,14 @@ kmclipm_vector*  kmo_analize_slitedges(const kmclipm_vector *midline,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((midline != NULL) &&
-                       (t_value != NULL) &&
-                       (t_level != NULL) &&
-                       (t_pos != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        // init
-        // t_level: holds the threshold level
-        // t_value: holds the detected number of edges
-        KMO_TRY_EXIT_IF_NULL(
-            *t_level = kmclipm_vector_new(t_cnt));
-        KMO_TRY_EXIT_IF_NULL(
-            *t_value = kmclipm_vector_new(t_cnt));
+        /* Check entries */
+        KMO_TRY_ASSURE(midline != NULL && t_value != NULL && t_level != NULL &&
+                t_pos != NULL, CPL_ERROR_NULL_INPUT, "Input data is missing");
+
+        /* t_level: holds the threshold level */
+        /* t_value: holds the detected number of edges */
+        KMO_TRY_EXIT_IF_NULL(*t_level = kmclipm_vector_new(t_cnt));
+        KMO_TRY_EXIT_IF_NULL(*t_value = kmclipm_vector_new(t_cnt));
         *t_pos = 0;
 
         // fill vectors with threshold levels and number of edges (NOE)
@@ -450,14 +303,14 @@ kmclipm_vector*  kmo_analize_slitedges(const kmclipm_vector *midline,
 
             pos = kmo_get_slitedges(midline, thresh_estimate);
             if (pos == NULL) {
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_vector_reject(*t_value, t));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_vector_reject(*t_value, t));
                 cpl_error_reset();
             } else {
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_vector_set(*t_value, t, kmclipm_vector_get_size(pos)));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_vector_set(*t_value, t, 
+                            kmclipm_vector_get_size(pos)));
             }
             kmclipm_vector_delete(pos); pos = NULL;
+
             KMO_TRY_CHECK_ERROR_STATE();
 
             thresh_estimate -= t_delta;
@@ -467,17 +320,16 @@ kmclipm_vector*  kmo_analize_slitedges(const kmclipm_vector *midline,
         // invalidate all levels with non-matching NOE (due to outliers)
         // valid values: 28,56,84,112,140,168,196,224 edges for 1 to 8 IFUs
         for (t = 0; t < t_cnt; t++) {
-            if (!kmo_validate_nr_edges(
-                        (int)(kmclipm_vector_get(*t_value, t, &is_rej)+.5),
-                        FALSE, FALSE))
-            {
+            if (!kmo_validate_nr_edges((int)(kmclipm_vector_get(*t_value, t, 
+                                &is_rej)+.5), FALSE, FALSE)) {
                 kmclipm_vector_reject(*t_value, t);
                 kmclipm_vector_reject(*t_level, t);
             }
         }
 
         // all rejected or all rejected but one, exit
-        if (kmclipm_vector_count_rejected(*t_value)+1 >= kmclipm_vector_get_size(*t_value)) {
+        if (kmclipm_vector_count_rejected(*t_value)+1 >= 
+                kmclipm_vector_get_size(*t_value)) {
             *t_pos = -1;
             thresh_final = -1;
             kmclipm_vector_delete(*t_value); *t_value = NULL;
@@ -512,12 +364,13 @@ kmclipm_vector*  kmo_analize_slitedges(const kmclipm_vector *midline,
                                 stop = t;
                                 last_val = val;
                             } else {
-                                // subsequent range, compare it with stored range
+                            // subsequent range, compare it with stored range
                                 if (last_stop-last_start+1 > t-start+1) {
                                     // stored range is still larger
                                 } else {
-                                    // subsequent range is larger, keep this one
-                                    // if equal take as well this one (at lower threshold level)
+                                    // subsequent range is larger, keep this 
+                                    // one, if equal take as well this one 
+                                    // (at lower threshold level)
                                     last_start = start;
                                     last_stop = last;
                                     start = t;
@@ -560,26 +413,20 @@ kmclipm_vector*  kmo_analize_slitedges(const kmclipm_vector *midline,
             thresh_final = kmclipm_vector_get(*t_level, *t_pos, &is_rej);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            KMO_TRY_EXIT_IF_NULL(
-                pos = kmo_get_slitedges(midline, thresh_final));
+            KMO_TRY_EXIT_IF_NULL(pos=kmo_get_slitedges(midline, thresh_final));
 
-            //
             // check for cut slitlets at beginning/end
             // if both cut, reject pos-vector
-            //
             double  *ppos       = NULL;
             int     cut_first   = FALSE,
                     cut_last    = FALSE,
                     size = kmclipm_vector_get_size(pos);
-            KMO_TRY_EXIT_IF_NULL(
-                ppos = cpl_vector_get_data(pos->data));
+            KMO_TRY_EXIT_IF_NULL(ppos = cpl_vector_get_data(pos->data));
 
-            if (ppos[1]-ppos[0] < (KMOS_SLITLET_X+KMOS_GAP_WIDTH)/2) {
+            if (ppos[1]-ppos[0] < (KMOS_SLITLET_X+KMOS_GAP_WIDTH)/2) 
                 cut_first = TRUE;
-            }
-            if (ppos[size-1]-ppos[size-2] < (KMOS_SLITLET_X+KMOS_GAP_WIDTH)/2) {
+            if (ppos[size-1]-ppos[size-2] < (KMOS_SLITLET_X+KMOS_GAP_WIDTH)/2) 
                 cut_last = TRUE;
-            }
             if (cut_first && cut_last) {
                 *t_pos = -1;
                 thresh_final = -1;
@@ -596,34 +443,32 @@ kmclipm_vector*  kmo_analize_slitedges(const kmclipm_vector *midline,
         kmclipm_vector_delete(*t_value); *t_value = NULL;
         kmclipm_vector_delete(*t_level); *t_level = NULL;
     }
-
     return pos;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Advanced identification of slitlet-edges with thresholding.
-
-    @param midline             The cut across the middle of the detector image.
-    @param thresh              The threshold to apply.
-    @param cut_first           (Output) FALSE if first edge belongs to slitlet,
-                               TRUE otherwise
-    @param cut_last            (Output) FALSE if first edge belongs to slitlet,
-                               TRUE otherwise
-
-    @return
-        A vector containing the positions of the edges.
-
-    Unifies kmo_calc_thresh() and kmo_get_slitedges() for the case that with
-    standard processing the number of detected edges wasn't a multiple of 28.
-
-    Possible cpl_error_code set in this function:
-    @li CPL_ERROR_NULL_INPUT    if @c midline is NULL.
+  @brief Advanced identification of slitlet-edges with thresholding.
+  @param    midline     The cut across the middle of the detector image.
+  @param    thresh      The threshold to apply.
+  @param    cut_first   (Out) FALSE if first edge belongs to slitlet,
+                        TRUE otherwise
+  @param    cut_last    (Out) FALSE if first edge belongs to slitlet,
+                        TRUE otherwise
+  @return A vector containing the positions of the edges.
+
+  Unifies kmo_calc_thresh() and kmo_get_slitedges() for the case that with
+  standard processing the number of detected edges wasn't a multiple of 28.
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c midline is NULL.
 */
-kmclipm_vector* kmo_analize_slitedges_advanced(kmclipm_vector *midline,
-                                               double thresh,
-                                               int *cut_first,
-                                               int *cut_last)
+/*----------------------------------------------------------------------------*/
+kmclipm_vector * kmo_analize_slitedges_advanced(
+        kmclipm_vector  *   midline,
+        double              thresh,
+        int             *   cut_first,
+        int             *   cut_last)
 {
     kmclipm_vector  *pos            = NULL,
                     *km_slits       = NULL,
@@ -648,25 +493,18 @@ kmclipm_vector* kmo_analize_slitedges_advanced(kmclipm_vector *midline,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((midline != NULL) &&
-                       (cut_first != NULL) &&
-                       (cut_last != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(midline != NULL && cut_first != NULL && cut_last != NULL,
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         *cut_first       = FALSE;
         *cut_last        = FALSE;
 
-        //
         // get edge positions
-        //
         KMO_TRY_EXIT_IF_NULL(
             pos = kmo_get_slitedges(midline, thresh));
 
-        //
-        // check for cut slitlets at beginning/end (left and right side of detector)
-        // and reject them
-        //
+        // check for cut slitlets at beginning/end (left and right side of 
+        // detector) and reject them
         KMO_TRY_EXIT_IF_NULL(
             ppos = cpl_vector_get_data(pos->data));
         size = kmclipm_vector_get_size(pos);
@@ -679,9 +517,7 @@ kmclipm_vector* kmo_analize_slitedges_advanced(kmclipm_vector *midline,
             kmclipm_vector_reject(pos, size-1);
         }
 
-        //
         // get intermediate vectors with slit-widths and gap-widths
-        //
         KMO_TRY_EXIT_IF_NULL(
             pos_valid = kmclipm_vector_create_non_rejected(pos));
 
@@ -693,9 +529,7 @@ kmclipm_vector* kmo_analize_slitedges_advanced(kmclipm_vector *midline,
             KMO_TRY_EXIT_IF_ERROR(
                 kmo_get_slit_gap(pos_valid, &slits, &gaps));
 
-            //
             // calculate medians and averages on slits/gaps after rejection
-            //
             KMO_TRY_EXIT_IF_NULL(
                 km_slits = kmclipm_vector_create(slits));
             KMO_TRY_EXIT_IF_ERROR(
@@ -705,9 +539,9 @@ kmclipm_vector* kmo_analize_slitedges_advanced(kmclipm_vector *midline,
 
             // gaps is one shorter than slits, add one element at end and reject it
             KMO_TRY_ASSURE(cpl_vector_get_size(slits) == cpl_vector_get_size(gaps)+1,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Number of slitlets should be equal number of gaps +1 (%d and %d)",
-                           (int)cpl_vector_get_size(slits), (int)cpl_vector_get_size(gaps));
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "Number of slitlets should be equal number of gaps +1 (%d and %d)",
+                    (int)cpl_vector_get_size(slits), (int)cpl_vector_get_size(gaps));
             KMO_TRY_EXIT_IF_NULL(
                 km_gaps = kmclipm_vector_new(cpl_vector_get_size(slits)));
             for (i = 0; i < cpl_vector_get_size(gaps); i++) {
@@ -796,28 +630,15 @@ kmclipm_vector* kmo_analize_slitedges_advanced(kmclipm_vector *midline,
     return pos;
 }
 
-cpl_array** kmo_analize_ifu_edges(kmclipm_vector *pos,
-                                  cpl_array *ifu_inactive,
-                                  int cut_first,
-                                  int cut_last,
-                                  int nx)
+cpl_array** kmo_accept_all_ifu_edges(kmclipm_vector *pos,
+                                     cpl_array *ifu_inactive)
 {
     int         i                   = 0,
-                ind1                = 0,
-                ind2                = 0,
+                j                   = 0,
                 size                = 0,
-                has_large_step      = FALSE,
-                nr_ifu              = 0,
-                ifu_width           = 0,
-                estimated_ifu_width = 0,
-                ifu_center          = 0,
-                invalidate_all      = FALSE;
-    double      mean_gap            = 0.,
-                *ppos_valid         = NULL,
-                *ppos_cut           = NULL;
-    cpl_vector  *pos_valid          = NULL,
-                *pos_cut            = NULL,
-                *gaps               = NULL;
+                nr_ifu              = 0;
+    double      *ppos_valid         = NULL;
+    cpl_vector  *pos_valid          = NULL;
     cpl_array   **array             = NULL;
 
     KMO_TRY
@@ -829,259 +650,15 @@ cpl_array** kmo_analize_ifu_edges(kmclipm_vector *pos,
             array[i] = NULL;
         }
 
-        if (pos == NULL) {
-            // invalidate all IFUs
-            for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
-                if (cpl_array_get_int(ifu_inactive, i, NULL) == 0) {
-                    KMO_TRY_EXIT_IF_ERROR(
-                        cpl_array_set_int(ifu_inactive, i, 2));
-                }
-            }
-            KMO_TRY_CHECK_ERROR_STATE();
-            return array;
-        }
-
         KMO_TRY_EXIT_IF_NULL(
             pos_valid = kmclipm_vector_create_non_rejected(pos));
         size = cpl_vector_get_size(pos_valid);
         KMO_TRY_CHECK_ERROR_STATE();
 
         //
-        // check for cut slitlets (halfways cut or dropped of the detector)
-        // either completely out of zoom or shifted extremly left or right
+        // check if we have all 224 edges, then just fill them into the array
         //
-        if (kmo_validate_nr_edges(size, cut_first, cut_last)) {
-            // either one or two slitlets cut halfways
-            if (cut_first) {
-                // just first AND last slitlets are cut halfways
-                int fi = kmo_find_first_non_rejected(pos, TRUE);
-                for (i = fi; i < fi+26; i++) {
-                    kmclipm_vector_reject(pos, i);
-                }
-                cut_first = FALSE;
-            }
-            if (cut_last) {
-                int fi = kmo_find_first_non_rejected(pos, FALSE);
-                for (i = fi; i > fi-26; i--) {
-                    kmclipm_vector_reject(pos, i);
-                }
-                cut_last = FALSE;
-            }
-
-            cpl_vector_delete(pos_valid); pos_valid = NULL;
-            KMO_TRY_EXIT_IF_NULL(
-                pos_valid = kmclipm_vector_create_non_rejected(pos));
-            size = cpl_vector_get_size(pos_valid);
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            if (!kmo_validate_nr_edges(size, cut_first, cut_last)) {
-                cpl_msg_warning("","First and/or last slitlet had been cut off. "
-                                "After omitting these slitlets, still an invalid "
-                                "number of slitlets are counted (number of valid "
-                                "edges found: %d edges)", size);
-                invalidate_all = TRUE;
-            }
-        } else {
-            KMO_TRY_EXIT_IF_NULL(
-                ppos_valid = cpl_vector_get_data(pos_valid));
-
-            if ((ppos_valid[0] < 25) && (ppos_valid[size-1] > nx-25)) {
-                // OUT OF ZOOM
-                cpl_msg_warning("","Out of zoom! At least one slitlet is completely off the "
-                                "detector, can't detect on which side. So invalidating all "
-                                "IFUs on this detector now (number of valid edges found: %d edges)", size);
-                invalidate_all = TRUE;
-            } else {
-                // BIG RIGHT/LEFT SHIFT
-                if (ppos_valid[0] > nx-ppos_valid[size-1]) {
-                    // whole detector shifted to the right, omitting slitlets on right side
-                    // until nr. slitlets is modulo 28
-                    while(size%(2*KMOS_SLITLET_Y) != 0) {
-                        int fi = kmo_find_first_non_rejected(pos, FALSE);
-                        kmclipm_vector_reject(pos, fi);
-                        size = kmclipm_vector_count_non_rejected(pos);
-                    }
-                    cut_first = FALSE;
-                    cut_last = FALSE;
-                } else {
-                    // whole detector shifted to the left, omitting slitlets on left side
-                    // until nr. slitlets is modulo 28
-                    while(size%(2*KMOS_SLITLET_Y) != 0) {
-                        int fi = kmo_find_first_non_rejected(pos, TRUE);
-                        kmclipm_vector_reject(pos, fi);
-                        size = kmclipm_vector_count_non_rejected(pos);
-                    }
-                    cut_first = FALSE;
-                    cut_last = FALSE;
-                }
-
-                cpl_vector_delete(pos_valid); pos_valid = NULL;
-                KMO_TRY_EXIT_IF_NULL(
-                    pos_valid = kmclipm_vector_create_non_rejected(pos));
-                size = cpl_vector_get_size(pos_valid);
-                KMO_TRY_CHECK_ERROR_STATE();
-
-                if (!kmo_validate_nr_edges(size, cut_first, cut_last)) {
-                    cpl_msg_warning("","Slitlets have a large shift on detector, "
-                                    "some of them have been omitted. But still wrong "
-                                    "number of slitlets (number of valid edges found: %d edges)", size);
-                    invalidate_all = TRUE;
-                }
-            }
-        }
-
-        if (!invalidate_all) {
-            if (size < 2*KMOS_SLITLET_Y) {
-                // invalidate all IFUs (less than 28 valid edges)
-                invalidate_all = TRUE;
-            }
-            KMO_TRY_CHECK_ERROR_STATE();
-        }
-
-        if (invalidate_all) {
-            for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
-                if (cpl_array_get_int(ifu_inactive, i, NULL) == 0) {
-                    KMO_TRY_EXIT_IF_ERROR(
-                        cpl_array_set_int(ifu_inactive, i, 2));
-                }
-            }
-            KMO_TRY_CHECK_ERROR_STATE();
-            cpl_vector_delete(pos_valid); pos_valid = NULL;
-            return array;
-        }
-
-        //
-        // check slitlet edges in packets of 28 for integrity
-        //
-        ind1 = 0;
-        ind2 = 2*KMOS_SLITLET_Y-1;
-        while (ind2 < cpl_vector_get_size(pos_valid))
-        {
-            KMO_TRY_EXIT_IF_NULL(
-                pos_cut = cpl_vector_extract(pos_valid, ind1, ind2, 1));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_get_slit_gap(pos_cut, NULL, &gaps));
-
-            // check if there is a large step in the gaps (e.g. from vignetting)
-            mean_gap = cpl_vector_get_mean(gaps);
-            for (i = 0; i < cpl_vector_get_size(gaps); i++) {
-                if ((mean_gap+slit_tol < cpl_vector_get(gaps, i)) || (mean_gap-slit_tol > cpl_vector_get(gaps, i))) {
-                    has_large_step = ind1;
-                    break;
-                }
-            }
-
-            if (!has_large_step) {
-                // check IFU width
-                ifu_width = (int)(cpl_vector_get(pos_cut, 2*KMOS_SLITLET_Y-1) -
-                                  cpl_vector_get(pos_cut, 0) + 1);
-                estimated_ifu_width = (int)rint(KMOS_SLITLET_Y*KMOS_SLITLET_X + (KMOS_SLITLET_Y-1)*KMOS_GAP_WIDTH);  //248
-                if ((ifu_width > estimated_ifu_width+10) || (ifu_width < estimated_ifu_width-10)) {
-                    KMO_TRY_ASSURE(1==0,
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "HOUSTON, WE HAVE A PROBLEM! "
-                                   "(ifu width: estimated: %d, actual: %d)", estimated_ifu_width, ifu_width);
-                } else {
-                    // check which IFU these edges belong to
-                    ifu_center = cpl_vector_get(pos_cut, cpl_vector_get_size(pos_cut)/2);
-                    if ((ifu_center >= 20) && (ifu_center <= 270)) {
-                        nr_ifu = 1;
-                    } else if((ifu_center >= 271) && (ifu_center <= 521)) {
-                        nr_ifu = 2;
-                    } else if((ifu_center >= 522) && (ifu_center <= 772)) {
-                        nr_ifu = 3;
-                    } else if((ifu_center >= 773) && (ifu_center <= 1023)) {
-                        nr_ifu = 4;
-                    } else if((ifu_center >= 1024) && (ifu_center <= 1274)) {
-                        nr_ifu = 5;
-                    } else if((ifu_center >= 1275) && (ifu_center <= 1525)) {
-                        nr_ifu = 6;
-                    } else if((ifu_center >= 1526) && (ifu_center <= 1776)) {
-                        nr_ifu = 7;
-                    } else if((ifu_center >= 1777) && (ifu_center <= 2027)) {
-                        nr_ifu = 8;
-                    } else {
-                        KMO_TRY_ASSURE(1==0,
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "HOUSTON, WE HAVE A PROBLEM! "
-                                       "(ifu-center not at expected position: %d)", ifu_center);
-                    }
-
-                    if (cpl_array_get_int(ifu_inactive, nr_ifu-1, NULL) == 1) {
-                        // IFU has been set inactive. dismiss found edges and continue
-                    } else {
-                        // fill array
-                        KMO_TRY_EXIT_IF_NULL(
-                            array[nr_ifu-1] = cpl_array_new(2*KMOS_SLITLET_Y, CPL_TYPE_INT));
-                        KMO_TRY_EXIT_IF_NULL(
-                            ppos_cut = cpl_vector_get_data(pos_cut));
-                        for (i = 0; i < 2*KMOS_SLITLET_Y; i++) {
-                            KMO_TRY_EXIT_IF_ERROR(
-                                cpl_array_set_int(array[nr_ifu-1], i, ppos_cut[i]));
-                        }
-                    }
-                }
-            } else {
-                KMO_TRY_ASSURE(1==0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "HOUSTON, WE HAVE A PROBLEM! (large gap somwhere "
-                               "between pixel %d and %d in x-direction)",
-                               has_large_step, has_large_step+2*KMOS_SLITLET_Y);
-            }
-
-            cpl_vector_delete(pos_cut); pos_cut = NULL;
-            cpl_vector_delete(gaps); gaps = NULL;
-
-            ind1 += 2*KMOS_SLITLET_Y;
-            ind2 += 2*KMOS_SLITLET_Y;
-        }
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-        for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
-            cpl_array_delete(array[i]); array[i] = NULL;
-        }
-        cpl_free(array); array = NULL;
-        cpl_vector_delete(gaps); gaps = NULL;
-        cpl_vector_delete(pos_cut); pos_cut = NULL;
-    }
-
-    cpl_vector_delete(pos_valid); pos_valid = NULL;
-
-    return array;
-}
-
-
-cpl_array** kmo_accept_all_ifu_edges(kmclipm_vector *pos,
-                                     cpl_array *ifu_inactive)
-{
-    int         i                   = 0,
-                j                   = 0,
-                size                = 0,
-                nr_ifu              = 0;
-    double      *ppos_valid         = NULL;
-    cpl_vector  *pos_valid          = NULL;
-    cpl_array   **array             = NULL;
-
-    KMO_TRY
-    {
-        // allocate array of cpl_arrays to return and initialize to zero
-        KMO_TRY_EXIT_IF_NULL(
-            array = (cpl_array**)cpl_malloc(KMOS_IFUS_PER_DETECTOR * sizeof(cpl_array*)));
-        for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
-            array[i] = NULL;
-        }
-
-        KMO_TRY_EXIT_IF_NULL(
-            pos_valid = kmclipm_vector_create_non_rejected(pos));
-        size = cpl_vector_get_size(pos_valid);
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        //
-        // check if we have all 224 edges, then just fill them into the array
-        //
-        if (size == 224) {
+        if (size == 224) {
             KMO_TRY_EXIT_IF_NULL(
                 ppos_valid = cpl_vector_get_data(pos_valid));
             j = 0;
@@ -2617,19 +2194,6 @@ cpl_error_code kmo_edge_trace(const cpl_image* data,
                 break;
             }
         }
-
-// doesn't work for rotation! just skip it, rejection is applied afterwards anyway
-//        // get level of group-positions with an edge
-//        double level = kmclipm_vector_median(mean_dsec);
-//        KMO_TRY_CHECK_ERROR_STATE();
-
-//        for (int i = 0; i < nr_groups; i++)
-//        {
-//            // check if below 10% margin
-//            if (pmean_dsec[i] < (0.1 * level)) {
-//                pedge[i] = -1.0;
-//            }
-//        }
     }
     KMO_CATCH
     {
@@ -2647,77 +2211,74 @@ cpl_error_code kmo_edge_trace(const cpl_image* data,
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Create x- and y-calibration frames, normalise global slope, update badpix.
-
-    @param slitlet_ids    The slitlet IDs of each edge.
-    @param edgepars       The parameters describing the polynomial.
-    @param detector_nr    The detector number the frames belong to.
-    @param data           (Input) The combined data.
-                          (Output) The normalised data.
-    @param noise          (Input) The combined noise.
-                          (Output) The normalised noise.
-    @param bad_pixel_mask (Input) The estimate of preliminary badpixel mask
-                          (Output) Will contain the updated badpixel mask when
-                          returning.
-    @param xcal           (Output) The x calibration frame. Because of the
-                          orientation of the IFUs xcal and ycal are ordered
-                          individually on these two frames, they can be
-                          switched and/or flipped! see KMOS DRL-doc for
-                          further information.
-    @param ycal           (Output) The y calibration frame. Because of the
-                          orientation of the IFUs xcal and ycal are ordered
-                          individually on these two frames, they can be
-                          switched and/or flipped! see KMOS DRL-doc for
-                          further information.
-
-    @return
-        The function returns CPL_ERROR_NONE on success or a CPL error code
-        otherwise.
-
-    Along the spectral axis the exact edges for each slitlet are calculated.
-    Then the badpixel mask is updated to fit these edges (gaps are set to zero)
-    and the xcal- and ycal-frames are calculated. Because of the orientation of
-    the IFUs xcal and ycal are ordered individually on these two frames, they
-    can be switched and/or flipped! see KMOS DRL-doc for further information.
-
-    Then the slope in the spectral axis is for each slitlet is fitted using a
-    3rd order polynomial. Therefore first the starting and ending position of
-    the slitlets are detected (out of the top and bottom badpixel areas of the
-    preliminaray badpixel mask.) The values of the slitlet are averaged for each
-    row, then the polynomial is fitted against it and normalised. At the end
-    all values of the slitlet are divided by the normalised, fitted polynomial.
-    The normalisation on the whole frame will be applied in the kmo_flat()
-    function itself afterwards).
-
-    ycal is composed as follows: the integer part is the y offset of the pixel
-    centre in mas from the field centre. The decimal part denotes the IFU number
-    (from 1 to 8 for each detector)
-    xcal: the integer part is the x offset of the pixel centre from the field
-    centre in mas. Note that +ve is to the left.
-    A pixel has a resolution of 0.2 arcsec (200 mas). So the distance from the
-    leftmost to the rightmost pixel of an IFU is about 2600 mas. Adding 100 mas
-    for each edge (since the values are calculated for the pxel centres) results
-    into 2800 mas = 14*0.2 arcsec
-
-    The returned badpixel mask is applyied to the internal badpix mask in
-    cpl_image-structure of @c data and @c noise.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c xcal , @c ycal or @c edgepars is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c xcal and @c ycal aren't quadratic and of
-                                size KMOS_DETECTOR_SIZE.
+  @brief Create x- and y- calib frames, normalise global slope, update badpix.
+  @param slitlet_ids    The slitlet IDs of each edge.
+  @param edgepars       The parameters describing the polynomial.
+  @param detector_nr    The detector number the frames belong to.
+  @param data           (Input) The combined data.
+                        (Output) The normalised data.
+  @param noise          (Input) The combined noise.
+                        (Output) The normalised noise.
+  @param bad_pixel_mask (Input) The estimate of preliminary badpixel mask
+                        (Output) Will contain the updated badpixel mask when
+                        returning.
+  @param xcal           (Output) The x calibration frame. Because of the
+                        orientation of the IFUs xcal and ycal are ordered
+                        individually on these two frames, they can be
+                        switched and/or flipped! see KMOS DRL-doc for
+                        further information.
+  @param ycal           (Output) The y calibration frame. Because of the
+                        orientation of the IFUs xcal and ycal are ordered
+                        individually on these two frames, they can be
+                        switched and/or flipped! see KMOS DRL-doc for
+                        further information.
+
+  @return CPL_ERROR_NONE on success or a CPL error code otherwise.
+
+  Along the spectral axis the exact edges for each slitlet are calculated.
+  Then the badpixel mask is updated to fit these edges (gaps are set to zero)
+  and the xcal- and ycal-frames are calculated. Because of the orientation of
+  the IFUs xcal and ycal are ordered individually on these two frames, they
+  can be switched and/or flipped! see KMOS DRL-doc for further information.
+
+  Then the slope in the spectral axis is for each slitlet is fitted using a
+  3rd order polynomial. Therefore first the starting and ending position of
+  the slitlets are detected (out of the top and bottom badpixel areas of the
+  preliminaray badpixel mask.) The values of the slitlet are averaged for each
+  row, then the polynomial is fitted against it and normalised. At the end
+  all values of the slitlet are divided by the normalised, fitted polynomial.
+  The normalisation on the whole frame will be applied in the kmo_flat()
+  function itself afterwards).
+
+  ycal is composed as follows: the integer part is the y offset of the pixel
+  centre in mas from the field centre. The decimal part denotes the IFU number
+  (from 1 to 8 for each detector)
+  xcal: the integer part is the x offset of the pixel centre from the field
+  centre in mas. Note that +ve is to the left.
+  A pixel has a resolution of 0.2 arcsec (200 mas). So the distance from the
+  leftmost to the rightmost pixel of an IFU is about 2600 mas. Adding 100 mas
+  for each edge (since the values are calculated for the pxel centres) results
+  into 2800 mas = 14*0.2 arcsec
+
+  The returned badpixel mask is applyied to the internal badpix mask in
+  cpl_image-structure of @c data and @c noise.
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c xcal , @c ycal or @c edgepars is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c xcal and @c ycal aren't quadratic and of
+                              size KMOS_DETECTOR_SIZE.
 */
-cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
-                                     cpl_matrix  **edgepars,
-                                     const int detector_nr,
-                                     cpl_image *data,
-                                     cpl_image *noise,
-                                     cpl_image *bad_pixel_mask,
-                                     cpl_image *xcal,
-                                     cpl_image *ycal)
+cpl_error_code kmo_calc_calib_frames(
+        cpl_vector  **  slitlet_ids,
+        cpl_matrix  **  edgepars,
+        const int       detector_nr,
+        cpl_image   *   data,
+        cpl_image   *   noise,
+        cpl_image   *   bad_pixel_mask,
+        cpl_image   *   xcal,
+        cpl_image   *   ycal)
 {
     cpl_error_code  ret_error       = CPL_ERROR_NONE;
 
@@ -2765,31 +2326,25 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((slitlet_ids != NULL) &&
-                       (edgepars != NULL) &&
-                       (data != NULL) &&
-                       (noise != NULL) &&
-                       (bad_pixel_mask != NULL) &&
-                       (xcal != NULL) &&
-                       (ycal != NULL),
-                       CPL_ERROR_NULL_INPUT,
+        KMO_TRY_ASSURE(slitlet_ids != NULL && edgepars != NULL &&
+                data != NULL && noise != NULL && bad_pixel_mask != NULL &&
+                xcal != NULL && ycal != NULL, CPL_ERROR_NULL_INPUT,
                        "Not all input data is provided!");
 
-        KMO_TRY_ASSURE((cpl_image_get_size_x(xcal) == KMOS_DETECTOR_SIZE) &&
-                       (cpl_image_get_size_x(ycal) == KMOS_DETECTOR_SIZE) &&
-                       (cpl_image_get_size_x(data) == KMOS_DETECTOR_SIZE) &&
-                       (cpl_image_get_size_x(noise) == KMOS_DETECTOR_SIZE) &&
-                       (cpl_image_get_size_x(bad_pixel_mask) == KMOS_DETECTOR_SIZE) &&
-                       (cpl_image_get_size_y(xcal) == cpl_image_get_size_y(ycal)) &&
-                       (cpl_image_get_size_y(xcal) == cpl_image_get_size_y(data)) &&
-                       (cpl_image_get_size_y(xcal) == cpl_image_get_size_y(noise)) &&
-                       (cpl_image_get_size_y(xcal) == cpl_image_get_size_y(bad_pixel_mask)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "xcal and ycal not of same size or not "
-                       "of size 'KMOS_DETECTOR_SIZE' in x!");
-
-        KMO_TRY_ASSURE(detector_nr > 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
+        KMO_TRY_ASSURE(
+                (cpl_image_get_size_x(xcal) == KMOS_DETECTOR_SIZE) &&
+                (cpl_image_get_size_x(ycal) == KMOS_DETECTOR_SIZE) &&
+                (cpl_image_get_size_x(data) == KMOS_DETECTOR_SIZE) &&
+                (cpl_image_get_size_x(noise) == KMOS_DETECTOR_SIZE) &&
+                (cpl_image_get_size_x(bad_pixel_mask) == KMOS_DETECTOR_SIZE) &&
+                (cpl_image_get_size_y(xcal) == cpl_image_get_size_y(ycal)) &&
+                (cpl_image_get_size_y(xcal) == cpl_image_get_size_y(data)) &&
+                (cpl_image_get_size_y(xcal) == cpl_image_get_size_y(noise)) &&
+        (cpl_image_get_size_y(xcal) == cpl_image_get_size_y(bad_pixel_mask)),
+                CPL_ERROR_ILLEGAL_INPUT,
+    "xcal and ycal not of same size or not of size 'KMOS_DETECTOR_SIZE' in x!");
+
+        KMO_TRY_ASSURE(detector_nr > 0, CPL_ERROR_ILLEGAL_INPUT,
                        "detector_nr has to be positive!");
 
         nx = cpl_image_get_size_x(xcal);
@@ -2805,39 +2360,30 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
             pdata = cpl_image_get_data_float(data));
         KMO_TRY_EXIT_IF_NULL(
             pnoise = cpl_image_get_data_float(noise));
-
         KMO_TRY_EXIT_IF_NULL(
             sum_data = cpl_vector_new(ny));
         KMO_TRY_EXIT_IF_NULL(
             psum_data = cpl_vector_get_data(sum_data));
-
         KMO_TRY_EXIT_IF_NULL(
             sum_goodpix = cpl_vector_new(ny));
         KMO_TRY_EXIT_IF_NULL(
             psum_goodpix = cpl_vector_get_data(sum_goodpix));
-
         KMO_TRY_EXIT_IF_NULL(
             slitlet_border = cpl_matrix_new(ny, 2));
         KMO_TRY_EXIT_IF_NULL(
             pslitlet_border = cpl_matrix_get_data(slitlet_border));
 
-        //
         // first check if any IFU is valid
-        //
         int all_ifus_bad    = TRUE,
             valid_ifu_found = FALSE,
             first_valid_ifu = -1,
             last_valid_ifu  = -1,
             act_valid_ifu   = -1;
         for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
-            if (edgepars[j] != NULL) {
-                all_ifus_bad = FALSE;
-            }
+            if (edgepars[j] != NULL) all_ifus_bad = FALSE;
         }
 
-        //
         // invalidate any unused IFUs
-        //
         if (all_ifus_bad) {
             // reject whole image
             for (x = 1; x <= nx; x++) {
@@ -2848,17 +2394,12 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                 }
             }
         } else {
-            //
             // invalidate IFUs from left
-            //
             j = 0;
             valid_ifu_found = FALSE;
             while (!valid_ifu_found && (j < KMOS_IFUS_PER_DETECTOR)) {
-                if (edgepars[j] != NULL) {
-                    valid_ifu_found = TRUE;
-                } else {
-                    j++;
-                }
+                if (edgepars[j] != NULL)    valid_ifu_found = TRUE;
+                else                        j++;
             }
             first_valid_ifu = j;
 
@@ -2868,21 +2409,15 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                 index_left = (2*i) * 4;
                 KMO_TRY_EXIT_IF_NULL(
                     pedgepars = cpl_matrix_get_data_const(edgepars[j]));
-                for (y = KMOS_BADPIX_BORDER;
-                     y < ny-KMOS_BADPIX_BORDER; y++)
-                {
+                for (y = KMOS_BADPIX_BORDER; y < ny-KMOS_BADPIX_BORDER; y++) {
                     left = pedgepars[index_left] +
                            pedgepars[index_left+1]*y +
                            pedgepars[index_left+2]*pow(y, 2) +
                            pedgepars[index_left+3]*pow(y, 3);
 
                     left_int = (int)(left+0.5);
-                    if (left_int < 0) {
-                        left_int = 0;
-                    }
-                    if (left_int >= nx) {
-                        left_int = nx-1;
-                    }
+                    if (left_int < 0)   left_int = 0;
+                    if (left_int >= nx) left_int = nx-1;
 
                     for (x = 0; x < left_int; x++) {
                         pbad_pixel_mask[x+y*nx] = 0.0;
@@ -2891,17 +2426,12 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                 }
             }
 
-            //
             // invalidate IFUs from right
-            //
             j = KMOS_IFUS_PER_DETECTOR-1;
             valid_ifu_found = FALSE;
             while (!valid_ifu_found && (j >= 0)) {
-                if (edgepars[j] != NULL) {
-                    valid_ifu_found = TRUE;
-                } else {
-                    j--;
-                }
+                if (edgepars[j] != NULL)    valid_ifu_found = TRUE;
+                else                        j--;
             }
             last_valid_ifu = j;
 
@@ -2911,22 +2441,15 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                 index_right = (2*i + 1) * 4;
                 KMO_TRY_EXIT_IF_NULL(
                     pedgepars = cpl_matrix_get_data_const(edgepars[j]));
-                for (y = KMOS_BADPIX_BORDER;
-                     y < ny-KMOS_BADPIX_BORDER; y++)
-                {
-
+                for (y = KMOS_BADPIX_BORDER; y < ny-KMOS_BADPIX_BORDER; y++) {
                     right = pedgepars[index_right] +
                             pedgepars[index_right+1]*y +
                             pedgepars[index_right+2]*pow(y, 2) +
                             pedgepars[index_right+3]*pow(y, 3);
 
                     right_int = (int)(right+0.5);
-                    if (right_int < 0) {
-                        right_int = 0;
-                    }
-                    if (right_int >= nx) {
-                        right_int = nx-1;
-                    }
+                    if (right_int < 0)      right_int = 0;
+                    if (right_int >= nx)    right_int = nx-1;
 
                     for (x = right_int+1; x < nx; x++) {
                         pbad_pixel_mask[x+y*nx] = 0.0;
@@ -2935,10 +2458,8 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                 }
             }
 
-            //
             // invalidate IFUs in the middle
             // (find invalid IFUs between first_valid_ifu & last_valid_ifu)
-            //
             act_valid_ifu = first_valid_ifu;
             while (act_valid_ifu != last_valid_ifu) {
                 act_valid_ifu = first_valid_ifu+1;
@@ -2974,20 +2495,12 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                                     pedgepars_left_ifu[index_right+3]*pow(y, 3);
 
                             left_int = (int)(left+0.5);
-                            if (left_int < 0) {
-                                left_int = 0;
-                            }
-                            if (left_int >= nx) {
-                                left_int = nx-1;
-                            }
+                            if (left_int < 0)   left_int = 0;
+                            if (left_int >= nx) left_int = nx-1;
 
                             right_int = (int)(right+0.5);
-                            if (right_int < 0) {
-                                right_int = 0;
-                            }
-                            if (right_int >= nx) {
-                                right_int = nx-1;
-                            }
+                            if (right_int < 0)      right_int = 0;
+                            if (right_int >= nx)    right_int = nx-1;
 
                             for (x = right_int+1; x < left_int; x++) {
                                 pbad_pixel_mask[x+y*nx] = 0.0;
@@ -3003,9 +2516,7 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
             }
         }
 
-        //
         // now loop all IFUs, with valid edgepars[j]
-        //
         for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
             if ((slitlet_ids[j] != NULL) && (edgepars[j] != NULL)) {
                 KMO_TRY_EXIT_IF_NULL(
@@ -3014,22 +2525,16 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                     pslitlet_ids = cpl_vector_get_data_const(slitlet_ids[j]));
 
                 // loop the slitlets
-                for (i = 0; i < cpl_matrix_get_nrow(edgepars[j]) / 2; i++)
-                {
+                for (i = 0; i < cpl_matrix_get_nrow(edgepars[j]) / 2; i++) {
                     // create polynomials for the left and right side of the slitlet
-                    if ((i == 0) && (j == 0)) {
-                        index_last_right = 0;
-                    } else {
-                        index_last_right = index_right;
-                    }
+                    if ((i == 0) && (j == 0))   index_last_right = 0;
+                    else                        index_last_right = index_right;
 
                     index_left = (2*i) * 4;
                     index_right = (2*i + 1) * 4;
-                    if (i > 0) {
-                        index_last_right = (2*i - 1) * 4;
-                    } else if ((i == 0) && (j == 0)) {
-                        index_last_right = 0;
-                    } else {
+                    if (i > 0)                      index_last_right=(2*i-1)*4;
+                    else if ((i == 0) && (j == 0))  index_last_right = 0;
+                    else {
                         // (i == 0) && (j > 0)
                         // in this case we keep the position of the last edge
                         // of last IFU
@@ -3083,30 +2588,18 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                         // note: the calculated left_int and right_int edges are
                         // included both in the slitlet and not marked bad!
                         left_int = (int)(left+0.5);
-                        if (left_int < 0) {
-                            left_int = 0;
-                        }
-                        if (left_int >= nx) {
-                            left_int = nx-1;
-                        }
+                        if (left_int < 0)   left_int = 0;
+                        if (left_int >= nx) left_int = nx-1;
                         pslitlet_border[2*y] = left_int;
 
                         right_int = (int)(right+0.5);
-                        if (right_int < 0) {
-                            right_int = 0;
-                        }
-                        if (right_int >= nx) {
-                            right_int = nx-1;
-                        }
+                        if (right_int < 0)      right_int = 0;
+                        if (right_int >= nx)    right_int = nx-1;
                         pslitlet_border[2*y+1] = right_int;
 
                         last_right_int = (int)(last_right+0.5);
-                        if (last_right_int < 0) {
-                            last_right_int = 0;
-                        }
-                        if (last_right_int >= nx) {
-                            last_right_int = nx-1;
-                        }
+                        if (last_right_int < 0)     last_right_int = 0;
+                        if (last_right_int >= nx)   last_right_int = nx-1;
 
                         // update bad_pix with correct bad_pix border
                         if ((i == 0) && (j == 0)) {
@@ -3286,21 +2779,7 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
                         }
                     }
 
-                    // following step is skipped since it introduces ripples in the slitwise
-                    // masterflat! But the overall mean level is still ok, since the overall
-                    // level is normalised
-
-                    // calculate mean of summed up pixels of each row of a slitlet
-                    // this isn't done with cpl_vector_divide, because sum_badpix can be zero
-//                    for (int y = 0; y < ny; y++) {
-//                        if (psum_goodpix[y] > 0) {
-//                            psum_data[y] /= psum_goodpix[y];
-//                        }
-//                    }
-
-                    //
                     // normalise data & noise
-                    //
                     KMO_TRY_EXIT_IF_ERROR(
                         kmo_normalize_slitlet(sum_data, start_index, end_index));
 
@@ -3332,10 +2811,6 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
             kmo_image_reject_from_mask(xcal, bad_pixel_mask));
         KMO_TRY_EXIT_IF_ERROR(
             kmo_image_reject_from_mask(ycal, bad_pixel_mask));
-//        KMO_TRY_EXIT_IF_ERROR(
-//            cpl_image_reject_from_mask(xcal, mask));
-//        KMO_TRY_EXIT_IF_ERROR(
-//            cpl_image_reject_from_mask(ycal, mask));
     }
     KMO_CATCH
     {
@@ -3347,7 +2822,6 @@ cpl_error_code kmo_calc_calib_frames(cpl_vector **slitlet_ids,
     cpl_vector_delete(sum_data); sum_data = NULL;
     cpl_vector_delete(sum_goodpix); sum_goodpix = NULL;
     cpl_matrix_delete(slitlet_border); slitlet_border = NULL;
-//    cpl_mask_delete(mask); mask = NULL;
 
     return ret_error;
 }
@@ -4675,3 +4149,380 @@ int kmo_imagelist_get_saturated(const cpl_imagelist *data,
 
 /** @} */
 
+/*----------------------------------------------------------------------------*/
+/**
+  @brief Returns the index to the first non-rejected element
+  @param    vec         The vector to examine
+  @param    from_left   TRUE if the vector should be examioned from the left,
+                        FALSE otherwise
+  @return The found index
+*/
+/*----------------------------------------------------------------------------*/
+static int  kmo_find_first_non_rejected(
+        const kmclipm_vector    *   vec, 
+        int                         from_left)
+{
+    int index   = -1,
+        size    = 0,
+        i       = 0;
+
+    KMO_TRY
+    {
+        size = kmclipm_vector_get_size(vec);
+        if (from_left) {
+            i = 0;
+            while ((i < size) && (kmclipm_vector_is_rejected(vec, i))) i++;
+            if (i < size) index = i;
+        } else {
+            i = size-1;
+            while ((i >= 0) && (kmclipm_vector_is_rejected(vec, i))) i-- ; 
+            if (i >= 0) index = i;
+        }
+    }
+    KMO_CATCH
+    {
+        KMO_CATCH_MSG();
+        index = -1;
+    }
+    return index;
+}
+
+/*----------------------------------------------------------------------------*/
+/**
+  @brief Validate the number of slitlet edges
+  @param nr_edges     The number of found edges
+  @param cut_left     TRUE if the leftmost slitlet is cut halfways
+  @param cut_right    TRUE if the rightmost slitlet is cut halfways
+  @return TRUE if valid, FALSE otherwise
+*/
+/*----------------------------------------------------------------------------*/
+static int kmo_validate_nr_edges(
+        int     nr_edges,
+        int     cut_left,
+        int     cut_right)
+{
+    int ret = FALSE;
+
+    if (!cut_left && !cut_right) {
+        // normal case
+        switch(nr_edges) {
+        case 28:
+        case 56:
+        case 84:
+        case 112:
+        case 140:
+        case 168:
+        case 196:
+        case 224:
+            ret = TRUE;
+            break;
+        default:
+            break;
+        }
+    }
+
+    if (cut_left && cut_right) {
+        // first AND last slitlet cut halfways
+        switch(nr_edges) {
+        case 24:
+        case 52:
+        case 80:
+        case 108:
+        case 136:
+        case 164:
+        case 192:
+        case 220:
+            ret = TRUE;
+            break;
+        default:
+            break;
+        }
+    } else {
+        // first OR last slitlet cut halfways
+        switch(nr_edges) {
+        case 26:
+        case 54:
+        case 82:
+        case 110:
+        case 138:
+        case 166:
+        case 194:
+        case 222:
+            ret = TRUE;
+            break;
+        default:
+            break;
+        }
+    }
+    return ret;
+}
+
+/*----------------------------------------------------------------------------*/
+/**
+  @brief 
+  @param
+  @param
+  @param
+  @param
+  @param
+  @return 
+*/
+/*----------------------------------------------------------------------------*/
+static cpl_array ** kmo_analize_ifu_edges(
+        kmclipm_vector  *   pos,
+        cpl_array       *   ifu_inactive,
+        int                 cut_first,
+        int                 cut_last,
+        int                 nx)
+{
+    int             i                   = 0,
+                    ind1                = 0,
+                    ind2                = 0,
+                    size                = 0,
+                    has_large_step      = FALSE,
+                    nr_ifu              = 0,
+                    ifu_width           = 0,
+                    estimated_ifu_width = 0,
+                    ifu_center          = 0,
+                    invalidate_all      = FALSE;
+    double          mean_gap            = 0.,
+                *   ppos_valid          = NULL,
+                *   ppos_cut            = NULL;
+    cpl_vector  *   pos_valid           = NULL,
+                *   pos_cut             = NULL,
+                *   gaps                = NULL;
+    cpl_array   **  array               = NULL;
+
+    KMO_TRY
+    {
+        // allocate array of cpl_arrays to return and initialize to zero
+        KMO_TRY_EXIT_IF_NULL(
+            array = (cpl_array**)cpl_malloc(KMOS_IFUS_PER_DETECTOR * sizeof(cpl_array*)));
+        for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
+            array[i] = NULL;
+        }
+
+        if (pos == NULL) {
+            // invalidate all IFUs
+            for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
+                if (cpl_array_get_int(ifu_inactive, i, NULL) == 0) {
+                    KMO_TRY_EXIT_IF_ERROR(
+                        cpl_array_set_int(ifu_inactive, i, 2));
+                }
+            }
+            KMO_TRY_CHECK_ERROR_STATE();
+            return array;
+        }
+
+        KMO_TRY_EXIT_IF_NULL(
+            pos_valid = kmclipm_vector_create_non_rejected(pos));
+        size = cpl_vector_get_size(pos_valid);
+        KMO_TRY_CHECK_ERROR_STATE();
+
+        //
+        // check for cut slitlets (halfways cut or dropped of the detector)
+        // either completely out of zoom or shifted extremly left or right
+        //
+        if (kmo_validate_nr_edges(size, cut_first, cut_last)) {
+            // either one or two slitlets cut halfways
+            if (cut_first) {
+                // just first AND last slitlets are cut halfways
+                int fi = kmo_find_first_non_rejected(pos, TRUE);
+                for (i = fi; i < fi+26; i++) {
+                    kmclipm_vector_reject(pos, i);
+                }
+                cut_first = FALSE;
+            }
+            if (cut_last) {
+                int fi = kmo_find_first_non_rejected(pos, FALSE);
+                for (i = fi; i > fi-26; i--) {
+                    kmclipm_vector_reject(pos, i);
+                }
+                cut_last = FALSE;
+            }
+
+            cpl_vector_delete(pos_valid); pos_valid = NULL;
+            KMO_TRY_EXIT_IF_NULL(
+                pos_valid = kmclipm_vector_create_non_rejected(pos));
+            size = cpl_vector_get_size(pos_valid);
+            KMO_TRY_CHECK_ERROR_STATE();
+
+            if (!kmo_validate_nr_edges(size, cut_first, cut_last)) {
+                cpl_msg_warning("","First and/or last slitlet had been cut off. "
+                                "After omitting these slitlets, still an invalid "
+                                "number of slitlets are counted (number of valid "
+                                "edges found: %d edges)", size);
+                invalidate_all = TRUE;
+            }
+        } else {
+            KMO_TRY_EXIT_IF_NULL(
+                ppos_valid = cpl_vector_get_data(pos_valid));
+
+            if ((ppos_valid[0] < 25) && (ppos_valid[size-1] > nx-25)) {
+                // OUT OF ZOOM
+                cpl_msg_warning("","Out of zoom! At least one slitlet is completely off the "
+                                "detector, can't detect on which side. So invalidating all "
+                                "IFUs on this detector now (number of valid edges found: %d edges)", size);
+                invalidate_all = TRUE;
+            } else {
+                // BIG RIGHT/LEFT SHIFT
+                if (ppos_valid[0] > nx-ppos_valid[size-1]) {
+                    // whole detector shifted to the right, omitting slitlets on right side
+                    // until nr. slitlets is modulo 28
+                    while(size%(2*KMOS_SLITLET_Y) != 0) {
+                        int fi = kmo_find_first_non_rejected(pos, FALSE);
+                        kmclipm_vector_reject(pos, fi);
+                        size = kmclipm_vector_count_non_rejected(pos);
+                    }
+                    cut_first = FALSE;
+                    cut_last = FALSE;
+                } else {
+                    // whole detector shifted to the left, omitting slitlets on left side
+                    // until nr. slitlets is modulo 28
+                    while(size%(2*KMOS_SLITLET_Y) != 0) {
+                        int fi = kmo_find_first_non_rejected(pos, TRUE);
+                        kmclipm_vector_reject(pos, fi);
+                        size = kmclipm_vector_count_non_rejected(pos);
+                    }
+                    cut_first = FALSE;
+                    cut_last = FALSE;
+                }
+
+                cpl_vector_delete(pos_valid); pos_valid = NULL;
+                KMO_TRY_EXIT_IF_NULL(
+                    pos_valid = kmclipm_vector_create_non_rejected(pos));
+                size = cpl_vector_get_size(pos_valid);
+                KMO_TRY_CHECK_ERROR_STATE();
+
+                if (!kmo_validate_nr_edges(size, cut_first, cut_last)) {
+                    cpl_msg_warning("","Slitlets have a large shift on detector, "
+                                    "some of them have been omitted. But still wrong "
+                                    "number of slitlets (number of valid edges found: %d edges)", size);
+                    invalidate_all = TRUE;
+                }
+            }
+        }
+
+        if (!invalidate_all) {
+            if (size < 2*KMOS_SLITLET_Y) {
+                // invalidate all IFUs (less than 28 valid edges)
+                invalidate_all = TRUE;
+            }
+            KMO_TRY_CHECK_ERROR_STATE();
+        }
+
+        if (invalidate_all) {
+            for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
+                if (cpl_array_get_int(ifu_inactive, i, NULL) == 0) {
+                    KMO_TRY_EXIT_IF_ERROR(
+                        cpl_array_set_int(ifu_inactive, i, 2));
+                }
+            }
+            KMO_TRY_CHECK_ERROR_STATE();
+            cpl_vector_delete(pos_valid); pos_valid = NULL;
+            return array;
+        }
+
+        //
+        // check slitlet edges in packets of 28 for integrity
+        //
+        ind1 = 0;
+        ind2 = 2*KMOS_SLITLET_Y-1;
+        while (ind2 < cpl_vector_get_size(pos_valid))
+        {
+            KMO_TRY_EXIT_IF_NULL(
+                pos_cut = cpl_vector_extract(pos_valid, ind1, ind2, 1));
+            KMO_TRY_EXIT_IF_ERROR(
+                kmo_get_slit_gap(pos_cut, NULL, &gaps));
+
+            // check if there is a large step in the gaps (e.g. from vignetting)
+            mean_gap = cpl_vector_get_mean(gaps);
+            for (i = 0; i < cpl_vector_get_size(gaps); i++) {
+                if ((mean_gap+slit_tol < cpl_vector_get(gaps, i)) || (mean_gap-slit_tol > cpl_vector_get(gaps, i))) {
+                    has_large_step = ind1;
+                    break;
+                }
+            }
+
+            if (!has_large_step) {
+                // check IFU width
+                ifu_width = (int)(cpl_vector_get(pos_cut, 2*KMOS_SLITLET_Y-1) -
+                                  cpl_vector_get(pos_cut, 0) + 1);
+                estimated_ifu_width = (int)rint(KMOS_SLITLET_Y*KMOS_SLITLET_X + (KMOS_SLITLET_Y-1)*KMOS_GAP_WIDTH);  //248
+                if ((ifu_width > estimated_ifu_width+10) || (ifu_width < estimated_ifu_width-10)) {
+                    KMO_TRY_ASSURE(1==0,
+                                   CPL_ERROR_ILLEGAL_INPUT,
+                                   "HOUSTON, WE HAVE A PROBLEM! "
+                                   "(ifu width: estimated: %d, actual: %d)", estimated_ifu_width, ifu_width);
+                } else {
+                    // check which IFU these edges belong to
+                    ifu_center = cpl_vector_get(pos_cut, cpl_vector_get_size(pos_cut)/2);
+                    if ((ifu_center >= 20) && (ifu_center <= 270)) {
+                        nr_ifu = 1;
+                    } else if((ifu_center >= 271) && (ifu_center <= 521)) {
+                        nr_ifu = 2;
+                    } else if((ifu_center >= 522) && (ifu_center <= 772)) {
+                        nr_ifu = 3;
+                    } else if((ifu_center >= 773) && (ifu_center <= 1023)) {
+                        nr_ifu = 4;
+                    } else if((ifu_center >= 1024) && (ifu_center <= 1274)) {
+                        nr_ifu = 5;
+                    } else if((ifu_center >= 1275) && (ifu_center <= 1525)) {
+                        nr_ifu = 6;
+                    } else if((ifu_center >= 1526) && (ifu_center <= 1776)) {
+                        nr_ifu = 7;
+                    } else if((ifu_center >= 1777) && (ifu_center <= 2027)) {
+                        nr_ifu = 8;
+                    } else {
+                        KMO_TRY_ASSURE(1==0,
+                                       CPL_ERROR_ILLEGAL_INPUT,
+                                       "HOUSTON, WE HAVE A PROBLEM! "
+                                       "(ifu-center not at expected position: %d)", ifu_center);
+                    }
+
+                    if (cpl_array_get_int(ifu_inactive, nr_ifu-1, NULL) == 1) {
+                        // IFU has been set inactive. dismiss found edges and continue
+                    } else {
+                        // fill array
+                        KMO_TRY_EXIT_IF_NULL(
+                            array[nr_ifu-1] = cpl_array_new(2*KMOS_SLITLET_Y, CPL_TYPE_INT));
+                        KMO_TRY_EXIT_IF_NULL(
+                            ppos_cut = cpl_vector_get_data(pos_cut));
+                        for (i = 0; i < 2*KMOS_SLITLET_Y; i++) {
+                            KMO_TRY_EXIT_IF_ERROR(
+                                cpl_array_set_int(array[nr_ifu-1], i, ppos_cut[i]));
+                        }
+                    }
+                }
+            } else {
+                KMO_TRY_ASSURE(1==0,
+                               CPL_ERROR_ILLEGAL_INPUT,
+                               "HOUSTON, WE HAVE A PROBLEM! (large gap somwhere "
+                               "between pixel %d and %d in x-direction)",
+                               has_large_step, has_large_step+2*KMOS_SLITLET_Y);
+            }
+
+            cpl_vector_delete(pos_cut); pos_cut = NULL;
+            cpl_vector_delete(gaps); gaps = NULL;
+
+            ind1 += 2*KMOS_SLITLET_Y;
+            ind2 += 2*KMOS_SLITLET_Y;
+        }
+    }
+    KMO_CATCH
+    {
+        KMO_CATCH_MSG();
+        for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
+            cpl_array_delete(array[i]); array[i] = NULL;
+        }
+        cpl_free(array); array = NULL;
+        cpl_vector_delete(gaps); gaps = NULL;
+        cpl_vector_delete(pos_cut); pos_cut = NULL;
+    }
+
+    cpl_vector_delete(pos_valid); pos_valid = NULL;
+
+    return array;
+}
+
+
diff --git a/kmos/kmo_priv_flat.h b/kmos/kmo_priv_flat.h
index 17af4b9..78377d3 100644
--- a/kmos/kmo_priv_flat.h
+++ b/kmos/kmo_priv_flat.h
@@ -47,15 +47,6 @@ cpl_image*          kmo_create_bad_pix_flat_thresh(
                                 int surrounding_pixels,
                                 int badpix_thresh);
 
-int                 kmo_find_first_non_rejected(
-                                const kmclipm_vector *vec,
-                                int from_left);
-
-int                 kmo_validate_nr_edges(
-                                int nr_edges,
-                                int cut_left,
-                                int cut_right);
-
 kmclipm_vector*     kmo_analize_slitedges(
                                 const kmclipm_vector *midline,
                                 double thresh_estimate,
@@ -69,13 +60,6 @@ kmclipm_vector*     kmo_analize_slitedges_advanced(
                                 int *cut_first,
                                 int *cut_last);
 
-cpl_array**         kmo_analize_ifu_edges(
-                                kmclipm_vector *pos,
-                                cpl_array *ifu_inactive,
-                                int cut_first,
-                                int cut_last,
-                                int nx);
-
 cpl_array**         kmo_accept_all_ifu_edges(
                                 kmclipm_vector *pos,
                                 cpl_array *ifu_inactive);
diff --git a/kmos/kmo_priv_functions.c b/kmos/kmo_priv_functions.c
index eba8e96..b172b5f 100644
--- a/kmos/kmo_priv_functions.c
+++ b/kmos/kmo_priv_functions.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_functions.c,v 1.16 2013-08-09 09:01:21 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-08-09 09:01:21 $
- * $Revision: 1.16 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -48,33 +40,32 @@
 
 /*----------------------------------------------------------------------------*/
 /**
-    @defgroup kmos_priv_functions     Helper functions general to the KMOS pipeline.
-
-    @{
+  @defgroup kmos_priv_functions Helper functions general to the KMOS pipeline.
  */
 /*----------------------------------------------------------------------------*/
 
+/**@{*/
+
 int print_warning_once_tweak_std = TRUE;
 int print_warning_once_tweak_std_noise = TRUE;
 int print_warning_once_tweak_closest = TRUE;
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Creates a vector with wavelength values according to FITS-header-data.
-
-    @param size     Size of the vector to create (size > 0).
-    @param crpix    Reference pixel position (CRPIX3 from FITS-header).
-    @param crval    Value of reference pixel (CRVAL3 from FITS-header).
-    @param cdelt    Delta between pixels (CDELT3 from FITS-header).
-
-    @return A vector in case of success, NULL otherwise.
-
-    The returned vector has to be deallocated with cpl_vector_delete().
+  @brief Creates a vector with wavelength values according to header data.
+  @param size     Size of the vector to create (size > 0).
+  @param crpix    Reference pixel position (CRPIX3 from FITS-header).
+  @param crval    Value of reference pixel (CRVAL3 from FITS-header).
+  @param cdelt    Delta between pixels (CDELT3 from FITS-header).
+  @return A vector in case of success, NULL otherwise.
+  The returned vector has to be deallocated with cpl_vector_delete().
 */
-cpl_vector* kmo_create_lambda_vec(int size,
-                                  int crpix,
-                                  double crval,
-                                  double cdelt)
+/*----------------------------------------------------------------------------*/
+cpl_vector* kmo_create_lambda_vec(
+        int     size,
+        int     crpix,
+        double  crval,
+        double  cdelt)
 {
     double          *vec_data	= NULL;
     int             i           = 0;
@@ -82,15 +73,10 @@ cpl_vector* kmo_create_lambda_vec(int size,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(size > 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Size must be greater than zero!");
-
-        KMO_TRY_EXIT_IF_NULL(
-            vec_lambda = cpl_vector_new(size));
-
-        KMO_TRY_EXIT_IF_NULL(
-            vec_data = cpl_vector_get_data(vec_lambda));
+        KMO_TRY_ASSURE(size > 0, CPL_ERROR_ILLEGAL_INPUT,
+                "Size must be greater than zero!");
+        KMO_TRY_EXIT_IF_NULL(vec_lambda = cpl_vector_new(size));
+        KMO_TRY_EXIT_IF_NULL(vec_data = cpl_vector_get_data(vec_lambda));
         for (i = 1; i <= size; i++) {
             vec_data[i-1] = (i - crpix) * cdelt + crval;
         }
@@ -100,42 +86,37 @@ cpl_vector* kmo_create_lambda_vec(int size,
         KMO_CATCH_MSG();
         cpl_vector_delete(vec_lambda); vec_lambda = NULL;
     }
-
     return vec_lambda;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Check if a value in a vector is within a certain spectral range.
-
-    This function checks if a value at a specified position in @c ifu_lambda_in
-    lies inbetween a specified range.
-
-    @param ranges        The vector containing the wavelength-ranges which will
-                         be valid. The vector MUST be even-sized. Each pair of
-                         values designates the start- and end-point of a valid
-                         wavelength-range.
-    @param ifu_lambda_in The wavelength-vector of a certain IFU.
-    @param index         The index to the value in @c ifu_lambda_in to examine.
-                         Starts at zero.
-
-    @return 1 if value is in range, 0 otherwise.
-
-    Possible cpl_error_code set in this function:
-
-    @c CPL_ERROR_NULL_INPUT    Not enough inputs defined
-    @c CPL_ERROR_ILLEGAL_INPUT @c ranges is not even-sized
-                               or index is larger or smaller than the size of
-                               @c ifu_lambda_in
+  @brief Check if a value in a vector is within a certain spectral range.
+  @param ranges        The vector containing the wavelength-ranges which will
+                       be valid. The vector MUST be even-sized. Each pair of
+                       values designates the start- and end-point of a valid
+                       wavelength-range.
+  @param ifu_lambda_in The wavelength-vector of a certain IFU.
+  @param index         The index to the value in @c ifu_lambda_in to examine.
+                       Starts at zero.
+  @return 1 if value is in range, 0 otherwise.
+  This function checks if a value at a specified position in @c ifu_lambda_in
+  lies inbetween a specified range.
+  Possible cpl_error_code set in this function:
+  @c CPL_ERROR_NULL_INPUT    Not enough inputs defined
+  @c CPL_ERROR_ILLEGAL_INPUT @c ranges is not even-sized
+                             or index is larger or smaller than the size of
+                             @c ifu_lambda_in
 */
-int kmo_is_in_range(const cpl_vector *ranges,
-                    const cpl_vector *ifu_lambda_in,
-                    int index)
+/*----------------------------------------------------------------------------*/
+int kmo_is_in_range(
+        const cpl_vector    *   ranges,
+        const cpl_vector    *   ifu_lambda_in,
+        int                     index)
 {
     int     size    = 0,
             i       = 0,
             ret_val = 0;
-
     double  start   = 0.0,
             stop    = 0.0,
             val     = 0.0;
@@ -143,32 +124,22 @@ int kmo_is_in_range(const cpl_vector *ranges,
     KMO_TRY
     {
         /* Check inputs */
-        KMO_TRY_ASSURE((ranges != NULL) &&
-                       (ifu_lambda_in != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-
+        KMO_TRY_ASSURE((ranges != NULL) && (ifu_lambda_in != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
         size = cpl_vector_get_size(ranges);
         KMO_TRY_CHECK_ERROR_STATE();
-
-        KMO_TRY_ASSURE((size % 2) == 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Ranges must have an even number of elements!");
-
-        KMO_TRY_ASSURE((index >= 0) &&
-                       (index < cpl_vector_get_size(ifu_lambda_in)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Index < 0 or larger than vector!");
+        KMO_TRY_ASSURE((size % 2) == 0, CPL_ERROR_ILLEGAL_INPUT,
+                "Ranges must have an even number of elements!");
+        KMO_TRY_ASSURE((index >= 0) && 
+                (index < cpl_vector_get_size(ifu_lambda_in)), 
+                CPL_ERROR_ILLEGAL_INPUT, "Index < 0 or larger than vector!");
 
         val  = cpl_vector_get(ifu_lambda_in, index);
         KMO_TRY_CHECK_ERROR_STATE();
         for (i = 0; i < size; i += 2) {
             start = cpl_vector_get(ranges, i);
             stop = cpl_vector_get(ranges, i + 1);
-            if ((start <= val) && (val <= stop + 1e-6)) {
-                ret_val = 1;
-            }
+            if ((start <= val) && (val <= stop + 1e-6))     ret_val = 1;
         }
     }
     KMO_CATCH
@@ -176,71 +147,55 @@ int kmo_is_in_range(const cpl_vector *ranges,
         KMO_CATCH_MSG();
         ret_val = 0;
     }
-
     return ret_val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Identifies spectral slices of a cube to collapse.
-
-    This function identifies spectral slices of a cube to collapse. It takes a
-    a range-vector created with @c kmo_identify_ranges .
-
-    @param ranges         An even sized vector defining the wavelength ranges
-                          (optional).
-    @param ifu_crpix      Reference pixel position (CRPIX3 from FITS-header).
-    @param ifu_crval      Value of reference pixel (CRVAL3 from FITS-header).
-    @param ifu_cdelt      Delta between pixels (CDELT3 from FITS-header).
-    @param size_ifu       The number of spectral slices of the IFU.
-
-    @return A vector in case of success, NULL otherwise. The vector is of the
-            same size as @c size_ifu and contains ones for valid slices and
-            zeros for invalid slices.
-
-    The returned vector has to be deallocated with cpl_vector_delete().
+  @brief Identifies spectral slices of a cube to collapse.
+  @param ranges         An even sized vector defining the wavelength ranges
+                        (optional).
+  @param ifu_crpix      Reference pixel position (CRPIX3 from FITS-header).
+  @param ifu_crval      Value of reference pixel (CRVAL3 from FITS-header).
+  @param ifu_cdelt      Delta between pixels (CDELT3 from FITS-header).
+  @param size_ifu       The number of spectral slices of the IFU.
+  @return A vector in case of success, NULL otherwise. The vector is of the
+          same size as @c size_ifu and contains ones for valid slices and
+          zeros for invalid slices.
+  This function identifies spectral slices of a cube to collapse. It takes a
+  a range-vector created with @c kmo_identify_ranges .
+  The returned vector has to be deallocated with cpl_vector_delete().
 */
-cpl_vector* kmo_identify_slices(const cpl_vector *ranges,
-                                double ifu_crpix,
-                                double ifu_crval,
-                                double ifu_cdelt,
-                                int size_ifu)
+/*----------------------------------------------------------------------------*/
+cpl_vector* kmo_identify_slices(
+        const cpl_vector    *   ranges,
+        double                  ifu_crpix,
+        double                  ifu_crval,
+        double                  ifu_cdelt,
+        int                     size_ifu)
 {
     cpl_vector      *slices           = NULL,
                     *ifu_lambda_in    = NULL;
-
     double          *data             = NULL;
 
     int             i                 = 0;
-
     KMO_TRY
     {
         if (ranges != NULL) {
             /* create lambda-vector for IFU */
             KMO_TRY_EXIT_IF_NULL(
-                ifu_lambda_in = kmo_create_lambda_vec(size_ifu,
-                                                    ifu_crpix,
-                                                    ifu_crval,
-                                                    ifu_cdelt));
+                ifu_lambda_in = kmo_create_lambda_vec(size_ifu, ifu_crpix, 
+                    ifu_crval, ifu_cdelt));
         }
 
         /* allocate output vector */
-        KMO_TRY_EXIT_IF_NULL(
-            slices = cpl_vector_new(size_ifu));
-
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_vector_fill(slices, 0.0));
-
-        /* populate output vector with ones and zeroes
-           one: slice is identified
-           zero: slice will be ignored */
-        KMO_TRY_EXIT_IF_NULL(
-            data = cpl_vector_get_data(slices));
+        KMO_TRY_EXIT_IF_NULL(slices = cpl_vector_new(size_ifu));
+        KMO_TRY_EXIT_IF_ERROR(cpl_vector_fill(slices, 0.0));
 
+       /* populate output vector */
+        KMO_TRY_EXIT_IF_NULL(data = cpl_vector_get_data(slices));
         for (i = 0; i < size_ifu; i++) {
-            if ((ranges == NULL) ||
-                kmo_is_in_range(ranges, ifu_lambda_in, i))
-            {
+            if ((ranges == NULL) || kmo_is_in_range(ranges, ifu_lambda_in, i)) {
                 data[i] = 1;
             }
         }
@@ -250,59 +205,48 @@ cpl_vector* kmo_identify_slices(const cpl_vector *ranges,
         KMO_CATCH_MSG();
         cpl_vector_delete(slices); slices = NULL;
     }
-
     cpl_vector_delete(ifu_lambda_in); ifu_lambda_in = NULL;
-
     return slices;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Parses a text string and extracts pairs of values as ranges.
-
-    The string has to be of following form: "0.8,1.2" or "0.8,0.9;1.0,2.0" etc.
-    Start- and end-value of a range have to be separated by a comma.
-    Multiple ranges have to be separated with a semi-colon (The decimal point
-    has to be a point).
-    The returned vector will be even sized. The format is as follows:
-    [start range 1, end range 1, start range 2, end range 2, ...]
-
-    @param txt   String to parse.
-
-    @return A vector in case of success, NULL otherwise.
-
-    The returned vector has to be deallocated with cpl_vector_delete().
-
-    Possible cpl_error_code set in this function:
-    @li CPL_ERROR_NULL_INPUT    if @c txt pointer is NULL
-    @li CPL_ERROR_ILLEGAL_INPUT if the @c txtpointer doesn't contain a end-value
-                                if a start-value has been provided.
+  @brief    Parses a text string and extracts pairs of values as ranges.
+  @param txt   String to parse.
+  @return   A vector in case of success, NULL otherwise.
+
+  The string has to be of following form: "0.8,1.2" or "0.8,0.9;1.0,2.0" etc.
+  Start- and end-value of a range have to be separated by a comma.
+  Multiple ranges have to be separated with a semi-colon (The decimal point
+  has to be a point).
+  The returned vector will be even sized. The format is as follows:
+  [start range 1, end range 1, start range 2, end range 2, ...]
+  The returned vector has to be deallocated with cpl_vector_delete().
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c txt pointer is NULL
+  @li CPL_ERROR_ILLEGAL_INPUT if the @c txtpointer doesn't contain a end-value
+                              if a start-value has been provided.
 */
+/*----------------------------------------------------------------------------*/
 cpl_vector* kmo_identify_ranges(const char *txt)
 {
     cpl_vector      *ranges         = NULL;
-
     char            **split_ranges  = NULL,
                     **split_values  = NULL;
-
     int             i               = 0,
                     j               = 0,
                     g               = 0,
                     size            = 0;
-
     double          *pranges        = NULL;
 
     KMO_TRY
     {
         /* Check inputs */
-        KMO_TRY_ASSURE(txt != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(txt != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         if (strcmp(txt, "") != 0) {
-
-            KMO_TRY_EXIT_IF_NULL(
-                split_ranges = kmo_strsplit(txt, ";", NULL));
+            KMO_TRY_EXIT_IF_NULL(split_ranges = kmo_strsplit(txt, ";", NULL));
 
             // get size of vector to create
             while (split_ranges[i] != NULL) {
@@ -315,50 +259,38 @@ cpl_vector* kmo_identify_ranges(const char *txt)
                 }
                 if (j != 2) {
                     KMO_TRY_ERROR_SET_MSG(CPL_ERROR_ILLEGAL_INPUT,
-                                          "Range-string incomplete!");
+                            "Range-string incomplete!");
                     KMO_TRY_EXIT();
                 }
-
                 kmo_strfreev(split_values); split_values = NULL;
-
                 i++;
                 j = 0;
             }
-
             if ((size % 2) != 0) {
                 KMO_TRY_ERROR_SET_MSG(CPL_ERROR_ILLEGAL_INPUT,
-                                      "Range-string incomplete!");
+                        "Range-string incomplete!");
                 KMO_TRY_EXIT();
             }
 
             // fill vector with extracted values
-            KMO_TRY_EXIT_IF_NULL(
-                ranges = cpl_vector_new(size));
-
-            KMO_TRY_EXIT_IF_NULL(
-                pranges = cpl_vector_get_data(ranges));
-
+            KMO_TRY_EXIT_IF_NULL(ranges = cpl_vector_new(size));
+            KMO_TRY_EXIT_IF_NULL(pranges = cpl_vector_get_data(ranges));
             i = 0;
             j = 0;
             while (split_ranges[i] != NULL) {
-
                 KMO_TRY_EXIT_IF_NULL(
                     split_values = kmo_strsplit(split_ranges[i], ",", NULL));
-
                 while (split_values[j] != NULL) {
                     pranges[g] = atof(split_values[j]);
-
                     j++;
                     g++;
                 }
                 kmo_strfreev(split_values);
                 split_values = NULL;
-
                 i++;
                 j = 0;
             }
             KMO_TRY_CHECK_ERROR_STATE();
-
             kmo_strfreev(split_ranges);
         }
     }
@@ -371,72 +303,56 @@ cpl_vector* kmo_identify_ranges(const char *txt)
             kmo_strfreev(split_values);
         }
     }
-
     return ranges;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Parses a text string and extracts values.
-
-    The string has to be of following form: "0.8" or "0.8;0.9" etc.
-    Values have to be separated with a semi-colon (The decimal point
-    has to be a point).
-
-    @param txt   String to parse.
-
-    @return A vector in case of success, NULL otherwise.
-
-    The returned vector has to be deallocated with cpl_vector_delete().
-
-    Possible cpl_error_code set in this function:
-    @li CPL_ERROR_NULL_INPUT    if @c txt pointer is NULL
-    @li CPL_ERROR_ILLEGAL_INPUT if the @c txtpointer doesn't contain a end-value
-                                if a start-value has been provided.
+  @brief    Parses a text string and extracts values.
+  @param txt   String to parse.
+  @return   A vector in case of success, NULL otherwise.
+
+  The string has to be of following form: "0.8" or "0.8;0.9" etc.
+  Values have to be separated with a semi-colon (The decimal point
+  has to be a point).
+  The returned vector has to be deallocated with cpl_vector_delete().
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c txt pointer is NULL
+  @li CPL_ERROR_ILLEGAL_INPUT if the @c txtpointer doesn't contain a end-value
+                              if a start-value has been provided.
 */
+/*----------------------------------------------------------------------------*/
 cpl_vector* kmo_identify_values(const char *txt)
 {
     cpl_vector      *values         = NULL;
-
     char            **split_values  = NULL,
                     *tmp            = NULL;
-
     int             size            = 0;
-
     double          *pvalues        = NULL;
 
     KMO_TRY
     {
         /* Check inputs */
-        KMO_TRY_ASSURE(txt != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(txt != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         if (strcmp(txt, "") != 0) {
-
             // check for wrong delimiters
             KMO_TRY_ASSURE((strstr(txt, ",") == NULL) &&
-                           (strstr(txt, ":") == NULL),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "',' and ':'aren't allowed in txt!");
+                    (strstr(txt, ":") == NULL), CPL_ERROR_ILLEGAL_INPUT,
+                    "',' and ':'aren't allowed in txt!");
 
-            KMO_TRY_EXIT_IF_NULL(
-                split_values = kmo_strsplit(txt, ";", &size));
+            KMO_TRY_EXIT_IF_NULL(split_values = kmo_strsplit(txt, ";", &size));
 
             // fill vector with extracted values
-            KMO_TRY_EXIT_IF_NULL(
-                values = cpl_vector_new(size));
-
-            KMO_TRY_EXIT_IF_NULL(
-                pvalues = cpl_vector_get_data(values));
-
+            KMO_TRY_EXIT_IF_NULL(values = cpl_vector_new(size));
+            KMO_TRY_EXIT_IF_NULL(pvalues = cpl_vector_get_data(values));
             size = 0;
             while (split_values[size] != NULL) {
                 pvalues[size] = atof(split_values[size]);
                 size++;
             }
             KMO_TRY_CHECK_ERROR_STATE();
-
             kmo_strfreev(split_values);
         }
     }
@@ -445,85 +361,62 @@ cpl_vector* kmo_identify_values(const char *txt)
         KMO_CATCH_MSG();
         cpl_free(tmp); tmp = NULL;
         cpl_vector_delete(values); values = NULL;
-        if (strcmp(txt, "") != 0) {
-            kmo_strfreev(split_values);
-        }
+        if (strcmp(txt, "") != 0)   kmo_strfreev(split_values);
     }
-
     return values;
 }
 
-
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculate the mean of an image considering a bad pixel mask.
-
-    @param data            Image to be averaged.
-    @param bad_pix_mask    The bad pixel mask.
-
-    @return
-        The mean.
-
-    All pixels in @c bad_pix_mask with a value of 0.0 are ignored.
-
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c data or @c bad_pix_mask don't have the
-                                same size.
+  @brief    Calculate the mean of an image considering a bad pixel mask.
+  @param data            Image to be averaged.
+  @param bad_pix_mask    The bad pixel mask.
+  @return   The mean.
+  All pixels in @c bad_pix_mask with a value of 0.0 are ignored.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c data or @c bad_pix_mask don't have the
+                              same size.
 */
-double kmo_image_get_mean_badpix(const cpl_image *data,
-                                 const cpl_image *bad_pix_mask)
+/*----------------------------------------------------------------------------*/
+double kmo_image_get_mean_badpix(
+        const cpl_image     *   data,
+        const cpl_image     *   bad_pix_mask)
 {
     int         nr_valid_pix    = 0,
                 nx              = 0,
                 ny              = 0,
                 i               = 0,
                 j               = 0;
-
     const float *pbad_pix_mask  = NULL,
                 *pdata          = NULL;
-
     double      ret_val         = 0.0,
                 sum             = 0.0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (bad_pix_mask != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
-
+        KMO_TRY_ASSURE((data != NULL) && (bad_pix_mask != NULL),
+                CPL_ERROR_NULL_INPUT, "No input data is provided!");
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
-
         nr_valid_pix = nx * ny;
 
         KMO_TRY_ASSURE((nx == cpl_image_get_size_x(bad_pix_mask)) &&
-                       (ny == cpl_image_get_size_y(bad_pix_mask)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Data and bad pixel mask must have same dimensions!");
+                (ny == cpl_image_get_size_y(bad_pix_mask)),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Data and bad pixel mask must have same dimensions!");
 
-        KMO_TRY_EXIT_IF_NULL(
-            pdata = cpl_image_get_data_float_const(data));
+        KMO_TRY_EXIT_IF_NULL(pdata = cpl_image_get_data_float_const(data));
 
         KMO_TRY_EXIT_IF_NULL(
             pbad_pix_mask = cpl_image_get_data_float_const(bad_pix_mask));
 
         for (j = 0; j < ny; j++) {
             for (i = 0; i < nx; i++) {
-                if (pbad_pix_mask[i+j*nx] < 0.5) {
-                    // bad pixel
-                    nr_valid_pix--;
-                } else {
-                    // valid pixel
-                    sum += pdata[i+j*nx];
-                }
-
+                if (pbad_pix_mask[i+j*nx] < 0.5)    nr_valid_pix--;
+                else                                sum += pdata[i+j*nx];
             }
         }
-
         ret_val = sum / nr_valid_pix;
     }
     KMO_CATCH
@@ -531,31 +424,25 @@ double kmo_image_get_mean_badpix(const cpl_image *data,
         KMO_CATCH_MSG();
         ret_val = 0.0;
     }
-
     return ret_val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculate the median of an image considering a bad pixel mask.
-
-    @param data            Input Image.
-    @param bad_pix_mask    The bad pixel mask.
-
-    @return
-        The median.
-
-    All pixels in @c bad_pix_mask with a value of 0.0 are ignored.
-
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c data or @c bad_pix_mask don't have the
-                                void *  cpl_malloc (size_t nbytes)same size.
+  @brief  Calculate the median of an image considering a bad pixel mask.
+  @param data            Input Image.
+  @param bad_pix_mask    The bad pixel mask.
+  @return     The median.
+  All pixels in @c bad_pix_mask with a value of 0.0 are ignored.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c data or @c bad_pix_mask don't have the
+                              void *  cpl_malloc (size_t nbytes)same size.
 */
-double kmo_image_get_median_badpix(const cpl_image *data,
-                                   const cpl_image *bad_pix_mask)
+/*----------------------------------------------------------------------------*/
+double kmo_image_get_median_badpix(
+        const cpl_image *   data,
+        const cpl_image *   bad_pix_mask)
 {
     int             nx              = 0,
                     ny              = 0,
@@ -568,38 +455,28 @@ double kmo_image_get_median_badpix(const cpl_image *data,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (bad_pix_mask != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
-
+        KMO_TRY_ASSURE((data != NULL) && (bad_pix_mask != NULL),
+                CPL_ERROR_NULL_INPUT, "No input data is provided!");
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
-
         KMO_TRY_ASSURE((nx == cpl_image_get_size_x(bad_pix_mask)) &&
-                       (ny == cpl_image_get_size_y(bad_pix_mask)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Data and bad pixel mask must have same dimensions!");
-
-        KMO_TRY_EXIT_IF_NULL(
-            vec = kmclipm_vector_new(nx*ny));
-
-        KMO_TRY_EXIT_IF_NULL(
-            pdata = cpl_image_get_data_float_const(data));
+                (ny == cpl_image_get_size_y(bad_pix_mask)),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Data and bad pixel mask must have same dimensions!");
 
+        KMO_TRY_EXIT_IF_NULL(vec = kmclipm_vector_new(nx*ny));
+        KMO_TRY_EXIT_IF_NULL(pdata = cpl_image_get_data_float_const(data));
         KMO_TRY_EXIT_IF_NULL(
             pbad_pix_mask = cpl_image_get_data_float_const(bad_pix_mask));
 
         for (j = 0; j < ny; j++) {
             for (i = 0; i < nx; i++) {
                 if (pbad_pix_mask[i+j*nx] >= 0.5) {
-                    // valid pixel
                     kmclipm_vector_set(vec, i+j*nx, pdata[i+j*nx]);
                     KMO_TRY_CHECK_ERROR_STATE();
                 }
             }
         }
-
         ret_val = kmclipm_vector_get_median(vec, KMCLIPM_ARITHMETIC);
     }
     KMO_CATCH
@@ -607,82 +484,62 @@ double kmo_image_get_median_badpix(const cpl_image *data,
         KMO_CATCH_MSG();
         ret_val = 0.0;
     }
-
     return ret_val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculate the stdev of an image considering a bad pixel mask.
-
-    @param data            Input data.
-    @param bad_pix_mask    The bad pixel mask.
-
-    @return
-        The standard deviation of @c data .
-
-    All pixels in @c bad_pix_mask with a value of 0.0 are ignored.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c data or @c bad_pix_mask don't have the
-                                same size.
+  @brief    Calculate the stdev of an image considering a bad pixel mask.
+  @param data            Input data.
+  @param bad_pix_mask    The bad pixel mask.
+  @return   The standard deviation of @c data .
+  All pixels in @c bad_pix_mask with a value of 0.0 are ignored.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c data or @c bad_pix_mask don't have the
+                              same size.
 */
-double kmo_image_get_stdev_badpix(const cpl_image *data,
-                                  const cpl_image *bad_pix_mask)
+/*----------------------------------------------------------------------------*/
+double kmo_image_get_stdev_badpix(
+        const cpl_image *   data,
+        const cpl_image *   bad_pix_mask)
 {
     int         nr_valid_pix    = 0,
                 nx              = 0,
                 ny              = 0,
                 i               = 0,
                 j               = 0;
-
     const float *pbad_pix_mask  = NULL,
                 *pdata          = NULL;
-
     double      ret_val         = 0.0,
                 sum             = 0.0,
                 tmp             = 0.0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (bad_pix_mask != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
-
+        KMO_TRY_ASSURE((data != NULL) && (bad_pix_mask != NULL),
+                CPL_ERROR_NULL_INPUT, "No input data is provided!");
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
-
         nr_valid_pix = nx * ny;
-
         KMO_TRY_ASSURE((nx == cpl_image_get_size_x(bad_pix_mask)) &&
-                       (ny == cpl_image_get_size_y(bad_pix_mask)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Data and bad pixel mask must have same dimensions!");
+                (ny == cpl_image_get_size_y(bad_pix_mask)),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Data and bad pixel mask must have same dimensions!");
 
         tmp = kmo_image_get_mean_badpix(data, bad_pix_mask);
         KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_EXIT_IF_NULL(
-            pdata = cpl_image_get_data_float_const(data));
-
+        KMO_TRY_EXIT_IF_NULL(pdata = cpl_image_get_data_float_const(data));
         KMO_TRY_EXIT_IF_NULL(
             pbad_pix_mask = cpl_image_get_data_float_const(bad_pix_mask));
 
         for (j = 0; j < ny; j++) {
             for (i = 0; i < nx; i++) {
-                if (pbad_pix_mask[i+j*nx] < 0.5) {
-                    // bad pixel
-                    nr_valid_pix--;
-                } else {
-                    // valid pixel
-                    sum += pow(pdata[i+j*nx] - tmp, 2);
-                }
+                if (pbad_pix_mask[i+j*nx] < 0.5)    nr_valid_pix--;
+                else                        sum += pow(pdata[i+j*nx] - tmp, 2);
             }
         }
-
         ret_val = sqrt(sum / (nr_valid_pix - 1));
     }
     KMO_CATCH
@@ -690,83 +547,62 @@ double kmo_image_get_stdev_badpix(const cpl_image *data,
         KMO_CATCH_MSG();
         ret_val = 0.0;
     }
-
     return ret_val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculate the stdev with median of an image considering a bad pixel mask.
-
-    @param data            Input data.
-    @param bad_pix_mask    The bad pixel mask.
-
-    @return
-        The standard deviation of @c data .
-
-    All pixels in @c bad_pix_mask with a value of 0.0 are ignored.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c data or @c bad_pix_mask don't have the
-                                same size.
-
+  @brief Calculate the stdev with median of an image considering a BPM
+  @param data            Input data.
+  @param bad_pix_mask    The bad pixel mask.
+  @return The standard deviation of @c data .
+  All pixels in @c bad_pix_mask with a value of 0.0 are ignored.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data or @c bad_pix_mask is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c data or @c bad_pix_mask don't have the
+                              same size.
 */
-double kmo_image_get_stdev_median_badpix(const cpl_image *data,
-                                         const cpl_image *bad_pix_mask)
+/*----------------------------------------------------------------------------*/
+double kmo_image_get_stdev_median_badpix(
+        const cpl_image *   data,
+        const cpl_image *   bad_pix_mask)
 {
     int         nr_valid_pix    = 0,
                 nx              = 0,
                 ny              = 0,
                 i               = 0,
                 j               = 0;
-
     const float *pbad_pix_mask  = NULL,
                 *pdata          = NULL;
-
     double      ret_val         = 0.0,
                 sum             = 0.0,
                 tmp             = 0.0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (bad_pix_mask != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
-
+        KMO_TRY_ASSURE((data != NULL) && (bad_pix_mask != NULL),
+                CPL_ERROR_NULL_INPUT, "No input data is provided!");
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
-
         nr_valid_pix = nx * ny;
 
         KMO_TRY_ASSURE((nx == cpl_image_get_size_x(bad_pix_mask)) &&
-                       (ny == cpl_image_get_size_y(bad_pix_mask)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Data and bad pixel mask must have same dimensions!");
+                (ny == cpl_image_get_size_y(bad_pix_mask)),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Data and bad pixel mask must have same dimensions!");
 
         tmp = kmo_image_get_median_badpix(data, bad_pix_mask);
         KMO_TRY_CHECK_ERROR_STATE();
-
-        KMO_TRY_EXIT_IF_NULL(
-            pdata = cpl_image_get_data_float_const(data));
-
+        KMO_TRY_EXIT_IF_NULL(pdata = cpl_image_get_data_float_const(data));
         KMO_TRY_EXIT_IF_NULL(
             pbad_pix_mask = cpl_image_get_data_float_const(bad_pix_mask));
 
         for (j = 0; j < ny; j++) {
             for (i = 0; i < nx; i++) {
-                if (pbad_pix_mask[i+j*nx] < 0.5) {
-                    // bad pixel
-                    nr_valid_pix--;
-                } else {
-                    // valid pixel
-                    sum += pow(pdata[i+j*nx] - tmp, 2);
-                }
+                if (pbad_pix_mask[i+j*nx] < 0.5)    nr_valid_pix--;
+                else                        sum += pow(pdata[i+j*nx] - tmp, 2);
             }
         }
-
         ret_val = sqrt(sum / (nr_valid_pix - 1));
     }
     KMO_CATCH
@@ -774,67 +610,48 @@ double kmo_image_get_stdev_median_badpix(const cpl_image *data,
         KMO_CATCH_MSG();
         ret_val = 0.0;
     }
-
     return ret_val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculate the stdev with median of an image.
-
-    @param data            Input data.
-
-    @return
-        The standard deviation of @c data .
-
-    Rejected values in @c data are taken into account.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data is NULL.
+  @brief    Calculate the stdev with median of an image.
+  @param data            Input data.
+  @return   The standard deviation of @c data .
+  Rejected values in @c data are taken into account.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data is NULL.
 */
+/*----------------------------------------------------------------------------*/
 double kmo_image_get_stdev_median(const cpl_image *data)
 {
     int         nr_valid_pix    = 0,
                 nx              = 0,
                 ny              = 0;
-
     const float *pdata          = NULL;
-
     double      ret_val         = 0.0,
                 sum             = 0.0,
                 tmp             = 0.0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(data != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
+        KMO_TRY_ASSURE(data != NULL, CPL_ERROR_NULL_INPUT,
+                "No input data is provided!");
 
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
-
         nr_valid_pix = nx * ny;
-
         tmp = cpl_image_get_median(data);
         KMO_TRY_CHECK_ERROR_STATE();
-
-        KMO_TRY_EXIT_IF_NULL(
-            pdata = cpl_image_get_data_float_const(data));
+        KMO_TRY_EXIT_IF_NULL(pdata = cpl_image_get_data_float_const(data));
 
         int ix = 0, iy = 0;
         for (iy = 0; iy < ny; iy++) {
             for (ix = 0; ix < nx; ix++) {
-                if (cpl_image_is_rejected(data, ix+1, iy+1)) {
-                    // bad pixel
-                    nr_valid_pix--;
-                } else {
-                    // valid pixel
-                    sum += pow(pdata[ix+iy*nx] - tmp, 2);
-                }
+                if (cpl_image_is_rejected(data, ix+1, iy+1))    nr_valid_pix--;
+                else                    sum += pow(pdata[ix+iy*nx] - tmp, 2);
             }
         }
-
         ret_val = sqrt(sum / (nr_valid_pix - 1));
     }
     KMO_CATCH
@@ -842,29 +659,28 @@ double kmo_image_get_stdev_median(const cpl_image *data)
         KMO_CATCH_MSG();
         ret_val = 0.0;
     }
-
     return ret_val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief  Adds combine-parameters to parameterlist.
-
-    This functions is called when creating the parameters for the recipes which
-    do combine frames.
-
-    @param  pl             The already allocated parameterlist.
-    @param  recipe_name    The name of the recipe in form of "kmo.kmo_xxx".
-    @param  default_method Default combining method (Applies only when
-                           no_method==FALSE)
-    @param  no_method      If FALSE "cmethod" will be added as parameter.
-                           If TRUE it isn't added.
-
-    @return 0 in case of success, -1 otherwise.
+  @brief    Adds combine-parameters to parameterlist.
+  @param  pl             The already allocated parameterlist.
+  @param  recipe_name    The name of the recipe in form of "kmo.kmo_xxx".
+  @param  default_method Default combining method (Applies only when
+                         no_method==FALSE)
+  @param  no_method      If FALSE "cmethod" will be added as parameter.
+                         If TRUE it isn't added.
+  @return   0 in case of success, -1 otherwise.
+  This functions is called when creating the parameters for the recipes which
+  do combine frames.
  */
-int kmo_combine_pars_create(cpl_parameterlist *pl,
-                            const char* recipe_name,
-                            const char* default_method,
-                            int no_cmethod)
+/*----------------------------------------------------------------------------*/
+int kmo_combine_pars_create(
+        cpl_parameterlist   *   pl,
+        const char          *   recipe_name,
+        const char          *   default_method,
+        int                     no_cmethod)
 {
     cpl_parameter   *p;
     char            *tmpstr = NULL;
@@ -875,12 +691,9 @@ int kmo_combine_pars_create(cpl_parameterlist *pl,
 
     if (no_cmethod == FALSE) {
         tmpstr = cpl_sprintf("%s.%s", recipe_name, "cmethod");
-        p = cpl_parameter_new_value(tmpstr,
-                                    CPL_TYPE_STRING,
-                                    "Either apply \"average\", \"median\", "
-                                    "\"sum\", \"min_max.\" or \"ksigma\".",
-                                    recipe_name,
-                                    default_method);
+        p = cpl_parameter_new_value(tmpstr, CPL_TYPE_STRING,
+        "Apply \"average\", \"median\", \"sum\", \"min_max.\" or \"ksigma\".",
+                recipe_name, default_method);
         cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cmethod");
         cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
         cpl_parameterlist_append(pl, p);
@@ -891,12 +704,9 @@ int kmo_combine_pars_create(cpl_parameterlist *pl,
         ((no_cmethod == TRUE) && (strcmp(default_method, "ksigma") == 0))) {
         /* --cpos_rej */
         tmpstr = cpl_sprintf("%s.%s", recipe_name, "cpos_rej");
-        p = cpl_parameter_new_value(tmpstr,
-                                    CPL_TYPE_DOUBLE,
-                                    "The positive rejection threshold for "
-                                    "kappa-sigma-clipping (sigma).",
-                                    recipe_name,
-                                    DEF_POS_REJ_THRES);
+        p = cpl_parameter_new_value(tmpstr, CPL_TYPE_DOUBLE,
+        "The positive rejection threshold for kappa-sigma-clipping (sigma).",
+                recipe_name, DEF_POS_REJ_THRES);
         cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cpos_rej");
         cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
         cpl_parameterlist_append(pl, p);
@@ -904,12 +714,9 @@ int kmo_combine_pars_create(cpl_parameterlist *pl,
 
         /* --cneg_rej */
         tmpstr = cpl_sprintf("%s.%s", recipe_name, "cneg_rej");
-        p = cpl_parameter_new_value(tmpstr,
-                                    CPL_TYPE_DOUBLE,
-                                    "The negative rejection threshold for "
-                                    "kappa-sigma-clipping (sigma).",
-                                    recipe_name,
-                                    DEF_NEG_REJ_THRES);
+        p = cpl_parameter_new_value(tmpstr, CPL_TYPE_DOUBLE,
+        "The negative rejection threshold for kappa-sigma-clipping (sigma).",
+                recipe_name, DEF_NEG_REJ_THRES);
         cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cneg_rej");
         cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
         cpl_parameterlist_append(pl, p);
@@ -917,12 +724,9 @@ int kmo_combine_pars_create(cpl_parameterlist *pl,
 
         /* --citer */
         tmpstr = cpl_sprintf("%s.%s", recipe_name, "citer");
-        p = cpl_parameter_new_value(tmpstr,
-                                    CPL_TYPE_INT,
-                                    "The number of iterations for kappa-sigma-"
-                                    "clipping.",
-                                    recipe_name,
-                                    DEF_ITERATIONS);
+        p = cpl_parameter_new_value(tmpstr, CPL_TYPE_INT,
+                "The number of iterations for kappa-sigma-clipping.",
+                recipe_name, DEF_ITERATIONS);
         cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "citer");
         cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
         cpl_parameterlist_append(pl, p);
@@ -933,12 +737,9 @@ int kmo_combine_pars_create(cpl_parameterlist *pl,
         ((no_cmethod == TRUE) && (strcmp(default_method, "min_max") == 0))) {
         /* --cmax */
         tmpstr = cpl_sprintf("%s.%s", recipe_name, "cmax");
-        p = cpl_parameter_new_value(tmpstr,
-                                    CPL_TYPE_INT,
-                                    "The number of maximum pixel values to clip "
-                                    "with min/max-clipping.",
-                                    recipe_name,
-                                    DEF_NR_MAX_REJ);
+        p = cpl_parameter_new_value(tmpstr, CPL_TYPE_INT,
+            "The number of maximum pixel values to clip with min/max-clipping.",
+                recipe_name, DEF_NR_MAX_REJ);
         cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cmax");
         cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
         cpl_parameterlist_append(pl, p);
@@ -946,12 +747,9 @@ int kmo_combine_pars_create(cpl_parameterlist *pl,
 
         /* --cmin */
         tmpstr = cpl_sprintf("%s.%s", recipe_name, "cmin");
-        p = cpl_parameter_new_value(tmpstr,
-                                    CPL_TYPE_INT,
-                                    "The number of minimum pixel values to clip "
-                                    "with min/max-clipping.",
-                                    recipe_name,
-                                    DEF_NR_MIN_REJ);
+        p = cpl_parameter_new_value(tmpstr, CPL_TYPE_INT,
+            "The number of minimum pixel values to clip with min/max-clipping.",
+                recipe_name, DEF_NR_MIN_REJ);
         cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cmin");
         cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
         cpl_parameterlist_append(pl, p);
@@ -961,24 +759,22 @@ int kmo_combine_pars_create(cpl_parameterlist *pl,
     if (cpl_error_get_code() != CPL_ERROR_NONE) {
         return -1;
     }
-
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief  Adds band-parameters to parameterlist.
-
-    This functions is called when creating the parameters for the recipes which
-    do reconstruct frames.
-
-    @param  pl             The already allocated parameterlist.
-    @param  recipe_name    The name of the recipe in form of "kmo.kmo_xxx".
+  @brief  Adds band-parameters to parameterlist.
+  @param  pl             The already allocated parameterlist.
+  @param  recipe_name    The name of the recipe in form of "kmo.kmo_xxx".
+  This functions is called when creating the parameters for the recipes which
+  do reconstruct frames.
  */
-void kmo_band_pars_create(cpl_parameterlist *pl,
-                                      const char* recipe_name)
+/*----------------------------------------------------------------------------*/
+void kmo_band_pars_create(cpl_parameterlist * pl, const char * recipe_name)
 {
-    cpl_parameter   *p;
-    char            *tmpstr = NULL;
+    cpl_parameter   *   p;
+    char            *   tmpstr = NULL;
 
     if ((pl == NULL) || (recipe_name == NULL)){
         return;
@@ -986,12 +782,9 @@ void kmo_band_pars_create(cpl_parameterlist *pl,
 
     /* --b_samples */
     tmpstr = cpl_sprintf("%s.%s", recipe_name, "b_samples");
-    p = cpl_parameter_new_value(tmpstr,
-                                CPL_TYPE_INT,
-                                "The number of samples in wavelength for the "
-                                "reconstructed cube",
-                                recipe_name,
-                                kmclipm_band_samples);
+    p = cpl_parameter_new_value(tmpstr, CPL_TYPE_INT,
+            "The number of samples in wavelength for the reconstructed cube",
+            recipe_name, kmclipm_band_samples);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "b_samples");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(pl, p);
@@ -999,14 +792,10 @@ void kmo_band_pars_create(cpl_parameterlist *pl,
 
     /* --b_start */
     tmpstr = cpl_sprintf("%s.%s", recipe_name, "b_start");
-    p = cpl_parameter_new_value(tmpstr,
-                                CPL_TYPE_DOUBLE,
-                                "The lowest wavelength [um] to take into "
-                                "account when reconstructing (default of -1 "
-                                "sets the proper value for the actual band "
-                                "automatically)",
-                                recipe_name,
-                                -1.0);
+    p = cpl_parameter_new_value(tmpstr, CPL_TYPE_DOUBLE,
+            "The lowest wavelength [um] to use when reconstructing. "
+            "Derived by default, depending on the band",
+            recipe_name, -1.0);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "b_start");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(pl, p);
@@ -1014,69 +803,60 @@ void kmo_band_pars_create(cpl_parameterlist *pl,
 
     /* --b_end */
     tmpstr = cpl_sprintf("%s.%s", recipe_name, "b_end");
-    p = cpl_parameter_new_value(tmpstr,
-                                CPL_TYPE_DOUBLE,
-                                "The highest wavelength [um] to take into "
-                                "account when reconstructing (default of -1 "
-                                "sets the proper value for the actual band "
-                                "automatically)",
-                                recipe_name,
-                                -1.0);
+    p = cpl_parameter_new_value(tmpstr, CPL_TYPE_DOUBLE,
+            "The highest wavelength [um] to use when reconstructing. "
+            "Derived by default, depending on the band",
+            recipe_name, -1.0);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "b_end");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(pl, p);
     cpl_free(tmpstr); tmpstr = NULL;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief  Loads combine-parameters from parameterlist.
-
-    This functions is called at the beginning of recipes which
-    do combine frames.
-
-    @param  pl             The parameterlist.
-    @param  recipe_name    The name of the recipe in form of "kmo.kmo_xxx".
-    @param  cmethod        (Output) Will hold the combing method.
-    @param  ccalc_noise    (Output) 1 if noise should be (re)calculated,
-                           0 otherwise.
-    @param  cpos_rej       (Output) Will hold the positive rejection factor for
-                           ksigma-rejection.
-    @param  cneg_rej       (Output) Will hold the negative rejection factor for
-                           ksigma-rejection.
-    @param  citer          (Output) Will hold the number of iterations for
-                           ksigma-rejection.
-    @param  cmin           (Output) Will hold the number of min pixels to
-                           reject using cmethod "min_max".
-    @param  cmax           (Output) Will hold the number of max pixels to
-                           reject using cmethod "min_max".
-    @param  no_method      If FALSE "cmethod" will be added as parameter.
-                           If TRUE it isn't added.
-
-    @return
-        CPL_ERROR_NONE in case of success.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the needed arguments is NULL.
+  @brief  Loads combine-parameters from parameterlist.
+  @param  pl             The parameterlist.
+  @param  recipe_name    The name of the recipe in form of "kmo.kmo_xxx".
+  @param  cmethod        (Output) Will hold the combing method.
+  @param  ccalc_noise    (Output) 1 if noise should be (re)calculated,
+                         0 otherwise.
+  @param  cpos_rej       (Output) Will hold the positive rejection factor for
+                         ksigma-rejection.
+  @param  cneg_rej       (Output) Will hold the negative rejection factor for
+                         ksigma-rejection.
+  @param  citer          (Output) Will hold the number of iterations for
+                         ksigma-rejection.
+  @param  cmin           (Output) Will hold the number of min pixels to
+                         reject using cmethod "min_max".
+  @param  cmax           (Output) Will hold the number of max pixels to
+                         reject using cmethod "min_max".
+  @param  no_method      If FALSE "cmethod" will be added as parameter.
+                         If TRUE it isn't added.
+  @return CPL_ERROR_NONE in case of success.
+  This functions is called at the beginning of recipes which
+  do combine frames.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the needed arguments is NULL.
  */
-cpl_error_code kmo_combine_pars_load(cpl_parameterlist *pl,
-                                     const char *recipe_name,
-                                     const char **cmethod,
-                                     double *cpos_rej,
-                                     double *cneg_rej,
-                                     int *citer,
-                                     int *cmin,
-                                     int *cmax,
-                                     int no_cmethod)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_combine_pars_load(
+        cpl_parameterlist   *   pl,
+        const char          *   recipe_name,
+        const char          **  cmethod,
+        double              *   cpos_rej,
+        double              *   cneg_rej,
+        int                 *   citer,
+        int                 *   cmin,
+        int                 *   cmax,
+        int                     no_cmethod)
 {
     char *tmpstr = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((pl !=NULL) &&
-                       (recipe_name != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input provided!");
+        KMO_TRY_ASSURE((pl !=NULL) && (recipe_name != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input provided!");
 
         // --cmethod
         if ((!no_cmethod) && (cmethod != NULL)) {
@@ -1086,27 +866,17 @@ cpl_error_code kmo_combine_pars_load(cpl_parameterlist *pl,
                 *cmethod = kmo_dfs_get_parameter_string(pl, tmpstr));
 
             KMO_TRY_ASSURE((strcmp(*cmethod, "ksigma") == 0) ||
-                           (strcmp(*cmethod, "sum") == 0) ||
-                           (strcmp(*cmethod, "average") == 0) ||
-                           (strcmp(*cmethod, "median") == 0) ||
-                           (strcmp(*cmethod, "min_max") == 0),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Following combining methods are available : \"ksigma\", "
-                           "\"average\", \"sum\", \"median\" or \"min_max\"");
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_print_parameter_help(pl, tmpstr));
+                    (strcmp(*cmethod, "sum") == 0) ||
+                    (strcmp(*cmethod, "average") == 0) ||
+                    (strcmp(*cmethod, "median") == 0) ||
+                    (strcmp(*cmethod, "min_max") == 0),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "Following combining methods are available : \"ksigma\", \"average\", \"sum\", \"median\" or \"min_max\"");
+
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
             cpl_free(tmpstr); tmpstr = NULL;
         }
-
-//        if (strcmp(*cmethod, "ksigma") == 0)
-//        {
-//            KMO_TRY_ASSURE((cpos_rej != NULL) &&
-//                           (cneg_rej != NULL) &&
-//                           (citer != NULL),
-//                           CPL_ERROR_NULL_INPUT,
-//                           "Not all input provided!");
-
+        
         // --cpos_rej
         if (cpos_rej != NULL) {
             KMO_TRY_EXIT_IF_NULL(
@@ -1114,12 +884,10 @@ cpl_error_code kmo_combine_pars_load(cpl_parameterlist *pl,
             *cpos_rej = kmo_dfs_get_parameter_double(pl, tmpstr);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            KMO_TRY_ASSURE(*cpos_rej >= 0.0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "cpos_rej must be greater or equal to zero!");
+            KMO_TRY_ASSURE(*cpos_rej >= 0.0, CPL_ERROR_ILLEGAL_INPUT,
+                    "cpos_rej must be greater or equal to zero!");
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_print_parameter_help(pl, tmpstr));
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
             cpl_free(tmpstr); tmpstr = NULL;
         }
 
@@ -1130,12 +898,10 @@ cpl_error_code kmo_combine_pars_load(cpl_parameterlist *pl,
             *cneg_rej = kmo_dfs_get_parameter_double(pl, tmpstr);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            KMO_TRY_ASSURE(*cneg_rej >= 0.0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "cneg_rej must be greater or equal to zero!");
+            KMO_TRY_ASSURE(*cneg_rej >= 0.0, CPL_ERROR_ILLEGAL_INPUT,
+                    "cneg_rej must be greater or equal to zero!");
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_print_parameter_help(pl, tmpstr));
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
             cpl_free(tmpstr); tmpstr = NULL;
         }
 
@@ -1146,21 +912,13 @@ cpl_error_code kmo_combine_pars_load(cpl_parameterlist *pl,
             *citer = kmo_dfs_get_parameter_int(pl, tmpstr);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            KMO_TRY_ASSURE(*citer >= 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "citer must be greater or equal to zero!");
+            KMO_TRY_ASSURE(*citer >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "citer must be greater or equal to zero!");
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_print_parameter_help(pl, tmpstr));
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
             cpl_free(tmpstr); tmpstr = NULL;
         }
 
-//        if (strcmp(*cmethod, "min_max") == 0) {
-//            KMO_TRY_ASSURE((cmin != NULL) &&
-//                           (cmax != NULL),
-//                           CPL_ERROR_NULL_INPUT,
-//                           "Not all input provided!");
-
         // --cmin
         if ((!no_cmethod) && (cmin != NULL)) {
             KMO_TRY_EXIT_IF_NULL(
@@ -1168,13 +926,10 @@ cpl_error_code kmo_combine_pars_load(cpl_parameterlist *pl,
             *cmin = kmo_dfs_get_parameter_int(pl, tmpstr);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            KMO_TRY_ASSURE(*cmin >= 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "cmin must be greater or equal to zero! (is %d)",
-                           *cmin);
+            KMO_TRY_ASSURE(*cmin >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "cmin must be greater or equal to zero! (is %d)", *cmin);
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_print_parameter_help(pl, tmpstr));
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
             cpl_free(tmpstr); tmpstr = NULL;
         }
 
@@ -1185,12 +940,10 @@ cpl_error_code kmo_combine_pars_load(cpl_parameterlist *pl,
             *cmax = kmo_dfs_get_parameter_int(pl, tmpstr);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            KMO_TRY_ASSURE(*cmax >= 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "cmax must be greater or equal to zero!");
+            KMO_TRY_ASSURE(*cmax >= 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "cmax must be greater or equal to zero!");
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_print_parameter_help(pl, tmpstr));
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
             cpl_free(tmpstr); tmpstr = NULL;
         }
     }
@@ -1204,41 +957,33 @@ cpl_error_code kmo_combine_pars_load(cpl_parameterlist *pl,
         if (cmin != NULL) *cmin = -1;
         if (cmax != NULL) *cmax = -1;
     }
-
     cpl_free(tmpstr); tmpstr = NULL;
-
     return cpl_error_get_code();
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief  Loads band-parameters from parameterlist.
-
-    This functions is called at the beginning of recipes which
-    do reconstruct frames.
-
-    @param  pl             The parameterlist.
-    @param  recipe_name    The name of the recipe in form of "kmo.kmo_xxx".
-
-    @return
-        CPL_ERROR_NONE in case of success.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the needed arguments is NULL.
+  @brief    Loads band-parameters from parameterlist.
+  @param  pl             The parameterlist.
+  @param  recipe_name    The name of the recipe in form of "kmo.kmo_xxx".
+  @return   CPL_ERROR_NONE in case of success.
+  This functions is called at the beginning of recipes which
+  do reconstruct frames.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the needed arguments is NULL.
  */
-cpl_error_code      kmo_band_pars_load(cpl_parameterlist *pl,
-                                      const char *recipe_name)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_band_pars_load(
+        cpl_parameterlist   *   pl,
+        const char          *   recipe_name)
 {
     char   *tmpstr  = NULL;
     double tol      = 0.001;
 
     KMO_TRY
     {
-
-        KMO_TRY_ASSURE((pl !=NULL) &&
-                       (recipe_name != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input provided!");
+        KMO_TRY_ASSURE((pl !=NULL) && (recipe_name != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input provided!");
 
         // --b_samples
         KMO_TRY_EXIT_IF_NULL(
@@ -1246,12 +991,10 @@ cpl_error_code      kmo_band_pars_load(cpl_parameterlist *pl,
         kmclipm_band_samples = kmo_dfs_get_parameter_int(pl, tmpstr);
         KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_ASSURE(kmclipm_band_samples > 2,
-                CPL_ERROR_ILLEGAL_INPUT,
-                "b_samples must be greater than 2 (is %d)", kmclipm_band_samples);
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(pl, tmpstr));
+        KMO_TRY_ASSURE(kmclipm_band_samples > 2, CPL_ERROR_ILLEGAL_INPUT,
+                "b_samples must be greater than 2 (is %d)", 
+                kmclipm_band_samples);
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
         cpl_free(tmpstr); tmpstr = NULL;
 
         // --b_start
@@ -1262,13 +1005,11 @@ cpl_error_code      kmo_band_pars_load(cpl_parameterlist *pl,
 
         if (!(fabs(kmclipm_band_start + 1.0) < tol)) {
             // check only if value has been provided
-            KMO_TRY_ASSURE(kmclipm_band_start > 0.0,
-                    CPL_ERROR_ILLEGAL_INPUT,
-                    "b_start must be greater than 0.0 (is %g)", kmclipm_band_start + 1.0);
+            KMO_TRY_ASSURE(kmclipm_band_start > 0.0, CPL_ERROR_ILLEGAL_INPUT,
+                    "b_start must be greater than 0.0 (is %g)", 
+                    kmclipm_band_start + 1.0);
         }
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(pl, tmpstr));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
         cpl_free(tmpstr); tmpstr = NULL;
 
         // --b_end
@@ -1279,169 +1020,153 @@ cpl_error_code      kmo_band_pars_load(cpl_parameterlist *pl,
 
         if (!(fabs(kmclipm_band_end + 1.0) < tol)) {
             // check only if value has been provided
-            KMO_TRY_ASSURE(kmclipm_band_end > kmclipm_band_start,
-                    CPL_ERROR_ILLEGAL_INPUT,
-                    "b_end must be greater than b_start (is %g)", fabs(kmclipm_band_end + 1.0));
+            KMO_TRY_ASSURE(kmclipm_band_end > kmclipm_band_start, 
+                    CPL_ERROR_ILLEGAL_INPUT, 
+                    "b_end must be greater than b_start (is %g)", 
+                    fabs(kmclipm_band_end + 1.0));
         }
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(pl, tmpstr));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(pl, tmpstr));
         cpl_free(tmpstr); tmpstr = NULL;
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-// don't do that on global variables
-//        kmclipm_band_samples = -1;
-//        kmclipm_band_start = -1;
-//        kmclipm_band_end = -1;
     }
-
     return cpl_error_get_code();
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Checks consistency of frames regarding grating, filter & rotation.
-
-    If @code check_grating is set following keywords will be checked for
-    existence and if they match for each detector and each provided frame of
-    type @code frame_type:
-       - ESO INS GRAT1 ID
-       - ESO INS GRAT2 ID
-       - ESO INS GRAT3 ID
-    If @code check_filter is set, the same tests are performed for keywords:
-       - ESO INS FILT1 ID
-       - ESO INS FILT2 ID
-       - ESO INS FILT3 ID
-    If @code check_rotation is set, test is performed to assure that the same
-    rotation offset preset is used:
-       - ESO OCS ROT NAANGLE
-
-    @param frameset         The frameset
-    @param frame_type       The type of the frames to examine (e.g. FLAT)
-    @param check_grating    1: if gratings should be checked, 0 otherwise
-    @param check_filter     1: if filters should be checked, 0 otherwise
-    @param check_rotation   1: if rotation should be checked, 0 otherwise
-    @param rot_tol          Tolerance for rotator offset
-
-    @return   error code
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
-        CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
+  @brief    Checks consistency of frames regarding grating, filter & rotation.
+  @param frameset         The frameset
+  @param frame_type       The type of the frames to examine (e.g. FLAT)
+  @param check_grating    1: if gratings should be checked, 0 otherwise
+  @param check_filter     1: if filters should be checked, 0 otherwise
+  @param check_rotation   1: if rotation should be checked, 0 otherwise
+  @param rot_tol          Tolerance for rotator offset
+  @return   error code
+
+  If @code check_grating is set following keywords will be checked for
+  existence and if they match for each detector and each provided frame of
+  type @code frame_type:
+     - ESO INS GRAT1 ID
+     - ESO INS GRAT2 ID
+     - ESO INS GRAT3 ID
+  If @code check_filter is set, the same tests are performed for keywords:
+     - ESO INS FILT1 ID
+     - ESO INS FILT2 ID
+     - ESO INS FILT3 ID
+  If @code check_rotation is set, test is performed to assure that the same
+  rotation offset preset is used:
+     - ESO OCS ROT NAANGLE
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
+      CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
 */
-cpl_error_code  kmo_check_frameset_setup(cpl_frameset *frameset,
-                                              const char *frame_type,
-                                              int check_grating,
-                                              int check_filter,
-                                              int check_rotation)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_check_frameset_setup(
+        cpl_frameset    *   frameset,
+        const char      *   frame_type,
+        int                 check_grating,
+        int                 check_filter,
+        int                 check_rotation)
 {
     cpl_error_code ret_error = CPL_ERROR_NONE;
-
     cpl_frame        *frame1                = NULL,
                      *frame2                = NULL;
-
     cpl_propertylist *h                     = NULL;
-
     const char       *tmp_str               = NULL;
-
     char             *keyword               = NULL;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((frameset != NULL) &&
-                       (frame_type != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((frameset != NULL) && (frame_type != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         // load 1st frame
-        KMO_TRY_EXIT_IF_NULL(
-            frame1 = kmo_dfs_get_frame(frameset, frame_type));
+        KMO_TRY_EXIT_IF_NULL(frame1 = kmo_dfs_get_frame(frameset, frame_type));
 
         if (cpl_frameset_count_tags(frameset, frame_type) == 1)
         {
             h = kmclipm_propertylist_load(cpl_frame_get_filename(frame1), 0);
             if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                cpl_msg_error("","File not found: %s!",
-                              cpl_frame_get_filename(frame1));
+                cpl_msg_error(__func__, "File not found: %s!",
+                        cpl_frame_get_filename(frame1));
                 KMO_TRY_CHECK_ERROR_STATE();
             }
 
             if (check_grating == 1) {
                 // check grating for detector1
                 KMO_TRY_EXIT_IF_NULL(
-                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 1, IFU_GRATID_POSTFIX));
+                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 1,
+                        IFU_GRATID_POSTFIX));
                 tmp_str = cpl_propertylist_get_string(h, keyword);
-                KMO_TRY_ASSURE(tmp_str != NULL,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, frame_type);
+                KMO_TRY_ASSURE(tmp_str != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type);
                 cpl_free(keyword); keyword = NULL;
 
                 // check grating for detector2
                 KMO_TRY_EXIT_IF_NULL(
-                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 2, IFU_GRATID_POSTFIX));
+                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 2, 
+                        IFU_GRATID_POSTFIX));
                 tmp_str = cpl_propertylist_get_string(h, keyword);
-                KMO_TRY_ASSURE(tmp_str != NULL,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, frame_type);
+                KMO_TRY_ASSURE(tmp_str != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type);
                 cpl_free(keyword); keyword = NULL;
 
                 // check grating for detector3
                 KMO_TRY_EXIT_IF_NULL(
-                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 3, IFU_GRATID_POSTFIX));
+                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 3, 
+                        IFU_GRATID_POSTFIX));
                 tmp_str = cpl_propertylist_get_string(h, keyword);
-                KMO_TRY_ASSURE(tmp_str != NULL,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, frame_type);
+                KMO_TRY_ASSURE(tmp_str != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type);
                 cpl_free(keyword); keyword = NULL;
             }
 
             if (check_filter == 1) {
                 // check filter for detector1
                 KMO_TRY_EXIT_IF_NULL(
-                    keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 1, IFU_FILTID_POSTFIX));
+                    keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 1, 
+                        IFU_FILTID_POSTFIX));
                 tmp_str = cpl_propertylist_get_string(h, keyword);
-                KMO_TRY_ASSURE(tmp_str != NULL,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, frame_type);
+                KMO_TRY_ASSURE(tmp_str != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type);
                 cpl_free(keyword); keyword = NULL;
 
                 // check filter for detector2
                 KMO_TRY_EXIT_IF_NULL(
-                    keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 2, IFU_FILTID_POSTFIX));
+                    keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 2, 
+                        IFU_FILTID_POSTFIX));
                 tmp_str = cpl_propertylist_get_string(h, keyword);
-                KMO_TRY_ASSURE(tmp_str != NULL,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, frame_type);
+                KMO_TRY_ASSURE(tmp_str != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type);
                 cpl_free(keyword); keyword = NULL;
 
                 // check filter for detector3
                 KMO_TRY_EXIT_IF_NULL(
-                    keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 3, IFU_FILTID_POSTFIX));
+                    keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 3, 
+                        IFU_FILTID_POSTFIX));
                 tmp_str = cpl_propertylist_get_string(h, keyword);
-                KMO_TRY_ASSURE(tmp_str != NULL,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, frame_type);
+                KMO_TRY_ASSURE(tmp_str != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type);
                 cpl_free(keyword); keyword = NULL;
             }
 
             if (check_rotation == 1) {
                 // check rotation offset
-                KMO_TRY_EXIT_IF_NULL(
-                    keyword = cpl_sprintf("%s", ROTANGLE));
+                KMO_TRY_EXIT_IF_NULL(keyword = cpl_sprintf("%s", ROTANGLE));
                 cpl_propertylist_get_double(h, keyword);
                 if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                    KMO_TRY_ASSURE(1 == 0,
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "keyword \n%s\n of frame %s is missing!",
-                                   keyword, frame_type);
+                    KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                            "keyword \n%s\n of frame %s is missing!",
+                            keyword, frame_type);
                     cpl_free(keyword); keyword = NULL;
                 }
             }
@@ -1449,14 +1174,10 @@ cpl_error_code  kmo_check_frameset_setup(cpl_frameset *frameset,
         } else {
             frame2 = kmo_dfs_get_frame(frameset, NULL);
             KMO_TRY_CHECK_ERROR_STATE();
-
             while (frame2 != NULL) {
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmo_priv_compare_frame_setup(frame1, frame2,
-                                                 frame_type, frame_type,
-                                                 check_grating, check_filter,
-                                                 check_rotation));
-
+                    kmo_priv_compare_frame_setup(frame1, frame2, frame_type, 
+                        frame_type,check_grating,check_filter,check_rotation));
                 frame2 = kmo_dfs_get_frame(frameset, NULL);
                 KMO_TRY_CHECK_ERROR_STATE();
             }
@@ -1467,279 +1188,278 @@ cpl_error_code  kmo_check_frameset_setup(cpl_frameset *frameset,
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_propertylist_delete(h); h = NULL;
     cpl_free(keyword); keyword = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Checks consistency of frames regarding grating, filter & rotation.
-
-    If @code check_grating is set following keywords will be checked for
-    existence and if they match for each detector and each provided frame of
-    type @code frame_type:
-       - ESO INS GRAT1 ID
-       - ESO INS GRAT2 ID
-       - ESO INS GRAT3 ID
-    If @code check_filter is set, the same tests are performed for keywords:
-       - ESO INS FILT1 ID
-       - ESO INS FILT2 ID
-       - ESO INS FILT3 ID
-    If @code check_rotation is set, test is performed to assure that the same
-    rotation offset preset is used:
-       - ESO OCS ROT NAANGLE
-
-    @param frameset         The frameset
-    @param frame_type1      The type of the 1st frame to examine (e.g. FLAT)
-    @param frame_type2      The type of the 2nd frame to examine (e.g. DARK)
-    @param check_grating    1: if gratings should be checked, 0 otherwise
-    @param check_filter     1: if filters should be checked, 0 otherwise
-    @param check_rotation   1: if rotation should be checked, 0 otherwise
-    @param rot_tol          Tolerance for rotator offset
-
-    @return   error code
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
-        CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
+  @brief    Checks consistency of frames regarding grating, filter & rotation.
+  @param frameset         The frameset
+  @param frame_type1      The type of the 1st frame to examine (e.g. FLAT)
+  @param frame_type2      The type of the 2nd frame to examine (e.g. DARK)
+  @param check_grating    1: if gratings should be checked, 0 otherwise
+  @param check_filter     1: if filters should be checked, 0 otherwise
+  @param check_rotation   1: if rotation should be checked, 0 otherwise
+  @param rot_tol          Tolerance for rotator offset
+  @return   error code
+  If @code check_grating is set following keywords will be checked for
+  existence and if they match for each detector and each provided frame of
+  type @code frame_type:
+     - ESO INS GRAT1 ID
+     - ESO INS GRAT2 ID
+     - ESO INS GRAT3 ID
+  If @code check_filter is set, the same tests are performed for keywords:
+     - ESO INS FILT1 ID
+     - ESO INS FILT2 ID
+     - ESO INS FILT3 ID
+  If @code check_rotation is set, test is performed to assure that the same
+  rotation offset preset is used:
+     - ESO OCS ROT NAANGLE
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
+      CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
 */
-cpl_error_code  kmo_check_frame_setup(cpl_frameset *frameset,
-                                      const char *frame_type1,
-                                      const char *frame_type2,
-                                      int check_grating,
-                                      int check_filter,
-                                      int check_rotation)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_check_frame_setup(
+        cpl_frameset    *   frameset,
+        const char      *   frame_type1,
+        const char      *   frame_type2,
+        int                 check_grating,
+        int                 check_filter,
+        int                 check_rotation)
 {
     cpl_error_code ret_error = CPL_ERROR_NONE;
-
     cpl_frame        *frame1                = NULL,
                      *frame2                = NULL;
-
     KMO_TRY
     {
-        KMO_TRY_ASSURE((frameset != NULL) &&
-                       (frame_type1 != NULL) &&
-                       (frame_type2 != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((frameset != NULL) && (frame_type1 != NULL) &&
+                (frame_type2 != NULL), CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         // get frames
-        KMO_TRY_EXIT_IF_NULL(
-            frame1 = kmo_dfs_get_frame(frameset, frame_type1));
-
-        KMO_TRY_EXIT_IF_NULL(
-            frame2 = kmo_dfs_get_frame(frameset, frame_type2));
+        KMO_TRY_EXIT_IF_NULL(frame1 = kmo_dfs_get_frame(frameset, frame_type1));
+        KMO_TRY_EXIT_IF_NULL(frame2 = kmo_dfs_get_frame(frameset, frame_type2));
 
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_priv_compare_frame_setup(frame1, frame2,
-                                         frame_type1, frame_type2,
-                                         check_grating, check_filter,
-                                         check_rotation));
+            kmo_priv_compare_frame_setup(frame1, frame2, frame_type1, 
+                frame_type2, check_grating, check_filter, check_rotation));
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Checks consistency of two frames regarding grating, filter & rotation.
-
-    If @code check_grating is set following keywords will be checked for
-    existence and if they match for each detector and each provided frame of
-    type @code frame_type:
-       - ESO INS GRAT1 ID
-       - ESO INS GRAT2 ID
-       - ESO INS GRAT3 ID
-    If @code check_filter is set, the same tests are performed for keywords:
-       - ESO INS FILT1 ID
-       - ESO INS FILT2 ID
-       - ESO INS FILT3 ID
-    If @code check_rotation is set, test is performed to assure that the same
-    rotation offset preset is used:
-       - ESO OCS ROT NAANGLE
-
-    @param frame1           The 1st frame
-    @param frame2           The 2nd frame
-    @param frame_type1      The type of the 1st frame to examine (e.g. FLAT)
-    @param frame_type2      The type of the 2nd frame to examine (e.g. DARK)
-    @param check_grating    1: if gratings should be checked, 0 otherwise
-    @param check_filter     1: if filters should be checked, 0 otherwise
-    @param check_rotation   1: if rotation should be checked, 0 otherwise
-
-    @return   error code
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
-        CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
+  @brief Checks consiѕtency of OH_SPEC filter 
+  @param frameset         The frameset
+  @param frame_type1      The type of the ref frame to examine (e.g.  XCAL)
+  @return   error code
+  The following keywords
+     - ESO INS FILT1 ID
+     - ESO INS FILT2 ID
+     - ESO INS FILT3 ID
+  are checked from the reference frame. Their value must match the
+  OH_SPEC keyword ESO FILT ID
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
+      CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
 */
-cpl_error_code  kmo_priv_compare_frame_setup(const cpl_frame *frame1,
-                                      const cpl_frame *frame2,
-                                      const char *frame_type1,
-                                      const char *frame_type2,
-                                      int check_grating,
-                                      int check_filter,
-                                      int check_rotation)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_check_oh_spec_setup(
+        cpl_frameset    *   frameset,
+        const char      *   frame_type)
 {
     cpl_error_code ret_error = CPL_ERROR_NONE;
-
+    cpl_frame        *frame1                = NULL,
+                     *frame2                = NULL;
     const char       *tmp_str1              = NULL,
                      *tmp_str2              = NULL;
-
-//    double           tmp_dbl1               = 0.0/*,
-//                     tmp_dbl2               = 0.0*/;
-
     char             *keyword               = NULL;
-
     cpl_propertylist *main_header1          = NULL,
                      *main_header2          = NULL;
+    int              i ;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((frame1 != NULL) &&
-                       (frame2 != NULL) &&
-                       (frame_type1 != NULL) &&
-                       (frame_type2 != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        main_header1 = kmclipm_propertylist_load(cpl_frame_get_filename(frame1), 0);
+        /* Check entries */
+        KMO_TRY_ASSURE((frameset != NULL) && (frame_type != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
+   
+        /* Get frames */
+        KMO_TRY_EXIT_IF_NULL(frame1 = kmo_dfs_get_frame(frameset, frame_type));
+        KMO_TRY_EXIT_IF_NULL(frame2 = kmo_dfs_get_frame(frameset, OH_SPEC));
+        
+        /* Get main header of reference frame */
+        main_header1 = kmclipm_propertylist_load(cpl_frame_get_filename(frame1),
+                0);
         if (cpl_error_get_code() != CPL_ERROR_NONE) {
-            cpl_msg_error("","File not found: %s!",
-                          cpl_frame_get_filename(frame1));
+            cpl_msg_error(__func__, "File not found: %s!",
+                    cpl_frame_get_filename(frame1));
             KMO_TRY_CHECK_ERROR_STATE();
         }
 
-        main_header2 = kmclipm_propertylist_load(cpl_frame_get_filename(frame2), 0);
+        /* Get Main header of OH_SPEC */
+        main_header2 = kmclipm_propertylist_load(cpl_frame_get_filename(frame2),
+                0);
         if (cpl_error_get_code() != CPL_ERROR_NONE) {
-            cpl_msg_error("","File not found: %s!",
-                          cpl_frame_get_filename(frame2));
+            cpl_msg_error(__func__, "File not found: %s!",
+                    cpl_frame_get_filename(frame2));
             KMO_TRY_CHECK_ERROR_STATE();
         }
 
-        if (check_grating == 1) {
-            // compare grating for detector1
-            KMO_TRY_EXIT_IF_NULL(
-                keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 1, IFU_GRATID_POSTFIX));
-            tmp_str1 = cpl_propertylist_get_string(main_header1, keyword);
-            KMO_TRY_ASSURE(tmp_str1 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type1);
-            tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
-            KMO_TRY_ASSURE(tmp_str2 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type2);
-            KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Grating for 1st detector of frames %s and %s "
-                           "don't match!", frame_type1, frame_type2);
-            cpl_free(keyword); keyword = NULL;
+        /* Get Filter info from OH_SPEC */
+        keyword = cpl_sprintf("ESO FILT ID");
+        tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
+        KMO_TRY_ASSURE(tmp_str2 != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                "keyword \n%s\n of frame %s is missing!",
+                keyword, OH_SPEC);
+        cpl_free(keyword); keyword = NULL;
 
-            // compare grating for detector2
+        /* Compare filter for detector 1,2,3 */
+        for (i=1 ; i<=3 ; i++) {
             KMO_TRY_EXIT_IF_NULL(
-                keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 2, IFU_GRATID_POSTFIX));
+                keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, i, 
+                    IFU_FILTID_POSTFIX));
             tmp_str1 = cpl_propertylist_get_string(main_header1, keyword);
-            KMO_TRY_ASSURE(tmp_str1 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type1);
-            tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
-            KMO_TRY_ASSURE(tmp_str2 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type2);
+            KMO_TRY_ASSURE(tmp_str1 != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                    "keyword \n%s\n of frame %s is missing!",
+                    keyword, frame_type);
             KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Grating for 2nd detector of frames %s and %s "
-                           "don't match!", frame_type1, frame_type2);
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "Filter for detector %d of frames %s and %s don't match!",
+                    i, frame_type, OH_SPEC);
             cpl_free(keyword); keyword = NULL;
+        }
+    }
 
-            // compare grating for detector3
-            KMO_TRY_EXIT_IF_NULL(
-                keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 3, IFU_GRATID_POSTFIX));
-            tmp_str1 = cpl_propertylist_get_string(main_header1, keyword);
-            KMO_TRY_ASSURE(tmp_str1 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type1);
-            tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
-            KMO_TRY_ASSURE(tmp_str2 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type2);
-            KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Grating for 3rd detector of frames %s and %s "
-                           "don't match!", frame_type1, frame_type2);
-            cpl_free(keyword); keyword = NULL;
+    KMO_CATCH
+    {
+        KMO_CATCH_MSG();
+        ret_error = cpl_error_get_code();
+    }
+    cpl_propertylist_delete(main_header1); main_header1 = NULL;
+    cpl_propertylist_delete(main_header2); main_header2 = NULL;
+    cpl_free(keyword); keyword = NULL;
+    return ret_error;
+}
+
+/*----------------------------------------------------------------------------*/
+/**
+  @brief Checks consistency of two frames regarding grating, filter &rotation
+  @param frame1           The 1st frame
+  @param frame2           The 2nd frame
+  @param frame_type1      The type of the 1st frame to examine (e.g. FLAT)
+  @param frame_type2      The type of the 2nd frame to examine (e.g. DARK)
+  @param check_grating    1: if gratings should be checked, 0 otherwise
+  @param check_filter     1: if filters should be checked, 0 otherwise
+  @param check_rotation   1: if rotation should be checked, 0 otherwise
+  @return   error code
+  If @code check_grating is set following keywords will be checked for
+  existence and if they match for each detector and each provided frame of
+  type @code frame_type:
+     - ESO INS GRAT1 ID
+     - ESO INS GRAT2 ID
+     - ESO INS GRAT3 ID
+  If @code check_filter is set, the same tests are performed for keywords:
+     - ESO INS FILT1 ID
+     - ESO INS FILT2 ID
+     - ESO INS FILT3 ID
+  If @code check_rotation is set, test is performed to assure that the same
+  rotation offset preset is used:
+     - ESO OCS ROT NAANGLE
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
+      CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
+*/
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_priv_compare_frame_setup(
+        const cpl_frame     *   frame1,
+        const cpl_frame     *   frame2,
+        const char          *   frame_type1,
+        const char          *   frame_type2,
+        int                     check_grating,
+        int                     check_filter,
+        int                     check_rotation)
+{
+    cpl_error_code          ret_error = CPL_ERROR_NONE;
+    const char          *   tmp_str1              = NULL,
+                        *   tmp_str2              = NULL;
+    char                *   keyword               = NULL;
+    cpl_propertylist    *   main_header1          = NULL,
+                        *   main_header2          = NULL;
+    int                     i ;
+
+    KMO_TRY
+    {
+        KMO_TRY_ASSURE((frame1 != NULL) && (frame2 != NULL) && 
+                (frame_type1 != NULL) && (frame_type2 != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
+
+        main_header1 = kmclipm_propertylist_load(cpl_frame_get_filename(frame1),
+                0);
+        if (cpl_error_get_code() != CPL_ERROR_NONE) {
+            cpl_msg_error(__func__, "File not found: %s!",
+                    cpl_frame_get_filename(frame1));
+            KMO_TRY_CHECK_ERROR_STATE();
         }
 
-        if (check_filter == 1) {
-            // compare filter for detector1
-            KMO_TRY_EXIT_IF_NULL(
-                keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 1, IFU_FILTID_POSTFIX));
-            tmp_str1 = cpl_propertylist_get_string(main_header1, keyword);
-            KMO_TRY_ASSURE(tmp_str1 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type1);
-            tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
-            KMO_TRY_ASSURE(tmp_str2 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type2);
-            KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Filter for 1st detector of frames %s and %s "
-                           "don't match!", frame_type1, frame_type2);
-            cpl_free(keyword); keyword = NULL;
+        main_header2 = kmclipm_propertylist_load(cpl_frame_get_filename(frame2),
+                0);
+        if (cpl_error_get_code() != CPL_ERROR_NONE) {
+            cpl_msg_error(__func__, "File not found: %s!",
+                    cpl_frame_get_filename(frame2));
+            KMO_TRY_CHECK_ERROR_STATE();
+        }
 
-            // compare filter for detector2
-            KMO_TRY_EXIT_IF_NULL(
-                keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 2, IFU_FILTID_POSTFIX));
-            tmp_str1 = cpl_propertylist_get_string(main_header1, keyword);
-            KMO_TRY_ASSURE(tmp_str1 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type1);
-            tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
-            KMO_TRY_ASSURE(tmp_str2 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type2);
-            KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Filter for 2nd detector of frames %s and %s "
-                           "don't match!", frame_type1, frame_type2);
-            cpl_free(keyword); keyword = NULL;
+        if (check_grating == 1) {
+            // compare grating for detector 1, 2, 3
+            for (i=1 ; i<=3 ; i++) {
+                KMO_TRY_EXIT_IF_NULL(
+                    keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, i, 
+                        IFU_GRATID_POSTFIX));
+                tmp_str1 = cpl_propertylist_get_string(main_header1, keyword);
+                KMO_TRY_ASSURE(tmp_str1 != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type1);
+                tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
+                KMO_TRY_ASSURE(tmp_str2 != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type2);
+                KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
+                        CPL_ERROR_ILLEGAL_INPUT, 
+                        "Grating for detector %d frame %s and %s don't match!",
+                        i, frame_type1, frame_type2);
+                cpl_free(keyword); keyword = NULL;
+            }
+        }
 
-            // compare filter for detector3
-            KMO_TRY_EXIT_IF_NULL(
-                keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 3, IFU_FILTID_POSTFIX));
-            tmp_str1 = cpl_propertylist_get_string(main_header1, keyword);
-            KMO_TRY_ASSURE(tmp_str1 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type1);
-            tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
-            KMO_TRY_ASSURE(tmp_str2 != NULL,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "keyword \n%s\n of frame %s is missing!",
-                           keyword, frame_type2);
-            KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Filter for 3rd detector of frames %s and %s "
-                           "don't match!", frame_type1, frame_type2);
-            cpl_free(keyword); keyword = NULL;
+        if (check_filter == 1) {
+            // compare filter for detector 1,2,3
+            for (i=1 ; i<=3 ; i++) {
+                KMO_TRY_EXIT_IF_NULL(
+                    keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, i, 
+                        IFU_FILTID_POSTFIX));
+                tmp_str1 = cpl_propertylist_get_string(main_header1, keyword);
+                KMO_TRY_ASSURE(tmp_str1 != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type1);
+                tmp_str2 = cpl_propertylist_get_string(main_header2, keyword);
+                KMO_TRY_ASSURE(tmp_str2 != NULL, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type2);
+                KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "Filter for detector %d frame %s and %s don't match!",
+                        i, frame_type1, frame_type2);
+                cpl_free(keyword); keyword = NULL;
+            }
         }
 
         if (check_rotation == 1) {
@@ -1748,29 +1468,10 @@ cpl_error_code  kmo_priv_compare_frame_setup(const cpl_frame *frame1,
                 keyword = cpl_sprintf("%s", ROTANGLE));
             cpl_propertylist_get_double(main_header1, keyword);
             if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                KMO_TRY_ASSURE(1 == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, frame_type1);
+                KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                        "keyword \n%s\n of frame %s is missing!",
+                        keyword, frame_type1);
             }
-
-//            tmp_dbl2 = cpl_propertylist_get_double(main_header2, keyword);
-//            if (cpl_error_get_code() != CPL_ERROR_NONE) {
-//                KMO_TRY_ASSURE(1 == 0,
-//                               CPL_ERROR_ILLEGAL_INPUT,
-//                               "keyword \n%s\n of frame %s is missing!",
-//                               keyword, frame_type2);
-//            }
-//            cpl_free(keyword); keyword = NULL;
-
-//            // strip angles below 0 deg and above 360 deg
-//            kmclipm_strip_angle(&tmp_dbl1);
-//            kmclipm_strip_angle(&tmp_dbl2);
-
-//            KMO_TRY_ASSURE(fabs(tmp_dbl1 - tmp_dbl2) <= rot_tol,
-//                           CPL_ERROR_ILLEGAL_INPUT,
-//                           "Rotation of frames %s and %s don't match!",
-//                           frame_type1, frame_type2);
         }
     }
     KMO_CATCH
@@ -1778,29 +1479,24 @@ cpl_error_code  kmo_priv_compare_frame_setup(const cpl_frame *frame1,
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_propertylist_delete(main_header1); main_header1 = NULL;
     cpl_propertylist_delete(main_header2); main_header2 = NULL;
     cpl_free(keyword); keyword = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Checks consistency of frames regarding MD5 keyword (XCAL, YCAL vs LCAL)
-
-    @param frameset         The frameset
-
-    @return   error code
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_NULL_INPUT if @code frameset is empty
+  @brief Checks consistency of frames regarding MD5 keyword (XCAL, YCAL vs LCAL)
+  @param frameset         The frameset
+  @return   error code
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_NULL_INPUT if @code frameset is empty
 */
-cpl_error_code  kmo_check_frame_setup_md5(cpl_frameset *frameset)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_check_frame_setup_md5(cpl_frameset *frameset)
 {
     cpl_error_code ret_error = CPL_ERROR_NONE;
-
     cpl_frame           *tmpFrame           = NULL;
     int                 matchError          = FALSE,
                         ind                 = 1;
@@ -1815,9 +1511,8 @@ cpl_error_code  kmo_check_frame_setup_md5(cpl_frameset *frameset)
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         KMO_TRY_EXIT_IF_NULL(
             mainLcal = kmo_dfs_load_primary_header(frameset, LCAL));
@@ -1836,23 +1531,26 @@ cpl_error_code  kmo_check_frame_setup_md5(cpl_frameset *frameset)
             if ((strcmp(valCatg, XCAL) == 0) ||
                 (strcmp(valCatg, YCAL) == 0) ||
                 (strcmp(valCatg, FLAT_EDGE) == 0) ||
-                (strcmp(valCatg, MASTER_FLAT) == 0))
-            {
+                (strcmp(valCatg, MASTER_FLAT) == 0)) {
                 tmpFrame = cpl_frameset_find(frameset, valCatg);
                 if (tmpFrame != NULL) {
                     // check if MD5 matches
                     KMO_TRY_EXIT_IF_NULL(
-                        keywordMd5 = cpl_sprintf("ESO PRO REC1 CAL%d DATAMD5", ind));
+                        keywordMd5 = cpl_sprintf("ESO PRO REC1 CAL%d DATAMD5", 
+                            ind));
 
                     KMO_TRY_EXIT_IF_NULL(
-                        valMd5 = cpl_propertylist_get_string(mainLcal, keywordMd5));
+                        valMd5 = cpl_propertylist_get_string(mainLcal, 
+                            keywordMd5));
                     cpl_free(keywordMd5); keywordMd5 = NULL;
 
                     KMO_TRY_EXIT_IF_NULL(
-                        mainTmp = kmo_dfs_load_primary_header(frameset, valCatg));
+                        mainTmp = kmo_dfs_load_primary_header(frameset,
+                            valCatg));
 
                     KMO_TRY_EXIT_IF_NULL(
-                        md5Tmp = cpl_propertylist_get_string(mainTmp, "DATAMD5"));
+                        md5Tmp = cpl_propertylist_get_string(mainTmp, 
+                            "DATAMD5"));
 
                     if (strcmp(valMd5, md5Tmp) != 0) {
                         if (!matchError) {
@@ -1890,40 +1588,33 @@ cpl_error_code  kmo_check_frame_setup_md5(cpl_frameset *frameset)
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_propertylist_delete(mainLcal); mainLcal = NULL;
     cpl_free(keywordName); keywordName = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Checks consistency of frames regarding MD5 keyword (XCAL, YCAL vs LCAL)
-
-    @param frameset         The frameset
-
-    @return   error code
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_NULL_INPUT if @code frameset is empty
+  @brief Checks consistency of frames regarding MD5 keyword (XCAL, YCAL vs LCAL)
+  @param frameset         The frameset
+  @return   error code
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_NULL_INPUT if @code frameset is empty
 */
-cpl_error_code  kmo_check_frame_setup_md5_xycal(cpl_frameset *frameset)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_check_frame_setup_md5_xycal(cpl_frameset *frameset)
 {
     cpl_error_code ret_error = CPL_ERROR_NONE;
-
     int                 ind                 = 1;
     cpl_propertylist    *mainXcal           = NULL,
                         *mainYcal           = NULL;
     char                *keywordName        = NULL;
     const char          *valX               = NULL,
                         *valY               = NULL;
-
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         KMO_TRY_EXIT_IF_NULL(
             mainXcal = kmo_dfs_load_primary_header(frameset, XCAL));
@@ -1937,15 +1628,13 @@ cpl_error_code  kmo_check_frame_setup_md5_xycal(cpl_frameset *frameset)
         int ok = TRUE;
         while (ok) {
             if (cpl_propertylist_has(mainXcal, keywordName) &&
-                cpl_propertylist_has(mainYcal, keywordName))
-            {
+                cpl_propertylist_has(mainYcal, keywordName)) {
                 KMO_TRY_EXIT_IF_NULL(
                     valX = cpl_propertylist_get_string(mainXcal, keywordName));
                 KMO_TRY_EXIT_IF_NULL(
                     valY = cpl_propertylist_get_string(mainYcal, keywordName));
 
-                if (strcmp(valX, valY) != 0)
-                {
+                if (strcmp(valX, valY) != 0) {
                     cpl_msg_warning("","**********************************************************************");
                     cpl_msg_warning("","**********************************************************************");
                     cpl_msg_warning("","***   XCAL and YCAL originate from different calibration sets!     ***");
@@ -1963,9 +1652,7 @@ cpl_error_code  kmo_check_frame_setup_md5_xycal(cpl_frameset *frameset)
             } else {
                 ok = FALSE;
             }
-
             cpl_free(keywordName); keywordName = NULL;
-
             // next keyword ESO PRO REC1 CALx NAME
             ind++;
             KMO_TRY_EXIT_IF_NULL(
@@ -1977,29 +1664,25 @@ cpl_error_code  kmo_check_frame_setup_md5_xycal(cpl_frameset *frameset)
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_propertylist_delete(mainXcal); mainXcal = NULL;
     cpl_propertylist_delete(mainYcal); mainYcal = NULL;
     cpl_free(keywordName); keywordName = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Get the ESO PRO REC1 PARAMx VALUE...
-
-    ... of a given ESO PRO REC1 PARAMx NAME value
-
-    @param header         The header
-    @param par_name       The value of the ESO PRO REC1 PARAMx NAME
-
-    @return   error code
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_NULL_INPUT if @code frameset is empty
+  @brief Get the ESO PRO REC1 PARAMx VALUE of a ESO PRO REC1 PARAMx NAME 
+  @param header         The header
+  @param par_name       The value of the ESO PRO REC1 PARAMx NAME
+  @return   error code
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_NULL_INPUT if @code frameset is empty
 */
-const char* kmo_get_pro_keyword_val(const cpl_propertylist *header, const char *par_name)
+/*----------------------------------------------------------------------------*/
+const char * kmo_get_pro_keyword_val(
+        const cpl_propertylist  *   header,
+        const char              *   par_name)
 {
     int         found           = FALSE,
                 ind             = 1;
@@ -2009,18 +1692,15 @@ const char* kmo_get_pro_keyword_val(const cpl_propertylist *header, const char *
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((header != NULL) ||
-                       (par_name != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-
+        KMO_TRY_ASSURE((header != NULL) || (par_name != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
         KMO_TRY_EXIT_IF_NULL(
             keywordName = cpl_sprintf("ESO PRO REC1 PARAM%d NAME", ind));
 
         while (!found && cpl_propertylist_has(header, keywordName)) {
             KMO_TRY_EXIT_IF_NULL(
-                keywordNameVal = cpl_propertylist_get_string(header, keywordName));
+                keywordNameVal = cpl_propertylist_get_string(header, 
+                    keywordName));
 
             if (strcmp(keywordNameVal, par_name) == 0) {
                 found = TRUE;
@@ -2048,23 +1728,19 @@ const char* kmo_get_pro_keyword_val(const cpl_propertylist *header, const char *
         KMO_CATCH_MSG();
         val = NULL;
     }
-
     cpl_free(keywordName); keywordName = NULL;
-
     return val;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Checks consistency of frames regarding sampling-keywords
-
-    @param frameset         The frameset
-
-    @return   error code
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_NULL_INPUT if @code frameset is empty
+  @brief Checks consistency of frames regarding sampling-keywords
+  @param frameset         The frameset
+  @return   error code
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_NULL_INPUT if @code frameset is empty
 */
+/*----------------------------------------------------------------------------*/
 cpl_error_code  kmo_check_frame_setup_sampling(cpl_frameset *frameset)
 {
     cpl_error_code      ret_error       = CPL_ERROR_NONE;
@@ -2076,9 +1752,8 @@ cpl_error_code  kmo_check_frame_setup_sampling(cpl_frameset *frameset)
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         KMO_TRY_EXIT_IF_NULL(
             mainLcal = kmo_dfs_load_primary_header(frameset, LCAL));
@@ -2137,43 +1812,42 @@ cpl_error_code  kmo_check_frame_setup_sampling(cpl_frameset *frameset)
         KMO_CATCH_MSG();
         ret_error = cpl_error_get_code();
     }
-
     cpl_propertylist_delete(mainLcal); mainLcal = NULL;
     cpl_propertylist_delete(mainTell); mainTell = NULL;
-
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Tweak loading of TELLURIC vector
-
-    This tweak is done for reducing frustration of non-matching telluric...
-    If an IFU contains antelluric, it is returned.
-    If it doesn't contain a telluric, the closest one in numbers is returned.
-    But only if it is one the same detector, otherwise NULL is returned without error
-
-    @param frameset     The input set-of-frames
-    @param category     The category of the image to load. Either a keyword or a
-                        string containing an integer designating the position of the
-                        frame in the frameset to load (first = "0"). If NULL, the
-                        next frame with same keyword as accessed right before will
-                        be returned
-    @param ifu_nr       The device number (IFU or detector) to access (first = 1)
-    @param is_noise     TRUE:  the noise frame of the device is returned
-                        FALSE: the data frame of the device is returned
-    @param no_subtract  Just used for printing messages. Supply -1 if no messages are wanted
-
-    @return   Found telluric, NULL if none valid has been found (no error set!)
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
-        CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
+  @brief    Tweak loading of TELLURIC vector
+  @param frameset     The input set-of-frames
+  @param category     The category of the image to load. Either a keyword or a
+                      string containing an integer designating the position of 
+                      the frame in the frameset to load (first = "0"). If NULL,
+                      the next frame with same keyword as accessed right before
+                      will be returned
+  @param ifu_nr       The device number (IFU or detector) to access (first = 1)
+  @param is_noise     TRUE:  the noise frame of the device is returned
+                      FALSE: the data frame of the device is returned
+  @param no_subtract  Just used for printing messages. Supply -1 if no messages
+                        are wanted
+  @return   Found telluric, NULL if none valid has been found (no error set!)
+
+  This tweak is done for reducing frustration of non-matching telluric...
+  If an IFU contains a telluric, it is returned.
+  If it doesn't contain a telluric, the closest one in numbers is returned.
+  But only if it is one the same detector, otherwise NULL is returned 
+  without error
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
+      CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
 */
-kmclipm_vector* kmo_tweak_load_telluric(cpl_frameset *frameset,
-                                        int ifu_nr,
-                                        int is_noise,
-                                        int no_subtract)
+/*----------------------------------------------------------------------------*/
+kmclipm_vector * kmo_tweak_load_telluric(
+        cpl_frameset    *   frameset,
+        int                 ifu_nr,
+        int                 is_noise,
+        int                 no_subtract)
 {
     kmclipm_vector      *vec                = NULL;
     cpl_propertylist    *header             = NULL;
@@ -2183,21 +1857,14 @@ kmclipm_vector* kmo_tweak_load_telluric(cpl_frameset *frameset,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
-
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
         KMO_TRY_ASSURE((ifu_nr >= 1) && (ifu_nr <= KMOS_NR_IFUS),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "device number is negative!");
-
+                CPL_ERROR_ILLEGAL_INPUT, "device number is negative!");
         KMO_TRY_ASSURE((is_noise == 0) || (is_noise == 1),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "is_noise must be 0 or 1!");
-
+                CPL_ERROR_ILLEGAL_INPUT, "is_noise must be 0 or 1!");
         KMO_TRY_EXIT_IF_NULL(
             header = kmo_dfs_load_primary_header(frameset, TELLURIC));
-
         KMO_TRY_EXIT_IF_NULL(
             tplid = cpl_propertylist_get_string(header, TPL_ID));
 
@@ -2213,7 +1880,8 @@ kmclipm_vector* kmo_tweak_load_telluric(cpl_frameset *frameset,
         }
 
         ifu_nr_telluric = kmo_tweak_find_ifu(frameset, ifu_nr);
-        if ((ifu_nr != ifu_nr_telluric) && (ifu_nr_telluric != -1) && (no_subtract != -1)) {
+        if ((ifu_nr != ifu_nr_telluric) && (ifu_nr_telluric != -1) && 
+                (no_subtract != -1)) {
             if (!no_subtract) {
                 cpl_msg_info("","        (telluric in IFU %d has been picked!)", ifu_nr_telluric);
             } else {
@@ -2224,11 +1892,14 @@ kmclipm_vector* kmo_tweak_load_telluric(cpl_frameset *frameset,
         actual_msg_level = cpl_msg_get_level();
         cpl_msg_set_level(CPL_MSG_OFF);
         if ((ifu_nr >= 1) && (ifu_nr <= 8)) {
-            vec = kmo_dfs_load_vector(frameset, TELLURIC, ifu_nr_telluric, is_noise);
+            vec = kmo_dfs_load_vector(frameset, TELLURIC, ifu_nr_telluric, 
+                    is_noise);
         } else if ((ifu_nr >= 9) && (ifu_nr <= 16)) {
-            vec = kmo_dfs_load_vector(frameset, TELLURIC, ifu_nr_telluric, is_noise);
+            vec = kmo_dfs_load_vector(frameset, TELLURIC, ifu_nr_telluric, 
+                    is_noise);
         } else if ((ifu_nr >= 17) && (ifu_nr <= 24)) {
-            vec = kmo_dfs_load_vector(frameset, TELLURIC, ifu_nr_telluric, is_noise);
+            vec = kmo_dfs_load_vector(frameset, TELLURIC, ifu_nr_telluric, 
+                    is_noise);
         }
         cpl_msg_set_level(actual_msg_level);
 
@@ -2241,9 +1912,7 @@ kmclipm_vector* kmo_tweak_load_telluric(cpl_frameset *frameset,
         KMO_CATCH_MSG();
         kmclipm_vector_delete(vec); vec = NULL;
     }
-
     cpl_propertylist_delete(header); header = NULL;
-
     if ((vec == NULL) && !is_noise && (no_subtract != -1)) {
         if (!no_subtract) {
             cpl_msg_warning("","        Couldn't find any telluric correction on this detector!");
@@ -2251,25 +1920,21 @@ kmclipm_vector* kmo_tweak_load_telluric(cpl_frameset *frameset,
             cpl_msg_warning("","Couldn't find any telluric correction on this detector for IFU %d!", ifu_nr);
         }
     }
-
     return vec;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Find closest telluric IFU on the same detector
-
-    @param frameset The input set-of-frames
-    @param ifu_nr   The IFU number
-
-    @return   The IFU ID containing the closest telluric
-
-    Possible cpl_error_code set in this function:
-        CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
-        CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
+  @brief Find closest telluric IFU on the same detector
+  @param frameset The input set-of-frames
+  @param ifu_nr   The IFU number
+  @return   The IFU ID containing the closest telluric
+  Possible cpl_error_code set in this function:
+      CPL_ERROR_ILLEGAL_INPUT if any of the keywords don't match.
+      CPL_ERROR_NULL_INPUT if @code frameset or @code frame_type is empty
 */
-int kmo_tweak_find_ifu(cpl_frameset *frameset,
-                       int ifu_nr)
+/*----------------------------------------------------------------------------*/
+int kmo_tweak_find_ifu(cpl_frameset *frameset, int ifu_nr)
 {
     int                 new_ifunr           = -1,
                         shift               = 0,
@@ -2281,33 +1946,23 @@ int kmo_tweak_find_ifu(cpl_frameset *frameset,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(frameset != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data provided!");
+        KMO_TRY_ASSURE(frameset != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data provided!");
         KMO_TRY_ASSURE((ifu_nr > 0) && (ifu_nr <= KMOS_NR_IFUS),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "ifu_nr must be from 1 to 24!");
+                CPL_ERROR_ILLEGAL_INPUT, "ifu_nr must be from 1 to 24!");
 
-        // load primary header
+        /* Load primary header */
         KMO_TRY_EXIT_IF_NULL(
             header = kmo_dfs_load_primary_header(frameset, TELLURIC));
 
-        //
-        // check if ifu_nr is a standard star
-        //
-
+        /* Check if ifu_nr is a standard star */
         // ESO PRO STDSTARi
-        KMO_TRY_EXIT_IF_NULL(
-            keywordStd = cpl_sprintf("%s%d", PRO_STD, ifu_nr));
+        KMO_TRY_EXIT_IF_NULL(keywordStd = cpl_sprintf("%s%d", PRO_STD, ifu_nr));
 
-        if (cpl_propertylist_has(header, keywordStd)) {
-                new_ifunr = ifu_nr;
-        }
+        if (cpl_propertylist_has(header, keywordStd))   new_ifunr = ifu_nr;
         cpl_free(keywordStd); keywordStd = NULL;
 
-        //
-        // check other IFUs on this detector for a standard star
-        //
+        /* Check other IFUs on this detector for a standard star */
         if (new_ifunr == -1) {
             det_nr_orig = (ifu_nr - 1)/KMOS_IFUS_PER_DETECTOR + 1;
             while (stop == 0) {
@@ -2315,10 +1970,11 @@ int kmo_tweak_find_ifu(cpl_frameset *frameset,
 
                 // look an IFU upwards
                 det_nr_shift = (ifu_nr+shift - 1)/KMOS_IFUS_PER_DETECTOR + 1;
-                if ((det_nr_shift == det_nr_orig) && (ifu_nr+shift <= KMOS_NR_IFUS)){
+                if ((det_nr_shift == det_nr_orig) && 
+                        (ifu_nr+shift <= KMOS_NR_IFUS)){
                     // ESO PRO STDSTARi
                     KMO_TRY_EXIT_IF_NULL(
-                        keywordStd = cpl_sprintf("%s%d", PRO_STD, ifu_nr+shift));
+                        keywordStd=cpl_sprintf("%s%d", PRO_STD, ifu_nr+shift));
 
                     if (cpl_propertylist_has(header, keywordStd)) {
                         new_ifunr = ifu_nr+shift;
@@ -2328,11 +1984,12 @@ int kmo_tweak_find_ifu(cpl_frameset *frameset,
 
                 // look an IFU downwards
                 if ((new_ifunr == -1) && (ifu_nr-shift >= 1)) {
-                    det_nr_shift = (ifu_nr-shift - 1)/KMOS_IFUS_PER_DETECTOR + 1;
+                    det_nr_shift=(ifu_nr-shift - 1)/KMOS_IFUS_PER_DETECTOR + 1;
                     if (det_nr_shift == det_nr_orig) {
                         // ESO PRO STDSTARi
                         KMO_TRY_EXIT_IF_NULL(
-                            keywordStd = cpl_sprintf("%s%d", PRO_STD, ifu_nr-shift));
+                            keywordStd = cpl_sprintf("%s%d", PRO_STD, 
+                                ifu_nr-shift));
 
                         if (cpl_propertylist_has(header, keywordStd)) {
                             new_ifunr = ifu_nr-shift;
@@ -2342,9 +1999,8 @@ int kmo_tweak_find_ifu(cpl_frameset *frameset,
                 }
 
                 // do we stop now?
-                if ((new_ifunr != -1) ||
-                    ((ifu_nr-shift < 0) && (ifu_nr+shift >= KMOS_IFUS_PER_DETECTOR)))
-                {
+                if ((new_ifunr != -1) || ((ifu_nr-shift < 0) && 
+                            (ifu_nr+shift >= KMOS_IFUS_PER_DETECTOR))) {
                     stop = 1;
                 }
             } // end while (stop)
@@ -2355,9 +2011,7 @@ int kmo_tweak_find_ifu(cpl_frameset *frameset,
         KMO_CATCH_MSG();
         new_ifunr = -1;
     }
-
     cpl_propertylist_delete(header); header = NULL;
-
     return new_ifunr;
 }
 
diff --git a/kmos/kmo_priv_functions.h b/kmos/kmo_priv_functions.h
index 842439d..b05ecf7 100644
--- a/kmos/kmo_priv_functions.h
+++ b/kmos/kmo_priv_functions.h
@@ -100,6 +100,10 @@ cpl_error_code      kmo_check_frameset_setup(
                                 int check_grating,
                                 int check_rotation);
 
+cpl_error_code kmo_check_oh_spec_setup(
+        cpl_frameset    *   frameset,
+        const char      *   frame_type) ;
+
 cpl_error_code      kmo_check_frame_setup(
                                 cpl_frameset *frameset,
                                 const char *frame_type1,
diff --git a/kmos/kmo_priv_make_image.c b/kmos/kmo_priv_make_image.c
index 3f3f685..37933d0 100644
--- a/kmos/kmo_priv_make_image.c
+++ b/kmos/kmo_priv_make_image.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_make_image.c,v 1.1.1.1 2012-01-18 09:31:59 yjung Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: yjung $
- * $Date: 2012-01-18 09:31:59 $
- * $Revision: 1.1.1.1 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -47,52 +39,51 @@
 
 /*----------------------------------------------------------------------------*/
 /**
-    @defgroup kmos_priv_make_image     Helper functions for recipe kmo_make_image.
-
-    @{
+  @defgroup kmos_priv_make_image  Helper functions for recipe kmo_make_image.
  */
 /*----------------------------------------------------------------------------*/
 
-/**
-    @brief
-        Identifies spectral slices of a cube to collapse.
-
-    This function identifies spectral slices of a cube to collapse. Therefore it
-    takes the wavelength values and data of the OH-spectrum, creates the
-    wavelength values of the IFU and compares them (i.e. checks if they are
-    overlapping), it takes a maximum threshold and a range-vector created with
-    @c kmo_identify_ranges . The oh-spectrum is interpolated to match the
-    spectrum of the IFU.
-
-    @param spec_data_in   The data of the OH-spectrum.
-    @param spec_lambda_in The wavelength values of the OH-spectrum.
-    @param ranges         An even sized vector defining the wavelength ranges
-                          (optional).
-    @param threshold      The maximum threshold (if < 0 it will be ignored).
-    @param ifu_crpix      Reference pixel position (CRPIX3 from FITS-header).
-    @param ifu_crval      Value of reference pixel (CRVAL3 from FITS-header).
-    @param ifu_cdelt      Delta between pixels (CDELT3 from FITS-header).
-    @param size_ifu       The number of spectral slices of the IFU.
+/**@{*/
 
-    @return A vector in case of success, NULL otherwise. The vector is of the
-            same size as @c spec_data_in and contains ones for valid slices and
-            zeros for invalid slices.
-
-    The returned vector has to be deallocated with cpl_vector_delete().
-
-    Possible cpl_error_code set in this function:
-    @li CPL_ERROR_NULL_INPUT    if any input pointer is NULL
-    @li CPL_ERROR_ILLEGAL_INPUT if @c spec_data_in and @c spec_lambda_in don't
-                                have the same size
+/*----------------------------------------------------------------------------*/
+/**
+  @brief Identifies spectral slices of a cube to collapse.
+  @param spec_data_in   The data of the OH-spectrum 
+  @param spec_lambda_in The wavelength values of the OH-spectrum 
+  @param ranges         The wavelength ranges or NULL
+  @param threshold      The maximum threshold (if < 0 it will be ignored).
+  @param ifu_crpix      Reference pixel position (CRPIX3 from FITS-header).
+  @param ifu_crval      Value of reference pixel (CRVAL3 from FITS-header).
+  @param ifu_cdelt      Delta between pixels (CDELT3 from FITS-header).
+  @param size_ifu       The number of spectral slices of the IFU.
+  @return A vector in case of success, NULL otherwise. The vector is of the
+          same size as @c spec_data_in and contains 1 for valid slices and
+          0 for invalid slices.
+    
+  This function identifies spectral slices of a cube to collapse. 
+  For that it uses the provided OH spectrum with a threshold AND an optional  
+  number of wavelength ranges. 
+  
+  The wavelength values of the IFU are created and compared to the OH ones.
+  A passed maximum threshold is used to select or not the slice. The OH
+  intensity is compared to the threshold.
+  The oh-spectrum is interpolated to match the spectrum of the IFU.
+  The returned vector has to be deallocated with cpl_vector_delete().
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any input pointer is NULL
+  @li CPL_ERROR_ILLEGAL_INPUT if @c spec_data_in and @c spec_lambda_in don't
+                              have the same size
 */
-cpl_vector* kmo_identify_slices_with_oh(cpl_vector *spec_data_in,
-                                        cpl_vector *spec_lambda_in,
-                                        cpl_vector *ranges,
-                                        double threshold,
-                                        int ifu_crpix,
-                                        double ifu_crval,
-                                        double ifu_cdelt,
-                                        int size_ifu)
+/*----------------------------------------------------------------------------*/
+cpl_vector * kmo_identify_slices_with_oh(
+        cpl_vector  *   spec_data_in,
+        cpl_vector  *   spec_lambda_in,
+        cpl_vector  *   ranges,
+        double          threshold,
+        double          ifu_crpix,
+        double          ifu_crval,
+        double          ifu_cdelt,
+        int             size_ifu)
 {
     cpl_vector      *slices           = NULL,
                     *spec_data_out    = NULL,
@@ -108,44 +99,31 @@ cpl_vector* kmo_identify_slices_with_oh(cpl_vector *spec_data_in,
     int             start_index       = 0,
                     stop_index        = 0,
                     i                 = 0,
-            //        found             = FALSE,
                     size_spec         = 0,
                     ind               = 0;
 
     KMO_TRY
     {
         /* Check inputs */
-        KMO_TRY_ASSURE((spec_data_in != NULL) &&
-                       (spec_lambda_in != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((spec_data_in != NULL) && (spec_lambda_in != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         size_spec = cpl_vector_get_size(spec_lambda_in);
-
         KMO_TRY_ASSURE(cpl_vector_get_size(spec_data_in) == size_spec,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Lambda- and data-vector of OH-line have "
-                       "different sizes!");
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Lambda- and data-vector of OH-line have different sizes!");
 
         /* create lambda-vector for IFU */
-        KMO_TRY_EXIT_IF_NULL(
-            ifu_lambda_in = kmo_create_lambda_vec(size_ifu,
-                                                  ifu_crpix,
-                                                  ifu_crval,
-                                                  ifu_cdelt));
-
-        /* check if lambdas of IFU lie outside the range of lambdas of spec
-           (it is assumed that values are ascending, but since the vectors have
-           been created with kmo_create_lambda_vec(), they are!) */
+        KMO_TRY_EXIT_IF_NULL(ifu_lambda_in = kmo_create_lambda_vec(size_ifu, 
+                    ifu_crpix, ifu_crval, ifu_cdelt));
+        
+        /* Keep only the part of ifu_lambda_in that is on the OH spec range */
         start_index = 0;
         stop_index = size_ifu - 1;
-
         min_lambda = cpl_vector_get(spec_lambda_in, 0);
         max_lambda = cpl_vector_get(spec_lambda_in, size_spec - 1);
-
         if ((cpl_vector_get(ifu_lambda_in, 0) <= min_lambda) ||
             (cpl_vector_get(ifu_lambda_in, size_ifu - 1) >= max_lambda)) {
-
             data = cpl_vector_get_data(ifu_lambda_in);
             for (i = 0; i < size_ifu; i++) {
                 if (min_lambda <= data[i]) {
@@ -159,53 +137,35 @@ cpl_vector* kmo_identify_slices_with_oh(cpl_vector *spec_data_in,
                     break;
                 }
             }
-
-            slices = cpl_vector_extract(ifu_lambda_in,
-                                               start_index,
-                                               stop_index, 1);
+            slices=cpl_vector_extract(ifu_lambda_in, start_index, stop_index,1);
             cpl_vector_delete(ifu_lambda_in);
             ifu_lambda_in = slices; slices = NULL;
         }
 
-        /* interpolate oh-line to match lambdas of IFU */
+        /* interpolate oh-line to match lambdas of IFU -> spec_data_out */
         KMO_TRY_EXIT_IF_NULL(
             spec_data_out = cpl_vector_new(stop_index - start_index + 1));
         KMO_TRY_EXIT_IF_NULL(
-            bivec_ref = cpl_bivector_wrap_vectors(spec_lambda_in,
-                                                  spec_data_in));
+            bivec_ref = cpl_bivector_wrap_vectors(spec_lambda_in,spec_data_in));
         KMO_TRY_EXIT_IF_NULL(
-            bivec_out = cpl_bivector_wrap_vectors(ifu_lambda_in,
-                                                  spec_data_out));
-
+            bivec_out = cpl_bivector_wrap_vectors(ifu_lambda_in,spec_data_out));
         KMO_TRY_EXIT_IF_ERROR(
             cpl_bivector_interpolate_linear(bivec_out, bivec_ref));
-
         cpl_bivector_unwrap_vectors(bivec_ref);
         cpl_bivector_unwrap_vectors(bivec_out);
 
-        /* allocate output vector */
-        KMO_TRY_EXIT_IF_NULL(
-            slices = cpl_vector_new(size_ifu));
-
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_vector_fill(slices, 0.0));
-
-        /* populate output vector with ones and zeroes
-           one: slice will be taken into account when collapsing the cube
-           zero: slice will be ignored */
-        KMO_TRY_EXIT_IF_NULL(
-            data = cpl_vector_get_data(slices));
+        /* allocate output vector with 0s */
+        KMO_TRY_EXIT_IF_NULL(slices = cpl_vector_new(size_ifu));
+        KMO_TRY_EXIT_IF_ERROR(cpl_vector_fill(slices, 0.0));
 
+        /* Identify wished Slices and set them to 1 */
+        KMO_TRY_EXIT_IF_NULL(data = cpl_vector_get_data(slices));
         ind = 0;
         for (i = start_index; i <= stop_index; i++) {
-            if ((ranges == NULL) ||
-                kmo_is_in_range(ranges, ifu_lambda_in, ind))
-            {
-                if (((threshold > 0.0) &&
-                      kmo_priv_is_below_threshold(threshold,
-                                                  spec_data_out, ind)) ||
-                    (threshold < 0.0))
-                {
+            if ((ranges == NULL) || kmo_is_in_range(ranges,ifu_lambda_in,ind)) {
+                if (threshold < 0.0) {
+                    data[i] = 1;
+                } else if (threshold > cpl_vector_get(spec_data_out, ind)) {
                     data[i] = 1;
                 }
             }
@@ -217,65 +177,9 @@ cpl_vector* kmo_identify_slices_with_oh(cpl_vector *spec_data_in,
         KMO_CATCH_MSG();
         cpl_vector_delete(slices); slices = NULL;
     }
-
     cpl_vector_delete(spec_data_out); spec_data_out = NULL;
     cpl_vector_delete(ifu_lambda_in); ifu_lambda_in = NULL;
-
     return slices;
 }
 
-/**
-    @brief
-        Checks if a value in a vector is below a certain threshold.
-
-    This function checks if a value at a specified position in @c spec_data_out
-    is below @c threshold.
-
-    @param threshold     The threshold value.
-    @param spec_data_out The data-vector of a certain IFU.
-    @param index         The index to the value in @c spec_data_out to examine.
-                         Starts at zero.
-
-    @return 1 if value is below threshold, 0 otherwise.
-
-    Possible cpl_error_code set in this function:
-
-    @c CPL_ERROR_NULL_INPUT    Not enough inputs defined
-    @c CPL_ERROR_ILLEGAL_INPUT index is larger or smaller than the size of
-                               @c ifu_lambda_in
-*/
-int kmo_priv_is_below_threshold(double threshold,
-                                cpl_vector *spec_data_out,
-                                int index)
-{
-    double  val     = 0.0;
-    int ret_val = 0;
-
-    KMO_TRY
-    {
-        /* Check inputs */
-        KMO_TRY_ASSURE(spec_data_out != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        KMO_TRY_ASSURE((index >= 0) &&
-                       (index < cpl_vector_get_size(spec_data_out)),
-                       CPL_ERROR_NULL_INPUT,
-                       "Index < 0 or larger than vector!");
-
-        val = cpl_vector_get(spec_data_out, index);
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        if (threshold > val) {
-            ret_val = 1;
-        }
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-        ret_val = 0;
-    }
-    return ret_val;
-}
-
 /** @} */
diff --git a/kmos/kmo_priv_make_image.h b/kmos/kmo_priv_make_image.h
index 17558ec..2414994 100644
--- a/kmos/kmo_priv_make_image.h
+++ b/kmos/kmo_priv_make_image.h
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_make_image.h,v 1.1.1.1 2012-01-18 09:31:59 yjung Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: yjung $
- * $Date: 2012-01-18 09:31:59 $
- * $Revision: 1.1.1.1 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifndef KMOS_PRIV_MAKE_IMAGE_H
 #define KMOS_PRIV_MAKE_IMAGE_H
 
@@ -35,20 +27,17 @@
 #include <cpl.h>
 
 /*------------------------------------------------------------------------------
- *                        Prototypes
+ *                              Prototypes
  *----------------------------------------------------------------------------*/
 
-cpl_vector* kmo_identify_slices_with_oh(cpl_vector *spec_data_in,
-                                   cpl_vector *spec_lambda_in,
-                                   cpl_vector *ranges,
-                                   double threshold,
-                                   int ifu_crpix,
-                                   double ifu_crval,
-                                   double ifu_cdelt,
-                                   int size_ifu);
-
-int kmo_priv_is_below_threshold(double threshold,
-                                   cpl_vector *spec_data_out,
-                                   int index);
+cpl_vector * kmo_identify_slices_with_oh(
+        cpl_vector  *   spec_data_in,
+        cpl_vector  *   spec_lambda_in,
+        cpl_vector  *   ranges,
+        double          threshold,
+        double          ifu_crpix,
+        double          ifu_crval,
+        double          ifu_cdelt,
+        int             size_ifu) ;
 
 #endif
diff --git a/kmos/kmo_priv_sky_tweak.c b/kmos/kmo_priv_sky_tweak.c
index a7c6762..74008c7 100644
--- a/kmos/kmo_priv_sky_tweak.c
+++ b/kmos/kmo_priv_sky_tweak.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_sky_tweak.c,v 1.12 2013-09-13 09:10:28 erw Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: erw $
- * $Date: 2013-09-13 09:10:28 $
- * $Revision: 1.12 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -48,6 +40,10 @@
 #include "kmo_priv_lcorr.h"
 #include "kmo_utils.h"
 
+/*-----------------------------------------------------------------------------
+ *                              Define
+ *----------------------------------------------------------------------------*/
+
 #define nrerror printf
 #define TINY 1.0e-10
 #define NMAX 5000
@@ -57,13 +53,17 @@
                        psum[j]=sum;}
 #define SWAP(a,b) {swap=(a);(a)=(b);(b)=swap;}
 
+/*-----------------------------------------------------------------------------
+ *                          Functions
+ *----------------------------------------------------------------------------*/
+
 void amoeba(double **p, double y[], int ndim, double ftol,
         double (*funk)(double []), int *nfunk)
 {
         double amotry(double **p, double y[], double psum[], int ndim,
                 double (*funk)(double []), int ihi, double fac);
         int i,ihi,ilo,inhi,j,mpts=ndim+1;
-        double rtol, sum, swap, ysave, ytry, *psum = NULL;
+        double rtol, sum, swap, ysave, ytry, *psum = NULL, d;
 
         psum=vector(ndim+1);
         *nfunk=0;
@@ -78,7 +78,12 @@ void amoeba(double **p, double y[], int ndim, double ftol,
                                 ihi=i;
                         } else if (y[i] > y[inhi] && i != ihi) inhi=i;
                 }
-                rtol=2.0*fabs(y[ihi]-y[ilo])/(fabs(y[ihi])+fabs(y[ilo])+TINY);
+                d = fabs(y[ihi])+fabs(y[ilo]);
+                if (d == 0.0) {
+                    rtol = ftol / 2. ; //succeeds next if statement -> breaks loop
+                } else {
+                    rtol=2.0*fabs(y[ihi]-y[ilo])/d;
+                }
                 if (rtol < ftol) {
                         SWAP(y[1],y[ilo])
                         for (i=1;i<=ndim;i++) SWAP(p[1][i],p[ilo][i])
@@ -193,7 +198,7 @@ double fitbkd(double *p) {
             max = tmp[i];
         }
     }
-
+    p[2]=fabs(p[2]);  // make sure scaling factor is positive
     if (max > 0.) {
         for (i=0; i<spectrum_size; i++) {
             thermal_background[i] = p[1] + tmp[i] / max * fabs(p[2]);
@@ -289,7 +294,7 @@ cpl_bivector* kmo_get_thermal_background(cpl_bivector* spectrum, int remove_it)
         p[1][2] = p_init[2];
         p[1][3] = p_init[3];
 
-        for (loop=0; loop<5; loop++) {
+        for (loop=0; loop<20; loop++) {
             for (i=2; i<nsimplex+1; i++) {
                 for (j=1; j<ndim+1; j++) {
                     p[i][j] = p[1][j];
@@ -315,7 +320,7 @@ cpl_bivector* kmo_get_thermal_background(cpl_bivector* spectrum, int remove_it)
                     tmp_v =  cpl_vector_duplicate(spectrum_v));
             KMO_TRY_EXIT_IF_ERROR(
                     cpl_vector_subtract(tmp_v, thermal_v));
-            limit = cpl_vector_get_median(tmp_v) + (2. - loop * .25) *  cpl_vector_get_stdev(tmp_v);
+            limit = cpl_vector_get_median(tmp_v) + 2.  *  cpl_vector_get_stdev(tmp_v);
             cpl_vector_delete(tmp_v);
             cpl_vector_unwrap(spectrum_v);
             cpl_vector_unwrap(thermal_v);
@@ -323,11 +328,7 @@ cpl_bivector* kmo_get_thermal_background(cpl_bivector* spectrum, int remove_it)
             min = +1.e30;
             new_size = 0;
             for (i=0; i<spectrum_size; i++) {
-                if (loop < 2) {
-                    diff = fabs(spectrum_value[i] - thermal_background[i]);
-                } else{
                     diff = spectrum_value[i] - thermal_background[i];
-                }
                 if (diff < limit) {
                     spectrum_lambda[new_size] = spectrum_lambda[i];
                     spectrum_value[new_size] = spectrum_value[i];
@@ -637,16 +638,18 @@ cpl_bivector* kmo_priv_sky_tweak_correct_vibrational_trans(
 
     cpl_bivector *result = NULL;
 
-    const double lambda_boundaries[] = {1.025, 1.067,  1.125,  1.196,  1.252, 1.289,  1.400,
+    const double lambda_boundaries[] = {0.780, 0.824, 0.873, 0.926, 0.964, 1.014,
+                                  1.067,  1.125,  1.196,  1.252, 1.289,  1.400,
                                   1.472, 1.5543, 1.6356, 1.7253, 1.840, 1.9570, 2.095,
                                   2.30, 2.460};
     const int nr_boundaries = sizeof(lambda_boundaries) / sizeof(double);
-    const char *labels[] = {"4-1 transitions", "5-2 transitions", "6-3 transitions",
+    const char *labels[] = { "","","","","",
+                            "4-1 transitions", "5-2 transitions", "6-3 transitions",
                             "7-4 transitions", " 02 transitions", "8-5 transitions",
                             "2-0 transitions", "3-1 transitions", "4-2 transitions",
                             "5-3 transitions", "6-4 transitions", "7-5 transitions",
                             "8-6 transitions", "9-7 transitions", "final bit"};
-    double scalings[nr_boundaries];
+    double scalings[nr_boundaries]; 
 
     int ix,
         il,
@@ -725,6 +728,9 @@ cpl_bivector* kmo_priv_sky_tweak_correct_vibrational_trans(
         sprintf(dbg_message, "> ");
         nr_transitions = 0;
         for (ix = 0; ix<nr_boundaries-1; ix++) {
+            // do following free in case continue-statement has been reached in if-staement below
+            if (tmp4_v != NULL) { cpl_vector_delete(tmp4_v);  tmp4_v = NULL; }
+
             tmp_dbg_message = cpl_sprintf("Checking %2d: %s", ix, labels[ix]);
             strcat(dbg_message, tmp_dbg_message);
             cpl_free(tmp_dbg_message); tmp_dbg_message = NULL;
diff --git a/kmos/kmo_priv_wave_cal.c b/kmos/kmo_priv_wave_cal.c
index 19ec268..90ca7ba 100644
--- a/kmos/kmo_priv_wave_cal.c
+++ b/kmos/kmo_priv_wave_cal.c
@@ -63,19 +63,33 @@
 #include "kmo_priv_functions.h"
 #include "kmo_debug.h"
 
+int dbgplot = FALSE;
+
+/*-----------------------------------------------------------------------------
+                                Functions prototypes
+ -----------------------------------------------------------------------------*/
+
 /*----------------------------------------------------------------------------*/
 /**
     @defgroup kmos_priv_wave_cal     Helper functions for kmo_wave_cal
-
-    @{
  */
 /*----------------------------------------------------------------------------*/
 
-int dbgplot = FALSE;
-//int dbgplot = TRUE;
+/**@{*/
 
-void kmo_wave_write_data_vector(const char *filename, const cpl_vector *vector, const char *extname) {
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+void kmo_wave_write_data_vector(
 
+        const char          *   filename, 
+        const cpl_vector    *   vector, 
+        const char          *   extname) 
+{
     cpl_propertylist *pl = cpl_propertylist_new();
     cpl_propertylist_update_string(pl, "EXTNAME", extname);
     cpl_error_code error = cpl_vector_save(vector,
@@ -85,9 +99,19 @@ void kmo_wave_write_data_vector(const char *filename, const cpl_vector *vector,
     }
 }
 
-void plot_estimated_lines(cpl_vector *spectrum, const cpl_bivector *catalog,
-        cpl_vector *positions, cpl_vector *lambdas) {
-
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+void plot_estimated_lines(
+        cpl_vector          *   spectrum, 
+        const cpl_bivector  *   catalog,
+        cpl_vector          *   positions, 
+        cpl_vector          *   lambdas) 
+{
     int catalog_size = cpl_bivector_get_size(catalog);
     cpl_bivector *catalog_lines = cpl_bivector_new(3 * catalog_size);
     double *xcl = cpl_bivector_get_x_data(catalog_lines);
@@ -115,9 +139,10 @@ void plot_estimated_lines(cpl_vector *spectrum, const cpl_bivector *catalog,
 
     cpl_polynomial *poly = cpl_polynomial_new(1);
     double *px = cpl_vector_get_data((cpl_vector*)positions);
-    cpl_matrix *x_matrix = cpl_matrix_wrap(1, cpl_vector_get_size(positions), px);
+    cpl_matrix *x_matrix = 
+        cpl_matrix_wrap(1, cpl_vector_get_size(positions), px);
     const cpl_boolean   sampsym     = CPL_FALSE;
-    cpl_size    mindeg1d    = 0,    //1,
+    cpl_size    mindeg1d    = 0, 
                 maxdeg1d    = degree;
     cpl_polynomial_fit(poly,
                        x_matrix,
@@ -156,10 +181,8 @@ void plot_estimated_lines(cpl_vector *spectrum, const cpl_bivector *catalog,
         yll[ix*3+0] = 0.;
         yll[ix*3+1] = yc[lx] * ratio;
         yll[ix*3+2] = 0.;
-
     }
 
-
 #define NBIV1 2
     const char *options1[NBIV1] = {
             "w l t 'catalog'",
@@ -177,12 +200,22 @@ void plot_estimated_lines(cpl_vector *spectrum, const cpl_bivector *catalog,
     bivectors2[0] = line_list;
     bivectors2[1] = spec_p;
     cpl_plot_bivectors("",options2,"",(const cpl_bivector**)bivectors2, NBIV2);
-
 }
 
-void plot_best_fit(const cpl_vector *spectrum, const cpl_bivector *catalog,
-        cpl_polynomial *guess_poly, cpl_polynomial *best_poly, const cpl_polynomial *init_poly) {
-
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+void plot_best_fit(
+        const cpl_vector        *   spectrum, 
+        const cpl_bivector      *   catalog,
+        cpl_polynomial          *   guess_poly, 
+        cpl_polynomial          *   best_poly, 
+        const cpl_polynomial    *   init_poly) 
+{
     int catalog_size = cpl_bivector_get_size(catalog);
     cpl_bivector *catalog_lines = cpl_bivector_new(3 * catalog_size);
     double *xcl = cpl_bivector_get_x_data(catalog_lines);
@@ -207,14 +240,16 @@ void plot_best_fit(const cpl_vector *spectrum, const cpl_bivector *catalog,
     cpl_vector *init_xwave = cpl_vector_duplicate(spectrum);
 
     cpl_vector_fill_polynomial(guess_xwave,guess_poly,0.,1.);
-    cpl_bivector *guess = cpl_bivector_wrap_vectors(guess_xwave, (cpl_vector*)spectrum);
+    cpl_bivector *guess = cpl_bivector_wrap_vectors(guess_xwave, 
+            (cpl_vector*)spectrum);
 
     cpl_vector_fill_polynomial(best_xwave,best_poly,0.,1.);
-    cpl_bivector *best = cpl_bivector_wrap_vectors(best_xwave, (cpl_vector*)spectrum);
+    cpl_bivector *best = cpl_bivector_wrap_vectors(best_xwave, 
+            (cpl_vector*)spectrum);
 
     cpl_vector_fill_polynomial(init_xwave,init_poly,0.,1.);
-    cpl_bivector *init = cpl_bivector_wrap_vectors(init_xwave, (cpl_vector*)spectrum);
-
+    cpl_bivector *init = cpl_bivector_wrap_vectors(init_xwave, 
+            (cpl_vector*)spectrum);
 
 #define NBIV 4
     const char *options[NBIV] = {
@@ -228,13 +263,19 @@ void plot_best_fit(const cpl_vector *spectrum, const cpl_bivector *catalog,
     bivectors[2] = best;
     bivectors[3] = init;
     cpl_plot_bivectors("",options,"",(const cpl_bivector**)bivectors, NBIV);
-
 }
 
-void kmo_find_lines_test (cpl_vector *spectrum, cpl_bivector * catalog/*,
-        cpl_vector **positions,
-        cpl_vector **lambdas*/) {
-
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+void kmo_find_lines_test(
+        cpl_vector      *   spectrum, 
+        cpl_bivector    *   catalog) 
+{
     int loop = 1;
     int plot = 1;
     int degree = 2;
@@ -247,10 +288,6 @@ void kmo_find_lines_test (cpl_vector *spectrum, cpl_bivector * catalog/*,
     cpl_table *wlres;
     cpl_vector *xcorrs;
     double wl_error_fill = .1;
-//    double coeffs[4] = {1.95090384365, 0.000264104234528,
-//            -1.3379515120037174E-8, 3.081911523618767E-12};
-//    double coeffs[4] = {1.94479301822645,0.000248990234102953,-1.23913455301759E-08,2.76262973149598E-12};
-//    double coeffs[4] = {1.43475, 0.000209167, -3.11131e-09, 2.85747e-13};
     double coeffs[4] = {1.41497, 0.000267623, -2.43218e-09, -1.90498e-13};
      cpl_polynomial *best_poly = NULL;
     cpl_polynomial *guess_poly;
@@ -288,7 +325,6 @@ void kmo_find_lines_test (cpl_vector *spectrum, cpl_bivector * catalog/*,
             break;
         }
     }
-//    cpl_vector *sub_spectrum = cpl_vector_extract(spectrum, start_index, end_index, 1);
 
     // trim catalog according sub_spectrum size
     double start_wavelength = start_index * coeffs[1] + coeffs[0];
@@ -305,10 +341,12 @@ void kmo_find_lines_test (cpl_vector *spectrum, cpl_bivector * catalog/*,
         }
     }
     start_ix++;
-    cpl_vector *sub_catalog_x = cpl_vector_extract(cpl_bivector_get_x(catalog),start_ix,end_ix,1);
-    cpl_vector *sub_catalog_y = cpl_vector_extract(cpl_bivector_get_y(catalog),start_ix,end_ix,1);
-    cpl_bivector *sub_catalog = cpl_bivector_wrap_vectors(sub_catalog_x, sub_catalog_y);
-
+    cpl_vector *sub_catalog_x = 
+        cpl_vector_extract(cpl_bivector_get_x(catalog),start_ix,end_ix,1);
+    cpl_vector *sub_catalog_y = 
+        cpl_vector_extract(cpl_bivector_get_y(catalog),start_ix,end_ix,1);
+    cpl_bivector *sub_catalog = 
+        cpl_bivector_wrap_vectors(sub_catalog_x, sub_catalog_y);
 
     while (loop) {
         int no_coeffs = sizeof(coeffs)/sizeof(coeffs[0]);
@@ -323,7 +361,7 @@ void kmo_find_lines_test (cpl_vector *spectrum, cpl_bivector * catalog/*,
         } else {
             guess_poly = cpl_polynomial_duplicate(best_poly);
         }
-        for (dx = cpl_polynomial_get_degree(guess_poly)+1; dx < degree+1; dx++ ) {
+        for (dx=cpl_polynomial_get_degree(guess_poly)+1; dx < degree+1; dx++ ) {
             pow[0] = dx;
             if (dx < no_coeffs) {
                 cpl_polynomial_set_coeff(guess_poly, pow, coeffs[dx]);
@@ -339,36 +377,38 @@ void kmo_find_lines_test (cpl_vector *spectrum, cpl_bivector * catalog/*,
         printf("Cross correlation: %g\n",xc);
         cpl_polynomial_dump(guess_poly,stdout);
         cpl_polynomial_dump(best_poly,stdout);
-        //        if (xcorrs != NULL) {
-        //            cpl_vector_dump(xcorrs,stdout);
-        //        }
-
-
-        // support plotting
-
         if (plot) {
             plot_best_fit(spectrum, catalog, guess_poly, best_poly, init_poly);
-//            int dummy=1;
         }
     }
-
     return;
 }
 
-int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *catalog,
-        const cpl_polynomial *init_poly,
-        cpl_polynomial **best_poly_ptr,
-        int *final_degree,
-        double *final_xc) {
-
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+int kmo_best_wave_cal_poly(
+        const cpl_vector        *   spectrum, 
+        const cpl_bivector      *   catalog,
+        const cpl_polynomial    *   init_poly,
+        cpl_polynomial          **  best_poly_ptr,
+        int                     *   final_degree,
+        double                  *   final_xc) 
+{
     int converged = 0;
-    int plot = 0; // bit 0 -> plot initial fit, bit 1 -> plot final fit, bit 2 -> plot interm. fits
+    int plot = 0; 
+    /* bit 0 -> plot initial fit */
+    /* bit 1 -> plot final fit */
+    /* bit 2 -> plot interm. fits */
     int degree;
     int nsamples;
     int max_loops;
     int nr_trials;
     int nr_loops;
-//    int pow[1];
     double c_wl_error;
     double fwhm = 2;
     double slitw = 2.;
@@ -377,7 +417,6 @@ int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *cata
 
     cpl_table *wlres;
     cpl_vector *xcorrs;
-//    cpl_vector *wl_error;
     cpl_polynomial *guess_poly;
     cpl_polynomial *best_poly;
 
@@ -388,14 +427,6 @@ int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *cata
         double wl_error;
     };
     struct best_fit_pars_struct best_fit_pars[] = {
-//                {2, 10, 1, 0.2},
-//                {2, 41, 2, 0.1},
-//                {1, 101, 1, 0.05},
-//                {2, 21, 1, 0.01},
-//                {2, 21, 1, 0.001},
-//                {2, 11, 3, 0.01},
-//            {3, 11, 1, 0.02},
-//            {3, 11, 1, 0.005},
             {3, 10, 1 , 0.02},
             {3, 10, 1 , 0.004},
             {4, 4, 1 , 0.004},
@@ -413,18 +444,13 @@ int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *cata
         cpl_vector *wl_error = cpl_vector_new(degree+1);
         cpl_vector_fill (wl_error, c_wl_error);
 
-//            int no_coeffs = sizeof(coeffs)/sizeof(coeffs[0]);
         guess_poly = cpl_polynomial_duplicate(best_poly);
         cpl_polynomial_delete(best_poly);
 
-//            printf("Cross correlation: IFU %d, degree %d, nsamples %d, wl_error %5f -->",
-//                    global_ifu_nr, degree, nsamples, best_fit_pars[lx].wl_error);
-
         best_poly = irplib_wlxcorr_best_poly(
                 spectrum, catalog, degree, guess_poly, wl_error,
                 nsamples, slitw, fwhm, &xc, &wlres, &xcorrs);
 
-//            printf(" %5f", xc);
         if ((plot & 1) && (lx == 0)) {
             plot_best_fit(spectrum, catalog, guess_poly, best_poly, init_poly);
         }
@@ -436,7 +462,7 @@ int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *cata
         }
 
         previous_xc = xc;
-        for (nr_trials=1; nr_trials<max_loops; nr_trials++) { //try it not more than x times
+        for (nr_trials=1; nr_trials<max_loops; nr_trials++) { 
             previous_xc = xc;
             cpl_polynomial_delete(guess_poly);
             guess_poly = best_poly;
@@ -444,9 +470,9 @@ int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *cata
             best_poly = irplib_wlxcorr_best_poly(
                     spectrum, catalog, degree, guess_poly, wl_error,
                     nsamples, slitw, fwhm, &xc, &wlres, &xcorrs);
-//                printf(" %5f",xc);
             if (plot & 4) {
-                plot_best_fit(spectrum, catalog, guess_poly, best_poly, init_poly);
+                plot_best_fit(spectrum, catalog, guess_poly, best_poly, 
+                        init_poly);
             }
 
             if (best_poly == NULL) {
@@ -456,11 +482,10 @@ int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *cata
                 converged = 1;
             }
 
-            if (fabs((xc-previous_xc)/previous_xc) < 0.005) { //break if improvement is less
-                break;                                      // than .5%
+            if (fabs((xc-previous_xc)/previous_xc) < 0.005) {
+                break;              
             }
         }
-
         if (!converged) {
             break;
         }
@@ -469,8 +494,6 @@ int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *cata
     if (plot & 2) {
         plot_best_fit(spectrum, catalog, guess_poly, best_poly, init_poly);
     }
-
-
     if (converged) {
         *best_poly_ptr = best_poly;
         cpl_polynomial_delete(guess_poly);
@@ -478,23 +501,27 @@ int kmo_best_wave_cal_poly (const cpl_vector *spectrum, const cpl_bivector *cata
         *best_poly_ptr = guess_poly;
         cpl_polynomial_delete(best_poly);
    }
-
     *final_degree = degree;
     *final_xc = xc;
     return converged;
 }
 
-/*
- * Extract part of array and return it wrapped in a cpl_vector
- * Part is specified by an offset (start index) and a range (number of elements
- * Offset must be smaller than array size, range must be larger than 0
- * The functions truncates the range if it is partly outside the arry.
- */
-cpl_vector *kmo_wave_wrap_array_part (
-        double *array,
-        int size,
-        int offset,
-        int range)
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+  Extract part of array and return it wrapped in a cpl_vector
+  Part is specified by an offset (start index) and a range (number of elements
+  Offset must be smaller than array size, range must be larger than 0
+  The functions truncates the range if it is partly outside the arry.
+*/
+/*----------------------------------------------------------------------------*/
+cpl_vector * kmo_wave_wrap_array_part (
+        double  *   array,
+        int         size,
+        int         offset,
+        int         range)
 {
     if ((range <= 0) || (offset >= size)) {
         range = 0;
@@ -507,7 +534,6 @@ cpl_vector *kmo_wave_wrap_array_part (
             range = size - offset + 1;
         }
     }
-
     if (range <= 0) {
         return NULL;
     } else {
@@ -515,14 +541,22 @@ cpl_vector *kmo_wave_wrap_array_part (
     }
 }
 
-void kmo_find_lines (const char *filter_id,
-        int global_ifu_nr,
-        int slitlet_nr,
-        cpl_vector *spectrum,
-        const cpl_bivector *catalog,
-        const cpl_table *reflines,
-        cpl_vector **positions,
-        cpl_vector **lambdas)
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+void kmo_find_lines(
+        const char          *   filter_id,
+        int                     global_ifu_nr,
+        int                     slitlet_nr,
+        cpl_vector          *   spectrum,
+        const cpl_bivector  *   catalog,
+        const cpl_table     *   reflines,
+        cpl_vector          **  positions,
+        cpl_vector          **  lambdas)
 {
     int         debug       = 0,
                 n_rl        = 0,
@@ -559,10 +593,13 @@ void kmo_find_lines (const char *filter_id,
         strncat(filter_regex, "^",1);
         strncat(filter_regex,filter_id,2);
         strncat(filter_regex, "$",1);
-        int row_cnt = cpl_table_and_selected_string((cpl_table*)reflines, "FILTER", CPL_EQUAL_TO, filter_regex );
-        row_cnt = cpl_table_and_selected_int((cpl_table*)reflines, "DETECTOR", CPL_EQUAL_TO, detector);
+        int row_cnt = cpl_table_and_selected_string((cpl_table*)reflines, 
+                "FILTER", CPL_EQUAL_TO, filter_regex );
+        row_cnt = cpl_table_and_selected_int((cpl_table*)reflines, "DETECTOR", 
+                CPL_EQUAL_TO, detector);
         if (row_cnt <= 0) {
-            cpl_msg_debug(__func__,"found no entries in reference line table for band %s and detector %d",
+            cpl_msg_debug(__func__,
+                    "found no entries in reference line table for band %s and detector %d",
                     filter_id, global_ifu_nr);
             KMO_TRY_SET_ERROR(CPL_ERROR_DATA_NOT_FOUND);
             KMO_TRY_EXIT();
@@ -591,10 +628,9 @@ void kmo_find_lines (const char *filter_id,
         KMO_TRY_EXIT_IF_NULL(
                 rl_pos = cpl_malloc(sizeof(double) * n_rl));
 
-        //
         // first match reference line with absolute positions
-        //
-        if (debug) printf("RP: %2d: %2d: (%d)  ", global_ifu_nr, slitlet_nr, n_rl );
+        if (debug) printf("RP: %2d: %2d: (%d)  ", 
+                global_ifu_nr, slitlet_nr, n_rl );
         for (i = 0; i < n_rl; i++) {
             if (rl_ref[i] == -1) {
                 double x0, sigma, area, goffset;
@@ -652,9 +688,7 @@ void kmo_find_lines (const char *filter_id,
                 cpl_vector_delete(mx);
            }
         }
-        //
         // next match reference line with relative positions
-        //
         for (i = 0; i < n_rl; i++) {
             if (rl_ref[i] != -1) {
                 double x0, sigma, area, goffset;
@@ -666,7 +700,8 @@ void kmo_find_lines (const char *filter_id,
 
                 if (rl_pos[rl_ref[i]] != -1) {
                     offset = rl_pos[rl_ref[i]] + rl_offset[i];
-                    yv1 = kmo_wave_wrap_array_part(trace, n_trace, offset, range);
+                    yv1 = kmo_wave_wrap_array_part(trace, n_trace, offset, 
+                            range);
                     if (yv1 == NULL) {
                         rl_pos[i] = -1;
                         cpl_msg_debug(__func__,
@@ -679,30 +714,31 @@ void kmo_find_lines (const char *filter_id,
                     if (max < rl_cut[i]) {
                         cpl_msg_debug(__func__,
                                 "peak value %f less than cut level %d for reference line %f for IFU %d slitlet %d in band %s",
-                                max, rl_cut[i], rl_wl[i], global_ifu_nr, slitlet_nr, filter_id);
+                                max, rl_cut[i], rl_wl[i], global_ifu_nr, 
+                                slitlet_nr, filter_id);
                     }
                     cpl_vector *mx = kmo_idl_where(yv1, max-1.0, ge);
                     range = 16;
                     offset = offset + ((int) cpl_vector_get(mx, 0)) - range/2;
 
-                    xv = kmo_wave_wrap_array_part(xtrace, n_trace, offset, range);
-                    yv2 = kmo_wave_wrap_array_part(trace, n_trace, offset, range);
+                    xv = kmo_wave_wrap_array_part(xtrace, n_trace, offset, 
+                            range);
+                    yv2 = kmo_wave_wrap_array_part(trace, n_trace, offset, 
+                            range);
                     if (yv2 == NULL) {
                         cpl_vector_unwrap(yv1);
                         cpl_vector_delete(mx);
                         rl_pos[i] = -1;
                         cpl_msg_debug(__func__,
                                 "Offset/range (%d/%d) spec is outside trace dimension for reference line %f for IFU %d slitlet %d in band %s",
-                                offset, range, rl_wl[i], global_ifu_nr, slitlet_nr, filter_id);
+                                offset, range, rl_wl[i], global_ifu_nr, 
+                                slitlet_nr, filter_id);
                         continue;
                     }
 
                     KMO_TRY_EXIT_IF_ERROR(
-                            kmo_easy_gaussfit(xv, yv2, &x0, &sigma, &area, &goffset));
-//                    sigma = 1.;
-//                    cpl_error_code ce = cpl_vector_fit_gaussian(xv, NULL, yv, NULL,
-//                            CPL_FIT_CENTROID | CPL_FIT_AREA | CPL_FIT_OFFSET,
-//                            &x0, &sigma, &area, &goffset, NULL, NULL, NULL);
+                            kmo_easy_gaussfit(xv, yv2, &x0, &sigma, &area, 
+                                &goffset));
                     if ((x0 > 0.0) && (sigma < 5.0) && (area > 20.)) {
                         rl_pos[i] = x0;
                     } else {
@@ -746,7 +782,8 @@ void kmo_find_lines (const char *filter_id,
             KMO_TRY_EXIT();
         } else if (cpl_vector_get_size(idx) <= degree) {
             cpl_msg_debug(__func__,"too few reference lines (%lld) found for IFU %d slitlet %d in band %s",
-                    cpl_vector_get_size(idx), global_ifu_nr, slitlet_nr, filter_id);
+                    cpl_vector_get_size(idx), global_ifu_nr, slitlet_nr, 
+                    filter_id);
             KMO_TRY_SET_ERROR(CPL_ERROR_DATA_NOT_FOUND);
             KMO_TRY_EXIT();
         } else {
@@ -772,12 +809,7 @@ void kmo_find_lines (const char *filter_id,
             }
             printf("\n");
         }
-
-
-        //
         // calculate all line positions
-        //
-//        const int hrange = 6; //same search range as in kmo_fit_arcline
         const int hrange = 4;
         double *c;
         cpl_vector *catalog_lambdas;
@@ -810,7 +842,8 @@ void kmo_find_lines (const char *filter_id,
             }
             if (((tmp-hrange) >= 0) && ((tmp+hrange) < n_trace)) {
                 double x0, sigma, area, goffset;
-                int range = 2 * hrange; //same search range as in kmo_fit_arcline
+                /* same search range as in kmo_fit_arcline */
+                int range = 2 * hrange;
                 cpl_vector *xv = NULL;
                 cpl_vector *yv = NULL;
                 int offset = ((int) tmp) - hrange;
@@ -823,12 +856,10 @@ void kmo_find_lines (const char *filter_id,
                 cpl_vector_unwrap(xv); xv = NULL;
                 cpl_vector_unwrap(yv); yv = NULL;
                 if (debug) printf("LF: %2d: %2d: %2d:  %f  %6.1f   %6.1f  %4.1f  %7.1f   %5.1f    %f",
-                        global_ifu_nr, slitlet_nr, i,
-                        x, tmp,
-                        x0, sigma, area, goffset, tmp-x0);
+                        global_ifu_nr, slitlet_nr, i, x, tmp, x0, sigma, area, 
+                        goffset, tmp-x0);
                 if ((x0 > 0.0) && (sigma < 5.0) && (area > 1.01)) {
                     if (debug) printf("\n");
-//                    ll_pos[n_valid] = x0;
                     ll_pos[n_valid] = tmp;
                     ll_lambda[n_valid] = x;
                     n_valid++;
@@ -837,10 +868,7 @@ void kmo_find_lines (const char *filter_id,
                 }
             }
         }
-        //
         // create and fill output vectors
-        //
-//        n_valid = n_valid -2;
         KMO_TRY_EXIT_IF_NULL(
                 *positions = cpl_vector_new(n_valid));
         KMO_TRY_EXIT_IF_NULL(
@@ -859,93 +887,80 @@ void kmo_find_lines (const char *filter_id,
     } KMO_CATCH {
         KMO_CATCH_MSG();
     }
-
     cpl_vector_delete(fit_pars); fit_pars = NULL;
-
     return;
-
 }
 
-void kmo_find_lines_2 (const char * table_filename,
-        const char *filter_id,
-        int global_ifu_nr,
-        int slitlet_nr,
-        cpl_vector *spectrum,
-        const cpl_bivector *catalog,
-        cpl_vector **positions,
-        cpl_vector **lambdas) {
-
-//    int loop = 0;
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+void kmo_find_lines_2(
+        const char          *   table_filename,
+        const char          *   filter_id,
+        int                     global_ifu_nr,
+        int                     slitlet_nr,
+        cpl_vector          *   spectrum,
+        const cpl_bivector  *   catalog,
+        cpl_vector          **  positions,
+        cpl_vector          **  lambdas) 
+{
     int converged;
     int degree;
-//    int nsamples = 10;
-//    int max_loops;
     int nr_matching_rows;
     int valid;
     cpl_size pow[1];
-//    double slitw = 2.0;
-//    double slitw = 0.01;
-//    double fwhm = 0.0008;
-//    double slitw = 3.;
-
     double x;
     double xc;
-//    double previous_xc;
-//    cpl_table *wlres;
-//    cpl_vector *xcorrs;
-//    double wl_error_fill = .01;
     double coeffs[NR_COEFFS_COLS];
-//    = {1.95090384365, 0.000264104234528,
-//            -1.3379515120037174E-8, 3.081911523618767E-12};
     cpl_polynomial *best_poly = NULL;
     cpl_polynomial *init_poly = NULL;
     char *coeff_cols[NR_COEFFS_COLS] = {COEFF_COLS};
     int i = 0, ix = 0, sx = 0, ssx = 0;
 
     KMO_TRY {
-
-        // load polynom coefficients table to read first guess polynom coefficients
+        // load polynom coefficients table to read first guess poly coeffs
         cpl_table *coeffs_table = cpl_table_load(table_filename, 1, 1);
         if (coeffs_table == NULL) {
-            cpl_msg_error(__func__, "Cannot load polynom coefficients table %s", table_filename);
+            cpl_msg_error(__func__, "Cannot load polynom coefficients table %s",
+                    table_filename);
             KMO_TRY_EXIT();
         }
 
-        KMO_TRY_EXIT_IF_ERROR(
-                cpl_table_select_all(coeffs_table));
+        KMO_TRY_EXIT_IF_ERROR(cpl_table_select_all(coeffs_table));
 
         char filter_id_regex[5] = {'\0', '\0', '\0', '\0', '\0'};
         if (strlen(filter_id) < 2) {
             strcat(filter_id_regex, "^");
             strcat(filter_id_regex, filter_id);
             strcat(filter_id_regex, "$");
-            nr_matching_rows = cpl_table_and_selected_string(coeffs_table, BAND_COL, CPL_EQUAL_TO,
-                    filter_id_regex);
+            nr_matching_rows = cpl_table_and_selected_string(coeffs_table, 
+                    BAND_COL, CPL_EQUAL_TO, filter_id_regex);
             if (nr_matching_rows != KMOS_NR_IFUS) {
                 KMO_TRY_EXIT_WITH_ERROR(CPL_ERROR_ILLEGAL_INPUT);
             }
         } else {
             KMO_TRY_EXIT_WITH_ERROR(CPL_ERROR_ILLEGAL_INPUT);
         }
-        nr_matching_rows = cpl_table_and_selected_int(coeffs_table, IFU_COL, CPL_EQUAL_TO, global_ifu_nr);
+        nr_matching_rows = cpl_table_and_selected_int(coeffs_table, IFU_COL, 
+                CPL_EQUAL_TO, global_ifu_nr);
         if (nr_matching_rows != 1) {
             KMO_TRY_EXIT_WITH_ERROR(CPL_ERROR_ILLEGAL_INPUT);
         }
         cpl_array *selected_rows = cpl_table_where_selected(coeffs_table);
         int selected_row = cpl_array_get_int(selected_rows, 0, &valid);
-       if (valid !=0 ) {
+        if (valid !=0 ) {
             KMO_TRY_EXIT();
-       }
-//       printf("Selected row %d, band %s (shall be %s), ifu %d (shall be %d), %f\n",
-//               selected_row,
-//               cpl_table_get_string(coeffs_table, BAND_COL, selected_row), filter_id,
-//               cpl_table_get_int(coeffs_table, IFU_COL, selected_row, &valid), global_ifu_nr,
-//               cpl_table_get_double(coeffs_table, A0_COL, selected_row, &valid));
+        }
         cpl_array_delete(selected_rows);
 
         init_poly = cpl_polynomial_new(1);
         for (i = 0; i < NR_COEFFS_COLS; i++) {
-            coeffs[i] = cpl_table_get_double(coeffs_table, coeff_cols[i], selected_row, &valid);
+            coeffs[i] = cpl_table_get_double(coeffs_table, coeff_cols[i], 
+                    selected_row, &valid);
             if (valid == -1) {
                 cpl_msg_error(__func__,
                         "Error reading polynom coefficients table %s, column %s, row %d",
@@ -996,14 +1011,16 @@ void kmo_find_lines_2 (const char * table_filename,
                 break;
             }
         }
-//        cpl_vector *sub_spectrum = cpl_vector_extract(spectrum, start_index, end_index, 1);
 
         // trim catalog according sub_spectrum size
         x = start_index;
-        double start_wavelength = coeffs[0] + coeffs[1]*x + coeffs[2]*x*x + coeffs[3]*x*x*x;
+        double start_wavelength = coeffs[0] + coeffs[1]*x + coeffs[2]*x*x + 
+            coeffs[3]*x*x*x;
         x = end_index;
-        double end_wave_length = coeffs[0] + coeffs[1]*x + coeffs[2]*x*x + coeffs[3]*x*x*x;
-        const double *catalog_wavelengths = cpl_bivector_get_x_data_const(catalog);
+        double end_wave_length = coeffs[0] + coeffs[1]*x + coeffs[2]*x*x + 
+            coeffs[3]*x*x*x;
+        const double *catalog_wavelengths = 
+            cpl_bivector_get_x_data_const(catalog);
         int start_ix = -1;
         int end_ix = cpl_bivector_get_size(catalog) - 1;
         for (sx = 0; sx < cpl_bivector_get_size(catalog); sx++) {
@@ -1018,7 +1035,6 @@ void kmo_find_lines_2 (const char * table_filename,
         cpl_vector *sub_catalog_x = cpl_vector_extract(cpl_bivector_get_x_const(catalog),start_ix,end_ix,1);
         cpl_vector *sub_catalog_y = cpl_vector_extract(cpl_bivector_get_y_const(catalog),start_ix,end_ix,1);
         cpl_bivector *sub_catalog = cpl_bivector_wrap_vectors(sub_catalog_x, sub_catalog_y);
-//        printf("Number of sub_catalog lines: %d\n",cpl_vector_get_size(sub_catalog_x));
 
         cpl_size c0[1]= {0},
                  c1[1]= {1},
@@ -1032,13 +1048,8 @@ void kmo_find_lines_2 (const char * table_filename,
                 cpl_polynomial_get_coeff(init_poly, c3));
 
         // find best polynom
-//        int test_loop=1;
-//        while (test_loop) {
         converged =  kmo_best_wave_cal_poly (spectrum, sub_catalog, init_poly,
                 &best_poly, &degree, &xc);
-//        }
-//        cpl_polynomial_dump(best_poly,stdout);
-
 
         printf(" final fit: converge:  %d  degree %d  a0 %g a1 %g a2 %g a3 %g  final xc: %g\n",
                 converged, degree,
@@ -1053,7 +1064,8 @@ void kmo_find_lines_2 (const char * table_filename,
         KMO_TRY_EXIT_IF_NULL (
                 fref = cpl_bivector_new(KMOS_DETECTOR_SIZE));
         KMO_TRY_EXIT_IF_ERROR(
-                cpl_vector_fill_polynomial(cpl_bivector_get_x(fref),best_poly,0.,1.));
+                cpl_vector_fill_polynomial(cpl_bivector_get_x(fref),best_poly,
+                    0.,1.));
         double *fref_y = cpl_bivector_get_y_data(fref);
         for (ix = 0; ix < KMOS_DETECTOR_SIZE; ix++) {
             fref_y[ix] = ix;
@@ -1062,7 +1074,8 @@ void kmo_find_lines_2 (const char * table_filename,
         double *scx =  cpl_bivector_get_x_data(sub_catalog);
         int fout_size = 0;
         double min = cpl_vector_get(cpl_bivector_get_x(fref), 0);
-        double max = cpl_vector_get(cpl_bivector_get_x(fref), KMOS_DETECTOR_SIZE - 1);
+        double max = cpl_vector_get(cpl_bivector_get_x(fref), 
+                KMOS_DETECTOR_SIZE - 1);
         for (ix = 0; ix < cpl_bivector_get_size(sub_catalog); ix++) {
             if (scx[ix]>=min && scx[ix]<=max) {
                 fout_size++;
@@ -1078,9 +1091,6 @@ void kmo_find_lines_2 (const char * table_filename,
                 tmp_ix++;
             }
         }
-//        KMO_TRY_EXIT_IF_ERROR(
-//                cpl_vector_copy(cpl_bivector_get_x(fout), cpl_bivector_get_x(sub_catalog)));
-
         KMO_TRY_EXIT_IF_ERROR(
                 cpl_bivector_interpolate_linear(fout, fref));
         KMO_TRY_EXIT_IF_NULL(
@@ -1089,24 +1099,29 @@ void kmo_find_lines_2 (const char * table_filename,
                 cpl_vector_copy(*positions,cpl_bivector_get_y(fout)));
         KMO_TRY_EXIT_IF_NULL(
                 *lambdas = cpl_vector_new(fout_size));
-         KMO_TRY_EXIT_IF_ERROR(
+        KMO_TRY_EXIT_IF_ERROR(
                 cpl_vector_copy(*lambdas, cpl_bivector_get_x(fout)));
-
-
         cpl_bivector_delete(fref);
         cpl_bivector_delete(fout);
         cpl_polynomial_delete(best_poly);
 
-
     } KMO_CATCH {
         KMO_CATCH_MSG();
     }
-
     return;
 }
 
-cpl_table*  kmo_wave_guess_table_open (const char *filename, int create) {
-
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+cpl_table * kmo_wave_guess_table_open(
+        const char  *   filename, 
+        int             create) 
+{
     cpl_table *table = NULL;
     char *bands[NR_BANDS] = {BANDS};
 
@@ -1116,7 +1131,8 @@ cpl_table*  kmo_wave_guess_table_open (const char *filename, int create) {
         cpl_error_reset();
         if (table == NULL && create) { // table read error, create new table
             KMO_TRY_EXIT_IF_NULL(
-                    table = cpl_table_new(NR_BANDS * KMOS_NR_IFUS));  //five bands times 24 IFUs
+                /* five bands times 24 IFUs */
+                    table = cpl_table_new(NR_BANDS * KMOS_NR_IFUS));  
             KMO_TRY_EXIT_IF_ERROR(
                     cpl_table_new_column(table, BAND_COL, CPL_TYPE_STRING));
             KMO_TRY_EXIT_IF_ERROR(
@@ -1149,19 +1165,25 @@ cpl_table*  kmo_wave_guess_table_open (const char *filename, int create) {
     } KMO_CATCH {
         KMO_CATCH_MSG();
     }
-
     return table;
-
 }
 
-int kmo_wave_guess_table_get_column (cpl_table *table,
-        const char *filter_id, const int global_ifu_nr) {
-
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+int kmo_wave_guess_table_get_column(
+        cpl_table   *   table,
+        const char  *   filter_id, 
+        const int       global_ifu_nr) 
+{
     int selected_row = -1;
     int nr_matching_rows;
     cpl_array*  selected_rows;
 
-
     KMO_TRY
     {
         KMO_TRY_EXIT_IF_ERROR(
@@ -1172,15 +1194,16 @@ int kmo_wave_guess_table_get_column (cpl_table *table,
             strcat(filter_id_regex, "^");
             strcat(filter_id_regex, filter_id);
             strcat(filter_id_regex, "$");
-            nr_matching_rows = cpl_table_and_selected_string(table, BAND_COL, CPL_EQUAL_TO,
-                    filter_id_regex);
+            nr_matching_rows = cpl_table_and_selected_string(table, BAND_COL, 
+                    CPL_EQUAL_TO, filter_id_regex);
             if (nr_matching_rows != KMOS_NR_IFUS) {
                 KMO_TRY_EXIT_WITH_ERROR(CPL_ERROR_ILLEGAL_INPUT);
             }
         } else {
             KMO_TRY_EXIT_WITH_ERROR(CPL_ERROR_ILLEGAL_INPUT);
         }
-        nr_matching_rows = cpl_table_and_selected_int(table, IFU_COL, CPL_EQUAL_TO, global_ifu_nr);
+        nr_matching_rows = cpl_table_and_selected_int(table, IFU_COL, 
+                CPL_EQUAL_TO, global_ifu_nr);
         if (nr_matching_rows != 1) {
             KMO_TRY_EXIT_WITH_ERROR(CPL_ERROR_ILLEGAL_INPUT);
         }
@@ -1191,50 +1214,48 @@ int kmo_wave_guess_table_get_column (cpl_table *table,
             KMO_TRY_EXIT();
         }
         cpl_array_delete(selected_rows);
-
-    } KMO_CATCH {
+    } 
+    
+    KMO_CATCH {
         KMO_CATCH_MSG();
     }
-
     return selected_row;
 
 }
-void kmo_wave_guess_table_update_1 (const char *filename,
-        int global_ifu_nr,  /*int slitlet_nr, */const char *filter_id,
-        cpl_vector *positions, cpl_vector *lambdas) {
 
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+void kmo_wave_guess_table_update_1(
+        const char  *   filename,
+        int             global_ifu_nr,  
+        const char  *   filter_id,
+        cpl_vector  *   positions, 
+        cpl_vector  *   lambdas) 
+{
     cpl_table* table = NULL;
     char *coeff_cols[NR_COEFFS_COLS] = {COEFF_COLS};
     int selected_row;
-//    double mse;
     cpl_size pows[1];
 
     KMO_TRY
     {
-// deprecated
-//        cpl_polynomial *poly  = cpl_polynomial_fit_1d_create(positions, lambdas, 3, &mse);
-
-// replaced with this, ok?
-cpl_polynomial *poly = cpl_polynomial_new(1);
-double *px = cpl_vector_get_data((cpl_vector*)positions);
-cpl_matrix *x_matrix = cpl_matrix_wrap(1, cpl_vector_get_size(positions), px);
-const cpl_boolean   sampsym     = CPL_FALSE;
-cpl_size mindeg1d    = 0,    //1,
-         maxdeg1d    = 3;
-cpl_polynomial_fit(poly,
-                   x_matrix,
-                   &sampsym,
-                   lambdas,
-                   NULL,
-                   CPL_FALSE,
-                   &mindeg1d,
-                   &maxdeg1d);
-
-//        cpl_polynomial_dump(poly, stdout);
-
+        cpl_polynomial *poly = cpl_polynomial_new(1);
+        double *px = cpl_vector_get_data((cpl_vector*)positions);
+        cpl_matrix *x_matrix = cpl_matrix_wrap(1, 
+                cpl_vector_get_size(positions), px);
+        const cpl_boolean   sampsym     = CPL_FALSE;
+        cpl_size mindeg1d    = 0,    //1,
+                 maxdeg1d    = 3;
+        cpl_polynomial_fit(poly, x_matrix, &sampsym, lambdas, NULL, CPL_FALSE,
+                   &mindeg1d, &maxdeg1d);
         table = kmo_wave_guess_table_open(filename, 1);
-
-        selected_row = kmo_wave_guess_table_get_column(table, filter_id, global_ifu_nr);
+        selected_row = kmo_wave_guess_table_get_column(table, filter_id, 
+                global_ifu_nr);
 
         int ix = 0;
         for (ix = 0; ix < NR_COEFFS_COLS; ix++) {
@@ -1252,38 +1273,48 @@ cpl_polynomial_fit(poly,
         KMO_CATCH_MSG();
     }
     cpl_table_delete(table);
-
 }
 
-void kmo_wave_guess_table_update_2 (const char *filename,
-        int ifu_nr, int global_ifu_nr,  const char *filter_id,
-        int flip_trace,
-        cpl_matrix **fitpars) {
-
-//    cpl_error_code error = CPL_ERROR_NONE;
-    cpl_table* table = NULL;
-    int selected_row = 0, i = 0;
-    char *coeff_cols[NR_COEFFS_COLS] = {COEFF_COLS};
-    double coeffs[NR_COEFFS_COLS];
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+void kmo_wave_guess_table_update_2(
+        const char  *   filename,
+        int             ifu_nr, 
+        int             global_ifu_nr,  
+        const char  *   filter_id,
+        int             flip_trace,
+        cpl_matrix  **  fitpars) 
+{
+    cpl_table   *   table = NULL;
+    int             selected_row = 0, 
+                    i = 0;
+    char        *   coeff_cols[NR_COEFFS_COLS] = {COEFF_COLS};
+    double          coeffs[NR_COEFFS_COLS];
 
     KMO_TRY
     {
         table = kmo_wave_guess_table_open(filename, 1);
-
-        selected_row = kmo_wave_guess_table_get_column(table, filter_id, global_ifu_nr);
-
+        selected_row = kmo_wave_guess_table_get_column(table, filter_id, 
+                global_ifu_nr);
         for (i = 0; i < NR_COEFFS_COLS; i++) {
             cpl_matrix *col = cpl_matrix_extract_column(fitpars[ifu_nr-1], i);
             coeffs[i] = cpl_matrix_get_median(col);
             printf("coeffs distribution: %d %d:  %g %g %g\n", ifu_nr, i,
-                    cpl_matrix_get_min(col),cpl_matrix_get_median(col),cpl_matrix_get_max(col));
+                    cpl_matrix_get_min(col),cpl_matrix_get_median(col),
+                    cpl_matrix_get_max(col));
         }
 
         if (!flip_trace) {
             double x = 2047.;
             KMO_TRY_EXIT_IF_ERROR(
                     cpl_table_set_double(table, coeff_cols[0], selected_row,
-                            coeffs[0] + coeffs[1]*x + coeffs[2]*x*x + coeffs[3]*x*x*x ));
+                            coeffs[0] + coeffs[1]*x + coeffs[2]*x*x + 
+                            coeffs[3]*x*x*x ));
             KMO_TRY_EXIT_IF_ERROR(
                     cpl_table_set_double(table, coeff_cols[1], selected_row,
                             -coeffs[1] - 2*coeffs[2]*x - 3*coeffs[3]*x*x ));
@@ -1296,16 +1327,17 @@ void kmo_wave_guess_table_update_2 (const char *filename,
         } else {
             for (i = 0; i < NR_COEFFS_COLS; i++) {
                 KMO_TRY_EXIT_IF_ERROR(
-                        cpl_table_set_double(table, coeff_cols[i], selected_row, coeffs[i]));
+                        cpl_table_set_double(table, coeff_cols[i],
+                            selected_row, coeffs[i]));
             }
         }
 
         int dummy;
         printf("coeffs to table:                               %g %g %g %g\n",
-                cpl_table_get_double(table, coeff_cols[0], selected_row, &dummy),
-                cpl_table_get_double(table, coeff_cols[1], selected_row, &dummy),
-                cpl_table_get_double(table, coeff_cols[2], selected_row, &dummy),
-                cpl_table_get_double(table, coeff_cols[3], selected_row, &dummy)
+                cpl_table_get_double(table, coeff_cols[0],selected_row, &dummy),
+                cpl_table_get_double(table, coeff_cols[1],selected_row, &dummy),
+                cpl_table_get_double(table, coeff_cols[2],selected_row, &dummy),
+                cpl_table_get_double(table, coeff_cols[3],selected_row, &dummy)
         );
 
         KMO_TRY_EXIT_IF_ERROR(
@@ -1319,73 +1351,69 @@ void kmo_wave_guess_table_update_2 (const char *filename,
     cpl_table_delete(table);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculates the wavelength calibration data for a detector.
-
-    @param data             The arcframe.
-    @param bad_pix          The badpixel frame.
-    @param xcal             The x-calibration frame from kmo_flat.
-    @param ycal             The y-calibration frame from kmo_flat.
-    @param filter_id        The filtzer ID (e.g. "K", "HK", etc)
-    @param lamp_config      Either ARGON, NEON or ARGON_NEON
-    @param detector_nr      The detector index (from 1 to 3)
-    @param ifu_inactive     Array containing flags if IFUs are (in)active.
-    @param edge_table       An array of size KMOS_IFUS_PER_DETECTOR. Each
-                            holding a table with 4 columns of edge fit parameters
-    @param lines            Vector with the defined arclines. This vector has
-                            been generated with kmo_get_lines().
-    @param disp             The expected dispersion in wavelength.
-    @param lcal             (Output) The wavelength calibration frame
-    @param qc_ar_eff        (Output) The argon lamp efficency QC parameter.
-    @param qc_ne_eff        (Output) The neon lamp efficency QC parameter.
-    @param flip_trace       FOR SIMULATION DATA only. Set to TRUE in this
-                            case (wavelengths are ascending from bottom of
-                            detector to top in this case).
-    @param fit_order        Polynomial order of the wavelength solution.
-
-    @return
-        The function returns CPL_ERROR_NONE on success or a CPL error code
-        otherwise.
-
-    First a line profile across the badpix frame is created, the positions of the
-    edges and corresponding IFUs are detected.
-    Then all slitlets are looped: The wavelength profile is calculated, then the
-    arclines defined in a text file are matched to get approximate estimates of
-    the line positions. Then the exact line positions are calculated using
-    function fitting. Then a polynomial is fitted along the wavelength direction
-    to get the wavelength calibration data. At the end some QC parameters are
-    collected and returned.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c detector_nr < 0 or if the dimensions of
-                                any of the input frames aren't equal.
+  @brief Calculates the wavelength calibration data for a detector.
+  @param data             The arcframe.
+  @param bad_pix          The badpixel frame.
+  @param xcal             The x-calibration frame from kmo_flat.
+  @param ycal             The y-calibration frame from kmo_flat.
+  @param filter_id        The filtzer ID (e.g. "K", "HK", etc)
+  @param lamp_config      Either ARGON, NEON or ARGON_NEON
+  @param detector_nr      The detector index (from 1 to 3)
+  @param ifu_inactive     Array containing flags if IFUs are (in)active.
+  @param edge_table       An array of size KMOS_IFUS_PER_DETECTOR. Each
+                          holding a table with 4 columns of edge fit parameters
+  @param lines            Vector with the defined arclines. This vector has
+                          been generated with kmo_get_lines().
+  @param disp             The expected dispersion in wavelength.
+  @param lcal             (Output) The wavelength calibration frame
+  @param qc_ar_eff        (Output) The argon lamp efficency QC parameter.
+  @param qc_ne_eff        (Output) The neon lamp efficency QC parameter.
+  @param flip_trace       FOR SIMULATION DATA only. Set to TRUE in this
+                          case (wavelengths are ascending from bottom of
+                          detector to top in this case).
+  @param fit_order        Polynomial order of the wavelength solution.
+  @return CPL_ERROR_NONE on success or a CPL error code otherwise.
+
+  First a line profile across the badpix frame is created, the positions of the
+  edges and corresponding IFUs are detected.
+  Then all slitlets are looped: The wavelength profile is calculated, then the
+  arclines defined in a text file are matched to get approximate estimates of
+  the line positions. Then the exact line positions are calculated using
+  function fitting. Then a polynomial is fitted along the wavelength direction
+  to get the wavelength calibration data. At the end some QC parameters are
+  collected and returned.
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c detector_nr < 0 or if the dimensions of
+                              any of the input frames aren't equal.
 */
-cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
-                                    const cpl_image *bad_pix,
-                                    const cpl_image *xcal,
-                                    const cpl_image *ycal,
-                                    const char *filter_id,
-                                    enum lampConfiguration lamp_config,
-                                    const int detector_nr,
-                                    cpl_array *ifu_inactive,
-                                    cpl_table **edge_table,
-                                    const cpl_bivector *lines,
-                                    const cpl_table *reflines,
-                                    double disp,
-                                    cpl_image **lcal,
-                                    double *qc_ar_eff,
-                                    double *qc_ne_eff,
-                                    int flip_trace,
-                                    const int fit_order,
-                                    const int line_estimate_method)
+/*----------------------------------------------------------------------------*/
+cpl_error_code  kmo_calc_wave_calib(
+        const cpl_image     *   data,
+        const cpl_image     *   bad_pix,
+        const cpl_image     *   xcal,
+        const cpl_image     *   ycal,
+        const char          *   filter_id,
+        enum lampConfiguration  lamp_config,
+        const int               detector_nr,
+        cpl_array           *   ifu_inactive,
+        cpl_table           **  edge_table,
+        const cpl_bivector  *   lines,
+        const cpl_table     *   reflines,
+        double                  disp,
+        cpl_image           **  lcal,
+        double              *   qc_ar_eff,
+        double              *   qc_ne_eff,
+        int                     flip_trace,
+        const int               fit_order,
+        const int               line_estimate_method)
 {
     cpl_error_code  ret_error           = CPL_ERROR_NONE;
 
     const char *coeffs_table_filename = "kmo_wave_guess_polynom_table.fits";
-
     char *data_fits_prefix = NULL;
     char *data_fits_name = NULL;
     if (getenv("KMO_WAVE_CAL_DATA_PREFIX") != NULL) {
@@ -1400,7 +1428,6 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
                     *lambdas            = NULL,
                     *positions          = NULL,
                     *qc_vec             = NULL,
-//                    *qc_disp_vec        = NULL,
                     ***xarray             = NULL,
                     ***larray             = NULL,
                     *qc_ar_flux         = NULL,
@@ -1409,13 +1436,10 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
                     *tmp_qc2            = NULL,
                     *left_edge          = NULL,
                     *right_edge         = NULL;
-
     cpl_image       ***yarray           = NULL;
-
     cpl_matrix      **fitpars           = NULL;
     cpl_matrix      **cfitpars           = NULL;
     cpl_array       **valid_columns     = NULL;
-
     double          *pqc_ar_flux        = NULL,
                     *pqc_ne_flux        = NULL,
                     *ppositions         = NULL,
@@ -1427,7 +1451,6 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
                     tmp_min_lambda      = 0.0,
                     tmp_max_lambda      = 0.0,
                     *pfitpars           = NULL;
-
     int             nx                  = 0,
                     ny                  = 0,
                     nr_edges            = 0,
@@ -1456,40 +1479,32 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (bad_pix != NULL) &&
-                       (xcal != NULL) &&
-                       (ycal != NULL) &&
-                       (filter_id != NULL) &&
-                       (ifu_inactive != NULL) &&
-                       (edge_table != NULL) &&
-                       (lines != NULL) &&
-                       (lcal != NULL) &&
-                       (qc_ar_eff != NULL) &&
-                       (qc_ne_eff != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((data != NULL) && (bad_pix != NULL) && (xcal != NULL) &&
+                (ycal != NULL) && (filter_id != NULL) &&
+                (ifu_inactive != NULL) && (edge_table != NULL) &&
+                (lines != NULL) && (lcal != NULL) && (qc_ar_eff != NULL) &&
+                (qc_ne_eff != NULL), CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
-        KMO_TRY_ASSURE(detector_nr > 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "detector_nr has to be positive!");
+        KMO_TRY_ASSURE(detector_nr > 0, CPL_ERROR_ILLEGAL_INPUT,
+                "detector_nr has to be positive!");
 
-        KMO_TRY_ASSURE(cpl_array_get_size(ifu_inactive)
-                                                    == KMOS_IFUS_PER_DETECTOR,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Array 'ifu_inactive'' must be of size 8!");
+        KMO_TRY_ASSURE(cpl_array_get_size(ifu_inactive)==KMOS_IFUS_PER_DETECTOR,
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Array 'ifu_inactive'' must be of size 8!");
 
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
 
-        KMO_TRY_ASSURE((nx == cpl_image_get_size_x(bad_pix)) &&
-                       (ny == cpl_image_get_size_y(bad_pix)) &&
-                       (nx == cpl_image_get_size_x(xcal)) &&
-                       (ny == cpl_image_get_size_y(xcal)) &&
-                       (nx == cpl_image_get_size_x(ycal)) &&
-                       (ny == cpl_image_get_size_y(ycal)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Data- and bad pix-frame haven't the same size!");
+        KMO_TRY_ASSURE(
+                (nx == cpl_image_get_size_x(bad_pix)) &&
+                (ny == cpl_image_get_size_y(bad_pix)) &&
+                (nx == cpl_image_get_size_x(xcal)) &&
+                (ny == cpl_image_get_size_y(xcal)) &&
+                (nx == cpl_image_get_size_x(ycal)) &&
+                (ny == cpl_image_get_size_y(ycal)),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Data- and bad pix-frame haven't the same size!");
 
         KMO_TRY_EXIT_IF_NULL(
             pdata = cpl_image_get_data_float_const(data));
@@ -1539,9 +1554,7 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
             valid_columns[i] = NULL;
         }
 
-        //
         // get the number of valid edges
-        //
         for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
             if ((edge_table[i] != NULL) &&
                 (cpl_array_get_int(ifu_inactive, i, NULL) == 0))
@@ -1557,14 +1570,9 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
             KMO_TRY_CHECK_ERROR_STATE();
         }
 
-        //
         // allocate data structures
-        //
         KMO_TRY_EXIT_IF_NULL(
             qc_vec = cpl_vector_new(4));
-//        KMO_TRY_EXIT_IF_NULL(
-//            qc_disp_vec = cpl_vector_new(9));
-
         KMO_TRY_EXIT_IF_NULL(
             qc_ar_flux = cpl_vector_new(nr_edges/2));
         cpl_vector_fill(qc_ar_flux, -1);
@@ -1588,85 +1596,40 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
         cpl_vector_fill(left_edge, -1);
         cpl_vector_fill(right_edge, -1);
 
-//        // allocate here an image (used as array) to keep track of the lcal
-//        // values set in kmo_fit_spectrum. If this function fails these values
-//        // can be set to 0.0 again -> only this slitlet is set invalid,
-//        // pipeline can continue
-//        KMO_TRY_EXIT_IF_NULL(
-//            unroll_lcal = cpl_image_new(KMOS_DETECTOR_SIZE*70,
-//                                        2, CPL_TYPE_FLOAT));
-
-        //
         // loop all the slitlets
-        //
         min_lambda = DBL_MAX;
         max_lambda = -DBL_MAX;
 
         KMO_TRY_CHECK_ERROR_STATE();
         max_nr_x_positions = 0;
-        for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++)
-// use loop below for line identification
-//            for (int i = 4; i <= 4; i++)
-        {
+        for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
             for (sx = 0; sx < KMOS_SLITLET_Y; sx ++) {
                 line_check_ok[i][sx] = FALSE;
             }
 
             ifu_nr = i+1;
             global_ifu_nr = (detector_nr-1)*KMOS_IFUS_PER_DETECTOR + ifu_nr;
-//cpl_msg_debug(cpl_func,"IFU: %d", i+1);
             if ((edge_table[i] != NULL) &&
-                (cpl_array_get_int(ifu_inactive, i, NULL) == 0))
-            {
-                // IFU has valid edges
-
-                // loop all slitlets of this IFU
-//cpl_msg_debug(cpl_func,"det: %d, ifu: %d, slit: %d", detector_nr, ifu_nr, slitlet_nr);
-                for (k = 0; k < cpl_table_get_nrow(edge_table[i]); k+=2)
-// use loop below for line identification
-// (this will be last edge of IFU 4 --> middle of the detector)
-//                     int t = cpl_table_get_nrow(edge_table[i])/2;
-//                    for (int k = t; k <= t; k++)
-                {
+                (cpl_array_get_int(ifu_inactive, i, NULL) == 0)) {
+                for (k = 0; k < cpl_table_get_nrow(edge_table[i]); k+=2) {
                     int sx = k/2;  //slitlet index
                     slitlet_nr = cpl_table_get_int(edge_table[i], "ID",
                                                    k, NULL);
                     KMO_TRY_CHECK_ERROR_STATE();
-                    //
                     // calculate left and right edge
-                    //
-                    for (j = KMOS_BADPIX_BORDER; j < ny-KMOS_BADPIX_BORDER; j++)
-                    {
-                        pleft_edge[j-KMOS_BADPIX_BORDER]  = (int)(kmo_calc_fitted_slitlet_edge(edge_table[i], k, j)+0.5);
-                        pright_edge[j-KMOS_BADPIX_BORDER] = (int)(kmo_calc_fitted_slitlet_edge(edge_table[i], k+1, j)+0.5);
+                    for (j=KMOS_BADPIX_BORDER; j<ny-KMOS_BADPIX_BORDER; j++) {
+                        pleft_edge[j-KMOS_BADPIX_BORDER]  = 
+                            (int)(kmo_calc_fitted_slitlet_edge(edge_table[i], 
+                                        k, j)+0.5);
+                        pright_edge[j-KMOS_BADPIX_BORDER] = 
+                            (int)(kmo_calc_fitted_slitlet_edge(edge_table[i], 
+                                        k+1, j)+0.5);
                     }
-//cpl_vector_save(left_edge, "left_edge.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-//cpl_vector_save(right_edge, "right_edge.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-
-//cpl_image_save(data, "img_data.fits", CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_CREATE);
-//cpl_image_save(bad_pix, "img_badpix.fits", CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_CREATE);
-//cpl_image* ddd = cpl_image_duplicate(data);
-//for (int ggg = 5; ggg<2045; ggg++) {
-//    int gggx = cpl_vector_get(left_edge, ggg-5);
-//    int gggy = ggg;
-//    cpl_image_set(ddd, gggx, gggy, 999999999);
-
-//    gggx = cpl_vector_get(right_edge, ggg-5);
-//    cpl_image_set(ddd, gggx, gggy, 888888888);
-//}
-//cpl_image_save(ddd, "img_data2.fits", CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_CREATE);
-//cpl_image_delete(ddd);
-
-                    //
+
                     // extract initial spectral trace
-                    //
-                    trace = kmo_extract_initial_trace(data,
-                                                      bad_pix,
-                                                      left_edge,
-                                                      right_edge,
-                                                      edge_offset);
-
-//cpl_vector_save(trace, "trace.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
+                    trace = kmo_extract_initial_trace(data, bad_pix, left_edge,
+                            right_edge, edge_offset);
+
                     if (trace == NULL) {
                         cpl_msg_warning("", "Couldn't get the wavelength "
                                         "trace for slitlet %d on IFU %d",
@@ -1690,20 +1653,18 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
                         }
 //kmo_plot_vector("set title \"trace\";", "w l;", trace);
 
-                        //
                         // identify initial lines,
                         // fit a vertical curve to get good initial estimates of
                         // all arcline positions
-                        //
-
-//                        kmo_find_lines_test (trace, lines/*, &positions, &lambdas*/);
+        //kmo_find_lines_test (trace, lines/*, &positions, &lambdas*/);
                         if (data_fits_name != NULL) {
                             cpl_free(data_fits_name);
                         }
                         if (data_fits_prefix != NULL) {
                             data_fits_name = cpl_sprintf(
                                 "%s_%s_ifu_%2.2d_slitlet_%2.2d.fits",
-                                data_fits_prefix, filter_id, i+1 + 8 * (detector_nr-1), slitlet_nr);
+                                data_fits_prefix, filter_id, 
+                                i+1 + 8 * (detector_nr-1), slitlet_nr);
                         }
                         if (data_fits_name != NULL) {
                             cpl_vector_save(NULL,data_fits_name,
@@ -1711,21 +1672,18 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
                             kmo_wave_write_data_vector(data_fits_name,
                                     trace,"trace");
                             kmo_wave_write_data_vector(data_fits_name,
-                                    cpl_bivector_get_x_const(lines), "line_list_lambda");
+                                    cpl_bivector_get_x_const(lines), 
+                                    "line_list_lambda");
                             kmo_wave_write_data_vector(data_fits_name,
-                                    cpl_bivector_get_y_const(lines), "line_list_strength");
+                                    cpl_bivector_get_y_const(lines), 
+                                    "line_list_strength");
                         }
 
                         if ((line_estimate_method & 3) == 0) {
-                            ret_error = kmo_estimate_lines(trace,
-                                                           cpl_bivector_get_x_const(lines),
-                                                           filter_id, disp,
-                                                           &positions, &lambdas,
-                                                           detector_nr,
-                                                           ifu_nr,
-                                                           slitlet_nr,
-                                                           data_fits_name);
-
+                            ret_error = kmo_estimate_lines(trace, 
+                                    cpl_bivector_get_x_const(lines), filter_id,
+                                    disp, &positions, &lambdas, detector_nr,
+                                    ifu_nr, slitlet_nr, data_fits_name);
                             if (data_fits_name != NULL) {
                                 kmo_wave_write_data_vector(data_fits_name,
                                         positions, "estimate_positions");
@@ -1735,19 +1693,20 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
                             }
                             int plotIt = 0;
                             if (plotIt) {
-                                plot_estimated_lines(trace, lines, positions, lambdas);
+                                plot_estimated_lines(trace, lines, positions, 
+                                        lambdas);
                             }
 
                             if (line_estimate_method & 16) {
-                                kmo_wave_guess_table_update_1(coeffs_table_filename,
-                                        i+1 + (detector_nr-1) * KMOS_IFUS_PER_DETECTOR, /*slitlet_nr,*/
+                                kmo_wave_guess_table_update_1(
+                                        coeffs_table_filename, 
+                                        i+1 + (detector_nr-1) * KMOS_IFUS_PER_DETECTOR,
                                         filter_id, positions, lambdas);
                             }
                         }
                         if ((line_estimate_method & 3) == 1){
                             kmo_find_lines_2 (coeffs_table_filename, filter_id,
-                                    global_ifu_nr, slitlet_nr,
-                                    trace, lines,
+                                    global_ifu_nr, slitlet_nr, trace, lines,
                                     &positions, &lambdas);
                             ret_error = CPL_ERROR_NONE;
                             if (data_fits_name != NULL) {
@@ -1783,8 +1742,7 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
                                 ppositions = cpl_vector_get_data(positions);
                                 for (g = 0;
                                      g < cpl_vector_get_size(positions);
-                                     g++)
-                                {
+                                     g++) {
                                     // correction of wave shift error of 1 pix
                                     //ppositions[g] = ny-1-ppositions[g];
                                     ppositions[g] = ny-ppositions[g];
@@ -1792,12 +1750,10 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
                             }
                             cpl_vector_delete(trace); trace = NULL;
 
-                            //
                             // calculate exact y-positions of arclines,
                             // fit a polynomial to every arcline
                             // extrapolate every fitted arcline to the
                             // minimum &maximum edges of the slitlet
-                            //
 
                             // size in x for extrapolation for this slitlet
                             fit_arc_size_x = cpl_vector_get_max(right_edge) -
@@ -1809,34 +1765,32 @@ cpl_error_code  kmo_calc_wave_calib(const cpl_image *data,
 
                             // allocate enough memory to hold extrapolated
                             // arclines
-                            cpl_vector_delete(xarray[i][sx]); xarray[i][sx] = NULL;
+                            cpl_vector_delete(xarray[i][sx]); 
+                            xarray[i][sx] = NULL;
                             KMO_TRY_EXIT_IF_NULL(
                                 xarray[i][sx] = cpl_vector_new(fit_arc_size_x));
 
-                            cpl_vector_delete(larray[i][sx]); larray[i][sx] = NULL;
+                            cpl_vector_delete(larray[i][sx]); 
+                            larray[i][sx] = NULL;
 
-                            cpl_image_delete(yarray[i][sx]); yarray[i][sx] = NULL;
+                            cpl_image_delete(yarray[i][sx]); 
+                            yarray[i][sx] = NULL;
                             KMO_TRY_EXIT_IF_NULL(
                                 yarray[i][sx] = cpl_image_new(fit_arc_size_x,
-                                                       fit_arc_size_y,
-                                                       CPL_TYPE_FLOAT));
+                                    fit_arc_size_y, CPL_TYPE_FLOAT));
 
-                            //
                             // calculate exact y-positions of arclines &
                             // extrapolate
-                            //
-kmclipm_vector *lll = kmclipm_vector_new(fit_arc_size_y);
-                            ret_error = kmo_extrapolate_arclines(
-                                            data, bad_pix,
-                                            positions, lambdas,
-                                            left_edge, right_edge,
-                                            &xarray[i][sx], &yarray[i][sx], &lll,
-                                            &qc_vec,
-                                            detector_nr, ifu_nr, slitlet_nr,
-                                            filter_id,
-                                            lamp_config);
-larray[i][sx] = cpl_vector_duplicate(lll->data);
-kmclipm_vector_delete(lll); lll = NULL;
+                            kmclipm_vector *lll = kmclipm_vector_new(
+                                    fit_arc_size_y);
+                            ret_error = kmo_extrapolate_arclines(data, bad_pix,
+                                    positions, lambdas, left_edge, right_edge,
+                                    &xarray[i][sx], &yarray[i][sx], &lll,
+                                    &qc_vec, detector_nr, ifu_nr, slitlet_nr,
+                                    filter_id, lamp_config);
+
+                            larray[i][sx] = cpl_vector_duplicate(lll->data);
+                            kmclipm_vector_delete(lll); lll = NULL;
 
                             if (data_fits_name != NULL) {
                                 kmo_wave_write_data_vector(data_fits_name,
@@ -1868,17 +1822,12 @@ kmclipm_vector_delete(lll); lll = NULL;
                                                 "for slitlet %d on IFU %d",
                                                 slitlet_nr, global_ifu_nr);
                             } else {
-//cpl_vector_save(xarray[i][sx], "xarray.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-//cpl_vector_save(larray[i][sx], "larray.fits", CPL_BPP_IEEE_DOUBLE, NULL,CPL_IO_DEFAULT);
-//cpl_image_save(yarray[i][sx], "yarray.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-
                                 line_check_ok[i][sx] = TRUE;
-
                                 // set qc_parameters
                                 pqc_ar_flux[slitlet_cnt] =
-                                                     cpl_vector_get(qc_vec,1);
+                                    cpl_vector_get(qc_vec,1);
                                 pqc_ne_flux[slitlet_cnt] =
-                                                     cpl_vector_get(qc_vec,3);
+                                    cpl_vector_get(qc_vec,3);
                                 slitlet_cnt++;
                             } // end if: no arclines extrapolated
                         } // end if: no lines estimated
@@ -1916,11 +1865,10 @@ kmclipm_vector_delete(lll); lll = NULL;
                         pfitpars = cpl_matrix_get_data(fitpars[i]));
                 KMO_TRY_EXIT_IF_NULL(
                         valid_columns[i] = cpl_array_new(
-//                                KMOS_SLITLET_Y * max_nr_x_positions *(fit_order+1),
-                                KMOS_SLITLET_Y * max_nr_x_positions,
-                                CPL_TYPE_INT));
+                            KMOS_SLITLET_Y * max_nr_x_positions, CPL_TYPE_INT));
                 KMO_TRY_EXIT_IF_NULL(
-                        pvalid_columns = cpl_array_get_data_int(valid_columns[i]));
+                        pvalid_columns = cpl_array_get_data_int(
+                            valid_columns[i]));
 
                 // loop thorugh all slitlets with detected lines of this IFU
                 for (k = 0; k < cpl_table_get_nrow(edge_table[i]); k+=2)
@@ -1935,59 +1883,41 @@ kmclipm_vector_delete(lll); lll = NULL;
                     if (data_fits_prefix != NULL) {
                         data_fits_name = cpl_sprintf(
                             "%s_%s_ifu_%2.2d_slitlet_%2.2d.fits",
-                            data_fits_prefix, filter_id, i+1 + 8 * (detector_nr-1), slitlet_nr);
+                            data_fits_prefix, filter_id, 
+                            i+1 + 8 * (detector_nr-1), slitlet_nr);
                     }
 
-                    slitlet_nr = cpl_table_get_int(edge_table[i], "ID",
-                            k, NULL);
+                    slitlet_nr = cpl_table_get_int(edge_table[i], "ID", k,NULL);
                     KMO_TRY_CHECK_ERROR_STATE();
-                    //
                     // calculate left and right edge
-                    //
-                    for (j = 0; j < ny-2*KMOS_BADPIX_BORDER; j++)
-                    {
-                        pleft_edge[j]  = (int)(kmo_calc_fitted_slitlet_edge(edge_table[i], k, j+KMOS_BADPIX_BORDER)+0.5);
-                        pright_edge[j] = (int)(kmo_calc_fitted_slitlet_edge(edge_table[i], k+1, j+KMOS_BADPIX_BORDER)+0.5);
+                    for (j = 0; j < ny-2*KMOS_BADPIX_BORDER; j++) {
+                        pleft_edge[j]  = (int)(kmo_calc_fitted_slitlet_edge(
+                                    edge_table[i],k, j+KMOS_BADPIX_BORDER)+0.5);
+                        pright_edge[j] = (int)(kmo_calc_fitted_slitlet_edge(
+                                edge_table[i],k+1,j+KMOS_BADPIX_BORDER)+0.5);
                     }
 
-                    //
                     // fit spectrum to the extrapolated arclines
-                    //
-                    int tmp_int =
-                            kmo_fit_spectrum_1(bad_pix,
-                                    xarray[i][sx], yarray[i][sx], larray[i][sx],
-                                    left_edge, right_edge,
-                                    lcal,
-                                    pfitpars,
-                                    fit_order,
-                                    pvalid_columns,
-                                    sx * max_nr_x_positions * (fit_order+1),
-                                    detector_nr,
-                                    ifu_nr,
-                                    slitlet_nr,
-                                    data_fits_name);
+                    int tmp_int = kmo_fit_spectrum_1(bad_pix, xarray[i][sx], 
+                            yarray[i][sx], larray[i][sx], left_edge, right_edge,
+                            lcal, pfitpars, fit_order, pvalid_columns,
+                            sx * max_nr_x_positions * (fit_order+1),
+                            detector_nr, ifu_nr, slitlet_nr, data_fits_name);
                     nr_valid_slitlets += tmp_int;
-                    //               if ((ret_error != CPL_ERROR_NONE) || (tmp_int == FALSE)) {
                     if (tmp_int == FALSE) {
                         cpl_msg_warning("", "Couldn't fit a "
-                                "spectrum for slitlet %d "
-                                "on IFU %d",
-                                slitlet_nr,
-                                global_ifu_nr);
+                                "spectrum for slitlet %d on IFU %d",
+                                slitlet_nr, global_ifu_nr);
                         cpl_error_reset();
                     }
                 }
             }
         }
-
         KMO_TRY_CHECK_ERROR_STATE();
 
 //printf("skip fitting of wavelength fit coefficients\n");
         goto skip;
-//
 // compress fit parameter matrices by removing invalid slots
-//
-
         for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
             int lix = 0;  //local IFU index
             int nr_cols;
@@ -1998,19 +1928,19 @@ kmclipm_vector_delete(lll); lll = NULL;
                 nr_cols = cpl_matrix_get_nrow(fitpars[i]);
                 nr_elements = cpl_array_get_size(valid_columns[i]);
                 if (nr_cols != nr_elements) {
-                    cpl_msg_debug(__func__,
-                            "trace point: nr_cols: %d      nr_elements: %d\n",
+                    cpl_msg_debug(__func__, 
+                            "trace point: nr_cols: %d   nr_elements: %d\n",
                             nr_cols,nr_elements);
                 }
                 if (nr_cols <= nr_elements) {
-                    const int *cols = cpl_array_get_data_int_const(valid_columns[i]);
+                    const int *cols = cpl_array_get_data_int_const(
+                            valid_columns[i]);
                     lix = 0;
                     for (k = 0; k < nr_cols; k++) {
                         if (cols[k] == 1) {
                             lix++;
                         }
                     }
-
                     KMO_TRY_EXIT_IF_NULL(
                             cfitpars[i] = cpl_matrix_new(lix, fit_order+1));
 
@@ -2019,8 +1949,8 @@ kmclipm_vector_delete(lll); lll = NULL;
                         if (cols[k] == 1) {
                             KMO_TRY_EXIT_IF_ERROR(
                                     cpl_matrix_copy(cfitpars[i],
-                                            cpl_matrix_extract_row(fitpars[i],k),
-                                            lix,0));
+                                        cpl_matrix_extract_row(fitpars[i],k),
+                                        lix,0));
                             lix++;
                         }
                     }
@@ -2039,21 +1969,21 @@ kmclipm_vector_delete(lll); lll = NULL;
         if ((value = getenv("LC_CH")) != NULL) {
             use_chebyshev = atoi(value);
         }
-        if ((value = getenv("LC_SIDES")) != NULL) { // number of different sizes
-                                                    // 1 -> all are equal, 2 -> left / right edges
+        if ((value = getenv("LC_SIDES")) != NULL) { 
+             /* number of different sizes  */
+             /* 1 -> all are equal, 2 -> left / right edges */
             left_right_pairs = atoi(value);
         }
-        if ((value = getenv("LC_FACTOR")) != NULL) { // n times stdev
+        if ((value = getenv("LC_FACTOR")) != NULL) {
+            /* n times stdev */
             threshold_factor = atof(value);
         }
 
         KMO_TRY_EXIT_IF_ERROR(
-                kmo_flat_interpolate_edge_parameters(cfitpars,
-                        threshold_factor, use_chebyshev, if_then_all_pars, left_right_pairs));
+                kmo_flat_interpolate_edge_parameters(cfitpars, threshold_factor,
+                    use_chebyshev, if_then_all_pars, left_right_pairs));
 
-//
-// "decompress" fit parameter matrices by adding invalid slots again
-//
+        /* "decompress" fit parameter matrices by adding invalid slots again */
         for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
             int lix = 0;  //local IFU index
             int nr_cols;
@@ -2065,20 +1995,21 @@ kmclipm_vector_delete(lll); lll = NULL;
                 nr_cols = cpl_matrix_get_nrow(fitpars[i]);
                 nr_elements = cpl_array_get_size(valid_columns[i]);
                 if (nr_cols <= nr_elements) {
-                    const int *cols = cpl_array_get_data_int_const(valid_columns[i]);
+                    const int *cols = cpl_array_get_data_int_const(
+                            valid_columns[i]);
                     lix = 0;
                     for (k = 0; k < nr_cols; k++) {
                         if (cols[k] == 1) {
                             KMO_TRY_EXIT_IF_ERROR(
                                     cpl_matrix_copy(fitpars[i],
-                                            cpl_matrix_extract_row(cfitpars[i],lix),
-                                            k,0));
+                                        cpl_matrix_extract_row(cfitpars[i],lix),
+                                        k,0));
                             lix++;
                         }
                     }
                     if (line_estimate_method & 32) {
-                        kmo_wave_guess_table_update_2(coeffs_table_filename,
-                                i+1, i+1 + (detector_nr-1) * KMOS_IFUS_PER_DETECTOR,
+                        kmo_wave_guess_table_update_2(coeffs_table_filename,i+1,
+                                i+1 + (detector_nr-1) * KMOS_IFUS_PER_DETECTOR,
                                 filter_id, flip_trace, cfitpars);
                     }
                 }
@@ -2086,24 +2017,21 @@ kmclipm_vector_delete(lll); lll = NULL;
         }
 
 skip:
-        for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++)
-        {
+        for (i = 0; i < KMOS_IFUS_PER_DETECTOR; i++) {
             ifu_nr = i+1;
             global_ifu_nr = (detector_nr-1)*KMOS_IFUS_PER_DETECTOR + ifu_nr;
             nr_valid_slitlets = 0;
             if ((edge_table[i] != NULL) &&
-                (cpl_array_get_int(ifu_inactive, i, NULL) == 0))
-            {
+                (cpl_array_get_int(ifu_inactive, i, NULL) == 0)) {
                 // IFU has valid edges
 
                KMO_TRY_EXIT_IF_NULL(
                         pfitpars = cpl_matrix_get_data(fitpars[i]));
                KMO_TRY_EXIT_IF_NULL(
-                        pvalid_columns = cpl_array_get_data_int(valid_columns[i]));
+                       pvalid_columns=cpl_array_get_data_int(valid_columns[i]));
 
                 // loop all slitlets of this IFU
-                for ( k = 0; k < cpl_table_get_nrow(edge_table[i]); k+=2)
-                {
+                for ( k = 0; k < cpl_table_get_nrow(edge_table[i]); k+=2) {
                     int sx = k/2;  //slitlet index
                     if ( ! line_check_ok[i][sx] ) {
                         continue;
@@ -2111,45 +2039,21 @@ skip:
                     slitlet_nr = cpl_table_get_int(edge_table[i], "ID",
                                                    k, NULL);
                     KMO_TRY_CHECK_ERROR_STATE();
-                    //
                     // calculate left and right edge
-                    //
-                    for (j = 0; j < ny-2*KMOS_BADPIX_BORDER; j++)
-                    {
-                        pleft_edge[j]  = (int)(kmo_calc_fitted_slitlet_edge(edge_table[i], k, j+KMOS_BADPIX_BORDER)+0.5);
-                        pright_edge[j] = (int)(kmo_calc_fitted_slitlet_edge(edge_table[i], k+1, j+KMOS_BADPIX_BORDER)+0.5);
+                    for (j = 0; j < ny-2*KMOS_BADPIX_BORDER; j++) {
+                        pleft_edge[j]  = (int)(kmo_calc_fitted_slitlet_edge(
+                                    edge_table[i],k,j+KMOS_BADPIX_BORDER)+0.5);
+                        pright_edge[j] = (int)(kmo_calc_fitted_slitlet_edge(
+                                    edge_table[i], k+1, j+KMOS_BADPIX_BORDER)+0.5);
                     }
 
-                    //
                     // fit spectrum to the extrapolated arclines
-                    //
-
-                    int tmp_int =
-                            kmo_fit_spectrum_2(bad_pix,
-                                        xarray[i][sx], yarray[i][sx], larray[i][sx],
-                                        left_edge, right_edge,
-                                        lcal,
-                                        &tmp_min_lambda,
-                                        &tmp_max_lambda,
-                                        pfitpars,
-                                        fit_order,
-                                        pvalid_columns,
-                                        sx * max_nr_x_positions * (fit_order+1),
-                                        detector_nr,
-                                        ifu_nr,
-                                        slitlet_nr);
-
-//                    int tmp_int =
-//                            kmo_fit_spectrum(bad_pix,
-//                                        xarray[i][sx], yarray[i][sx], larray[i][sx],
-//                                        left_edge, right_edge,
-//                                        lcal,
-//                                        &tmp_min_lambda,
-//                                        &tmp_max_lambda,
-//                                        fit_order,
-//                                        detector_nr,
-//                                        ifu_nr,
-//                                        slitlet_nr);
+                    int tmp_int = kmo_fit_spectrum_2(bad_pix, xarray[i][sx], 
+                            yarray[i][sx], larray[i][sx], left_edge, right_edge,
+                            lcal, &tmp_min_lambda, &tmp_max_lambda, pfitpars, 
+                            fit_order, pvalid_columns, 
+                            sx * max_nr_x_positions * (fit_order+1), 
+                            detector_nr, ifu_nr, slitlet_nr);
 
                     nr_valid_slitlets += tmp_int;
                     if ((ret_error != CPL_ERROR_NONE) ||
@@ -2207,9 +2111,7 @@ skip:
         KMO_TRY_EXIT_IF_ERROR(
             cpl_image_multiply(*lcal, bad_pix));
 
-        //
         // calculate global qc parameters on the whole detector frame
-        //
         tmp_qc1 = kmo_idl_where(qc_ar_flux, -1, ne);
         if (tmp_qc1 != NULL) {
             KMO_TRY_EXIT_IF_NULL(
@@ -2282,78 +2184,72 @@ skip:
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Extracts a wavelength profile of a slitlet from an arcframe.
-
-    @param data         The arc frame.
-    @param bad_pix      The associated bad pixel frame.
-    @param left_edge    The left edge of a slitlet along he y axis of the
-                        detector frame.
-    @param right_edge   The right edge of a slitlet along he y axis of the
-                        detector frame.
-    @param edge_offset  Offset to apply to the defined edge positions, to
-                        compensate the rotation of the detector frame.
-
-    @return
-        The extracted wavelength profile.
-
-    For each wavelength (y-direction) the median of all pixels between
-    left_edge + edge_offset and right_edge - edge_offset is calculated.
-
-    (Used in kmo_calc_wave_calib())
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero.
+  @brief Extracts a wavelength profile of a slitlet from an arcframe.
+  @param data         The arc frame.
+  @param bad_pix      The associated bad pixel frame.
+  @param left_edge    The left edge of a slitlet along he y axis of the
+                      detector frame.
+  @param right_edge   The right edge of a slitlet along he y axis of the
+                      detector frame.
+  @param edge_offset  Offset to apply to the defined edge positions, to
+                      compensate the rotation of the detector frame.
+  @return The extracted wavelength profile.
+
+  For each wavelength (y-direction) the median of all pixels between
+  left_edge + edge_offset and right_edge - edge_offset is calculated.
+  (Used in kmo_calc_wave_calib())
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero.
 */
-cpl_vector*     kmo_extract_initial_trace(const cpl_image *data,
-                                          const cpl_image *bad_pix,
-                                          const cpl_vector *left_edge,
-                                          const cpl_vector *right_edge,
-                                          const int edge_offset)
+/*----------------------------------------------------------------------------*/
+cpl_vector * kmo_extract_initial_trace(
+        const cpl_image     *   data,
+        const cpl_image     *   bad_pix,
+        const cpl_vector    *   left_edge,
+        const cpl_vector    *   right_edge,
+        const int               edge_offset)
 {
-    cpl_vector      *trace          = NULL,
-                    *my_tmp         = NULL,
-                    **tmp_array     = NULL;
-
-    double          *ptrace         = NULL,
-                    *pmy_tmp        = NULL;
-
-    const double    *pleft_edge     = NULL,
-                    *pright_edge    = NULL;
-
-    const float     *pdata          = NULL,
-                    *pbad_pix       = NULL;
-
-    int             k               = 0,
-                    i               = 0,
-                    j               = 0,
-                    nx              = 0,
-                    ny              = 0,
-                    my_right        = 0,
-                    my_left         = 0,
-                    offset          = edge_offset,
-                    nr_tmp          = 25;   // nr. of preallocated vectors
+    cpl_vector      *   trace       = NULL,
+                    *   my_tmp      = NULL,
+                    **  tmp_array   = NULL;
+    double          *   ptrace      = NULL,
+                    *   pmy_tmp     = NULL;
+
+    const double    *   pleft_edge  = NULL,
+                    *   pright_edge = NULL;
+
+    const float     *   pdata       = NULL,
+                    *   pbad_pix    = NULL;
+
+    int                 k           = 0,
+                        i           = 0,
+                        j           = 0,
+                        nx          = 0,
+                        ny          = 0,
+                        my_right    = 0,
+                        my_left     = 0,
+                        offset      = edge_offset,
+                        nr_tmp      = 25;   // nr. of preallocated vectors
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (bad_pix != NULL) &&
-                       (left_edge != NULL) &&
-                       (right_edge != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((data != NULL) && (bad_pix != NULL) &&
+                (left_edge != NULL) && (right_edge != NULL),
+                CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
 
-        KMO_TRY_ASSURE((nx == cpl_image_get_size_x(bad_pix)) &&
-                       (ny == cpl_image_get_size_y(bad_pix)) &&
-                       (ny == cpl_vector_get_size(left_edge)+2*KMOS_BADPIX_BORDER) &&
-                       (ny == cpl_vector_get_size(right_edge)+2*KMOS_BADPIX_BORDER),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Sizes of inputs don't match!");
+        KMO_TRY_ASSURE(
+                (nx == cpl_image_get_size_x(bad_pix)) &&
+                (ny == cpl_image_get_size_y(bad_pix)) &&
+                (ny == cpl_vector_get_size(left_edge)+2*KMOS_BADPIX_BORDER) &&
+                (ny == cpl_vector_get_size(right_edge)+2*KMOS_BADPIX_BORDER),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "Sizes of inputs don't match!");
 
         KMO_TRY_EXIT_IF_NULL(
             pdata = cpl_image_get_data_float_const(data));
@@ -2369,8 +2265,6 @@ cpl_vector*     kmo_extract_initial_trace(const cpl_image *data,
         cpl_vector_fill(trace, 0.0);
         KMO_TRY_EXIT_IF_NULL(
             ptrace = cpl_vector_get_data(trace));
-//cpl_vector_save(left_edge, "left_edge.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-//cpl_vector_save(right_edge, "right_edge.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
         // preallocatarray of 25 vectors of length 1 to 26
         // in order to calculate median in for-loop, is faster that way
         KMO_TRY_EXIT_IF_NULL(
@@ -2396,7 +2290,7 @@ cpl_vector*     kmo_extract_initial_trace(const cpl_image *data,
             if ((my_left<my_right) && (my_left != -1) && (my_right != -1)) {
                 // detemine which preallocated vector to use
                 if (my_right-my_left+1 > nr_tmp) {
-                    // huh, vector is so much tilted or bent that I need a larger vector
+                    // vector is so much tilted that I need a larger vector
                     my_tmp = cpl_vector_new(my_right-my_left+1);
                 } else {
                     my_tmp = tmp_array[my_right-my_left];
@@ -2436,39 +2330,34 @@ cpl_vector*     kmo_extract_initial_trace(const cpl_image *data,
     return trace;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-         Generate output to estimate line detection quality
-
-    Creates a plot, console output and files
-
-    @param trace_low    The low-pass filtered trace along the wavelength axis.
-    @param peak_pos     The identified candidate positions of lines.
-    @param peak_lambda  The candidate wavelengths of the linelist.
-    @param positions    The positions of the matched lines.
-    @param lambdas      The wavelengths of the matched lines.
-    @param dbg_detector_nr (Needed fort debugging only)
-    @param dbg_ifu_nr      (Needed fort debugging only)
-    @param dbg_slitlet_nr  (Needed fort debugging only)
-
-
-    @return
-        The function returns CPL_ERROR_NONE on success or a CPL error code
-        otherwise.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
-                                outputs isn't allocated.
+  @brief Generate output to estimate line detection quality
+  @param trace_low    The low-pass filtered trace along the wavelength axis.
+  @param peak_pos     The identified candidate positions of lines.
+  @param peak_lambda  The candidate wavelengths of the linelist.
+  @param positions    The positions of the matched lines.
+  @param lambdas      The wavelengths of the matched lines.
+  @param dbg_detector_nr (Needed fort debugging only)
+  @param dbg_ifu_nr      (Needed fort debugging only)
+  @param dbg_slitlet_nr  (Needed fort debugging only)
+  @return CPL_ERROR_NONE on success or a CPL error code otherwise.
+
+  Creates a plot, console output and files
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
+                              outputs isn't allocated.
 */
-cpl_error_code  debug_fitted_lines(const cpl_vector *trace_low,
-                                   const cpl_vector *peak_pos,
-                                   const cpl_vector *peak_lambda,
-                                   const cpl_vector *positions,
-                                   const cpl_vector *lambdas,
-                                   int dbg_detector_nr,
-                                   int dbg_ifu_nr,
-                                   int dbg_slitlet_nr)
+/*----------------------------------------------------------------------------*/
+cpl_error_code debug_fitted_lines(
+        const cpl_vector    *   trace_low,
+        const cpl_vector    *   peak_pos,
+        const cpl_vector    *   peak_lambda,
+        const cpl_vector    *   positions,
+        const cpl_vector    *   lambdas,
+        int                     dbg_detector_nr,
+        int                     dbg_ifu_nr,
+        int                     dbg_slitlet_nr)
 {
     int             nr_plots            = 4,
                     speak_pos           = 0,
@@ -2532,12 +2421,7 @@ cpl_error_code  debug_fitted_lines(const cpl_vector *trace_low,
 
         if (dbgplot)
         {
-//    kmo_plot_vector("set title \"trace\";", "w l;", trace);
-//    kmo_plot_vector("set title \"trace low-pass\";", "w l;", trace_low);
-
-            //
             // plot data with gnuplot
-            //
             KMO_TRY_EXIT_IF_NULL(
                 xx  = cpl_vector_duplicate(trace_low));
             KMO_TRY_EXIT_IF_NULL(
@@ -2647,28 +2531,29 @@ cpl_error_code  debug_fitted_lines(const cpl_vector *trace_low,
                         // position missed
                         if (!all_matched) {
                             pnon_matched[n] = ppeak_pos[ipeak_pos++];
-//                            cpl_msg_error("", ">>>match>>>%g", pnon_matched[n]);
+//                     cpl_msg_error("", ">>>match>>>%g", pnon_matched[n]);
                             n++;
                         }
-                    } else if ((ppeak_pos[ipeak_pos] < ppositions[ipositions]) &&
-                               (ppeak_lambda[ipeak_lambda] < plambdas[ipositions]))
-                    {
+                    } else if ((ppeak_pos[ipeak_pos]<ppositions[ipositions]) &&
+                            (ppeak_lambda[ipeak_lambda]<plambdas[ipositions])) {
                         // position AND line missed
                         if (!all_matched) {
                             pnon_matched[n] = ppeak_pos[ipeak_pos++];
-//                            cpl_msg_error("", ">>>match>>>%g", pnon_matched[n]);
+//                     cpl_msg_error("", ">>>match>>>%g", pnon_matched[n]);
                             n++;
                         }
                         if (!all_list) {
                             pnon_list[l] = ppeak_lambda[ipeak_lambda++];
-                            cpl_msg_warning("", "line non matched: %g", pnon_list[l]);
+                            cpl_msg_warning("", "line non matched: %g", 
+                                    pnon_list[l]);
                             l++;
                         }
                     } else {
                         // line missed
                         if (!all_list) {
                             pnon_list[l] = ppeak_lambda[ipeak_lambda++];
-                            cpl_msg_warning("", "line non matched: %g", pnon_list[l]);
+                            cpl_msg_warning("", "line non matched: %g", 
+                                    pnon_list[l]);
                             l++;
                         }
                     }
@@ -2712,7 +2597,7 @@ cpl_error_code  debug_fitted_lines(const cpl_vector *trace_low,
             }
 
             KMO_TRY_EXIT_IF_NULL(
-                plots[0] = cpl_bivector_wrap_vectors(xx, (cpl_vector*)trace_low));
+                plots[0]=cpl_bivector_wrap_vectors(xx, (cpl_vector*)trace_low));
             KMO_TRY_EXIT_IF_NULL(
                 plots[1] = cpl_bivector_wrap_vectors(xx, in_peaky));
             KMO_TRY_EXIT_IF_NULL(
@@ -2729,19 +2614,21 @@ cpl_error_code  debug_fitted_lines(const cpl_vector *trace_low,
                     "w p lc rgbcolor \"red\" t 'non-matched peaks'"};
             if (!all_matched) {
                 KMO_TRY_EXIT_IF_NULL(
-                    title = cpl_sprintf("set term x11; set title 'low_pass trace  "
-                                    "(# lines: list: %d, candidate: %d, matched: "
-                                    "%d) Det: %d, IFU: %d, slitlet: %d';",
-                                    speak_lambda, speak_pos, spositions,
-                                    dbg_detector_nr, dbg_ifu_nr, dbg_slitlet_nr));
+                    title = cpl_sprintf(
+                        "set term x11; set title 'low_pass trace  "
+                        "(# lines: list: %d, candidate: %d, matched: "
+                        "%d) Det: %d, IFU: %d, slitlet: %d';",
+                        speak_lambda, speak_pos, spositions,
+                        dbg_detector_nr, dbg_ifu_nr, dbg_slitlet_nr));
             } else {
                 nr_plots = 3;
                 KMO_TRY_EXIT_IF_NULL(
-                    title = cpl_sprintf("set term x11; set title 'low_pass trace  "
-                                    "(# lines: list: %d, candidate: %d) Det: %d, "
-                                    "IFU: %d, slitlet: %d';", speak_lambda,
-                                    speak_pos, dbg_detector_nr, dbg_ifu_nr,
-                                    dbg_slitlet_nr));
+                    title = cpl_sprintf(
+                        "set term x11; set title 'low_pass trace  "
+                        "(# lines: list: %d, candidate: %d) Det: %d, "
+                        "IFU: %d, slitlet: %d';", speak_lambda,
+                        speak_pos, dbg_detector_nr, dbg_ifu_nr,
+                        dbg_slitlet_nr));
             }
 
             KMO_TRY_EXIT_IF_ERROR(
@@ -2808,10 +2695,12 @@ cpl_error_code  debug_fitted_lines(const cpl_vector *trace_low,
                 else strcpy(cin_lam, "-");
 
                 if (same) {
-                    if (k_out < spositions) sprintf(cout_pos, "%g", ppositions[k_out]);
+                    if (k_out < spositions) 
+                        sprintf(cout_pos, "%g", ppositions[k_out]);
                     else strcpy(cout_pos, "-");
 
-                    if (k_out < slambdas) sprintf(cout_lam, "%g", plambdas[k_out]);
+                    if (k_out < slambdas) 
+                        sprintf(cout_lam, "%g", plambdas[k_out]);
                     else strcpy(cout_lam, "-");
 
                     k_out++;
@@ -2840,54 +2729,45 @@ cpl_error_code  debug_fitted_lines(const cpl_vector *trace_low,
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Matches given arclines to a wavelength profile.
-
-    @param trace           The given wavelength profile.
-    @param lines           Vector with the defined arclines. This vector has
-                           been generated with kmo_get_lines().
-    @param filter_id       The filter ID of this detector.
-    @param disp            The expected dispersion in wavelength.
-    @param positions       (Output) Matched positions.
-    @param lambdas         (Output) Matched wavelengths.
-    @param dbg_detector_nr (Needed fort debugging only)
-    @param dbg_ifu_nr      (Needed fort debugging only)
-    @param dbg_slitlet_nr  (Needed fort debugging only)
-
-    @return
-        The function returns CPL_ERROR_NONE on success or a CPL error code
-        otherwise.
-
-    First the positions of the peaks in @c trace are detected. Therefore the
-    trace is low-pass filtered and thresholded (peaks are only recognised if the
-    values between to peaks go below the threshold!) and the maximum values are
-    detected. To each of these preliminary positions a gaussfit is applied to
-    get the exact position.
-    Then a line pattern matching using cpl_ppm_match_positions() is performed.
-
-    (Used in kmo_calc_wave_calib())
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero.
+  @brief Matches given arclines to a wavelength profile.
+  @param trace           The given wavelength profile.
+  @param lines           Vector with the defined arclines. This vector has
+                         been generated with kmo_get_lines().
+  @param filter_id       The filter ID of this detector.
+  @param disp            The expected dispersion in wavelength.
+  @param positions       (Output) Matched positions.
+  @param lambdas         (Output) Matched wavelengths.
+  @param dbg_detector_nr (Needed fort debugging only)
+  @param dbg_ifu_nr      (Needed fort debugging only)
+  @param dbg_slitlet_nr  (Needed fort debugging only)
+  @return CPL_ERROR_NONE on success or a CPL error code otherwise.
+
+  First the positions of the peaks in @c trace are detected. Therefore the
+  trace is low-pass filtered and thresholded (peaks are only recognised if the
+  values between to peaks go below the threshold!) and the maximum values are
+  detected. To each of these preliminary positions a gaussfit is applied to
+  get the exact position.
+  Then a line pattern matching using cpl_ppm_match_positions() is performed.
+  (Used in kmo_calc_wave_calib())
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero.
 */
-cpl_error_code  kmo_estimate_lines(const cpl_vector *trace,
-                                   const cpl_vector *lines,
-                                   const char *filter_id,
-                                   double disp,
-                                   cpl_vector **positions,
-                                   cpl_vector **lambdas,
-                                   int dbg_detector_nr,
-                                   int dbg_ifu_nr,
-                                   int dbg_slitlet_nr,
-                                   const char *data_fits_name)
-{
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_estimate_lines(
+        const cpl_vector    *   trace,
+        const cpl_vector    *   lines,
+        const char          *   filter_id,
+        double                  disp,
+        cpl_vector          **  positions,
+        cpl_vector          **  lambdas,
+        int                     dbg_detector_nr,
+        int                     dbg_ifu_nr,
+        int                     dbg_slitlet_nr,
+        const char          *   data_fits_name) {
     cpl_error_code  ret_error   = CPL_ERROR_NONE;
-
     cpl_bivector    *matched_positions  = NULL;
-
-
     cpl_vector  *trace_low              = NULL,
                 *tmp_vec                = NULL,
                 *peak_pos               = NULL,
@@ -2919,13 +2799,10 @@ cpl_error_code  kmo_estimate_lines(const cpl_vector *trace,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((trace != NULL) &&
-                       (filter_id != NULL) &&
-                       (lines != NULL) &&
-                       (positions != NULL) &&
-                       (lambdas != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((trace != NULL) && (filter_id != NULL) &&
+                (lines != NULL) && (positions != NULL) && (lambdas != NULL),
+                CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         if (disp < 0.0) {
             if (strcmp(filter_id, "H") == 0) {
@@ -2955,9 +2832,10 @@ cpl_error_code  kmo_estimate_lines(const cpl_vector *trace,
         // signal will be low-pass filtered, values below stdev/3 are ignored
         KMO_TRY_EXIT_IF_NULL(
             trace_low = cpl_vector_filter_lowpass_create(trace,
-                                                      CPL_LOWPASS_GAUSSIAN, 27));
+                CPL_LOWPASS_GAUSSIAN, 27));
         if (data_fits_name != NULL) {
-            kmo_wave_write_data_vector(data_fits_name, trace_low, "low_pass_filtered_trace");
+            kmo_wave_write_data_vector(data_fits_name, trace_low, 
+                    "low_pass_filtered_trace");
         }
         KMO_TRY_EXIT_IF_NULL(
             ptrace_low = cpl_vector_get_data(trace_low));
@@ -3034,7 +2912,8 @@ cpl_error_code  kmo_estimate_lines(const cpl_vector *trace,
         }
 
         if (data_fits_name != NULL) {
-            kmo_wave_write_data_vector(data_fits_name, peak_pos, "peak_pos_gauss_corrected");
+            kmo_wave_write_data_vector(data_fits_name, peak_pos, 
+                    "peak_pos_gauss_corrected");
         }
 
         cpl_vector_delete(tmp_vec); tmp_vec = NULL;
@@ -3095,30 +2974,28 @@ cpl_error_code  kmo_estimate_lines(const cpl_vector *trace,
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Extracts the applicable lines from the line list table.
-
-    @param arclines        Table with the defined arclines. The table must
-                           consist of three columns of data: The 1st column
-                           contains the wavelengths of the arclines, the 2nd
-                           column contains the intensities of the arclines and
-                           the 3rd contains a string, either 'Ar' or 'Ne'
-                           designating the lamp the line belongs to. (Currently
-                           the intensities aren't used)
-    @param lamp_config     The Lamp configuration: Either ARGON, NEON or
-                           ARGON_NEON.
-
-    @return
-        The vector with the applicable lines.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
-                                outputs isn't allocated.
+  @brief Extracts the applicable lines from the line list table.
+  @param arclines        Table with the defined arclines. The table must
+                         consist of three columns of data: The 1st column
+                         contains the wavelengths of the arclines, the 2nd
+                         column contains the intensities of the arclines and
+                         the 3rd contains a string, either 'Ar' or 'Ne'
+                         designating the lamp the line belongs to. (Currently
+                         the intensities aren't used)
+  @param lamp_config     The Lamp configuration: Either ARGON, NEON or
+                         ARGON_NEON.
+  @return The vector with the applicable lines.
+ 
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
+                              outputs isn't allocated.
 */
-cpl_bivector*  kmo_get_lines(const cpl_table *arclines,
-                           enum lampConfiguration lamp_config)
+/*----------------------------------------------------------------------------*/
+cpl_bivector * kmo_get_lines(
+        const cpl_table     *   arclines,
+        enum lampConfiguration  lamp_config)
 {
     double      *plines                 = NULL;
     double      *pstrength              = NULL;
@@ -3131,8 +3008,7 @@ cpl_bivector*  kmo_get_lines(const cpl_table *arclines,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(arclines != NULL,
-                       CPL_ERROR_NULL_INPUT,
+        KMO_TRY_ASSURE(arclines != NULL, CPL_ERROR_NULL_INPUT,
                        "Not all input data is provided!");
 
         // get column "gas"
@@ -3159,16 +3035,14 @@ cpl_bivector*  kmo_get_lines(const cpl_table *arclines,
             size = cpl_table_get_nrow(arclines);
             break;
         default:
-            KMO_TRY_ASSURE(1==0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Unknown lamp configuration! (Ar, Ne or Ar+Ne expected)");
+            KMO_TRY_ASSURE(1==0, CPL_ERROR_ILLEGAL_INPUT,
+                    "Unknown lamp configuration! (Ar, Ne or Ar+Ne expected)");
         }
 
-        KMO_TRY_ASSURE(size > 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "No lines have been found in the list for the detected "
-                       "arc lamp configuration! Did you provide the correct arc"
-                       " line list?");
+        KMO_TRY_ASSURE(size > 0, CPL_ERROR_ILLEGAL_INPUT,
+                "No lines have been found in the list for the detected "
+                "arc lamp configuration! Did you provide the correct arc"
+                " line list?");
 
         // create & fill vector
         KMO_TRY_EXIT_IF_NULL(
@@ -3180,7 +3054,8 @@ cpl_bivector*  kmo_get_lines(const cpl_table *arclines,
        KMO_TRY_EXIT_IF_NULL(
              pwave_line = cpl_table_get_data_float_const(arclines, WAVE_COL));
         KMO_TRY_EXIT_IF_NULL(
-             pstrength_line = cpl_table_get_data_float_const(arclines, STRE_COL));
+             pstrength_line = 
+             cpl_table_get_data_float_const(arclines, STRE_COL));
         size = 0;
         switch (lamp_config) {
         case ARGON:
@@ -3208,9 +3083,8 @@ cpl_bivector*  kmo_get_lines(const cpl_table *arclines,
          }
             break;
         default:
-            KMO_TRY_ASSURE(1==0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Unknown lamp configuration! (Ar, Ne or Ar+Ne expected)");
+            KMO_TRY_ASSURE(1==0, CPL_ERROR_ILLEGAL_INPUT,
+                    "Unknown lamp configuration! (Ar, Ne or Ar+Ne expected)");
         }
     }
     KMO_CATCH
@@ -3222,81 +3096,78 @@ cpl_bivector*  kmo_get_lines(const cpl_table *arclines,
     return lines;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculates the exact positions of arclines based on estimates.
-
-    @param data       The image data.
-    @param bad_pix    The bad pixel mask.
-    @param positions  Estimated positions of the lines.
-    @param lambdas    Wavelengths of the lines.
-    @param left_edge  The left edge of a slitlet along he y axis of the
-                      detector frame.
-    @param right_edge The right edge of a slitlet along he y axis of the
-                      detector frame.
-    @param xarray     (Output) Vector containing absolute indices to the
-                      detector frame
-    @param yarray     (Output) Array containing the exact positions for all
-                      matched lines (in @c kmo_estimate_lines ) at each of the
-                      x-positions defined in @c xarray
-    @param larray     (Output) Vector containing the corresponding wavelengths
-    @param qc_vec     (Output) Vector containing qc parameters calculated for
-                      the processed slitlet:
-                      qc_vec[0] = argon fwhm
-                      qc_vec[1] = argon flux
-                      qc_vec[2] = neon fwhm
-                      qc_vec[3] = neon flux
-    @param dbg_detector_nr (Needed fort debugging only)
-    @param dbg_ifu_nr      (Needed fort debugging only)
-    @param dbg_slitlet_nr  (Needed fort debugging only)
-
-    @return
-        The function returns CPL_ERROR_NONE on success or a CPL error code
-        otherwise.
-
-    The exact position of the arclines is calculated based on estimated
-    positions.
-    - First a gauss is fitted to every arcline at each x-position to get the
-      effective position in the visible part of the slitlet. At this stage
-      already some QC parameters are collected regarding the quality of the
-      fits (sigma & flux) at the reference argon and neon line.
-    Since the slitlet can be tilted and we want to fit a polynomial in
-    wavelength direction later on, we would have only few data points at one
-    edge at the bottom and the top. For this we extrapolate the exact arcline
-    positions in x-direction to get a rectangular grid.
-    - This is done using rejection on the exact data points, fitting a
-      polynomial in x-direction, subtracting the fitted values from the
-      original ones, rejecting again, fitting again a polynomial, subtracting
-      again. If the standard deviation of this operation is small enough, we
-      apply the fitted polynomial to our rectangular grid otherwise the values
-      are set to -1. At this stage again some QC parameters are calculated
-      regarding the FWHM and flux of our reference argon and neon lines.
-
-    (Used in kmo_calc_wave_calib())
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
-                                outputs isn't allocated.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c positions and @c lambdas haven't the same
-                                size or if @c left_edge is greater than
-                                @c right_edge
+  @brief Calculates the exact positions of arclines based on estimates.
+  @param data       The image data.
+  @param bad_pix    The bad pixel mask.
+  @param positions  Estimated positions of the lines.
+  @param lambdas    Wavelengths of the lines.
+  @param left_edge  The left edge of a slitlet along he y axis of the
+                    detector frame.
+  @param right_edge The right edge of a slitlet along he y axis of the
+                    detector frame.
+  @param xarray     (Output) Vector containing absolute indices to the
+                    detector frame
+  @param yarray     (Output) Array containing the exact positions for all
+                    matched lines (in @c kmo_estimate_lines ) at each of the
+                    x-positions defined in @c xarray
+  @param larray     (Output) Vector containing the corresponding wavelengths
+  @param qc_vec     (Output) Vector containing qc parameters calculated for
+                    the processed slitlet:
+                    qc_vec[0] = argon fwhm
+                    qc_vec[1] = argon flux
+                    qc_vec[2] = neon fwhm
+                    qc_vec[3] = neon flux
+  @param dbg_detector_nr (Needed fort debugging only)
+  @param dbg_ifu_nr      (Needed fort debugging only)
+  @param dbg_slitlet_nr  (Needed fort debugging only)
+
+  @return CPL_ERROR_NONE on success or a CPL error code otherwise.
+
+  The exact position of the arclines is calculated based on estimated
+  positions.
+  - First a gauss is fitted to every arcline at each x-position to get the
+    effective position in the visible part of the slitlet. At this stage
+    already some QC parameters are collected regarding the quality of the
+    fits (sigma & flux) at the reference argon and neon line.
+  Since the slitlet can be tilted and we want to fit a polynomial in
+  wavelength direction later on, we would have only few data points at one
+  edge at the bottom and the top. For this we extrapolate the exact arcline
+  positions in x-direction to get a rectangular grid.
+  - This is done using rejection on the exact data points, fitting a
+    polynomial in x-direction, subtracting the fitted values from the
+    original ones, rejecting again, fitting again a polynomial, subtracting
+    again. If the standard deviation of this operation is small enough, we
+    apply the fitted polynomial to our rectangular grid otherwise the values
+    are set to -1. At this stage again some QC parameters are calculated
+    regarding the FWHM and flux of our reference argon and neon lines.
+  (Used in kmo_calc_wave_calib())
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
+                              outputs isn't allocated.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c positions and @c lambdas haven't the same
+                              size or if @c left_edge is greater than
+                              @c right_edge
 */
-cpl_error_code  kmo_extrapolate_arclines(const cpl_image *data,
-                                         const cpl_image *bad_pix,
-                                         const cpl_vector *positions,
-                                         const cpl_vector *lambdas,
-                                         const cpl_vector *left_edge,
-                                         const cpl_vector *right_edge,
-                                         cpl_vector **xarray,
-                                         cpl_image **yarray,
-                                         kmclipm_vector **larray,
-                                         cpl_vector **qc_vec,
-                                         int dbg_detector_nr,
-                                         int dbg_ifu_nr,
-                                         int dbg_slitlet_nr,
-                                         const char *filter_id,
-                                         enum lampConfiguration lamp_config)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_extrapolate_arclines(
+        const cpl_image     *   data,
+        const cpl_image     *   bad_pix,
+        const cpl_vector    *   positions,
+        const cpl_vector    *   lambdas,
+        const cpl_vector    *   left_edge,
+        const cpl_vector    *   right_edge,
+        cpl_vector          **  xarray,
+        cpl_image           **  yarray,
+        kmclipm_vector      **  larray,
+        cpl_vector          **  qc_vec,
+        int                     dbg_detector_nr,
+        int                     dbg_ifu_nr,
+        int                     dbg_slitlet_nr,
+        const char          *   filter_id,
+        enum lampConfiguration  lamp_config)
 {
     cpl_error_code      ret_error           = CPL_ERROR_NONE;
     cpl_vector          *good               = NULL,
@@ -3338,32 +3209,22 @@ cpl_error_code  kmo_extrapolate_arclines(const cpl_image *data,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (bad_pix != NULL) &&
-                       (positions != NULL) &&
-                       (lambdas != NULL) &&
-                       (xarray != NULL) &&
-                       (yarray != NULL) &&
-                       (larray != NULL) &&
-                       (qc_vec != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((data != NULL) && (bad_pix != NULL) && 
+                (positions != NULL) && (lambdas != NULL) && (xarray != NULL) &&
+                (yarray != NULL) && (larray != NULL) && (qc_vec != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
-        KMO_TRY_ASSURE((*xarray != NULL) &&
-                       (*yarray != NULL) &&
-                       (*larray != NULL) &&
-                       (*qc_vec != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is allocated!");
+        KMO_TRY_ASSURE((*xarray != NULL) && (*yarray != NULL) && 
+                (*larray != NULL) && (*qc_vec != NULL), CPL_ERROR_NULL_INPUT,
+                "Not all input data is allocated!");
 
-        KMO_TRY_ASSURE(cpl_vector_get_size(positions) ==
-                                                 cpl_vector_get_size(lambdas),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "vectors of positions and lambdas don't have same size!");
+        KMO_TRY_ASSURE(
+                cpl_vector_get_size(positions) == cpl_vector_get_size(lambdas),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "vectors of positions and lambdas don't have same size!");
 
         // get band dependen reference arc lines
-        if ((lamp_config == ARGON) ||
-            (lamp_config == ARGON_NEON))
+        if ((lamp_config == ARGON) || (lamp_config == ARGON_NEON))
         {
             if (strcmp(filter_id, "H") == 0) {
                 ref_wavelength_ar = REF_LINE_AR_H;
@@ -3378,8 +3239,7 @@ cpl_error_code  kmo_extrapolate_arclines(const cpl_image *data,
             }
         }
 
-        if ((lamp_config == NEON) ||
-            (lamp_config == ARGON_NEON))
+        if ((lamp_config == NEON) || (lamp_config == ARGON_NEON))
         {
             if (strcmp(filter_id, "H") == 0) {
                 ref_wavelength_ne = REF_LINE_NE_H;
@@ -3415,10 +3275,8 @@ cpl_error_code  kmo_extrapolate_arclines(const cpl_image *data,
         for (j = 0; j < nx_yarray; j++) {
             pxarray[j] = tmp_int + j;
         }
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_image_fill(*yarray, -1.0));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_vector_fill(*qc_vec, -1.0));
+        KMO_TRY_EXIT_IF_ERROR(kmo_image_fill(*yarray, -1.0));
+        KMO_TRY_EXIT_IF_ERROR(cpl_vector_fill(*qc_vec, -1.0));
 
         // each arcline is traced across the slitlet:
         // fit a vertical gauss curve for each arcline at each x-pos of the
@@ -3447,7 +3305,8 @@ cpl_error_code  kmo_extrapolate_arclines(const cpl_image *data,
                 if (kmclipm_vector_is_rejected(yline, i)) {
                     cpl_image_reject(*yarray, i+1, i_arc+1) ;
                 } else {
-                    cpl_image_set(*yarray, i+1, i_arc+1, kmclipm_vector_get(yline, i, NULL));
+                    cpl_image_set(*yarray, i+1, i_arc+1, 
+                            kmclipm_vector_get(yline, i, NULL));
                 }
             }
 
@@ -3502,21 +3361,21 @@ cpl_error_code  kmo_extrapolate_arclines(const cpl_image *data,
 
             // crop same range of xarray, reject same values as in tmp_yarr
             KMO_TRY_EXIT_IF_NULL(
-                tmp_xarr = kmclipm_vector_create(cpl_vector_duplicate(*xarray)));
+                tmp_xarr=kmclipm_vector_create(cpl_vector_duplicate(*xarray)));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_vector_reject_from_mask(tmp_xarr,
-                                                kmclipm_vector_get_bpm(tmp_yarr),
-                                                TRUE));
+                    kmclipm_vector_get_bpm(tmp_yarr), TRUE));
             KMO_TRY_EXIT_IF_NULL(
                 tmp_xarr2 = kmclipm_vector_create_non_rejected(tmp_xarr));
 
             KMO_TRY_CHECK_ERROR_STATE();
-            KMO_TRY_ASSURE((kmclipm_vector_get_min(tmp_xarr, NULL) >= KMOS_BADPIX_BORDER) &&
-                           (kmclipm_vector_get_max(tmp_xarr, NULL) < KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER+1),
-                           CPL_ERROR_NULL_INPUT,
-                           "xarray: indices outside frame! (min: %g, max: %g)",
-                           kmclipm_vector_get_min(tmp_xarr, NULL),
-                           kmclipm_vector_get_max(tmp_xarr, NULL));
+            KMO_TRY_ASSURE(
+                (kmclipm_vector_get_min(tmp_xarr, NULL)>=KMOS_BADPIX_BORDER) &&
+                (kmclipm_vector_get_max(tmp_xarr, NULL) < KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER+1),
+                CPL_ERROR_NULL_INPUT,
+                "xarray: indices outside frame! (min: %g, max: %g)",
+                kmclipm_vector_get_min(tmp_xarr, NULL),
+                kmclipm_vector_get_max(tmp_xarr, NULL));
 
             // fit a polynomial to the line of yarray
             KMO_TRY_EXIT_IF_NULL(
@@ -3533,8 +3392,7 @@ cpl_error_code  kmo_extrapolate_arclines(const cpl_image *data,
                 yfit = kmclipm_vector_new(kmclipm_vector_get_size(tmp_yarr)));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_vector_reject_from_mask(yfit,
-                                                kmclipm_vector_get_bpm(tmp_yarr),
-                                                TRUE));
+                    kmclipm_vector_get_bpm(tmp_yarr), TRUE));
 
             for (i = 0; i < kmclipm_vector_get_size(tmp_yarr); i++) {
                 if (!kmclipm_vector_is_rejected(yfit, i)) {
@@ -3561,20 +3419,18 @@ cpl_error_code  kmo_extrapolate_arclines(const cpl_image *data,
 
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_vector_reject_from_mask(tmp_yarr,
-                                                kmclipm_vector_get_bpm(yfit),
-                                                TRUE));
+                    kmclipm_vector_get_bpm(yfit), TRUE));
             KMO_TRY_EXIT_IF_NULL(
                 tmp_yarr2 = kmclipm_vector_create_non_rejected(tmp_yarr));
 
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_vector_reject_from_mask(tmp_xarr,
-                                                kmclipm_vector_get_bpm(yfit),
-                                                TRUE));
+                    kmclipm_vector_get_bpm(yfit), TRUE));
             KMO_TRY_EXIT_IF_NULL(
                 tmp_xarr2 = kmclipm_vector_create_non_rejected(tmp_xarr));
 
             // fit again a polynomial
-cpl_vector *dbg_ggg = cpl_vector_duplicate(tmp_yarr2);
+            cpl_vector *dbg_ggg = cpl_vector_duplicate(tmp_yarr2);
             KMO_TRY_EXIT_IF_NULL(
                 fit_par = kmo_polyfit_1d(tmp_xarr2, tmp_yarr2, poly_degree));
 
@@ -3600,17 +3456,12 @@ cpl_vector *dbg_ggg = cpl_vector_duplicate(tmp_yarr2);
             stddev = kmclipm_vector_get_stdev(tmp_yarr);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            //if (stddev < 0.1) {  // was too low for real lab data on edges of detector
             if (stddev < 0.5) {
-//cpl_msg_debug(">>>","OK     Det: %d, IFU: %d, slitlet: %d, arcline: %d (stdev: %g)",
-//              dbg_detector_nr, dbg_ifu_nr, dbg_slitlet_nr, i_arc+1, stddev);
-                // now calculate fitted values over whole, tilted slitlet width
-                // overwrite yarray with fitted yfit-values
-                // --> write yarray with extrapolated (in x-direction),fitted values
                 for (i = 0; i < nx_yarray; i++) {
                     pyarray[i+i_arc*nx_yarray] = 0.0;
                     for(k = 0; k < cpl_vector_get_size(fit_par); k++) {
-                        pyarray[i+i_arc*nx_yarray] += pfit_par[k] * pow(pxarray[i], k);
+                        pyarray[i+i_arc*nx_yarray] += 
+                            pfit_par[k] * pow(pxarray[i], k);
                     }
                 }
 
@@ -3624,10 +3475,9 @@ cpl_vector *dbg_ggg = cpl_vector_duplicate(tmp_yarr2);
                     // calc fwhm of reference argon line
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_vector_reject_from_mask(ar_sline,
-                                                        kmclipm_vector_get_bpm(yfit),
-                                                        TRUE));
+                            kmclipm_vector_get_bpm(yfit), TRUE));
 
-                    fwhm = CPL_MATH_FWHM_SIG * kmclipm_vector_get_mean(ar_sline);
+                    fwhm = CPL_MATH_FWHM_SIG*kmclipm_vector_get_mean(ar_sline);
 
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_vector_set(*qc_vec, 0, fwhm));
@@ -3635,12 +3485,11 @@ cpl_vector *dbg_ggg = cpl_vector_duplicate(tmp_yarr2);
                     // calc flux of reference argon line
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_vector_reject_from_mask(ar_fline,
-                                                        kmclipm_vector_get_bpm(yfit),
-                                                        TRUE));
+                            kmclipm_vector_get_bpm(yfit), TRUE));
 
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_vector_set(*qc_vec, 1,
-                                       kmclipm_vector_get_mean(ar_fline) * fwhm));
+                            kmclipm_vector_get_mean(ar_fline) * fwhm));
 
                     kmclipm_vector_delete(ar_sline); ar_sline = NULL;
                     kmclipm_vector_delete(ar_fline); ar_fline = NULL;
@@ -3651,10 +3500,8 @@ cpl_vector *dbg_ggg = cpl_vector_duplicate(tmp_yarr2);
                     // calc fwhm of reference neon line
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_vector_reject_from_mask(ne_sline,
-                                                        kmclipm_vector_get_bpm(yfit),
-                                                        TRUE));
-
-                    fwhm = CPL_MATH_FWHM_SIG * kmclipm_vector_get_mean(ne_sline);
+                            kmclipm_vector_get_bpm(yfit), TRUE));
+                    fwhm = CPL_MATH_FWHM_SIG*kmclipm_vector_get_mean(ne_sline);
 
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_vector_set(*qc_vec, 2, fwhm));
@@ -3662,12 +3509,11 @@ cpl_vector *dbg_ggg = cpl_vector_duplicate(tmp_yarr2);
                     // calc flux of reference neon line
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_vector_reject_from_mask(ne_fline,
-                                                        kmclipm_vector_get_bpm(yfit),
-                                                        TRUE));
+                            kmclipm_vector_get_bpm(yfit), TRUE));
 
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_vector_set(*qc_vec, 3,
-                                       kmclipm_vector_get_mean(ne_fline) * fwhm));
+                            kmclipm_vector_get_mean(ne_fline) * fwhm));
 
                     kmclipm_vector_delete(ne_sline); ne_sline = NULL;
                     kmclipm_vector_delete(ne_fline); ne_fline = NULL;
@@ -3760,56 +3606,50 @@ cpl_vector_delete(dbg_ggg); dbg_ggg=NULL;
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Fits a gauss to each valid pixel of an arcline, starting from the middle
-        of the slitlet.
-
-    @param left_edge  The left edge of the slitlet at @c ypos .
-    @param right_edge The right edge of the slitlet at @c ypos .
-    @param ypos       y-position of the arcline we are examining.
-    @param min_left_edge The left-most poition of the overall left edge. Needed
-                      to get formatting of ylines correctly.
-    @param data       The image data.
-    @param badpix     The bad pixel mask.
-    @param yline      (Output) The fitted y-positions of the valid pixels
-                      according to the bad pixel mask.
-    @param sline      (Output) The sigmas of the fitted values.
-    @param fline      (Output) The fluxes of the fitted values.
-
-    @return
-        The function returns CPL_ERROR_NONE on success or a CPL error code
-        otherwise.
-
-    First all output vectors are filled with -1. A -1 in the final result will
-    denote an invalid pixel.
-    Then we move from the left edge to the right edge and fit a gauss
-    function to every x-position, as long as there are enough good pixels.
-    The gauss is fitted in a range of +/- 6 pixels in y-direction.
-    For each fit the calculated sigma and flux is recorded.
-    The resulting output vectors will contain -1 at the left and/or right edges
-    according to the rotation of the slitlet. These missing values will be
-    extrapolated in @c kmo_extrapolate_arclines .
-
-    (Used in kmo_extrapolate_arclines())
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
-                                outputs isn't allocated.
+  @brief Fits a gauss to each valid pixel of an arcline, starting from the 
+        middle of the slitlet.
+  @param left_edge  The left edge of the slitlet at @c ypos .
+  @param right_edge The right edge of the slitlet at @c ypos .
+  @param ypos       y-position of the arcline we are examining.
+  @param min_left_edge The left-most poition of the overall left edge. Needed
+                    to get formatting of ylines correctly.
+  @param data       The image data.
+  @param badpix     The bad pixel mask.
+  @param yline      (Output) The fitted y-positions of the valid pixels
+                    according to the bad pixel mask.
+  @param sline      (Output) The sigmas of the fitted values.
+  @param fline      (Output) The fluxes of the fitted values.
+  @return CPL_ERROR_NONE on success or a CPL error code otherwise.
+
+  First all output vectors are filled with -1. A -1 in the final result will
+  denote an invalid pixel.
+  Then we move from the left edge to the right edge and fit a gauss
+  function to every x-position, as long as there are enough good pixels.
+  The gauss is fitted in a range of +/- 6 pixels in y-direction.
+  For each fit the calculated sigma and flux is recorded.
+  The resulting output vectors will contain -1 at the left and/or right edges
+  according to the rotation of the slitlet. These missing values will be
+  extrapolated in @c kmo_extrapolate_arclines .
+  (Used in kmo_extrapolate_arclines())
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
+                              outputs isn't allocated.
 */
-cpl_error_code  kmo_fit_arcline(const int left_edge,
-                                const int right_edge,
-                                const int ypos,
-                                const int min_left_edge,
-                                const cpl_image *data,
-                                const cpl_image *badpix,
-                                kmclipm_vector **yline,
-                                kmclipm_vector **sline,
-                                kmclipm_vector **fline)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_fit_arcline(
+        const int           left_edge,
+        const int           right_edge,
+        const int           ypos,
+        const int           min_left_edge,
+        const cpl_image *   data,
+        const cpl_image *   badpix,
+        kmclipm_vector  **  yline,
+        kmclipm_vector  **  sline,
+        kmclipm_vector  **  fline)
 {
     cpl_error_code  ret_error   = CPL_ERROR_NONE;
-
     cpl_vector      *yvec       = NULL,
                     *bvec       = NULL,
                     *fvec       = NULL,
@@ -3828,28 +3668,20 @@ cpl_error_code  kmo_fit_arcline(const int left_edge,
     const float     *pdata      = NULL,
                     *pbadpix    = NULL;
 
-//    int             len         = 6,
     int             len         = 4,
                     nx          = 0,
-//                    doitonce    = FALSE,
                     tmp_int     = 0,
                     i = 0, ix = 0, iy = 0;
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((data != NULL) &&
-                       (badpix != NULL) &&
-                       (yline != NULL) &&
-                       (sline != NULL) &&
-                       (fline != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((data != NULL) && (badpix != NULL) && (yline != NULL) &&
+                (sline != NULL) && (fline != NULL), CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
-        KMO_TRY_ASSURE((*yline != NULL) &&
-                       (*sline != NULL) &&
-                       (*fline != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is allocated!");
+        KMO_TRY_ASSURE((*yline != NULL) && (*sline != NULL) && (*fline != NULL),
+                CPL_ERROR_NULL_INPUT,
+                "Not all input data is allocated!");
 
         KMO_TRY_EXIT_IF_ERROR(
             kmclipm_vector_fill(*yline, -1.0));
@@ -3895,38 +3727,23 @@ cpl_error_code  kmo_fit_arcline(const int left_edge,
             good = kmo_idl_where(bvec, 0.5, gt);
             KMO_TRY_CHECK_ERROR_STATE();
 
-//            // override: For science grade detectors the arcline can't be fitted
-//            // because there are so many pixels flagged as bad. Anyway on the arc
-//            // frame the lines can be seen visually perfectly, so fit anyway and
-//            // give a warning
-//            if ((good != NULL) & (cpl_vector_get_size(good) <= len + 1)) {
-//                doitonce=TRUE;
-//                cpl_msg_warning(cpl_func, "Too much bad pixels! "
-//                                          "Is this a science grade detector?");
-//            }
-
-//            if (doitonce ||
-//               ((good != NULL) && (cpl_vector_get_size(good) > len + 1)))
-//            {
-            if (good != NULL)
-            {
+            if (good != NULL) {
                 yvec_good = kmo_idl_values_at_indices(yvec, good);
                 fvec_good = kmo_idl_values_at_indices(fvec, good);
 
                 cpl_vector_delete(good); good = NULL;
 
                 ret_error = kmo_easy_gaussfit(yvec_good, fvec_good,
-                                              &x0, &sigma, &area, &offset);
+                        &x0, &sigma, &area, &offset);
 
                 tmp_int = ix-min_left_edge;
                 if (ret_error == CPL_ERROR_NONE) {
-                    if ((tmp_int >= 0) && (tmp_int < kmclipm_vector_get_size(*yline))) {
-                        kmclipm_vector_set(*yline, tmp_int,
-                                           x0);
-                        kmclipm_vector_set(*sline, tmp_int,
-                                           sigma);
+                    if ((tmp_int >= 0) && 
+                            (tmp_int < kmclipm_vector_get_size(*yline))) {
+                        kmclipm_vector_set(*yline, tmp_int, x0);
+                        kmclipm_vector_set(*sline, tmp_int, sigma);
                         kmclipm_vector_set(*fline, tmp_int,
-                                           area/(sqrt(CPL_MATH_2PI)*sigma)+offset);
+                                area/(sqrt(CPL_MATH_2PI)*sigma)+offset);
                     }
                 } else {
                     // gauss couldn't be calculated at this position,
@@ -3969,75 +3786,69 @@ cpl_error_code  kmo_fit_arcline(const int left_edge,
     return ret_error;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Fits polynomials in wavelength direction to a whole slitlet.
-
-    @param bad_pix      The bad pixel mask.
-    @param xarray       Vector containing absolute indices to the detector
-                        frame.
-    @param yarray       Array containing the exact positions for all matched
-                        lines at each of the x-positions defined in @c xarray
-    @param larray       Vector containing the corresponding wavelengths.
-    @param left_edge    The left edge of a slitlet along he y axis of the
-                        detector frame.
-    @param right_edge   The right edge of a slitlet along he y axis of the
-                        detector frame.
-    @param lcal         (Input/Output) Contains a pointer to the final
-                        wavelength calibration frame. It will be updated slitlet
-                        by slitlet.
-    @param min_lambda   (Input/Output) Keeps track of the minimum wavelength in
-                        the whole processed frame.
-    @param max_lambda   (Input/Output) Keeps track of the maximum wavelength in
-                        the whole processed frame.
-    @param fit_order    Polynomial order of the wavelength solution.
-    @param fit_order    Polynomial order of the wavelength solution.
-    @param dbg_detector_nr (Needed fort debugging only)
-    @param dbg_ifu_nr      (Needed fort debugging only)
-    @param dbg_slitlet_nr  (Needed fort debugging only)
-
-    @return
-        The function returns TRUE if the slitlet has at least one valid pixel
-        which could have been wavelength calibrated, FALSE otherwise.
-
-    For each x-position between @c side1 and @c side2, a polynomial will be
-    fitted in wavelength direction.
-    For all valid pixels according to @c bad_pix, the resulting values will be
-    written into @c lcal. (To be precise: the value is only written if it really
-    belongs to the actual slitlet, since the rotation can be so strong, we could
-    accidentally write values at positions belonging to a neighbouring slitlet.
-    To avois this, we comare @c ifu_id with the values in @c xcal and @c ycal at
-    currently processed positions.)
-    The fitting procedure is as follows we fit the values, subtrat the fitted
-    values from the original ones, reject deviant values and fit again.
-    For all valid columns (at least one pixel has been written to @c lcal after
-    checking @c bad_pix, @c xcal and @c ycal) we calculate some QC parameters
-    (see description of @c qc_vec ).
-
-    (Used in kmo_calc_wave_calib())
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
-                                outputs isn't allocated.
-    @li CPL_ERROR_ILLEGAL_INPUT if tghe dimensions of @c xarray, @c yarray and
-                                @c larray don't match.
+  @brief Fits polynomials in wavelength direction to a whole slitlet.
+  @param bad_pix      The bad pixel mask.
+  @param xarray       Vector containing absolute indices to the detector frame.
+  @param yarray       Array containing the exact positions for all matched
+                      lines at each of the x-positions defined in @c xarray
+  @param larray       Vector containing the corresponding wavelengths.
+  @param left_edge    The left edge of a slitlet along he y axis of the
+                      detector frame.
+  @param right_edge   The right edge of a slitlet along he y axis of the
+                      detector frame.
+  @param lcal         (Input/Output) Contains a pointer to the final
+                      wavelength calibration frame. It will be updated slitlet
+                      by slitlet.
+  @param min_lambda   (Input/Output) Keeps track of the minimum wavelength in
+                      the whole processed frame.
+  @param max_lambda   (Input/Output) Keeps track of the maximum wavelength in
+                      the whole processed frame.
+  @param fit_order    Polynomial order of the wavelength solution.
+  @param fit_order    Polynomial order of the wavelength solution.
+  @param dbg_detector_nr (Needed fort debugging only)
+  @param dbg_ifu_nr      (Needed fort debugging only)
+  @param dbg_slitlet_nr  (Needed fort debugging only)
+
+  @return TRUE if the slitlet has at least one valid pixel which could 
+          have been wavelength calibrated, FALSE otherwise.
+
+  For each x-position between @c side1 and @c side2, a polynomial will be
+  fitted in wavelength direction.
+  For all valid pixels according to @c bad_pix, the resulting values will be
+  written into @c lcal. (To be precise: the value is only written if it really
+  belongs to the actual slitlet, since the rotation can be so strong, we could
+  accidentally write values at positions belonging to a neighbouring slitlet.
+  To avois this, we comare @c ifu_id with the values in @c xcal and @c ycal at
+  currently processed positions.)
+  The fitting procedure is as follows we fit the values, subtrat the fitted
+  values from the original ones, reject deviant values and fit again.
+  For all valid columns (at least one pixel has been written to @c lcal after
+  checking @c bad_pix, @c xcal and @c ycal) we calculate some QC parameters
+  (see description of @c qc_vec ).
+  (Used in kmo_calc_wave_calib())
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if any of the inputs is zero or any of the
+                              outputs isn't allocated.
+  @li CPL_ERROR_ILLEGAL_INPUT if tghe dimensions of @c xarray, @c yarray and
+                              @c larray don't match.
 */
-int  kmo_fit_spectrum(const cpl_image *bad_pix,
-                      const cpl_vector *xarray,
-                      const cpl_image *yarray,
-                      const cpl_vector *larray,
-                      const cpl_vector *left_edge,
-                      const cpl_vector *right_edge,
-                      cpl_image **lcal,
-                      double *min_lambda,
-                      double *max_lambda,
-//                      cpl_image *unroll_lcal,
-//                      int unroll_lcal_cnt,
-                      const int fit_order,
-                      int dbg_detector_nr,
-                      int dbg_ifu_nr,
-                      int dbg_slitlet_nr)
+/*----------------------------------------------------------------------------*/
+int kmo_fit_spectrum(
+        const cpl_image     *   bad_pix,
+        const cpl_vector    *   xarray,
+        const cpl_image     *   yarray,
+        const cpl_vector    *   larray,
+        const cpl_vector    *   left_edge,
+        const cpl_vector    *   right_edge,
+        cpl_image           **  lcal,
+        double              *   min_lambda,
+        double              *   max_lambda,
+        const int               fit_order,
+        int                     dbg_detector_nr,
+        int                     dbg_ifu_nr,
+        int                     dbg_slitlet_nr)
 {
     int             l               = 0,
                     lsize           = 0,
@@ -4045,7 +3856,8 @@ int  kmo_fit_spectrum(const cpl_image *bad_pix,
                     nx              = 0,
                     ny              = 0,
                     valid_column    = FALSE,
-                    valid_slitlet   = FALSE, // TRUE for at least one valid column
+                     /* TRUE for at least one valid column */
+                    valid_slitlet   = FALSE, 
                     order_first_try = 0,
                     ix = 0, iy = 0, k = 0, j= 0;
     cpl_vector      *yvec           = NULL,
@@ -4081,16 +3893,12 @@ int  kmo_fit_spectrum(const cpl_image *bad_pix,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((xarray != NULL) &&
-                       (yarray != NULL) &&
-                       (larray != NULL) &&
-                       (lcal != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((xarray != NULL) && (yarray != NULL) && (larray != NULL)
+                && (lcal != NULL), CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
-        KMO_TRY_ASSURE(*lcal != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is allocated!");
+        KMO_TRY_ASSURE(*lcal != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is allocated!");
 
         KMO_TRY_ASSURE((cpl_vector_get_size(xarray) ==
                                               cpl_image_get_size_x(yarray)) &&
@@ -4099,11 +3907,9 @@ int  kmo_fit_spectrum(const cpl_image *bad_pix,
                        CPL_ERROR_ILLEGAL_INPUT,
                        "Size of inputs doesn't match!");
 
-        KMO_TRY_ASSURE((dbg_detector_nr > 0) &&
-                       (dbg_ifu_nr > 0) &&
-                       (dbg_slitlet_nr > 0),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "dbg values must be > 0!");
+        KMO_TRY_ASSURE((dbg_detector_nr > 0) && (dbg_ifu_nr > 0) &&
+                (dbg_slitlet_nr > 0), CPL_ERROR_ILLEGAL_INPUT,
+                "dbg values must be > 0!");
 
         // get some dimensions
         xsize = cpl_vector_get_size(xarray);
@@ -4124,8 +3930,6 @@ int  kmo_fit_spectrum(const cpl_image *bad_pix,
             pleft_edge = cpl_vector_get_data_const(left_edge));
         KMO_TRY_EXIT_IF_NULL(
             pright_edge = cpl_vector_get_data_const(right_edge));
-//        KMO_TRY_EXIT_IF_NULL(
-//            punroll_lcal = cpl_image_get_data(unroll_lcal));
 
         // extract valid arclines
         KMO_TRY_EXIT_IF_NULL(
@@ -4150,7 +3954,6 @@ int  kmo_fit_spectrum(const cpl_image *bad_pix,
 
         // for each x-pos fit a polynomial to spectrum and fill fitted values
         // into lcal taking into account the slitlet_mask
-
         for (ix = 0; ix < xsize; ix++) {
             if ((pxarray[ix] >= KMOS_BADPIX_BORDER) &&
                 (pxarray[ix] < KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER))
@@ -4200,25 +4003,6 @@ fit_again:
                     }
                     cpl_vector_delete(fit_par); fit_par = NULL;
 
-//if ((dbg_detector_nr==1) && (dbg_ifu_nr==2) && (dbg_slitlet_nr==8)) {
-//    cpl_vector_save(lfit, "lfit.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-//    cpl_vector_save(lvec, "lvec.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-//    cpl_vector_save(yvec, "yvec.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-
-//    char tit[1024], nr[12];
-//    const char *opt[2] = { "w p lc rgbcolor \"red\" t 'real'",
-//                           "w p lc rgbcolor \"blue\" t 'fit'"};
-//    strcpy(tit, "set title '1st fit (det: ");
-//    sprintf(nr, "%d", dbg_detector_nr); strcat(tit, nr);
-//    strcat(tit, ", ifu: ");
-//    sprintf(nr, "%d", dbg_ifu_nr); strcat(tit, nr);
-//    strcat(tit, ", slitlet: ");
-//    sprintf(nr, "%d", dbg_slitlet_nr); strcat(tit, nr);
-//    strcat(tit, ", #vals: ");
-//    sprintf(nr, "%d", lsize); strcat(tit, nr);
-//    strcat(tit, ")';");
-//    kmo_plot_vectors2(tit, opt, yvec, lvec, lfit);
-//}
                     // subtract fitted from original values
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_vector_subtract(lfit, lvec));
@@ -4226,18 +4010,12 @@ fit_again:
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_vector_multiply_scalar(lfit, -1.0));
 
-//if ((dbg_detector_nr==1) && (dbg_ifu_nr==2) && (dbg_slitlet_nr==8)) {
-//    kmo_plot_vector("", "", lfit);
-//}
                     // reject deviant values
 kmclipm_vector *ddd1 = kmclipm_vector_create(cpl_vector_duplicate(lfit));
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_reject_deviant(ddd1, 3, 3, &stddev, &mean));
 good2 = kmclipm_vector_get_mask(ddd1);
 kmclipm_vector_delete(ddd1); ddd1 = NULL;
-//if ((dbg_detector_nr==1) && (dbg_ifu_nr==2) && (dbg_slitlet_nr==8)) {
-//    kmo_debug_vector( good2);
-//}
                     KMO_TRY_EXIT_IF_NULL(
                         yvec2 = kmo_idl_values_at_indices(yvec, good2));
                     KMO_TRY_EXIT_IF_NULL(
@@ -4249,10 +4027,6 @@ kmclipm_vector_delete(ddd1); ddd1 = NULL;
                         lvec2 = kmo_idl_values_at_indices(lvec, good2));
                     KMO_TRY_EXIT_IF_NULL(
                         plvec2 = cpl_vector_get_data(lvec2));
-//if ((dbg_detector_nr==1) && (dbg_ifu_nr==2) && (dbg_slitlet_nr==8)) {
-//    cpl_vector_save(lvec2, "lvec2.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-//    cpl_vector_save(yvec2, "yvec2.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-//}
                     // refit the polynomial (2nd fit)
                     fit_par2 = kmo_polyfit_1d(yvec2, lvec2, fit_order);
 
@@ -4267,67 +4041,30 @@ kmclipm_vector_delete(ddd1); ddd1 = NULL;
                         cpl_vector_delete(fit_par);
                         fit_par = fit_par2;
                     }
-
-//if ((dbg_detector_nr==1) && (dbg_ifu_nr==2) && (dbg_slitlet_nr==8)) {
-//    pfit_par = cpl_vector_get_data(fit_par);
-//    if (pfit_par !=NULL) {
-//        char tit[1024], nr[12];
-//        // calculate the fitted polynomial
-//        KMO_TRY_EXIT_IF_NULL(
-//            pyvec2 = cpl_vector_get_data(yvec2));
-//        cpl_vector *lfit2 = NULL;
-//        double *plfit2 = NULL;
-//        KMO_TRY_EXIT_IF_NULL(
-//            lfit2 = cpl_vector_new(cpl_vector_get_size(lvec2)));
-//        KMO_TRY_EXIT_IF_NULL(
-//            plfit2 = cpl_vector_get_data(lfit2));
-//        l = 0;
-//        for (int j = 0; j < cpl_vector_get_size(lvec2); j++) {
-//            plfit2[l] = 0.0;
-//            for(int k = 0; k < cpl_vector_get_size(fit_par); k++) {
-//                plfit2[l] += pfit_par[k] * pow(pyvec2[j], k);
-//            }
-//            l++;
-//        }
-//        cpl_vector_save(lfit2, "lfit2.fits", CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-//        const char*opt2[2] = { "w p lc rgbcolor \"red\" t 'real'",
-//                              "w p lc rgbcolor \"chartreuse\" t 'fit'"};
-//        strcpy(tit, "set title '2nd fit (det: ");
-//        sprintf(nr, "%d", dbg_detector_nr); strcat(tit, nr);
-//        strcat(tit, ", ifu: ");
-//        sprintf(nr, "%d", dbg_ifu_nr); strcat(tit, nr);
-//        strcat(tit, ", slitlet: ");
-//        sprintf(nr, "%d", dbg_slitlet_nr); strcat(tit, nr);
-//        strcat(tit, ", #vals: ");
-//        sprintf(nr, "%d", cpl_vector_get_size(lvec2)); strcat(tit, nr);
-//        strcat(tit, ")';");
-//        kmo_plot_vectors2(tit, opt2, yvec2, lvec2, lfit2);
-//    } else {
-//        cpl_error_reset();
-//    }
-//}
                 }
 
                 if (valid_column) {
-                    // recalculate the fitted polynomial and write value only into lcal
-                    // if it corresponds to the actual slitlet
+                    // recalculate the fitted polynomial and write value 
+                    // only into lcal if it corresponds to the actual slitlet
                     KMO_TRY_EXIT_IF_NULL(
                         pfit_par = cpl_vector_get_data(fit_par));
 
                     valid_column = FALSE;
-                    for (iy = KMOS_BADPIX_BORDER; iy < ny-KMOS_BADPIX_BORDER; iy++) {
-                        if ((pxarray[ix] >= pleft_edge[iy-KMOS_BADPIX_BORDER]) &&
-                            (pxarray[ix] <= pright_edge[iy-KMOS_BADPIX_BORDER]))
-                        {
+                    for (iy = KMOS_BADPIX_BORDER; iy < ny-KMOS_BADPIX_BORDER; 
+                            iy++) {
+                        if ((pxarray[ix]>=pleft_edge[iy-KMOS_BADPIX_BORDER]) &&
+                            (pxarray[ix]<=pright_edge[iy-KMOS_BADPIX_BORDER])) {
                             tmp_dbl = 0.0;
                             for(k = 0; k < cpl_vector_get_size(fit_par); k++) {
                                 tmp_dbl += pfit_par[k] * pow(iy+1, k);
                             }
 
-                            if ((iy == KMOS_BADPIX_BORDER) && (tmp_dbl < *min_lambda)) {
+                            if ((iy == KMOS_BADPIX_BORDER) && (tmp_dbl < 
+                                        *min_lambda)) {
                                 *min_lambda = tmp_dbl;
                             }
-                            if ((iy == ny-KMOS_BADPIX_BORDER-1) && (tmp_dbl > *max_lambda)) {
+                            if ((iy == ny-KMOS_BADPIX_BORDER-1) && (tmp_dbl > 
+                                        *max_lambda)) {
                                 *max_lambda = tmp_dbl;
                             }
 
@@ -4335,9 +4072,6 @@ kmclipm_vector_delete(ddd1); ddd1 = NULL;
                                 // good pix
                                 valid_column = TRUE;
                                 plcal[(int)(pxarray[ix])+iy*nx] = tmp_dbl;
-//                                punroll_lcal[unroll_lcal_cnt] = (int)(pxarray[ix]);
-//                                punroll_lcal[unroll_lcal_cnt+1] = iy;
-//                                unroll_lcal_cnt +=2;
                             } else {
                                 // bad pix
                                 // is already set to 0
@@ -4363,11 +4097,6 @@ kmclipm_vector_delete(ddd1); ddd1 = NULL;
         KMO_CATCH_MSG();
 
         valid_slitlet = FALSE;
-//        ret_error = cpl_error_get_code();
-//        for (int i = 0; i < unroll_lcal_cnt; i+=2) {
-//            plcal[(int)(punroll_lcal[i]) +
-//                  (int)(punroll_lcal[i+1])*nx] = 0.0;
-//        }
 
         *min_lambda = -1.0;
         *max_lambda = -1.0;
@@ -4385,26 +4114,35 @@ kmclipm_vector_delete(ddd1); ddd1 = NULL;
     return valid_slitlet;
 }
 
-int  kmo_fit_spectrum_1 (const cpl_image *bad_pix,
-                      const cpl_vector *xarray,
-                      const cpl_image *yarray,
-                      const cpl_vector *larray,
-                      const cpl_vector *left_edge,
-                      const cpl_vector *right_edge,
-                      cpl_image **lcal,
-                      double *pfitpar,
-                      const int fit_order,
-                      int *valid_columns,
-                      const int fitpar_offset,
-                      int dbg_detector_nr,
-                      int dbg_ifu_nr,
-                      int dbg_slitlet_nr,
-                      const char* data_fits_name)
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+int kmo_fit_spectrum_1(
+        const cpl_image     *   bad_pix,
+        const cpl_vector    *   xarray,
+        const cpl_image     *   yarray,
+        const cpl_vector    *   larray,
+        const cpl_vector    *   left_edge,
+        const cpl_vector    *   right_edge,
+        cpl_image           **  lcal,
+        double              *   pfitpar,
+        const int               fit_order,
+        int                 *   valid_columns,
+        const int               fitpar_offset,
+        int                     dbg_detector_nr,
+        int                     dbg_ifu_nr,
+        int                     dbg_slitlet_nr,
+        const char          *   data_fits_name)
 {
     int             l               = 0,
                     lsize           = 0,
                     xsize           = 0,
-                    valid_slitlet   = FALSE, // TRUE for at least one valid column
+                    /* TRUE for at least one valid column */
+                    valid_slitlet   = FALSE, 
                     order_first_try = 0,
                     valid_col_offset = fitpar_offset/(fit_order+1),
                     px = 0, ix = 0, j = 0, k = 0;
@@ -4440,12 +4178,9 @@ int  kmo_fit_spectrum_1 (const cpl_image *bad_pix,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((xarray != NULL) &&
-                       (yarray != NULL) &&
-                       (larray != NULL) &&
-                       (lcal != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((xarray != NULL) && (yarray != NULL) && 
+                (larray != NULL) && (lcal != NULL), CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         KMO_TRY_ASSURE((cpl_vector_get_size(xarray) ==
                                               cpl_image_get_size_x(yarray)) &&
@@ -4562,18 +4297,19 @@ fit_again:
                         cpl_vector_multiply_scalar(lfit, -1.0));
 
                     // reject deviant values
-kmclipm_vector *ddd2 = kmclipm_vector_create(cpl_vector_duplicate(lfit));
+                    kmclipm_vector *ddd2 = kmclipm_vector_create(
+                            cpl_vector_duplicate(lfit));
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_reject_deviant(ddd2, 3, 3, &stddev, &mean));
-cpl_vector *mmask = kmclipm_vector_get_mask(ddd2);
-good2 = kmo_idl_where(mmask,1.0,eq);
-cpl_vector_delete(mmask); mmask = NULL;
-kmclipm_vector_delete(ddd2); ddd2 = NULL;
+
+                    cpl_vector *mmask = kmclipm_vector_get_mask(ddd2);
+                    good2 = kmo_idl_where(mmask,1.0,eq);
+                    cpl_vector_delete(mmask); mmask = NULL;
+                    kmclipm_vector_delete(ddd2); ddd2 = NULL;
                     KMO_TRY_EXIT_IF_NULL(
                         yvec2 = kmo_idl_values_at_indices(yvec, good2));
                     KMO_TRY_EXIT_IF_NULL(
                         pyvec2 = cpl_vector_get_data(yvec2));
-
                     cpl_vector_delete(yvec); yvec = NULL;
 
                     KMO_TRY_EXIT_IF_NULL(
@@ -4616,8 +4352,8 @@ kmclipm_vector_delete(ddd2); ddd2 = NULL;
 
                     if (valid_columns[valid_col_offset+ix]) {
                         for (px = 0; px < fit_order+1; px++) {
-//                            pfitpar[fitpar_offset+px] = cpl_vector_get(fit_par, px);
-                            pfitpar[fitpar_offset+ix*(fit_order+1)+px] = cpl_vector_get(fit_par, px);
+                            pfitpar[fitpar_offset+ix*(fit_order+1)+px] = 
+                                cpl_vector_get(fit_par, px);
                             KMO_TRY_CHECK_ERROR_STATE();
                         }
                         valid_slitlet = TRUE;
@@ -4641,6 +4377,13 @@ kmclipm_vector_delete(ddd2); ddd2 = NULL;
     return valid_slitlet;
 }
 
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
 int  kmo_fit_spectrum_2(const cpl_image *bad_pix,
                       const cpl_vector *xarray,
                       const cpl_image *yarray,
@@ -4976,6 +4719,7 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                         fwhm_mean                   = 0.,
                         fwhm_stdev                  = 0.,
                         fwhm_95ile                  = 0.,
+                        vscale                      = 0.,
                         wavelength                  = 0.,
                         cdelt                       = 0.;
     char                *imethod                    = "CS",
@@ -4991,12 +4735,14 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                         *stored_ar_fwhm_mean        = NULL,
                         *stored_ar_fwhm_stdev       = NULL,
                         *stored_ar_fwhm_95ile       = NULL,
+                        *stored_ar_vscale           = NULL,
                         *stored_ne_pos_mean_offset  = NULL,
                         *stored_ne_pos_stdev        = NULL,
                         *stored_ne_pos_95ile        = NULL,
                         *stored_ne_fwhm_mean        = NULL,
                         *stored_ne_fwhm_stdev       = NULL,
-                        *stored_ne_fwhm_95ile       = NULL;
+                        *stored_ne_fwhm_95ile       = NULL,
+                        *stored_ne_vscale           = NULL;
     cpl_table           *band_table                 = NULL;
     cpl_vector          *calAngles                   = NULL;
 
@@ -5050,17 +4796,12 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
         KMO_TRY_EXIT_IF_ERROR(
             kmclipm_setup_grid(&gd, imethod, neighborhoodRange, KMOS_PIX_RESOLUTION, 0.));
 
-        char *tmp_band_method = getenv("KMO_BAND_METHOD");
-        int band_method = 0;
-        if (tmp_band_method != NULL) {
-            band_method = atoi(tmp_band_method);
-        }
         // this overrides gd.l.dim in kmclipm_setup_grid()
         KMO_TRY_EXIT_IF_NULL(
             band_table = kmo_dfs_load_table(frameset, WAVE_BAND, 1, 0));
         KMO_TRY_EXIT_IF_ERROR(
-            kmclipm_setup_grid_band_lcal(&gd, lcalDetImg, filter_id,
-                                         band_method, band_table));
+            kmclipm_setup_grid_band_lcal(&gd, filter_id,
+                                         band_table));
         cpl_table_delete(band_table); band_table = NULL;
 
         KMO_TRY_EXIT_IF_NULL(
@@ -5116,12 +4857,14 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
         stored_ar_fwhm_mean       = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
         stored_ar_fwhm_stdev      = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
         stored_ar_fwhm_95ile      = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
+        stored_ar_vscale          = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
         stored_ne_pos_mean_offset = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
         stored_ne_pos_stdev       = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
         stored_ne_pos_95ile       = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
         stored_ne_fwhm_mean       = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
         stored_ne_fwhm_stdev      = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
         stored_ne_fwhm_95ile      = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
+        stored_ne_vscale          = kmclipm_vector_new(KMOS_IFUS_PER_DETECTOR);
 
         kmclipm_vector_fill(stored_ar_pos_mean_offset, -1.);
         kmclipm_vector_fill(stored_ar_pos_stdev, -1.);
@@ -5129,12 +4872,14 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
         kmclipm_vector_fill(stored_ar_fwhm_mean, -1.);
         kmclipm_vector_fill(stored_ar_fwhm_stdev, -1.);
         kmclipm_vector_fill(stored_ar_fwhm_95ile, -1.);
+        kmclipm_vector_fill(stored_ar_vscale, -1.);
         kmclipm_vector_fill(stored_ne_pos_mean_offset, -1.);
         kmclipm_vector_fill(stored_ne_pos_stdev, -1.);
         kmclipm_vector_fill(stored_ne_pos_95ile, -1.);
         kmclipm_vector_fill(stored_ne_fwhm_mean, -1.);
         kmclipm_vector_fill(stored_ne_fwhm_stdev, -1.);
         kmclipm_vector_fill(stored_ne_fwhm_95ile, -1.);
+        kmclipm_vector_fill(stored_ne_vscale, -1.);
 
         for (ifu = 0; ifu < KMOS_IFUS_PER_DETECTOR; ifu++) {
             int ifu_nr = ifu + 1 + (device_nr - 1) * KMOS_IFUS_PER_DETECTOR;
@@ -5144,29 +4889,12 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
             {
                 // reconstruct cube
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmo_reconstruct_sci_image(ifu_nr,
-                                            bounds[2*(ifu_nr-1)],
-                                            bounds[2*(ifu_nr-1)+1],
-                                            arcDetImg_data,
-                                            NULL,
-                                            darkDetImg_data,
-                                            NULL,
-                                            flatDetImg_data,
-                                            NULL,
-                                            xcalDetImg,
-                                            ycalDetImg,
-                                            lcalDetImg,
-                                            &gd,
-                                            calTimestamp,
-                                            calAngles,
-                                            lutFilename,
-                                            &data_cube,
-                                            NULL,
-                                            FALSE,
-                                            FALSE,
-                                            NULL,
-                                            NULL,
-                                            NULL));
+                    kmo_reconstruct_sci_image(ifu_nr, bounds[2*(ifu_nr-1)], 
+                        bounds[2*(ifu_nr-1)+1], arcDetImg_data, NULL,
+                        darkDetImg_data, NULL, flatDetImg_data, NULL,
+                        xcalDetImg, ycalDetImg, lcalDetImg, &gd, calTimestamp,
+                        calAngles, lutFilename, &data_cube, NULL, FALSE, FALSE,
+                        NULL, NULL, NULL));
 
                 // create detector image
                 for (lz = 0; lz < gd.l.dim; lz++) {
@@ -5176,10 +4904,9 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                                              cpl_imagelist_get(data_cube, lz)));
                     for (ly = 0; ly < gd.y.dim; ly++) {
                         for (lx = 0; lx < gd.x.dim; lx++) {
-                            int ix = lx +
-                                     ly * gd.x.dim +
-                                     ifu * gd.x.dim*gd.y.dim +
-                                     lz * gd.x.dim*gd.y.dim*KMOS_IFUS_PER_DETECTOR;
+                            int ix = lx + ly * gd.x.dim +
+                                ifu * gd.x.dim*gd.y.dim +
+                                lz * gd.x.dim*gd.y.dim*KMOS_IFUS_PER_DETECTOR;
                             pdet_img[ix] = slice[lx + ly*gd.x.dim];
                         }
                     }
@@ -5202,12 +4929,10 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                     }
 
                     KMO_TRY_EXIT_IF_ERROR(
-                        kmo_calc_qc_wave_cal(data_cube, 1.0,
-                                             gd.l.start, gd.l.delta, wavelength,
-                                             &pos_mean_offset, &pos_stdev,
-                                             &pos_95ile,
-                                             &fwhm_mean, &fwhm_stdev,
-                                             &fwhm_95ile));
+                        kmo_calc_qc_wave_cal(data_cube, 1.0, gd.l.start, 
+                            gd.l.delta, wavelength, &pos_mean_offset, 
+                            &pos_stdev, &pos_95ile, &fwhm_mean, &fwhm_stdev, 
+                            &fwhm_95ile, &vscale));
 
                     // set these QC values
                     kmclipm_vector_set(stored_ar_pos_mean_offset, ifu,
@@ -5217,6 +4942,7 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                     kmclipm_vector_set(stored_ar_fwhm_mean, ifu, fwhm_mean);
                     kmclipm_vector_set(stored_ar_fwhm_stdev, ifu, fwhm_stdev);
                     kmclipm_vector_set(stored_ar_fwhm_95ile, ifu, fwhm_95ile);
+                    kmclipm_vector_set(stored_ar_vscale, ifu, vscale);
                 }
                 KMO_TRY_CHECK_ERROR_STATE();
 
@@ -5236,12 +4962,10 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                     }
 
                     KMO_TRY_EXIT_IF_ERROR(
-                        kmo_calc_qc_wave_cal(data_cube, 1.0,
-                                             gd.l.start, gd.l.delta, wavelength,
-                                             &pos_mean_offset, &pos_stdev,
-                                             &pos_95ile,
-                                             &fwhm_mean, &fwhm_stdev,
-                                             &fwhm_95ile));
+                        kmo_calc_qc_wave_cal(data_cube, 1.0, gd.l.start, 
+                            gd.l.delta, wavelength, &pos_mean_offset, 
+                            &pos_stdev, &pos_95ile, &fwhm_mean, &fwhm_stdev,
+                            &fwhm_95ile, &vscale));
 
                     // set these QC values
                     kmclipm_vector_set(stored_ne_pos_mean_offset, ifu,
@@ -5251,6 +4975,7 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                     kmclipm_vector_set(stored_ne_fwhm_mean, ifu, fwhm_mean);
                     kmclipm_vector_set(stored_ne_fwhm_stdev, ifu, fwhm_stdev);
                     kmclipm_vector_set(stored_ne_fwhm_95ile, ifu, fwhm_95ile);
+                    kmclipm_vector_set(stored_ne_vscale, ifu, vscale);
                 }
                 KMO_TRY_CHECK_ERROR_STATE();
                 cpl_imagelist_delete(data_cube); data_cube = NULL;
@@ -5260,10 +4985,9 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                 for (lz = 0; lz < gd.l.dim; lz++) {
                     for (ly = 0; ly < gd.y.dim; ly++) {
                         for (lx = 0; lx < gd.x.dim; lx++) {
-                            int ix = lx +
-                                     ly * gd.x.dim +
-                                     ifu * gd.x.dim*gd.y.dim +
-                                     lz * gd.x.dim*gd.y.dim*KMOS_IFUS_PER_DETECTOR;
+                            int ix = lx + ly * gd.x.dim + 
+                                ifu * gd.x.dim*gd.y.dim +
+                                lz * gd.x.dim*gd.y.dim*KMOS_IFUS_PER_DETECTOR;
                             pdet_img[ix] = nan;
                         }
                     }
@@ -5276,6 +5000,7 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                 kmclipm_vector_reject(stored_ar_fwhm_mean, ifu);
                 kmclipm_vector_reject(stored_ar_fwhm_stdev, ifu);
                 kmclipm_vector_reject(stored_ar_fwhm_95ile, ifu);
+                kmclipm_vector_reject(stored_ar_vscale, ifu);
 
                 kmclipm_vector_reject(stored_ne_pos_mean_offset, ifu);
                 kmclipm_vector_reject(stored_ne_pos_stdev, ifu);
@@ -5283,39 +5008,19 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
                 kmclipm_vector_reject(stored_ne_fwhm_mean, ifu);
                 kmclipm_vector_reject(stored_ne_fwhm_stdev, ifu);
                 kmclipm_vector_reject(stored_ne_fwhm_95ile, ifu);
+                kmclipm_vector_reject(stored_ne_vscale, ifu);
             } //if bounds[]
             KMO_TRY_CHECK_ERROR_STATE();
         } // for: ifu=KMOS_IFUS_PER_DETECTOR
         KMO_TRY_CHECK_ERROR_STATE();
 
-//cpl_msg_info("","     | pos Ar\t\t\t| fwhm Ar\t\t\t\t| pos Ne\t\t\t| fwhm Ne\t\t\t |");
-//cpl_msg_info("","ifu: | avg/off.\tstdev\t95%%ile\t| avg\t\tstdev\t95%%ile\t\t| avg/off.\tstdev\t95%%ile\t| avg\t\tstdev\t95%%ile\t |");
-//cpl_msg_info("","------------------------------------------------------------------------------------------------------------------------------------------");
-//for (int ifu = 0; ifu < KMOS_IFUS_PER_DETECTOR; ifu++) {
-//cpl_msg_info("","%i   | %.4f\t%.4f\t%.4f\t| %.4f\t%.4f\t%.4f\t| %.4f\t%.4f\t%.4f\t| %.4f\t%.4f\t%.4f |", ifu,
-//             kmclipm_vector_get(stored_ar_pos_mean_offset, ifu, NULL),
-//             kmclipm_vector_get(stored_ar_pos_stdev, ifu, NULL),
-//             kmclipm_vector_get(stored_ar_pos_95ile, ifu, NULL),
-//             kmclipm_vector_get(stored_ar_fwhm_mean, ifu, NULL),
-//             kmclipm_vector_get(stored_ar_fwhm_stdev, ifu, NULL),
-//             kmclipm_vector_get(stored_ar_fwhm_95ile, ifu, NULL),
-//             kmclipm_vector_get(stored_ne_pos_mean_offset, ifu, NULL),
-//             kmclipm_vector_get(stored_ne_pos_stdev, ifu, NULL),
-//             kmclipm_vector_get(stored_ne_pos_95ile, ifu, NULL),
-//             kmclipm_vector_get(stored_ne_fwhm_mean, ifu, NULL),
-//             kmclipm_vector_get(stored_ne_fwhm_stdev, ifu, NULL),
-//             kmclipm_vector_get(stored_ne_fwhm_95ile, ifu, NULL));
-//}
-
         if (flip == FALSE) {
             KMO_TRY_EXIT_IF_ERROR(
                 cpl_image_flip(det_img, 0));
         }
 
         // calculate QC parameters for whole detector
-        if ((lamp_config == ARGON) ||
-            (lamp_config == ARGON_NEON))
-        {
+        if ((lamp_config == ARGON) || (lamp_config == ARGON_NEON)) {
             maxdiff = kmclipm_vector_get_max(stored_ar_pos_mean_offset,
                                              &pos_maxdiff);
             mindiff = kmclipm_vector_get_min(stored_ar_pos_mean_offset,
@@ -5327,45 +5032,47 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
 
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_AR_POS_MEAN,
-                               kmclipm_vector_get_mean(stored_ar_pos_mean_offset),
-                               "[km/s] mean of pos. offset for Ar ref. line"));
+                    kmclipm_vector_get_mean(stored_ar_pos_mean_offset),
+                    "[km/s] mean of pos. offset for Ar ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_double(*qc_header, QC_ARC_AR_POS_MAXDIFF,
-                               maxdiff,
-                               "[km/s] max diff of pos. offset for Ar ref. line"));
+                kmclipm_update_property_double(*qc_header, 
+                    QC_ARC_AR_POS_MAXDIFF, maxdiff,
+                    "[km/s] max diff of pos. offset for Ar ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_int(*qc_header, QC_ARC_AR_POS_MAXDIFF_ID,
-                            pos_maxdiff+1,
-                            "[] IFU ID with max diff in Ar pos. offset"));
+                kmclipm_update_property_int(*qc_header, 
+                    QC_ARC_AR_POS_MAXDIFF_ID, pos_maxdiff+1,
+                    "[] IFU ID with max diff in Ar pos. offset"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_AR_POS_STDEV,
-                            kmclipm_vector_get_mean(stored_ar_pos_stdev),
-                            "[km/s] mean stdev of pos. offset for Ar ref. line"));
+                    kmclipm_vector_get_mean(stored_ar_pos_stdev),
+                    "[km/s] mean stdev of pos. offset for Ar ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_AR_POS_95ILE,
-                            kmclipm_vector_get_mean(stored_ar_pos_95ile),
-                            "[km/s] mean 95%ile of pos. offset for Ar ref. line"));
+                    kmclipm_vector_get_mean(stored_ar_pos_95ile),
+                    "[km/s] mean 95%ile of pos. offset for Ar ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_AR_FWHM_MEAN,
-                            kmclipm_vector_get_mean(stored_ar_fwhm_mean),
-                            "[km/s] mean of fwhm for Ar ref. line"));
+                    kmclipm_vector_get_mean(stored_ar_fwhm_mean),
+                    "[km/s] mean of fwhm for Ar ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_AR_FWHM_STDEV,
-                            kmclipm_vector_get_mean(stored_ar_fwhm_stdev),
-                            "[km/s] mean stdev of fwhm for Ar ref. line"));
+                    kmclipm_vector_get_mean(stored_ar_fwhm_stdev),
+                    "[km/s] mean stdev of fwhm for Ar ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_AR_FWHM_95ILE,
-                            kmclipm_vector_get_mean(stored_ar_fwhm_95ile),
-                            "[km/s] mean 95%ile of fwhm for Ar ref. line"));
+                    kmclipm_vector_get_mean(stored_ar_fwhm_95ile),
+                    "[km/s] mean 95%ile of fwhm for Ar ref. line"));
+            KMO_TRY_EXIT_IF_ERROR(
+                kmclipm_update_property_double(*qc_header, QC_ARC_AR_VSCALE,
+                    kmclipm_vector_get_mean(stored_ar_vscale),
+                    "Velocity scale used for conversion for Ar ref. line"));
         }
 
-        if ((lamp_config == NEON) ||
-            (lamp_config == ARGON_NEON))
-        {
+        if ((lamp_config == NEON) || (lamp_config == ARGON_NEON)) {
             maxdiff = kmclipm_vector_get_max(stored_ne_pos_mean_offset,
-                                             &pos_maxdiff);
+                    &pos_maxdiff);
             mindiff = kmclipm_vector_get_min(stored_ne_pos_mean_offset,
-                                             &pos_mindiff);
+                    &pos_mindiff);
             if (fabs(mindiff) > fabs(maxdiff)) {
                 maxdiff = mindiff;
                 pos_maxdiff = pos_mindiff;
@@ -5373,42 +5080,44 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
 
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_NE_POS_MEAN,
-                            kmclipm_vector_get_mean(stored_ne_pos_mean_offset),
-                            "[km/s] mean of pos. offset for Ne ref. line"));
+                    kmclipm_vector_get_mean(stored_ne_pos_mean_offset),
+                    "[km/s] mean of pos. offset for Ne ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_double(*qc_header, QC_ARC_NE_POS_MAXDIFF,
-                            maxdiff,
-                            "[km/s] max diff of pos. offset for Ne ref. line"));
+                kmclipm_update_property_double(*qc_header, 
+                    QC_ARC_NE_POS_MAXDIFF, maxdiff,
+                    "[km/s] max diff of pos. offset for Ne ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_int(*qc_header, QC_ARC_NE_POS_MAXDIFF_ID,
-                            pos_maxdiff+1,
-                            "[] IFU ID with max diff in Ne pos. offset"));
+                kmclipm_update_property_int(*qc_header, 
+                    QC_ARC_NE_POS_MAXDIFF_ID, pos_maxdiff+1,
+                    "[] IFU ID with max diff in Ne pos. offset"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_NE_POS_STDEV,
-                            kmclipm_vector_get_mean(stored_ne_pos_stdev),
-                            "[km/s] mean stdev of pos. offset for Ne ref. line"));
+                    kmclipm_vector_get_mean(stored_ne_pos_stdev),
+                    "[km/s] mean stdev of pos. offset for Ne ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_NE_POS_95ILE,
-                            kmclipm_vector_get_mean(stored_ne_pos_95ile),
-                            "[km/s] mean 95%ile of pos. offset for Ne ref. line"));
+                    kmclipm_vector_get_mean(stored_ne_pos_95ile),
+                    "[km/s] mean 95%ile of pos. offset for Ne ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_NE_FWHM_MEAN,
-                            kmclipm_vector_get_mean(stored_ne_fwhm_mean),
-                            "[km/s] mean of fwhm for Ne ref. line"));
+                    kmclipm_vector_get_mean(stored_ne_fwhm_mean),
+                    "[km/s] mean of fwhm for Ne ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_NE_FWHM_STDEV,
-                            kmclipm_vector_get_mean(stored_ne_fwhm_stdev),
-                            "[km/s] mean stdev of fwhm for Ne ref. line"));
+                    kmclipm_vector_get_mean(stored_ne_fwhm_stdev),
+                    "[km/s] mean stdev of fwhm for Ne ref. line"));
             KMO_TRY_EXIT_IF_ERROR(
                 kmclipm_update_property_double(*qc_header, QC_ARC_NE_FWHM_95ILE,
-                            kmclipm_vector_get_mean(stored_ne_fwhm_95ile),
-                            "[km/s] mean 95%ile of fwhm for Ne ref. line"));
+                    kmclipm_vector_get_mean(stored_ne_fwhm_95ile),
+                    "[km/s] mean 95%ile of fwhm for Ne ref. line"));
+            KMO_TRY_EXIT_IF_ERROR(
+                kmclipm_update_property_double(*qc_header, QC_ARC_NE_VSCALE,
+                    kmclipm_vector_get_mean(stored_ne_vscale),
+                    "Velocity scale used for conversion for Ne ref. line"));
         }
     } KMO_CATCH {
-        cpl_msg_error(cpl_func,
-                      "Encountered error: %s in %s",
-                      cpl_error_get_message(),
-                      cpl_error_get_where());
+        cpl_msg_error(cpl_func, "Encountered error: %s in %s",
+                cpl_error_get_message(), cpl_error_get_where());
         cpl_propertylist_delete(*qc_header); *qc_header = NULL;
         cpl_image_delete(det_img); det_img = NULL;
     }
@@ -5423,6 +5132,7 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
     kmclipm_vector_delete(stored_ar_fwhm_mean); stored_ar_fwhm_mean = NULL;
     kmclipm_vector_delete(stored_ar_fwhm_stdev); stored_ar_fwhm_stdev = NULL;
     kmclipm_vector_delete(stored_ar_fwhm_95ile); stored_ar_fwhm_95ile = NULL;
+    kmclipm_vector_delete(stored_ar_vscale); stored_ar_vscale = NULL;
     kmclipm_vector_delete(stored_ne_pos_mean_offset);
     stored_ne_pos_mean_offset = NULL;
     kmclipm_vector_delete(stored_ne_pos_stdev); stored_ne_pos_stdev = NULL;
@@ -5430,6 +5140,7 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
     kmclipm_vector_delete(stored_ne_fwhm_mean); stored_ne_fwhm_mean = NULL;
     kmclipm_vector_delete(stored_ne_fwhm_stdev); stored_ne_fwhm_stdev = NULL;
     kmclipm_vector_delete(stored_ne_fwhm_95ile); stored_ne_fwhm_95ile = NULL;
+    kmclipm_vector_delete(stored_ne_vscale); stored_ne_vscale = NULL;
     cpl_free(bounds); bounds = NULL;
 
     if (last_env != NULL) {
@@ -5441,17 +5152,26 @@ cpl_image* kmo_reconstructed_arc_image(cpl_frameset *frameset,
     return det_img;
 }
 
-cpl_error_code kmo_calc_qc_wave_cal(const cpl_imagelist *cube,
-                                    double crpix,
-                                    double crval,
-                                    double cdelt,
-                                    double ref_wavelength,
-                                    double *pos_mean_offset,
-                                    double *pos_stdev,
-                                    double *pos_95ile,
-                                    double *fwhm_mean_offset,
-                                    double *fwhm_stdev,
-                                    double *fwhm_95ile)
+/*----------------------------------------------------------------------------*/
+/**
+  @brief
+  @param 
+  @return
+*/
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_calc_qc_wave_cal(
+        const cpl_imagelist     *   cube,
+        double                      crpix,
+        double                      crval,
+        double                      cdelt,
+        double                      ref_wavelength,
+        double                  *   pos_mean_offset,
+        double                  *   pos_stdev,
+        double                  *   pos_95ile,
+        double                  *   fwhm_mean_offset,
+        double                  *   fwhm_stdev,
+        double                  *   fwhm_95ile,
+        double                  *   veloc_scale)
 {
     cpl_error_code  err             = CPL_ERROR_NONE;
     double          vscale          = 0.,
@@ -5495,18 +5215,13 @@ cpl_error_code kmo_calc_qc_wave_cal(const cpl_imagelist *cube,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((cube != NULL) ||
-                       (pos_mean_offset != NULL) ||
-                       (pos_stdev != NULL) ||
-                       (pos_95ile != NULL) ||
-                       (fwhm_mean_offset != NULL) ||
-                       (fwhm_stdev != NULL) ||
-                       (fwhm_95ile != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((cube != NULL) || (pos_mean_offset != NULL) ||
+                (pos_stdev != NULL) || (pos_95ile != NULL) ||
+                (fwhm_mean_offset != NULL) || (fwhm_stdev != NULL) ||
+                (fwhm_95ile != NULL) || (veloc_scale != NULL), 
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
-        KMO_TRY_EXIT_IF_NULL(
-            img = cpl_imagelist_get_const(cube, 0));
+        KMO_TRY_EXIT_IF_NULL(img = cpl_imagelist_get_const(cube, 0));
         nx = cpl_image_get_size_x(img);
         ny = cpl_image_get_size_y(img);
         nz = cpl_imagelist_get_size(cube);
@@ -5523,31 +5238,19 @@ cpl_error_code kmo_calc_qc_wave_cal(const cpl_imagelist *cube,
         // (pixel position of min(abs(lambda-ref_wavelength)) )
         KMO_TRY_EXIT_IF_NULL(
             tmp_vec = kmclipm_vector_duplicate(lambda));
-
         KMO_TRY_EXIT_IF_ERROR(
             kmclipm_vector_subtract_scalar(tmp_vec, ref_wavelength));
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmclipm_vector_abs(tmp_vec));
-
+        KMO_TRY_EXIT_IF_ERROR(kmclipm_vector_abs(tmp_vec));
         kmclipm_vector_get_min(tmp_vec, &ref_pixpos);
         KMO_TRY_CHECK_ERROR_STATE();
-
         kmclipm_vector_delete(tmp_vec); tmp_vec = NULL;
 
-        KMO_TRY_EXIT_IF_NULL(
-            x = cpl_vector_new(len));
-        for (i = 0; i < len; i++) {
-            cpl_vector_set(x, i, i);
-        }
-        KMO_TRY_EXIT_IF_NULL(
-            y = cpl_vector_new(len));
-        KMO_TRY_EXIT_IF_NULL(
-            gpos = kmclipm_vector_new(nx*ny));
-        KMO_TRY_EXIT_IF_NULL(
-            gfwhm = kmclipm_vector_new(nx*ny));
-        KMO_TRY_EXIT_IF_NULL(
-            gpeak = kmclipm_vector_new(nx*ny));
+        KMO_TRY_EXIT_IF_NULL(x = cpl_vector_new(len));
+        for (i = 0; i < len; i++) cpl_vector_set(x, i, i);
+        KMO_TRY_EXIT_IF_NULL(y = cpl_vector_new(len));
+        KMO_TRY_EXIT_IF_NULL(gpos = kmclipm_vector_new(nx*ny));
+        KMO_TRY_EXIT_IF_NULL(gfwhm = kmclipm_vector_new(nx*ny));
+        KMO_TRY_EXIT_IF_NULL(gpeak = kmclipm_vector_new(nx*ny));
 
         for (iy = 0; iy < ny; iy++) {
             for (ix = 0; ix < nx; ix++) {
@@ -5555,36 +5258,22 @@ cpl_error_code kmo_calc_qc_wave_cal(const cpl_imagelist *cube,
                 for (iz = ref_pixpos-len2; iz <= ref_pixpos+len2; iz++) {
                     KMO_TRY_EXIT_IF_NULL(
                         img = cpl_imagelist_get_const(cube, iz));
-                    cpl_vector_set(y, iv++, cpl_image_get(img, ix+1, iy+1, &tmp_int));
+                    cpl_vector_set(y, iv++, cpl_image_get(img, ix+1, iy+1, 
+                                &tmp_int));
                     KMO_TRY_CHECK_ERROR_STATE();
                 }
 
-//                KMO_TRY_EXIT_IF_ERROR(
-//                    err = cpl_vector_fit_gaussian(x, NULL,
-//                                                  y, NULL,
-//                                                  CPL_FIT_CENTROID |
-//                                                      CPL_FIT_STDEV |
-//                                                      CPL_FIT_AREA,
-//                                                  &fitted_centroid,
-//                                                  &fitted_sigma,
-//                                                  &fitted_area,
-//                                                  &offset,      // not fitted here
-//                                                  NULL, NULL, NULL));
-                err = cpl_vector_fit_gaussian(x, NULL,
-                                              y, NULL,
-                                              CPL_FIT_CENTROID |
-                                                  CPL_FIT_STDEV |
-                                                  CPL_FIT_AREA,
-                                              &fitted_centroid,
-                                              &fitted_sigma,
-                                              &fitted_area,
-                                              &offset,      // not fitted here
-                                              NULL, NULL, NULL);
+                err = cpl_vector_fit_gaussian(x, NULL, y, NULL,
+                        CPL_FIT_CENTROID | CPL_FIT_STDEV | CPL_FIT_AREA,
+                        &fitted_centroid, &fitted_sigma, &fitted_area,
+                        &offset, NULL, NULL, NULL);
                 if (err == CPL_ERROR_NONE) {
                     // found the reference line and fitted it
                     kmclipm_vector_set(gpos,  ix+iy*nx, fitted_centroid);
-                    kmclipm_vector_set(gfwhm, ix+iy*nx, fitted_sigma*CPL_MATH_FWHM_SIG);
-                    kmclipm_vector_set(gpeak, ix+iy*nx, fitted_area/(fitted_sigma*CPL_MATH_SQRT2PI));
+                    kmclipm_vector_set(gfwhm, ix+iy*nx, 
+                            fitted_sigma*CPL_MATH_FWHM_SIG);
+                    kmclipm_vector_set(gpeak, ix+iy*nx, 
+                            fitted_area/(fitted_sigma*CPL_MATH_SQRT2PI));
                 } else {
                     // didn't identify the reference line
                     kmclipm_vector_reject(gpos, ix+iy*nx);
@@ -5592,19 +5281,13 @@ cpl_error_code kmo_calc_qc_wave_cal(const cpl_imagelist *cube,
                     kmclipm_vector_reject(gpeak, ix+iy*nx);
                     err = CPL_ERROR_NONE;
                 }
-                cpl_error_reset();// error status must be reset anyway also if err==CPL_ERROR_NONE
+                /* error status must be reset anyway also if CPL_ERROR_NONE */
+                cpl_error_reset();
             }
         }
         cpl_vector_delete(y); y = NULL;
         KMO_TRY_CHECK_ERROR_STATE();
-//kmclipm_vector_dump(gpos);
-//kmclipm_vector_dump(gfwhm);
-//kmclipm_vector_dump(gpeak);
-        // calculate robust means on gpeaks, reject same values on gpos and gfwhm
-//cpl_msg_debug(cpl_func,"min before: %g", kmclipm_vector_get_min(gpeak, NULL));
-//cpl_msg_debug(cpl_func,"max before: %g", kmclipm_vector_get_max(gpeak, NULL));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_priv_reject_qc(gpeak, &gpeakm, &gpeaks));
+        KMO_TRY_EXIT_IF_ERROR(kmo_priv_reject_qc(gpeak, &gpeakm, &gpeaks));
         gpmax = gpeakm + 5*gpeaks;
         gpmin = gpeakm - 5*gpeaks;
         if (gpmin < 0.) {
@@ -5623,43 +5306,36 @@ cpl_error_code kmo_calc_qc_wave_cal(const cpl_imagelist *cube,
             }
         }
         KMO_TRY_CHECK_ERROR_STATE();
-int n_rej = kmclipm_vector_count_rejected(gpos);    // sollte 15 sein... ist 1
+        int n_rej = kmclipm_vector_count_rejected(gpos); 
         for (i = 0; i < kmclipm_vector_get_size(gfwhm); i++) {
             int isrej = 0;
             double val = kmclipm_vector_get(gpeak, i, &isrej);
             if (!kmclipm_vector_is_rejected(gfwhm, i) &&
-                (isrej || ((val < gpmin) || (val > gpmax)))
-               )
-            {
-                kmclipm_vector_reject(gfwhm, i);
-            }
+                (isrej || ((val < gpmin) || (val > gpmax)))) 
+                kmclipm_vector_reject(gfwhm, i); 
         }
         KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_priv_reject_qc(gpos, &gposm, &gposs));
-n_rej = kmclipm_vector_count_rejected(gpos);    // sollte 15 sein... ist 1
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_priv_reject_qc(gfwhm, &gfwhmm, &gfwhms));
+        KMO_TRY_EXIT_IF_ERROR(kmo_priv_reject_qc(gpos, &gposm, &gposs));
+        
+        n_rej = kmclipm_vector_count_rejected(gpos);
+
+        KMO_TRY_EXIT_IF_ERROR(kmo_priv_reject_qc(gfwhm, &gfwhmm, &gfwhms));
 
-        // interpolate gposml out from gposm (gposm: position of mean line pix pos
+        // interpolate gposml out from gposm (gposm: pos of mean line pix pos
         // gposml: correspinding lambda value)
         KMO_TRY_EXIT_IF_NULL(
-            tmp_vec = kmclipm_vector_extract(lambda, ref_pixpos-9, ref_pixpos+9));
+            tmp_vec = kmclipm_vector_extract(lambda,ref_pixpos-9,ref_pixpos+9));
         KMO_TRY_EXIT_IF_NULL(
             vecl = kmclipm_vector_create_non_rejected(tmp_vec));
         kmclipm_vector_delete(tmp_vec); tmp_vec = NULL;
 
-        KMO_TRY_EXIT_IF_NULL(
-            bivec_ref = cpl_bivector_wrap_vectors(x, vecl));
-        KMO_TRY_EXIT_IF_NULL(
-            vgposm = cpl_vector_new(1));
+        KMO_TRY_EXIT_IF_NULL(bivec_ref = cpl_bivector_wrap_vectors(x, vecl));
+        KMO_TRY_EXIT_IF_NULL(vgposm = cpl_vector_new(1));
         cpl_vector_set(vgposm, 0, gposm);
-        KMO_TRY_EXIT_IF_NULL(
-            vgposml = cpl_vector_new(1));
+        KMO_TRY_EXIT_IF_NULL(vgposml = cpl_vector_new(1));
         KMO_TRY_EXIT_IF_NULL(
             bivec_out = cpl_bivector_wrap_vectors(vgposm, vgposml));
-
         KMO_TRY_EXIT_IF_ERROR(
             cpl_bivector_interpolate_linear(bivec_out, bivec_ref));
 
@@ -5672,52 +5348,50 @@ n_rej = kmclipm_vector_count_rejected(gpos);    // sollte 15 sein... ist 1
         cpl_vector_delete(vgposml); vgposml = NULL;
 
         // get 95%ile position offset
-        KMO_TRY_EXIT_IF_ERROR(
-            kmclipm_vector_subtract_scalar(gpos, gposm));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmclipm_vector_abs(gpos));
-
-        KMO_TRY_EXIT_IF_NULL(
-            x = kmclipm_vector_create_non_rejected(gpos));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_vector_sort(x, CPL_SORT_ASCENDING));
+        KMO_TRY_EXIT_IF_ERROR(kmclipm_vector_subtract_scalar(gpos, gposm));
+        KMO_TRY_EXIT_IF_ERROR(kmclipm_vector_abs(gpos));
+        KMO_TRY_EXIT_IF_NULL(x = kmclipm_vector_create_non_rejected(gpos));
+        KMO_TRY_EXIT_IF_ERROR(cpl_vector_sort(x, CPL_SORT_ASCENDING));
         index = (int)ceil(0.95 * cpl_vector_get_size(x));
-        if (index != 0) {
-            index -= 1;  //vector index is running 0..n-1
-        }
+        /* vector index is running 0..n-1 */
+        if (index != 0) index -= 1; 
         q95 = cpl_vector_get(x, index);
         cpl_vector_delete(x); x = NULL;
         KMO_TRY_CHECK_ERROR_STATE();
 
         // get 95%ile fwhm
-        KMO_TRY_EXIT_IF_NULL(
-            x = kmclipm_vector_create_non_rejected(gfwhm));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_vector_sort(x, CPL_SORT_ASCENDING));
+        KMO_TRY_EXIT_IF_NULL(x = kmclipm_vector_create_non_rejected(gfwhm));
+        KMO_TRY_EXIT_IF_ERROR(cpl_vector_sort(x, CPL_SORT_ASCENDING));
         index = (int)ceil(0.95 * cpl_vector_get_size(x));
-        if (index != 0) {
-            index -= 1;  //vector index is running 0..n-1
-        }
+        /* vector index is running 0..n-1 */
+        if (index != 0) index -= 1;
         f95 = cpl_vector_get(x, index);
         cpl_vector_delete(x); x = NULL;
         KMO_TRY_CHECK_ERROR_STATE();
 
-        vscale= cdelt / ref_wavelength * CPL_PHYS_C/1000.; // speed of light in [km/s]
-cpl_msg_debug(cpl_func,"1 ref_pixpos = %g [km/s]",vscale);
-cpl_msg_debug(cpl_func,"number rejected = %d (%g %%)",n_rej, 1.*n_rej/(nx*ny)*100.);
-cpl_msg_debug(cpl_func,"Line position mean=%g, stddev=%g [um]",gposml-ref_wavelength, gposs*cdelt);
-cpl_msg_debug(cpl_func,"Line position mean=%g, stddev=%g [km/s]",(gposml-ref_wavelength)/ref_wavelength*CPL_PHYS_C/1000., gposs*vscale);
-cpl_msg_debug(cpl_func,"95%%ile = %g pixels, %g km/s", q95, q95*vscale);
-cpl_msg_debug(cpl_func," ");
-cpl_msg_debug(cpl_func,"Line width mean=%g, stddev=%g [km/s]",gfwhmm*vscale, gfwhms*vscale);
-cpl_msg_debug(cpl_func,"95%%ile = %g pixels, %g km/s", f95, f95*vscale);
-
-        *pos_mean_offset = (gposml-ref_wavelength)/ref_wavelength*CPL_PHYS_C/1000.;
+        /* speed of light in [km/s] */
+        vscale= cdelt / ref_wavelength * CPL_PHYS_C/1000.; 
+        cpl_msg_debug(cpl_func,"1 ref_pixpos = %g [km/s]",vscale);
+        cpl_msg_debug(cpl_func,"number rejected = %d (%g %%)",n_rej, 
+                1.*n_rej/(nx*ny)*100.);
+        cpl_msg_debug(cpl_func,"Line position mean=%g, stddev=%g [um]",
+                gposml-ref_wavelength, gposs*cdelt);
+        cpl_msg_debug(cpl_func,"Line position mean=%g, stddev=%g [km/s]",
+        (gposml-ref_wavelength)/ref_wavelength*CPL_PHYS_C/1000., gposs*vscale);
+        cpl_msg_debug(cpl_func,"95%%ile = %g pixels, %g km/s", q95, q95*vscale);
+        cpl_msg_debug(cpl_func," ");
+        cpl_msg_debug(cpl_func,"Line width mean=%g, stddev=%g [km/s]",
+                gfwhmm*vscale, gfwhms*vscale);
+        cpl_msg_debug(cpl_func,"95%%ile = %g pixels, %g km/s", f95, f95*vscale);
+
+        *pos_mean_offset = 
+            (gposml-ref_wavelength)/ref_wavelength*CPL_PHYS_C/1000.;
         *pos_stdev = gposs*vscale;
         *pos_95ile = q95*vscale;
         *fwhm_mean_offset = gfwhmm*vscale;
         *fwhm_stdev = gfwhms*vscale;
         *fwhm_95ile = f95*vscale;
+        *veloc_scale = vscale;
         KMO_TRY_CHECK_ERROR_STATE();
     } KMO_CATCH {
         KMO_CATCH_MSG();
@@ -5728,6 +5402,7 @@ cpl_msg_debug(cpl_func,"95%%ile = %g pixels, %g km/s", f95, f95*vscale);
         *fwhm_mean_offset = 0./0.;
         *fwhm_stdev = 0./0.;
         *fwhm_95ile = 0./0.;
+        *veloc_scale = 0./0.;
     }
 
     kmclipm_vector_delete(lambda); lambda = NULL;
@@ -5738,27 +5413,24 @@ cpl_msg_debug(cpl_func,"95%%ile = %g pixels, %g km/s", f95, f95*vscale);
     return err;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculate mean and stdev with rejection for QC parameters.
-
-    @param data     The data values.
-    @param stddev   (Output) The standard deviation after rejection.
-    @param mean     (Output) The mean after rejection.
-
-    @return
-        A possibly shorter vector than @c data . It contains the indices of the
-        valid pixels to consider for further calculations.
-
-    Deviant values will be removed using a two-step rejection.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data is NULL.
+  @brief Calculate mean and stdev with rejection for QC parameters.
+  @param data     The data values.
+  @param stddev   (Output) The standard deviation after rejection.
+  @param mean     (Output) The mean after rejection.
+  @return A possibly shorter vector than @c data . It contains the indices 
+          of the valid pixels to consider for further calculations.
+
+  Deviant values will be removed using a two-step rejection.
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data is NULL.
 */
-cpl_error_code kmo_priv_reject_qc(const kmclipm_vector *cube,
-                                  double *mean,
-                                  double *stddev)
+/*----------------------------------------------------------------------------*/
+cpl_error_code kmo_priv_reject_qc(
+        const kmclipm_vector    *   cube,
+        double                  *   mean,
+        double                  *   stddev)
 {
     cpl_error_code  err                 = CPL_ERROR_NONE;
     cpl_vector      *tmp_vec_sort       = NULL;
@@ -5773,17 +5445,12 @@ cpl_error_code kmo_priv_reject_qc(const kmclipm_vector *cube,
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE((cube != NULL) &&
-                       (mean != NULL) &&
-                       (stddev != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((cube != NULL) && (mean != NULL) && (stddev != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         nz = cpl_vector_get_size(cube->data);
 
-        /*
-         * 1st rejection iteration (80% clipping)
-         */
+         /* 1st rejection iteration (80% clipping) */
 
         /* get absolute values from data-median */
         KMO_TRY_EXIT_IF_NULL(
@@ -5827,15 +5494,13 @@ cpl_error_code kmo_priv_reject_qc(const kmclipm_vector *cube,
 
         for (i = 0; i < nz; i++) {
             if (!kmclipm_vector_is_rejected(secf, i))  {
-                if (fabs(kmclipm_vector_get(secf, i, NULL)-*mean) > 3*(*stddev))  {
+                if (fabs(kmclipm_vector_get(secf, i, NULL)-*mean) > 
+                        3*(*stddev))  {
                     kmclipm_vector_reject(secf, i);
                 }
             }
         }
         KMO_TRY_CHECK_ERROR_STATE();
-//cpl_msg_debug(cpl_func,"min after: %g", kmclipm_vector_get_min(secf, NULL));
-//cpl_msg_debug(cpl_func,"max after: %g", kmclipm_vector_get_max(secf, NULL));
-//cpl_msg_debug(cpl_func,"rejected: %d", kmclipm_vector_count_rejected(secf));
         *mean = kmclipm_vector_get_mean(secf);
         *stddev = kmclipm_vector_get_stdev(secf);
         KMO_TRY_CHECK_ERROR_STATE();
@@ -5853,28 +5518,29 @@ cpl_error_code kmo_priv_reject_qc(const kmclipm_vector *cube,
     return err;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Calculates the pixel position of the fitted edge.
-
-    The KMOS_BADPIX_BORDER is respected:
-      - minimum edge position can be KMOS_BADPIX_BORDER
-      - maximum edge border can be KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER-1
-
-    @param  edge_table  The table containing the fitted edge parameters.
-                        In the columns are the edge parameters, in the
-                        rows are the edges.
-    @param  row         The number of the edge to calculate.
-    @param  y           The position in y at this edge where the x value
-                        should be calculated.
-
-    @return An int value (x) denoting the edge of the slitlet. This pixel is part
-            of the edge.
-
-    Possible _cpl_error_code_ set in this function:
-    @li CPL_ERROR_NULL_INPUT if @c edge_table is NULL.
+  @brief Calculates the pixel position of the fitted edge.
+  @param  edge_table  The table containing the fitted edge parameters.
+                      In the columns are the edge parameters, in the
+                      rows are the edges.
+  @param  row         The number of the edge to calculate.
+  @param  y           The position in y at this edge where the x value
+                      should be calculated.
+  @return An int value (x) denoting the edge of the slitlet. This pixel is 
+              part of the edge.
+
+  The KMOS_BADPIX_BORDER is respected:
+    - minimum edge position can be KMOS_BADPIX_BORDER
+    - maximum edge border can be KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER-1
+  Possible _cpl_error_code_ set in this function:
+  @li CPL_ERROR_NULL_INPUT if @c edge_table is NULL.
  */
-double kmo_calc_fitted_slitlet_edge(cpl_table *edge_table, int row, int y)
+/*----------------------------------------------------------------------------*/
+double kmo_calc_fitted_slitlet_edge(
+        cpl_table   *   edge_table, 
+        int             row, 
+        int             y)
 {
     int     nr_cols     = 0;
     char    *name       = NULL;
@@ -5883,15 +5549,17 @@ double kmo_calc_fitted_slitlet_edge(cpl_table *edge_table, int row, int y)
     KMO_TRY
     {
         // check inputs
-        KMO_TRY_ASSURE(edge_table != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Any of the inputs is NULL!");
+        KMO_TRY_ASSURE(edge_table != NULL, CPL_ERROR_NULL_INPUT,
+                "Any of the inputs is NULL!");
         KMO_TRY_ASSURE(((row >= 0) && (row < cpl_table_get_nrow(edge_table))),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "row must >= 0 and smaller than size of table (%d)!", (int)cpl_table_get_nrow(edge_table));
-        KMO_TRY_ASSURE(((y >= KMOS_BADPIX_BORDER) && (y < KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER+1)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "y must be >= %d and < %d! (y=%d)", KMOS_BADPIX_BORDER, KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER+1, y);
+                CPL_ERROR_ILLEGAL_INPUT,
+                "row must >= 0 and smaller than size of table (%d)!", 
+                (int)cpl_table_get_nrow(edge_table));
+        KMO_TRY_ASSURE(((y >= KMOS_BADPIX_BORDER) && 
+                    (y < KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER+1)),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "y must be >= %d and < %d! (y=%d)", 
+                KMOS_BADPIX_BORDER, KMOS_DETECTOR_SIZE-KMOS_BADPIX_BORDER+1, y);
 
         // subtract one because the first column contains the slitlet IDs
         nr_cols = cpl_table_get_ncol(edge_table)-1;
@@ -5926,22 +5594,21 @@ double kmo_calc_fitted_slitlet_edge(cpl_table *edge_table, int row, int y)
     return x;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Gets the number of pixels above a given threshold.
-
-    @param data            Input Image.
-    @param threshold       The threshold level.
-
-    @return
-        The number of pixels which are saturated. Returns -1 on error.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c data is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT if @c threshold is <= zero.
+  @brief Gets the number of pixels above a given threshold.
+  @param data            Input Image.
+  @param threshold       The threshold level.
+  @return The number of pixels which are saturated. Returns -1 on error.
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c data is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT if @c threshold is <= zero.
 */
-int kmo_image_get_saturated(const cpl_image *data, float threshold)
+/*----------------------------------------------------------------------------*/
+int kmo_image_get_saturated(
+        const cpl_image     *   data, 
+        float                   threshold)
 {
     int         saturated_pixels    = 0,
                 i                   = 0,
@@ -5953,13 +5620,11 @@ int kmo_image_get_saturated(const cpl_image *data, float threshold)
 
     KMO_TRY
     {
-        KMO_TRY_ASSURE(data != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
+        KMO_TRY_ASSURE(data != NULL, CPL_ERROR_NULL_INPUT,
+                "No input data is provided!");
 
-        KMO_TRY_ASSURE(threshold > 0.0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "threshold must be greater than zero!");
+        KMO_TRY_ASSURE(threshold > 0.0, CPL_ERROR_ILLEGAL_INPUT,
+                "threshold must be greater than zero!");
 
         nx = cpl_image_get_size_x(data);
         ny = cpl_image_get_size_y(data);
@@ -5986,49 +5651,42 @@ int kmo_image_get_saturated(const cpl_image *data, float threshold)
     return saturated_pixels;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Checks if grating and filter matches for each detector.
-
-    This function checks if a value at a specified position in @c ifu_lambda_in
-    lies inbetween a specified range.
-
-    @param pl           The propertylist to examine.
-    @param nr_devices   The number of detectors available (in general 3 for KMOS :-).
-    @param check_return The index to the value in @c ifu_lambda_in to examine.
-                         Starts at zero.
-
-    @return
-        An array of filter-strings for each device (only if @c check_return is
-        TRUE), NULL otherwise.
-
-    Possible cpl_error_code set in this function:
-
-    @c CPL_ERROR_NULL_INPUT    Not enough inputs defined
+  @brief Checks if grating and filter matches for each detector.
+  @param pl           The propertylist to examine.
+  @param nr_devices   The number of detectors available 
+  @param check_return The index to the value in @c ifu_lambda_in to examine.
+                       Starts at zero.
+  @return An array of filter-strings for each device (only if @c 
+              check_return is TRUE), NULL otherwise.
+
+  This function checks if a value at a specified position in @c ifu_lambda_in
+  lies inbetween a specified range.
+  Possible cpl_error_code set in this function:
+  @c CPL_ERROR_NULL_INPUT    Not enough inputs defined
 */
-char**  kmo_get_filter_setup(const cpl_propertylist *pl,
-                             int nr_devices,
-                             int check_return)
+/*----------------------------------------------------------------------------*/
+char ** kmo_get_filter_setup(
+        const cpl_propertylist  *   pl,
+        int                         nr_devices,
+        int                         check_return)
 {
-
     const char       *tmp_str1              = NULL,
                      *tmp_str2              = NULL;
-
     char             *keyword               = NULL,
                      **ret                  = NULL;
     int             i                       = 0;
     KMO_TRY
     {
-        KMO_TRY_ASSURE(pl != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE(pl != NULL, CPL_ERROR_NULL_INPUT,
+                "Not all input data is provided!");
 
         if (check_return == 1) {
             KMO_TRY_EXIT_IF_NULL(
                 ret = (char**)cpl_malloc(sizeof(char*)*nr_devices));
         }
 
-
         for (i = 0; i < nr_devices; i++) {
             if (check_return == 1) {
                 // allocate string to return
@@ -6038,20 +5696,22 @@ char**  kmo_get_filter_setup(const cpl_propertylist *pl,
 
             // get grating
             KMO_TRY_EXIT_IF_NULL(
-                keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 1, IFU_GRATID_POSTFIX));
+                keyword = cpl_sprintf("%s%d%s", IFU_GRATID_PREFIX, 1, 
+                    IFU_GRATID_POSTFIX));
             tmp_str1 = cpl_propertylist_get_string(pl, keyword);
             cpl_free(keyword); keyword = NULL;
 
             // get filter
             KMO_TRY_EXIT_IF_NULL(
-                keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 1, IFU_FILTID_POSTFIX));
+                keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, 1, 
+                    IFU_FILTID_POSTFIX));
             tmp_str2 = cpl_propertylist_get_string(pl, keyword);
             cpl_free(keyword); keyword = NULL;
 
             KMO_TRY_ASSURE(strcmp(tmp_str1, tmp_str2) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Grating (%s) and filter (%s) for detector %d"
-                           "don't match!", tmp_str1, tmp_str2, i+1);
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "Grating (%s) and filter (%s) for detector %d"
+                    "don't match!", tmp_str1, tmp_str2, i+1);
 
             if (check_return == 1) {
                 strcpy(ret[i], tmp_str1);
@@ -6069,7 +5729,6 @@ char**  kmo_get_filter_setup(const cpl_propertylist *pl,
         }
         ret = NULL;
     }
-
     return ret;
 }
 
diff --git a/kmos/kmo_priv_wave_cal.h b/kmos/kmo_priv_wave_cal.h
index 72a1019..5ab38a6 100644
--- a/kmos/kmo_priv_wave_cal.h
+++ b/kmos/kmo_priv_wave_cal.h
@@ -193,7 +193,8 @@ cpl_error_code  kmo_calc_qc_wave_cal(
                                     double *pos_95ile,
                                     double *fwhm_mean_offset,
                                     double *fwhm_stdev,
-                                    double *fwhm_95ile);
+                                    double *fwhm_95ile,
+                                    double *veloc_scale);
 
 cpl_error_code  kmo_priv_reject_qc( const kmclipm_vector *gpeak,
                                     double *mean,
diff --git a/kmos/kmo_utils.c b/kmos/kmo_utils.c
index dec46c3..10ab548 100644
--- a/kmos/kmo_utils.c
+++ b/kmos/kmo_utils.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_utils.c,v 1.29 2013-10-21 13:44:54 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-21 13:44:54 $
- * $Revision: 1.29 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -511,38 +503,34 @@ enum kmo_frame_type kmo_string_to_frame_type(const char* frame_type_str)
     return type;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Extracts a @li main_fits_desc from a fits-file.
-
-    @param filename The filename and path of the fits-file to describe.
-
-    @return
-        The function returns a structure of type @c main_fits_desc.
-
-    Creates a structure of type @c main_fits_desc which contains all values
-    relevant to the KMOS-pipeline of a given fits-file.
-    These are: NAXIS, NAXIS1, NAXIS2, NAXIS3, KMOS_TYPE, EX_NOISE, NR_EXT
-    The values are extracted from the main fits-header and from the headers
-    of eventually existing extensions.
-    The data from extensions is stored in the structure-member @c sub_desc .
-
-    It is assumed, that RAW-files have empty main-header (NAXIS = 0) and
-    that 3 extensions exist all with NAXIS=2 and that NAXIS1 and NAXIS2 of
-    all 3 extansions have the same values each and it is assumed by default,
-    that raw is data, so EX_NOISE will be FALSE
-
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c filename is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT The position is less than 0 or the properties
-        cannot be read from the file name.
-    @li CPL_ERROR_FILE_IO   The file name does not exist.
-    @li CPL_ERROR_BAD_FILE_FORMAT   The file name is not a valid FITS file.
-    @li CPL_ERROR_DATA_NOT_FOUND    The requested data set at index position
-        does not exist.
+  @brief    Extracts a @li main_fits_desc from a fits-file.
+  @param filename   The filename and path of the fits-file to describe.
+  @return   The function returns a structure of type @c main_fits_desc.
+
+  Creates a structure of type @c main_fits_desc which contains all values
+  relevant to the KMOS-pipeline of a given fits-file.
+  These are: NAXIS, NAXIS1, NAXIS2, NAXIS3, KMOS_TYPE, EX_NOISE, NR_EXT
+  The values are extracted from the main fits-header and from the headers
+  of eventually existing extensions.
+  The data from extensions is stored in the structure-member @c sub_desc .
+  
+  It is assumed, that RAW-files have empty main-header (NAXIS = 0) and
+  that 3 extensions exist all with NAXIS=2 and that NAXIS1 and NAXIS2 of
+  all 3 extansions have the same values each and it is assumed by default,
+  that raw is data, so EX_NOISE will be FALSE
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c filename is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT The position is less than 0 or the properties
+      cannot be read from the file name.
+  @li CPL_ERROR_FILE_IO   The file name does not exist.
+  @li CPL_ERROR_BAD_FILE_FORMAT   The file name is not a valid FITS file.
+  @li CPL_ERROR_DATA_NOT_FOUND    The requested data set at index position
+      does not exist.
 */
+/*----------------------------------------------------------------------------*/
 main_fits_desc kmo_identify_fits_header(const char *filename)
 {
     cpl_propertylist    *main_header    = NULL,
@@ -586,44 +574,34 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
 
     KMO_TRY
     {
-        // init to default
+        /* Initialize */
         kmo_init_fits_desc(&desc);
         KMO_TRY_CHECK_ERROR_STATE();
 
-        // check input
-        KMO_TRY_ASSURE(filename != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
+        /* Check input */
+        KMO_TRY_ASSURE(filename != NULL, CPL_ERROR_NULL_INPUT,
+                "No input data is provided");
 
+        /* Load the Primary Header */
         KMO_TRY_EXIT_IF_NULL(
             main_header = kmclipm_propertylist_load(filename, 0));
 
+        /* Check input */
         KMO_TRY_ASSURE(cpl_propertylist_get_int(main_header, NAXIS) == 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Primary extension must be empty!");
-
-        if (cpl_error_get_code() != CPL_ERROR_NONE) {
-            cpl_msg_error(cpl_func, "File '%s' not found", filename);
-            KMO_TRY_CHECK_ERROR_STATE();
-        }
-
-        KMO_TRY_EXIT_IF_NULL(
-            frame = cpl_frame_new());
-
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_filename(frame, filename));
+                CPL_ERROR_ILLEGAL_INPUT, "Primary extension must be empty");
 
+        /* Get the Number of extensions */
+        KMO_TRY_EXIT_IF_NULL(frame = cpl_frame_new());
+        KMO_TRY_EXIT_IF_ERROR(cpl_frame_set_filename(frame, filename));
         desc.nr_ext = cpl_frame_get_nextensions(frame);
         KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_ASSURE(desc.nr_ext > 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "There is only one (primary?) extension!");
+        KMO_TRY_ASSURE(desc.nr_ext > 0, CPL_ERROR_ILLEGAL_INPUT,
+                "No Extension Found");
 
-        // check if EXTNAME keywords in subheaders correspond to "CHIPx.INTy"
-        // notation
-        // if yes: it is a RAW file, otherwise it must have been processed by
-        // KMOS pipeline or it is invalid
+        /* Check if the frame is RAW */
+        /* All EXTNAME values of all extensions must contain "CHIP" */
+        /* Otherwise, is_raw is set to FALSE */
         if (desc.nr_ext == KMOS_NR_DETECTORS) {
             is_raw = TRUE;
             i = 1;
@@ -634,26 +612,23 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                 KMO_TRY_EXIT_IF_NULL(
                     extname = cpl_propertylist_get_string(sub_header, EXTNAME));
 
+                /* Check if extname contains "CHIP" */
                 result = strstr(extname, EXTNAME_RAW);
-
-                if (result ==  NULL) {
-                    is_raw = FALSE;
-                }
+                if (result ==  NULL)    is_raw = FALSE;
                 cpl_propertylist_delete(sub_header); sub_header = NULL;
                 i++;
             }
         }
 
-        KMO_TRY_EXIT_IF_NULL(
-            desc.sub_desc = (sub_fits_desc*)cpl_malloc(desc.nr_ext *
-                                                   sizeof(sub_fits_desc)));
+        /* Allocate the sub_desc for each extension */
+        KMO_TRY_EXIT_IF_NULL(desc.sub_desc = (sub_fits_desc*)cpl_malloc(
+                    desc.nr_ext * sizeof(sub_fits_desc)));
 
         if (is_raw) {
             /* RAW fits-file */
-            KMO_TRY_ASSURE(desc.nr_ext == KMOS_NR_DETECTORS,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "RAW frame must have primary extension plus 3 "
-                           "data extensions!");
+            KMO_TRY_ASSURE(desc.nr_ext == KMOS_NR_DETECTORS, 
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "RAW frame must have primary unit and 3 extensions");
 
             desc.fits_type = raw_fits;
             desc.frame_type = detector_frame;
@@ -663,16 +638,15 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
             for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
                 KMO_TRY_EXIT_IF_NULL(
                     sub_header = kmclipm_propertylist_load(filename, i));
-
                 KMO_TRY_ASSURE(cpl_propertylist_has(sub_header, XTENSION),
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "All extensions need the XTENSION keyword!");
-
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "All extensions need the XTENSION keyword!");
                 KMO_TRY_ASSURE(
-                    strcmp(IMAGE,cpl_propertylist_get_string(sub_header,
-                                                             XTENSION)) == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "XTENSION keyword must be IMAGE!");
+                        strcmp(IMAGE, 
+                            cpl_propertylist_get_string(sub_header, XTENSION)) 
+                        == 0,
+                    CPL_ERROR_ILLEGAL_INPUT, 
+                    "XTENSION keyword must be IMAGE!");
 
                 if (i == 1) {
                     desc.naxis  = cpl_propertylist_get_int(sub_header, NAXIS);
@@ -686,26 +660,21 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                     n2 = cpl_propertylist_get_int(sub_header, NAXIS2);
                     KMO_TRY_CHECK_ERROR_STATE();
 
-                    KMO_TRY_ASSURE((n == desc.naxis) &&
-                                   (n1 == desc.naxis1) &&
-                                   (n2 == desc.naxis2),
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "All data frames must have the same dimensions!");
+                    KMO_TRY_ASSURE((n == desc.naxis) && (n1 == desc.naxis1) &&
+                            (n2 == desc.naxis2), CPL_ERROR_ILLEGAL_INPUT,
+                            "All data frames must have the same dimensions");
                 }
 
-                desc.sub_desc[i-1] = kmo_identify_fits_sub_header(
-                                        i,
-                                        desc.naxis > 0,
-                                        0,
-                                        0,
-                                        cpl_propertylist_get_int(sub_header,
-                                                                 CHIPINDEX));
+                desc.sub_desc[i-1] = kmo_identify_fits_sub_header(i, 
+                        desc.naxis > 0, 0, 0,
+                        cpl_propertylist_get_int(sub_header, CHIPINDEX));
                 KMO_TRY_CHECK_ERROR_STATE();
-
                 cpl_propertylist_delete(sub_header); sub_header = NULL;
             }
         } else {
             /* other than RAW fits-file */
+
+            /* Create Local Infos Holders */
             KMO_TRY_EXIT_IF_NULL(
                 arr_naxis   = (int*)cpl_calloc(desc.nr_ext, sizeof(int)));
             KMO_TRY_EXIT_IF_NULL(
@@ -716,7 +685,7 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                 arr_naxis3  = (int*)cpl_calloc(desc.nr_ext, sizeof(int)));
             KMO_TRY_EXIT_IF_NULL(
                 arr_type    = (enum kmo_frame_type*)cpl_calloc(desc.nr_ext,
-                                                  sizeof(enum kmo_frame_type)));
+                    sizeof(enum kmo_frame_type)));
             KMO_TRY_EXIT_IF_NULL(
                 arr_id      = (int*)cpl_calloc(desc.nr_ext, sizeof(int)));
             KMO_TRY_EXIT_IF_NULL(
@@ -731,30 +700,30 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
             }
             KMO_TRY_CHECK_ERROR_STATE();
 
-            // gather data from all sub_headers
+            /* Gather Informations from all sub_headers */
             for (i = 0; i < desc.nr_ext; i++) {
                 KMO_TRY_EXIT_IF_NULL(
                     sub_header = kmclipm_propertylist_load(filename, i+1));
-
                 KMO_TRY_EXIT_IF_NULL(
                     extname = cpl_propertylist_get_string(sub_header, EXTNAME));
-
                 arr_naxis[i]  = cpl_propertylist_get_int(sub_header, NAXIS);
+
+                /* XTENSION = IMAGE */
                 if (strcmp(IMAGE,
-                        cpl_propertylist_get_string(sub_header, XTENSION)) == 0)
-                {
+                            cpl_propertylist_get_string(sub_header, XTENSION)) 
+                        == 0) {
                     arr_xtension[i] = IMAGE;
 
                     // gather NAXIS keywords
                     if (arr_naxis[i] > 0) {
                         arr_naxis1[i] = cpl_propertylist_get_int(sub_header,
-                                                                 NAXIS1);
+                                NAXIS1);
                         if (arr_naxis[i] > 1) {
                             arr_naxis2[i] = cpl_propertylist_get_int(sub_header,
-                                                                     NAXIS2);
+                                    NAXIS2);
                             if (arr_naxis[i] > 2) {
-                                arr_naxis3[i] = cpl_propertylist_get_int(sub_header,
-                                                                         NAXIS3);
+                                arr_naxis3[i] = 
+                                    cpl_propertylist_get_int(sub_header,NAXIS3);
                             } else {
                                 arr_naxis3[i] = 0;
                             }
@@ -774,10 +743,8 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                         arr_type[i] = spectrum_frame;
                     } else {
                         KMO_TRY_EXIT_IF_ERROR(
-                            kmo_extname_extractor(extname,
-                                                  &(arr_type[i]),
-                                                  &(arr_id[i]),
-                                                  arr_content[i]));
+                            kmo_extname_extractor(extname, &(arr_type[i]),
+                                &(arr_id[i]), arr_content[i]));
                         if (arr_type[i] == illegal_frame) {
                             // try to recover
                             if (arr_naxis[i] == 2) {
@@ -787,11 +754,9 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                                 recovered=TRUE;
                             }
                             if ((i > 0) && (arr_type[i-1] != arr_type[i])) {
-                                 KMO_TRY_ASSURE(1==0,
-                                                CPL_ERROR_ILLEGAL_INPUT,
-                                                "NAXIS isn't the same "
-                                                "for ext %d and %d!",
-                                                i, i+1);
+                                 KMO_TRY_ASSURE(1==0, CPL_ERROR_ILLEGAL_INPUT,
+                                         "NAXIS is different for ext %d and %d",
+                                         i, i+1);
                             }
                         }
 
@@ -806,16 +771,15 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                             arr_id[i] = i+1;
                             arr_xtension[i] = BINTABLE;
                         } else {
-                            KMO_TRY_ASSURE(1==0,
-                                           CPL_ERROR_ILLEGAL_INPUT,
-                                           "First subheader has a content flag "
-                                           "of %s  (instead of DATA, NOISE or "
-                                           "BADPIX)", arr_content[i]);
+                            KMO_TRY_ASSURE(1==0, CPL_ERROR_ILLEGAL_INPUT,
+"First subheader has a content flag of %s (instead of DATA, NOISE or BADPIX)",
+                                arr_content[i]);
                         }
                     }
                 } else if (strcmp(BINTABLE,
-                        cpl_propertylist_get_string(sub_header, XTENSION)) == 0)
-                {
+                            cpl_propertylist_get_string(sub_header, 
+                                XTENSION)) == 0) {
+                /* XTENSION = BINTABLE */
                     nr_list++;
                     arr_xtension[i] = BINTABLE;
 
@@ -830,29 +794,26 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                                                              NAXIS2);
 
                     KMO_TRY_ASSURE(strstr(extname, EXT_LIST) != NULL,
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "EXTNAME keyword should contain 'LIST'");
+                            CPL_ERROR_ILLEGAL_INPUT,
+                            "EXTNAME keyword should contain 'LIST'");
                 } else {
-                    KMO_TRY_ASSURE(1==0,
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "XTENSION keyword must be IMAGE or BINTABLE!");
+                /* XTENSION seems wrong */
+                    KMO_TRY_ASSURE(1==0, CPL_ERROR_ILLEGAL_INPUT,
+                            "XTENSION keyword must be IMAGE or BINTABLE");
                 }
-
                 cpl_propertylist_delete(sub_header); sub_header = NULL;
             }
 
-            // set (and check) desc.type here
+            /* Set (and check) desc.type here */
             desc.frame_type = arr_type[0];
             tmp_xtension = arr_xtension[0];
             for (i = 1; i < desc.nr_ext; i++) {
                 KMO_TRY_ASSURE(desc.frame_type == arr_type[i],
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "frame type of all frames must be the same!");
-
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "frame type of all frames must be the same");
                 KMO_TRY_ASSURE(strcmp(tmp_xtension, arr_xtension[i]) == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "XTENSION keyword must be the same for all "
-                               "extensions!");
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "XTENSION keyword must be the same for all extensions");
             }
 
             if (desc.frame_type == detector_frame) {
@@ -864,18 +825,17 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                     desc.fits_type = b2d_fits;
 
                     KMO_TRY_ASSURE((nr_data == 0) && (nr_noise == 0),
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "If badpix frames exists, there mustn't be "
-                                   "data or noise frames!");
+                            CPL_ERROR_ILLEGAL_INPUT,
+            "If badpix frames exists, there mustn't be data or noise frames!");
 
                     KMO_TRY_ASSURE(desc.nr_ext % KMOS_NR_DETECTORS ==0,
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "B2D must have 3 * x extensions (plus primary one)!");
+                            CPL_ERROR_ILLEGAL_INPUT,
+                        "B2D must have 3 * x extensions (plus primary one)!");
 
                     for (i = 0; i < desc.nr_ext; i++) {
                         KMO_TRY_ASSURE(arr_naxis[i] == 2,
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "For B2D frames NAXIS must be 2!");
+                                CPL_ERROR_ILLEGAL_INPUT,
+                                "For B2D frames NAXIS must be 2!");
                     }
 
                     desc.naxis = arr_naxis[0];
@@ -887,47 +847,38 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                             desc.naxis = arr_naxis[i];
                         }
                         KMO_TRY_ASSURE((desc.naxis == arr_naxis[i]) ||
-                                       (desc.naxis == 0),
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "NAXIS must equal to 2 (or 0 if the whole "
-                                       "extension is invalid)!");
+                                (desc.naxis == 0), CPL_ERROR_ILLEGAL_INPUT,
+            "NAXIS must equal to 2 (or 0 if the whole extension is invalid)");
 
                         KMO_TRY_ASSURE((desc.naxis1 == arr_naxis1[i]) &&
-                                       (desc.naxis2 == arr_naxis2[i]),
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "NAXIS1 and NAXIS2 have to be the same for "
-                                       "all frames!");
+                                (desc.naxis2 == arr_naxis2[i]),
+                                CPL_ERROR_ILLEGAL_INPUT,
+                    "NAXIS1 and NAXIS2 have to be the same for all frames!");
                     }
 
                     // fill sub_desc
                     for (i = 0; i < desc.nr_ext; i++) {
-
                         desc.sub_desc[i] = kmo_identify_fits_sub_header(i+1,
-                                                           TRUE,
-                                        strcmp(arr_content[i], EXT_NOISE) == 0,
-                                        strcmp(arr_content[i], EXT_BADPIX) == 0,
-                                                            arr_id[i]);
+                                TRUE, strcmp(arr_content[i], EXT_NOISE) == 0,
+                                strcmp(arr_content[i], EXT_BADPIX) == 0,
+                                arr_id[i]);
                         KMO_TRY_CHECK_ERROR_STATE();
                     }
 
                     // check indices uniqueness of the ids
                     // (or twiceness when noise exists)
-                    KMO_TRY_ASSURE(kmo_check_indices(arr_id, desc.nr_ext, desc.ex_noise),
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "The IDs of the frame seem to be incorrect"
-                                   "(1, 2 and 3 expected)");
-
+                    KMO_TRY_ASSURE(kmo_check_indices(arr_id, desc.nr_ext, 
+                                desc.ex_noise), 
+                            CPL_ERROR_ILLEGAL_INPUT,
+            "The IDs of the frame seem to be incorrect (1, 2 and 3 expected)");
                 } else {
-                    KMO_TRY_ASSURE(nr_data > 0,
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "There must be data frames if there are no "
-                                   "badpix frames!");
+                    KMO_TRY_ASSURE(nr_data > 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "There must be data frames if there are no badpix frames");
 
                     if (desc.ex_noise) {
                         KMO_TRY_ASSURE((nr_data == nr_noise),
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "The number of data and noise frames "
-                                       "must be the same!");
+                                CPL_ERROR_ILLEGAL_INPUT,
+                    "The number of data and noise frames must be the same");
                     }
 
                     desc.naxis = arr_naxis[my_id];
@@ -943,41 +894,31 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                         } else {
                             if (arr_naxis[i] != 0) {
                                 KMO_TRY_ASSURE(desc.naxis == arr_naxis[i],
-                                               CPL_ERROR_ILLEGAL_INPUT,
-                                               "NAXIS has to be the same value for "
-                                               "all extensions (or 0 if invalid)!");
+                                        CPL_ERROR_ILLEGAL_INPUT,
+        "NAXIS has to be the same value for all extensions (or 0 if invalid)!");
 
                                 if ((!emit_once1) &&
                                     (arr_naxis1[i] != 0) &&
-                                    (desc.naxis1 != arr_naxis1[i]))
-                                {
+                                    (desc.naxis1 != arr_naxis1[i])) {
                                     cpl_msg_warning(cpl_func,
-                                                    "NAXIS1 differs at least between "
-                                                    "extensions %d and %d (%d and "
-                                                    "%d), have any IFUs been rotated?",
-                                                    my_id, i, desc.naxis1,
-                                                    arr_naxis1[i]);
+                                            "NAXIS1 differs at least between extensions %d and %d (%d and %d), have any IFUs been rotated?",
+                                            my_id,i,desc.naxis1,arr_naxis1[i]);
                                     emit_once1 = TRUE;
                                 }
                                 if (desc.naxis > 1) {
-                                    if ((!emit_once2) &&
-                                        (arr_naxis2[i] != 0) &&
-                                        (desc.naxis2 != arr_naxis2[i]))
-                                    {
+                                    if ((!emit_once2) && (arr_naxis2[i] != 0) &&
+                                            (desc.naxis2 != arr_naxis2[i])) {
                                         cpl_msg_warning(cpl_func,
-                                                        "NAXIS2 differs at least "
-                                                        "between extensions %d and "
-                                                        "%d (%d and %d), have any "
-                                                        "IFUs been rotated?", my_id,
-                                                        i, desc.naxis2, arr_naxis2[i]);
+                                            "NAXIS2 differs at least between extensions %d and %d (%d and %d), have any IFUs been rotated?",
+                                            my_id,i,desc.naxis2,arr_naxis2[i]);
                                         emit_once2 = TRUE;
                                     }
 
-                                    KMO_TRY_ASSURE((desc.naxis1 == arr_naxis1[i]) &&
-                                                   (desc.naxis2 == arr_naxis2[i]),
-                                                   CPL_ERROR_ILLEGAL_INPUT,
-                                                   "NAXIS1 and NAXIS2 have to be the same for "
-                                                   "all frames!");
+                                    KMO_TRY_ASSURE(
+                                            (desc.naxis1 == arr_naxis1[i]) &&
+                                            (desc.naxis2 == arr_naxis2[i]),
+                                            CPL_ERROR_ILLEGAL_INPUT,
+                    "NAXIS1 and NAXIS2 have to be the same for all frames!");
                                 }
                             }
                         }
@@ -991,80 +932,56 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                         desc.fits_type = f2d_fits;
                         break;
                     default:
-                        cpl_msg_warning(cpl_func, "All extensions are empty, "
-                                                  "assume F3I as type!");
+                        cpl_msg_warning(cpl_func, 
+                                "All extensions empty, assume F3I as type!");
                         desc.fits_type = f3i_fits;
                     }
 
                     if (desc.fits_type == f2d_fits) {
                         KMO_TRY_ASSURE((desc.nr_ext % KMOS_NR_DETECTORS == 0),
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "%s: F2D must have 3 * x extensions (plus "
-                                       "primary one)!", filename);
+                                CPL_ERROR_ILLEGAL_INPUT,
+                    "%s: F2D must have 3 * x extensions (plus primary one)!", 
+                                filename);
                     }
 
                     // fill sub_desc
                     for (i = 0; i < desc.nr_ext; i++) {
-
-                        desc.sub_desc[i] = kmo_identify_fits_sub_header(i+1,
-                                                            arr_naxis[i] > 0,
-                                        strcmp(arr_content[i], EXT_NOISE) == 0,
-                                        strcmp(arr_content[i], EXT_BADPIX) == 0,
-                                                            arr_id[i]);
+                        desc.sub_desc[i] = kmo_identify_fits_sub_header(
+                                i+1,
+                                arr_naxis[i] > 0, 
+                                strcmp(arr_content[i], EXT_NOISE) == 0,
+                                strcmp(arr_content[i], EXT_BADPIX) == 0,
+                                arr_id[i]);
                         KMO_TRY_CHECK_ERROR_STATE();
                     }
 
                     // check indices uniqueness of the ids
                     // (or twiceness when noise exists)
-                    KMO_TRY_ASSURE(kmo_check_indices(arr_id, desc.nr_ext,
-                    desc.ex_noise),
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "The IDs of the frame seem to be incorrect"
-                                   "(1, 2 and 3 expected)");
+                    KMO_TRY_ASSURE(
+                            kmo_check_indices(arr_id,desc.nr_ext,desc.ex_noise),
+                            CPL_ERROR_ILLEGAL_INPUT,
+            "The IDs of the frame seem to be incorrect (1, 2 and 3 expected)");
                 }
             } else if (desc.frame_type == ifu_frame) {
                 // check here if F1I, F2I or F3I with or without noise
-                KMO_TRY_ASSURE(nr_badpix == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "F1I, F2I or F3I frames can't contain badpix"
-                               "information!");
+                KMO_TRY_ASSURE(nr_badpix == 0, CPL_ERROR_ILLEGAL_INPUT,
+                        "F1I, F2I or F3I frames can't contain badpix infos");
 
-                KMO_TRY_ASSURE(nr_data > 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "For F1I, F2I or F3I there must be data frames!");
+                KMO_TRY_ASSURE(nr_data > 0, CPL_ERROR_ILLEGAL_INPUT,
+                        "For F1I, F2I or F3I there must be data frames");
 
                 if (nr_noise > 0) {
-                    KMO_TRY_ASSURE(nr_data == nr_noise,
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "For F1I, F2I or F3I the number of data and "
-                                   "noise frames must be the same!");
+                    KMO_TRY_ASSURE(nr_data == nr_noise, CPL_ERROR_ILLEGAL_INPUT,
+"For F1I, F2I or F3I the number of data and noise frames must be the same!");
                 }
 
                 desc.ex_badpix = 0;
                 desc.ex_noise = nr_noise > 0;
 
                 KMO_TRY_ASSURE((desc.nr_ext >= 1) &&
-                               (desc.nr_ext <= 2*KMOS_NR_IFUS),
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "F1I, F2I and F3I can have 1-24 extensions, "
-                               "2-48 with noise frames (plus primary one)!");
-
-                // emit warning if F1I, F2I or F3I have an other number of
-                // extensions than 1 or 24 (2 or 48 with noise)
-//                if (((desc.nr_ext > 2) && (desc.nr_ext < KMOS_NR_IFUS)) ||
-//                    ((desc.nr_ext > KMOS_NR_IFUS) && (desc.nr_ext < 2*KMOS_NR_IFUS))) {
-//                    cpl_msg_warning(cpl_func, "F1I, F2I and F3I should have 1 "
-//                                    "or 24 extensions (2 or 48 with noise!)");
-//                }
-
-// too restrictive
-//                KMO_TRY_ASSURE((desc.nr_ext == 1) ||
-//                               (desc.nr_ext == 2) ||
-//                               (desc.nr_ext == KMOS_NR_IFUS) ||
-//                               (desc.nr_ext == 2*KMOS_NR_IFUS),
-//                               CPL_ERROR_ILLEGAL_INPUT,
-//                               "F1I, F2I and F3I can have 1 or 24 extensions, "
-//                               "2 or 48 with noise frames (plus primary one)!");
+                        (desc.nr_ext <= 2*KMOS_NR_IFUS),
+                        CPL_ERROR_ILLEGAL_INPUT,
+        "F1I, F2I and F3I can have 1-24 extensions, 2-48 with noise frames (plus primary one)!");
 
                 desc.naxis = arr_naxis[my_id];
                 desc.naxis1 = arr_naxis1[my_id];
@@ -1080,51 +997,37 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                     } else {
                         if (arr_naxis[i] != 0) {
                             KMO_TRY_ASSURE(desc.naxis == arr_naxis[i],
-                                           CPL_ERROR_ILLEGAL_INPUT,
-                                           "NAXIS has to be the same value for "
-                                           "all extensions (or 0 if invalid)!");
-
-                            if ((!emit_once1) &&
-                                (arr_naxis1[i] != 0) &&
-                                (desc.naxis1 != arr_naxis1[i]))
-                            {
+                                    CPL_ERROR_ILLEGAL_INPUT,
+        "NAXIS has to be the same value for all extensions (or 0 if invalid)!");
+
+                            if ((!emit_once1) && (arr_naxis1[i] != 0) &&
+                                (desc.naxis1 != arr_naxis1[i])) {
                                 if (!kmclipm_omit_warning_one_slice) {
                                     cpl_msg_warning(cpl_func,
-                                                    "NAXIS1 differs at least between "
-                                                    "extensions %d and %d (%d and "
-                                                    "%d), have any IFUs been rotated?",
-                                                    my_id, i, desc.naxis1,
-                                                    arr_naxis1[i]);
+                    "NAXIS1 differs at least between extensions %d and %d (%d and %d), have any IFUs been rotated?",
+                    
+                                        my_id, i, desc.naxis1, arr_naxis1[i]);
                                 }
                                 emit_once1 = TRUE;
                             }
                             if (desc.naxis > 1) {
-                                if ((!emit_once2) &&
-                                    (arr_naxis2[i] != 0) &&
-                                    (desc.naxis2 != arr_naxis2[i]))
-                                {
+                                if ((!emit_once2) && (arr_naxis2[i] != 0) &&
+                                    (desc.naxis2 != arr_naxis2[i])) {
                                     if (!kmclipm_omit_warning_one_slice) {
                                         cpl_msg_warning(cpl_func,
-                                                        "NAXIS2 differs at least "
-                                                        "between extensions %d and "
-                                                        "%d (%d and %d), have any "
-                                                        "IFUs been rotated?", my_id,
-                                                        i, desc.naxis2, arr_naxis2[i]);
+                "NAXIS2 differs at least between extensions %d and %d (%d and %d), have any IFUs been rotated?", 
+                                            my_id,i,desc.naxis2, arr_naxis2[i]);
                                     }
                                     emit_once2 = TRUE;
                                 }
                                 if (desc.naxis > 2) {
-                                    if ((!emit_once3) &&
-                                        (arr_naxis3[i] != 0) &&
-                                        (desc.naxis3 != arr_naxis3[i]))
-                                    {
+                                    if ((!emit_once3) && (arr_naxis3[i] != 0) &&
+                                        (desc.naxis3 != arr_naxis3[i])) {
                                         cpl_msg_warning(cpl_func,
-                                                        "NAXIS2 differs at least "
-                                                        "between extensions %d and "
-                                                        "%d (%d and %d), have "
-                                                        "any IFUs been rotated?",
-                                                        my_id, i, desc.naxis3,
-                                                        arr_naxis3[i]);
+                                                    
+                "NAXIS2 differs at least between extensions %d and %d (%d and %d), have any IFUs been rotated?",
+                                                        
+                                            my_id,i,desc.naxis3, arr_naxis3[i]);
                                         emit_once3 = TRUE;
                                     }
                                 }
@@ -1144,73 +1047,59 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                     desc.fits_type = f3i_fits;
                     break;
                 default:
-                    cpl_msg_warning(cpl_func, "All extensions are empty, "
-                                              "assume F3I as type!");
+                    cpl_msg_warning(cpl_func, 
+                            "All extensions are empty, assume F3I as type!");
                     desc.fits_type = f3i_fits;
                 }
 
                 // fill sub_desc
                 for (i = 0; i < desc.nr_ext; i++) {
                     if (!recovered) {
-                        KMO_TRY_EXIT_IF_NULL(
-                            ifu_notused = cpl_sprintf("%s%d%s", IFU_VALID_PREFIX, arr_id[i], IFU_VALID_POSTFIX));
-                        valid = !cpl_propertylist_has(main_header,ifu_notused) && arr_naxis[i] > 0;
+                        KMO_TRY_EXIT_IF_NULL(ifu_notused = cpl_sprintf("%s%d%s",
+                                    IFU_VALID_PREFIX, arr_id[i], 
+                                    IFU_VALID_POSTFIX));
+                        valid = !cpl_propertylist_has(main_header,ifu_notused) 
+                            && arr_naxis[i] > 0;
                     } else {
                         valid = TRUE;
                     }
-                    desc.sub_desc[i] = kmo_identify_fits_sub_header(i+1,
-                                                                    valid,
-                                                                    strcmp(arr_content[i], EXT_NOISE) == 0,
-                                                                    strcmp(arr_content[i], EXT_BADPIX) == 0,
-                                                                    arr_id[i]);
+                    desc.sub_desc[i] = kmo_identify_fits_sub_header(i+1, valid,
+                            strcmp(arr_content[i], EXT_NOISE) == 0, 
+                            strcmp(arr_content[i], EXT_BADPIX) == 0, arr_id[i]);
                     cpl_free(ifu_notused); ifu_notused= NULL;
                     KMO_TRY_CHECK_ERROR_STATE();
                 }
 
                 // check indices uniqueness of the ids
                 // (or twiceness when noise exists)
-                KMO_TRY_ASSURE(kmo_check_indices(arr_id, desc.nr_ext, desc.ex_noise),
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "The IDs of the frame seem to be incorrect"
-                               "(1, 2 and 3 expected)");
+                KMO_TRY_ASSURE(kmo_check_indices(arr_id, desc.nr_ext, 
+                            desc.ex_noise), CPL_ERROR_ILLEGAL_INPUT,
+            "The IDs of the frame seem to be incorrect (1, 2 and 3 expected)");
             } else if (desc.frame_type == spectrum_frame) {
-                KMO_TRY_ASSURE(desc.nr_ext == 1,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "A F1S frame can contain only one "
-                               "spectrum!");
-
+                KMO_TRY_ASSURE(desc.nr_ext == 1, CPL_ERROR_ILLEGAL_INPUT,
+                        "A F1S frame can contain only one spectrum");
                 desc.naxis = arr_naxis[0];
                 desc.naxis1 = arr_naxis1[0];
                 desc.naxis2 = arr_naxis2[0];
                 desc.naxis3 = arr_naxis3[0];
 
-                KMO_TRY_ASSURE((desc.naxis == 1) &&
-                               (desc.naxis2 == 0) &&
-                               (desc.naxis3 == 0),
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "A F1S must have NAXIS = 1, NAXIS2 = 0, "
-                               "NAXIS3 = 0!");
-
+                KMO_TRY_ASSURE((desc.naxis == 1) && (desc.naxis2 == 0) &&
+                        (desc.naxis3 == 0), CPL_ERROR_ILLEGAL_INPUT,
+                        "A F1S must have NAXIS = 1, NAXIS2 = 0, NAXIS3 = 0!");
                 desc.fits_type = f1s_fits;
                 desc.ex_noise = 0;
                 desc.ex_badpix = 0;
-                desc.sub_desc[0] = kmo_identify_fits_sub_header(1,
-                                            TRUE,
-                                            0,
-                                            0,
-                                            1);
+                desc.sub_desc[0] = kmo_identify_fits_sub_header(1, TRUE,0,0,1);
                 KMO_TRY_CHECK_ERROR_STATE();
             } else if (desc.frame_type == list_frame) {
-                KMO_TRY_ASSURE(((desc.nr_ext >= 1) &&
-                               (desc.nr_ext <= KMOS_NR_IFUS)) || desc.nr_ext % 24 == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "F1L and F2L can have 1-24 extensions, or multiple of 24!");
+                KMO_TRY_ASSURE(((desc.nr_ext >= 1)&&(desc.nr_ext<=KMOS_NR_IFUS))
+                        || desc.nr_ext % 24 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "F1L and F2L can have 1-24 extensions, or multiple of 24");
 
                 // do we have to store the value of TFIELDS here?
                 // I think this is not needed (although almost everything is
                 // prepared to do so...
 
-
                 my_id = 0;
                 for (i = 0; i < desc.nr_ext; i++) {
                     if (arr_naxis[i] > 0) {
@@ -1220,9 +1109,8 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                 }
                 desc.naxis = arr_naxis[my_id];
 
-                KMO_TRY_ASSURE(desc.naxis == 2,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "A F1L or F2L must have NAXIS = 2!");
+                KMO_TRY_ASSURE(desc.naxis == 2, CPL_ERROR_ILLEGAL_INPUT,
+                        "A F1L or F2L must have NAXIS = 2");
 
                 desc.naxis1 = arr_tfields[my_id];
                 desc.naxis2 = arr_naxis2[my_id];
@@ -1232,9 +1120,8 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                 } else if (arr_tfields[my_id] > 2) {
                     desc.fits_type = f2l_fits;
                 } else {
-                    KMO_TRY_ASSURE(1==0,
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "TFIELDS keyword must be >= 2!");
+                    KMO_TRY_ASSURE(1==0, CPL_ERROR_ILLEGAL_INPUT,
+                            "TFIELDS keyword must be >= 2");
                 }
                 desc.ex_noise = 0;
                 desc.ex_badpix = 0;
@@ -1242,14 +1129,13 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
                 // fill sub_desc
                 for (i = 0; i < desc.nr_ext; i++) {
                     KMO_TRY_EXIT_IF_NULL(
-                        ifu_notused = cpl_sprintf("%s%d%s", IFU_VALID_PREFIX, arr_id[i], IFU_VALID_POSTFIX));
-                    desc.sub_desc[i] = kmo_identify_fits_sub_header(i+1,
-                                                !cpl_propertylist_has(main_header,
-                                                                      ifu_notused) &&
-                                                arr_naxis[i] > 0,
-                                                strcmp(arr_content[i], EXT_NOISE) == 0,
-                                                strcmp(arr_content[i], EXT_BADPIX) == 0,
-                                                arr_id[i]);
+                        ifu_notused = cpl_sprintf("%s%d%s", IFU_VALID_PREFIX, 
+                            arr_id[i], IFU_VALID_POSTFIX));
+                    desc.sub_desc[i] = kmo_identify_fits_sub_header(i+1, 
+                            !cpl_propertylist_has(main_header, 
+                                ifu_notused) && arr_naxis[i] > 0,
+                            strcmp(arr_content[i], EXT_NOISE) == 0,
+                            strcmp(arr_content[i], EXT_BADPIX) == 0, arr_id[i]);
                     cpl_free(ifu_notused); ifu_notused = NULL;
                     KMO_TRY_CHECK_ERROR_STATE();
                 }
@@ -1287,39 +1173,35 @@ main_fits_desc kmo_identify_fits_header(const char *filename)
     return desc;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Creates a @li sub_fits_desc from a specific extension of a fits-file.
-
-    @param filename The filename and path of the fits-file to describe.
-    @param ext      The extension number (Starting at 0).
-
-    @return
-        The function returns a structure of type @c sub_desc.
-
-    Creates a structure of type @c sub_desc which contains all values
-    relevant to the KMOS-pipeline of a given fits-file.
-
-    These are: VALIDDAT, IS_NOISE, DETEC_INDEX, IFU_INDEX
-
-    The values are extracted from the headers of extensions.
-
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_NULL_INPUT    if @c filename is NULL.
-    @li CPL_ERROR_ILLEGAL_INPUT The position is less than 0 or the properties
-        cannot be read from the file name or @c ext is negative.
-    @li CPL_ERROR_FILE_IO   The file name does not exist.
-    @li CPL_ERROR_BAD_FILE_FORMAT   The file name is not a valid FITS file.
-    @li CPL_ERROR_DATA_NOT_FOUND    The requested data set at index position
-        does not exist.
+  @brief Creates a @li sub_fits_desc from a specific extension of a fits-file
+  @param ext_nr
+  @param valid_data
+  @param is_noise
+  @param is_badpix
+  @param device_nr
+  @return The function returns a structure of type @c sub_desc.
+
+  Creates a structure of type @c sub_desc which contains all values relevant 
+  to the KMOS-pipeline of a given fits-file.
+
+  Possible cpl_error_code set in this function:
+  @li CPL_ERROR_NULL_INPUT    if @c filename is NULL.
+  @li CPL_ERROR_ILLEGAL_INPUT The position is less than 0 or the properties
+      cannot be read from the file name or @c ext is negative.
+  @li CPL_ERROR_FILE_IO   The file name does not exist.
+  @li CPL_ERROR_BAD_FILE_FORMAT   The file name is not a valid FITS file.
+  @li CPL_ERROR_DATA_NOT_FOUND    The requested data set at index position
+      does not exist.
 */
-sub_fits_desc kmo_identify_fits_sub_header(int ext_nr,
-                                           int valid_data,
-                                           int is_noise,
-                                           int is_badpix,
-                                           int id)
+/*----------------------------------------------------------------------------*/
+sub_fits_desc kmo_identify_fits_sub_header(
+        int     ext_nr,
+        int     valid_data,
+        int     is_noise,
+        int     is_badpix,
+        int     device_nr)
 {
     sub_fits_desc       desc;
 
@@ -1327,12 +1209,11 @@ sub_fits_desc kmo_identify_fits_sub_header(int ext_nr,
     {
         // init to default
         kmo_init_fits_sub_desc(&desc);
-
         desc.ext_nr     = ext_nr;
         desc.valid_data = valid_data;
         desc.is_noise   = is_noise;
         desc.is_badpix  = is_badpix;
-        desc.device_nr  = id;
+        desc.device_nr  = device_nr;
 
         KMO_TRY_CHECK_ERROR_STATE();
     }
@@ -1459,20 +1340,17 @@ void kmo_free_fits_desc(main_fits_desc *desc)
     }
 }
 
+/*----------------------------------------------------------------------------*/
 /**
-    @brief
-        Initialises a @li main_fits_desc structure.
-
-    @param desc The main_fits_desc to initialise.
+  @brief    Initialises a @li main_fits_desc structure.
+  @param desc   The main_fits_desc to initialise.
 */
+/*----------------------------------------------------------------------------*/
 void kmo_init_fits_desc(main_fits_desc *desc)
 {
     KMO_TRY
     {
-        KMO_TRY_ASSURE(desc != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No input data is provided!");
-
+        KMO_TRY_ASSURE(desc != NULL, CPL_ERROR_NULL_INPUT, "Null Inputs");
         desc->fits_type = illegal_fits;
         desc->frame_type = illegal_frame;
         desc->naxis = -1;
@@ -1481,9 +1359,8 @@ void kmo_init_fits_desc(main_fits_desc *desc)
         desc->naxis3 = -1;
         desc->ex_noise = -1;
         desc->ex_badpix = -1;
-        desc->sub_desc = NULL;
         desc->nr_ext = -1;
-
+        desc->sub_desc = NULL;
     }
     KMO_CATCH
     {
diff --git a/kmos/kmo_utils.h b/kmos/kmo_utils.h
index aaf30bf..4a2467e 100644
--- a/kmos/kmo_utils.h
+++ b/kmos/kmo_utils.h
@@ -1,5 +1,4 @@
-/* $Id: kmo_utils.h,v 1.2 2012-09-11 10:20:58 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2012-09-11 10:20:58 $
- * $Revision: 1.2 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifndef KMOS_UTILS_H
 #define KMOS_UTILS_H
 
@@ -35,8 +27,9 @@
 #include <cpl.h>
 
 /*------------------------------------------------------------------------------
- *                        defines
+ *                        Defines
  *----------------------------------------------------------------------------*/
+
 #define RAW                      "RAW"
 #define F1D                      "F1D"
 #define F2D                      "F2D"
@@ -49,91 +42,77 @@
 #define F2L                      "F2L"
 
 /*------------------------------------------------------------------------------
- *                        enums
+                                Enums
  *----------------------------------------------------------------------------*/
 
 /**
-    @brief Available KMOS frame categories.
-
-    - illegal_frame:  Default initialisation frame type
-    - detector_frame: denoting a detector frame
-    - list_frame:     denoting a list frame
-    - spectrum_frame: denoting a spectrum frame
-    - ifu_frame:      denoting an IFU frame
+  @brief Available KMOS frame categories.
 */
-enum kmo_frame_type {illegal_frame,
-                     detector_frame,
-                     list_frame,
-                     spectrum_frame,
-                     ifu_frame};
+enum kmo_frame_type {
+    /* Default initialisation frame type */
+    illegal_frame,
+    detector_frame,
+    list_frame,
+    spectrum_frame,
+    ifu_frame
+};
 
 /**
-    @brief Available KMOS frame types.
-
-    - illegal_fits:  Default initialisation frame type
-    - raw_fits: raw frame
-    - f2d_fits: (obsolete)
-    - f2d_fits: processed float 2D detector frame
-    - b2d_fits: processed float 2D detector frame, badpixel
-    - f2l_fits: Table, LUT
-    - f1i_fits: processed 1D IFU vector
-    - f1l_fits: Table with two columns (e.g. wavelength, strength)
-    - f1s_fits: Spectrum, one dimensional
-    - f2i_fits: processed 2D IFU image
-    - f3i_fits: processed 3D IFU cube
+  @brief    Available KMOS frame types.
 */
-enum kmo_fits_type  {illegal_fits,
-                     raw_fits,
-                     f1d_fits,
-                     f2d_fits,
-                     b2d_fits,
-                     f2l_fits,
-                     f1i_fits,
-                     f1l_fits,
-                     f1s_fits,
-                     f2i_fits,
-                     f3i_fits};
+enum kmo_fits_type {
+    /* Default initialisation frame type */
+    illegal_fits,   
+    /* Raw frame */
+    raw_fits,
+    /* Obsolete */
+    f1d_fits,
+    /* processed float 2D detector frame */
+    f2d_fits,
+    /* processed float 2D detector frame, badpixel */
+    b2d_fits,
+    /* Table, LUT */
+    f2l_fits,
+    /* processed 1D IFU vector */
+    f1i_fits,
+    /* Table with two columns (e.g. wavelength, strength) */
+    f1l_fits,
+    /* Spectrum, one dimensional */
+    f1s_fits,
+    /* processed 2D IFU image */
+    f2i_fits,
+    /* processed 3D IFU cube */
+    f3i_fits
+};
 
 /**
     @brief IDL-like comparative operators
-
-    - eq: ==
-    - ne: !=
-    - ge: >=
-    - gt: >
-    - le: <=
-    - lt: <
 */
-enum idl_rel_ops    {eq,
-                     ne,
-                     ge,
-                     gt,
-                     le,
-                     lt};
+enum idl_rel_ops {eq, ne, ge, gt, le, lt};
 
 /*------------------------------------------------------------------------------
  *                        structs
  *----------------------------------------------------------------------------*/
 
 typedef struct {
-    int ext_nr;
-    int valid_data;
-    int is_noise;
-    int is_badpix;
-    int device_nr;
+    int     ext_nr;
+    int     valid_data;
+    int     is_noise;
+    int     is_badpix;
+    int     device_nr;
 } sub_fits_desc;
 
 typedef struct {
-    enum kmo_fits_type fits_type;
+    enum kmo_fits_type  fits_type;
     enum kmo_frame_type frame_type;
-    int naxis;
-    int naxis1;
-    int naxis2;
-    int naxis3;
-    int ex_noise;
-    int ex_badpix;
-    int nr_ext;
-    sub_fits_desc *sub_desc;    /* array */
+    int                 naxis;
+    int                 naxis1;
+    int                 naxis2;
+    int                 naxis3;
+    int                 ex_noise;
+    int                 ex_badpix;
+    int                 nr_ext;
+    sub_fits_desc   *   sub_desc; 
 } main_fits_desc;
 
 /*------------------------------------------------------------------------------
@@ -142,43 +121,33 @@ typedef struct {
 
 /* ---------------------- common functions ---------------------------------- */
 const char*         kmos_get_license(void);
-
 cpl_error_code      kmo_cut_endings(cpl_vector** vec,
                                       int *begin,
                                       int *end,
                                       int cut);
-
 cpl_error_code      kmo_easy_gaussfit(const cpl_vector *x,
                                       const cpl_vector *y,
                                       double *x0,
                                       double *sigma,
                                       double *area,
                                       double *offset);
-
 cpl_vector*         kmo_polyfit_1d(const cpl_vector *x,
                                       const cpl_vector *y,
                                       const int degree);
-
 double              kmo_to_deg(double val);
 
-
-
 /* ---------------------- enum-conversion functions ------------------------- */
 enum kmo_frame_type kmo_string_to_frame_type(const char* frame_type_str);
 
 /* ---------------------- fits-descriptor functions ------------------------- */
 main_fits_desc      kmo_identify_fits_header(const char *filename);
-
 sub_fits_desc       kmo_identify_fits_sub_header(int ext_nr,
                                                  int valid_data,
                                                  int is_noise,
                                                  int is_badpix,
                                                  int id);
-
 int                 kmo_check_indices(int *id, int nr_id, int ex_noise);
-
 void                kmo_free_fits_desc(main_fits_desc *desc);
-
 void                kmo_init_fits_desc(main_fits_desc *desc);
 void                kmo_init_fits_sub_desc(sub_fits_desc *desc);
 
@@ -186,7 +155,6 @@ void                kmo_init_fits_sub_desc(sub_fits_desc *desc);
 cpl_vector*         kmo_idl_where(const cpl_vector *data,
                                       double val,
                                       int op);
-
 cpl_vector*         kmo_idl_values_at_indices(const cpl_vector *data,
                                       const cpl_vector *indices);
 
@@ -194,23 +162,15 @@ cpl_vector*         kmo_idl_values_at_indices(const cpl_vector *data,
 cpl_array**         kmo_get_unused_ifus(const cpl_frameset *frameset,
                                         int omit_telluric,
                                         int omit_illum);
-
 cpl_error_code      kmo_set_unused_ifus(cpl_array **unused,
                                         cpl_propertylist *header,
                                         const char *recipe_name);
-
 cpl_array**         kmo_duplicate_unused_ifus(cpl_array **unused);
-
 void                kmo_print_unused_ifus(cpl_array **unused, int after);
-
 void                kmo_free_unused_ifus(cpl_array **unused);
-
 char**              kmo_strsplit(const char *str, const char *delimiter, int *size);
-
 void                kmo_strfreev(char **strarr);
-
 char*               kmo_strlower(char *);
-
 char*               kmo_strupper(char *);
 
 #endif
diff --git a/kmos/tests/create_data_kmos.c b/kmos/tests/create_data_kmos.c
index 3d5a136..54d810f 100644
--- a/kmos/tests/create_data_kmos.c
+++ b/kmos/tests/create_data_kmos.c
@@ -94,47 +94,28 @@ void kmo_test_fill_vector(cpl_vector *vec,
     }
 }
 
+/******************************************************************************/
 /**
-    @brief Fills an image with increasing values.
-
-    @param   img         The image to fill with values.
-    @param   seed        The starting value.
-    @param   offset      The offset for the values.
-
+  @brief    Fills an image with increasing values.
+  @param    img     The image to fill with values.
+  @param    seed    The starting value.
+  @param    offset  The offset for the values.
  */
-void kmo_test_fill_image(cpl_image *img,
-                         float seed,
-                         float offset)
+/******************************************************************************/
+void kmo_test_fill_image(
+        cpl_image   *   img,
+        float           seed,
+        float           offset)
 {
-    int         i       = 0,
-                j       = 0;
-    cpl_size    d       = 0,
-                x       = 0,
-                y       = 0;
-    float       *data   = NULL,
-                f       = 0.0;
+    cpl_size    npix    = 0;
+    float   *   data    = NULL ;
+    cpl_size    i ;
 
-    KMO_TRY
-    {
-        x = cpl_image_get_size_x(img);
-        y = cpl_image_get_size_y(img);
+    npix = cpl_image_get_size_x(img) * cpl_image_get_size_y(img);
+    data = cpl_image_get_data_float(img);
+    if (data == NULL) return ;
 
-
-        data = cpl_image_get_data_float(img);
-        KMO_TRY_EXIT_IF_NOT(data != NULL);
-
-        // horizontal stripes: bottom = 0, top = seed * (y-1)
-        for (i = 0; i < y; i++) {
-            for (j = 0; j < x; j++) {
-                data[d] = seed + f;
-                d++;
-                f += offset;
-            }
-        }
-    }
-    KMO_CATCH
-    {
-    }
+    for (i=0 ; i<npix ; i++) data[i] = seed + offset*i ;
 }
 
 /**
@@ -160,7 +141,7 @@ void kmo_test_fill_cube(cpl_imagelist *cube,
         for (i = 0; i < size; i++) {
             kmo_test_fill_image(cpl_imagelist_get(cube, i),
                                 seed, offset);
-                seed += offset;
+            seed += offset;
         }
     }
     KMO_CATCH
diff --git a/kmos/tests/kmo_cpl_extensions-test.c b/kmos/tests/kmo_cpl_extensions-test.c
index 8536a92..41816f7 100644
--- a/kmos/tests/kmo_cpl_extensions-test.c
+++ b/kmos/tests/kmo_cpl_extensions-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_cpl_extensions-test.c,v 1.5 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.5 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -454,7 +446,7 @@ void test_kmo_imagelist_divide()
  */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     // ---------------------- missing in CPL -----------------------------------
     test_kmo_image_histogram();
diff --git a/kmos/tests/kmo_debug-test.c b/kmos/tests/kmo_debug-test.c
index f2e69db..4e9ae6d 100644
--- a/kmos/tests/kmo_debug-test.c
+++ b/kmos/tests/kmo_debug-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_debug-test.c,v 1.3 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -141,7 +133,7 @@ void test_kmo_debug_array()
 void test_kmo_debug_desc()
 {
     kmo_test_verbose_off();
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     main_fits_desc desc = kmo_identify_fits_header(my_path);
     cpl_test_eq(CPL_ERROR_NONE, kmo_debug_desc(desc));
     kmo_test_verbose_on();
@@ -207,7 +199,7 @@ void test_kmo_plot_image()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_debug_header();
     test_kmo_debug_frameset();
diff --git a/kmos/tests/kmo_dfs-test.c b/kmos/tests/kmo_dfs-test.c
index d3539ac..b1ffb8e 100644
--- a/kmos/tests/kmo_dfs-test.c
+++ b/kmos/tests/kmo_dfs-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_dfs-test.c,v 1.12 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.12 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -190,7 +182,7 @@ void test_kmo_dfs_load_primary_header()
     cpl_propertylist    *pl         = NULL;
     cpl_frameset        *fs         = cpl_frameset_new();
     cpl_frame           *fr         = NULL;
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     fr = kmo_test_frame_new(my_path, "", CPL_FRAME_GROUP_RAW);
     cpl_frameset_insert(fs, fr);
 
@@ -220,7 +212,7 @@ void test_kmo_dfs_load_sub_header()
     cpl_propertylist    *pl         = NULL;
     cpl_frameset        *fs         = cpl_frameset_new();
     cpl_frame           *fr         = NULL;
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     fr = kmo_test_frame_new(my_path, "", CPL_FRAME_GROUP_RAW);
     cpl_frameset_insert(fs, fr);
 
@@ -635,7 +627,7 @@ void test_kmo_dfs_save_main_header()
         kmo_dfs_save_main_header(fs, "aga", NULL, NULL, NULL, NULL, ""));
     cpl_test_error(CPL_ERROR_NULL_INPUT);
 
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     fr = kmo_test_frame_new(my_path, "", CPL_FRAME_GROUP_RAW);
     cpl_frameset_insert(fs, fr);
 
@@ -676,7 +668,7 @@ void test_kmo_dfs_save_sub_header()
     cpl_test_error(CPL_ERROR_NULL_INPUT);
     kmo_test_verbose_on();
 
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     pl = cpl_propertylist_load(my_path, 1);
     cpl_test_eq(CPL_ERROR_NONE,
         kmo_dfs_save_sub_header("agaa", "", pl));
@@ -714,7 +706,7 @@ void test_kmo_dfs_save_vector()
     /* save real vector here (first save main header)*/
     cpl_parameterlist   *parl       = cpl_parameterlist_new();
     cpl_frameset        *fs         = cpl_frameset_new();
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     cpl_frame           *fr         = kmo_test_frame_new( my_path, "", CPL_FRAME_GROUP_RAW);
     cpl_frameset_insert(fs, fr);
     cpl_test_eq(CPL_ERROR_NONE,
@@ -771,7 +763,7 @@ void test_kmo_dfs_save_image()
     /* save real image here (first save main header) */
     cpl_parameterlist   *parl       = cpl_parameterlist_new();
     cpl_frameset        *fs         = cpl_frameset_new();
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     cpl_frame           *fr         = kmo_test_frame_new(my_path, "", CPL_FRAME_GROUP_RAW);
     cpl_frameset_insert(fs, fr);
     cpl_test_eq(CPL_ERROR_NONE,
@@ -834,7 +826,7 @@ void test_kmo_dfs_save_cube()
     /* save real cube here */
     cpl_parameterlist   *parl       = cpl_parameterlist_new();
     cpl_frameset        *fs         = cpl_frameset_new();
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     cpl_frame           *fr         = kmo_test_frame_new( my_path, "", CPL_FRAME_GROUP_RAW);
     cpl_frameset_insert(fs, fr);
     cpl_test_eq(CPL_ERROR_NONE,
@@ -903,7 +895,7 @@ void test_kmo_dfs_get_frame()
     cpl_test_error(CPL_ERROR_ILLEGAL_INPUT);
     kmo_test_verbose_on();
 
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     fr = kmo_test_frame_new(my_path, "", CPL_FRAME_GROUP_RAW);
     cpl_frameset_insert(fs, fr);
     cpl_frame *ff;
@@ -1154,7 +1146,7 @@ void test_kmo_identify_index()
 {
     cpl_frameset        *fs         = cpl_frameset_new();
     cpl_frame           *fr         = NULL;
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     fr = kmo_test_frame_new(my_path, "", CPL_FRAME_GROUP_RAW);
     cpl_frameset_insert(fs, fr);
 
@@ -1211,7 +1203,7 @@ void test_kmo_check_lamp()
  */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_strlower();
     test_kmo_extname_extractor();
diff --git a/kmos/tests/kmo_functions-test.c b/kmos/tests/kmo_functions-test.c
index b2fef37..8b60ba0 100644
--- a/kmos/tests/kmo_functions-test.c
+++ b/kmos/tests/kmo_functions-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_functions-test.c,v 1.4 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -51,7 +43,7 @@ void test_kmo_reconstruct_sci()
  */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_reconstruct_sci();
 
diff --git a/kmos/tests/kmo_priv_arithmetic-test.c b/kmos/tests/kmo_priv_arithmetic-test.c
index 7fe7722..1e80fae 100644
--- a/kmos/tests/kmo_priv_arithmetic-test.c
+++ b/kmos/tests/kmo_priv_arithmetic-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_arithmetic-test.c,v 1.5 2013-10-08 11:18:19 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.5 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -299,7 +291,7 @@ void test_kmo_arithmetic_3D_2D()
     kmo_test_fill_image(img, 4.4, 2.2);
     kmo_arithmetic_3D_2D(cube1, img, NULL, NULL, "*");
     cpl_test_abs(cpl_image_get(cpl_imagelist_get(cube1, 2), 4, 99, &rej),
-                 2.11496e+08, 400);
+                 2.11504e+08, 400);
 
     cpl_image_delete(img);
     cpl_imagelist_delete(cube1);
@@ -323,9 +315,9 @@ void test_kmo_arithmetic_3D_2D()
     kmo_test_fill_image(noise_img, 2.1, 0.2);
     kmo_arithmetic_3D_2D(cube1, img, noise_cube1, noise_img, "+");
     cpl_test_abs(cpl_image_get(cpl_imagelist_get(cube1, 2), 4, 99, &rej),
-                 31375.2, 2*tol);
+                 31376, 2*tol);
     cpl_test_abs(cpl_image_get(cpl_imagelist_get(noise_cube1, 2), 4, 99, &rej),
-                 2193.96, tol);
+                 2194.16, tol);
 
     cpl_image_delete(img);
     cpl_image_delete(noise_img);
@@ -469,7 +461,7 @@ void test_kmo_arithmetic_3D_scalar_noise()
  */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_arithmetic_1D_1D();
     test_kmo_arithmetic_1D_scalar();
diff --git a/kmos/tests/kmo_priv_combine-test.c b/kmos/tests/kmo_priv_combine-test.c
index 6d9c71f..e6d288a 100644
--- a/kmos/tests/kmo_priv_combine-test.c
+++ b/kmos/tests/kmo_priv_combine-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_combine-test.c,v 1.7 2013-10-08 11:19:14 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:19:14 $
- * $Revision: 1.7 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -424,7 +416,7 @@ void test_kmo_priv_combine()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_align_subpix();
     test_kmo_priv_combine();
diff --git a/kmos/tests/kmo_priv_copy-test.c b/kmos/tests/kmo_priv_copy-test.c
index 67389a8..2460794 100644
--- a/kmos/tests/kmo_priv_copy-test.c
+++ b/kmos/tests/kmo_priv_copy-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_copy-test.c,v 1.4 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -654,7 +646,7 @@ void test_kmo_copy_cube_F3I()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_copy_scalar_F1I();
     test_kmo_copy_scalar_F2I();
diff --git a/kmos/tests/kmo_priv_dark-test.c b/kmos/tests/kmo_priv_dark-test.c
index 37b504b..4ff054a 100644
--- a/kmos/tests/kmo_priv_dark-test.c
+++ b/kmos/tests/kmo_priv_dark-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_dark-test.c,v 1.3 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -167,7 +159,7 @@ void test_kmo_add_bad_pix_border()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_create_bad_pix_dark();
     test_kmo_add_bad_pix_border();
diff --git a/kmos/tests/kmo_priv_extract_spec-test.c b/kmos/tests/kmo_priv_extract_spec-test.c
index 35bc0cc..80500c5 100644
--- a/kmos/tests/kmo_priv_extract_spec-test.c
+++ b/kmos/tests/kmo_priv_extract_spec-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_extract_spec-test.c,v 1.4 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -179,7 +171,7 @@ void test_kmo_priv_update_header()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_priv_extract_spec();
     test_kmo_priv_update_header();
diff --git a/kmos/tests/kmo_priv_fit_profile-test.c b/kmos/tests/kmo_priv_fit_profile-test.c
index 2a649ae..d3e88da 100644
--- a/kmos/tests/kmo_priv_fit_profile-test.c
+++ b/kmos/tests/kmo_priv_fit_profile-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_fit_profile-test.c,v 1.3 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -682,7 +674,7 @@ void test_kmo_priv_moffat2d_fncd()
  */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     // 1D
     test_kmo_fit_profile_1D();
diff --git a/kmos/tests/kmo_priv_fits_check-test.c b/kmos/tests/kmo_priv_fits_check-test.c
index 1f63411..948d756 100644
--- a/kmos/tests/kmo_priv_fits_check-test.c
+++ b/kmos/tests/kmo_priv_fits_check-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_fits_check-test.c,v 1.3 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -173,7 +165,7 @@ void test_kmo_fits_check_print_info()
  */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_fits_check_print_header();
     test_kmo_fits_check_print_vector();
diff --git a/kmos/tests/kmo_priv_fits_stack-test.c b/kmos/tests/kmo_priv_fits_stack-test.c
index aee7078..d0f8620 100644
--- a/kmos/tests/kmo_priv_fits_stack-test.c
+++ b/kmos/tests/kmo_priv_fits_stack-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_fits_stack-test.c,v 1.3 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -446,7 +438,7 @@ void test_kmo_priv_check_dimensions()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_priv_fits_stack();
     test_kmo_priv_check_dimensions();
diff --git a/kmos/tests/kmo_priv_flat-test.c b/kmos/tests/kmo_priv_flat-test.c
index c8e2a0f..2606ba7 100644
--- a/kmos/tests/kmo_priv_flat-test.c
+++ b/kmos/tests/kmo_priv_flat-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_flat-test.c,v 1.15 2013-10-11 07:59:36 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-11 07:59:36 $
- * $Revision: 1.15 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -2036,7 +2028,7 @@ void test_kmo_calc_curvature()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_create_bad_pix_flat_thresh();
     test_kmo_calc_calib_frames();
diff --git a/kmos/tests/kmo_priv_functions-test.c b/kmos/tests/kmo_priv_functions-test.c
index 6df92f4..3c182b9 100644
--- a/kmos/tests/kmo_priv_functions-test.c
+++ b/kmos/tests/kmo_priv_functions-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_functions-test.c,v 1.8 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.8 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -665,7 +657,7 @@ void test_kmo_priv_compare_frameset_setup()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_create_lambda_vec();
     test_kmo_is_in_range();
diff --git a/kmos/tests/kmo_priv_lcorr-test.c b/kmos/tests/kmo_priv_lcorr-test.c
index d818c46..cddcaa0 100644
--- a/kmos/tests/kmo_priv_lcorr-test.c
+++ b/kmos/tests/kmo_priv_lcorr-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_lcorr-test.c,v 1.8 2013-07-04 08:24:49 erw Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: erw $
- * $Date: 2013-07-04 08:24:49 $
- * $Revision: 1.8 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -313,7 +305,7 @@ int main()
                    *obj_spectrum = NULL;
     cpl_propertylist *obj_header = NULL;
 
-    cpl_test_init("kmos-spark at mpe.mpg.de", CPL_MSG_WARNING);
+    cpl_test_init("usd-help at eso.org", CPL_MSG_WARNING);
     kmo_test_verbose_off();
 
 //    cpl_msg_set_level(CPL_MSG_INFO);
diff --git a/kmos/tests/kmo_priv_make_image-test.c b/kmos/tests/kmo_priv_make_image-test.c
index 0979571..8b073dd 100644
--- a/kmos/tests/kmo_priv_make_image-test.c
+++ b/kmos/tests/kmo_priv_make_image-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_make_image-test.c,v 1.3 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -100,39 +92,13 @@ void test_kmo_identify_slices_with_oh()
 }
 
 /**
-    @brief   test for kmo_priv_is_below_threshold()
-*/
-void test_kmo_priv_is_below_threshold()
-{
-    cpl_vector  *spec = NULL;
-
-    /* --- invalid tests --- */
-    kmo_test_verbose_off();
-    cpl_test_eq(0, kmo_priv_is_below_threshold(-1.0, NULL, -1));
-    cpl_test_error(CPL_ERROR_NULL_INPUT);
-    spec = cpl_vector_new(100);
-    cpl_test_eq(0, kmo_priv_is_below_threshold(-1.0, spec, -1));
-    cpl_test_error(CPL_ERROR_NULL_INPUT);
-    kmo_test_verbose_on();
-
-    /* --- valid tests --- */
-    kmo_test_fill_vector(spec, 1.0, 0.01);
-    cpl_test_eq(1, kmo_priv_is_below_threshold(1.5, spec, 10));
-    cpl_test_eq(0, kmo_priv_is_below_threshold(1.5, spec, 99));
-
-    cpl_vector_delete(spec);
-    cpl_test_error(CPL_ERROR_NONE);
-}
-
-/**
     @brief   Test of helper functions for kmo_make_image
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_identify_slices_with_oh();
-    test_kmo_priv_is_below_threshold();
 
     return cpl_test_end(0);
 }
diff --git a/kmos/tests/kmo_priv_noise_map-test.c b/kmos/tests/kmo_priv_noise_map-test.c
index 02fcd15..9bb89b1 100644
--- a/kmos/tests/kmo_priv_noise_map-test.c
+++ b/kmos/tests/kmo_priv_noise_map-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_noise_map-test.c,v 1.3 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -86,7 +78,7 @@ void test_kmo_calc_noise_map()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_calc_noise_map();
 
diff --git a/kmos/tests/kmo_priv_reconstruct-test.c b/kmos/tests/kmo_priv_reconstruct-test.c
index 8a4f349..7c329aa 100644
--- a/kmos/tests/kmo_priv_reconstruct-test.c
+++ b/kmos/tests/kmo_priv_reconstruct-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_reconstruct-test.c,v 1.8 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.8 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -182,7 +174,7 @@ void test_kmo_save_det_img_ext()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_calc_flux_in();
     test_kmo_calc_wcs_gd();
diff --git a/kmos/tests/kmo_priv_rotate-test.c b/kmos/tests/kmo_priv_rotate-test.c
index 115ca59..5a5e9b2 100644
--- a/kmos/tests/kmo_priv_rotate-test.c
+++ b/kmos/tests/kmo_priv_rotate-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_rotate-test.c,v 1.6 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.6 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -253,7 +245,7 @@ void test_kmo_priv_rotate()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_priv_rotate();
 
diff --git a/kmos/tests/kmo_priv_shift-test.c b/kmos/tests/kmo_priv_shift-test.c
index ce628f9..a5d3d2c 100644
--- a/kmos/tests/kmo_priv_shift-test.c
+++ b/kmos/tests/kmo_priv_shift-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_shift-test.c,v 1.5 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.5 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -302,7 +294,7 @@ void test_kmo_priv_shift()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_priv_shift();
 
diff --git a/kmos/tests/kmo_priv_sky_mask-test.c b/kmos/tests/kmo_priv_sky_mask-test.c
index 7334706..80e9ef0 100644
--- a/kmos/tests/kmo_priv_sky_mask-test.c
+++ b/kmos/tests/kmo_priv_sky_mask-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_sky_mask-test.c,v 1.3 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -140,7 +132,7 @@ void test_kmo_calc_sky_mask()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_calc_sky_mask();
 
diff --git a/kmos/tests/kmo_priv_sky_tweak-test.c b/kmos/tests/kmo_priv_sky_tweak-test.c
index 1f7fc89..e8a3478 100644
--- a/kmos/tests/kmo_priv_sky_tweak-test.c
+++ b/kmos/tests/kmo_priv_sky_tweak-test.c
@@ -1,11 +1,3 @@
-/* $Id: kmo_priv_sky_tweak-test.c,v 1.4 2013-09-13 09:10:28 erw Exp $
-
- *
- * $Author: erw $
- * $Date: 2013-09-13 09:10:28 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -133,8 +125,11 @@ void test_kmo_get_thermal_background(cpl_bivector *spectrum) {
 
     cpl_test_eq(cpl_bivector_get_size(spectrum), cpl_bivector_get_size(result));
     cpl_test_vector_abs(x_spectrum, x_result, ftol);
+
+    /* FAILING TESTS */
     cpl_test_vector_abs(ref, y_spectrum, ftol);
     cpl_test_vector_abs(th_bkg, y_result, ftol);
+    /* END FAILING TESTS */
 
     if (ref != NULL) { cpl_vector_delete(ref); }
     if (th_bkg != NULL) { cpl_vector_delete(th_bkg); }
@@ -212,13 +207,15 @@ int main(){
     cpl_vector *lambda = NULL;
     int ix;
 
-    cpl_test_init("kmos-spark at mpe.mpg.de", CPL_MSG_WARNING);
+    cpl_test_init("usd-help at eso.org", CPL_MSG_WARNING);
     kmo_test_verbose_off();
 
     char *my_path = cpl_sprintf("%s/ref_data/lcorr_obj_cube.fits", getenv("srcdir"));
     obj_header = cpl_propertylist_load(my_path,0);
     obj_cube = cpl_imagelist_load(my_path, CPL_TYPE_FLOAT, 0);
     cpl_free(my_path);
+    
+    
     obj_spectrum = kmo_lcorr_extract_spectrum(obj_cube, obj_header, 0.8, NULL);
     cpl_imagelist_delete(obj_cube);
     cpl_propertylist_delete(obj_header);
@@ -245,14 +242,10 @@ int main(){
     test_kmo_priv_sky_tweak_correct_vibrational_trans(obj_cube, sky_cube, lambda);
     test_kmo_priv_sky_tweak(obj_cube, sky_cube, obj_header);
 
-
-
     cpl_bivector_delete(obj_spectrum);
     cpl_propertylist_delete(obj_header);
     cpl_imagelist_delete(obj_cube);
     cpl_imagelist_delete(sky_cube);
     cpl_vector_delete(lambda);
-
-//    printf("Testing sky_tweak done\n");
     return cpl_test_end(0);
 }
diff --git a/kmos/tests/kmo_priv_stats-test.c b/kmos/tests/kmo_priv_stats-test.c
index 5b0d964..a6aa9e5 100644
--- a/kmos/tests/kmo_priv_stats-test.c
+++ b/kmos/tests/kmo_priv_stats-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_stats-test.c,v 1.6 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.6 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -753,7 +745,7 @@ void test_kmo_calc_remaining()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_calc_stats_cube();
     test_kmo_calc_stats_img();
diff --git a/kmos/tests/kmo_priv_std_star-test.c b/kmos/tests/kmo_priv_std_star-test.c
index 9f10d16..548541a 100644
--- a/kmos/tests/kmo_priv_std_star-test.c
+++ b/kmos/tests/kmo_priv_std_star-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_std_star-test.c,v 1.10 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.10 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -430,7 +422,7 @@ void test_kmo_calculate_std_trace()
  */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmo_get_spec_type();
     test_kmo_get_temperature();
diff --git a/kmos/tests/kmo_priv_wave_cal-test.c b/kmos/tests/kmo_priv_wave_cal-test.c
index de1df25..d516fdf 100644
--- a/kmos/tests/kmo_priv_wave_cal-test.c
+++ b/kmos/tests/kmo_priv_wave_cal-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_priv_wave_cal-test.c,v 1.4 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -99,7 +91,7 @@ void test_kmo_calc_fitted_slitlet_edge()
 
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
 //    test_kmo_calc_wave_calib();
 //    test_kmo_extract_initial_trace();
diff --git a/kmos/tests/kmo_utils-test.c b/kmos/tests/kmo_utils-test.c
index 14d02f4..8925705 100644
--- a/kmos/tests/kmo_utils-test.c
+++ b/kmos/tests/kmo_utils-test.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_utils-test.c,v 1.7 2013-10-08 11:18:19 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Library
  * Copyright (C) 2007-2008 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:19 $
- * $Revision: 1.7 $
- * $Name: not supported by cvs2svn $
-*/
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -224,7 +216,7 @@ void test_kmo_identify_fits_header()
 {
     main_fits_desc       main_desc;
 
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     main_desc = kmo_identify_fits_header(my_path);
     cpl_free(my_path);
     cpl_test_eq(3, main_desc.nr_ext);
@@ -307,7 +299,7 @@ void test_kmo_free_fits_desc()
 {
     main_fits_desc       main_desc;
 
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
+    char *my_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
     main_desc = kmo_identify_fits_header(my_path);
     cpl_free(my_path);
 
@@ -845,7 +837,7 @@ void test_kmo_strupper()
 */
 int main()
 {
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
+    cpl_test_init("<usd-help at eso.org>", CPL_MSG_WARNING);
 
     test_kmos_get_license();
     test_kmo_cut_endings();
diff --git a/recipes/Makefile.am b/recipes/Makefile.am
index 912f409..587f97c 100644
--- a/recipes/Makefile.am
+++ b/recipes/Makefile.am
@@ -21,24 +21,16 @@ AUTOMAKE_OPTIONS = 1.8 foreign
 
 DISTCLEANFILES = *~
 
-SUBDIRS = tests
-
-
 if MAINTAINER_MODE
 
 MAINTAINERCLEANFILES = Makefile.in
 
 endif
 
-
 INCLUDES = $(all_includes) 
-#INCLUDES = $(all_includes) -I../kmclipm/include/
 
 noinst_HEADERS = 
 
-#-----------------------------------------------------------------
-# plugin_LTLIBRARIES =  kmo_fit_profile.la
-
 plugin_LTLIBRARIES = kmo_arithmetic.la \
                      kmo_combine.la \
                      kmo_copy.la \
@@ -62,8 +54,7 @@ plugin_LTLIBRARIES = kmo_arithmetic.la \
                      kmo_sky_tweak.la \
                      kmo_stats.la \
                      kmo_std_star.la \
-                     kmo_wave_cal.la \
-                     kmo_dev_setup.la
+                     kmo_wave_cal.la 
 
 kmo_arithmetic_la_SOURCES = kmo_arithmetic.c
 kmo_arithmetic_la_LIBADD = $(LIBKMOS)
@@ -170,11 +161,6 @@ kmo_illumination_flat_la_LIBADD = $(LIBKMOS)
 kmo_illumination_flat_la_LDFLAGS = -module -avoid-version
 kmo_illumination_flat_la_DEPENDENCIES = $(LIBKMOS)
 
-kmo_dev_setup_la_SOURCES = kmo_dev_setup.c
-kmo_dev_setup_la_LIBADD = $(LIBKMOS)
-kmo_dev_setup_la_LDFLAGS = -module -avoid-version
-kmo_dev_setup_la_DEPENDENCIES = $(LIBKMOS)
-
 kmo_std_star_la_SOURCES = kmo_std_star.c
 kmo_std_star_la_LIBADD = $(LIBKMOS)
 kmo_std_star_la_LDFLAGS = -module -avoid-version
@@ -189,5 +175,3 @@ kmo_fits_strip_la_SOURCES = kmo_fits_strip.c
 kmo_fits_strip_la_LIBADD = $(LIBKMOS)
 kmo_fits_strip_la_LDFLAGS = -module -avoid-version
 kmo_fits_strip_la_DEPENDENCIES = $(LIBKMOS)
- 
-#-----------------------------------------------------------------
diff --git a/recipes/Makefile.in b/recipes/Makefile.in
index 03e7c51..b2c15f1 100644
--- a/recipes/Makefile.in
+++ b/recipes/Makefile.in
@@ -105,11 +105,6 @@ kmo_dark_la_OBJECTS = $(am_kmo_dark_la_OBJECTS)
 kmo_dark_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(kmo_dark_la_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_dev_setup_la_OBJECTS = kmo_dev_setup.lo
-kmo_dev_setup_la_OBJECTS = $(am_kmo_dev_setup_la_OBJECTS)
-kmo_dev_setup_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_dev_setup_la_LDFLAGS) $(LDFLAGS) -o $@
 am_kmo_extract_spec_la_OBJECTS = kmo_extract_spec.lo
 kmo_extract_spec_la_OBJECTS = $(am_kmo_extract_spec_la_OBJECTS)
 kmo_extract_spec_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -227,10 +222,10 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	$(LDFLAGS) -o $@
 SOURCES = $(kmo_arithmetic_la_SOURCES) $(kmo_combine_la_SOURCES) \
 	$(kmo_copy_la_SOURCES) $(kmo_dark_la_SOURCES) \
-	$(kmo_dev_setup_la_SOURCES) $(kmo_extract_spec_la_SOURCES) \
-	$(kmo_fit_profile_la_SOURCES) $(kmo_fits_check_la_SOURCES) \
-	$(kmo_fits_stack_la_SOURCES) $(kmo_fits_strip_la_SOURCES) \
-	$(kmo_flat_la_SOURCES) $(kmo_illumination_la_SOURCES) \
+	$(kmo_extract_spec_la_SOURCES) $(kmo_fit_profile_la_SOURCES) \
+	$(kmo_fits_check_la_SOURCES) $(kmo_fits_stack_la_SOURCES) \
+	$(kmo_fits_strip_la_SOURCES) $(kmo_flat_la_SOURCES) \
+	$(kmo_illumination_la_SOURCES) \
 	$(kmo_illumination_flat_la_SOURCES) \
 	$(kmo_make_image_la_SOURCES) \
 	$(kmo_multi_reconstruct_la_SOURCES) \
@@ -241,10 +236,10 @@ SOURCES = $(kmo_arithmetic_la_SOURCES) $(kmo_combine_la_SOURCES) \
 	$(kmo_std_star_la_SOURCES) $(kmo_wave_cal_la_SOURCES)
 DIST_SOURCES = $(kmo_arithmetic_la_SOURCES) $(kmo_combine_la_SOURCES) \
 	$(kmo_copy_la_SOURCES) $(kmo_dark_la_SOURCES) \
-	$(kmo_dev_setup_la_SOURCES) $(kmo_extract_spec_la_SOURCES) \
-	$(kmo_fit_profile_la_SOURCES) $(kmo_fits_check_la_SOURCES) \
-	$(kmo_fits_stack_la_SOURCES) $(kmo_fits_strip_la_SOURCES) \
-	$(kmo_flat_la_SOURCES) $(kmo_illumination_la_SOURCES) \
+	$(kmo_extract_spec_la_SOURCES) $(kmo_fit_profile_la_SOURCES) \
+	$(kmo_fits_check_la_SOURCES) $(kmo_fits_stack_la_SOURCES) \
+	$(kmo_fits_strip_la_SOURCES) $(kmo_flat_la_SOURCES) \
+	$(kmo_illumination_la_SOURCES) \
 	$(kmo_illumination_flat_la_SOURCES) \
 	$(kmo_make_image_la_SOURCES) \
 	$(kmo_multi_reconstruct_la_SOURCES) \
@@ -253,48 +248,10 @@ DIST_SOURCES = $(kmo_arithmetic_la_SOURCES) $(kmo_combine_la_SOURCES) \
 	$(kmo_shift_la_SOURCES) $(kmo_sky_mask_la_SOURCES) \
 	$(kmo_sky_tweak_la_SOURCES) $(kmo_stats_la_SOURCES) \
 	$(kmo_std_star_la_SOURCES) $(kmo_wave_cal_la_SOURCES)
-RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
-	html-recursive info-recursive install-data-recursive \
-	install-dvi-recursive install-exec-recursive \
-	install-html-recursive install-info-recursive \
-	install-pdf-recursive install-ps-recursive install-recursive \
-	installcheck-recursive installdirs-recursive pdf-recursive \
-	ps-recursive uninstall-recursive
 HEADERS = $(noinst_HEADERS)
-RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
-  distclean-recursive maintainer-clean-recursive
-AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
-	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
-	distdir
 ETAGS = etags
 CTAGS = ctags
-DIST_SUBDIRS = $(SUBDIRS)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-am__relativize = \
-  dir0=`pwd`; \
-  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
-  sed_rest='s,^[^/]*/*,,'; \
-  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
-  sed_butlast='s,/*[^/]*$$,,'; \
-  while test -n "$$dir1"; do \
-    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
-    if test "$$first" != "."; then \
-      if test "$$first" = ".."; then \
-        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
-        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
-      else \
-        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
-        if test "$$first2" = "$$first"; then \
-          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
-        else \
-          dir2="../$$dir2"; \
-        fi; \
-        dir0="$$dir0"/"$$first"; \
-      fi; \
-    fi; \
-    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
-  done; \
-  reldir="$$dir2"
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AR = @AR@
@@ -453,14 +410,9 @@ wkfcopydir = @wkfcopydir@
 wkfextradir = @wkfextradir@
 AUTOMAKE_OPTIONS = 1.8 foreign
 DISTCLEANFILES = *~
-SUBDIRS = tests
 @MAINTAINER_MODE_TRUE at MAINTAINERCLEANFILES = Makefile.in
 INCLUDES = $(all_includes) 
-#INCLUDES = $(all_includes) -I../kmclipm/include/
 noinst_HEADERS = 
-
-#-----------------------------------------------------------------
-# plugin_LTLIBRARIES =  kmo_fit_profile.la
 plugin_LTLIBRARIES = kmo_arithmetic.la \
                      kmo_combine.la \
                      kmo_copy.la \
@@ -484,8 +436,7 @@ plugin_LTLIBRARIES = kmo_arithmetic.la \
                      kmo_sky_tweak.la \
                      kmo_stats.la \
                      kmo_std_star.la \
-                     kmo_wave_cal.la \
-                     kmo_dev_setup.la
+                     kmo_wave_cal.la 
 
 kmo_arithmetic_la_SOURCES = kmo_arithmetic.c
 kmo_arithmetic_la_LIBADD = $(LIBKMOS)
@@ -571,10 +522,6 @@ kmo_illumination_flat_la_SOURCES = kmo_illumination_flat.c
 kmo_illumination_flat_la_LIBADD = $(LIBKMOS)
 kmo_illumination_flat_la_LDFLAGS = -module -avoid-version
 kmo_illumination_flat_la_DEPENDENCIES = $(LIBKMOS)
-kmo_dev_setup_la_SOURCES = kmo_dev_setup.c
-kmo_dev_setup_la_LIBADD = $(LIBKMOS)
-kmo_dev_setup_la_LDFLAGS = -module -avoid-version
-kmo_dev_setup_la_DEPENDENCIES = $(LIBKMOS)
 kmo_std_star_la_SOURCES = kmo_std_star.c
 kmo_std_star_la_LIBADD = $(LIBKMOS)
 kmo_std_star_la_LDFLAGS = -module -avoid-version
@@ -587,7 +534,7 @@ kmo_fits_strip_la_SOURCES = kmo_fits_strip.c
 kmo_fits_strip_la_LIBADD = $(LIBKMOS)
 kmo_fits_strip_la_LDFLAGS = -module -avoid-version
 kmo_fits_strip_la_DEPENDENCIES = $(LIBKMOS)
-all: all-recursive
+all: all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
@@ -660,8 +607,6 @@ kmo_copy.la: $(kmo_copy_la_OBJECTS) $(kmo_copy_la_DEPENDENCIES) $(EXTRA_kmo_copy
 	$(kmo_copy_la_LINK) -rpath $(plugindir) $(kmo_copy_la_OBJECTS) $(kmo_copy_la_LIBADD) $(LIBS)
 kmo_dark.la: $(kmo_dark_la_OBJECTS) $(kmo_dark_la_DEPENDENCIES) $(EXTRA_kmo_dark_la_DEPENDENCIES) 
 	$(kmo_dark_la_LINK) -rpath $(plugindir) $(kmo_dark_la_OBJECTS) $(kmo_dark_la_LIBADD) $(LIBS)
-kmo_dev_setup.la: $(kmo_dev_setup_la_OBJECTS) $(kmo_dev_setup_la_DEPENDENCIES) $(EXTRA_kmo_dev_setup_la_DEPENDENCIES) 
-	$(kmo_dev_setup_la_LINK) -rpath $(plugindir) $(kmo_dev_setup_la_OBJECTS) $(kmo_dev_setup_la_LIBADD) $(LIBS)
 kmo_extract_spec.la: $(kmo_extract_spec_la_OBJECTS) $(kmo_extract_spec_la_DEPENDENCIES) $(EXTRA_kmo_extract_spec_la_DEPENDENCIES) 
 	$(kmo_extract_spec_la_LINK) -rpath $(plugindir) $(kmo_extract_spec_la_OBJECTS) $(kmo_extract_spec_la_LIBADD) $(LIBS)
 kmo_fit_profile.la: $(kmo_fit_profile_la_OBJECTS) $(kmo_fit_profile_la_DEPENDENCIES) $(EXTRA_kmo_fit_profile_la_DEPENDENCIES) 
@@ -713,7 +658,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_combine.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_copy.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_dark.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_dev_setup.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_extract_spec.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_fit_profile.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_fits_check.Plo at am__quote@
@@ -762,76 +706,6 @@ mostlyclean-libtool:
 clean-libtool:
 	-rm -rf .libs _libs
 
-# This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-#     (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-$(RECURSIVE_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	dot_seen=no; \
-	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    dot_seen=yes; \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
-	done; \
-	if test "$$dot_seen" = "no"; then \
-	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
-	fi; test -z "$$fail"
-
-$(RECURSIVE_CLEAN_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	dot_seen=no; \
-	case "$@" in \
-	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-	  *) list='$(SUBDIRS)' ;; \
-	esac; \
-	rev=''; for subdir in $$list; do \
-	  if test "$$subdir" = "."; then :; else \
-	    rev="$$subdir $$rev"; \
-	  fi; \
-	done; \
-	rev="$$rev ."; \
-	target=`echo $@ | sed s/-recursive//`; \
-	for subdir in $$rev; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
-	done && test -z "$$fail"
-tags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
-	done
-ctags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
-	done
-
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -842,23 +716,10 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	mkid -fID $$unique
 tags: TAGS
 
-TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	set x; \
 	here=`pwd`; \
-	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
-	  include_option=--etags-include; \
-	  empty_fix=.; \
-	else \
-	  include_option=--include; \
-	  empty_fix=; \
-	fi; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
-	    test ! -f $$subdir/TAGS || \
-	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
-	  fi; \
-	done; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
@@ -877,7 +738,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  fi; \
 	fi
 ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -927,51 +788,22 @@ distdir: $(DISTFILES)
 	    || exit 1; \
 	  fi; \
 	done
-	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
-	    test -d "$(distdir)/$$subdir" \
-	    || $(MKDIR_P) "$(distdir)/$$subdir" \
-	    || exit 1; \
-	  fi; \
-	done
-	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
-	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
-	    $(am__relativize); \
-	    new_distdir=$$reldir; \
-	    dir1=$$subdir; dir2="$(top_distdir)"; \
-	    $(am__relativize); \
-	    new_top_distdir=$$reldir; \
-	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
-	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
-	    ($(am__cd) $$subdir && \
-	      $(MAKE) $(AM_MAKEFLAGS) \
-	        top_distdir="$$new_top_distdir" \
-	        distdir="$$new_distdir" \
-		am__remove_distdir=: \
-		am__skip_length_check=: \
-		am__skip_mode_fix=: \
-	        distdir) \
-	      || exit 1; \
-	  fi; \
-	done
 check-am: all-am
-check: check-recursive
+check: check-am
 all-am: Makefile $(LTLIBRARIES) $(HEADERS)
-installdirs: installdirs-recursive
-installdirs-am:
+installdirs:
 	for dir in "$(DESTDIR)$(plugindir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
-install: install-recursive
-install-exec: install-exec-recursive
-install-data: install-data-recursive
-uninstall: uninstall-recursive
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 
-installcheck: installcheck-recursive
+installcheck: installcheck-am
 install-strip:
 	if test -z '$(STRIP)'; then \
 	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
@@ -995,83 +827,81 @@ maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
 	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-clean: clean-recursive
+clean: clean-am
 
 clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
 	mostlyclean-am
 
-distclean: distclean-recursive
+distclean: distclean-am
 	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
 
-dvi: dvi-recursive
+dvi: dvi-am
 
 dvi-am:
 
-html: html-recursive
+html: html-am
 
 html-am:
 
-info: info-recursive
+info: info-am
 
 info-am:
 
 install-data-am: install-pluginLTLIBRARIES
 
-install-dvi: install-dvi-recursive
+install-dvi: install-dvi-am
 
 install-dvi-am:
 
 install-exec-am:
 
-install-html: install-html-recursive
+install-html: install-html-am
 
 install-html-am:
 
-install-info: install-info-recursive
+install-info: install-info-am
 
 install-info-am:
 
 install-man:
 
-install-pdf: install-pdf-recursive
+install-pdf: install-pdf-am
 
 install-pdf-am:
 
-install-ps: install-ps-recursive
+install-ps: install-ps-am
 
 install-ps-am:
 
 installcheck-am:
 
-maintainer-clean: maintainer-clean-recursive
+maintainer-clean: maintainer-clean-am
 	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
-mostlyclean: mostlyclean-recursive
+mostlyclean: mostlyclean-am
 
 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
 	mostlyclean-libtool
 
-pdf: pdf-recursive
+pdf: pdf-am
 
 pdf-am:
 
-ps: ps-recursive
+ps: ps-am
 
 ps-am:
 
 uninstall-am: uninstall-pluginLTLIBRARIES
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
-	install-am install-strip tags-recursive
+.MAKE: install-am install-strip
 
-.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
-	all all-am check check-am clean clean-generic clean-libtool \
-	clean-pluginLTLIBRARIES ctags ctags-recursive distclean \
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
 	distclean-compile distclean-generic distclean-libtool \
 	distclean-tags distdir dvi dvi-am html html-am info info-am \
 	install install-am install-data install-data-am install-dvi \
@@ -1079,14 +909,11 @@ uninstall-am: uninstall-pluginLTLIBRARIES
 	install-html-am install-info install-info-am install-man \
 	install-pdf install-pdf-am install-pluginLTLIBRARIES \
 	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs installdirs-am maintainer-clean \
+	installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags tags-recursive uninstall uninstall-am \
-	uninstall-pluginLTLIBRARIES
-
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
 
-#-----------------------------------------------------------------
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/recipes/kmo_arithmetic.c b/recipes/kmo_arithmetic.c
index 4565f00..ced317c 100644
--- a/recipes/kmo_arithmetic.c
+++ b/recipes/kmo_arithmetic.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_arithmetic.c,v 1.15 2013-09-05 12:24:58 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-09-05 12:24:58 $
- * $Revision: 1.15 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -77,7 +69,7 @@ static char kmo_arithmetic_description[] =
 "--scalar\n"
 "To be provided if a frame should be processed together with a scalar\n"
 "\n"
-"--file_extension"
+"--file_extension\n"
 "Define a string to append to the product filename ARITHMETIC in order to get\n"
 "an unique filename\n"
 "\n"
@@ -139,7 +131,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Perform basic arithmetic on cubes",
                         kmo_arithmetic_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_arithmetic_create,
                         kmo_arithmetic_exec,
diff --git a/recipes/kmo_combine.c b/recipes/kmo_combine.c
index 36d5f70..3859d37 100644
--- a/recipes/kmo_combine.c
+++ b/recipes/kmo_combine.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_combine.c,v 1.32 2013-06-27 13:10:21 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-06-27 13:10:21 $
- * $Revision: 1.32 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -232,7 +224,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Combine reconstructed cubes",
                         kmo_combine_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_combine_create,
                         kmo_combine_exec,
@@ -714,6 +706,15 @@ static int kmo_combine(cpl_parameterlist *parlist, cpl_frameset *frameset)
             } else {
                 if (ifus != NULL) {
                     char *tmptmp = NULL;
+
+                    // replace all ; with _
+                    char *found_char = NULL;
+                    found_char = strstr(ifus_txt, ";");
+                    while (found_char != NULL) {
+                        strncpy(found_char, "_", 1);
+                        found_char = strstr(ifus_txt, ";");
+                    }
+
                     if (strlen(ifus_txt) > 10) {
                         KMO_TRY_EXIT_IF_NULL(
                             tmptmp = kmo_shorten_ifu_string(ifus_txt));
@@ -736,7 +737,7 @@ static int kmo_combine(cpl_parameterlist *parlist, cpl_frameset *frameset)
         //
         // load all data (and noise if existent) cubes and store them
         //
-        for (nv = 0; nv < name_vec_size; nv++){
+        for (nv = 0; nv < name_vec_size; nv++) {
             name = name_vec[nv];
 
             data_cube_counter = 0;
@@ -991,6 +992,16 @@ static int kmo_combine(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 kmo_dfs_save_cube(cube_combined_data, fn_combine, "", data_header_list[0], 0./0.));
             KMO_TRY_EXIT_IF_ERROR(
                 kmo_dfs_save_cube(cube_combined_noise, fn_combine, "", noise_header_list[0], 0./0.));
+            cpl_propertylist_erase(data_header_list[0], CRPIX3);
+            cpl_propertylist_erase(data_header_list[0], CRPIX3);
+            cpl_propertylist_erase(data_header_list[0], CRVAL3);
+            cpl_propertylist_erase(data_header_list[0], CDELT3);
+            cpl_propertylist_erase(data_header_list[0], CD1_3);
+            cpl_propertylist_erase(data_header_list[0], CD2_3);
+            cpl_propertylist_erase(data_header_list[0], CD3_1);
+            cpl_propertylist_erase(data_header_list[0], CD3_2);
+            cpl_propertylist_erase(data_header_list[0], CD3_3);
+            cpl_propertylist_erase(data_header_list[0], CTYPE3);
             KMO_TRY_EXIT_IF_ERROR(
                 kmo_dfs_save_image(exp_mask, fn_mask, "", data_header_list[0], 0./0.));
 
@@ -1022,7 +1033,7 @@ static int kmo_combine(cpl_parameterlist *parlist, cpl_frameset *frameset)
             }
             cpl_free(fn_combine); fn_combine = NULL;
             cpl_free(fn_mask); fn_mask = NULL;
-        }
+        } // end for (nv = 0; nv < name_vec_size; nv++)
     }
     KMO_CATCH
     {
diff --git a/recipes/kmo_copy.c b/recipes/kmo_copy.c
index 8d42ee2..6f4cf43 100644
--- a/recipes/kmo_copy.c
+++ b/recipes/kmo_copy.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_copy.c,v 1.12 2013-05-21 12:13:58 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-05-21 12:13:58 $
- * $Revision: 1.12 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -157,7 +149,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                             "image or spectrum",
                         kmo_copy_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_copy_create,
                         kmo_copy_exec,
diff --git a/recipes/kmo_dark.c b/recipes/kmo_dark.c
index 802f4f7..aaabc1e 100644
--- a/recipes/kmo_dark.c
+++ b/recipes/kmo_dark.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_dark.c,v 1.21 2013-07-02 09:37:22 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-07-02 09:37:22 $
- * $Revision: 1.21 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -63,44 +55,40 @@ static int kmo_dark(cpl_parameterlist *, cpl_frameset *);
 static char kmo_dark_description[] =
 "This recipe calculates the master dark frame.\n"
 "\n"
-"It is recommended to provide three or more dark exposures to produce a reason-\n"
-"able master with associated noise.\n"
+"It is recommended to provide three or more dark exposures to produce a\n"
+"reasonable master with associated noise.\n"
 "\n"
 "BASIC PARAMETERS\n"
 "----------------\n"
 "--pos_bad_pix_rej\n"
 "--neg_bad_pix_rej\n"
-"Bad pixels above and below defined positive/negative threshold levels will be\n"
-"flagged and output to the BADPIX_DARK frame (which will go into the kmo_flat\n"
-"recipe). The number of bad pixels is returned as a QC1 parameter. The two para-\n"
-"meters can be used to change these thresholds.\n"
+"Bad pixels above and below defined positive/negative threshold levels will\n"
+"be flagged and output to the BADPIX_DARK frame.\n"
+"The number of bad pixels is returned as a QC1 parameter.\n"
+"The two parameters can be used to change these thresholds.\n"
 "\n"
 "--cmethod\n"
 "Following methods of frame combination are available:\n"
 "   * 'ksigma' (Default)\n"
-"   An iterative sigma clipping. For each position all pixels in the spectrum\n"
-"   are examined. If they deviate significantly, they will be rejected according\n"
-"   to the conditions:\n"
-"       val > mean + stdev * cpos_rej\n"
-"   and\n"
-"       val < mean - stdev * cneg_rej\n"
-"   where --cpos_rej, --cneg_rej and --citer are the corresponding configuration\n"
-"   parameters. In the first iteration median and percentile level are used.\n"
-"\n"
+"       An iterative sigma clipping. For each position all pixels in the\n"
+"       spectrum are examined. If they deviate significantly, they will be\n"
+"       rejected according to the conditions:\n"
+"           val > mean + stdev * cpos_rej\n"
+"       and\n"
+"           val < mean - stdev * cneg_rej\n"
+"       where --cpos_rej, --cneg_rej and --citer are the wished parameters\n"
+"       In the first iteration median and percentile level are used.\n"
 "   * 'median'\n"
-"   At each pixel position the median is calculated.\n"
-"\n"
+"       At each pixel position the median is calculated.\n"
 "   * 'average'\n"
-"   At each pixel position the average is calculated.\n"
-"\n"
+"       At each pixel position the average is calculated.\n"
 "   * 'sum'\n"
-"   At each pixel position the sum is calculated.\n"
-"\n"
+"       At each pixel position the sum is calculated.\n"
 "   * 'min_max'\n"
-"   The specified number of minimum and maximum pixel values will be rejected.\n"
-"   --cmax and --cmin apply to this method.\n"
+"       The specified number of min and max pixel values will be rejected.\n"
+"       --cmax and --cmin apply to this method.\n"
 "\n"
-"--file_extension"
+"--file_extension\n"
 "Set this parameter to TRUE if the EXPTIME keyword should be appended to\n"
 "the output filenames.\n"
 "\n"
@@ -109,31 +97,24 @@ static char kmo_dark_description[] =
 "--cpos_rej\n"
 "--cneg_rej\n"
 "--citer\n"
-"see --cmethod='ksigma'\n"
-"\n"
+"   see --cmethod='ksigma'\n"
 "--cmax\n"
 "--cmin\n"
-"see --cmethod='min_max'\n"
+"   see --cmethod='min_max'\n"
 "\n"
-"-------------------------------------------------------------------------------\n"
+"---------------------------------------------------------------------------\n"
 "Input files:\n"
-"\n"
-"   DO                   KMOS                                                   \n"
-"   category             Type   Explanation                     Required #Frames\n"
-"   --------             -----  -----------                     -------- -------\n"
-"   DARK                 RAW    Dark exposures                     Y       1-n  \n"
-"                               (at least 3 frames recommended)                 \n"
+"   DO CATG          Type   Explanation                     Required #Frames\n"
+"   -------          -----  -----------                     -------- -------\n"
+"   DARK             RAW    Dark exposures                     Y       1-n  \n"
+"                           (at least 3 frames recommended)                 \n"
 "\n"
 "Output files:\n"
-"\n"
-"   DO                   KMOS\n"
-"   category             Type   Explanation\n"
-"   --------             -----  -----------\n"
-"   MASTER_DARK          F2D    Calculated master dark frames\n"
-"\n"
-"   BADPIXEL_DARK        B2D    Associated badpixel frames\n"
-"\n"
-"-------------------------------------------------------------------------------"
+"   DO CATG          Type   Explanation\n"
+"   -------          -----  -----------\n"
+"   MASTER_DARK      F2D    Calculated master dark frames\n"
+"   BADPIXEL_DARK    B2D    Associated badpixel frames\n"
+"---------------------------------------------------------------------------"
 "\n";
 
 /*-----------------------------------------------------------------------------
@@ -141,13 +122,12 @@ static char kmo_dark_description[] =
  *----------------------------------------------------------------------------*/
 
 /**
- * @defgroup kmo_dark kmo_dark Create master dark frame & bad pixel mask
- *
- * See recipe description for details.
+ * @defgroup kmo_dark   Create master dark frame & bad pixel mask
  */
 
 /**@{*/
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Build the list of available plugins, for this module. 
   @param    list    the plugin list
@@ -156,30 +136,32 @@ static char kmo_dark_description[] =
   Create the recipe instance and make it available to the application using the 
   interface. This function is exported.
  */
+/*----------------------------------------------------------------------------*/
 int cpl_plugin_get_info(cpl_pluginlist *list)
 {
     cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
     cpl_plugin *plugin = &recipe->interface;
 
     cpl_plugin_init(plugin,
-                        CPL_PLUGIN_API,
-                        KMOS_BINARY_VERSION,
-                        CPL_PLUGIN_TYPE_RECIPE,
-                        "kmo_dark",
-                        "Create master dark frame & bad pixel mask",
-                        kmo_dark_description,
-                        "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
-                        kmos_get_license(),
-                        kmo_dark_create,
-                        kmo_dark_exec,
-                        kmo_dark_destroy);
+            CPL_PLUGIN_API,
+            KMOS_BINARY_VERSION,
+            CPL_PLUGIN_TYPE_RECIPE,
+            "kmo_dark",
+            "Create master dark frame & bad pixel mask",
+            kmo_dark_description,
+            "Alex Agudo Berbel",
+            "usd-help at eso.org",
+            kmos_get_license(),
+            kmo_dark_create,
+            kmo_dark_exec,
+            kmo_dark_destroy);
 
     cpl_pluginlist_append(list, plugin);
 
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Setup the recipe options    
   @param    plugin  the plugin
@@ -187,6 +169,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
 
   Defining the command-line/configuration parameters for the recipe.
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_dark_create(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -204,49 +187,40 @@ static int kmo_dark_create(cpl_plugin *plugin)
     /* Fill the parameters list */
 
     /* --pos_bad_pix_rej */
-    p = cpl_parameter_new_value("kmos.kmo_dark.pos_bad_pix_rej",
-                                CPL_TYPE_DOUBLE,
-                                "The positive rejection threshold for "
-                                "bad pixels",
-                                "kmos.kmo_dark",
-                                50.0);
+    p = cpl_parameter_new_value("kmos.kmo_dark.pos_bad_pix_rej", 
+            CPL_TYPE_DOUBLE, "The positive rejection threshold for bad pixels",
+            "kmos.kmo_dark", 50.0);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "pos_bad_pix_rej");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --neg_bad_pix_rej */
     p = cpl_parameter_new_value("kmos.kmo_dark.neg_bad_pix_rej",
-                                CPL_TYPE_DOUBLE,
-                                "The negative rejection threshold for "
-                                "bad pixels",
-                                "kmos.kmo_dark",
-                                50.0);
+            CPL_TYPE_DOUBLE, "The negative rejection threshold for bad pixels",
+            "kmos.kmo_dark", 50.0);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "neg_bad_pix_rej");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --file_extension */
-    p = cpl_parameter_new_value("kmos.kmo_dark.file_extension",
-                                CPL_TYPE_BOOL,
-                                "Controls if EXPTIME keyword should be appended "
-                                "to product filenames.",
-                                "kmos.kmo_dark",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_dark.file_extension", CPL_TYPE_BOOL,
+            "Controls if EXPTIME should be appended to product filenames",
+            "kmos.kmo_dark", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "file_extension");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
-    return kmo_combine_pars_create(recipe->parameters,
-                                   "kmos.kmo_dark",
-                                   DEF_REJ_METHOD,
-                                   FALSE);
+    return kmo_combine_pars_create(recipe->parameters, "kmos.kmo_dark", 
+            DEF_REJ_METHOD, FALSE);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Execute the plugin instance given by the interface
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_dark_exec(cpl_plugin *plugin)
 {
     cpl_recipe  *recipe;
@@ -259,11 +233,13 @@ static int kmo_dark_exec(cpl_plugin *plugin)
     return kmo_dark(recipe->parameters, recipe->frames);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Destroy what has been created by the 'create' function
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_dark_destroy(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -277,6 +253,7 @@ static int kmo_dark_destroy(cpl_plugin *plugin)
     return 0 ;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Interpret the command line options and execute the data processing
   @param    parlist     the parameters list
@@ -287,10 +264,10 @@ static int kmo_dark_destroy(cpl_plugin *plugin)
 
     @li CPL_ERROR_ILLEGAL_INPUT      if frames of wrong KMOS format are provided
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
 {
     cpl_imagelist    *detector_in_window       = NULL;
-
     cpl_image        *img_in_window            = NULL,
                      *combined_data            = NULL,
                      *combined_data_window     = NULL,
@@ -298,9 +275,7 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      *combined_noise_window    = NULL,
                      *bad_pix_mask             = NULL,
                      *bad_pix_mask_window      = NULL;
-
     cpl_frame        *frame             = NULL;
-
     int              ret_val             = 0,
                      nr_devices          = 0,
                      i                   = 0,
@@ -314,7 +289,6 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      nz                  = 0,
                      ndit                = 0,
                      file_extension      = FALSE;
-
     double           cpos_rej            = 0.0,
                      cneg_rej            = 0.0,
                      exptime             = 0.0,
@@ -326,19 +300,15 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      qc_readnoise        = 0.0,
                      qc_readnoise_median = 0.0,
                      qc_bad_pix_num      = 0.0;
-
     const char       *cmethod            = NULL,
                      *my_method          = NULL;
 
     char             *filename           = NULL,
                      *filename_bad       = NULL,
                      *extname            = NULL;
-
     cpl_propertylist *main_header        = NULL,
                      *sub_header         = NULL;
-
     main_fits_desc   desc1, desc2;
-
     char             do_mode[256];
 
     KMO_TRY
@@ -347,14 +317,12 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
         kmo_init_fits_desc(&desc2);
 
         // --- check inputs ---
-        KMO_TRY_ASSURE((parlist != NULL) &&
-                       (frameset != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((parlist != NULL) && (frameset != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         if (cpl_frameset_count_tags(frameset, DARK) < 3) {
-            cpl_msg_warning(cpl_func, "It is recommended to provide at least "
-                                      "3 DARK frames!");
+            cpl_msg_warning(cpl_func, 
+                    "It is recommended to provide at least 3 DARK frames!");
         }
 
         if (cpl_frameset_count_tags(frameset, DARK) >= 1) {
@@ -364,45 +332,35 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
         }
 
         KMO_TRY_ASSURE(kmo_dfs_set_groups(frameset, "kmo_dark") == 1,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Cannot identify RAW and CALIB frames!");
+                CPL_ERROR_ILLEGAL_INPUT, 
+                "Cannot identify RAW and CALIB frames!");
 
         // --- get parameters ---
         cpl_msg_info("", "--- Parameter setup for kmo_dark ----------");
 
         pos_bad_pix_rej = kmo_dfs_get_parameter_double(parlist,
-                                           "kmos.kmo_dark.pos_bad_pix_rej");
+                "kmos.kmo_dark.pos_bad_pix_rej");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_dark.pos_bad_pix_rej"));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_dark.pos_bad_pix_rej"));
 
         neg_bad_pix_rej = kmo_dfs_get_parameter_double(parlist,
-                                           "kmos.kmo_dark.neg_bad_pix_rej");
+                "kmos.kmo_dark.neg_bad_pix_rej");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_dark.neg_bad_pix_rej"));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(parlist, 
+                    "kmos.kmo_dark.neg_bad_pix_rej"));
 
-        file_extension = kmo_dfs_get_parameter_bool(parlist,
-                                                        "kmos.kmo_dark.file_extension");
+        file_extension = kmo_dfs_get_parameter_bool(parlist, 
+                "kmos.kmo_dark.file_extension");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-           kmo_dfs_print_parameter_help(parlist, "kmos.kmo_dark.file_extension"));
-
-        KMO_TRY_ASSURE((file_extension == TRUE) ||
-                       (file_extension == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "extension must be TRUE or FALSE!");
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_combine_pars_load(parlist,
-                                  "kmos.kmo_dark",
-                                  &cmethod,
-                                  &cpos_rej,
-                                  &cneg_rej,
-                                  &citer,
-                                  &cmin,
-                                  &cmax,
-                                  FALSE));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(parlist, 
+                    "kmos.kmo_dark.file_extension"));
+
+        KMO_TRY_ASSURE((file_extension == TRUE) || (file_extension == FALSE),
+                CPL_ERROR_ILLEGAL_INPUT, "extension must be TRUE or FALSE!");
+
+        KMO_TRY_EXIT_IF_ERROR(kmo_combine_pars_load(parlist, "kmos.kmo_dark", 
+                    &cmethod, &cpos_rej, &cneg_rej, &citer, &cmin,&cmax,FALSE));
         
         cpl_msg_info("", "-------------------------------------------");
         cpl_msg_info("", "Detected instrument setup:");
@@ -412,33 +370,28 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
         cpl_msg_info("", "   not checked here");
         cpl_msg_info("", "-------------------------------------------");
 
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, do_mode));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, do_mode));
 
         i = 0;
         while (frame != NULL) {
              main_header = kmclipm_propertylist_load(
-                                              cpl_frame_get_filename(frame), 0);
-
+                     cpl_frame_get_filename(frame), 0);
             if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                cpl_msg_error(cpl_func, "File '%s' not found",
-                                                 cpl_frame_get_filename(frame));
+                cpl_msg_error(cpl_func, "File '%s' not found", 
+                        cpl_frame_get_filename(frame));
                 KMO_TRY_CHECK_ERROR_STATE();
             }
 
             if (i == 0) {
                 exptime = cpl_propertylist_get_double(main_header, EXPTIME);
-
-                KMO_TRY_CHECK_ERROR_STATE("EXPTIME keyword in main header "
-                                          "missing!");
+                KMO_TRY_CHECK_ERROR_STATE("EXPTIME missing in main header");
 
                 ndit = cpl_propertylist_get_int(main_header, NDIT);
-
-                KMO_TRY_CHECK_ERROR_STATE("NDIT keyword in main header "
-                                          "missing!");
+                KMO_TRY_CHECK_ERROR_STATE("NDIT missing in main header");
 
                 if (file_extension) {
-                    // delete trailing zeros (if zero right after decimal point, delete point as well)
+                    /* Delete trailing zeros  */
+                    /* If zero right after decimal point,delete point as well */
                     char *exptimeStr = cpl_sprintf("%g", exptime);
                     char *p = 0;
                     for(p=exptimeStr; *p; ++p) {
@@ -449,75 +402,62 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
                             break;
                         }
                     }
-
                     filename = cpl_sprintf("%s_%s", MASTER_DARK, exptimeStr);
-                    filename_bad = cpl_sprintf("%s_%s", BADPIXEL_DARK, exptimeStr);
+                    filename_bad = cpl_sprintf("%s_%s", BADPIXEL_DARK, 
+                            exptimeStr);
                     cpl_free(exptimeStr); exptimeStr = NULL;
                 } else {
                     filename = cpl_sprintf("%s", MASTER_DARK);
                     filename_bad = cpl_sprintf("%s", BADPIXEL_DARK);
                 }
-
-
-                desc1 = kmo_identify_fits_header(
-                            cpl_frame_get_filename(frame));
-
-                KMO_TRY_CHECK_ERROR_STATE_MSG("First fits file doesn't seem to "
-                                              "be in KMOS-format!");
+                desc1 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
+                KMO_TRY_CHECK_ERROR_STATE_MSG(
+                        "First fits file doesn't seem to be in KMOS-format!");
 
                 KMO_TRY_ASSURE(desc1.fits_type == raw_fits,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "First input file hasn't correct data type "
-                               "(must be a raw, unprocessed file)!");
+                        CPL_ERROR_ILLEGAL_INPUT, 
+                        "First input file wrong data type - must be RAW");
             } else {
-
-                desc2 = kmo_identify_fits_header(
-                            cpl_frame_get_filename(frame));
-                KMO_TRY_CHECK_ERROR_STATE_MSG("Fits file doesn't seem to be "
-                                              "in KMOS-format!");
-
+                desc2 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
+                KMO_TRY_CHECK_ERROR_STATE_MSG(
+                        "Fits file doesn't seem to be in KMOS-format!");
                 KMO_TRY_ASSURE(desc2.fits_type == raw_fits,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "An input file hasn't correct data type "
-                               "(must be a raw, unprocessed file)!");
-
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "Input file wrong data type - must be a RAW)");
                 kmo_free_fits_desc(&desc2);
             }
 
             // check if all lamps are off (flat and arc lamp)
-            KMO_TRY_ASSURE(((kmo_check_lamp(main_header, INS_LAMP1_ST) == FALSE) &&
-                            (kmo_check_lamp(main_header, INS_LAMP2_ST) == FALSE) &&
-                            (kmo_check_lamp(main_header, INS_LAMP3_ST) == FALSE) &&
-                            (kmo_check_lamp(main_header, INS_LAMP4_ST) == FALSE)) ||
-                           (((kmo_check_lamp(main_header, INS_LAMP1_ST) == TRUE) ||
-                             (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE) ||
-                             (kmo_check_lamp(main_header, INS_LAMP3_ST) == TRUE) ||
-                             (kmo_check_lamp(main_header, INS_LAMP4_ST) == TRUE)) &&
-                            (strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT1 ID"), "Block") == 0) &&
-                            (strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT2 ID"), "Block") == 0) &&
-                            (strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT3 ID"), "Block") == 0)),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "All lamps must be switched off for DARK frames!");
+            KMO_TRY_ASSURE((
+                        (kmo_check_lamp(main_header, INS_LAMP1_ST) == FALSE) &&
+                        (kmo_check_lamp(main_header, INS_LAMP2_ST) == FALSE) &&
+                        (kmo_check_lamp(main_header, INS_LAMP3_ST) == FALSE) &&
+                        (kmo_check_lamp(main_header, INS_LAMP4_ST) == FALSE)) ||
+                    (((kmo_check_lamp(main_header, INS_LAMP1_ST) == TRUE) ||
+                      (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE) ||
+                      (kmo_check_lamp(main_header, INS_LAMP3_ST) == TRUE) ||
+                      (kmo_check_lamp(main_header, INS_LAMP4_ST) == TRUE)) &&
+                     (strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT1 ID"), "Block") == 0) &&
+                     (strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT2 ID"), "Block") == 0) &&
+                     (strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT3 ID"), "Block") == 0)),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "All lamps must be switched off for DARK frames!");
 
             // check if EXPTIME and NDIT are the same for all frames
             if (cpl_propertylist_get_double(main_header, EXPTIME) != exptime) {
                 cpl_msg_warning(cpl_func,
-                                "EXPTIME isn't the same for all "
-                                "frames: (is %g and %g). Proceeding anyway...",
-                                cpl_propertylist_get_double(main_header,
-                                                            EXPTIME),
-                                exptime);
+                        "EXPTIME isn't the same for all frames: (is %g and %g)",
+                        cpl_propertylist_get_double(main_header, EXPTIME), 
+                        exptime);
             }
 
             if (cpl_propertylist_get_int(main_header, NDIT) != ndit) {
                 cpl_msg_warning(cpl_func,
-                                "NDIT isn't the same for all "
-                                "frames: (is %d and %d). Proceeding anyway...",
-                                cpl_propertylist_get_int(main_header, NDIT),
-                                ndit);
+                        "NDIT isn't the same for all frames: (is %d and %d)",
+                        cpl_propertylist_get_int(main_header, NDIT), ndit);
             }
 
-            // get next DARK frame
+            /* Get next DARK frame */
             frame = kmo_dfs_get_frame(frameset, NULL);
             KMO_TRY_CHECK_ERROR_STATE();
 
@@ -525,298 +465,226 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
             i++;
         }
 
-        // --- load, update & save primary header ---
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, do_mode));
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, filename, "", frame,
-                                     NULL, parlist, cpl_func));
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, filename_bad, "", frame,
-                                     NULL, parlist, cpl_func));
+        /* --- load, update & save primary header --- */
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, do_mode));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, 
+                    filename, "", frame, NULL, parlist, cpl_func));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, 
+                    filename_bad, "", frame, NULL, parlist, cpl_func));
 
-        // --- load data ---
+        /* --- load data --- */
         nr_devices = desc1.nr_ext;
 
+        /* Use average method in case there is only 1 input */
         my_method = cmethod;
         if ((cpl_frameset_count_tags(frameset, DARK) == 1) ||
             (cpl_frameset_count_tags(frameset, COMMANDLINE) == 1)) {
-            cpl_msg_warning(cpl_func, "cmethod is changed to 'average' "
-                            "since there is only one input frame!");
-
+            cpl_msg_warning(cpl_func, 
+                    "cmethod is set to 'average' since there is only 1 input");
             my_method = "average";
         }
 
-        // get size of input frame
-        KMO_TRY_EXIT_IF_NULL(
-            img_in_window = kmo_dfs_load_image(frameset, do_mode, 1, FALSE, FALSE, NULL));
+        /* Get size of input frame */
+        KMO_TRY_EXIT_IF_NULL(img_in_window = kmo_dfs_load_image(frameset, 
+                    do_mode, 1, FALSE, FALSE, NULL));
         nx_orig = cpl_image_get_size_x(img_in_window);
         ny_orig = cpl_image_get_size_y(img_in_window);
         cpl_image_delete(img_in_window); img_in_window = NULL;
-
         KMO_TRY_ASSURE((nx_orig > 2*KMOS_BADPIX_BORDER) &&
-                       (ny_orig > 2*KMOS_BADPIX_BORDER),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Input frames must have a height and width of at "
-                       "least 9 pixels!");
+                (ny_orig > 2*KMOS_BADPIX_BORDER), CPL_ERROR_ILLEGAL_INPUT,
+                "Input frames must have a height and width of at least 9 pix");
 
-        // --- loop through all detectors ---
+        /* --- loop through all detectors --- */
         for (i = 1; i <= nr_devices; i++) {
-            cpl_msg_info("","Processing detector No. %d", i);
+            cpl_msg_info(cpl_func, "Processing detector No. %d", i);
 
-            KMO_TRY_EXIT_IF_NULL(
-                detector_in_window = cpl_imagelist_new());
-
-            KMO_TRY_EXIT_IF_NULL(
-                sub_header = kmo_dfs_load_sub_header(frameset, do_mode,
-                                                     i, FALSE));
+            KMO_TRY_EXIT_IF_NULL(detector_in_window = cpl_imagelist_new());
+            KMO_TRY_EXIT_IF_NULL(sub_header = 
+                    kmo_dfs_load_sub_header(frameset, do_mode, i, FALSE));
 
             // load data of device i of all DARK frames into an imagelist
             KMO_TRY_EXIT_IF_NULL(
-                img_in_window = kmo_dfs_load_image_window(
-                                       frameset, do_mode, i, FALSE,
-                                       KMOS_BADPIX_BORDER+1,
-                                       KMOS_BADPIX_BORDER+1,
-                                       nx_orig-KMOS_BADPIX_BORDER,
-                                       ny_orig-KMOS_BADPIX_BORDER,
-                                       FALSE, NULL));
+                img_in_window = kmo_dfs_load_image_window(frameset, do_mode, i,
+                    FALSE, KMOS_BADPIX_BORDER+1, KMOS_BADPIX_BORDER+1,
+                    nx_orig-KMOS_BADPIX_BORDER, ny_orig-KMOS_BADPIX_BORDER,
+                    FALSE, NULL));
 
             nx = cpl_image_get_size_x(img_in_window);
             ny = cpl_image_get_size_y(img_in_window);
-
             nz = 0;
             while (img_in_window != NULL) {
                 cpl_imagelist_set(detector_in_window, img_in_window, nz);
                 KMO_TRY_CHECK_ERROR_STATE();
 
-                // load same extension of next DARK frame
-                img_in_window = kmo_dfs_load_image_window(
-                                            frameset, NULL, i, FALSE,
-                                            KMOS_BADPIX_BORDER+1,
-                                            KMOS_BADPIX_BORDER+1,
-                                            nx_orig-KMOS_BADPIX_BORDER,
-                                            ny_orig-KMOS_BADPIX_BORDER,
-                                            FALSE, NULL);
+                /* Load same extension of next DARK frame */
+                img_in_window = kmo_dfs_load_image_window(frameset, NULL, i, 
+                        FALSE, KMOS_BADPIX_BORDER+1, KMOS_BADPIX_BORDER+1, 
+                        nx_orig-KMOS_BADPIX_BORDER, ny_orig-KMOS_BADPIX_BORDER,
+                        FALSE, NULL);
                 KMO_TRY_CHECK_ERROR_STATE();
 
                 if (img_in_window != NULL) {
-                    KMO_TRY_ASSURE((nx == cpl_image_get_size_x(img_in_window)) &&
-                                   (ny == cpl_image_get_size_y(img_in_window)),
-                                   CPL_ERROR_ILLEGAL_INPUT,
-                                   "Not all input frames have the "
-                                   "same dimensions!");
+                    KMO_TRY_ASSURE((nx==cpl_image_get_size_x(img_in_window)) &&
+                            (ny == cpl_image_get_size_y(img_in_window)),
+                            CPL_ERROR_ILLEGAL_INPUT,
+                            "Not all input frames have the same dimensions");
                 }
                 nz++;
             }
 
-            // combine imagelist (data only) and create noise
+            /* Combine imagelist (data only) and create noise */
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_combine_frames(detector_in_window,
-                                       NULL,
-                                       NULL,
-                                       my_method,
-                                       cpos_rej,
-                                       cneg_rej,
-                                       citer,
-                                       cmax,
-                                       cmin,
-                                       &combined_data_window,
-                                       &combined_noise_window,
-                                       -1.0));
+                kmclipm_combine_frames(detector_in_window, NULL, NULL,
+                    my_method, cpos_rej, cneg_rej, citer, cmax, cmin,
+                    &combined_data_window, &combined_noise_window, -1.0));
 
             if (kmclipm_omit_warning_one_slice > 10) {
-// AA: commmented this out: Too unclear for the user, no benefit to know about this number
-//                cpl_msg_warning(cpl_func, "Previous warning (number of "
-//                                          "identified slices) occured %d times.",
-//                                kmclipm_omit_warning_one_slice);
                 kmclipm_omit_warning_one_slice = FALSE;
             }
 
-            // calculate preliminary mean and stdev to create the bad pixel mask
+            /* Calculate preliminary mean and stdev to create the BPM */
             qc_dark = cpl_image_get_mean(combined_data_window);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            if (nz > 2) {
-                qc_readnoise = cpl_image_get_mean(combined_noise_window);
-                KMO_TRY_CHECK_ERROR_STATE();
-
-                KMO_TRY_ASSURE(qc_readnoise != 0.0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "All frames of detector %i are exactly "
-                               "the same!", i);
-            } else if (nz == 2) {
-                qc_readnoise = cpl_image_get_stdev(combined_noise_window);
-                KMO_TRY_CHECK_ERROR_STATE();
-
-                KMO_TRY_ASSURE(qc_readnoise != 0.0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "All frames of detector %i are exactly "
-                               "the same!", i);
-            } else if (nz == 1) {
+            /* Check the noise frame (NULL or ALL pixels are bad) */
+            if (combined_noise_window == NULL ||
+                    cpl_image_count_rejected(combined_noise_window) ==
+                    cpl_image_get_size_x(combined_noise_window)*
+                    cpl_image_get_size_y(combined_noise_window)) {
                 qc_readnoise = cpl_image_get_stdev(combined_data_window);
-                KMO_TRY_CHECK_ERROR_STATE();
-
-                KMO_TRY_ASSURE(qc_readnoise != 0.0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "The detector frame %d seems to be uniform!", i);
             } else {
-                KMO_TRY_ASSURE(1 == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "detector frame must have at least one frame!");
+                if (nz > 2)         qc_readnoise = 
+                    cpl_image_get_mean(combined_noise_window);
+                else if (nz == 2)   qc_readnoise = 
+                    cpl_image_get_stdev(combined_noise_window);
+                else if (nz == 1)   qc_readnoise = 
+                    cpl_image_get_stdev(combined_data_window);
+                else 
+                    KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT, 
+                            "Detector frame must have at least one frame");
             }
+            KMO_TRY_CHECK_ERROR_STATE();
 
-            // create bad-pixel-mask
-            qc_bad_pix_num = kmo_create_bad_pix_dark(combined_data_window,
-                                                     qc_dark,
-                                                     qc_readnoise,
-                                                     pos_bad_pix_rej,
-                                                     neg_bad_pix_rej,
-                                                     &bad_pix_mask_window);
+            /* Create bad-pixel-mask */
+            qc_bad_pix_num = kmo_create_bad_pix_dark(combined_data_window, 
+                    qc_dark, qc_readnoise, pos_bad_pix_rej, neg_bad_pix_rej, 
+                    &bad_pix_mask_window);
             KMO_TRY_CHECK_ERROR_STATE();
 
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_int(sub_header,
-                                            QC_NR_BAD_PIX,
-                                            qc_bad_pix_num,
-                                            "[] nr. of bad pixels"));
+                kmclipm_update_property_int(sub_header, QC_NR_BAD_PIX,
+                    qc_bad_pix_num, "[] nr. of bad pixels"));
 
-            //
-            // calculate QC.DARK, QC.READNOISE, QC.DARK.MEDIAN,
-            // QC.READNOISE.MEDIAN, QC.DARKCUR
-
-            // badpixels from combined_data_window are already rejected in
-            // kmo_create_bad_pix_dark()
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_image_reject_from_mask(combined_noise_window,
-                                           bad_pix_mask_window));
+            
+            /* Calculate QC.DARK, QC.READNOISE, QC.DARK.MEDIAN, */
+            /* QC.READNOISE.MEDIAN, QC.DARKCUR */
 
+            /* Badpixels from combined_data_window are already rejected */
+            /* by kmo_create_bad_pix_dark() */
+            KMO_TRY_EXIT_IF_ERROR(kmo_image_reject_from_mask(
+                        combined_noise_window, bad_pix_mask_window));
             qc_dark = cpl_image_get_mean(combined_data_window);
+            qc_dark_median = cpl_image_get_median(combined_data_window);
             KMO_TRY_CHECK_ERROR_STATE();
 
-            // calculate mean and stddev of combined frames (with rejection)
-            if (nz > 2) {
-                qc_readnoise = cpl_image_get_mean(combined_noise_window) * sqrt(nz);
-            } else if (nz == 2) {
-                qc_readnoise =
-                     cpl_image_get_stdev(combined_noise_window) * sqrt(2.0);
-            } else if (nz == 1) {
+            /* Check the noise frame (NULL or ALL pixels are bad) */
+            /* Calculate mean and stddev of combined frames (with rejection) */
+            if (combined_noise_window == NULL ||
+                    cpl_image_count_rejected(combined_noise_window) ==
+                    cpl_image_get_size_x(combined_noise_window)*
+                    cpl_image_get_size_y(combined_noise_window)) {
                 qc_readnoise = cpl_image_get_stdev(combined_data_window);
+                qc_readnoise_median = 
+                    kmo_image_get_stdev_median(combined_data_window);
             } else {
-                KMO_TRY_ASSURE(1 == 0,
-                        CPL_ERROR_ILLEGAL_INPUT,
-                        "detector frame must have at least one frame!");
-            }
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            qc_dark_median = cpl_image_get_median(combined_data_window);
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            if (nz > 2) {
-                qc_readnoise_median =
+                if (nz > 2) {         
+                    qc_readnoise = 
+                        cpl_image_get_mean(combined_noise_window) * sqrt(nz) ;
+                    qc_readnoise_median =
                         cpl_image_get_median(combined_noise_window) * sqrt(nz);
-            } else if (nz == 2) {
-                qc_readnoise_median =
-                         kmo_image_get_stdev_median(combined_noise_window) *
-                                                                  sqrt(2.0);
-            } else if (nz == 1) {
-                qc_readnoise_median =
-                           kmo_image_get_stdev_median(combined_data_window);
-            } else {
-                KMO_TRY_ASSURE(1 == 0,
-                        CPL_ERROR_ILLEGAL_INPUT,
-                        "detector frame must have at least one frame!");
+                } else if (nz == 2) {   
+                    qc_readnoise = 
+                        cpl_image_get_stdev(combined_noise_window) * sqrt(nz) ;
+                    qc_readnoise_median = sqrt(nz) *
+                        kmo_image_get_stdev_median(combined_noise_window) ;
+                } else if (nz == 1) {
+                    qc_readnoise = 
+                        cpl_image_get_stdev(combined_data_window);
+                    qc_readnoise_median =
+                        kmo_image_get_stdev_median(combined_data_window);
+                } else {
+                    KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT, 
+                            "Detector frame must have at least one frame");
+                }
             }
             KMO_TRY_CHECK_ERROR_STATE();
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_double(sub_header,
-                                               QC_DARK,
-                                               qc_dark,
-                                              "[adu] mean of master dark"));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_double(sub_header,
-                                               QC_READNOISE,
-                                               qc_readnoise,
-                                        "[adu] mean noise of master dark"));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_double(sub_header,
-                                               QC_DARK_MEDIAN,
-                                               qc_dark_median,
-                                            "[adu] median of master dark"));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_double(sub_header,
-                                               QC_READNOISE_MEDIAN,
-                                               qc_readnoise_median,
-                                      "[adu] median noise of master dark"));
-
-            // load gain
+            KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(sub_header,
+                        QC_DARK, qc_dark, "[adu] mean of master dark"));
+            KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(sub_header,
+                        QC_READNOISE, qc_readnoise, 
+                        "[adu] mean noise of master dark"));
+            KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(sub_header,
+                        QC_DARK_MEDIAN, qc_dark_median, 
+                        "[adu] median of master dark"));
+            KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(sub_header,
+                        QC_READNOISE_MEDIAN, qc_readnoise_median, 
+                        "[adu] median noise of master dark"));
+
+            /* Load gain */
             gain = kmo_dfs_get_property_double(sub_header, GAIN);
             KMO_TRY_CHECK_ERROR_STATE_MSG(
-                                 "GAIN-keyword in fits-header is missing!");
+                    "GAIN-keyword in fits-header is missing!");
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_double(sub_header,
-                                               QC_DARK_CURRENT,
-                                               qc_dark / exptime / gain,
-                                               "[e-/s] dark current"));
+            KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(sub_header,
+                        QC_DARK_CURRENT, qc_dark / exptime / gain,
+                        "[e-/s] dark current"));
 
-            // save dark frame
-            KMO_TRY_EXIT_IF_NULL(
-                extname = kmo_extname_creator(detector_frame, i, EXT_DATA));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_string(sub_header, EXTNAME,
-                                               extname,
-                                               "FITS extension name"));
+            /* Save dark frame */
+            KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(detector_frame, 
+                        i, EXT_DATA));
+            KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(sub_header, 
+                        EXTNAME, extname, "FITS extension name"));
             cpl_free(extname); extname = NULL;
 
-            KMO_TRY_EXIT_IF_NULL(
-                combined_data = kmo_add_bad_pix_border(combined_data_window,
-                                                       TRUE));
+            KMO_TRY_EXIT_IF_NULL(combined_data = 
+                    kmo_add_bad_pix_border(combined_data_window, TRUE));
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_save_image(combined_data, filename, "", sub_header, 0./0.));
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(combined_data, 
+                        filename, "", sub_header, 0./0.));
 
-            // save noise frame
-            KMO_TRY_EXIT_IF_NULL(
-                extname = kmo_extname_creator(detector_frame, i, EXT_NOISE));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_string(sub_header, EXTNAME,
-                                               extname,
-                                               "FITS extension name"));
+            /* Save noise frame */
+            KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(detector_frame, 
+                        i, EXT_NOISE));
+            KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(sub_header, 
+                        EXTNAME, extname, "FITS extension name"));
             cpl_free(extname); extname = NULL;
 
-            KMO_TRY_EXIT_IF_NULL(
-                combined_noise = kmo_add_bad_pix_border(combined_noise_window,
-                                                        TRUE));
+            KMO_TRY_EXIT_IF_NULL(combined_noise = 
+                    kmo_add_bad_pix_border(combined_noise_window, TRUE));
 
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_save_image(combined_noise, filename, "", sub_header, 0./0.));
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(combined_noise, 
+                        filename, "", sub_header, 0./0.));
 
-            // save bad_pix frame
+            /* Save bad_pix frame */
             KMO_TRY_EXIT_IF_NULL(
                 extname = kmo_extname_creator(detector_frame, i, EXT_BADPIX));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_string(sub_header, EXTNAME,
-                                               extname,
-                                               "FITS extension name"));
+            KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(sub_header, 
+                        EXTNAME, extname, "FITS extension name"));
             cpl_free(extname); extname = NULL;
 
-            KMO_TRY_EXIT_IF_NULL(
-                bad_pix_mask = kmo_add_bad_pix_border(bad_pix_mask_window,
-                                                      FALSE));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_save_image(bad_pix_mask, filename_bad, "", sub_header, 0.));
+            KMO_TRY_EXIT_IF_NULL(bad_pix_mask = 
+                    kmo_add_bad_pix_border(bad_pix_mask_window, FALSE));
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(bad_pix_mask, 
+                        filename_bad, "", sub_header, 0.));
 
-            // free memory
+            /* Free memory */
             cpl_propertylist_delete(sub_header); sub_header = NULL;
             cpl_imagelist_delete(detector_in_window); detector_in_window = NULL;
             cpl_image_delete(combined_data); combined_data = NULL;
             cpl_image_delete(combined_data_window); combined_data_window = NULL;
             cpl_image_delete(combined_noise); combined_noise = NULL;
-            cpl_image_delete(combined_noise_window); combined_noise_window = NULL;
+            cpl_image_delete(combined_noise_window); combined_noise_window=NULL;
             cpl_image_delete(bad_pix_mask); bad_pix_mask = NULL;
             cpl_image_delete(bad_pix_mask_window); bad_pix_mask_window = NULL;
         } // for i = [1, nr_devices]
@@ -829,11 +697,7 @@ static int kmo_dark(cpl_parameterlist *parlist, cpl_frameset *frameset)
     KMO_CATCH
     {
         KMO_CATCH_MSG();
-
-//        if (desc2.sub_desc != NULL) {
-            kmo_free_fits_desc(&desc2);
-//        }
-
+        kmo_free_fits_desc(&desc2);
         ret_val = -1;
     }
 
diff --git a/recipes/kmo_dev_setup.c b/recipes/kmo_dev_setup.c
deleted file mode 100644
index 3f1d256..0000000
--- a/recipes/kmo_dev_setup.c
+++ /dev/null
@@ -1,1244 +0,0 @@
-/* $Id: kmo_dev_setup.c,v 1.10 2013-06-18 07:56:47 aagudo Exp $
- *
- * This file is part of the KMOS Pipeline
- * Copyright (C) 2002,2003 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-06-18 07:56:47 $
- * $Revision: 1.10 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/*-----------------------------------------------------------------------------
- *                              Includes
- *----------------------------------------------------------------------------*/
-
-
-#include <math.h>
-#include <string.h>
-
-#include <cpl.h>
-
-#include "kmclipm_math.h"
-
-#include "kmo_priv_reconstruct.h"
-#include "kmo_priv_functions.h"
-#include "kmo_priv_fits_stack.h"
-#include "kmo_cpl_extensions.h"
-#include "kmo_dfs.h"
-#include "kmo_error.h"
-#include "kmo_constants.h"
-#include "kmo_debug.h"
-
-/*-----------------------------------------------------------------------------
- *                          Functions prototypes
- *----------------------------------------------------------------------------*/
-
-static int kmo_dev_setup_create(cpl_plugin *);
-static int kmo_dev_setup_exec(cpl_plugin *);
-static int kmo_dev_setup_destroy(cpl_plugin *);
-static int kmo_dev_setup(cpl_parameterlist *, cpl_frameset *);
-
-/*-----------------------------------------------------------------------------
- *                          Static variables
- *----------------------------------------------------------------------------*/
-
-static char kmo_dev_setup_description[] =
-"     #############################################\n"
-"     ### INTENDED FOR PIPELINE DEVELOPERS ONLY ###\n"
-"     #############################################\n"
-"\n"
-"This recipe is intended to create KMOS conform files in a semi-automatic manner.\n"
-"It is sufficient to provide a single FITS file and a few parameters to create\n"
-"KMOS conform FITS files suited for different recipes. Internally it calls repea-\n"
-"tedly the recipe kmo_fits_stack. There are also parameters that allow to prepare\n"
-"the frames, i.e. early test out of the lab, in a way they can be processed.\n"
-"\n"
-"One extension from the input frame is taken, some noise is added automatically\n"
-"in order to create similar frames for the other extensions.\n"
-"\n"
-"BASIC PARAMETERS:\n"
-"-----------------\n"
-"--type\n"
-"Defines for which recipe the files should be created ('DARK', \n"
-"'FLAT_ON', 'FLAT_OFF', 'ARC_ON', 'ARC_OFF', 'STD', 'SKY').\n"
-"\n"
-"--extension\n"
-"Defines which extension is used to craete frames\n"
-"\n"
-"--xshift\n"
-"--yshift\n"
-"Shift frames in x and y\n"
-"\n"
-"--rotangle\n"
-"Sets the ESO OCS ROT NAANGLE keyword in the primary header.\n"
-"\n"
-"--topcrop\n"
-"--bottomcrop\n"
-"--leftcrop\n"
-"--rightcrop\n"
-"These are cropping the image (filled with 0).\n"
-"\n"
-"--mainkey\n"
-"--subkey\n"
-"Add individual keywords to primary- or sub-header\n"
-"\n"
-"--valid\n"
-"Defines if IFUs are active or inactive\n"
-"\n"
-"--objects\n"
-"Defines if IFUs contain object or sky.\n"
-"\n"
-"--date\n"
-"Sets the DATE-OBS keword in the primary header.\n"
-"\n"
-"--filter\n"
-"Sets the filter type for all extensions.\n"
-"\n"
-"--grating\n"
-"Sets the grating type for all extensions.\n"
-"\n"
-"-------------------------------------------------------------------------------\n"
-"  Input files:\n"
-"\n"
-"   DO                     KMOS                                                 \n"
-"   category               Type  Explanation                    Required #Frames\n"
-"   --------               ----- -----------                    -------- -------\n"
-"    DARK        or        RAW   Frame to create Master dark or    Y        1   \n"
-"    FLAT_ON     or              Flat-on or                                     \n"
-"    FLAT_OFF    or              Flat-off or                                    \n"
-"    ARC_ON      or              Arc-on or                                      \n"
-"    ARC_OFF     or              Arc-off or                                     \n"
-"    SKY         or              Sky or                                         \n"
-"    STD         or              Std star or                                    \n"
-"    GENERIC                     any other generic KMOS frame                   \n"
-"\n"
-"  Output files:\n"
-"\n"
-"   DO                    KMOS\n"
-"   category              Type   Explanation\n"
-"   --------              -----  -----------\n"
-"   <see comment>         RAW    Named depending on --type parameter\n"
-"-------------------------------------------------------------------------------\n"
-"\n";
-
-/*-----------------------------------------------------------------------------
- *                              Functions code
- *----------------------------------------------------------------------------*/
-
-/**
- * @defgroup kmo_dev_setup kmo_dev_setup Create aligned KMOS files out of test frames
- *
- * See recipe description for details.
- */
-
-/**@{*/
-
-/**
-  @brief    Build the list of available plugins, for this module. 
-  @param    list    the plugin list
-  @return   0 if everything is ok, -1 otherwise
-
-  Create the recipe instance and make it available to the application using the 
-  interface. This function is exported.
- */
-int cpl_plugin_get_info(cpl_pluginlist *list)
-{
-    cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
-    cpl_plugin *plugin = &recipe->interface;
-
-    cpl_plugin_init(plugin,
-                        CPL_PLUGIN_API,
-                        KMOS_BINARY_VERSION,
-                        CPL_PLUGIN_TYPE_RECIPE,
-                        "kmo_dev_setup",
-                        "Create aligned KMOS files out of test frames",
-                        kmo_dev_setup_description,
-                        "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
-                        kmos_get_license(),
-                        kmo_dev_setup_create,
-                        kmo_dev_setup_exec,
-                        kmo_dev_setup_destroy);
-
-    cpl_pluginlist_append(list, plugin);
-
-    return 0;
-}
-
-/**
-  @brief    Setup the recipe options    
-  @param    plugin  the plugin
-  @return   0 if everything is ok
-
-  Defining the command-line/configuration parameters for the recipe.
- */
-static int kmo_dev_setup_create(cpl_plugin *plugin)
-{
-    cpl_recipe *recipe;
-    cpl_parameter *p;
-
-    /* Check that the plugin is part of a valid recipe */
-    if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
-        recipe = (cpl_recipe *)plugin;
-    else
-        return -1;
-
-    /* Create the parameters list in the cpl_recipe object */
-    recipe->parameters = cpl_parameterlist_new();
-
-     /* Fill the parameters list */
-    /* --type */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.type",
-                                CPL_TYPE_STRING,
-                                "FITS type to create (DARK, FLAT_ON, "
-                                "FLAT_OFF, ARC_ON, ARC_OFF, SKY, GENERIC, STD)",
-                                "kmos.kmo_dev_setup",
-                                "");
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "type");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --extension */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.extension",
-                                CPL_TYPE_INT,
-                                "FITS extension to process (0: primary, 1, 2,...)",
-                                "kmos.kmo_dev_setup",
-                                0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "extension");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --xshift */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.xshift",
-                                CPL_TYPE_INT,
-                                "integer shift in x (to the right -> pos)",
-                                "kmos.kmo_dev_setup",
-                                0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "xshift");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --yshift */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.yshift",
-                                CPL_TYPE_INT,
-                                "integer shift in y (to the top -> pos)",
-                                "kmos.kmo_dev_setup",
-                                0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "yshift");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-//    /* --rotation */
-//    p = cpl_parameter_new_value("kmos.kmo_dev_setup.rotation",
-//                                CPL_TYPE_DOUBLE,
-//                                "rotation in degrees (CCW)",
-//                                "kmos.kmo_dev_setup",
-//                                0.0);
-//    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rotation");
-//    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-//    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --rotangle */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.rotangle",
-                                CPL_TYPE_DOUBLE,
-                                "Rotator offset angle in degrees (CCW)",
-                                "kmos.kmo_dev_setup",
-                                -1.0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rotangle");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --topcrop */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.topcrop",
-                                CPL_TYPE_INT,
-                                "number of rows to crop at top",
-                                "kmos.kmo_dev_setup",
-                                0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "topcrop");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --bottomcrop */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.bottomcrop",
-                                CPL_TYPE_INT,
-                                "number of rows to crop at bottom",
-                                "kmos.kmo_dev_setup",
-                                0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "bottomcrop");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --leftcrop */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.leftcrop",
-                                CPL_TYPE_INT,
-                                "number of columns to crop at left",
-                                "kmos.kmo_dev_setup",
-                                0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "leftcrop");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --rightcrop */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.rightcrop",
-                                CPL_TYPE_INT,
-                                "number of columns to crop at right",
-                                "kmos.kmo_dev_setup",
-                                0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "rightcrop");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --mainkey */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.mainkey",
-                             CPL_TYPE_STRING,
-                             "Optional: Additional keywords for primary header",
-                             "kmos.kmo_dev_setup",
-                             "");
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "mainkey");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --subkey */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.subkey",
-                                CPL_TYPE_STRING,
-                                "Optional: Additional keywords for sub headers",
-                                "kmos.kmo_dev_setup",
-                                "");
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "subkey");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --valid */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.valid",
-                                CPL_TYPE_STRING,
-                                "Optional: Specify which IFUs are active. "
-                                "Either empty string or string with 8 elements"
-                                " (ones or zeros) e.g: [1;0;1;0;0;...;1]",
-                                "kmos.kmo_dev_setup",
-                                "");
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "valid");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --objects */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.objects",
-                                CPL_TYPE_STRING,
-                                "Optional (STD only): Specify which IFUs contain"
-                                " objects. Either empty string or string with 8"
-                                " elements (ones or zeros) "
-                                "e.g: [1;0;1;0;0;...;1]",
-                                "kmos.kmo_dev_setup",
-                                "");
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "objects");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --date */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.date",
-                                CPL_TYPE_STRING,
-                                "Optional (STD only): Specify the date to save "
-                                "into DATE-OBS "
-                                "e.g: [2010-01-31T11:53:15.9789]",
-                                "kmos.kmo_dev_setup",
-                                "");
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "date");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --filter */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.filter",
-                                CPL_TYPE_STRING,
-                                "filter type (K, H, HK, etc.)",
-                                "kmos.kmo_dev_setup",
-                                "");
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filter");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    /* --grating */
-    p = cpl_parameter_new_value("kmos.kmo_dev_setup.grating",
-                                CPL_TYPE_STRING,
-                                "grating type (K, H, HK, etc.)",
-                                "kmos.kmo_dev_setup",
-                                "");
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "grating");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    return 0;
-}
-
-/**
-  @brief    Execute the plugin instance given by the interface
-  @param    plugin  the plugin
-  @return   0 if everything is ok
- */
-static int kmo_dev_setup_exec(cpl_plugin *plugin)
-{
-    cpl_recipe  *recipe;
-
-    /* Get the recipe out of the plugin */
-    if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
-        recipe = (cpl_recipe *)plugin;
-    else return -1;
-
-    return kmo_dev_setup(recipe->parameters, recipe->frames);
-}
-
-/**
-  @brief    Destroy what has been created by the 'create' function
-  @param    plugin  the plugin
-  @return   0 if everything is ok
- */
-static int kmo_dev_setup_destroy(cpl_plugin *plugin)
-{
-    cpl_recipe *recipe;
-
-    /* Get the recipe out of the plugin */
-    if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
-        recipe = (cpl_recipe *)plugin;
-    else return -1 ;
-
-    cpl_parameterlist_delete(recipe->parameters);
-    return 0 ;
-}
-
-cpl_frameset* dev_frameset(const char *p1, const char *p2, const char *p3) {
-    cpl_frameset *frset = NULL;
-    cpl_frame *fr = NULL;
-
-    KMO_TRY
-    {
-
-        KMO_TRY_EXIT_IF_NULL(
-            frset = cpl_frameset_new());
-
-        KMO_TRY_EXIT_IF_NULL(
-            fr = cpl_frame_new());
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_filename(fr, p1));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_tag(fr, FS_DATA));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_type(fr, CPL_FRAME_TYPE_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_group(fr, CPL_FRAME_GROUP_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_level(fr, CPL_FRAME_LEVEL_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frameset_insert(frset, fr));
-
-        KMO_TRY_EXIT_IF_NULL(
-            fr = cpl_frame_new());
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_filename(fr, p2));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_tag(fr, FS_DATA));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_type(fr, CPL_FRAME_TYPE_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_group(fr, CPL_FRAME_GROUP_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_level(fr, CPL_FRAME_LEVEL_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frameset_insert(frset, fr));
-
-        KMO_TRY_EXIT_IF_NULL(
-            fr = cpl_frame_new());
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_filename(fr, p3));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_tag(fr, FS_DATA));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_type(fr, CPL_FRAME_TYPE_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_group(fr, CPL_FRAME_GROUP_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frame_set_level(fr, CPL_FRAME_LEVEL_NONE));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_frameset_insert(frset, fr));
-    }
-    KMO_CATCH
-    {
-        cpl_frameset_delete(frset); frset = NULL;
-    }
-    return frset;
-}
-
-cpl_frameset* dev_frameset_master(const char *p1) {
-    cpl_frameset *frset = NULL;
-
-    cpl_frame *fr = NULL;
-    int i = 0;
-
-    KMO_TRY
-    {
-
-        KMO_TRY_EXIT_IF_NULL(
-            frset = cpl_frameset_new());
-        for (i = 0; i < 3; i++) {
-            KMO_TRY_EXIT_IF_NULL(
-                fr = cpl_frame_new());
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_filename(fr, p1));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_tag(fr, FS_DATA));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_type(fr, CPL_FRAME_TYPE_NONE));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_group(fr, CPL_FRAME_GROUP_NONE));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_level(fr, CPL_FRAME_LEVEL_NONE));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frameset_insert(frset, fr));
-
-            KMO_TRY_EXIT_IF_NULL(
-                fr = cpl_frame_new());
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_filename(fr, p1));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_tag(fr, FS_NOISE));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_type(fr, CPL_FRAME_TYPE_NONE));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_group(fr, CPL_FRAME_GROUP_NONE));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frame_set_level(fr, CPL_FRAME_LEVEL_NONE));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_frameset_insert(frset, fr));
-        }
-    }
-    KMO_CATCH
-    {
-        cpl_frameset_delete(frset); frset = NULL;
-    }
-    return frset;
-}
-
-/**
-  @brief    Interpret the command line options and execute the data processing
-  @param    parlist     the parameters list
-  @param    frameset   the frames list
-  @return   0 if everything is ok
-
-  Possible _cpl_error_code_ set in this function:
-
-    @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
-                                     if first operand not 3d or
-                                     if second operand not valid
-    @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands
-                                     do not match
- */
-static int kmo_dev_setup(cpl_parameterlist *parlist, cpl_frameset *frameset)
-{
-    int         ret_val     = 0,
-                ext         = 0,
-                xshift      = 0,
-                yshift      = 0,
-                topcrop     = 0,
-                bottomcrop  = 0,
-                leftcrop    = 0,
-                rightcrop   = 0,
-                x           = 0,
-                y           = 0,
-                nx          = 0,
-                ny          = 0,
-                i           = 0;
-//    double      rotation    = 0.0;
-    double      rotangle    = 0.0;
-
-    float       *pimg1      = NULL,
-                *ptmp_img   = NULL;
-
-    const char  *type       = NULL,
-                *mainkey    = NULL,
-                *subkey     = NULL,
-                *valid      = NULL,
-                *objects_txt= NULL,
-                *date       = NULL,
-                *filter     = NULL,
-                *grating    = NULL;
-
-    char        pmainkey[2048],
-                psubkey[2048],
-                pvalid[2048],
-                pfilename[2048],
-                tmp_str[256];
-
-    const char *obsid        = "-2147",
-               *exptime_min  = "2.47624",
-               *exptime_long  = "600";
-
-
-    cpl_frame   *frame      = NULL;
-
-    cpl_image   *img1       = NULL,
-                *img_copy   = NULL,
-                *noise      = NULL,
-                *noise_copy = NULL,
-                *img_noise1 = NULL,
-                *img_noise2 = NULL,
-                *img_noise3 = NULL,
-                *tmp_img    = NULL;
-
-    cpl_vector  *objects    = NULL;
-
-    cpl_frameset *frset     = NULL;
-
-//    cpl_frame   *fr         = NULL;
-
-    cpl_parameterlist *plist    = NULL;
-
-    cpl_parameter *p        = NULL;
-
-    KMO_TRY
-    {
-        strcpy(pmainkey, "");
-        strcpy(psubkey, "");
-        strcpy(pvalid, "");
-        strcpy(pfilename, "");
-        strcpy(tmp_str, "");
-
-        /* --- check input --- */
-        KMO_TRY_ASSURE((parlist != NULL) &&
-                       (frameset != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        /* --- get parameters --- */
-        cpl_msg_info("", "--- Parameter setup for kmo_dev_setup -----");
-
-        KMO_TRY_EXIT_IF_NULL(
-            type = kmo_dfs_get_parameter_string(parlist,
-                                            "kmos.kmo_dev_setup.type"));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.type"));
-
-        ext = kmo_dfs_get_parameter_int(parlist,
-                                        "kmos.kmo_dev_setup.extension");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_ASSURE(ext >= 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "ext >= 0!");
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.extension"));
-
-        xshift = kmo_dfs_get_parameter_int(parlist,
-                                           "kmos.kmo_dev_setup.xshift");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.xshift"));
-
-        yshift = kmo_dfs_get_parameter_int(parlist,
-                                           "kmos.kmo_dev_setup.yshift");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.yshift"));
-
-//        rotation = kmo_dfs_get_parameter_double(parlist,
-//                                           "kmos.kmo_dev_setup.rotation");
-//        KMO_TRY_CHECK_ERROR_STATE();
-//        KMO_TRY_EXIT_IF_ERROR(
-//            kmo_dfs_print_parameter_help(parlist,
-//                                        "kmos.kmo_dev_setup.rotation"));
-
-        topcrop = kmo_dfs_get_parameter_int(parlist,
-                                           "kmos.kmo_dev_setup.topcrop");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.topcrop"));
-
-        bottomcrop = kmo_dfs_get_parameter_int(parlist,
-                                           "kmos.kmo_dev_setup.bottomcrop");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.bottomcrop"));
-
-        leftcrop = kmo_dfs_get_parameter_int(parlist,
-                                           "kmos.kmo_dev_setup.leftcrop");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.leftcrop"));
-
-        rightcrop = kmo_dfs_get_parameter_int(parlist,
-                                           "kmos.kmo_dev_setup.rightcrop");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.rightcrop"));
-
-        KMO_TRY_EXIT_IF_NULL(
-            mainkey = kmo_dfs_get_parameter_string(parlist,
-                                            "kmos.kmo_dev_setup.mainkey"));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.mainkey"));
-
-        KMO_TRY_EXIT_IF_NULL(
-            subkey = kmo_dfs_get_parameter_string(parlist,
-                                            "kmos.kmo_dev_setup.subkey"));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.subkey"));
-
-        KMO_TRY_EXIT_IF_NULL(
-            valid = kmo_dfs_get_parameter_string(parlist,
-                                            "kmos.kmo_dev_setup.valid"));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.valid"));
-
-        KMO_TRY_EXIT_IF_NULL(
-            objects_txt = kmo_dfs_get_parameter_string(parlist,
-                                            "kmos.kmo_dev_setup.objects"));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.objects"));
-
-        KMO_TRY_EXIT_IF_NULL(
-            date = kmo_dfs_get_parameter_string(parlist,
-                                            "kmos.kmo_dev_setup.date"));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.date"));
-
-        KMO_TRY_EXIT_IF_NULL(
-            filter = kmo_dfs_get_parameter_string(parlist,
-                                            "kmos.kmo_dev_setup.filter"));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.filter"));
-
-        KMO_TRY_EXIT_IF_NULL(
-            grating = kmo_dfs_get_parameter_string(parlist,
-                                            "kmos.kmo_dev_setup.grating"));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                        "kmos.kmo_dev_setup.grating"));
-
-        cpl_msg_info("", "-------------------------------------------");
-
-        KMO_TRY_ASSURE((strcmp(type, "DARK") == 0) ||
-                       (strcmp(type, "FLAT_ON") == 0) ||
-                       (strcmp(type, "FLAT_OFF") == 0) ||
-                       (strcmp(type, "ARC_ON") == 0) ||
-                       (strcmp(type, "ARC_OFF") == 0) ||
-                       (strcmp(type, "SKY") == 0) ||
-                       (strcmp(type, "STD") == 0) ||
-                       (strcmp(type, "MASTER_FLAT") == 0) ||
-                       (strcmp(type, "GENERIC") == 0),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Wrong type!");
-
-        // get frame
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, "0"));
-
-        // load data
-        KMO_TRY_EXIT_IF_NULL(
-            img1 = kmclipm_image_load(cpl_frame_get_filename(frame),
-                                CPL_TYPE_FLOAT,
-                                0,
-                                ext));
-
-        //
-        // SHIFT
-        //
-        if ((xshift != 0) || (yshift != 0)) {
-            cpl_msg_info(cpl_func, "shift: x=%d, y=%d", xshift, yshift);
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_image_shift(img1, xshift, yshift));
-        } else {
-            cpl_msg_info(cpl_func, "no shift applied.");
-        }
-//cpl_image_save(img1, "dev_shift.fits", CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_CREATE);
-
-//        //
-//        // ROTATION
-//        //
-//        if (fabs(rotation) >= 0.0001) {
-//            cpl_msg_info(cpl_func, "rotation: r=%g CCW", rotation);
-//            KMO_TRY_EXIT_IF_NULL(
-//                    img2 = kmo_dev_rotate(img1, rotation,
-//                                          1, "BCS", NONE_NANS));
-//        } else {
-//            cpl_msg_info(cpl_func, "no rotation applied.");
-//            img2 = img1;
-//        }
-//cpl_image_save(img2, "dev_rotation.fits", CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_CREATE);
-
-        nx = cpl_image_get_size_x(img1);
-        ny = cpl_image_get_size_y(img1);
-
-        //
-        // CROP
-        //
-        if ((topcrop != 0) || (bottomcrop != 0) ||
-            (leftcrop != 0) || (rightcrop != 0)) {
-            cpl_msg_info(cpl_func, "crop: top=%d, bottom=%d, left=%d, right=%d",
-                         topcrop, bottomcrop, leftcrop, rightcrop);
-
-            KMO_TRY_EXIT_IF_NULL(
-                pimg1 = cpl_image_get_data_float(img1));
-
-            // bottomcrop
-            for (y = 0; y < bottomcrop; y++) {
-                for (x = 0; x < nx; x++) {
-                    pimg1[x+y*nx] = 0.0;
-                }
-            }
-
-            // topcrop
-            for (y = nx-topcrop; y < nx; y++) {
-                for (x = 0; x < nx; x++) {
-                    pimg1[x+y*nx] = 0.0;
-                }
-            }
-
-            // leftcrop
-            for (y = 0; y < ny; y++) {
-                for (x = 0; x < leftcrop; x++) {
-                    pimg1[x+y*nx] = 0.0;
-                }
-            }
-
-            // rightcrop
-            for (y = 0; y < ny; y++) {
-                for (x = nx-rightcrop; x < nx; x++) {
-                    pimg1[x+y*nx] = 0.0;
-                }
-            }
-        } else {
-            cpl_msg_info(cpl_func, "no crop applied.");
-        }
-//cpl_image_save(img1, "dev_crop.fits", CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_CREATE);
-
-        //
-        // NOISIFY
-        //
-        KMO_TRY_EXIT_IF_NULL(
-            noise = cpl_image_new(nx, ny, CPL_TYPE_FLOAT));
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_image_fill_noise_uniform(noise, -1.0, 1.0));
-
-        // calculate level
-        float level = 0.0;
-        if ((strcmp(type, "DARK") == 0) ||
-            (strcmp(type, "SKY") == 0))
-        {
-            KMO_TRY_EXIT_IF_NULL(
-                tmp_img = cpl_image_duplicate(img1));
-            KMO_TRY_EXIT_IF_NULL(
-                ptmp_img = cpl_image_get_data(tmp_img));
-            for (i = 0; i < nx*ny; i++) {
-                if (kmclipm_is_nan_or_inf(ptmp_img[i])) {
-                    ptmp_img[i] = 0;
-                }
-            }
-            KMO_TRY_CHECK_ERROR_STATE();
-            level = cpl_image_get_stdev(tmp_img);
-            KMO_TRY_CHECK_ERROR_STATE();
-            cpl_image_delete(tmp_img); tmp_img = NULL;
-
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_image_multiply_scalar(noise, level));
-
-            // img_noise1:
-            img_noise1 = img1;
-
-            // img_noise2: just add noise
-            KMO_TRY_EXIT_IF_NULL(
-                img_noise2 = cpl_image_add_create(img1, noise));
-
-            // img_noise3: add noise flipped horizontally
-            cpl_image_flip(noise, 0);
-            KMO_TRY_EXIT_IF_NULL(
-                img_noise3 = cpl_image_add_create(img1, noise));
-        } else {
-            KMO_TRY_EXIT_IF_NULL(
-                img_copy = cpl_image_duplicate(img1));
-
-            KMO_TRY_EXIT_IF_NULL(
-                noise_copy = cpl_image_duplicate(noise));
-
-            // img_noise1:
-            img_noise1 = img1;
-
-            // img_noise2: add noise level 1
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_image_multiply_scalar(noise, 10));
-            KMO_TRY_EXIT_IF_NULL(
-                img_noise2 = cpl_image_add_create(img1, noise));
-
-            // img_noise3: add noise level 2
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_image_multiply_scalar(noise_copy, 15));
-            KMO_TRY_EXIT_IF_NULL(
-                img_noise3 = cpl_image_add_create(img_copy, noise_copy));
-
-            cpl_image_delete(img_copy); img_copy = NULL;
-            cpl_image_delete(noise_copy); noise_copy = NULL;
-        }
-        cpl_image_delete(noise); noise = NULL;
-
-        // these have to be stored!
-        kmclipm_image_save(img_noise1, "tmp_delete1.fits", CPL_BPP_IEEE_FLOAT,
-                           NULL, CPL_IO_CREATE, 0);
-        kmclipm_image_save(img_noise2, "tmp_delete2.fits", CPL_BPP_IEEE_FLOAT,
-                           NULL, CPL_IO_CREATE, 0);
-        kmclipm_image_save(img_noise3, "tmp_delete3.fits", CPL_BPP_IEEE_FLOAT,
-                           NULL, CPL_IO_CREATE, 0);
-        cpl_image_delete(img_noise2); img_noise2 = NULL;
-        cpl_image_delete(img_noise3); img_noise3 = NULL;
-
-        //
-        // STACK
-        //
-
-        // setup parameterlist
-
-// all types
-        /* --mainkey */
-
-        if (strcmp(mainkey, "") != 0) {
-            strcpy(pmainkey, mainkey);
-            strcat(pmainkey, ";");
-            strcat(pmainkey,"ESO OBS ID;int;");strcat(pmainkey, obsid);
-        } else {
-            strcpy(pmainkey,"ESO OBS ID;int;");strcat(pmainkey, obsid);
-        }
-//        strcat(pmainkey, ";");
-        if (rotangle != -1) {
-            char *nr = NULL;
-            KMO_TRY_EXIT_IF_NULL(
-                nr = cpl_sprintf("%g", rotangle));
-            strcat(pmainkey,";ESO OCS ROT NAANGLE;double;");strcat(pmainkey, nr);
-            cpl_free(nr); nr = NULL;
-        }
-
-        if (strcmp(filter, "") != 0) {
-            strcat(pmainkey, ";ESO INS FILT1 ID;string;");strcat(pmainkey, filter);
-            strcat(pmainkey,";ESO INS FILT2 ID;string;");strcat(pmainkey, filter);
-            strcat(pmainkey,";ESO INS FILT3 ID;string;");strcat(pmainkey, filter);
-        }
-
-        if (strcmp(grating, "") != 0) {
-            strcat(pmainkey,";ESO INS GRAT1 ID;string;");strcat(pmainkey, grating);
-            strcat(pmainkey,";ESO INS GRAT2 ID;string;");strcat(pmainkey, grating);
-            strcat(pmainkey,";ESO INS GRAT3 ID;string;");strcat(pmainkey, grating);
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        /* --subkey */
-        if (strcmp(subkey, "") != 0) {
-            strcpy(psubkey, subkey);
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-
-//        if (strcmp(type, "DARK") == 0) {
-            /* --mainkey */
-            strcat(pmainkey, ";ESO DET SEQ1 MINDIT;double;");strcat(pmainkey, exptime_min);
-            strcat(pmainkey, ";ESO DET NDIT;int;1");
-            strcat(pmainkey, ";EXPTIME;double;");strcat(pmainkey, exptime_long);
-            strcat(pmainkey, ";ESO DET READ CURNAME;string;Double");
-
-            /* --subkey */
-            if (strcmp(subkey, "") != 0) strcat(psubkey, ";");
-            strcat(psubkey, "EXPTIME;double;");strcat(psubkey, exptime_long);
-//        }
-
-        if (strcmp(type, "FLAT_ON") == 0) {
-            /* --mainkey */
-            strcat(pmainkey,";ESO INS LAMP3 ST;bool;1");
-//            strcat(pmainkey, "EXPTIME;double;");strcat(pmainkey, exptime_long);
-
-            /* --subkey */
-//            if (strcmp(subkey, "") != 0)  strcat(psubkey, ";");
-//            strcat(psubkey, "EXPTIME;double;");strcat(psubkey, exptime_long);
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        if (strcmp(type, "ARC_ON") == 0)
-        {
-            strcat(pmainkey,";ESO INS LAMP1 ST;bool;1");
-//            strcat(pmainkey, "EXPTIME;double;");strcat(pmainkey, exptime_long);
-
-            /* --subkey */
-            if (strcmp(subkey, "") != 0)  strcat(psubkey, ";");
-//            strcat(psubkey, "EXPTIME;double;");strcat(psubkey, exptime_long);
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        if ((strcmp(type, "FLAT_OFF") == 0) ||
-            (strcmp(type, "ARC_OFF") == 0)) {
-            /* --mainkey */
-//            strcat(pmainkey, "EXPTIME;double;");strcat(pmainkey, exptime_long);
-
-            /* --subkey */
-            if (strcmp(subkey, "") != 0)  strcat(psubkey, ";");
-//            strcat(psubkey, "EXPTIME;double;");strcat(psubkey, exptime_long);
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        if ((strcmp(type, "SKY") == 0) ||
-            (strcmp(type, "MASTER_FLAT") == 0) ||
-            (strcmp(type, "STD") == 0) ||
-            (strcmp(type, "GENERIC") == 0))
-        {
-            /* --mainkey */
-            if (strcmp(type, "STD") == 0) {
-                // add DATE-OBS keyword
-//                strcat(pmainkey,";");
-                strcat(pmainkey,";DATE-OBS;string;");strcat(pmainkey, date);
-//                strcat(pmainkey, ";EXPTIME;double;");strcat(pmainkey, exptime_long);
-
-                // add ESO OCS ARMi TYPE keywords
-                objects = kmo_identify_values(objects_txt);
-                KMO_TRY_ASSURE(cpl_vector_get_size(objects) == KMOS_IFUS_PER_DETECTOR,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "valid parameter must have 8 elements!");
-
-                for (i = 0; i < cpl_vector_get_size(objects)*3; i++) {
-                    strcat(pmainkey,";");
-                    strcat(pmainkey,"ESO OCS ARM");
-                    sprintf(tmp_str, "%d ", i+1);
-                    strcat(pmainkey,tmp_str);
-                    strcat(pmainkey,"TYPE;string;");
-
-                    if (fabs(cpl_vector_get(objects, i%KMOS_IFUS_PER_DETECTOR)-1) > 0.01 ) {
-                        // sky
-                        strcat(pmainkey,"S");
-                    } else {
-                        //object
-                        strcat(pmainkey,"O");
-                    }
-                }
-                cpl_vector_delete(objects); objects = NULL;
-            }
-//printf("----------\n");
-//printf("%s\n", pmainkey);
-//printf("----------\n");
-//            /* --subkey */
-//            if (strcmp(subkey, "") != 0) {
-//                strcat(psubkey, ";");
-//            }
-//            strcat(psubkey, ";EXPTIME;double;");
-//            strcat(psubkey, exptime_long);
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-
-// SETUP PARAMETERLIST
-        plist = cpl_parameterlist_new();
-
-        /* --valid */
-        strcpy(pvalid, valid);
-        strcat(pvalid, ";");
-        strcat(pvalid, valid);
-        strcat(pvalid, ";");
-        strcat(pvalid, valid);
-
-        p = cpl_parameter_new_value("kmos.kmo_fits_stack.valid",
-                                    CPL_TYPE_STRING,
-                                    "Optional: Specify which IFUs are active. "
-                                    "Either empty string or string with 24 elements"
-                                    " (ones or zeros) e.g: [1;0;1;0;0;...;1]",
-                                    "kmos.kmo_fits_stack",
-                                    pvalid);
-        cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "valid");
-        cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-        cpl_parameterlist_append(plist, p);
-
-        if (strcmp(type, "MASTER_FLAT") != 0) {
-            // all types except MASTER_FLAT
-
-            /* --type (RAW, F1D, F2D, F1I, F2I, F3I) */
-            p = cpl_parameter_new_value("kmos.kmo_fits_stack.type",
-                                        CPL_TYPE_STRING,
-                                        "The KMOS data format type (either \"RAW\", "
-                                        "\"F1D\", \"F2D\", \"F1I\", \"F2I\", \"F3I\", "
-                                        "\"F1S\", \"F1L\", \"F2L\")",
-                                        "kmos.kmo_fits_stack",
-                                        RAW);
-            cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "type");
-            cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-            cpl_parameterlist_append(plist, p);
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            /* --mainkey */
-            p = cpl_parameter_new_value("kmos.kmo_fits_stack.mainkey",
-                                     CPL_TYPE_STRING,
-                                     "Optional: Additional keywords for primary header",
-                                     "kmos.kmo_fits_stack",
-                                     pmainkey);
-            cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "mainkey");
-            cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-            cpl_parameterlist_append(plist, p);
-
-            /* --subkey */
-            p = cpl_parameter_new_value("kmos.kmo_fits_stack.subkey",
-                                        CPL_TYPE_STRING,
-                                        "Optional: Additional keywords for sub headers",
-                                        "kmos.kmo_fits_stack",
-                                        psubkey);
-            cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "subkey");
-            cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-            cpl_parameterlist_append(plist, p);
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            // stack 1st
-            KMO_TRY_EXIT_IF_NULL(
-                frset = dev_frameset("tmp_delete1.fits", "tmp_delete2.fits", "tmp_delete3.fits"));
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            /* --filename */
-            strcpy(pfilename, type);
-            strcat(pfilename, "_123");
-            p = cpl_parameter_new_value("kmos.kmo_fits_stack.filename",
-                                        CPL_TYPE_STRING,
-                                        "Optional: The output filename (.fits will be "
-                                                                    "added as postfix)",
-                                        "kmos.kmo_fits_stack",
-                                        pfilename);
-            cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filename");
-            cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-            cpl_parameterlist_append(plist, p);
-
-            kmo_priv_fits_stack(plist, frset);
-            KMO_TRY_CHECK_ERROR_STATE();
-            cpl_frameset_delete(frset); frset = NULL;
-
-            if ((strcmp(type, "DARK") == 0) ||
-                (strcmp(type, "FLAT_ON") == 0) ||
-                (strcmp(type, "FLAT_OFF") == 0) ||
-                (strcmp(type, "SKY") == 0))
-            {
-                // stack 2nd
-                KMO_TRY_EXIT_IF_NULL(
-                    frset = dev_frameset("tmp_delete2.fits", "tmp_delete3.fits", "tmp_delete1.fits"));
-                strcpy(pfilename, type);
-                strcat(pfilename, "_231");
-                KMO_TRY_EXIT_IF_NULL(
-                    p = cpl_parameterlist_find(plist, "kmos.kmo_fits_stack.filename"));
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_parameter_set_string(p, pfilename));
-
-                kmo_priv_fits_stack(plist, frset);
-                KMO_TRY_CHECK_ERROR_STATE();
-                cpl_frameset_delete(frset); frset = NULL;
-
-                // stack 3rd
-                KMO_TRY_EXIT_IF_NULL(
-                    frset = dev_frameset("tmp_delete3.fits", "tmp_delete1.fits", "tmp_delete2.fits"));
-                strcpy(pfilename, type);
-                strcat(pfilename, "_312");
-                KMO_TRY_EXIT_IF_NULL(
-                    p = cpl_parameterlist_find(plist, "kmos.kmo_fits_stack.filename"));
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_parameter_set_string(p, pfilename));
-
-                kmo_priv_fits_stack(plist, frset);
-                KMO_TRY_CHECK_ERROR_STATE();
-                cpl_frameset_delete(frset); frset = NULL;
-            }
-        } else{
-            /* --type (RAW, F1D, F2D, F1I, F2I, F3I) */
-            p = cpl_parameter_new_value("kmos.kmo_fits_stack.type",
-                                        CPL_TYPE_STRING,
-                                        "The KMOS data format type (either \"RAW\", "
-                                        "\"F1D\", \"F2D\", \"F1I\", \"F2I\", \"F3I\", "
-                                        "\"F1S\", \"F1L\", \"F2L\")",
-                                        "kmos.kmo_fits_stack",
-                                        F2D);
-            cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "type");
-            cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-            cpl_parameterlist_append(plist, p);
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            /* --mainkey */
-            p = cpl_parameter_new_value("kmos.kmo_fits_stack.mainkey",
-                                     CPL_TYPE_STRING,
-                                     "Optional: Additional keywords for primary header",
-                                     "kmos.kmo_fits_stack",
-                                     pmainkey);
-            cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "mainkey");
-            cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-            cpl_parameterlist_append(plist, p);
-
-            /* --subkey */
-            p = cpl_parameter_new_value("kmos.kmo_fits_stack.subkey",
-                                        CPL_TYPE_STRING,
-                                        "Optional: Additional keywords for sub headers",
-                                        "kmos.kmo_fits_stack",
-                                        psubkey);
-            cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "subkey");
-            cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-            cpl_parameterlist_append(plist, p);
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            /* --filename */
-            strcpy(pfilename, "master_flat_ones");
-            p = cpl_parameter_new_value("kmos.kmo_fits_stack.filename",
-                                        CPL_TYPE_STRING,
-                                        "Optional: The output filename (.fits will be "
-                                                                    "added as postfix)",
-                                        "kmos.kmo_fits_stack",
-                                        pfilename);
-            cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filename");
-            cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-            cpl_parameterlist_append(plist, p);
-
-            KMO_TRY_EXIT_IF_NULL(
-                frset = dev_frameset_master(cpl_frame_get_filename(frame)));
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            kmo_priv_fits_stack(plist, frset);
-            KMO_TRY_CHECK_ERROR_STATE();
-            cpl_frameset_delete(frset); frset = NULL;
-        }
-
-        KMO_TRY_CHECK_ERROR_STATE();
-        cpl_msg_info("", "*******************************************");
-        cpl_msg_info("", "Saved a set of KMOS frames for recipe %s.", type );
-        cpl_msg_info("", "*******************************************");
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-        ret_val = -1;
-    }
-
-    cpl_image_delete(img1); img1 = NULL;
-    cpl_parameterlist_delete(plist); plist = NULL;
-
-    return ret_val;
-}
-
-/**@}*/
diff --git a/recipes/kmo_extract_spec.c b/recipes/kmo_extract_spec.c
index 3da7824..f6b24e1 100644
--- a/recipes/kmo_extract_spec.c
+++ b/recipes/kmo_extract_spec.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_extract_spec.c,v 1.15 2013-06-07 15:41:20 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-06-07 15:41:20 $
- * $Revision: 1.15 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -193,7 +185,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Extract a spectrum from a cube.",
                         kmo_extract_spec_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_extract_spec_create,
                         kmo_extract_spec_exec,
@@ -700,23 +692,23 @@ static int kmo_extract_spec(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 if (save_mask) {
                     // delete WCS for 3rd dimension since mask is 2D
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CRPIX3));
+                        cpl_propertylist_erase(sub_header_mask, CRPIX3));
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CRVAL3));
+                        cpl_propertylist_erase(sub_header_mask, CRVAL3));
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CDELT3));
+                        cpl_propertylist_erase(sub_header_mask, CDELT3));
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CTYPE3));
+                        cpl_propertylist_erase(sub_header_mask, CTYPE3));
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CD1_3));
+                        cpl_propertylist_erase(sub_header_mask, CD1_3));
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CD2_3));
+                        cpl_propertylist_erase(sub_header_mask, CD2_3));
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CD3_3));
+                        cpl_propertylist_erase(sub_header_mask, CD3_3));
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CD3_1));
+                        cpl_propertylist_erase(sub_header_mask, CD3_1));
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_propertylist_erase(sub_header_data, CD3_2));
+                        cpl_propertylist_erase(sub_header_mask, CD3_2));
 
                     KMO_TRY_EXIT_IF_ERROR(
                         kmo_dfs_save_image(mask, EXTRACT_SPEC_MASK, "",
diff --git a/recipes/kmo_fit_profile.c b/recipes/kmo_fit_profile.c
index 6d14a79..47fb669 100644
--- a/recipes/kmo_fit_profile.c
+++ b/recipes/kmo_fit_profile.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_fit_profile.c,v 1.10 2013-06-07 15:41:21 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-06-07 15:41:21 $
- * $Revision: 1.10 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -138,7 +130,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "resolution or find the centre of a source",
                         kmo_fit_profile_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_fit_profile_create,
                         kmo_fit_profile_exec,
diff --git a/recipes/kmo_fits_check.c b/recipes/kmo_fits_check.c
index ac462eb..d57e7b0 100644
--- a/recipes/kmo_fits_check.c
+++ b/recipes/kmo_fits_check.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_fits_check.c,v 1.7 2013-05-21 12:13:58 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-05-21 12:13:58 $
- * $Revision: 1.7 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -117,7 +109,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Check contents of a KMOS fits-file",
                         kmo_fits_check_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_fits_check_create,
                         kmo_fits_check_exec,
diff --git a/recipes/kmo_fits_stack.c b/recipes/kmo_fits_stack.c
index 8a5608b..76fe5be 100644
--- a/recipes/kmo_fits_stack.c
+++ b/recipes/kmo_fits_stack.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_fits_stack.c,v 1.8 2013-05-21 12:13:58 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-05-21 12:13:58 $
- * $Revision: 1.8 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -169,7 +161,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Creates KMOS conform fits-files",
                         kmo_fits_stack_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_fits_stack_create,
                         kmo_fits_stack_exec,
diff --git a/recipes/kmo_fits_strip.c b/recipes/kmo_fits_strip.c
index d6495b5..835c9ab 100644
--- a/recipes/kmo_fits_strip.c
+++ b/recipes/kmo_fits_strip.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_fits_strip.c,v 1.14 2013/08/02 09:09:54 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013/08/02 09:09:54 $
- * $Revision: 1.14 $
- * $Name:  $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -122,7 +114,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "processed KMOS fits frame",
                         kmo_fits_strip_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_fits_strip_create,
                         kmo_fits_strip_exec,
diff --git a/recipes/kmo_flat.c b/recipes/kmo_flat.c
index 0b8276f..d11bd8b 100644
--- a/recipes/kmo_flat.c
+++ b/recipes/kmo_flat.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_flat.c,v 1.49 2013-09-20 13:10:47 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-09-20 13:10:47 $
- * $Revision: 1.49 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -59,34 +51,35 @@ static int kmo_flat(cpl_parameterlist *, cpl_frameset *);
  *                          Static variables
  *----------------------------------------------------------------------------*/
 
-static char kmo_flat_description[15000] =
-"This recipe creates the master flat field and calibration frames needed for \n"
+static char kmo_flat_description[] =
+"This recipe creates the master flat field and calibration frames needed for\n"
 "spatial calibration for all three detectors. It must be called after the \n"
-"kmo_dark-recipe, which generates a bad pixel mask (badpixel_dark.fits). The \n"
-"bad pixel mask will be updated in this recipe (goes into badpixel_flat.fits).\n"
-"As input at least 3 dark frames, 3 frames with the flat lamp on are recommen-\n"
-"ded. Additionally a badpixel mask from kmo_dark is required.\n"
+"kmo_dark-recipe, which generates a bad pixel mask (badpixel_dark.fits). The\n"
+"bad pixel mask will be updated in this recipe.\n"
+"As input at least 3 dark frames, 3 frames with the flat lamp on are\n"
+"recommended. Additionally a badpixel mask from kmo_dark is required.\n"
 "\n"
 "The badpixel mask contains 0 for bad pixels and 1 for good ones.\n"
 "\n"
-"The structure of the resulting xcal and ycal frames is quite complex since the\n"
-"arrangement of the IFUs isn't just linear on the detector. Basically the inte-\n"
-"ger part of the calibration data shows the offset of each pixels centre in mas\n"
-"(Milli arcsec) from the field centre. The viewing of an IFU is 2800mas \n"
-"(14pix*0.2arcsec/pix). So the values in these two frames will vary between \n"
-"+/-1500 (One would expect 1400, but since the slitlets aren't expected to be \n"
-"exactly vertical, the values can even go up to around 1500). Additionally in \n"
-"the calibration data in y-direction the decimal part of the data designates \n"
-"the IFU to which the slitlet corresponds to (for each detector from 1 to 8).\n"
-"Because of the irregular arrangement of the IFUs not all x-direction calibra-\n"
-"tion data is found in xcal and similarly not all y-direction calibration data\n"
-"is located in ycal. For certain IFUs they are switched and/or flipped in x- or\n"
-"y-direction:\n"
-"For IFUs 1,2,3,4,13,14,15,16:		x- and y- data is switched\n"
-"For IFUs 17,18,19,20:			y-data is flipped \n"
-"For IFUs 21,22,23,24:			x-data is flipped \n"
-"For IFUs 5,6,7,8,9,10,11,12:		x- and y- data is switched and x- and \n"
-"                                      y- data is flipped\n"
+"The structure of the resulting xcal and ycal frames is quite complex since\n"
+"the arrangement of the IFUs isn't just linear on the detector. Basically the\n"
+"integer part of the calibration data shows the offset of each pixels centre\n"
+"in mas (Milli arcsec) from the field centre. The viewing of an IFU is\n"
+"2800 mas (14pix*0.2arcsec/pix). So the values in these two frames will vary\n"
+"between +/-1500 (One would expect 1400, but since the slitlets aren't\n"
+"expected to be exactly vertical, the values can even go up to around 1500).\n"
+"Additionally in the calibration data in y-direction the decimal part of the\n"
+"data designates the IFU to which the slitlet corresponds to (for each\n"
+"detector from 1 to 8).\n"
+"Because of the irregular arrangement of the IFUs not all x-direction\n"
+"calibration data is found in xcal and similarly not all y-direction\n"
+"calibration data is located in ycal. For certain IFUs they are switched\n"
+" and/or flipped in x- or y-direction:\n"
+"For IFUs 1,2,3,4,13,14,15,16:  x- and y- data is switched\n"
+"For IFUs 17,18,19,20:          y-data is flipped \n"
+"For IFUs 21,22,23,24:          x-data is flipped \n"
+"For IFUs 5,6,7,8,9,10,11,12:   x- and y- data is switched and\n"
+"                               x- and y- data is flipped\n"
 "\n"
 "Furthermore frames can be provided for several rotator angles. In this case\n"
 "the resulting calibration frames for each detector are repeatedly saved as \n"
@@ -94,32 +87,34 @@ static char kmo_flat_description[15000] =
 "\n"
 "Advanced features:\n"
 "------------------\n"
-"To create the badpixel mask the edges of all slitlets are fitted to a polyno-\n"
-"mial. Since it can happen that some of these fits (3 detectors * 8 IFUs * \n"
-"14slitlets * 2 edges  (left and right edge of slitlet)= 672 edges) fail, the\n"
-"fit parameters are themselves fitted again to detect any outliers. By default\n"
-"the parameters of all left and all right edges are grouped individually and \n"
-"then fitted using chebyshev polynomials. The advantage of a chebyshev polyno-\n"
-"mial is, that it consists in fact of a series of orthogonal polynomials. This\n"
-"implies that the parameters of the polynomials are independent. This fact pre-\n"
-"destines the use of chebyshev polynomials for our case. So each individual pa-\n"
-"rameter can be examined independently. The reason why the left and right edges\n"
-"are fitted individually is that there is a systematic pattern specific to \n"
-"these groups. The reason for this pattern is probably to be found in the opti-\n"
-"cal path the light is traversing.\n"
+"To create the badpixel mask the edges of all slitlets are fitted to a\n"
+"polynomial. Since it can happen that some of these fits (3 detectors\n"
+"8 IFUs * 14slitlets * 2 edges  (left and right edge of slitlet)= 672 edges)\n"
+"fail, the fit parameters are themselves fitted again to detect any outliers.\n"
+"By default, the parameters of all left and all right edges are grouped\n"
+"individually and then fitted using chebyshev polynomials. The advantage of\n"
+"a chebyshev polynomial is, that it consists in fact of a series of\n"
+"orthogonal polynomials. This implies that the parameters of the polynomials\n"
+"are independent. This fact predestines the use of chebyshev polynomials\n"
+"for our case. So each individual parameter can be examined independently.\n"
+"The reason why the left and right edges are fitted individually is that\n"
+"there is a systematic pattern specific to these groups. The reason for\n"
+"this pattern is probably to be found in the optical path the light is\n"
+"traversing.\n"
 "\n"
-"The behaviour of this fitting step can be influenced via environment parameters:\n"
+"The behaviour of this fitting step can be influenced via environment\n"
+"parameters:\n"
 "* KF_ALLPARS (default: 1)\n"
-"  When set to 1 all coefficients of the polynomial of an edge are to be cor-\n"
-"  rected, also when just one of these coefficients is an outlier. When set to\n"
-"  0 only the outlier is to be corrected.\n"
+"  When set to 1 all coefficients of the polynomial of an edge are to be\n"
+"  corrected, also when just one of these coefficients is an outlier. When\n"
+"  set to 0 only the outlier is to be corrected.\n"
 "* KF_CH (default: 1)\n"
 "  When set to 1 chebyshev polynomials are used to fit the fitted parameters.\n"
 "  When set to 0 normal polynomials are used.\n"
 "* KF_SIDES (default: 2)\n"
-"  This variable can either be set to 1 or 2. When set to 2 the left and right\n"
-"  edges are examined individually. When set to 1 all edges are examined as one\n"
-"  group.\n"
+"  This variable can either be set to 1 or 2. When set to 2 the left and\n"
+"  right edges are examined individually. When set to 1 all edges are\n"
+"  examined as one group.\n"
 "* KF_FACTOR(default: 4)\n"
 "  This factor defines the threshold factor. All parameters deviating \n"
 "  KF_FACTOR*stddev are to be corrected\n"
@@ -136,13 +131,13 @@ static char kmo_flat_description[15000] =
 "--cmethod\n"
 "Following methods of frame combination are available:\n"
 "   * 'ksigma' (Default)\n"
-"   An iterative sigma clipping. For each position all pixels in the spectrum\n"
-"   are examined. If they deviate significantly, they will be rejected according\n"
-"   to the conditions:\n"
+"   An iterative sigma clipping. For each position all pixels in the\n"
+"   spectrum are examined. If they deviate significantly, they will be\n"
+"   rejected according to the conditions:\n"
 "       val > mean + stdev * cpos_rej\n"
 "   and\n"
 "       val < mean - stdev * cneg_rej\n"
-"   where --cpos_rej, --cneg_rej and --citer are the corresponding configuration\n"
+"   where --cpos_rej, --cneg_rej and --citer are the configuration\n"
 "   parameters. In the first iteration median and percentile level are used.\n"
 "\n"
 "   * 'median'\n"
@@ -155,7 +150,7 @@ static char kmo_flat_description[15000] =
 "   At each pixel position the sum is calculated.\n"
 "\n"
 "   * 'min_max'\n"
-"   The specified number of minimum and maximum pixel values will be rejected.\n"
+"   The specified number of min and max pixel values will be rejected.\n"
 "   --cmax and --cmin apply to this method.\n"
 "\n"
 "ADVANCED PARAMETERS\n"
@@ -170,49 +165,44 @@ static char kmo_flat_description[15000] =
 "see --cmethod='min_max'\n"
 "\n"
 "--suppress_extension\n"
-"If set to TRUE, the arbitrary filename extensions are supressed. If multiple\n"
-"products with the same category are produced, they will be numered consecutively\n"
-"starting from 0.\n"
+"If set to TRUE, the arbitrary filename extensions are supressed. If\n"
+"multiple products with the same category are produced, they will be\n"
+"numered consecutively starting from 0.\n"
 "\n"
 "-------------------------------------------------------------------------------\n"
 "  Input files:\n"
-"\n"
-"   DO                    KMOS                                                  \n"
-"   category              Type   Explanation                    Required #Frames\n"
-"   --------              -----  -----------                    -------- -------\n"
-"   FLAT_ON               RAW    Flatlamp-on exposures             Y       1-n  \n"
-"                                (at least 3 frames recommended)                \n"
-"   FLAT_OFF              RAW    Flatlamp-off exposures            Y       1-n  \n"
-"                                (at least 3 frames recommended)                \n"
-"   BADPIXEL_DARK         B2D    Bad pixel mask                    Y        1   \n"
+"   DO CATG           Type   Explanation                    Required #Frames\n"
+"   -------           -----  -----------                    -------- -------\n"
+"   FLAT_ON           RAW    Flatlamp-on exposures             Y       1-n  \n"
+"                            (at least 3 frames recommended)                \n"
+"   FLAT_OFF          RAW    Flatlamp-off exposures            Y       1-n  \n"
+"                            (at least 3 frames recommended)                \n"
+"   BADPIXEL_DARK     B2D    Bad pixel mask                    Y        1   \n"
 "\n"
 "  Output files:\n"
-"\n"
-"   DO                    KMOS\n"
-"   category              Type   Explanation\n"
-"   --------              -----  -----------\n"
-"   MASTER_FLAT           F2D    Normalised flat field\n"
-"                                (6 extensions: alternating data & noise\n"
-"   BADPIXEL_FLAT         B2D    Updated bad pixel mask (3 Extensions)\n"
-"   XCAL                  F2D    Calibration frame 1 (3 Extensions)\n"
-"   YCAL                  F2D    Calibration frame 2 (3 Extensions)\n"
-"   FLAT_EDGE             F2L    Frame containing parameters of fitted \n"
-"                                slitlets of all IFUs of all detectors\n"
-"-------------------------------------------------------------------------------"
+"   DO CATG           Type   Explanation\n"
+"   -------           -----  -----------\n"
+"   MASTER_FLAT       F2D    Normalised flat field\n"
+"                            (6 extensions: alternating data & noise\n"
+"   BADPIXEL_FLAT     B2D    Updated bad pixel mask (3 Extensions)\n"
+"   XCAL              F2D    Calibration frame 1 (3 Extensions)\n"
+"   YCAL              F2D    Calibration frame 2 (3 Extensions)\n"
+"   FLAT_EDGE         F2L    Frame containing parameters of fitted \n"
+"                            slitlets of all IFUs of all detectors\n"
+"---------------------------------------------------------------------------"
 "\n";
 
 /*-----------------------------------------------------------------------------
  *                              Functions code
  *----------------------------------------------------------------------------*/
+
 /**
- * @defgroup kmo_flat kmo_flat Create master flatfield frame and badpixel map
- *
- * See recipe description for details.
+ * @defgroup kmo_flat   Create master flatfield frame and badpixel map
  */
 
 /**@{*/
 
-
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Build the list of available plugins, for this module. 
   @param    list    the plugin list
@@ -221,31 +211,32 @@ static char kmo_flat_description[15000] =
   Create the recipe instance and make it available to the application using the 
   interface. This function is exported.
  */
+/*----------------------------------------------------------------------------*/
 int cpl_plugin_get_info(cpl_pluginlist *list)
 {
     cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
     cpl_plugin *plugin = &recipe->interface;
 
     cpl_plugin_init(plugin,
-                        CPL_PLUGIN_API,
-                        KMOS_BINARY_VERSION,
-                        CPL_PLUGIN_TYPE_RECIPE,
-                        "kmo_flat",
-                        "Create master flatfield frame and badpixel map to be "
-                        "used during science reduction",
-                        kmo_flat_description,
-                        "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
-                        kmos_get_license(),
-                        kmo_flat_create,
-                        kmo_flat_exec,
-                        kmo_flat_destroy);
+            CPL_PLUGIN_API,
+            KMOS_BINARY_VERSION,
+            CPL_PLUGIN_TYPE_RECIPE,
+            "kmo_flat",
+            "Create master flatfield frame and badpixel map",
+            kmo_flat_description,
+            "Alex Agudo Berbel",
+            "usd-help at eso.org",
+            kmos_get_license(),
+            kmo_flat_create,
+            kmo_flat_exec,
+            kmo_flat_destroy);
 
     cpl_pluginlist_append(list, plugin);
 
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Setup the recipe options    
   @param    plugin  the plugin
@@ -253,70 +244,66 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
 
   Defining the command-line/configuration parameters for the recipe.
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_flat_create(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
     cpl_parameter *p;
 
-    // Check that the plugin is part of a valid recipe
+    /* Check that the plugin is part of a valid recipe */
     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
         recipe = (cpl_recipe *)plugin;
     else
         return -1;
 
-    // Create the parameters list in the cpl_recipe object
+    /* Create the parameters list in the cpl_recipe object */
     recipe->parameters = cpl_parameterlist_new();
 
-    // Fill the parameters list
-    // --badpix_thresh
+    /* Fill the parameters list */
+
+    /* --badpix_thresh */
     p = cpl_parameter_new_value("kmos.kmo_flat.badpix_thresh",
-                                CPL_TYPE_INT,
-                                "The threshold level to mark pixels as bad on "
-                                "the dark subtracted frames [%].",
-                                "kmos.kmo_flat",
-                                35);
+            CPL_TYPE_INT,
+            "The threshold level to mark pixels as bad on the dark subtracted frames [%].",
+            "kmos.kmo_flat", 35);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "badpix_thresh");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
-    // --surrounding_pixels
+    /* --surrounding_pixels */
     p = cpl_parameter_new_value("kmos.kmo_flat.surrounding_pixels",
-                                CPL_TYPE_INT,
-                                "The amount of bad pixels to surround a specific "
-                                "pixel, to let it be marked bad as well.",
-                                "kmos.kmo_flat",
-                                5);
+            CPL_TYPE_INT,
+            "The amount of bad pixels to surround a specific pixel, to let it be marked bad as well.",
+            "kmos.kmo_flat", 5);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "surrounding_pixels");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --suppress_extension */
     p = cpl_parameter_new_value("kmos.kmo_flat.suppress_extension",
-                                CPL_TYPE_BOOL,
-                                "Suppress arbitrary filename extension."
-                                "(TRUE (apply) or FALSE (don't apply)",
-                                "kmos.kmo_flat",
-                                FALSE);
+            CPL_TYPE_BOOL,
+            "Suppress arbitrary filename extension. (TRUE (apply) or FALSE (don't apply)",
+            "kmos.kmo_flat", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "suppress_extension");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
-    return kmo_combine_pars_create(recipe->parameters,
-                                   "kmos.kmo_flat",
-                                   DEF_REJ_METHOD,
-                                   FALSE);
+    return kmo_combine_pars_create(recipe->parameters, "kmos.kmo_flat", 
+            DEF_REJ_METHOD, FALSE);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Execute the plugin instance given by the interface
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_flat_exec(cpl_plugin *plugin)
 {
     cpl_recipe  *recipe;
 
-    // Get the recipe out of the plugin
+    /* Get the recipe out of the plugin */
     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
         recipe = (cpl_recipe *)plugin;
     else return -1;
@@ -324,16 +311,18 @@ static int kmo_flat_exec(cpl_plugin *plugin)
     return kmo_flat(recipe->parameters, recipe->frames);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Destroy what has been created by the 'create' function
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_flat_destroy(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
 
-    // Get the recipe out of the plugin
+    /* Get the recipe out of the plugin */
     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
         recipe = (cpl_recipe *)plugin;
     else return -1 ;
@@ -342,6 +331,7 @@ static int kmo_flat_destroy(cpl_plugin *plugin)
     return 0 ;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Interpret the command line options and execute the data processing
   @param    parlist     the parameters list
@@ -349,13 +339,13 @@ static int kmo_flat_destroy(cpl_plugin *plugin)
   @return   0 if everything is ok
 
   Possible _cpl_error_code_ set in this function:
-
-    @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
-                                     if first operand not 3d or
-                                     if second operand not valid
-    @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands
-                                     do not match
+  @li CPL_ERROR_ILLEGAL_INPUT    if operator not valid,
+                                 if first operand not 3d or
+                                 if second operand not valid
+  @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands
+                                   do not match
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
 {
     cpl_imagelist    *det_lamp_on           = NULL,
@@ -394,7 +384,6 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      *stored_qc_flat_sat    = NULL,
                      *bounds                = NULL,
                      **total_bounds         = NULL,
-//                     ***all_bounds          = NULL,
                      nr_bad_pix             = 0,
                      ndit                   = 0,
                      suppress_extension     = FALSE,
@@ -455,312 +444,247 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
         kmo_init_fits_desc(&desc1);
         kmo_init_fits_desc(&desc2);
 
-// #############################################################################
-// ###           check inputs
-// #############################################################################
-        KMO_TRY_ASSURE((parlist != NULL) &&
-                       (frameset != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        KMO_TRY_ASSURE((parlist != NULL) && (frameset != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, FLAT_OFF) >= 1,
-                       CPL_ERROR_NULL_INPUT,
-                       "At least 1 FLAT_OFF frame must be provided (3 or more "
-                       "recommended)!");
+                CPL_ERROR_NULL_INPUT,
+                "At least 1 FLAT_OFF frame is needed (3 or more recommended)");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, FLAT_ON) >= 1,
-                       CPL_ERROR_NULL_INPUT,
-                       "At least 1 FLAT_ON frame must be provided (3 or more "
-                       "recommended)!");
+                CPL_ERROR_NULL_INPUT,
+                "At least 1 FLAT_ON frame is needed (3 or more recommended)");
 
         if (cpl_frameset_count_tags(frameset, FLAT_OFF) < 3) {
-            cpl_msg_warning(cpl_func, "It is recommended to provide at least "
-                                      "3 FLAT_OFF frames (Generated noise frames"
-                                      " will not be very representative)!");
+            cpl_msg_warning(cpl_func, 
+                    "It is recommended to provide at least 3 FLAT_OFF frames");
         }
 
         if (cpl_frameset_count_tags(frameset, FLAT_ON) < 3) {
-            cpl_msg_warning(cpl_func, "It is recommended to provide at least "
-                                      "3 FLAT_ON frames (Generated noise frames"
-                                      " will not be very representative)!");
+            cpl_msg_warning(cpl_func, 
+                    "It is recommended to provide at least 3 FLAT_ON frames") ;
         }
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, BADPIXEL_DARK) == 1,
-                       CPL_ERROR_NULL_INPUT,
-                       "A BADPIXEL_DARK frame must be provided!");
+                CPL_ERROR_NULL_INPUT, "BADPIXEL_DARK frame must be provided");
 
         KMO_TRY_ASSURE(kmo_dfs_set_groups(frameset, "kmo_flat") == 1,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Cannot identify RAW and CALIB frames!");
-
+                CPL_ERROR_ILLEGAL_INPUT,"Cannot identify RAW and CALIB frames");
 
-        //
-        // ------------ get parameters ------------
-        //
+        /* ------------ get parameters ------------ */
         cpl_msg_info("", "--- Parameter setup for kmo_flat ----------");
 
         surrounding_pixels = kmo_dfs_get_parameter_int(parlist,
-                                         "kmos.kmo_flat.surrounding_pixels");
+                "kmos.kmo_flat.surrounding_pixels");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                         "kmos.kmo_flat.surrounding_pixels"));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(parlist,
+                    "kmos.kmo_flat.surrounding_pixels"));
 
         badpix_thresh = kmo_dfs_get_parameter_int(parlist,
-                                         "kmos.kmo_flat.badpix_thresh");
+                "kmos.kmo_flat.badpix_thresh");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist,
-                                         "kmos.kmo_flat.badpix_thresh"));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(parlist,
+                    "kmos.kmo_flat.badpix_thresh"));
 
         suppress_extension = kmo_dfs_get_parameter_bool(parlist,
-                                          "kmos.kmo_flat.suppress_extension");
+                "kmos.kmo_flat.suppress_extension");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_flat.suppress_extension"));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(parlist,
+                    "kmos.kmo_flat.suppress_extension"));
 
-        KMO_TRY_ASSURE((suppress_extension == TRUE) || (suppress_extension == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "suppress_extension must be TRUE or FALSE!");
+        KMO_TRY_ASSURE((suppress_extension == TRUE) || 
+                (suppress_extension == FALSE),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "suppress_extension must be TRUE or FALSE!");
 
         KMO_TRY_EXIT_IF_ERROR(
             kmo_combine_pars_load(parlist, "kmos.kmo_flat", &cmethod, &cpos_rej,
-                                  &cneg_rej, &citer, &cmin, &cmax,
-                                  FALSE));
+                &cneg_rej, &citer, &cmin, &cmax, FALSE));
 
         cpl_msg_info("", "-------------------------------------------");
 
-        // check BADPIXEL_DARK
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, BADPIXEL_DARK));
-
-        desc2 = kmo_identify_fits_header(
-                    cpl_frame_get_filename(frame));
+        /* check BADPIXEL_DARK */
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset,BADPIXEL_DARK));
+        desc2 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
         KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_ASSURE((desc2.nr_ext == 3) &&
-                       (desc2.ex_badpix == TRUE) &&
-                       (desc2.fits_type == b2d_fits) &&
-                       (desc2.frame_type == detector_frame),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "BADPIXEL_DARK isn't in the correct format!!!");
+        KMO_TRY_ASSURE((desc2.nr_ext == 3) && (desc2.ex_badpix == TRUE) &&
+                (desc2.fits_type == b2d_fits) &&
+                (desc2.frame_type == detector_frame), CPL_ERROR_ILLEGAL_INPUT,
+                "BADPIXEL_DARK isn't in the correct format");
 
         nx = desc2.naxis1;
         ny = desc2.naxis2;
         nz = desc2.naxis3;
 
         KMO_TRY_ASSURE((surrounding_pixels >= 0) && (surrounding_pixels <= 8),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "surrounding_pixels must be between 0 and 8!");
+                CPL_ERROR_ILLEGAL_INPUT,
+                "surrounding_pixels must be between 0 and 8!");
 
         KMO_TRY_ASSURE((badpix_thresh >= 0) && (badpix_thresh <= 100),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "badpix_thresh must be between 0 and 100%%!");
+                CPL_ERROR_ILLEGAL_INPUT, 
+                "badpix_thresh must be between 0 and 100%%!");
 
-        //
         // ------------ check EXPTIME, NDIT, READMODE and lamps ------------
         //    EXPTIME, NDIT, READMODE: the same for all frames
         //    lamps:   at least 3 lamp on and 3 lamp off frames
-        //
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, FLAT_OFF));
-
-        KMO_TRY_EXIT_IF_NULL(
-            main_header = kmclipm_propertylist_load(
-                                         cpl_frame_get_filename(frame), 0));
-
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, FLAT_OFF));
+        
+        KMO_TRY_EXIT_IF_NULL(main_header = kmclipm_propertylist_load(
+                    cpl_frame_get_filename(frame), 0));
         ndit = cpl_propertylist_get_int(main_header, NDIT);
-        KMO_TRY_CHECK_ERROR_STATE("NDIT keyword in main header "
-                                  "missing!");
-
+        KMO_TRY_CHECK_ERROR_STATE("NDIT keyword in main header missing");
         exptime = cpl_propertylist_get_double(main_header, EXPTIME);
-        KMO_TRY_CHECK_ERROR_STATE("EXPTIME keyword in main header "
-                                  "missing!");
-
-        readmode = cpl_strdup(cpl_propertylist_get_string(main_header, READMODE));
-        KMO_TRY_CHECK_ERROR_STATE("ESO DET READ CURNAME keyword in main "
-                                  "header missing!");
-
+        KMO_TRY_CHECK_ERROR_STATE("EXPTIME keyword in main header missing");
+        readmode =cpl_strdup(cpl_propertylist_get_string(main_header,READMODE));
+        KMO_TRY_CHECK_ERROR_STATE("ESO DET READ CURNAME keyword is missing");
         cpl_propertylist_delete(main_header); main_header = NULL;
 
+        /* Loop through FLAT_OFF frames */
         while (frame != NULL) {
             KMO_TRY_EXIT_IF_NULL(
                 main_header = kmclipm_propertylist_load(
-                                             cpl_frame_get_filename(frame), 0));
+                    cpl_frame_get_filename(frame), 0));
 
             KMO_TRY_ASSURE(cpl_propertylist_get_int(main_header, NDIT) == ndit,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "NDIT isn't the same for all frames: (is %d and %d).",
-                            cpl_propertylist_get_int(main_header, NDIT), ndit);
-
-            KMO_TRY_ASSURE(cpl_propertylist_get_double(main_header, EXPTIME) == exptime,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "EXPTIME isn't the same for all frames: (is %g and %g).",
-                           cpl_propertylist_get_double(main_header, EXPTIME), exptime);
-
-            KMO_TRY_ASSURE(strcmp(cpl_propertylist_get_string(main_header, READMODE), readmode) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "ESO DET READ CURNAME isn't the same for all frames: (is %s and %s).",
-                           cpl_propertylist_get_string(main_header, READMODE), readmode);
-
-            desc1 = kmo_identify_fits_header(
-                        cpl_frame_get_filename(frame));
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "NDIT isn't the same for all frames: (is %d and %d).",
+                    cpl_propertylist_get_int(main_header, NDIT), ndit);
+
+            KMO_TRY_ASSURE(
+                    cpl_propertylist_get_double(main_header, EXPTIME)==exptime,
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "EXPTIME isn't the same for all frames: (is %g and %g).",
+                    cpl_propertylist_get_double(main_header, EXPTIME), exptime);
+
+            KMO_TRY_ASSURE(strcmp(cpl_propertylist_get_string(main_header, 
+                            READMODE), readmode) == 0,
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "ESO DET READ CURNAME isn't constant: (is %s and %s).",
+                    cpl_propertylist_get_string(main_header, READMODE), 
+                    readmode);
+
+            desc1 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
             KMO_TRY_CHECK_ERROR_STATE_MSG(
-                    cpl_sprintf("File (%s) doesn't seem to be in KMOS-format!",
-                            cpl_frame_get_filename(frame)));
+                    cpl_sprintf("File (%s) doesn't seem to be in KMOS-format",
+                        cpl_frame_get_filename(frame)));
 
             KMO_TRY_ASSURE(desc1.fits_type == raw_fits,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "File hasn't correct data type "
-                           "(%s must be a raw, unprocessed file)!",
-                           cpl_frame_get_filename(frame));
-
-            KMO_TRY_ASSURE((desc1.naxis1 == nx) &&
-                           (desc1.naxis2 == ny) &&
-                           (desc1.naxis3 == nz),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "File (%s) hasn't correct dimensions! (x,y): "
-                           "(%d,%d) vs (%d,%d)",
-                           cpl_frame_get_filename(frame),
-                           desc1.naxis1, desc1.naxis2, nx, ny);
-
-            // assure that arc lamps are off
-            KMO_TRY_ASSURE((kmo_check_lamp(main_header, INS_LAMP1_ST) == FALSE) &&
-                           (kmo_check_lamp(main_header, INS_LAMP2_ST) == FALSE),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Arc lamps must be switched off (%s)!",
-                           cpl_frame_get_filename(frame));
-
-            // check if flat lamps are off
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "File hasn't correct data type (%s must be a raw)",
+                    cpl_frame_get_filename(frame));
+
+            KMO_TRY_ASSURE((desc1.naxis1 == nx) && (desc1.naxis2 == ny) &&
+                    (desc1.naxis3 == nz), CPL_ERROR_ILLEGAL_INPUT,
+                    "File (%s) has wrong dimensions! (x,y): (%d,%d) vs (%d,%d)",
+                    cpl_frame_get_filename(frame), desc1.naxis1, desc1.naxis2, 
+                    nx, ny);
+
+            /* Assure that arc lamps are off */
+            KMO_TRY_ASSURE((kmo_check_lamp(main_header, INS_LAMP1_ST) == FALSE)
+                    && (kmo_check_lamp(main_header, INS_LAMP2_ST) == FALSE),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "Arc lamps must be switched off (%s)!",
+                    cpl_frame_get_filename(frame));
+
+            /* Check if flat lamps are off */
             if ((kmo_check_lamp(main_header, INS_LAMP3_ST) == TRUE) ||
-                (kmo_check_lamp(main_header, INS_LAMP4_ST) == TRUE))
-            {
-                if (!(strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT1 ID"), "Block") == 0) ||
-                    !(strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT2 ID"), "Block") == 0) ||
-                    !(strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT3 ID"), "Block") == 0))
-                {
-                    cpl_msg_warning("","At least one flat lamp is on! Check if the lamps are blocked!");
+                (kmo_check_lamp(main_header, INS_LAMP4_ST) == TRUE)) {
+                if (!(strcmp(cpl_propertylist_get_string(main_header, 
+                                    "ESO INS FILT1 ID"), "Block") == 0) ||
+                    !(strcmp(cpl_propertylist_get_string(main_header, 
+                                "ESO INS FILT2 ID"), "Block") == 0) ||
+                    !(strcmp(cpl_propertylist_get_string(main_header, 
+                                "ESO INS FILT3 ID"), "Block") == 0)) {
+                    cpl_msg_warning(__func__, "At least one flat lamp is on");
                 }
             }
-
             kmo_free_fits_desc(&desc1);
 
-            // get next FLAT_OFF frame
+            /* Get next FLAT_OFF frame */
             frame = kmo_dfs_get_frame(frameset, NULL);
             KMO_TRY_CHECK_ERROR_STATE();
 
             cpl_propertylist_delete(main_header); main_header = NULL;
         }
 
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, FLAT_ON));
-
-        // uncomment this if these keywords can be different for FLAT_OFF and FLAT_ON
-//        KMO_TRY_EXIT_IF_NULL(
-//            main_header = kmclipm_propertylist_load(
-//                                         cpl_frame_get_filename(frame), 0));
-//        ndit = cpl_propertylist_get_int(main_header, NDIT);
-//        KMO_TRY_CHECK_ERROR_STATE("NDIT keyword in main header "
-//                                  "missing!");
-//        exptime = cpl_propertylist_get_double(main_header, EXPTIME);
-//        KMO_TRY_CHECK_ERROR_STATE("EXPTIME keyword in main header "
-//                                  "missing!");
-
-//        readmode = cpl_propertylist_get_string(main_header, READMODE);
-//        KMO_TRY_CHECK_ERROR_STATE("ESO DET READ CURNAME keyword in main "
-//                                  "header missing!");
-
-//        cpl_propertylist_delete(main_header); main_header = NULL;
-
+        /* Loop through FLAT_ON frames */
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, FLAT_ON));
         while (frame != NULL) {
-            KMO_TRY_EXIT_IF_NULL(
-                main_header = kmclipm_propertylist_load(
-                                             cpl_frame_get_filename(frame), 0));
+            KMO_TRY_EXIT_IF_NULL(main_header = kmclipm_propertylist_load(
+                        cpl_frame_get_filename(frame), 0));
 
             KMO_TRY_ASSURE(cpl_propertylist_get_int(main_header, NDIT) == ndit,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "NDIT isn't the same for all frames: (is %d and %d).",
-                            cpl_propertylist_get_int(main_header, NDIT), ndit);
-
-            KMO_TRY_ASSURE(cpl_propertylist_get_double(main_header, EXPTIME) == exptime,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "EXPTIME isn't the same for all frames: (is %g and %g).",
-                           cpl_propertylist_get_double(main_header, EXPTIME), exptime);
-
-            KMO_TRY_ASSURE(strcmp(cpl_propertylist_get_string(main_header, READMODE), readmode) == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "ESO DET READ CURNAME isn't the same for all frames: (is %s and %s).",
-                           cpl_propertylist_get_string(main_header, READMODE), readmode);
-
-            desc1 = kmo_identify_fits_header(
-                        cpl_frame_get_filename(frame));
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "NDIT isn't the same for all frames: (is %d and %d).",
+                    cpl_propertylist_get_int(main_header, NDIT), ndit);
+
+            KMO_TRY_ASSURE(
+                    cpl_propertylist_get_double(main_header, EXPTIME)==exptime,
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "EXPTIME isn't the same for all frames: (is %g and %g).",
+                    cpl_propertylist_get_double(main_header, EXPTIME), exptime);
+
+            KMO_TRY_ASSURE(strcmp(cpl_propertylist_get_string(main_header, 
+                            READMODE), readmode) == 0,
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "ESO DET READ CURNAME isn't constant: (is %s and %s).",
+                    cpl_propertylist_get_string(main_header,READMODE),readmode);
+
+            desc1 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
             KMO_TRY_CHECK_ERROR_STATE_MSG(
-                    cpl_sprintf("File (%s) doesn't seem to be in KMOS-format!",
-                            cpl_frame_get_filename(frame)));
+                    cpl_sprintf("File (%s) doesn't seem to be in KMOS-format",
+                        cpl_frame_get_filename(frame)));
 
-            KMO_TRY_ASSURE(desc1.fits_type == raw_fits,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "File hasn't correct data type "
-                           "(%s must be a raw, unprocessed file)!",
-                           cpl_frame_get_filename(frame));
-
-            KMO_TRY_ASSURE((desc1.naxis1 == nx) &&
-                           (desc1.naxis2 == ny) &&
-                           (desc1.naxis3 == nz),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "File (%s) hasn't correct dimensions! (x,y): "
-                           "(%d,%d) vs (%d,%d)",
-                           cpl_frame_get_filename(frame),
-                           desc1.naxis1, desc1.naxis2, nx, ny);
-
-            // assure that arc lamps are off
-            KMO_TRY_ASSURE((kmo_check_lamp(main_header, INS_LAMP1_ST) == FALSE) &&
-                           (kmo_check_lamp(main_header, INS_LAMP2_ST) == FALSE),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Arc lamps must be switched off (%s)!",
-                           cpl_frame_get_filename(frame));
-
-            // assure that at least one flat lamp is on
-            KMO_TRY_ASSURE((kmo_check_lamp(main_header, INS_LAMP3_ST) == TRUE) ||
-                           (kmo_check_lamp(main_header, INS_LAMP4_ST) == TRUE),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "At least one flat lamps must be switched on (%s)!",
-                           cpl_frame_get_filename(frame));
+            KMO_TRY_ASSURE(desc1.fits_type == raw_fits, CPL_ERROR_ILLEGAL_INPUT,
+                    "File hasn't correct data type (%s must be a raw)",
+                    cpl_frame_get_filename(frame));
 
+            KMO_TRY_ASSURE((desc1.naxis1 == nx) && (desc1.naxis2 == ny) &&
+                    (desc1.naxis3 == nz), CPL_ERROR_ILLEGAL_INPUT,
+                    "File (%s) has wrong dimensions (x,y): (%d,%d) vs (%d,%d)",
+                    cpl_frame_get_filename(frame),
+                    desc1.naxis1, desc1.naxis2, nx, ny);
+
+            /* Assure that arc lamps are off */
+            KMO_TRY_ASSURE((kmo_check_lamp(main_header, INS_LAMP1_ST) == FALSE)
+                    && (kmo_check_lamp(main_header, INS_LAMP2_ST) == FALSE),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "Arc lamps must be switched off (%s)",
+                    cpl_frame_get_filename(frame));
+
+            /* Assure that at least one flat lamp is on */
+            KMO_TRY_ASSURE((kmo_check_lamp(main_header, INS_LAMP3_ST) == TRUE)
+                    || (kmo_check_lamp(main_header, INS_LAMP4_ST) == TRUE),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "At least one flat lamps must be switched on (%s)",
+                    cpl_frame_get_filename(frame));
             kmo_free_fits_desc(&desc1);
 
-            // get next FLAT_ON frame
+            /* Get next FLAT_ON frame */
             frame = kmo_dfs_get_frame(frameset, NULL);
             KMO_TRY_CHECK_ERROR_STATE();
 
             cpl_propertylist_delete(main_header); main_header = NULL;
         }
 
-        //
-        // ------------ check filter_id, grating_id and rotator offset ---------
-        //              must match for all detectors
-        //
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_check_frameset_setup(frameset, FLAT_ON,
-                                     TRUE, FALSE, FALSE));
-
+        /* -------- check filter_id, grating_id and rotator offset -------- */
+        /* must match for all detectors */
+        KMO_TRY_EXIT_IF_ERROR(kmo_check_frameset_setup(frameset, FLAT_ON,
+                    TRUE, FALSE, FALSE));
         strcpy(filename_flat, MASTER_FLAT);
         strcpy(filename_bad, BADPIXEL_FLAT);
         strcpy(filename_xcal, XCAL);
         strcpy(filename_ycal, YCAL);
         strcpy(filename_edge, FLAT_EDGE);
 
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, FLAT_ON));
-        KMO_TRY_EXIT_IF_NULL(
-            suffix = kmo_dfs_get_suffix(frame, TRUE, FALSE));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, FLAT_ON));
+        KMO_TRY_EXIT_IF_NULL(suffix = kmo_dfs_get_suffix(frame, TRUE, FALSE));
 
         cpl_msg_info("", "Detected instrument setup:   %s", suffix+1);
         cpl_msg_info("", "(grating 1, 2 & 3)");
 
-        //
-        // ---- scan for rotator angles
-        //
+        /* ---- scan for rotator angles */
         #define ANGLE_DIM 360
         int rotang_found[ANGLE_DIM];
         int rotang_cnt[ANGLE_DIM];
@@ -768,24 +692,17 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
             rotang_found[i] = 0;
             rotang_cnt[i] = 0;
         }
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, FLAT_ON));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, FLAT_ON));
         while (frame != NULL) {
-            main_header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
+            main_header = kmclipm_propertylist_load(
+                    cpl_frame_get_filename(frame), 0);
             if (cpl_propertylist_has(main_header, ROTANGLE)) {
-                int rot_angle = (int) rint(cpl_propertylist_get_double(main_header, ROTANGLE));
-                if (rot_angle < 0) {
-                    rot_angle += 360;
-                }
-                if (rot_angle < 360 && rot_angle >= 0) {
-                    rotang_cnt[rot_angle]++;
-//                    char * tag = cpl_sprintf("FLAT_ON_%3.3d",rot_angle);
-//                    KMO_TRY_EXIT_IF_ERROR(
-//                            cpl_frame_set_tag(frame, tag));
-//                    cpl_free(tag);
-                }
+                int rot_angle = (int) rint(cpl_propertylist_get_double(
+                            main_header, ROTANGLE));
+                if (rot_angle < 0)                      rot_angle += 360;
+                if (rot_angle < 360 && rot_angle >= 0)  rotang_cnt[rot_angle]++;
             } else {
-                cpl_msg_warning("","File %s has no keyword \"ROTANGLE\"",
+                cpl_msg_warning(__func__, "File %s has no keyword \"ROTANGLE\"",
                         cpl_frame_get_filename(frame));
             }
 
@@ -796,32 +713,27 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
         nr_angles = 0;
         for (ax = 0; ax < ANGLE_DIM; ax++) {
             if (rotang_cnt[ax] != 0) {
-//                if (rotang_cnt[ax] >=3) {
-                    cpl_msg_info("","Found %d frames with rotator angle %d",rotang_cnt[ax],ax);
-                    rotang_found[nr_angles] = ax;
-                    nr_angles++;
-//                } else {
-//                    cpl_msg_warning("","Found %d frames with rotator angle %d but at least three are required",
-//                            rotang_cnt[ax],ax);
-//                }
+                cpl_msg_info(__func__, "Found %d frames with rotator angle %d",
+                        rotang_cnt[ax],ax);
+                rotang_found[nr_angles] = ax;
+                nr_angles++;
             }
         }
 
-        KMO_TRY_EXIT_IF_NULL (
-            angle_frameset = (cpl_frameset **) cpl_malloc(nr_angles * sizeof(cpl_frameset*)));
+        /* Create a Frameset per different Angle */
+        KMO_TRY_EXIT_IF_NULL(angle_frameset = 
+                (cpl_frameset **)cpl_malloc(nr_angles * sizeof(cpl_frameset*)));
         for (i = 0; i < nr_angles; i++) {
             angle_frameset[i] = cpl_frameset_new();
         }
-
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, FLAT_ON));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, FLAT_ON));
         while (frame != NULL) {
-            main_header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
+            main_header = kmclipm_propertylist_load(cpl_frame_get_filename(
+                        frame), 0);
             if (cpl_propertylist_has(main_header, ROTANGLE)) {
-                int rot_angle = (int) rint(cpl_propertylist_get_double(main_header, ROTANGLE));
-                if (rot_angle < 0) {
-                    rot_angle += 360;
-                }
+                int rot_angle = (int)rint(cpl_propertylist_get_double(
+                            main_header, ROTANGLE));
+                if (rot_angle < 0)  rot_angle += 360;
                 int ix = -1;
                 for (ix = 0; ix<nr_angles; ix++) {
                     if (rotang_found[ix] == rot_angle) {
@@ -829,8 +741,8 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     }
                 }
                 if (ix<nr_angles) {
-                    KMO_TRY_EXIT_IF_ERROR(
-                        cpl_frameset_insert(angle_frameset[ix], cpl_frame_duplicate(frame)));
+                    KMO_TRY_EXIT_IF_ERROR(cpl_frameset_insert(
+                                angle_frameset[ix],cpl_frame_duplicate(frame)));
                 }
             }
 
@@ -840,69 +752,49 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
         }
 
 
-// #############################################################################
-// ###           allocate temporary memory
-// #############################################################################
-        // load descriptor and header of first operand
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, FLAT_ON));
-
+        /* -------- Allocate temporary memory */
+        /* Load descriptor and header of first operand */
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, FLAT_ON));
         desc1 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
         KMO_TRY_CHECK_ERROR_STATE();
 
         nr_devices = desc1.nr_ext;
 
-        // the frames have to be stored temporarily because the QC parameters
-        // for the main header are calculated from each detector. So they can be
-        // stored only when all detectors are processed
-        KMO_TRY_EXIT_IF_NULL(
-            stored_flat = (cpl_image**)cpl_calloc(nr_devices * nr_angles,
-                                                  sizeof(cpl_image*)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_noise = (cpl_image**)cpl_calloc(nr_devices * nr_angles,
-                                                   sizeof(cpl_image*)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_badpix = (cpl_image**)cpl_calloc(nr_devices * nr_angles,
-                                                    sizeof(cpl_image*)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_xcal = (cpl_image**)cpl_calloc(nr_devices * nr_angles,
-                                                    sizeof(cpl_image*)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_ycal = (cpl_image**)cpl_calloc(nr_devices * nr_angles,
-                                                    sizeof(cpl_image*)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_qc_flat_sat = (int*)cpl_malloc(nr_devices * nr_angles *
-                                                  sizeof(int)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_qc_flat_eff = (double*)cpl_malloc(nr_devices * nr_angles *
-                                                     sizeof(double)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_qc_flat_sn = (double*)cpl_malloc(nr_devices * nr_angles *
-                                                    sizeof(double)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_gapmean = (double*)cpl_malloc(nr_devices * nr_angles *
-                                                 sizeof(double)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_gapsdv = (double*)cpl_malloc(nr_devices * nr_angles *
-                                                sizeof(double)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_gapmaxdev = (double*)cpl_malloc(nr_devices * nr_angles *
-                                                   sizeof(double)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_slitmean = (double*)cpl_malloc(nr_devices * nr_angles *
-                                                  sizeof(double)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_slitsdv = (double*)cpl_malloc(nr_devices * nr_angles *
-                                                 sizeof(double)));
-        KMO_TRY_EXIT_IF_NULL(
-            stored_slitmaxdev = (double*)cpl_malloc(nr_devices * nr_angles *
-                                                    sizeof(double)));
-        KMO_TRY_EXIT_IF_NULL(
-            spec_found = (cpl_error_code*)cpl_malloc(nr_devices * nr_angles *
-                                                     sizeof(cpl_error_code)));
-        KMO_TRY_EXIT_IF_NULL(
-            edge_table = (cpl_table***)cpl_malloc(KMOS_NR_DETECTORS * nr_angles *
-                                                  sizeof(cpl_table**)));
+        /* The frames have to be stored temporarily because the QC parameters */
+        /* for the main header are calculated from each detector.  */
+        /* So they can be stored only when all detectors are processed */
+        KMO_TRY_EXIT_IF_NULL(stored_flat = (cpl_image**)cpl_calloc(
+                    nr_devices * nr_angles, sizeof(cpl_image*)));
+        KMO_TRY_EXIT_IF_NULL(stored_noise = (cpl_image**)cpl_calloc(
+                    nr_devices * nr_angles, sizeof(cpl_image*)));
+        KMO_TRY_EXIT_IF_NULL(stored_badpix = (cpl_image**)cpl_calloc(
+                    nr_devices * nr_angles, sizeof(cpl_image*)));
+        KMO_TRY_EXIT_IF_NULL(stored_xcal = (cpl_image**)cpl_calloc(
+                    nr_devices * nr_angles, sizeof(cpl_image*)));
+        KMO_TRY_EXIT_IF_NULL(stored_ycal = (cpl_image**)cpl_calloc(
+                    nr_devices * nr_angles, sizeof(cpl_image*)));
+        KMO_TRY_EXIT_IF_NULL(stored_qc_flat_sat = (int*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(int)));
+        KMO_TRY_EXIT_IF_NULL(stored_qc_flat_eff = (double*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(double)));
+        KMO_TRY_EXIT_IF_NULL(stored_qc_flat_sn = (double*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(double)));
+        KMO_TRY_EXIT_IF_NULL(stored_gapmean = (double*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(double)));
+        KMO_TRY_EXIT_IF_NULL(stored_gapsdv = (double*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(double)));
+        KMO_TRY_EXIT_IF_NULL(stored_gapmaxdev = (double*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(double)));
+        KMO_TRY_EXIT_IF_NULL(stored_slitmean = (double*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(double)));
+        KMO_TRY_EXIT_IF_NULL(stored_slitsdv = (double*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(double)));
+        KMO_TRY_EXIT_IF_NULL(stored_slitmaxdev = (double*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(double)));
+        KMO_TRY_EXIT_IF_NULL(spec_found = (cpl_error_code*)cpl_malloc(
+                    nr_devices * nr_angles * sizeof(cpl_error_code)));
+        KMO_TRY_EXIT_IF_NULL(edge_table = (cpl_table***)cpl_malloc(
+                    KMOS_NR_DETECTORS * nr_angles * sizeof(cpl_table**)));
 
         // initialize to NULL
         for (i = 0; i < nr_devices * nr_angles ; i++) {
@@ -922,57 +814,44 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
             edge_table[i] = NULL;
         }
 
-// #############################################################################
-// ###           process data
-// #############################################################################
-
-        // check which IFUs are active for all FLAT_ON frames
-        KMO_TRY_EXIT_IF_NULL(
-            unused_ifus_before = kmo_get_unused_ifus(frameset, 0, 0));
-
-        KMO_TRY_EXIT_IF_NULL(
-            unused_ifus_after = kmo_duplicate_unused_ifus(unused_ifus_before));
+        /* ------------------- Process data */
 
+        /* Check which IFUs are active for all FLAT_ON frames */
+        KMO_TRY_EXIT_IF_NULL(unused_ifus_before = 
+                kmo_get_unused_ifus(frameset, 0, 0));
+        KMO_TRY_EXIT_IF_NULL(unused_ifus_after = 
+                kmo_duplicate_unused_ifus(unused_ifus_before));
         kmo_print_unused_ifus(unused_ifus_before, FALSE);
 
-        cpl_msg_info("", "EXPTIME:  %g seconds", exptime);
-        cpl_msg_info("", "NDIT: %d", ndit);
-        cpl_msg_info("", "Detector readout mode: %s", readmode);
-        cpl_msg_info("", "-------------------------------------------");
-
-        //
-        // ------------ loop all rotator angles and detectors ------------
-        //
+        cpl_msg_info(__func__, "EXPTIME:  %g seconds", exptime);
+        cpl_msg_info(__func__, "NDIT: %d", ndit);
+        cpl_msg_info(__func__, "Detector readout mode: %s", readmode);
+        cpl_msg_info(__func__, "-------------------------------------------");
 
+        /* ------------ loop all rotator angles and detectors-------- */
         for (a = 0; a < nr_angles; a++) {
-            cpl_msg_info("","Processing rotator angle %d -> %d degree", a, rotang_found[a]);
+            cpl_msg_info(__func__, "Processing rotator angle %d -> %d degree", 
+                    a, rotang_found[a]);
             for (i = 1; i <= nr_devices; i++) {
-                cpl_msg_info("","Processing detector No. %d", i);
-
+                cpl_msg_info(__func__, "Processing detector No. %d", i);
                 sx = a * nr_devices + (i - 1);
+                KMO_TRY_EXIT_IF_NULL(bad_pix_mask_dark = 
+                        kmo_dfs_load_image(frameset, BADPIXEL_DARK, i, 2, 
+                            FALSE, NULL));
 
-                KMO_TRY_EXIT_IF_NULL(
-                    bad_pix_mask_dark = kmo_dfs_load_image(frameset, BADPIXEL_DARK,
-                                                           i, 2, FALSE, NULL));
+                /* -------- load all lamp_on and lamp_off images */
+                KMO_TRY_EXIT_IF_NULL(det_lamp_on = cpl_imagelist_new());
+                KMO_TRY_EXIT_IF_NULL(det_lamp_off = cpl_imagelist_new());
 
-                //
-                // ------------ load all lamp_on and lamp_off images ------------
-                //
-                KMO_TRY_EXIT_IF_NULL(
-                    det_lamp_on = cpl_imagelist_new());
-                KMO_TRY_EXIT_IF_NULL(
-                    det_lamp_off = cpl_imagelist_new());
-
-                // load lamp-on images
-                KMO_TRY_EXIT_IF_NULL(
-                    frame = kmo_dfs_get_frame(angle_frameset[a], FLAT_ON));
+                /* Load lamp-on images for Angle a */
+                KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(
+                            angle_frameset[a], FLAT_ON));
                 j = 0;
                 while (frame != NULL) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        img_in = kmo_dfs_load_image_frame(frame, i, FALSE, TRUE, &nr_sat));
-
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_image_reject_from_mask(img_in, bad_pix_mask_dark));
+                    KMO_TRY_EXIT_IF_NULL(img_in = kmo_dfs_load_image_frame(
+                                frame, i, FALSE, TRUE, &nr_sat));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_image_reject_from_mask(
+                                img_in, bad_pix_mask_dark));
 
                     cpl_imagelist_set(det_lamp_on, img_in, j++);
                     KMO_TRY_CHECK_ERROR_STATE();
@@ -981,119 +860,98 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     KMO_TRY_CHECK_ERROR_STATE();
                 }
 
-                // load lamp-off images
-                KMO_TRY_EXIT_IF_NULL(
-                    frame = kmo_dfs_get_frame(frameset, FLAT_OFF));
+                /* Load lamp-off images */
+                KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, 
+                            FLAT_OFF));
                 j = 0;
                 while (frame != NULL) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        img_in = kmo_dfs_load_image_frame(frame, i, FALSE, FALSE, NULL));
+                    KMO_TRY_EXIT_IF_NULL(img_in = kmo_dfs_load_image_frame(
+                                frame, i, FALSE, FALSE, NULL));
 
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_image_reject_from_mask(img_in, bad_pix_mask_dark));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_image_reject_from_mask(
+                                img_in, bad_pix_mask_dark));
 
                     cpl_imagelist_set(det_lamp_off, img_in, j++);
                     KMO_TRY_CHECK_ERROR_STATE();
 
-                    // get next frame
+                    /* Get next frame */
                     frame = kmo_dfs_get_frame(frameset, NULL);
                     KMO_TRY_CHECK_ERROR_STATE();
                 }
 
-                //
-                // ------------ process imagelist ------------
-                //
+                /* ------------ Process imagelist */
 
-                // count saturated pixels for each detector
-                KMO_TRY_EXIT_IF_NULL(
-                    frame = kmo_dfs_get_frame(angle_frameset[a], FLAT_ON));
-                KMO_TRY_EXIT_IF_NULL(
-                    main_header = kmclipm_propertylist_load(
-                                                 cpl_frame_get_filename(frame), 0));
-                if (strcmp(cpl_propertylist_get_string(main_header, READMODE), "Nondest") == 0) {
+                /* Count saturated pixels for each detector */
+                KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(
+                            angle_frameset[a], FLAT_ON));
+                KMO_TRY_EXIT_IF_NULL(main_header = kmclipm_propertylist_load(
+                            cpl_frame_get_filename(frame), 0));
+                if (strcmp(cpl_propertylist_get_string(main_header, READMODE), 
+                            "Nondest") == 0) {
                     // NDR: non-destructive readout mode
                     stored_qc_flat_sat[sx] = nr_sat;
                 } else {
                     // normal readout mode
-                    stored_qc_flat_sat[sx] =
-                                     kmo_imagelist_get_saturated(det_lamp_on,
-                                                                 KMO_FLAT_SATURATED,
-                                                                 KMO_FLAT_SAT_MIN);
+                    stored_qc_flat_sat[sx] = kmo_imagelist_get_saturated(
+                            det_lamp_on, KMO_FLAT_SATURATED, KMO_FLAT_SAT_MIN);
                 }
                 cpl_propertylist_delete(main_header); main_header = NULL;
                 KMO_TRY_CHECK_ERROR_STATE();
 
-                // combine imagelists and create noise
+                /* Combine imagelists and create noise */
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_combine_frames(det_lamp_on, NULL,
-                                           NULL,
-                                           cmethod, cpos_rej, cneg_rej, citer,
-                                           cmax, cmin,
-                                           &combined_data_on,
-                                           &combined_noise_on,
-                                           -1.0));
+                    kmclipm_combine_frames(det_lamp_on, NULL, NULL, cmethod, 
+                        cpos_rej, cneg_rej, citer, cmax, cmin, 
+                        &combined_data_on, &combined_noise_on, -1.0));
 
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_combine_frames(det_lamp_off, NULL,
-                                           NULL,
-                                           cmethod, cpos_rej, cneg_rej, citer,
-                                           cmax, cmin,
-                                           &combined_data_off,
-                                           &combined_noise_off,
-                                           -1.0));
+                    kmclipm_combine_frames(det_lamp_off, NULL, NULL, cmethod, 
+                        cpos_rej, cneg_rej, citer, cmax, cmin,
+                        &combined_data_off, &combined_noise_off, -1.0));
 
                 if (kmclipm_omit_warning_one_slice > 10) {
-// AA: commmented this out: Too unclear for the user, no benefit to know about this number
-//                    cpl_msg_warning(cpl_func, "Previous warning (number of "
-//                                              "identified slices) occured %d times.",
-//                                    kmclipm_omit_warning_one_slice);
                     kmclipm_omit_warning_one_slice = FALSE;
                 }
 
-                // subtract combined lamp_off from lamp_on
+                /* Subtract combined lamp_off from lamp_on */
                 // (for noise: sig_x = sqrt(sig_u^2 + sig_v^2)
                 KMO_TRY_EXIT_IF_ERROR(
                     cpl_image_subtract(combined_data_on, combined_data_off));
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_image_power(combined_noise_on, 2.0));
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_image_power(combined_noise_off, 2.0));
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_image_add(combined_noise_on, combined_noise_off));
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_image_power(combined_noise_on, 0.5));
-
-                // create bad-pixel-mask
-                KMO_TRY_EXIT_IF_NULL(
-                    bad_pix_mask_flat = kmo_create_bad_pix_flat_thresh(
-                                                                combined_data_on,
-                                                                surrounding_pixels,
-                                                                badpix_thresh));
-
-                // calculate spectral curvature here
-                spec_found[sx] = kmo_calc_curvature(combined_data_on,
-                                                    combined_noise_on,
-                                                    unused_ifus_after[i-1],
-                                                    bad_pix_mask_flat,
-                                                    i,
-                                                    &xcal,
-                                                    &ycal,
-                                                    stored_gapmean+(sx),
-                                                    stored_gapsdv+(sx),
-                                                    stored_gapmaxdev+(sx),
-                                                    stored_slitmean+(sx),
-                                                    stored_slitsdv+(sx),
-                                                    stored_slitmaxdev+(sx),
-                                                    &edge_table[sx]);
+                KMO_TRY_EXIT_IF_ERROR(cpl_image_power(combined_noise_on, 2.0));
+                KMO_TRY_EXIT_IF_ERROR(cpl_image_power(combined_noise_off, 2.0));
+                KMO_TRY_EXIT_IF_ERROR(cpl_image_add(combined_noise_on, 
+                            combined_noise_off));
+                KMO_TRY_EXIT_IF_ERROR(cpl_image_power(combined_noise_on, 0.5));
+
+                /* Create bad-pixel-mask */
+                KMO_TRY_EXIT_IF_NULL(bad_pix_mask_flat = 
+                        kmo_create_bad_pix_flat_thresh(combined_data_on,
+                            surrounding_pixels, badpix_thresh));
+
+                /* Calculate spectral curvature here */
+                spec_found[sx] = kmo_calc_curvature(
+                        combined_data_on,
+                        combined_noise_on,
+                        unused_ifus_after[i-1],
+                        bad_pix_mask_flat,
+                        i,
+                        &xcal,
+                        &ycal,
+                        stored_gapmean+(sx),
+                        stored_gapsdv+(sx),
+                        stored_gapmaxdev+(sx),
+                        stored_slitmean+(sx),
+                        stored_slitsdv+(sx),
+                        stored_slitmaxdev+(sx),
+                        &edge_table[sx]);
 
                 if (spec_found[sx] == CPL_ERROR_NONE) {
-                    // all fine
-
-                    // in kmo_calc_curvature() the spectral slope of each slitlet
-                    // has been normalised individually. Now the normalisation on
-                    // the whole frame is applied. (cpl_image_get_mean()
-                    // ignores bad pixels when calculating the mean)
+                    // in kmo_calc_curvature() the spectral slope of each 
+                    // slitlet has been normalised individually. Now the 
+                    // normalisation on the whole frame is applied. 
+                    // (cpl_image_get_mean() ignores bad pixels when 
+                    // calculating the mean)
                     mean_data = cpl_image_get_mean(combined_data_on);
                     KMO_TRY_CHECK_ERROR_STATE();
 
@@ -1103,41 +961,36 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     KMO_TRY_CHECK_ERROR_STATE();
 
                     if ((cpl_frameset_count_tags(frameset, FLAT_OFF) > 1) ||
-                        (cpl_frameset_count_tags(frameset, FLAT_ON) > 1))
-                    {
+                        (cpl_frameset_count_tags(frameset, FLAT_ON) > 1)) {
                         KMO_TRY_ASSURE(mean_noise != 0.0,
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "All frames of detector %i are exactly "
-                                       "the same!", i);
-
+                                CPL_ERROR_ILLEGAL_INPUT,
+                                "All frames of detector %i are the same", i);
                         stored_qc_flat_sn[sx] = mean_data / mean_noise;
                     }
 
-                    // normalize data & noise on the whole detector frame (the
-                    // spectral slope on each slitlet has already been normalised in
-                    // kmo_calc_curvature())
+                    /* Normalize data & noise on the whole detector frame */
+                    /* The spectral slope on each slitlet has already been  */
+                    /* normalised in kmo_calc_curvature() */
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_image_divide_scalar(combined_data_on, mean_data));
 
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_image_divide_scalar(combined_noise_on, mean_data));
 
-                    // apply the badpixel mask to the produced frames
-                    KMO_TRY_EXIT_IF_ERROR(
-                        cpl_image_multiply(combined_data_on, bad_pix_mask_flat));
+                    /* Apply the badpixel mask to the produced frames */
+                    KMO_TRY_EXIT_IF_ERROR(cpl_image_multiply(combined_data_on, 
+                                bad_pix_mask_flat));
 
-                    KMO_TRY_EXIT_IF_ERROR(
-                        cpl_image_multiply(combined_noise_on, bad_pix_mask_flat));
+                    KMO_TRY_EXIT_IF_ERROR(cpl_image_multiply(combined_noise_on,
+                                bad_pix_mask_flat));
 
-                    KMO_TRY_EXIT_IF_ERROR(
-                        cpl_image_multiply(xcal, bad_pix_mask_flat));
+                    KMO_TRY_EXIT_IF_ERROR(cpl_image_multiply(xcal, 
+                                bad_pix_mask_flat));
 
-                    KMO_TRY_EXIT_IF_ERROR(
-                        cpl_image_multiply(ycal, bad_pix_mask_flat));
+                    KMO_TRY_EXIT_IF_ERROR(cpl_image_multiply(ycal, 
+                                bad_pix_mask_flat));
 
-                    //
-                    // ------ store temporarily flat, badpixel and calibration -----
-                    //
+                    /* Store temporarily flat, badpixel and calibration */
                     stored_flat[sx] = combined_data_on;
                     stored_noise[sx] = combined_noise_on;
                     stored_badpix[sx] = bad_pix_mask_flat;
@@ -1148,12 +1001,15 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     // just save empty frames
                     cpl_error_reset();
 
-                    cpl_image_delete(combined_data_on); combined_data_on = NULL;
-                    cpl_image_delete(combined_noise_on); combined_noise_on = NULL;
-                    cpl_image_delete(bad_pix_mask_flat); bad_pix_mask_flat = NULL;
+                    cpl_image_delete(combined_data_on); 
+                    combined_data_on = NULL;
+                    cpl_image_delete(combined_noise_on); 
+                    combined_noise_on = NULL;
+                    cpl_image_delete(bad_pix_mask_flat); 
+                    bad_pix_mask_flat = NULL;
 
                     KMO_TRY_EXIT_IF_NULL(
-                        stored_flat[sx] = cpl_image_new(nx, ny, CPL_TYPE_FLOAT));
+                        stored_flat[sx]=cpl_image_new(nx, ny, CPL_TYPE_FLOAT));
                     for(ix = 1; ix <= nx; ix++) {
                         for(iy = 1; iy <= ny; iy++) {
                             cpl_image_reject(stored_flat[sx], ix, iy);
@@ -1162,29 +1018,28 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     KMO_TRY_CHECK_ERROR_STATE();
 
                     KMO_TRY_EXIT_IF_NULL(
-                        stored_noise[sx]  = cpl_image_duplicate(stored_flat[sx]));
+                        stored_noise[sx]=cpl_image_duplicate(stored_flat[sx]));
                     KMO_TRY_EXIT_IF_NULL(
-                        stored_xcal[sx]  = cpl_image_duplicate(stored_flat[sx]));
+                        stored_xcal[sx]=cpl_image_duplicate(stored_flat[sx]));
                     KMO_TRY_EXIT_IF_NULL(
-                        stored_ycal[sx]  = cpl_image_duplicate(stored_flat[sx]));
+                        stored_ycal[sx]=cpl_image_duplicate(stored_flat[sx]));
                     KMO_TRY_EXIT_IF_NULL(
-                        stored_badpix[sx] = cpl_image_new(nx, ny, CPL_TYPE_FLOAT));
+                        stored_badpix[sx]=cpl_image_new(nx, ny,CPL_TYPE_FLOAT));
                 } else {
                     // another error occured
                     KMO_TRY_CHECK_ERROR_STATE();
                 }
 
                 // store immediate results, free memory
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_image_save(stored_flat[sx], fn_flat,
-                                       CPL_TYPE_FLOAT, NULL, save_mode, 0./0.));
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_image_save(stored_noise[sx], fn_noise,
-                                       CPL_TYPE_FLOAT, NULL, save_mode, 0./0.));
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_image_save(stored_badpix[sx], fn_badpix,
-                                       CPL_TYPE_FLOAT, NULL, save_mode, 0./0.));
-                save_mode = CPL_IO_EXTEND; //all other saves will create extensions
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_image_save(stored_flat[sx],
+                            fn_flat, CPL_TYPE_FLOAT, NULL, save_mode, 0./0.));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_image_save(stored_noise[sx],
+                            fn_noise, CPL_TYPE_FLOAT, NULL, save_mode, 0./0.));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_image_save(stored_badpix[sx],
+                            fn_badpix, CPL_TYPE_FLOAT, NULL, save_mode, 0./0.));
+
+                /* All other saves will create extensions */
+                save_mode = CPL_IO_EXTEND;
                 cpl_image_delete(stored_flat[sx]); stored_flat[sx] = NULL;
                 cpl_image_delete(stored_noise[sx]); stored_noise[sx] = NULL;
                 cpl_image_delete(stored_badpix[sx]); stored_badpix[sx] = NULL;
@@ -1199,16 +1054,12 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
         } // for a = 0; a < nr_angles
         KMO_TRY_CHECK_ERROR_STATE();
 
-// #############################################################################
-// ###           QC parameters & saving
-// #############################################################################
-        //
-        // ------------ load, update & save primary header ------------
-        //
-        KMO_TRY_EXIT_IF_NULL(
-            main_header = kmo_dfs_load_primary_header(frameset, FLAT_ON));
+        /* ----- QC parameters & saving */
+        /* ---- load, update & save primary header */
+        KMO_TRY_EXIT_IF_NULL(main_header = kmo_dfs_load_primary_header(
+                    frameset, FLAT_ON));
 
-        // update which IFUs are not used
+        /* Update which IFUs are not used */
         kmo_print_unused_ifus(unused_ifus_after, TRUE);
 
         KMO_TRY_EXIT_IF_ERROR(
@@ -1218,14 +1069,14 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
         // xcal gets additionally the boundaries of the IFUs for reconstruction
 
         // add here boundaries for reconstruction
-        KMO_TRY_EXIT_IF_NULL(
-            main_header_xcal = cpl_propertylist_new());
+        KMO_TRY_EXIT_IF_NULL(main_header_xcal = cpl_propertylist_new());
 
         KMO_TRY_EXIT_IF_NULL(
             total_bounds = (int**)cpl_malloc(nr_devices*sizeof(int*)));
         for (i = 0; i < nr_devices; i++) {
             KMO_TRY_EXIT_IF_NULL(
-                total_bounds[i] = (int*) cpl_calloc(2*KMOS_IFUS_PER_DETECTOR,sizeof(int)));
+                total_bounds[i] = 
+                (int*) cpl_calloc(2*KMOS_IFUS_PER_DETECTOR,sizeof(int)));
             for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
                 total_bounds[i][2*j] = 2048;
                 total_bounds[i][2*j+1] = 0;
@@ -1233,21 +1084,7 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
         }
         KMO_TRY_CHECK_ERROR_STATE();
 
-//        KMO_TRY_EXIT_IF_NULL(
-//            all_bounds = (int***) cpl_malloc(nr_angles*sizeof(int**)));
-//        for (a = 0; a < nr_angles; a++) {
-//            KMO_TRY_EXIT_IF_NULL(
-//                all_bounds[a] = (int**) cpl_malloc(nr_devices*sizeof(int*)));
-//            for (i = 0; i < nr_devices; i++) {
-//                KMO_TRY_EXIT_IF_NULL(
-//                    all_bounds[a][i] = (int*) cpl_calloc(2*KMOS_IFUS_PER_DETECTOR,sizeof(int)));
-//            }
-//        }
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        //
-        // store the min left bound and max right bound for all angles
-        //
+        /* Store the min left bound and max right bound for all angles */
         for (a = 0; a < nr_angles; a++) {
             for (i = 0; i < nr_devices; i++) {
                 sx = a * nr_devices + i;
@@ -1256,11 +1093,7 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         bounds = kmo_split_frame(stored_ycal[sx]));
 
                     for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
-//                        all_bounds[a][i][2*j] = bounds[2*j];
-//                        all_bounds[a][i][2*j+1] = bounds[2*j+1];
-
-
-                        if ((total_bounds[i][2*j] == -1) || (bounds[2*j] == -1)) {
+                        if ((total_bounds[i][2*j] == -1)||(bounds[2*j] == -1)) {
                             total_bounds[i][2*j] = -1;
                         } else {
                             if (total_bounds[i][2*j] > bounds[2*j]) {
@@ -1268,38 +1101,18 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                             }
                         }
 
-                        if ((total_bounds[i][2*j+1] == -1) || (bounds[2*j+1] == -1)) {
+                        if ((total_bounds[i][2*j+1] == -1) || 
+                                (bounds[2*j+1] == -1)) {
                             total_bounds[i][2*j+1] = -1;
                         } else {
                             if (total_bounds[i][2*j+1] < bounds[2*j+1]) {
                                 total_bounds[i][2*j+1] = bounds[2*j+1];
                             }
                         }
-
-//                        if (total_bounds[i][2*j] >= 0 ) {
-//                            if (bounds[2*j] < 0) {
-//                                total_bounds[i][2*j] = bounds[2*j];
-//                            } else {
-//                                if (total_bounds[i][2*j] > bounds[2*j]) {
-//                                    total_bounds[i][2*j] = bounds[2*j];
-//                                }
-//                            }
-//                        }
-//                        if (total_bounds[i][2*j+1] >= 0 ) {
-//                            if (bounds[2*j+1] < 0) {
-//                                total_bounds[i][2*j+1] = bounds[2*j+1];
-//                            } else {
-//                                if (total_bounds[i][2*j+1] < bounds[2*j+1]) {
-//                                    total_bounds[i][2*j+1] = bounds[2*j+1];
-//                                }
-//                            }
-//                        }
                     }
                 } else {
                     // whole detector inactive
                     for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
-//                        all_bounds[a][i][2*j] = -1;
-//                        all_bounds[a][i][2*j+1] = -1;
                         total_bounds[i][2*j] = -1;
                         total_bounds[i][2*j+1] = -1;
                     }
@@ -1310,253 +1123,157 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
             } // for (nr_devices)
         } // for (nr_angles)
 
-        //
-        // write the min left bound and max right bound for all angles
-        // into the main header
-        //
+        /* Write the min left bound and max right bound for all angles */
+        /* into the main header */
         for (i = 0; i < nr_devices; i++) {
             for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
                 if (total_bounds[i][2*j] > -1) {
-                    KMO_TRY_EXIT_IF_NULL(
-                            tmpstr= cpl_sprintf("%s%d%s",
-                                    BOUNDS_PREFIX,
-                                    i*KMOS_IFUS_PER_DETECTOR + j+1,
-                                    "_L"));
-                    KMO_TRY_EXIT_IF_ERROR(
-                            kmclipm_update_property_int(main_header_xcal,
-                                    tmpstr, total_bounds[i][2*j],
-                                    "[pix] left boundary for reconstr."));
+                    KMO_TRY_EXIT_IF_NULL(tmpstr= cpl_sprintf("%s%d%s",
+                        BOUNDS_PREFIX, i*KMOS_IFUS_PER_DETECTOR + j+1, "_L"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                                main_header_xcal, tmpstr, total_bounds[i][2*j],
+                                "[pix] left boundary for reconstr."));
                     cpl_free(tmpstr); tmpstr = NULL;
                 }
 
                 if (total_bounds[i][2*j+1] > -1) {
-                    KMO_TRY_EXIT_IF_NULL(
-                            tmpstr= cpl_sprintf("%s%d%s",
-                                    BOUNDS_PREFIX,
-                                    i*KMOS_IFUS_PER_DETECTOR + j+1,
-                                    "_R"));
-                    KMO_TRY_EXIT_IF_ERROR(
-                            kmclipm_update_property_int(main_header_xcal,
-                                    tmpstr, total_bounds[i][2*j+1],
-                                    "[pix] right boundary for reconstr."));
+                    KMO_TRY_EXIT_IF_NULL(tmpstr= cpl_sprintf("%s%d%s",
+                        BOUNDS_PREFIX, i*KMOS_IFUS_PER_DETECTOR + j+1, "_R"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                                main_header_xcal,tmpstr, total_bounds[i][2*j+1],
+                                "[pix] right boundary for reconstr."));
                     cpl_free(tmpstr); tmpstr = NULL;
                 }
             }
         } // for (nr_devices)
         KMO_TRY_CHECK_ERROR_STATE();
 
-        //
-        // ------------ saving headers ------------
-        //
+        /* --------- saving headers  */
         if (!suppress_extension) {
-            KMO_TRY_EXIT_IF_NULL(
-                fn_suffix = cpl_sprintf("%s", suffix));
+            KMO_TRY_EXIT_IF_NULL(fn_suffix = cpl_sprintf("%s", suffix));
         } else {
-            KMO_TRY_EXIT_IF_NULL(
-                fn_suffix = cpl_sprintf("%s", ""));
+            KMO_TRY_EXIT_IF_NULL(fn_suffix = cpl_sprintf("%s", ""));
         }
 
-        cpl_msg_info("","Saving data...");
+        cpl_msg_info(__func__, "Saving data...");
 
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, FLAT_ON));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, FLAT_ON));
 
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, filename_flat, fn_suffix, frame,
-                                     main_header, parlist, cpl_func));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, filename_xcal, fn_suffix, frame,
-                                     main_header_xcal, parlist, cpl_func));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, filename_ycal, fn_suffix, frame,
-                                     main_header, parlist, cpl_func));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, filename_bad, fn_suffix, frame,
-                                     main_header, parlist, cpl_func));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, filename_edge, fn_suffix, frame,
-                                     main_header, parlist, cpl_func));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, filename_flat,
+                    fn_suffix, frame, main_header, parlist, cpl_func));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, filename_xcal,
+                    fn_suffix, frame, main_header_xcal, parlist, cpl_func));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, filename_ycal,
+                    fn_suffix, frame, main_header, parlist, cpl_func));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, filename_bad,
+                    fn_suffix, frame, main_header, parlist, cpl_func));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, filename_edge,
+                    fn_suffix, frame, main_header, parlist, cpl_func));
 
         cpl_propertylist_delete(main_header); main_header = NULL;
         cpl_propertylist_delete(main_header_xcal); main_header_xcal = NULL;
 
-        //
-        // ------------ saving sub frames ------------
-        //
+        /* -------- saving sub frames  */
         for (a = 0; a < nr_angles; a++) {
             for (i = 1; i <= nr_devices; i++) {
                 sx = a * nr_devices + (i - 1);
 
                 // load stored data again
-                KMO_TRY_EXIT_IF_NULL(
-                        stored_flat[sx] = kmclipm_image_load(fn_flat,
-                                CPL_TYPE_FLOAT, 0, sx));
-                KMO_TRY_EXIT_IF_NULL(
-                        stored_noise[sx] = kmclipm_image_load(fn_noise,
-                                CPL_TYPE_FLOAT, 0, sx));
-                KMO_TRY_EXIT_IF_NULL(
-                        stored_badpix[sx] = kmclipm_image_load(fn_badpix,
-                                CPL_TYPE_FLOAT, 0, sx));
-
-                KMO_TRY_EXIT_IF_NULL(
-                    sub_header = kmo_dfs_load_sub_header(frameset, FLAT_ON, i,
-                                                         FALSE));
-// leave keywords in for proper fitsverify output
-//                cpl_propertylist_erase(sub_header, CRPIX1);
-//                cpl_propertylist_erase(sub_header, CRPIX2);
-
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_double(sub_header,CAL_ROTANGLE,
-                                                   ((double) rotang_found[a]),
-                                                   "[deg] Rotator relative to nasmyth"));
-
-// AA: commented this out: not needed for the moment. Additionally there were only
-//     34 values saved instead of 48?!?
-//     And sometimes the keyword was named IFU-2_L instead of IFU2_L ?!?
-//                // write BOUNDS as well into subheaders
-//                if (i == 1) {
-//                    for (ii = 0; ii < nr_devices; ii++) {
-//                        for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
-//                            if (all_bounds[a][ii][2*j] > -1) {
-//                                KMO_TRY_EXIT_IF_NULL(
-//                                        tmpstr= cpl_sprintf("%s%d%s",
-//                                                BOUNDS_PREFIX,
-//                                                ii*KMOS_IFUS_PER_DETECTOR + j+1,
-//                                                "_L"));
-//                                KMO_TRY_EXIT_IF_ERROR(
-//                                        kmclipm_update_property_int(sub_header,
-//                                                tmpstr, all_bounds[a][ii][2*j],
-//                                                "[pix] left boundary for reconstr."));
-//                                cpl_free(tmpstr); tmpstr = NULL;
-//                            }
-//
-//                            if (all_bounds[a][ii][2*j+1] > -1) {
-//                                KMO_TRY_EXIT_IF_NULL(
-//                                        tmpstr= cpl_sprintf("%s%d%s",
-//                                                BOUNDS_PREFIX,
-//                                                ii-1*KMOS_IFUS_PER_DETECTOR + j+1,
-//                                                "_R"));
-//                                KMO_TRY_EXIT_IF_ERROR(
-//                                        kmclipm_update_property_int(sub_header,
-//                                                tmpstr, all_bounds[a][ii][2*j+1],
-//                                                "[pix] right boundary for reconstr."));
-//                                cpl_free(tmpstr); tmpstr = NULL;
-//                            }
-//                        }
-//                    } // for (nr_devices)
-//                }
+                KMO_TRY_EXIT_IF_NULL(stored_flat[sx] = kmclipm_image_load(
+                            fn_flat, CPL_TYPE_FLOAT, 0, sx));
+                KMO_TRY_EXIT_IF_NULL(stored_noise[sx] = kmclipm_image_load(
+                            fn_noise, CPL_TYPE_FLOAT, 0, sx));
+                KMO_TRY_EXIT_IF_NULL(stored_badpix[sx] = kmclipm_image_load(
+                            fn_badpix, CPL_TYPE_FLOAT, 0, sx));
+
+                KMO_TRY_EXIT_IF_NULL(sub_header = kmo_dfs_load_sub_header(
+                            frameset, FLAT_ON, i, FALSE));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                            sub_header,CAL_ROTANGLE, ((double) rotang_found[a]),
+                            "[deg] Rotator relative to nasmyth"));
 
                 if (spec_found[sx] == CPL_ERROR_NONE) {
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_int(sub_header,
-                                                    QC_FLAT_SAT,
-                                                    stored_qc_flat_sat[sx],
-                                         "[] nr. saturated pixels of master flat"));
-                    // load gain
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                                sub_header, QC_FLAT_SAT, stored_qc_flat_sat[sx],
+                                "[] nr. saturated pixels of master flat"));
+                    /* Load gain */
                     gain = kmo_dfs_get_property_double(sub_header, GAIN);
                     KMO_TRY_CHECK_ERROR_STATE_MSG(
-                                         "GAIN-keyword in fits-header is missing!");
-
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(sub_header,
-                                                       QC_FLAT_EFF,
-                                                       stored_qc_flat_eff[sx]/gain,
-                                            "[e-/s] rel. brightness of flat lamp"));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(sub_header,
-                                                       QC_FLAT_SN,
-                                                       stored_qc_flat_sn[sx],
-                                                       "[] S/N of master flat"));
+                            "GAIN-keyword in fits-header is missing!");
+
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                                sub_header, QC_FLAT_EFF,
+                                stored_qc_flat_eff[sx]/gain,
+                                "[e-/s] rel. brightness of flat lamp"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                                sub_header, QC_FLAT_SN, stored_qc_flat_sn[sx],
+                                "[] S/N of master flat"));
                 }
 
-                // store qc parameters only if any slitlet- and gap-width has been
-                // detected (should be the case when at least one IFU is active)
+                /* Store qc parameters only if any slitlet- and gap-width  */
+                /* has been detected (should be the case when at least */
+                /* one IFU is active) */
                 if (stored_xcal[sx] != NULL) {
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(sub_header,
-                                                       QC_GAP_MEAN,
-                                                       stored_gapmean[sx],
-                                          "[pix] mean gap width between slitlets"));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(sub_header,
-                                                       QC_GAP_SDV,
-                                                       stored_gapsdv[sx],
-                                      "[pix] stdev of gap width between slitlets"));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(sub_header,
-                                                       QC_GAP_MAXDEV,
-                                                       stored_gapmaxdev[sx],
-                                       "[pix] max gap deviation between slitlets"));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(sub_header,
-                                                       QC_SLIT_MEAN,
-                                                       stored_slitmean[sx],
-                                                       "[pix] mean slitlet width"));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(sub_header,
-                                                       QC_SLIT_SDV,
-                                                       stored_slitsdv[sx],
-                                                  "[pix] stdev of slitlet widths"));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(sub_header,
-                                                       QC_SLIT_MAXDEV,
-                                                       stored_slitmaxdev[sx],
-                                              "[pix] max slitlet width deviation"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                                sub_header, QC_GAP_MEAN, stored_gapmean[sx],
+                                "[pix] mean gap width between slitlets"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                                sub_header, QC_GAP_SDV, stored_gapsdv[sx],
+                                "[pix] stdev of gap width between slitlets"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                                sub_header, QC_GAP_MAXDEV, stored_gapmaxdev[sx],
+                                "[pix] max gap deviation between slitlets"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                                sub_header, QC_SLIT_MEAN, stored_slitmean[sx],
+                                "[pix] mean slitlet width"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                                sub_header, QC_SLIT_SDV, stored_slitsdv[sx],
+                                "[pix] stdev of slitlet widths"));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_double(
+                                sub_header, QC_SLIT_MAXDEV, 
+                                stored_slitmaxdev[sx],
+                                "[pix] max slitlet width deviation"));
                 }
 
-                // calculate QC.BADPIX.NCOUNT
+                /* Calculate QC.BADPIX.NCOUNT */
                 nr_bad_pix = cpl_image_count_rejected(stored_badpix[sx]);
                 KMO_TRY_CHECK_ERROR_STATE();
 
-                // remove 4pixel-border as bad pixels
+                /* Remove 4pixel-border as bad pixels */
                 nr_bad_pix -= 2*KMOS_BADPIX_BORDER*(nx-2*KMOS_BADPIX_BORDER) +
-                                  2*KMOS_BADPIX_BORDER*ny;
+                    2*KMOS_BADPIX_BORDER*ny;
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_int(sub_header,
-                                                QC_NR_BAD_PIX,
-                                                nr_bad_pix,
-                                                "[] nr. of bad pixels"));
-                // save flat frame
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = kmo_extname_creator(detector_frame, i, EXT_DATA));
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_string(sub_header, EXTNAME,
-                                                   extname,
-                                                   "FITS extension name"));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(sub_header,
+                            QC_NR_BAD_PIX, nr_bad_pix, "[] nr. of bad pixels"));
+
+                /* Save flat frame */
+                KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(
+                            detector_frame, i, EXT_DATA));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(
+                            sub_header, EXTNAME,extname,"FITS extension name"));
                 cpl_free(extname); extname = NULL;
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_int(sub_header,
-                                                EXTVER,
-                                                sx+1,
-                                                "FITS extension ver"));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                            sub_header, EXTVER, sx+1, "FITS extension ver"));
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_image(stored_flat[sx], filename_flat,
-                                       fn_suffix, sub_header, 0./0.));
+                KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(stored_flat[sx], 
+                            filename_flat, fn_suffix, sub_header, 0./0.));
 
-                // save noise frame only when enough input frames were available
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = kmo_extname_creator(detector_frame, i,
-                                                  EXT_NOISE));
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_string(sub_header, EXTNAME,
-                                                   extname,
-                                                   "FITS extension name"));
+                /* Save noise frame when enough input frames were available */
+                KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(
+                            detector_frame, i, EXT_NOISE));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(
+                            sub_header, EXTNAME,extname,"FITS extension name"));
                 cpl_free(extname); extname = NULL;
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_image(stored_noise[sx], filename_flat,
-                                       fn_suffix, sub_header, 0./0.));
+                KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(stored_noise[sx], 
+                            filename_flat, fn_suffix, sub_header, 0./0.));
 
-                // save bad_pix frame
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = kmo_extname_creator(detector_frame, i, EXT_BADPIX));
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_string(sub_header, EXTNAME,
-                                                   extname,
-                                                   "FITS extension name"));
+                /* Save bad_pix frame */
+                KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(
+                            detector_frame, i, EXT_BADPIX));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(
+                            sub_header, EXTNAME,extname,"FITS extension name"));
                 cpl_free(extname); extname = NULL;
 
                 KMO_TRY_EXIT_IF_ERROR(
@@ -1566,44 +1283,40 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 // save xcal and ycal-frame
                 KMO_TRY_EXIT_IF_NULL(
                     extname = kmo_extname_creator(detector_frame, i, EXT_DATA));
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_string(sub_header, EXTNAME,
-                                                   extname,
-                                                   "FITS extension name"));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(
+                            sub_header, EXTNAME,extname,"FITS extension name"));
                 cpl_free(extname); extname = NULL;
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_image(stored_xcal[sx], filename_xcal,
-                                       fn_suffix, sub_header, 0./0.));
+                KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(stored_xcal[sx],
+                            filename_xcal, fn_suffix, sub_header, 0./0.));
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_image(stored_ycal[sx], filename_ycal,
-                                       fn_suffix, sub_header, 0./0.));
+                KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(stored_ycal[sx], 
+                            filename_ycal, fn_suffix, sub_header, 0./0.));
 
-                // save edge_pars-frame
                 cpl_free(extname); extname = NULL;
 
+                /* Save edge_pars-frame */
                 for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
                     KMO_TRY_EXIT_IF_NULL(
-                        extname = cpl_sprintf("%s_IFU.%d_ANGLE.%d",
-                                              EXT_LIST,
-                                              j+1+(i-1)*KMOS_IFUS_PER_DETECTOR,
-                                              rotang_found[a]));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_string(sub_header, EXTNAME,
-                                                       extname,
-                                                       "FITS extension name"));
+                            extname = cpl_sprintf("%s_IFU.%d_ANGLE.%d", 
+                                EXT_LIST, j+1+(i-1)*KMOS_IFUS_PER_DETECTOR,
+                                rotang_found[a]));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(
+                                sub_header, EXTNAME, extname,
+                                "FITS extension name"));
                     cpl_free(extname); extname = NULL;
 
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_int(sub_header, CAL_IFU_NR,
-                                                       j+1+(i-1)*KMOS_IFUS_PER_DETECTOR,
-                                                       "IFU Number {1..24}"));
-
-                    // save edge-parameters as product
-                    if ((spec_found[sx] != CPL_ERROR_DATA_NOT_FOUND) && (edge_table[sx][j] != NULL))  {
-                        KMO_TRY_EXIT_IF_ERROR(
-                            kmo_dfs_save_table(edge_table[sx][j], filename_edge, fn_suffix, sub_header));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                                sub_header, CAL_IFU_NR,
+                                j+1+(i-1)*KMOS_IFUS_PER_DETECTOR,
+                                "IFU Number {1..24}"));
+
+                    /* Save edge-parameters as product */
+                    if ((spec_found[sx] != CPL_ERROR_DATA_NOT_FOUND) && 
+                            (edge_table[sx][j] != NULL))  {
+                        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_table(
+                                    edge_table[sx][j], filename_edge, 
+                                    fn_suffix, sub_header));
                     } else {
                         cpl_propertylist_erase(sub_header, CRVAL1);
                         cpl_propertylist_erase(sub_header, CRVAL2);
@@ -1617,8 +1330,8 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         cpl_propertylist_erase(sub_header, CTYPE2);
                         KMO_TRY_CHECK_ERROR_STATE();
 
-                        KMO_TRY_EXIT_IF_ERROR(
-                            kmo_dfs_save_table(NULL, filename_edge, fn_suffix, sub_header));
+                        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_table(NULL, 
+                                    filename_edge, fn_suffix, sub_header));
                     }
                 }
 
@@ -1684,15 +1397,8 @@ static int kmo_flat(cpl_parameterlist *parlist, cpl_frameset *frameset)
     cpl_free(stored_ycal); stored_ycal = NULL;
     for (a = 0; a < nr_angles; a++) {
         cpl_frameset_delete(angle_frameset[a]); angle_frameset[a] = NULL;
-//        if ((all_bounds != NULL) && (all_bounds[a] != NULL)) {
-//            for (i = 0; i < nr_devices; i++) {
-//                cpl_free(all_bounds[a][i]); all_bounds[a][i] = NULL;
-//            }
-//            cpl_free(all_bounds[a]); all_bounds[a] = NULL;
-//        }
     }
     cpl_free(angle_frameset); angle_frameset = NULL;
-//    cpl_free(all_bounds); all_bounds = NULL;
     if (edge_table != NULL) {
         for (i = 0; i < KMOS_NR_DETECTORS * nr_angles; i++) {
             if (edge_table[i] != NULL) {
diff --git a/recipes/kmo_illumination.c b/recipes/kmo_illumination.c
index bb6a783..e0140b7 100644
--- a/recipes/kmo_illumination.c
+++ b/recipes/kmo_illumination.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_illumination.c,v 1.65 2013-10-21 13:44:54 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-10-21 13:44:54 $
- * $Revision: 1.65 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -210,7 +202,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "non-uniformity of flatfield.",
                         kmo_illumination_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_illumination_create,
                         kmo_illumination_exec,
@@ -1393,12 +1385,6 @@ static int kmo_illumination(cpl_parameterlist *parlist, cpl_frameset *frameset)
                                                             &rotangle_found, -1, 0, 0));
             }
 
-            char *tmp_band_method = getenv("KMO_BAND_METHOD");
-            int band_method = 0;
-            if (tmp_band_method != NULL) {
-                band_method = atoi(tmp_band_method);
-            }
-
             // ESO INS FILTi ID
             KMO_TRY_EXIT_IF_NULL(
                 keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, det_nr,
@@ -1410,8 +1396,7 @@ static int kmo_illumination(cpl_parameterlist *parlist, cpl_frameset *frameset)
             KMO_TRY_EXIT_IF_NULL(
                 band_table = kmo_dfs_load_table(frameset, WAVE_BAND, 1, 0));
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_setup_grid_band_lcal(&gd, lcal, filter_id, band_method,
-                                             band_table));
+                kmclipm_setup_grid_band_lcal(&gd, filter_id, band_table));
             cpl_table_delete(band_table); band_table = NULL;
 
             cpl_msg_info("","Reconstructing cubes...");
diff --git a/recipes/kmo_illumination_flat.c b/recipes/kmo_illumination_flat.c
index 908990c..77858e2 100644
--- a/recipes/kmo_illumination_flat.c
+++ b/recipes/kmo_illumination_flat.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_illumination_flat.c,v 1.1 2013/10/21 13:44:55 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013/10/21 13:44:55 $
- * $Revision: 1.1 $
- * $Name:  $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -195,7 +187,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Alternative to kmo_illumination based on flatfield frames.",
                         kmo_illumination_flat_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_illumination_flat_create,
                         kmo_illumination_flat_exec,
@@ -915,12 +907,6 @@ static int kmo_illumination_flat(cpl_parameterlist *parlist, cpl_frameset *frame
             //
             print_warning_once_reconstruct = FALSE;
 
-            char *tmp_band_method = getenv("KMO_BAND_METHOD");
-            int band_method = 0;
-            if (tmp_band_method != NULL) {
-                band_method = atoi(tmp_band_method);
-            }
-
             // ESO INS FILTi ID
             KMO_TRY_EXIT_IF_NULL(
                 keyword = cpl_sprintf("%s%d%s", IFU_FILTID_PREFIX, det_nr,
@@ -932,8 +918,7 @@ static int kmo_illumination_flat(cpl_parameterlist *parlist, cpl_frameset *frame
             KMO_TRY_EXIT_IF_NULL(
                 band_table = kmo_dfs_load_table(frameset, WAVE_BAND, 1, 0));
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_setup_grid_band_lcal(&gd, lcal, filter_id, band_method,
-                                             band_table));
+                kmclipm_setup_grid_band_lcal(&gd, filter_id, band_table));
             cpl_table_delete(band_table); band_table = NULL;
 
             cpl_msg_info("","Reconstructing cubes...");
@@ -1257,6 +1242,17 @@ static int kmo_illumination_flat(cpl_parameterlist *parlist, cpl_frameset *frame
                                      main_header, parlist, cpl_func));
 
         for (i = 0; i < nr_devices * KMOS_IFUS_PER_DETECTOR; i++) {
+            cpl_propertylist_erase(stored_sub_headers[i], CRPIX3);
+            cpl_propertylist_erase(stored_sub_headers[i], CRVAL3);
+            cpl_propertylist_erase(stored_sub_headers[i], CDELT3);
+            cpl_propertylist_erase(stored_sub_headers[i], CTYPE3);
+            cpl_propertylist_erase(stored_sub_headers[i], CUNIT3);
+            cpl_propertylist_erase(stored_sub_headers[i], CD1_3);
+            cpl_propertylist_erase(stored_sub_headers[i], CD2_3);
+            cpl_propertylist_erase(stored_sub_headers[i], CD3_3);
+            cpl_propertylist_erase(stored_sub_headers[i], CD3_2);
+            cpl_propertylist_erase(stored_sub_headers[i], CD3_1);
+
             KMO_TRY_EXIT_IF_ERROR(
                 kmo_dfs_save_image(stored_data_images[i], ILLUM_CORR_FLAT, fn_suffix,
                                    stored_sub_headers[i], 0./0.));
diff --git a/recipes/kmo_make_image.c b/recipes/kmo_make_image.c
index 48bbe8d..a7da11d 100644
--- a/recipes/kmo_make_image.c
+++ b/recipes/kmo_make_image.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_make_image.c,v 1.16 2013-06-07 13:37:26 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,17 +17,14 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-06-07 13:37:26 $
- * $Revision: 1.16 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
+/*-----------------------------------------------------------------------------
+ *                              Includes
+ *----------------------------------------------------------------------------*/
+
 #include <string.h>
 
 #include <cpl.h>
@@ -41,11 +37,19 @@
 #include "kmo_priv_functions.h"
 #include "kmo_constants.h"
 
+/*-----------------------------------------------------------------------------
+ *                          Functions prototypes
+ *----------------------------------------------------------------------------*/
+
 static int kmo_make_image_create(cpl_plugin *);
 static int kmo_make_image_exec(cpl_plugin *);
 static int kmo_make_image_destroy(cpl_plugin *);
 static int kmo_make_image(cpl_parameterlist *, cpl_frameset *);
 
+/*-----------------------------------------------------------------------------
+ *                          Static variables
+ *----------------------------------------------------------------------------*/
+
 static char kmo_make_image_description[] =
 "This recipe collapses a cube along the spectral axis using rejection. By \n"
 "default all spectral slices are averaged.\n"
@@ -55,80 +59,71 @@ static char kmo_make_image_description[] =
 "BASIC PARAMETERS:\n"
 "-----------------\n"
 "--range\n"
-"The spectral range can be delimited to one or several sub-ranges like \"1.8,1.9\"\n"
-"or \"1.8,1.9; 2.0,2.11\"\n"
+"The spectral range can be delimited to one or several sub-ranges like \n"
+"\"1.8,1.9\" or \"1.8,1.9; 2.0,2.11\"\n"
 "\n"
 "--cmethod\n"
 "Following methods of frame combination are available:\n"
 "   * 'ksigma' (Default)\n"
-"   An iterative sigma clipping. For each position all pixels in the spectrum\n"
-"   are examined. If they deviate significantly, they will be rejected according\n"
-"   to the conditions:\n"
-"       val > mean + stdev * cpos_rej\n"
-"   and\n"
-"       val < mean - stdev * cneg_rej\n"
-"   where --cpos_rej, --cneg_rej and --citer are the corresponding configuration\n"
-"   parameters. In the first iteration median and percentile level are used.\n"
-"\n"
+"       An iterative sigma clipping. For each position all pixels in the\n"
+"       spectrum are examined. If they deviate significantly, they will be\n"
+"       rejected according to the conditions:\n"
+"           val > mean + stdev * cpos_rej\n"
+"       and\n"
+"           val < mean - stdev * cneg_rej\n"
+"       where --cpos_rej, --cneg_rej and --citer are the wished parameters\n"
+"       In the first iteration median and percentile level are used.\n"
 "   * 'median'\n"
-"   At each pixel position the median is calculated.\n"
-"\n"
+"       At each pixel position the median is calculated.\n"
 "   * 'average'\n"
-"   At each pixel position the average is calculated.\n"
-"\n"
+"       At each pixel position the average is calculated.\n"
 "   * 'sum'\n"
-"   At each pixel position the sum is calculated.\n"
-"\n"
+"       At each pixel position the sum is calculated.\n"
 "   * 'min_max'\n"
-"   The specified number of minimum and maximum pixel values will be rejected.\n"
-"   --cmax and --cmin apply to this method.\n"
+"       The specified number of min and max pixel values will be rejected.\n"
+"       --cmax and --cmin apply to this method.\n"
 "\n"
 "ADVANCED PARAMETERS\n"
 "-------------------\n"
 "--threshold\n"
 "Optionally an OH spectrum can be provided. In this case a threshold can be\n"
-"defined. The wavelengths of values above the threshold level in the OH spectrum\n"
-"are omitted in the input frame. This parameter can be combined with the --range\n"
-"parameter. Negative threshold values are ignored.\n"
-"Own spectra can be converted into the required F1S KMOS FITS format for the OH\n"
-"spectrum using kmo_fits_stack.\n"
+"defined. The wavelengths of values above the threshold level in the OH\n"
+"spectrum are omitted in the input frame. This parameter can be combined with\n"
+"the --range parameter. Negative threshold values are ignored.\n"
+"Own spectra can be converted into the required F1S KMOS FITS format for the\n"
+"OH spectrum using kmo_fits_stack.\n"
 "\n"
 "--cpos_rej\n"
 "--cneg_rej\n"
 "--citer\n"
-"see --cmethod='ksigma'\n"
-"\n"
+"   see --cmethod='ksigma'\n"
 "--cmax\n"
 "--cmin\n"
-"see --cmethod='min_max'\n"
+"   see --cmethod='min_max'\n"
 "\n"
-"-------------------------------------------------------------------------------\n"
+"---------------------------------------------------------------------------\n"
 "  Input files:\n"
-"\n"
-"   DO                    KMOS                                                  \n"
-"   category              Type   Explanation                    Required #Frames\n"
-"   --------              -----  -----------                    -------- -------\n"
-"   <none or any>         F3I    data frame                         Y       1   \n"
-"   <none or any>         F1S    OH line spectrum                   N      0,1  \n"
+"   DO CATG           Type   Explanation                    Required #Frames\n"
+"   -------           -----  -----------                    -------- -------\n"
+"   <none or any>     F3I    data frame                         Y       1   \n"
+"   <none or any>     F1S    OH line spectrum                   N      0,1  \n"
 "\n"
 "  Output files:\n"
-"\n"
-"   DO                    KMOS\n"
-"   category              Type   Explanation\n"
-"   --------              -----  -----------\n"
-"   MAKE_IMAGE            F2I    Collapsed data cubes\n"
-"-------------------------------------------------------------------------------\n"
+"   DO CATG           Type   Explanation\n"
+"   -------           -----  -----------\n"
+"   MAKE_IMAGE        F2I    Collapsed data cubes\n"
+"---------------------------------------------------------------------------\n"
 "\n";
 
+/*----------------------------------------------------------------------------*/
 /**
- * @defgroup kmo_make_image kmo_make_image Collapse a cube to create a spatial
- * image
- *
- * See recipe description for details.
+  @defgroup kmo_make_image     Collapse a cube to create a spatial image
  */
+/*----------------------------------------------------------------------------*/
 
 /**@{*/
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Build the list of available plugins, for this module. 
   @param    list    the plugin list
@@ -137,30 +132,32 @@ static char kmo_make_image_description[] =
   Create the recipe instance and make it available to the application using the 
   interface. This function is exported.
 */
+/*----------------------------------------------------------------------------*/
 int cpl_plugin_get_info(cpl_pluginlist *list)
 {
     cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
     cpl_plugin *plugin = &recipe->interface;
 
     cpl_plugin_init(plugin,
-                        CPL_PLUGIN_API,
-                        KMOS_BINARY_VERSION,
-                        CPL_PLUGIN_TYPE_RECIPE,
-                        "kmo_make_image",
-                        "Collapse a cube to create a spatial image",
-                        kmo_make_image_description,
-                        "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
-                        kmos_get_license(),
-                        kmo_make_image_create,
-                        kmo_make_image_exec,
-                        kmo_make_image_destroy);
+            CPL_PLUGIN_API,
+            KMOS_BINARY_VERSION,
+            CPL_PLUGIN_TYPE_RECIPE,
+            "kmo_make_image",
+            "Collapse a cube to create a spatial image",
+            kmo_make_image_description,
+            "Alex Agudo Berbel",
+            "usd-help at eso.org",
+            kmos_get_license(),
+            kmo_make_image_create,
+            kmo_make_image_exec,
+            kmo_make_image_destroy);
 
     cpl_pluginlist_append(list, plugin);
 
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Setup the recipe options    
   @param    plugin  the plugin
@@ -168,6 +165,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
 
   Defining the command-line/configuration parameters for the recipe.
 */
+/*----------------------------------------------------------------------------*/
 static int kmo_make_image_create(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -184,37 +182,33 @@ static int kmo_make_image_create(cpl_plugin *plugin)
 
     /* Fill the parameters list */
     /* --range */
-    p = cpl_parameter_new_value("kmos.kmo_make_image.range",
-                                CPL_TYPE_STRING,
-                                "The spectral ranges to combine. e.g."
-                                "\"x1_start,x1_end;x2_start,x2_end\" (microns)",
-                                "kmos.kmo_make_image",
-                                "");
+    p = cpl_parameter_new_value("kmos.kmo_make_image.range", CPL_TYPE_STRING,
+            "The spectral ranges to combine. e.g."
+            "\"x1_start,x1_end;x2_start,x2_end\" (microns)",
+            "kmos.kmo_make_image", "");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "range");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --threshold (if < 0, no thresholding at all) */
     p = cpl_parameter_new_value("kmos.kmo_make_image.threshold",
-                                CPL_TYPE_DOUBLE,
-                                "The OH threshold level (%)",
-                                "kmos.kmo_make_image",
-                                0.1);
+            CPL_TYPE_DOUBLE, "The OH threshold level (%)",
+            "kmos.kmo_make_image", 0.1);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "threshold");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
-    return kmo_combine_pars_create(recipe->parameters,
-                                   "kmos.kmo_make_image",
-                                   DEF_REJ_METHOD,
-                                   FALSE);
+    return kmo_combine_pars_create(recipe->parameters, "kmos.kmo_make_image", 
+            DEF_REJ_METHOD, FALSE);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Execute the plugin instance given by the interface
   @param    plugin  the plugin
   @return   0 if everything is ok
 */
+/*----------------------------------------------------------------------------*/
 static int kmo_make_image_exec(cpl_plugin *plugin)
 {
     cpl_recipe  *recipe;
@@ -227,11 +221,13 @@ static int kmo_make_image_exec(cpl_plugin *plugin)
     return kmo_make_image(recipe->parameters, recipe->frames);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Destroy what has been created by the 'create' function
   @param    plugin  the plugin
   @return   0 if everything is ok
 */
+/*----------------------------------------------------------------------------*/
 static int kmo_make_image_destroy(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -245,6 +241,7 @@ static int kmo_make_image_destroy(cpl_plugin *plugin)
     return 0 ;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Interpret the command line options and execute the data processing
   @param    parlist     the parameters list
@@ -252,20 +249,22 @@ static int kmo_make_image_destroy(cpl_plugin *plugin)
   @return   0 if everything is ok
 
   Possible _cpl_error_code_ set in this function:
-
-    @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
-                                     if first operand not 3d or
-                                     if second operand not valid
-    @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands do
-                                     not match
+  @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
+                                   if first operand not 3d or
+                                   if second operand not valid
+  @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands do
+                                   not match
 */
+/*----------------------------------------------------------------------------*/
 static int kmo_make_image(cpl_parameterlist *parlist, cpl_frameset *frameset)
 {
     const char       *cmethod             = NULL;
 
     double           threshold           = 0.0,
+                     spec_crpix          = 0.0,
                      spec_crval          = 0.0,
                      spec_cdelt          = 0.0,
+                     ifu_crpix           = 0.0,
                      ifu_crval           = 0.0,
                      ifu_cdelt           = 0.0,
                      cpos_rej            = 0.0,
@@ -291,8 +290,6 @@ static int kmo_make_image(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      citer               = 0,
                      cmax                = 0,
                      cmin                = 0,
-                     ifu_crpix           = 0,
-                     spec_crpix          = 0,
                      devnr               = 0,
                      index_data          = 0,
                      index_noise         = 0;
@@ -307,153 +304,93 @@ static int kmo_make_image(cpl_parameterlist *parlist, cpl_frameset *frameset)
     cpl_frame        *op1_frame          = NULL,
                      *op2_frame          = NULL;
 
-    char             do_mode1[256],
-                     do_mode2[256];
-
     KMO_TRY
     {
         kmo_init_fits_desc(&desc1);
         kmo_init_fits_desc(&desc2);
 
-        // --- check input ---
-        KMO_TRY_ASSURE((parlist != NULL) &&
-                       (frameset != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        /* --- check input --- */
+        KMO_TRY_ASSURE((parlist != NULL) && (frameset != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided");
 
         KMO_TRY_ASSURE(kmo_dfs_set_groups(frameset, "kmo_make_image") == 1,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Cannot identify RAW and CALIB frames!");
+                CPL_ERROR_ILLEGAL_INPUT,"Cannot identify RAW and CALIB frames");
 
         cpl_msg_info("", "--- Parameter setup for kmo_make_image ----");
-
         threshold = kmo_dfs_get_parameter_double(parlist,
-                                          "kmos.kmo_make_image.threshold");
+                "kmos.kmo_make_image.threshold");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_make_image.threshold"));
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(parlist, 
+                    "kmos.kmo_make_image.threshold"));
 
         ranges_txt = kmo_dfs_get_parameter_string(parlist,
-                                                  "kmos.kmo_make_image.range");
+                "kmos.kmo_make_image.range");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_make_image.range"));
-
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_print_parameter_help(parlist, 
+                    "kmos.kmo_make_image.range"));
         ranges = kmo_identify_ranges(ranges_txt);
         KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_combine_pars_load(parlist,
-                                  "kmos.kmo_make_image",
-                                  &cmethod,
-                                  &cpos_rej,
-                                  &cneg_rej,
-                                  &citer,
-                                  &cmin,
-                                  &cmax,
-                                  FALSE));
+        KMO_TRY_EXIT_IF_ERROR(kmo_combine_pars_load(parlist,
+                    "kmos.kmo_make_image", &cmethod, &cpos_rej, &cneg_rej,
+                    &citer, &cmin, &cmax, FALSE));
         cpl_msg_info("", "-------------------------------------------");
 
         KMO_TRY_ASSURE((cpl_frameset_get_size(frameset) == 1) ||
-                       ((cpl_frameset_get_size(frameset) == 2) &&
-                       (threshold != 0.0)),
-                       CPL_ERROR_NULL_INPUT,
-                       "A cube or a cube and a OH line spectrum "
-                       "must be provided!");
-
-        if (cpl_frameset_get_size(frameset) == 1) {
-            strcpy(do_mode1, "0");
-            strcpy(do_mode2, "");
-        } else {
-            strcpy(do_mode1, "0");
-            strcpy(do_mode2, "1");
-            KMO_TRY_EXIT_IF_NULL(
-                op2_frame = kmo_dfs_get_frame(frameset, do_mode2));
-
+                ((cpl_frameset_get_size(frameset) == 2) && (threshold != 0.0)),
+                CPL_ERROR_NULL_INPUT,
+                "A cube or a cube and a OH line spectrum must be provided");
+
+        /* Get First Frame and its Descriptor */
+        op1_frame=cpl_frameset_get_position(frameset, 0) ;
+        desc1 = kmo_identify_fits_header(cpl_frame_get_filename(op1_frame));
+        KMO_TRY_CHECK_ERROR_STATE_MSG("Wrong File Format");
+        KMO_TRY_ASSURE(desc1.fits_type == f3i_fits, CPL_ERROR_ILLEGAL_INPUT,
+                "First file has wrong data type (expect F3I)");
+
+        /* Get Second Frame and its decriptor */
+        if (cpl_frameset_get_size(frameset) > 1) {
+            op2_frame=cpl_frameset_get_position(frameset, 1) ;
             desc2 = kmo_identify_fits_header(cpl_frame_get_filename(op2_frame));
-            KMO_TRY_CHECK_ERROR_STATE_MSG("Provided fits file doesn't seem "
-                                          "to be in KMOS-format! "
-                                          "(KMOSTYPE must be F1S)!");
-
-            KMO_TRY_ASSURE(desc2.fits_type == f1s_fits,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Second input file hasn't correct data type "
-                           "(KMOSTYPE must be F1S)!");
-        }
-        KMO_TRY_EXIT_IF_NULL(
-            op1_frame = kmo_dfs_get_frame(frameset, do_mode1));
-
-        // load descriptor of first operand
-        desc1 = kmo_identify_fits_header( cpl_frame_get_filename(op1_frame));
-        KMO_TRY_CHECK_ERROR_STATE_MSG("Provided fits file doesn't seem to be "
-                                      "in KMOS-format!");
-
-        KMO_TRY_ASSURE(desc1.fits_type == f3i_fits,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "First input file hasn't correct data type "
-                       "(KMOSTYPE must be F3I)!");
-
-        if (cpl_frameset_get_size(frameset) == 1) {
-            // only cube is provided
-        } else if (cpl_frameset_get_size(frameset) == 2) {
-            // cube and OH line spectrum are provided
-            KMO_TRY_EXIT_IF_NULL(
-                spec_header = kmo_dfs_load_sub_header(frameset, do_mode2, 1, FALSE));
-
+            KMO_TRY_CHECK_ERROR_STATE_MSG("Wrong File Format");
+            KMO_TRY_ASSURE(desc2.fits_type == f1s_fits, CPL_ERROR_ILLEGAL_INPUT,
+                    "Second file has wrong data type (expect F1S)");
+            
+            /* Load OH-lines header */
+            spec_header = kmos_dfs_load_sub_header(op2_frame, 1, FALSE);
+            KMO_TRY_EXIT_IF_NULL(spec_header) ;
             KMO_TRY_ASSURE(cpl_propertylist_get_int(spec_header, NAXIS) == 1,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Second input file has to be a vector!");
-
-            // load header & data of OH-lines
-            switch (cpl_propertylist_get_type(spec_header, CRPIX1)) {
-            case CPL_TYPE_INT:
-                spec_crpix = cpl_propertylist_get_int(spec_header, CRPIX1);
-                break;
-            case CPL_TYPE_DOUBLE:
-                spec_crpix = cpl_propertylist_get_double(spec_header, CRPIX1);
-                break;
-            case CPL_TYPE_FLOAT:
-                spec_crpix = cpl_propertylist_get_float(spec_header, CRPIX1);
-                break;
-            default:
-                KMO_TRY_ASSURE(1 == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "CRPIX1 is of wrong type!");
-            }
-            KMO_TRY_CHECK_ERROR_STATE();
+                    CPL_ERROR_ILLEGAL_INPUT, 
+                    "Second input file must be a vector");
+            spec_crpix = cpl_propertylist_get_double(spec_header, CRPIX1);
+            KMO_TRY_CHECK_ERROR_STATE_MSG("Cannot get CRPIX1");
             spec_crval = cpl_propertylist_get_double(spec_header, CRVAL1);
-            KMO_TRY_CHECK_ERROR_STATE();
+            KMO_TRY_CHECK_ERROR_STATE_MSG("Cannot get CRVAL1");
             spec_cdelt = cpl_propertylist_get_double(spec_header, CDELT1);
-            KMO_TRY_CHECK_ERROR_STATE();
+            KMO_TRY_CHECK_ERROR_STATE_MSG("Cannot get CDELT1");
 
-            kmclipm_vector *tmp_vec = NULL;
-            KMO_TRY_EXIT_IF_NULL(
-                tmp_vec = kmo_dfs_load_vector(frameset, do_mode2, 1, FALSE));
-            KMO_TRY_EXIT_IF_NULL(
-                spec_data_in = kmclipm_vector_create_non_rejected(tmp_vec));
-            kmclipm_vector_delete(tmp_vec); tmp_vec = NULL;
+            /* Load OH lines data */
+            kmclipm_vector * tmp_vec ;
+            tmp_vec = kmos_dfs_load_vector(op2_frame, 1, FALSE) ;
+            spec_data_in = kmclipm_vector_create_non_rejected(tmp_vec);
+            kmclipm_vector_delete(tmp_vec);
+            KMO_TRY_EXIT_IF_NULL(spec_data_in) ;
 
-            // convert threshold from percentage to absolute value
+            /* Convert threshold from percentage to absolute value */
             threshold = threshold * cpl_vector_get_max(spec_data_in);
 
             // create lambda-vector for OH-lines
             KMO_TRY_EXIT_IF_NULL(
                 spec_lambda_in = kmo_create_lambda_vec(
-                                    cpl_vector_get_size(spec_data_in),
-                                    spec_crpix,
-                                    spec_crval,
-                                    spec_cdelt));
-
-        } else {
-            KMO_TRY_EXIT_WITH_ERROR(CPL_ERROR_ILLEGAL_INPUT);
+                    cpl_vector_get_size(spec_data_in), 
+                    (int)spec_crpix, spec_crval, spec_cdelt));
         }
 
-        // --- load, update & save primary header ---
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, MAKE_IMAGE, "", op1_frame,
-                                     NULL, parlist, cpl_func));
+        /* --- load, update & save primary header --- */
+        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, MAKE_IMAGE, 
+                    "", op1_frame, NULL, parlist, cpl_func));
 
-        // --- load data ---
+        /* --- load data --- */
         if (desc1.ex_noise == TRUE) {
             nr_devices = desc1.nr_ext / 2;
         } else {
@@ -461,12 +398,15 @@ static int kmo_make_image(cpl_parameterlist *parlist, cpl_frameset *frameset)
         }
 
         for (i = 1; i <= nr_devices; i++) {
+
+            /* Get the Device Nb */
             if (desc1.ex_noise == FALSE) {
                 devnr = desc1.sub_desc[i - 1].device_nr;
             } else {
                 devnr = desc1.sub_desc[2 * i - 1].device_nr;
             }
 
+            /* Get the Data index */
             if (desc1.ex_badpix == FALSE) {
                 index_data = kmo_identify_index_desc(desc1, devnr, FALSE);
             } else {
@@ -474,27 +414,27 @@ static int kmo_make_image(cpl_parameterlist *parlist, cpl_frameset *frameset)
             }
             KMO_TRY_CHECK_ERROR_STATE();
 
+            /* Get the Noise index */
             if (desc1.ex_noise) {
                 index_noise = kmo_identify_index_desc(desc1, devnr, TRUE);
             }
             KMO_TRY_CHECK_ERROR_STATE();
 
-            KMO_TRY_EXIT_IF_NULL(
-                sub_header_data = kmo_dfs_load_sub_header(frameset, do_mode1,
-                                                          devnr, FALSE));
+            /* Load the Extension Header */
+            sub_header_data = kmos_dfs_load_sub_header(op1_frame, devnr, FALSE);
+            KMO_TRY_EXIT_IF_NULL(sub_header_data) ;
 
-            // check if IFU is valid
+            /* Check if IFU is valid */
             valid_ifu = FALSE;
             if (desc1.sub_desc[index_data-1].valid_data == TRUE) {
                 valid_ifu = TRUE;
             }
 
+            /* Load noise anyway since we have to save it in the output */
             if (desc1.ex_noise) {
-                // load noise anyway since we have to save it in the output
-                KMO_TRY_EXIT_IF_NULL(
-                    sub_header_noise = kmo_dfs_load_sub_header(frameset, do_mode1,
-                                                               devnr, TRUE));
-
+                sub_header_noise = kmos_dfs_load_sub_header(op1_frame, devnr, 
+                        TRUE);
+                KMO_TRY_EXIT_IF_NULL(sub_header_noise) ;
                 if (cpl_propertylist_has(sub_header_noise, CRPIX3))
                     cpl_propertylist_erase(sub_header_noise, CRPIX3);
                 if (cpl_propertylist_has(sub_header_noise, CRVAL3))
@@ -518,43 +458,33 @@ static int kmo_make_image(cpl_parameterlist *parlist, cpl_frameset *frameset)
             }
 
             if (valid_ifu) {
-                // load data
-                KMO_TRY_EXIT_IF_NULL(
-                    data_in = kmo_dfs_load_cube(frameset, do_mode1,
-                                                devnr, FALSE));
-
-                // load noise, if existing
-                if (desc1.ex_noise && desc1.sub_desc[index_noise-1].valid_data) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        noise_in = kmo_dfs_load_cube(frameset, do_mode1, devnr,
-                                                     TRUE));
+                /* Load data */
+                data_in = kmos_dfs_load_cube(op1_frame, devnr, FALSE) ;
+                KMO_TRY_EXIT_IF_NULL(data_in) ;
+
+                /* Load noise, if existing */
+                if (desc1.ex_noise && desc1.sub_desc[index_noise-1].valid_data){
+                    noise_in = kmos_dfs_load_cube(op1_frame, devnr, TRUE) ;
+                    KMO_TRY_EXIT_IF_NULL(noise_in) ;
                 }
 
-                // interpolate oh-lines to fit input data
-                if (spec_data_in != NULL) {
-                    ifu_crpix = cpl_propertylist_get_double(sub_header_data, CRPIX3);
-                    KMO_TRY_CHECK_ERROR_STATE_MSG(
-                        "CRPIX3 keyword in FITS-header is missing!");
-
-                    ifu_crval = cpl_propertylist_get_double(sub_header_data, CRVAL3);
-                    KMO_TRY_CHECK_ERROR_STATE_MSG(
-                        "CRVAL3 keyword in FITS-header is missing!");
-
-
-                    ifu_cdelt = cpl_propertylist_get_double(sub_header_data, CDELT3);
-                    KMO_TRY_CHECK_ERROR_STATE_MSG(
-                        "CDELT3 keyword in FITS-header is missing!");
-
-                    KMO_TRY_EXIT_IF_NULL(
-                        identified_slices = kmo_identify_slices_with_oh(spec_data_in,
-                                                                        spec_lambda_in,
-                                                                        ranges,
-                                                                        threshold,
-                                                                        ifu_crpix,
-                                                                        ifu_crval,
-                                                                        ifu_cdelt,
-                                                                        desc1.naxis3));
+                /* Interpolate oh-lines to fit input data */
+                ifu_crpix = cpl_propertylist_get_double(sub_header_data,CRPIX3);
+                KMO_TRY_CHECK_ERROR_STATE_MSG("CRPIX3 is missing");
+                ifu_crval = cpl_propertylist_get_double(sub_header_data,CRVAL3);
+                KMO_TRY_CHECK_ERROR_STATE_MSG("CRVAL3 is missing");
+                ifu_cdelt = cpl_propertylist_get_double(sub_header_data,CDELT3);
+                KMO_TRY_CHECK_ERROR_STATE_MSG("CDELT3 is missing");
+
+                if (spec_data_in == NULL) {
+                    identified_slices = kmo_identify_slices(ranges, ifu_crpix, 
+                            ifu_crval, ifu_cdelt, desc1.naxis3);
+                } else {
+                    identified_slices = kmo_identify_slices_with_oh(
+                            spec_data_in, spec_lambda_in, ranges, threshold,
+                            ifu_crpix, ifu_crval, ifu_cdelt, desc1.naxis3);
                 }
+                KMO_TRY_EXIT_IF_NULL(identified_slices) ;
 
                 if (cpl_propertylist_has(sub_header_data, CRPIX3))
                     cpl_propertylist_erase(sub_header_data, CRPIX3);
@@ -577,26 +507,21 @@ static int kmo_make_image(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 if (cpl_propertylist_has(sub_header_data, CD3_1))
                     cpl_propertylist_erase(sub_header_data, CD3_1);
 
-                // process & save data
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_make_image(data_in, noise_in,
-                                       &data_out, &noise_out,
-                                       identified_slices,
-                                       cmethod, cpos_rej, cneg_rej, citer,
-                                       cmax, cmin));
+                /* Process & save data */
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_make_image(data_in, noise_in,
+                            &data_out, &noise_out, identified_slices, cmethod,
+                            cpos_rej, cneg_rej, citer, cmax, cmin));
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_image(data_out, MAKE_IMAGE, "",
-                                       sub_header_data, 0./0.));
+                KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(data_out, MAKE_IMAGE,
+                            "", sub_header_data, 0./0.));
 
-                // process & save noise, if existing
+                /* Process & save noise, if existing */
                 if (desc1.ex_noise) {
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_image(noise_out, MAKE_IMAGE, "",
-                                           sub_header_noise, 0./0.));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(noise_out, 
+                                MAKE_IMAGE, "", sub_header_noise, 0./0.));
                 }
 
-                // free memory
+                /* Free memory */
                 cpl_imagelist_delete(data_in); data_in = NULL;
                 cpl_imagelist_delete(noise_in); noise_in = NULL;
                 cpl_image_delete(data_out); data_out = NULL;
@@ -625,12 +550,12 @@ static int kmo_make_image(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     cpl_propertylist_erase(sub_header_data, CD3_1);
 
                 // invalid IFU, just save sub_headers
-                 KMO_TRY_EXIT_IF_ERROR(
-                     kmo_dfs_save_sub_header(MAKE_IMAGE, "", sub_header_data));
+                 KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_sub_header(MAKE_IMAGE, "", 
+                             sub_header_data));
 
                  if (desc1.ex_noise) {
-                     KMO_TRY_EXIT_IF_ERROR(
-                         kmo_dfs_save_sub_header(MAKE_IMAGE, "", sub_header_noise));
+                     KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_sub_header(MAKE_IMAGE, 
+                                 "", sub_header_noise));
                  }
             }
 
diff --git a/recipes/kmo_multi_reconstruct.c b/recipes/kmo_multi_reconstruct.c
index b4b89dc..d9e6ad4 100644
--- a/recipes/kmo_multi_reconstruct.c
+++ b/recipes/kmo_multi_reconstruct.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_multi_reconstruct.c,v 1.55 2013-10-08 14:55:01 erw Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: erw $
- * $Date: 2013-10-08 14:55:01 $
- * $Revision: 1.55 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -290,7 +282,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Reconstruct and combine obj/sky-pairs in one step.",
                         kmo_multi_reconstruct_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_multi_reconstruct_create,
                         kmo_multi_reconstruct_exec,
@@ -900,6 +892,10 @@ static int kmo_multi_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frame
                                            TRUE, FALSE, TRUE));
         }
 
+        if (cpl_frameset_count_tags(frameset, OH_SPEC) > 0) {
+            KMO_TRY_EXIT_IF_ERROR(kmo_check_oh_spec_setup(frameset, XCAL));
+        }   
+
         // check descriptors of all frames
         KMO_TRY_EXIT_IF_NULL(
             xcal_frame = kmo_dfs_get_frame(frameset, XCAL));
@@ -1147,9 +1143,9 @@ static int kmo_multi_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frame
         KMO_TRY_EXIT_IF_NULL(
             filter_id = cpl_sprintf("%s", cpl_propertylist_get_string(tmp_header, filter_keyword)));
         KMO_TRY_EXIT_IF_ERROR(
-            kmclipm_setup_grid_band_lcal(&gd, NULL, filter_id, 0, band_table));
+            kmclipm_setup_grid_band_lcal(&gd, filter_id, band_table));
         KMO_TRY_EXIT_IF_ERROR(
-            kmclipm_setup_grid_band_lcal(&gd_14x14, NULL, filter_id, 0, band_table));
+            kmclipm_setup_grid_band_lcal(&gd_14x14, filter_id, band_table));
         cpl_propertylist_delete(tmp_header); tmp_header = NULL;
         cpl_table_delete(band_table); band_table = NULL;
 
diff --git a/recipes/kmo_noise_map.c b/recipes/kmo_noise_map.c
index 178ba2a..e9c273f 100644
--- a/recipes/kmo_noise_map.c
+++ b/recipes/kmo_noise_map.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_noise_map.c,v 1.8 2013-05-21 12:13:58 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-05-21 12:13:58 $
- * $Revision: 1.8 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -98,7 +90,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Generate a noise map from a raw frame",
                         kmo_noise_map_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_noise_map_create,
                         kmo_noise_map_exec,
diff --git a/recipes/kmo_reconstruct.c b/recipes/kmo_reconstruct.c
index d9ed916..15c11e0 100644
--- a/recipes/kmo_reconstruct.c
+++ b/recipes/kmo_reconstruct.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_reconstruct.c,v 1.61 2013/10/08 14:55:01 erw Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: erw $
- * $Date: 2013/10/08 14:55:01 $
- * $Revision: 1.61 $
- * $Name:  $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -64,9 +56,9 @@ static int kmo_reconstruct(cpl_parameterlist *, cpl_frameset *);
  *----------------------------------------------------------------------------*/
 
 static char kmo_reconstruct_description[] =
-"Data with or without noise is reconstructed into a cube using the calibration\n"
-"frames XCAL, YCAL and LCAL. XCAL and YCAL are generated using recipe kmo_flat,\n"
-"LCAL is generated using recipe kmo_wave_cal.\n"
+"Data with or without noise is reconstructed into a cube using the\n"
+"calibration frames XCAL, YCAL and LCAL. XCAL and YCAL are generated using\n"
+"recipe kmo_flat, LCAL is generated using recipe kmo_wave_cal.\n"
 "The input data can contain noise extensions and will be reconstructed into\n"
 "additional extensions.\n"
 "If an OH spectrum is given in the SOF file the lambda axis will be corrected\n"
@@ -78,10 +70,10 @@ static char kmo_reconstruct_description[] =
 "The interpolation method used for reconstruction.\n"
 "\n"
 "--detectorimage\n"
-"Specify if the resampled image of the input frame should be generated. There-\n"
-"fore all slitlets of all IFUs are aligned one next to the other. This frame\n"
-"serves for quality control. One can immediately see if the reconstruction was\n"
-"successful.\n"
+"Specify if the resampled image of the input frame should be generated.\n"
+"Therefore all slitlets of all IFUs are aligned one next to the other. This\n"
+"frame serves for quality control. One can immediately see if the\n"
+"reconstruction was successful.\n"
 "\n"
 "--file_extension"
 "Set to TRUE if OBS_ID (from input frame header) should be appended to the\n"
@@ -96,8 +88,8 @@ static char kmo_reconstruct_description[] =
 "Defines the range to search for neighbors during reconstruction\n"
 "\n"
 "--b_samples\n"
-"The number of samples in spectral direction for the reconstructed cube. Ideal-\n"
-"ly this number should be greater than 2048, the detector size.\n"
+"The number of samples in spectral direction for the reconstructed cube."
+"Ideally this number should be greater than 2048, the detector size.\n"
 "\n"
 "--b_start\n"
 "--b_end\n"
@@ -113,50 +105,51 @@ static char kmo_reconstruct_description[] =
 "closest rotator angles in the calibration file. Otherwise take the values\n"
 "of the closest rotator angle\n"
 "\n"
-"-------------------------------------------------------------------------------\n"
+"---------------------------------------------------------------------------\n"
 "  Input files:\n"
 "\n"
-"   DO                  KMOS                                                    \n"
-"   category            Type     Explanation                    Required #Frames\n"
-"   --------            -----    -----------                    -------- -------\n"
-"   DARK    or          RAW/F2D  data with                          Y       1   \n"
-"   FLAT_ON or          RAW/F2D  or without noise                               \n"
-"   ARC_ON  or          RAW/F2D                                                 \n"
-"   OBJECT  or          RAW                                                     \n"
-"   STD     or          RAW                                                     \n"
-"   SCIENCE             RAW                                                     \n"
-"   XCAL                F2D      x-direction calib. frame           Y       1   \n"
-"   YCAL                F2D      y-direction calib. frame           Y       1   \n"
-"   LCAL                F2D      Wavelength calib. frame            Y       1   \n"
-"   WAVE_BAND           F2L      Table with start-/end-wavelengths  Y       1   \n"
-"   OH_SPEC             F1S      Vector holding OH lines            N       1   \n"
+"   DO              KMOS                                                    \n"
+"   category        Type     Explanation                    Required #Frames\n"
+"   --------        -----    -----------                    -------- -------\n"
+"   DARK    or      RAW/F2D  data with                          Y       1   \n"
+"   FLAT_ON or      RAW/F2D  or without noise                               \n"
+"   ARC_ON  or      RAW/F2D                                                 \n"
+"   OBJECT  or      RAW                                                     \n"
+"   STD     or      RAW                                                     \n"
+"   SCIENCE         RAW                                                     \n"
+"   XCAL            F2D      x-direction calib. frame           Y       1   \n"
+"   YCAL            F2D      y-direction calib. frame           Y       1   \n"
+"   LCAL            F2D      Wavelength calib. frame            Y       1   \n"
+"   WAVE_BAND       F2L      Table with start-/end-wavelengths  Y       1   \n"
+"   OH_SPEC         F1S      Vector holding OH lines            N       1   \n"
 "\n"
 "  Output files:\n"
 "\n"
-"   DO                    KMOS\n"
-"   category              Type     Explanation\n"
+"   DO                KMOS\n"
+"   category          Type     Explanation\n"
 "   --------              -----    -----------\n"
-"   CUBE_DARK   or        F3I      Reconstructed cube   \n"
-"   CUBE_FLAT   or        RAW/F2D  with or without noise\n"
-"   CUBE_ARC    or                                      \n"
-"   CUBE_OBJECT or                                      \n"
-"   CUBE_STD    or                                      \n"
-"   CUBE_SCIENCE                                        \n"
-"-------------------------------------------------------------------------------\n"
+"   CUBE_DARK   or    F3I      Reconstructed cube   \n"
+"   CUBE_FLAT   or    RAW/F2D  with or without noise\n"
+"   CUBE_ARC    or                                  \n"
+"   CUBE_OBJECT or                                  \n"
+"   CUBE_STD    or                                  \n"
+"   CUBE_SCIENCE                                    \n"
+"---------------------------------------------------------------------------\n"
 "\n";
 
 /*-----------------------------------------------------------------------------
  *                              Functions code
  *----------------------------------------------------------------------------*/
 
+/*----------------------------------------------------------------------------*/
 /**
- * @defgroup kmo_reconstruct kmo_reconstruct Performs the cube reconstruction
- *
- * See recipe description for details.
+ * @defgroup kmo_reconstruct    Performs the cube reconstruction
  */
+/*----------------------------------------------------------------------------*/
 
 /**@{*/
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Build the list of available plugins, for this module. 
   @param    list    the plugin list
@@ -165,6 +158,7 @@ static char kmo_reconstruct_description[] =
   Create the recipe instance and make it available to the application using the 
   interface. This function is exported.
  */
+/*----------------------------------------------------------------------------*/
 int cpl_plugin_get_info(cpl_pluginlist *list)
 {
     cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
@@ -179,7 +173,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "using different interpolation methods.",
                         kmo_reconstruct_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_reconstruct_create,
                         kmo_reconstruct_exec,
@@ -190,6 +184,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Setup the recipe options    
   @param    plugin  the plugin
@@ -197,6 +192,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
 
   Defining the command-line/configuration parameters for the recipe.
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_reconstruct_create(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -213,111 +209,86 @@ static int kmo_reconstruct_create(cpl_plugin *plugin)
 
     /* Fill the parameters list */
     /* --imethod */
-    p = cpl_parameter_new_value("kmos.kmo_reconstruct.imethod",
-                                CPL_TYPE_STRING,
-                                "Method to use for interpolation. "
-                                "[\"NN\" (nearest neighbour), "
-                                "\"lwNN\" (linear weighted nearest neighbor), "
-                                "\"swNN\" (square weighted nearest neighbor), "
-                                "\"MS\" (Modified Shepard's method)"
-                                "\"CS\" (Cubic spline)]",
-                                "kmos.kmo_reconstruct",
-                                "CS");
+    p = cpl_parameter_new_value("kmos.kmo_reconstruct.imethod", CPL_TYPE_STRING,
+            "Method to use for interpolation. [\"NN\" (nearest neighbour), "
+            "\"lwNN\" (linear weighted nearest neighbor), "
+            "\"swNN\" (square weighted nearest neighbor), "
+            "\"MS\" (Modified Shepard's method)"
+            "\"CS\" (Cubic spline)]",
+            "kmos.kmo_reconstruct", "CS");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "imethod");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --neighborhoodRange */
     p = cpl_parameter_new_value("kmos.kmo_reconstruct.neighborhoodRange",
-                                CPL_TYPE_DOUBLE,
-                                "Defines the range to search for neighbors. "
-                                "in pixels",
-                                "kmos.kmo_reconstruct",
-                                1.001);
+            CPL_TYPE_DOUBLE,
+            "Defines the range to search for neighbors. in pixels",
+            "kmos.kmo_reconstruct", 1.001);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "neighborhoodRange");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --flux */
-    p = cpl_parameter_new_value("kmos.kmo_reconstruct.flux",
-                                CPL_TYPE_BOOL,
-                                "TRUE: Apply flux conservation. FALSE: otherwise",
-                                "kmos.kmo_reconstruct",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_reconstruct.flux", CPL_TYPE_BOOL,
+            "TRUE: Apply flux conservation. FALSE: otherwise",
+            "kmos.kmo_reconstruct", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "flux");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --detectorimage */
     p = cpl_parameter_new_value("kmos.kmo_reconstruct.detectorimage",
-                                CPL_TYPE_BOOL,
-                                "TRUE: if resampled detector frame should be "
-                                "created, FALSE: otherwise",
-                                "kmos.kmo_reconstruct",
-                                FALSE);
+            CPL_TYPE_BOOL,
+            "TRUE: if resampled detector frame should be "
+            "created, FALSE: otherwise",
+            "kmos.kmo_reconstruct", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "detimg");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --file_extension */
     p = cpl_parameter_new_value("kmos.kmo_reconstruct.file_extension",
-                                CPL_TYPE_BOOL,
-                                "TRUE: if OBS_ID keyword should be appended to "
-                                "output frames, FALSE: otherwise",
-                                "kmos.kmo_reconstruct",
-                                FALSE);
+            CPL_TYPE_BOOL,
+            "TRUE: if OBS_ID keyword should be appended to "
+            "output frames, FALSE: otherwise",
+            "kmos.kmo_reconstruct", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "file_extension");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --pix_scale */
     p = cpl_parameter_new_value("kmos.kmo_reconstruct.pix_scale",
-                                CPL_TYPE_DOUBLE,
-                                "Change the pixel scale [arcsec]. "
-                                "Default of 0.2\" results into cubes of 14x14pix, "
-                                "a scale of 0.1\" results into cubes of 28x28pix, "
-                                "etc.",
-                                "kmos.kmo_reconstruct",
-                                KMOS_PIX_RESOLUTION);
+            CPL_TYPE_DOUBLE,
+            "Change the pixel scale [arcsec]. "
+            "Default of 0.2\" results into cubes of 14x14pix, "
+            "a scale of 0.1\" results into cubes of 28x28pix, etc.",
+            "kmos.kmo_reconstruct", KMOS_PIX_RESOLUTION);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "pix_scale");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
-    /* --dev_flip */
-    p = cpl_parameter_new_value("kmos.kmo_reconstruct.dev_flip",
-                                CPL_TYPE_BOOL,
-                                "INTENDED FOR PIPELINE DEVELOPERS ONLY: "
-                                "Set this parameter to TRUE if the wavelengths "
-                                "are ascending on the detector from bottom to "
-                                "top (only for old simulation data).",
-                                "kmos.kmo_reconstruct",
-                                FALSE);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dev_flip");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
     /* --xcal_interpolation */
     p = cpl_parameter_new_value("kmos.kmo_reconstruct.xcal_interpolation",
-                                CPL_TYPE_BOOL,
-                                "TRUE: Interpolate xcal between rotator angles. FALSE: otherwise",
-                                "kmos.kmo_reconstruct",
-                                TRUE);
+            CPL_TYPE_BOOL,
+            "TRUE: Interpolate xcal between rotator angles. FALSE: otherwise",
+            "kmos.kmo_reconstruct", TRUE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "xcal_interpolation");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
-    // add parameters for band-definition
-    kmo_band_pars_create(recipe->parameters,
-                         "kmos.kmo_reconstruct");
-
+    /* Add parameters for band-definition */
+    kmo_band_pars_create(recipe->parameters, "kmos.kmo_reconstruct");
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Execute the plugin instance given by the interface
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_reconstruct_exec(cpl_plugin *plugin)
 {
     cpl_recipe  *recipe;
@@ -330,11 +301,13 @@ static int kmo_reconstruct_exec(cpl_plugin *plugin)
     return kmo_reconstruct(recipe->parameters, recipe->frames);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Destroy what has been created by the 'create' function
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_reconstruct_destroy(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -348,6 +321,7 @@ static int kmo_reconstruct_destroy(cpl_plugin *plugin)
     return 0 ;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Interpret the command line options and execute the data processing
   @param    parlist     the parameters list
@@ -362,6 +336,7 @@ static int kmo_reconstruct_destroy(cpl_plugin *plugin)
     @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands
                                      do not match
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
 {
     int                 ret_val                 = 0,
@@ -376,7 +351,6 @@ static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         ifu_nr                  = 0,
                         obs_id                  = 0,
                         file_extension          = FALSE,
-                        dev_flip                = FALSE,
                         xcal_interpolation      = FALSE,
                         detImgCube              = FALSE,
                         l = 0, x = 0, y = 0;
@@ -546,16 +520,6 @@ static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
                        "pix_scale must be between 0.01 and 0.4 (results in cubes "
                        "with 7x7 to 280x280 pixels)!");
 
-        dev_flip = kmo_dfs_get_parameter_bool(parlist,
-                                           "kmos.kmo_reconstruct.dev_flip");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_reconstruct.dev_flip"));
-        KMO_TRY_ASSURE((dev_flip == TRUE) ||
-                       (dev_flip == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "dev_flip must be TRUE or FALSE!");
-
         xcal_interpolation = kmo_dfs_get_parameter_bool(parlist,
                                            "kmos.kmo_reconstruct.xcal_interpolation");
         KMO_TRY_CHECK_ERROR_STATE();
@@ -601,79 +565,16 @@ static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
             kmo_check_frame_setup(frameset, XCAL, LCAL,
                                        TRUE, FALSE, TRUE));
 
-        if (cpl_frameset_count_tags(frameset, DARK) != 1) {
+        if (cpl_frameset_count_tags(frameset, OH_SPEC) > 0) {
+            KMO_TRY_EXIT_IF_ERROR(kmo_check_oh_spec_setup(frameset, XCAL));
+        }
 
+        if (cpl_frameset_count_tags(frameset, DARK) != 1) {
             // check if filters, gratings and rotator offset match
             // (except for DARK frames)
             KMO_TRY_EXIT_IF_ERROR(
                 kmo_check_frame_setup(frameset, XCAL, input_frame_name,
                                            TRUE, FALSE, FALSE));
-/*
-            // check if rotator offset don't differ to much
-            cpl_frame        *f1 = NULL, *f2 = NULL;
-            cpl_propertylist *h1 = NULL, *h2 = NULL;
-            char             *kw = NULL;
-            double           tmp_dbl1 = 0.0, tmp_dbl2 = 0.0;
-
-            KMO_TRY_EXIT_IF_NULL(
-                f1 = kmo_dfs_get_frame(frameset, XCAL));
-
-            KMO_TRY_EXIT_IF_NULL(
-                f2 = kmo_dfs_get_frame(frameset, input_frame_name));
-            h1 = kmclipm_propertylist_load(cpl_frame_get_filename(f1), 0);
-            if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                cpl_msg_error("","File not found: %s!",
-                              cpl_frame_get_filename(f1));
-                KMO_TRY_CHECK_ERROR_STATE();
-            }
-
-            h2 = kmclipm_propertylist_load(cpl_frame_get_filename(f2), 0);
-            if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                cpl_msg_error("","File not found: %s!",
-                              cpl_frame_get_filename(f2));
-                KMO_TRY_CHECK_ERROR_STATE();
-            }
-            KMO_TRY_EXIT_IF_NULL(
-                kw = cpl_sprintf("%s", ROTANGLE));
-            tmp_dbl1 = cpl_propertylist_get_double(h1, kw);
-            if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                KMO_TRY_ASSURE(1 == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, XCAL);
-            }
-
-            tmp_dbl2 = cpl_propertylist_get_double(h2, kw);
-            if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                KMO_TRY_ASSURE(1 == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "keyword \n%s\n of frame %s is missing!",
-                               keyword, input_frame_name);
-            }
-
-            // strip angles below 0 deg and above 360 deg
-            kmclipm_strip_angle(&tmp_dbl1);
-            kmclipm_strip_angle(&tmp_dbl2);
-
-            if (fabs(tmp_dbl1 - tmp_dbl2) > 30.) {
-                if ((fabs(tmp_dbl1) < 0.001) && (tmp_dbl2>330) && (tmp_dbl2<360)) {
-                    // singularity!
-                    // we have rot=0 for XCAL and rot>330 | rot<360 for input frame
-                } else {
-                cpl_msg_warning("","The angle of the calibration files (%g deg) "
-                                "and the angle of the frame to reconstruct"
-                                " (%g deg) differ by %g deg! Think about using "
-                                "calibration files matching better the actual "
-                                "rotator offset (ESO OCS ROT NAANGLE)",
-                                tmp_dbl1, tmp_dbl2,
-                                fabs(tmp_dbl1 - tmp_dbl2));
-                }
-            }
-
-            cpl_propertylist_delete(h1); h1 = NULL;
-            cpl_propertylist_delete(h2); h2 = NULL;
-            cpl_free(kw); kw = NULL;
-*/
         }
 
         KMO_TRY_EXIT_IF_NULL(
@@ -879,18 +780,13 @@ static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 print_cal_angle_msg_once = TRUE;
                 print_xcal_angle_msg_once = TRUE;
             }
-            char *tmp_band_method = getenv("KMO_BAND_METHOD");
-            int band_method = 0;
-            if (tmp_band_method != NULL) {
-                band_method = atoi(tmp_band_method);
-            }
 
             KMO_TRY_EXIT_IF_NULL(
                 band_table = kmo_dfs_load_table(frameset, WAVE_BAND, 1, FALSE));
 
             KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_setup_grid_band_lcal(&gd, lcal, my_filter_id,
-                                             band_method, band_table));
+                kmclipm_setup_grid_band_lcal(&gd, my_filter_id,
+                                             band_table));
             cpl_table_delete(band_table); band_table = NULL;
 
             cpl_image_delete(lcal); lcal = NULL;
@@ -1028,78 +924,6 @@ static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
                                                 flux,
                                                 background,
                                                 xcal_interpolation));
-/*
- // show that lambda correction improved the data cube, a second one would improve even more
-
-                        cpl_bivector *obj_spectrum2, *obj_spectrum3;
-                        cpl_polynomial *lcorr_coeffs2, *lcorr_coeffs3;
-                        KMO_TRY_EXIT_IF_NULL(
-                                obj_spectrum2 = kmo_lcorr_extract_spectrum(
-                                        cube_data, actual_sub_header, 0.8, NULL));
-
-                        KMO_TRY_EXIT_IF_NULL(
-                                lcorr_coeffs2 = kmo_lcorr_crosscorrelate_spectra(
-                                        obj_spectrum2, ref_spectrum, peaks, 0.002));
-
-                        cpl_bivector_delete(obj_spectrum2);
-
-                        coeff_dump[0] = 0;
-                        for (ic=0; ic<=cpl_polynomial_get_degree(lcorr_coeffs2) && ic < max_coeffs; ic++) {
-                            pows[0] = ic;
-                            coeff_string = cpl_sprintf(" %*g,",
-                                    format_width-2, cpl_polynomial_get_coeff(lcorr_coeffs2,pows));
-                            strncat(coeff_dump, coeff_string, format_width);
-                            cpl_free(coeff_string);
-                            double c1 =  cpl_polynomial_get_coeff(lcorr_coeffs,pows);
-                            double c2 =  cpl_polynomial_get_coeff(lcorr_coeffs2,pows);
-                            cpl_polynomial_set_coeff(lcorr_coeffs, pows, c1+c2);
-                        }
-                        cpl_msg_debug("","Lambda correction coeffs for ifu %d %s",ifu_nr, coeff_dump);
-                        cpl_polynomial_delete(lcorr_coeffs2); lcorr_coeffs2=NULL;
-
-                        cpl_imagelist_delete(cube_data); cube_data = NULL;
-                        cpl_imagelist_delete(cube_noise); cube_noise = NULL;
-                        KMO_TRY_EXIT_IF_ERROR(
-                            kmo_reconstruct_sci(ifu_nr,
-                                                bounds[2*(ifu_nr-1)],
-                                                bounds[2*(ifu_nr-1)+1],
-                                                rec_frame,
-                                                input_frame_name,
-                                                NULL,
-                                                NULL,
-                                                NULL,
-                                                xcal_frame,
-                                                ycal_frame,
-                                                lcal_frame,
-                                                lcorr_coeffs,
-                                                &gd,
-                                                &cube_data,
-                                                &cube_noise,
-                                                flux,
-                                                background,
-                                                xcal_interpolation));
-
-                        KMO_TRY_EXIT_IF_NULL(
-                                obj_spectrum3 = kmo_lcorr_extract_spectrum(
-                                        cube_data, actual_sub_header, 0.8, NULL));
-
-                        KMO_TRY_EXIT_IF_NULL(
-                                lcorr_coeffs3 = kmo_lcorr_crosscorrelate_spectra(
-                                        obj_spectrum3, ref_spectrum, peaks, 0.002));
-
-                        cpl_bivector_delete(obj_spectrum3);
-
-                        coeff_dump[0] = 0;
-                        for (ic=0; ic<=cpl_polynomial_get_degree(lcorr_coeffs3) && ic < max_coeffs; ic++) {
-                            pows[0] = ic;
-                            coeff_string = cpl_sprintf(" %*g,",
-                                    format_width-2, cpl_polynomial_get_coeff(lcorr_coeffs3,pows));
-                            strncat(coeff_dump, coeff_string, format_width);
-                            cpl_free(coeff_string);
-                        }
-                        cpl_msg_debug("","Lambda correction coeffs for iFu %d %s",ifu_nr, coeff_dump);
-                        cpl_polynomial_delete(lcorr_coeffs3); lcorr_coeffs3=NULL;
-*/
                         cpl_polynomial_delete(lcorr_coeffs); lcorr_coeffs = NULL;
 
                     }
@@ -1208,7 +1032,7 @@ static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
                                          cpl_frame_get_filename(rec_frame), index));
                 KMO_TRY_EXIT_IF_ERROR(
                     kmo_save_det_img_ext(det_img_data[i-1], gd, i, filename_img,
-                                         obs_suffix, tmp_header, dev_flip, FALSE));
+                                         obs_suffix, tmp_header, FALSE, FALSE));
                 cpl_propertylist_delete(tmp_header); tmp_header = NULL;
 
                 if (detImgCube) {
@@ -1225,7 +1049,8 @@ static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
                                              cpl_frame_get_filename(rec_frame), index));
                     KMO_TRY_EXIT_IF_ERROR(
                         kmo_save_det_img_ext(det_img_noise[i-1], gd, i, filename_img,
-                                             obs_suffix, tmp_header, dev_flip, TRUE));
+                                             obs_suffix, tmp_header,
+                                             FALSE, TRUE));
                     cpl_propertylist_delete(tmp_header); tmp_header = NULL;
                 }
             }
@@ -1260,7 +1085,6 @@ static int kmo_reconstruct(cpl_parameterlist *parlist, cpl_frameset *frameset)
     cpl_free(suffix); suffix = NULL;
     cpl_free(filename_img); filename_img = NULL;
     cpl_free(filename_cube); filename_cube = NULL;
-//    sat_mode_msg = FALSE;
 
     return ret_val;
 }
diff --git a/recipes/kmo_rotate.c b/recipes/kmo_rotate.c
index c5ff192..8d9e37b 100644
--- a/recipes/kmo_rotate.c
+++ b/recipes/kmo_rotate.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_rotate.c,v 1.12 2013-06-07 15:41:21 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-06-07 15:41:21 $
- * $Revision: 1.12 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -128,7 +120,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Rotate a cube spatially",
                         kmo_rotate_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_rotate_create,
                         kmo_rotate_exec,
diff --git a/recipes/kmo_sci_red.c b/recipes/kmo_sci_red.c
index e04ed99..2d9e89c 100644
--- a/recipes/kmo_sci_red.c
+++ b/recipes/kmo_sci_red.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_sci_red.c,v 1.92 2013-10-08 14:55:01 erw Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,20 +17,14 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: erw $
- * $Date: 2013-10-08 14:55:01 $
- * $Revision: 1.92 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
 /*-----------------------------------------------------------------------------
- *                              Includes
+ *                                  Includes
  *----------------------------------------------------------------------------*/
+
 #include <string.h>
 #include <math.h>
 
@@ -55,10 +48,6 @@
 #include "kmo_priv_sky_tweak.h"
 
 /*-----------------------------------------------------------------------------
- *              Types
- *-----------------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------------
  *                          Functions prototypes
  *----------------------------------------------------------------------------*/
 
@@ -72,14 +61,14 @@ static int kmo_sci_red(cpl_parameterlist *, cpl_frameset *);
  *----------------------------------------------------------------------------*/
 
 static char kmo_sci_red_description[] =
-"Ideally at least two data frames have to be provided since we need for each IFU\n"
-"pointing to an object as well a sky frame for the same IFU.\n"
+"Ideally at least two data frames have to be provided since we need for each\n"
+"IFU pointing to an object as well a sky frame for the same IFU.\n"
 "If an OH spectrum is given in the SOF file the lambda axis will be corrected\n"
 "using the OH lines as reference.\n"
 "Every IFU containing an object will be reconstructed and divided by telluric\n"
-"and illumination correction. By default these intermediate cubes are saved to\n"
-"disk. Frames just containing skies won’t produce an output here, so the number\n"
-"of output frames can be smaller than the number of input frames.\n"
+"and illumination correction. By default these intermediate cubes are saved\n"
+"to disk. Frames just containing skies won’t produce an output here, so the\n"
+"number of output frames can be smaller than the number of input frames.\n"
 "Then the reconstructed objects with the same object name are combined. These\n"
 "outputs are also saved to disk, the number of created files depends on the\n"
 "number of reconstructed objects of different name. If the user just wants to\n"
@@ -99,18 +88,18 @@ static char kmo_sci_red_description[] =
 "--name\n"
 "--ifus\n"
 "Since an object can be present only once per exposure and since it can be\n"
-"located in different IFUs for the existing exposures, there are two modes to\n"
-"identify the objects:\n"
+"located in different IFUs for the existing exposures, there are two modes\n"
+"to identify the objects:\n"
 "   * Combine by object names (default)\n"
-"   In this case the object name must be provided via the --name parameter. The\n"
-"   object name will be searched for in all primary headers of all provided\n"
-"   frames in the keyword ESO OCS ARMx NAME.\n"
+"   In this case the object name must be provided via the --name parameter.\n"
+"   The object name will be searched for in all primary headers of all\n"
+"   provided frames in the keyword ESO OCS ARMx NAME.\n"
 "\n"
 "   * Combine by index (advanced)\n"
-"   In this case the --ifus parameter must be provided. The parameter must have\n"
-"   the same number of entries as frames are provided, e.g. \"3;1;24\" for 3\n"
-"   exposures. The index doesn't reference the extension in the frame but the\n"
-"   real index of the IFU as defined in the EXTNAME keyword.\n"
+"   In this case the --ifus parameter must be provided. The parameter must\n"
+"   have the same number of entries as frames are provided, e.g.  \"3;1;24\"\n"
+"   for 3 exposures. The index doesn't reference the extension in the frame\n"
+"   but the real index of the IFU as defined in the EXTNAME keyword.\n"
 "   (e.g. 'IFU.3.DATA')\n"
 "\n"
 "ADVANCED PARAMETERS\n"
@@ -123,8 +112,8 @@ static char kmo_sci_red_description[] =
 "\n"
 "--suppress_extension\n"
 "If set to TRUE, the arbitrary filename extensions are supressed. If multiple\n"
-"products with the same category are produced, they will be numered consecutively\n"
-"starting from 0.\n"
+"products with the same category are produced, they will be numered\n"
+"consecutively starting from 0.\n"
 "\n"
 "--sky_tweak\n"
 "If set to TRUE sky substraction is not done by subtracting the corresponding\n"
@@ -132,7 +121,8 @@ static char kmo_sci_red_description[] =
 "It is not allowed that \"--sky_tweak\" and \"--no_subtract\" both are TRUE.\n"
 "\n"
 "--tbsub\n"
-"If set to TRUE subtract the thermal background from the cube resulting from sky tweaking.\n"
+"If set to TRUE subtract the thermal background from the cube resulting from\n"
+"sky tweaking.\n"
 "Default value is TRUE.\n"
 "\n"
 "--obj_sky_table\n"
@@ -166,7 +156,7 @@ static char kmo_sci_red_description[] =
 "\n"
 "--no_subtract\n"
 "If set to TRUE, the found objects and references won't be sky subtracted. \n"
-"Additionally all IFUs will be reconstructed, even the ones containing skies. \n"
+"Additionally all IFUs will be reconstructed, even the ones containing skies.\n"
 "This option sets the parameter no_combine to TRUE automatically.\n"
 "\n"
 "--xcal_interpolation\n"
@@ -177,26 +167,26 @@ static char kmo_sci_red_description[] =
 "--extrapolate\n"
 "By default no extrapolation is applied. This means that the intermediate\n"
 "reconstructed cubes will shrink at most one pixel, which is ok for templates\n"
-"like KMOS_spec_obs_nodtosky or KMOS_spec_obs_freedither. When the cubes will be\n"
-"arranged as a map, a grid is likely to occur between the IFUs. Therefore extra-\n"
-"polation during the shifting process can be switched on in order to get IFUs of\n"
-"original size. For frames taken with mapping templates, extrapolation is\n"
-"switched on automatically.\n"
+"like KMOS_spec_obs_nodtosky or KMOS_spec_obs_freedither. When the cubes will\n"
+"be arranged as a map, a grid is likely to occur between the IFUs. Therefore\n"
+"extrapolation during the shifting process can be switched on in order to get\n"
+"IFUs of original size. For frames taken with mapping templates,\n"
+"extrapolation is switched on automatically.\n"
 "\n"
 "--velocity_offset\n"
 "Specifies the velocity offset correction in km/s for lambda scale.\n"
 "Default is 0.0 km/s, i.e. no velocity correction.\n"
 "\n"
 "--save_interims\n"
-"If set to TRUE the interim object and sky cubes used for sky tweaking are saved\n"
-"to FITS file in the same format as SCI_RECONSTRUCTED\n"
+"If set to TRUE the interim object and sky cubes used for sky tweaking are\n"
+"saved to FITS file in the same format as SCI_RECONSTRUCTED\n"
  "Default is FALSE.\n"
  "\n"
 "  Advanced combining parameters\n"
 "  ----------------------------------\n"
 "--edge_nan\n"
-"Set borders of two sides of the cubes to NaN before combining them. This minimises\n"
-"unwanted border effects when dithering.\n"
+"Set borders of two sides of the cubes to NaN before combining them. This\n"
+"minimises unwanted border effects when dithering.\n"
 "\n"
 "--no_combine\n"
 "If set to TRUE, the reconstructed cubes will not be combined.\n"
@@ -205,38 +195,40 @@ static char kmo_sci_red_description[] =
 "There are following sources to get the shift parameters from:\n"
 "   * 'header' (default)\n"
 "   The shifts are calculated according to the WCS information stored in the\n"
-"   header of every IFU. The output frame will get larger, except the object is\n"
-"   at the exact same position for all exposures. The size of the exposures can\n"
-"   differ, but the orientation must be the same for all exposures.\n"
+"   header of every IFU. The output frame will get larger, except the object\n"
+"   is at the exact same position for all exposures. The size of the\n"
+"   exposures can differ, but the orientation must be the same for all\n"
+"   exposures.\n"
 "\n"
 "   * 'none'\n"
 "   The cubes are directly recombined, not shifting at all. The ouput frame\n"
 "   will have the same dimensions as the input cubes.\n"
-"   If the size differs a warning will be emitted and the cubes will be aligned\n"
-"   to the lower left corner. If the orientation differs a warning will be\n"
-"   emitted, but the cubes are combined anyway.\n"
+"   If the size differs a warning will be emitted and the cubes will be\n"
+"   aligned to the lower left corner. If the orientation differs a warning\n"
+"   will be emitted, but the cubes are combined anyway.\n"
 "\n"
 "   * 'center'\n"
 "   The shifts are calculated using a centering algorithm. The cube will be\n"
 "   collapsed and a 2D profile will be fitted to it to identify the centre.\n"
-"   With the parameter --fmethod the function to fit can be provided. The size\n"
-"   of the exposures can differ, but the orientation must be the same for all\n"
-"   exposures.\n"
+"   With the parameter --fmethod the function to fit can be provided. The\n"
+"   size of the exposures can differ, but the orientation must be the same\n"
+"   for all exposures.\n"
 "\n"
 "   * 'user'\n"
 "   Read the shifts from a user specified file. The path of the file must be\n"
 "   provided using the --filename parameter. For every exposure (except the\n"
-"   first one) two shift values are expected per line, they have to be separa-\n"
-"   ted with simple spaces. The values indicate pixel shifts and are referenced\n"
-"   to the first frame. The 1st value is the shift in x-direction to the left,\n"
-"   the 2nd the shift in y-direction upwards. The size of the exposures can\n"
-"   differ, but the orientation must be the same for all exposures.\n"
+"   first one) two shift values are expected per line, they have to be\n"
+"   separated with simple spaces. The values indicate pixel shifts and are\n"
+"   referenced to the first frame. The 1st value is the shift in x-direction\n"
+"   to the left, the 2nd the shift in y-direction upwards. The size of the\n"
+"   exposures can differ, but the orientation must be the same for all\n"
+"   exposures.\n"
 "\n"
 "--fmethod\n"
 "see --method='center'\n"
 "The type of function that should be fitted spatially to the collapsed image.\n"
-"This fit is used to create a mask to extract the spectrum of the object. Valid\n"
-"values are 'gauss' and 'moffat'.\n"
+"This fit is used to create a mask to extract the spectrum of the object.\n"
+"Valid values are 'gauss' and 'moffat'.\n"
 "\n"
 "--filename\n"
 "see --method='user'\n"
@@ -245,13 +237,14 @@ static char kmo_sci_red_description[] =
 "Following methods of frame combination are available:\n"
 "   * 'ksigma' (Default)\n"
 "   An iterative sigma clipping. For each position all pixels in the spectrum\n"
-"   are examined. If they deviate significantly, they will be rejected according\n"
-"   to the conditions:\n"
+"   are examined. If they deviate significantly, they will be rejected\n"
+"   according to the conditions:\n"
 "       val > mean + stdev * cpos_rej\n"
 "   and\n"
 "       val < mean - stdev * cneg_rej\n"
-"   where --cpos_rej, --cneg_rej and --citer are the corresponding configuration\n"
-"   parameters. In the first iteration median and percentile level are used.\n"
+"   where --cpos_rej, --cneg_rej and --citer are the corresponding\n"
+"   configuration parameters. In the first iteration median and percentile\n"
+"   level are used.\n"
 "\n"
 "   * 'median'\n"
 "   At each pixel position the median is calculated.\n"
@@ -263,7 +256,8 @@ static char kmo_sci_red_description[] =
 "   At each pixel position the sum is calculated.\n"
 "\n"
 "   * 'min_max'\n"
-"   The specified number of minimum and maximum pixel values will be rejected.\n"
+"   The specified number of minimum and maximum pixel values will be\n"
+"   rejected.\n"
 "   --cmax and --cmin apply to this method.\n"
 "\n"
 "--cpos_rej\n"
@@ -275,51 +269,53 @@ static char kmo_sci_red_description[] =
 "--cmin\n"
 "see --cmethod='min_max'\n"
 "\n"
-"------------------------------------------------------------------------------\n"
+"--------------------------------------------------------------------------\n"
 "  Input files:\n"
 "\n"
-"   DO                    KMOS                                                  \n"
-"   category              Type   Explanation                   Required #Frames\n"
-"   --------              -----  -----------                   -------- -------\n"
-"   SCIENCE               RAW    The science frames                Y      >=1  \n"
-"   XCAL                  F2D    x calibration frame               Y       1   \n"
-"   YCAL                  F2D    y calibration frame               Y       1   \n"
-"   LCAL                  F2D    Wavelength calib. frame           Y       1   \n"
-"   WAVE_BAND             F2L    Table with start-/end-wavelengths Y       1   \n"
-"   MASTER_FLAT           F2D    Master flat                       Y      0,1  \n"
-"   ILLUM_CORR            F2I    Illumination correction           N      0,1  \n"
-"   TELLURIC              F1I    normalised telluric spectrum      N      0,1  \n"
-"   OH_SPEC               F1S    Vector holding OH lines           N      0,1  \n"
+"   DO                KMOS                                                 \n"
+"   category          Type   Explanation                   Required #Frames\n"
+"   --------          -----  -----------                   -------- -------\n"
+"   SCIENCE           RAW    The science frames                Y      >=1  \n"
+"   XCAL              F2D    x calibration frame               Y       1   \n"
+"   YCAL              F2D    y calibration frame               Y       1   \n"
+"   LCAL              F2D    Wavelength calib. frame           Y       1   \n"
+"   WAVE_BAND         F2L    Table with start-/end-wavelengths Y       1   \n"
+"   MASTER_FLAT       F2D    Master flat                       Y      0,1  \n"
+"   ILLUM_CORR        F2I    Illumination correction           N      0,1  \n"
+"   TELLURIC          F1I    normalised telluric spectrum      N      0,1  \n"
+"   OH_SPEC           F1S    Vector holding OH lines           N      0,1  \n"
 "\n"
 "  Output files:\n"
 "\n"
-"   DO                    KMOS\n"
-"   category              Type   Explanation\n"
+"   DO                KMOS\n"
+"   category          Type   Explanation\n"
 "   --------              -----  -----------\n"
-"   SCI_COMBINED          F3I    Combined cubes with noise\n"
-"   SCI_RECONSTRUCTED     F3I    Reconstructed cube with noise\n"
-"   EXP_MASK              F3I    Exposure time mask (not for mapping-templates!)\n"
-"   SCI_INTERIM_OBJECT    F3I    (optional) Intermediate reconstructed object \n"
-"                                cubes used for sky tweaking, no noise \n"
-"                                (set --sky_tweak and --save_interims)\n"
-"   SCI_INTERIM_SKY       F3I    (optional) Intermediate reconstructed sky \n"
-"                                cubes used for sky tweaking, no noise\n"
-"                                (set --sky_tweak and --save_interims)\n"
-"------------------------------------------------------------------------------\n"
+"   SCI_COMBINED      F3I    Combined cubes with noise\n"
+"   SCI_RECONSTRUCTED F3I    Reconstructed cube with noise\n"
+"   EXP_MASK          F3I    Exposure time mask (not for mapping-templates!)\n"
+"   SCI_INTERIM_OBJECT F3I    (optional) Intermediate reconstructed object \n"
+"                            cubes used for sky tweaking, no noise \n"
+"                            (set --sky_tweak and --save_interims)\n"
+"   SCI_INTERIM_SKY   F3I    (optional) Intermediate reconstructed sky \n"
+"                            cubes used for sky tweaking, no noise\n"
+"                            (set --sky_tweak and --save_interims)\n"
+"--------------------------------------------------------------------------\n"
 "\n";
 
 /*-----------------------------------------------------------------------------
  *                              Functions code
  *----------------------------------------------------------------------------*/
 
+/*----------------------------------------------------------------------------*/
 /**
- * @defgroup kmo_sci_red kmo_sci_red Reconstruct and combine data frames dividing illumination and telluric correction
- *
- * See recipe description for details.
+  @defgroup kmo_sci_red Reconstruct and combine data frames dividing 
+                        illumination and telluric correction
  */
+/*----------------------------------------------------------------------------*/
 
 /**@{*/
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Build the list of available plugins, for this module. 
   @param    list    the plugin list
@@ -328,31 +324,33 @@ static char kmo_sci_red_description[] =
   Create the recipe instance and make it available to the application using the 
   interface. This function is exported.
  */
+/*----------------------------------------------------------------------------*/
 int cpl_plugin_get_info(cpl_pluginlist *list)
 {
     cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
     cpl_plugin *plugin = &recipe->interface;
 
     cpl_plugin_init(plugin,
-                        CPL_PLUGIN_API,
-                        KMOS_BINARY_VERSION,
-                        CPL_PLUGIN_TYPE_RECIPE,
-                        "kmo_sci_red",
-                        "Reconstruct obj/sky-pairs individually and combine "
-                        "them afterwards",
-                        kmo_sci_red_description,
-                        "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
-                        kmos_get_license(),
-                        kmo_sci_red_create,
-                        kmo_sci_red_exec,
-                        kmo_sci_red_destroy);
+            CPL_PLUGIN_API,
+            KMOS_BINARY_VERSION,
+            CPL_PLUGIN_TYPE_RECIPE,
+            "kmo_sci_red",
+            "Reconstruct obj/sky-pairs individually and combine "
+            "them afterwards",
+            kmo_sci_red_description,
+            "Alex Agudo Berbel",
+            "usd-help at eso.org",
+            kmos_get_license(),
+            kmo_sci_red_create,
+            kmo_sci_red_exec,
+            kmo_sci_red_destroy);
 
     cpl_pluginlist_append(list, plugin);
 
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Setup the recipe options    
   @param    plugin  the plugin
@@ -360,6 +358,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
 
   Defining the command-line/configuration parameters for the recipe.
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_sci_red_create(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -375,290 +374,233 @@ static int kmo_sci_red_create(cpl_plugin *plugin)
     recipe->parameters = cpl_parameterlist_new();
 
     /* --imethod (interpolation method) */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.imethod",
-                                CPL_TYPE_STRING,
-                                "Method to use for interpolation during reconstruction. "
-                                "[\"NN\" (nearest neighbour), "
-                                "\"lwNN\" (linear weighted nearest neighbor), "
-                                "\"swNN\" (square weighted nearest neighbor), "
-                                "\"MS\" (Modified Shepard's method)"
-                                "\"CS\" (Cubic spline)]",
-                                "kmos.kmo_sci_red",
-                                "CS");
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.imethod", CPL_TYPE_STRING,
+            "Method to use for interpolation during reconstruction. "
+            "[\"NN\" (nearest neighbour), "
+            "\"lwNN\" (linear weighted nearest neighbor), "
+            "\"swNN\" (square weighted nearest neighbor), "
+            "\"MS\" (Modified Shepard's method)"
+            "\"CS\" (Cubic spline)]",
+            "kmos.kmo_sci_red", "CS");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "imethod");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --smethod  (shift interpolation method) */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.smethod",
-                                CPL_TYPE_STRING,
-                                "Method to use for interpolation during shifting. "
-                                "[\"NN\" (nearest neighbour), "
-                                "\"CS\" (Cubic spline)]",
-                                "kmos.kmo_sci_red",
-                                "CS");
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.smethod", CPL_TYPE_STRING,
+            "Method to use for interpolation during shifting. "
+            "[\"NN\" (nearest neighbour), "
+            "\"CS\" (Cubic spline)]",
+            "kmos.kmo_sci_red", "CS");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "smethod");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --method  (shift method) */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.method",
-                                CPL_TYPE_STRING,
-                                "The shifting method:   "
-                                "'none': no shifting, combined directly, "
-                                "'header': shift according to WCS (default), "
-                                "'center': centering algorithm, "
-                                "'user': read shifts from file",
-                                "kmos.kmo_sci_red",
-                                "header");
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.method", CPL_TYPE_STRING,
+            "The shifting method:   "
+            "'none': no shifting, combined directly, "
+            "'header': shift according to WCS (default), "
+            "'center': centering algorithm, "
+            "'user': read shifts from file",
+            "kmos.kmo_sci_red", "header");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "method");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --fmethod */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.fmethod",
-                                CPL_TYPE_STRING,
-                                "The fitting method (applies only when "
-                                "method='center'):   "
-                                "'gauss': fit a gauss function to collapsed "
-                                "image (default), "
-                                "'moffat': fit a moffat function to collapsed"
-                                " image",
-                                "kmos.kmo_sci_red",
-                                "gauss");
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.fmethod", CPL_TYPE_STRING,
+            "The fitting method (applies only when method='center'):   "
+            "'gauss': fit a gauss function to collapsed image (default), "
+            "'moffat': fit a moffat function to collapsed image",
+            "kmos.kmo_sci_red", "gauss");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fmethod");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --name */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.name",
-                                CPL_TYPE_STRING,
-                                "Name of the object to combine.",
-                                "kmos.kmo_sci_red",
-                                "");
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.name", CPL_TYPE_STRING,
+            "Name of the object to combine.", "kmos.kmo_sci_red", "");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --ifus */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.ifus",
-                                CPL_TYPE_STRING,
-                                "The indices of the IFUs to combine. "
-                                "\"ifu1;ifu2;...\"",
-                                "kmos.kmo_sci_red",
-                                "");
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.ifus", CPL_TYPE_STRING,
+            "The indices of the IFUs to combine. \"ifu1;ifu2;...\"", 
+            "kmos.kmo_sci_red", "");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ifus");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --pix_scale */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.pix_scale",
-                                CPL_TYPE_DOUBLE,
-                                "Change the pixel scale [arcsec]. "
-                                "Default of 0.2\" results into cubes of 14x14pix, "
-                                "a scale of 0.1\" results into cubes of 28x28pix, "
-                                "etc.",
-                                "kmos.kmo_sci_red",
-                                KMOS_PIX_RESOLUTION);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.pix_scale", CPL_TYPE_DOUBLE,
+            "Change the pixel scale [arcsec]. "
+            "Default of 0.2\" results into cubes of 14x14pix, "
+            "a scale of 0.1\" results into cubes of 28x28pix, etc.",
+            "kmos.kmo_sci_red", KMOS_PIX_RESOLUTION);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "pix_scale");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --suppress_extension */
     p = cpl_parameter_new_value("kmos.kmo_sci_red.suppress_extension",
-                                CPL_TYPE_BOOL,
-                                "Suppress arbitrary filename extension."
-                                "(TRUE (apply) or FALSE (don't apply)",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+            CPL_TYPE_BOOL,
+            "Suppress arbitrary filename extension."
+            "(TRUE (apply) or FALSE (don't apply)",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "suppress_extension");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --neighborhoodRange */
     p = cpl_parameter_new_value("kmos.kmo_sci_red.neighborhoodRange",
-                                CPL_TYPE_DOUBLE,
-                                "Defines the range to search for neighbors "
-                                "in pixels",
-                                "kmos.kmo_sci_red",
-                                1.001);
+            CPL_TYPE_DOUBLE, 
+            "Defines the range to search for neighbors in pixels",
+            "kmos.kmo_sci_red", 1.001);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "neighborhoodRange");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --filename */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.filename",
-                                CPL_TYPE_STRING,
-                                "The path to the file with the shift vectors."
-                                "(Applies only to method='user')",
-                                "kmos.kmo_sci_red",
-                                "");
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.filename", CPL_TYPE_STRING,
+            "The path to the file with the shift vectors."
+            "(Applies only to method='user')",
+            "kmos.kmo_sci_red", "");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filename");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --flux */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.flux",
-                                CPL_TYPE_BOOL,
-                                "TRUE: Apply flux conservation. FALSE: otherwise",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.flux", CPL_TYPE_BOOL,
+            "TRUE: Apply flux conservation. FALSE: otherwise", 
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "flux");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --background */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.background",
-                                CPL_TYPE_BOOL,
-                                "TRUE: Apply background removal. FALSE: otherwise",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.background", CPL_TYPE_BOOL, 
+            "TRUE: Apply background removal. FALSE: otherwise",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "background");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --fast_mode */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.fast_mode",
-                                CPL_TYPE_BOOL,
-                                "FALSE: cubes are shifted and combined,"
-                                "TRUE: cubes are collapsed and then shifted and combined",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.fast_mode", CPL_TYPE_BOOL,
+            "FALSE: cubes are shifted and combined,"
+            "TRUE: cubes are collapsed and then shifted and combined",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fast_mode");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --extrapolate */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.extrapolate",
-                                CPL_TYPE_BOOL,
-                                "Applies only to 'smethod=CS' when doing sub-"
-                                "pixel shifts: "
-                                "FALSE: shifted IFU will be filled with NaN's "
-                                "at the borders,"
-                                "TRUE: shifted IFU will be extrapolated at "
-                                "the borders",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.extrapolate", CPL_TYPE_BOOL,
+            "Applies only to 'smethod=CS' when doing sub-pixel shifts: "
+            "FALSE: shifted IFU will be filled with NaN's at the borders,"
+            "TRUE: shifted IFU will be extrapolated at the borders",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "extrapolate");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --xcal_interpolation */
     p = cpl_parameter_new_value("kmos.kmo_sci_red.xcal_interpolation",
-                                CPL_TYPE_BOOL,
-                                "TRUE: Interpolate xcal between rotator angles. FALSE: otherwise",
-                                "kmos.kmo_sci_red",
-                                TRUE);
+            CPL_TYPE_BOOL,
+            "TRUE: Interpolate xcal between rotator angles. FALSE: otherwise",
+            "kmos.kmo_sci_red", TRUE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "xcal_interpolation");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --edge_nan */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.edge_nan",
-                                CPL_TYPE_BOOL,
-                                "Set borders of cubes to NaN before combining them."
-                                "(TRUE (apply) or "
-                                "FALSE (don't apply)",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.edge_nan", CPL_TYPE_BOOL,
+            "Set borders of cubes to NaN before combining them."
+            "(TRUE (apply) or FALSE (don't apply)",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "edge_nan");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --no_combine */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.no_combine",
-                                CPL_TYPE_BOOL,
-                                "Don't combine cubes after reconstruction."
-                                "(TRUE (apply) or "
-                                "FALSE (don't apply)",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.no_combine", CPL_TYPE_BOOL,
+            "Don't combine cubes after reconstruction."
+            "(TRUE (apply) or FALSE (don't apply)",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "no_combine");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --no_subtract */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.no_subtract",
-                                CPL_TYPE_BOOL,
-                                "Don't sky subtract object and references."
-                                "(TRUE (apply) or "
-                                "FALSE (don't apply)",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.no_subtract", CPL_TYPE_BOOL,
+            "Don't sky subtract object and references."
+            "(TRUE (apply) or FALSE (don't apply)",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "no_subtract");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --sky_tweak */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.sky_tweak",
-                                CPL_TYPE_BOOL,
-                                "Use modified sky cube for sky subtraction."
-                                "(TRUE (apply) or "
-                                "FALSE (don't apply)",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.sky_tweak", CPL_TYPE_BOOL,
+            "Use modified sky cube for sky subtraction."
+            "(TRUE (apply) or FALSE (don't apply)",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sky_tweak");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --tbsub */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.tbsub",
-                                CPL_TYPE_BOOL,
-                                "Subtract thermal background from input cube."
-                                "(TRUE (apply) or "
-                                "FALSE (don't apply)",
-                                "kmos.kmo_sci_red",
-                                TRUE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.tbsub", CPL_TYPE_BOOL,
+            "Subtract thermal background from input cube."
+            "(TRUE (apply) or FALSE (don't apply)",
+            "kmos.kmo_sci_red", TRUE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "tbsub");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     // add parameters for band-definition
-    kmo_band_pars_create(recipe->parameters,
-                         "kmos.kmo_sci_red");
+    kmo_band_pars_create(recipe->parameters, "kmos.kmo_sci_red");
 
     /* --obj_sky_table */
     p = cpl_parameter_new_value("kmos.kmo_sci_red.obj_sky_table",
-                                CPL_TYPE_STRING,
-                                "The path to the file with the modified obj/sky associations.",
-                                "kmos.kmo_sci_red",
-                                "");
+            CPL_TYPE_STRING,
+            "The path to the file with the modified obj/sky associations.",
+            "kmos.kmo_sci_red", "");
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "obj_sky_table");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --velocity_offset */
     p = cpl_parameter_new_value("kmos.kmo_sci_red.velocity_offset",
-                                CPL_TYPE_DOUBLE,
-                                "Specify velocity offset correction in km/s for lambda scale",
-                                "kmos.kmo_sci_red",
-                                0.0);
+            CPL_TYPE_DOUBLE,
+            "Specify velocity offset correction in km/s for lambda scale",
+            "kmos.kmo_sci_red", 0.0);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "velocity_offset");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     /* --save_interims */
-    p = cpl_parameter_new_value("kmos.kmo_sci_red.save_interims",
-                                CPL_TYPE_BOOL,
-                                "Save interim object and sky cubes. "
-                                "Can only be used together with --sky_tweak",
-                                "kmos.kmo_sci_red",
-                                FALSE);
+    p = cpl_parameter_new_value("kmos.kmo_sci_red.save_interims", CPL_TYPE_BOOL,
+            "Save interim object and sky cubes. "
+            "Can only be used together with --sky_tweak",
+            "kmos.kmo_sci_red", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "save_interims");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
-    return kmo_combine_pars_create(recipe->parameters,
-                                   "kmos.kmo_sci_red",
-                                   DEF_REJ_METHOD,
-                                   FALSE);
+    return kmo_combine_pars_create(recipe->parameters, "kmos.kmo_sci_red",
+            DEF_REJ_METHOD, FALSE);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Execute the plugin instance given by the interface
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_sci_red_exec(cpl_plugin *plugin)
 {
     cpl_recipe  *recipe;
@@ -671,11 +613,13 @@ static int kmo_sci_red_exec(cpl_plugin *plugin)
     return kmo_sci_red(recipe->parameters, recipe->frames);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Destroy what has been created by the 'create' function
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_sci_red_destroy(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -689,20 +633,20 @@ static int kmo_sci_red_destroy(cpl_plugin *plugin)
     return 0 ;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Interpret the command line options and execute the data processing
   @param    parlist     the parameters list
   @param    frameset   the frames list
   @return   0 if everything is ok
-
   Possible _cpl_error_code_ set in this function:
-
-    @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
-                                     if first operand not 3d or
-                                     if second operand not valid
-    @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands
-                                     do not match
+  @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
+                                   if first operand not 3d or
+                                   if second operand not valid
+  @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands
+                                   do not match
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
 {
     int                     ret_val                     = 0,
@@ -711,6 +655,7 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                             has_illum_corr              = 0,
                             has_master_flat             = 0,
                             has_telluric                = 0,
+                            has_oh_spec                 = 0,
                             telluric_ok                 = 0,
                             *bounds                     = NULL,
                             det_nr                      = 0,
@@ -826,182 +771,146 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
         kmo_init_fits_desc(&desc2);
         kmo_init_fits_desc(&desc_telluric);
 
-        //
-        // check frameset
-        //
-        KMO_TRY_ASSURE((parlist != NULL) &&
-                       (frameset != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        /* Check frameset */
+        KMO_TRY_ASSURE((parlist != NULL) && (frameset != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         nr_science_frames = cpl_frameset_count_tags(frameset, SCIENCE);
-        KMO_TRY_ASSURE(nr_science_frames >= 1,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "At least one SCIENCE frame is required!");
+        KMO_TRY_ASSURE(nr_science_frames >= 1, CPL_ERROR_ILLEGAL_INPUT,
+                "At least one SCIENCE frame is required!");
         if (nr_science_frames == 1) {
-            cpl_msg_warning("", "At least two SCIENCE frames should be provided "
-                                "in order to apply sky subtraction!");
-            cpl_msg_warning("", "All IFUs will be reconstructed regardless if "
-                                "they contain object, reference or sky!");
+            cpl_msg_warning(__func__, 
+                    "2 SCIENCE frames are needed for sky subtraction");
+            cpl_msg_warning(__func__, 
+                    "All IFUs are reconstructed (object, reference and sky");
         }
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, XCAL) == 1,
                        CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one XCAL frame is required!");
+                       "Exactly one XCAL frame is required");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, YCAL) == 1,
                        CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one YCAL frame is required!");
+                       "Exactly one YCAL frame is required");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, LCAL) == 1,
                        CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one LCAL frame is required!");
+                       "Exactly one LCAL frame is required");
 
         has_master_flat = cpl_frameset_count_tags(frameset, MASTER_FLAT);
         KMO_TRY_ASSURE((has_master_flat == 0) || (has_master_flat == 1),
                        CPL_ERROR_FILE_NOT_FOUND,
-                       "At most one MASTER_FLAT frame can be provided!");
+                       "At most one MASTER_FLAT frame can be provided");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, WAVE_BAND) == 1,
                        CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one WAVE_BAND frame is required!");
+                       "Exactly one WAVE_BAND frame is required");
 
         has_illum_corr = cpl_frameset_count_tags(frameset, ILLUM_CORR);
         KMO_TRY_ASSURE((has_illum_corr == 0) || (has_illum_corr == 1),
                        CPL_ERROR_FILE_NOT_FOUND,
-                       "At most one ILLUM_CORR frame can be provided!");
+                       "At most one ILLUM_CORR frame can be provided");
 
         has_telluric = cpl_frameset_count_tags(frameset, TELLURIC);
         KMO_TRY_ASSURE((has_telluric == 0) || (has_telluric == 1),
                        CPL_ERROR_FILE_NOT_FOUND,
-                       "At most one TELLURIC frame can be provided!");
+                       "At most one TELLURIC frame can be provided");
+
+        has_oh_spec = cpl_frameset_count_tags(frameset, OH_SPEC) ;
+        KMO_TRY_ASSURE(has_oh_spec == 0 || has_oh_spec == 1,
+                       CPL_ERROR_ILLEGAL_INPUT,
+                       "Only a single reference spectrum can be provided!");
 
         KMO_TRY_ASSURE(kmo_dfs_set_groups(frameset, "kmo_sci_red") == 1,
                        CPL_ERROR_ILLEGAL_INPUT,
                        "Cannot identify RAW and CALIB frames!");
 
-        KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, OH_SPEC) == 0 ||
-                       cpl_frameset_count_tags(frameset, OH_SPEC) == 1,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Only a single reference spectrum can be provided!");
-        //
-        // get parameters
-        //
+        /* Get parameters */
         cpl_msg_info("", "--- Parameter setup for kmo_sci_red ------");
-
         flux = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.flux");
-
-        KMO_TRY_ASSURE((flux == 0) ||
-                       (flux == 1),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "flux must be either FALSE or TRUE! %d", flux);
-
+        KMO_TRY_ASSURE((flux == 0) || (flux == 1), CPL_ERROR_ILLEGAL_INPUT,
+                "flux must be either FALSE or TRUE! %d", flux);
         KMO_TRY_EXIT_IF_ERROR(
             kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.flux"));
-
-        background = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.background");
-
-        KMO_TRY_ASSURE((background == 0) ||
-                       (background == 1),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "background must be either FALSE or TRUE! %d", background);
-
+        background = kmo_dfs_get_parameter_bool(parlist, 
+                "kmos.kmo_sci_red.background");
+        KMO_TRY_ASSURE((background == 0) || (background == 1),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "background must be either FALSE or TRUE! %d", background);
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.background"));
-
+            kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_sci_red.background"));
         KMO_TRY_EXIT_IF_NULL(
-            imethod = kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.imethod"));
-
+            imethod = kmo_dfs_get_parameter_string(parlist, 
+                "kmos.kmo_sci_red.imethod"));
         KMO_TRY_ASSURE((strcmp(imethod, "NN") == 0) ||
-                       (strcmp(imethod, "lwNN") == 0) ||
-                       (strcmp(imethod, "swNN") == 0) ||
-                       (strcmp(imethod, "MS") == 0) ||
-                       (strcmp(imethod, "CS") == 0),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "imethod must be either \"NN\", \"lwNN\", "
-                       "\"swNN\", \"MS\" or \"CS\"!");
-
+                (strcmp(imethod, "lwNN") == 0) ||
+                (strcmp(imethod, "swNN") == 0) ||
+                (strcmp(imethod, "MS") == 0) ||
+                (strcmp(imethod, "CS") == 0),
+                CPL_ERROR_ILLEGAL_INPUT,
+        "imethod must be either \"NN\", \"lwNN\", \"swNN\", \"MS\" or \"CS\"!");
         KMO_TRY_EXIT_IF_ERROR(
             kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.imethod"));
-
         KMO_TRY_EXIT_IF_NULL(
-            smethod = kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.smethod"));
-
+            smethod = kmo_dfs_get_parameter_string(parlist, 
+                "kmos.kmo_sci_red.smethod"));
         KMO_TRY_ASSURE((strcmp(smethod, "NN") == 0) ||
-                       (strcmp(smethod, "CS") == 0),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "smethod must be either \"NN\" or \"CS\"!");
-
+                (strcmp(smethod, "CS") == 0), CPL_ERROR_ILLEGAL_INPUT,
+                "smethod must be either \"NN\" or \"CS\"!");
         KMO_TRY_EXIT_IF_ERROR(
             kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.smethod"));
-
-        neighborhoodRange = kmo_dfs_get_parameter_double(parlist, "kmos.kmo_sci_red.neighborhoodRange");
+        neighborhoodRange = kmo_dfs_get_parameter_double(parlist, 
+                "kmos.kmo_sci_red.neighborhoodRange");
         KMO_TRY_CHECK_ERROR_STATE();
-
-        KMO_TRY_ASSURE(neighborhoodRange > 0.0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "neighborhoodRange must be greater than 0.0");
-
+        KMO_TRY_ASSURE(neighborhoodRange > 0.0, CPL_ERROR_ILLEGAL_INPUT,
+                "neighborhoodRange must be greater than 0.0");
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.neighborhoodRange"));
-
+            kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_sci_red.neighborhoodRange"));
         KMO_TRY_EXIT_IF_NULL(
-            comb_method = kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.method"));
-
+            comb_method = kmo_dfs_get_parameter_string(parlist, 
+                "kmos.kmo_sci_red.method"));
         KMO_TRY_EXIT_IF_NULL(
-            fmethod = kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.fmethod"));
-
+            fmethod = kmo_dfs_get_parameter_string(parlist, 
+                "kmos.kmo_sci_red.fmethod"));
         KMO_TRY_ASSURE((strcmp(comb_method, "none") == 0) ||
-                       (strcmp(comb_method, "header") == 0) ||
-                       (strcmp(comb_method, "center") == 0) ||
-                       (strcmp(comb_method, "user") == 0),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Following shift methods are available : 'none', "
-                       "'header', 'center' or 'user'");
-
+                (strcmp(comb_method, "header") == 0) ||
+                (strcmp(comb_method, "center") == 0) ||
+                (strcmp(comb_method, "user") == 0), CPL_ERROR_ILLEGAL_INPUT,
+"Following shift methods are available : 'none', 'header', 'center' or 'user'");
         if (strcmp(comb_method, "user") == 0) {
-            filename = kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.filename");
+            filename = kmo_dfs_get_parameter_string(parlist, 
+                    "kmos.kmo_sci_red.filename");
             KMO_TRY_CHECK_ERROR_STATE();
-
-            KMO_TRY_ASSURE(strcmp(filename, "") != 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "path of file with shift information must be "
-                           "provided!");
-
+            KMO_TRY_ASSURE(strcmp(filename, "") != 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "path of file with shift information must be provided!");
             KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.filename"));
+                kmo_dfs_print_parameter_help(parlist, 
+                    "kmos.kmo_sci_red.filename"));
         }
-
         KMO_TRY_EXIT_IF_ERROR(
             kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.method"));
 
-        ifus_txt = kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.ifus");
+        ifus_txt=kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.ifus");
         KMO_TRY_CHECK_ERROR_STATE();
-
         name = kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.name");
         KMO_TRY_CHECK_ERROR_STATE();
-
         if (strcmp(ifus_txt, "") != 0) {
-            KMO_TRY_ASSURE(strcmp(name, "") == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "name parameter must be NULL if IFU indices are "
-                           "provided!");
-
-            KMO_TRY_EXIT_IF_NULL(
-                ifus = kmo_identify_values(ifus_txt));
-
+            KMO_TRY_ASSURE(strcmp(name, "") == 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "name parameter must be NULL if IFU indices are provided!");
+            KMO_TRY_EXIT_IF_NULL(ifus = kmo_identify_values(ifus_txt));
             KMO_TRY_ASSURE(cpl_vector_get_size(ifus) == nr_science_frames,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "ifus parameter must have the same number of values "
-                           "than frames provided (for frames just containing "
-                           "skies insert 0)) (%lld!=%d)",
-                           cpl_vector_get_size(ifus), nr_science_frames);
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "ifus parameter must have the same number of values than"
+                    "frames provided (for frames just containing "
+                    "skies insert 0)) (%lld!=%d)",
+                    cpl_vector_get_size(ifus), nr_science_frames);
         }
 
         if (strcmp(name, "") != 0) {
-            KMO_TRY_ASSURE(strcmp(ifus_txt, "") == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "ifus parameter must be NULL if name is provided!");
+            KMO_TRY_ASSURE(strcmp(ifus_txt, "") == 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "ifus parameter must be NULL if name is provided!");
         }
 
         KMO_TRY_EXIT_IF_ERROR(
@@ -1012,12 +921,14 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
 
         kmo_band_pars_load(parlist, "kmos.kmo_sci_red");
 
-        extrapolate = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.extrapolate");
+        extrapolate = kmo_dfs_get_parameter_bool(parlist, 
+                "kmos.kmo_sci_red.extrapolate");
         KMO_TRY_CHECK_ERROR_STATE();
 
         if (strcmp(smethod, "NN") == 0) {
             if (extrapolate == TRUE) {
-                cpl_msg_warning("", "extrapolation for smethod='NN' not available!");
+                cpl_msg_warning(__func__, 
+                        "extrapolation for smethod='NN' not available!");
             }
             extrapol_enum = NONE_NANS;
         } else if (strcmp(smethod, "CS") == 0) {
@@ -1026,151 +937,127 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
             } else if (extrapolate == TRUE) {
                 extrapol_enum = BCS_NATURAL;
             } else {
-                KMO_TRY_ASSURE(1 == 0,
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "extrapolate must be either FALSE or TRUE!");
+                KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                        "extrapolate must be either FALSE or TRUE");
             }
             smethod = "BCS";
         } else {
-            KMO_TRY_ASSURE(1 == 0,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "method must be either \"CS\" or \"NN\" !");
+            KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                    "smethod must be either \"CS\" or \"NN\"");
         }
         KMO_TRY_CHECK_ERROR_STATE();
 
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.extrapolate"));
+            kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_sci_red.extrapolate"));
 
-        fast_mode = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.fast_mode");
+        fast_mode = kmo_dfs_get_parameter_bool(parlist, 
+                "kmos.kmo_sci_red.fast_mode");
         KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_ASSURE((fast_mode == TRUE) ||
-                       (fast_mode == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "fast_mode must be either FALSE or TRUE!");
+        KMO_TRY_ASSURE((fast_mode == TRUE) || (fast_mode == FALSE),
+                CPL_ERROR_ILLEGAL_INPUT, "fast_mode is either FALSE or TRUE");
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.fast_mode"));
-
-        edge_nan = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.edge_nan");
+            kmo_dfs_print_parameter_help(parlist,"kmos.kmo_sci_red.fast_mode"));
+        edge_nan = kmo_dfs_get_parameter_bool(parlist, 
+                "kmos.kmo_sci_red.edge_nan");
         KMO_TRY_CHECK_ERROR_STATE();
         KMO_TRY_EXIT_IF_ERROR(
             kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.edge_nan"));
-
         KMO_TRY_ASSURE((edge_nan == TRUE) || (edge_nan == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "edge_nan must be TRUE or FALSE!");
-
-        no_combine = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.no_combine");
+                CPL_ERROR_ILLEGAL_INPUT, "edge_nan must be TRUE or FALSE");
+        no_combine = kmo_dfs_get_parameter_bool(parlist, 
+                "kmos.kmo_sci_red.no_combine");
         KMO_TRY_CHECK_ERROR_STATE();
-
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.no_combine"));
-
+            kmo_dfs_print_parameter_help(parlist,
+                "kmos.kmo_sci_red.no_combine"));
         KMO_TRY_ASSURE((no_combine == TRUE) || (no_combine == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "no_combine must be TRUE or FALSE!");
-
-        no_subtract = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.no_subtract");
+                CPL_ERROR_ILLEGAL_INPUT, "no_combine must be TRUE or FALSE!");
+        no_subtract = kmo_dfs_get_parameter_bool(parlist, 
+                "kmos.kmo_sci_red.no_subtract");
         KMO_TRY_CHECK_ERROR_STATE();
-
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.no_subtract"));
-
+            kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_sci_red.no_subtract"));
         KMO_TRY_ASSURE((no_subtract == TRUE) || (no_subtract == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "no_subtract must be TRUE or FALSE!");
-
-        sky_tweak = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.sky_tweak");
+                CPL_ERROR_ILLEGAL_INPUT, "no_subtract must be TRUE or FALSE");
+        sky_tweak = kmo_dfs_get_parameter_bool(parlist, 
+                "kmos.kmo_sci_red.sky_tweak");
         KMO_TRY_CHECK_ERROR_STATE();
-
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.sky_tweak"));
-
+            kmo_dfs_print_parameter_help(parlist,"kmos.kmo_sci_red.sky_tweak"));
         KMO_TRY_ASSURE((sky_tweak == TRUE) || (sky_tweak == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "sky_tweak must be TRUE or FALSE!");
-
+                CPL_ERROR_ILLEGAL_INPUT, "sky_tweak must be TRUE or FALSE");
         KMO_TRY_ASSURE(!((no_subtract == TRUE) && (sky_tweak == TRUE)),
                 CPL_ERROR_ILLEGAL_INPUT,
                 "Either no_subtract or sky_tweak or both must be FALSE (try instead sky_tweak and save_interims)!");
-
         tbsub = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.tbsub");
         KMO_TRY_CHECK_ERROR_STATE();
 
-        pix_scale = kmo_dfs_get_parameter_double(parlist, "kmos.kmo_sci_red.pix_scale");
+        pix_scale = kmo_dfs_get_parameter_double(parlist,
+                "kmos.kmo_sci_red.pix_scale");
         KMO_TRY_CHECK_ERROR_STATE();
         KMO_TRY_EXIT_IF_ERROR(
            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.pix_scale"));
-        KMO_TRY_ASSURE((pix_scale >= 0.01) &&
-                       (pix_scale <= 0.4),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "pix_scale must be between 0.01 and 0.4 (results in cubes "
-                       "with 7x7 to 280x280 pixels)!");
-
-        xcal_interpolation = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.xcal_interpolation");
+        KMO_TRY_ASSURE((pix_scale >= 0.01) && (pix_scale <= 0.4),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "pix_scale must be between 0.01 and 0.4 (results in cubes "
+                "with 7x7 to 280x280 pixels)!");
+        xcal_interpolation = kmo_dfs_get_parameter_bool(parlist,
+                "kmos.kmo_sci_red.xcal_interpolation");
         KMO_TRY_CHECK_ERROR_STATE();
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.xcal_interpolation"));
+            kmo_dfs_print_parameter_help(parlist,
+                "kmos.kmo_sci_red.xcal_interpolation"));
         KMO_TRY_ASSURE((xcal_interpolation == TRUE) ||
-                       (xcal_interpolation == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "xcal_interpolation must be TRUE or FALSE!");
-
+                (xcal_interpolation == FALSE),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "xcal_interpolation must be TRUE or FALSE!");
         suppress_extension = kmo_dfs_get_parameter_bool(parlist,
-                                          "kmos.kmo_sci_red.suppress_extension");
+                "kmos.kmo_sci_red.suppress_extension");
         KMO_TRY_CHECK_ERROR_STATE();
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.suppress_extension"));
-
-        KMO_TRY_ASSURE((suppress_extension == TRUE) || (suppress_extension == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "suppress_extension must be TRUE or FALSE!");
-
-        fn_obj_sky_table = kmo_dfs_get_parameter_string(parlist, "kmos.kmo_sci_red.obj_sky_table");
+            kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_sci_red.suppress_extension"));
+        KMO_TRY_ASSURE((suppress_extension == TRUE) || 
+                (suppress_extension == FALSE),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "suppress_extension must be TRUE or FALSE!");
+        fn_obj_sky_table = kmo_dfs_get_parameter_string(parlist, 
+                "kmos.kmo_sci_red.obj_sky_table");
         KMO_TRY_CHECK_ERROR_STATE();
-
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.obj_sky_table"));
-
+            kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_sci_red.obj_sky_table"));
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_combine_pars_load(parlist,
-                                  "kmos.kmo_sci_red",
-                                  &cmethod,
-                                  &cpos_rej,
-                                  &cneg_rej,
-                                  &citer,
-                                  &cmin,
-                                  &cmax,
-                                  FALSE));
-
-        velo_offset = kmo_dfs_get_parameter_double(parlist, "kmos.kmo_sci_red.velocity_offset");
+            kmo_combine_pars_load(parlist, "kmos.kmo_sci_red", &cmethod,
+                &cpos_rej, &cneg_rej, &citer, &cmin, &cmax, FALSE));
+        velo_offset = kmo_dfs_get_parameter_double(parlist, 
+                "kmos.kmo_sci_red.velocity_offset");
         KMO_TRY_CHECK_ERROR_STATE();
 
         velo_corr = 1. + velo_offset * 1000. / CPL_PHYS_C;
         velo_corr_ptr = &velo_corr;
-
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.velocity_offset"));
-
-        save_interims = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sci_red.save_interims");
+            kmo_dfs_print_parameter_help(parlist,
+                "kmos.kmo_sci_red.velocity_offset"));
+        save_interims = kmo_dfs_get_parameter_bool(parlist,
+                "kmos.kmo_sci_red.save_interims");
         KMO_TRY_CHECK_ERROR_STATE();
         KMO_TRY_ASSURE((save_interims == TRUE) || (save_interims == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "save_interims must be TRUE or FALSE!");
+                CPL_ERROR_ILLEGAL_INPUT, "save_interims must be TRUE or FALSE");
         KMO_TRY_ASSURE(!((save_interims == TRUE) && (sky_tweak == FALSE)),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Save_interims saves sky_tweak objects so sky_tweak must be enabled too!");
+                CPL_ERROR_ILLEGAL_INPUT,
+               "Save_interims saves sky_tweak objects so sky_tweak must be enabled too");
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_sci_red.save_interims"));
-
+            kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_sci_red.save_interims"));
         cpl_msg_info("", "-------------------------------------------");
 
-        //
         // assure that filters, grating and rotation offsets match for
         // XCAL, YCAL, LCAL and for data frame to reconstruct (except DARK
         // frames)
-        //
-
-        // check if filter_id and grating_id match for all detectors
+        /* Check if filter_id and grating_id match for all detectors */
         KMO_TRY_EXIT_IF_ERROR(
             kmo_check_frameset_setup(frameset, SCIENCE, TRUE, FALSE, TRUE));
         KMO_TRY_EXIT_IF_ERROR(
@@ -1180,221 +1067,206 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
         KMO_TRY_EXIT_IF_ERROR(
             kmo_check_frame_setup(frameset, XCAL, LCAL, TRUE, FALSE, TRUE));
         if (has_master_flat) {
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_check_frame_setup(frameset, XCAL, MASTER_FLAT, TRUE, FALSE, TRUE));
+            KMO_TRY_EXIT_IF_ERROR(kmo_check_frame_setup(frameset, XCAL,
+                        MASTER_FLAT, TRUE, FALSE, TRUE));
         }
         if (has_telluric) {
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_check_frame_setup(frameset, XCAL, TELLURIC,
-                                           TRUE, FALSE, TRUE));
+            KMO_TRY_EXIT_IF_ERROR(kmo_check_frame_setup(frameset, XCAL, 
+                        TELLURIC, TRUE, FALSE, TRUE));
+        }
+        if (has_oh_spec) {
+            KMO_TRY_EXIT_IF_ERROR(kmo_check_oh_spec_setup(frameset, XCAL));
         }
 
         // check descriptors of all frames
-        KMO_TRY_EXIT_IF_NULL(
-            xcal_frame = kmo_dfs_get_frame(frameset, XCAL));
+        KMO_TRY_EXIT_IF_NULL(xcal_frame = kmo_dfs_get_frame(frameset, XCAL));
 
         desc1 = kmo_identify_fits_header(cpl_frame_get_filename(xcal_frame));
         KMO_TRY_CHECK_ERROR_STATE();
 
         KMO_TRY_ASSURE((desc1.nr_ext % KMOS_NR_DETECTORS == 0) &&
-                       (desc1.ex_badpix == FALSE) &&
-                       (desc1.fits_type == f2d_fits) &&
-                       (desc1.frame_type == detector_frame),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "XCAL isn't in the correct format!!!");
+                (desc1.ex_badpix == FALSE) &&
+                (desc1.fits_type == f2d_fits) &&
+                (desc1.frame_type == detector_frame),
+                CPL_ERROR_ILLEGAL_INPUT,
+                "XCAL isn't in the correct format!!!");
 
-        KMO_TRY_EXIT_IF_NULL(
-            ycal_frame = kmo_dfs_get_frame(frameset, YCAL));
+        KMO_TRY_EXIT_IF_NULL(ycal_frame = kmo_dfs_get_frame(frameset, YCAL));
         desc2 = kmo_identify_fits_header(cpl_frame_get_filename(ycal_frame));
         KMO_TRY_CHECK_ERROR_STATE();
 
         KMO_TRY_ASSURE((desc1.nr_ext == desc2.nr_ext) &&
-                       (desc1.ex_badpix == desc2.ex_badpix) &&
-                       (desc1.fits_type == desc2.fits_type) &&
-                       (desc1.frame_type == desc2.frame_type),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "YCAL isn't in the correct format!!!");
+               (desc1.ex_badpix == desc2.ex_badpix) &&
+               (desc1.fits_type == desc2.fits_type) &&
+               (desc1.frame_type == desc2.frame_type),
+               CPL_ERROR_ILLEGAL_INPUT,
+               "YCAL isn't in the correct format!!!");
         kmo_free_fits_desc(&desc2);
         kmo_init_fits_desc(&desc2);
 
-        KMO_TRY_EXIT_IF_NULL(
-            lcal_frame = kmo_dfs_get_frame(frameset, LCAL));
+        KMO_TRY_EXIT_IF_NULL(lcal_frame = kmo_dfs_get_frame(frameset, LCAL));
         desc2 = kmo_identify_fits_header(cpl_frame_get_filename(lcal_frame));
         KMO_TRY_CHECK_ERROR_STATE();
 
         KMO_TRY_ASSURE((desc2.nr_ext % KMOS_NR_DETECTORS == 0) &&
-                       (desc1.ex_badpix == desc2.ex_badpix) &&
-                       (desc1.fits_type == desc2.fits_type) &&
-                       (desc1.frame_type == desc2.frame_type),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "LCAL isn't in the correct format!!!");
+               (desc1.ex_badpix == desc2.ex_badpix) &&
+               (desc1.fits_type == desc2.fits_type) &&
+               (desc1.frame_type == desc2.frame_type),
+               CPL_ERROR_ILLEGAL_INPUT,
+               "LCAL isn't in the correct format!!!");
         kmo_free_fits_desc(&desc2);
         kmo_init_fits_desc(&desc2);
 
         if (has_master_flat) {
-            KMO_TRY_EXIT_IF_NULL(
-                flat_frame = kmo_dfs_get_frame(frameset, MASTER_FLAT));
-            desc2 = kmo_identify_fits_header(cpl_frame_get_filename(flat_frame));
+            KMO_TRY_EXIT_IF_NULL(flat_frame = kmo_dfs_get_frame(frameset, 
+                        MASTER_FLAT));
+            desc2=kmo_identify_fits_header(cpl_frame_get_filename(flat_frame));
             KMO_TRY_CHECK_ERROR_STATE();
 
             KMO_TRY_ASSURE((desc2.nr_ext % (2*KMOS_NR_DETECTORS) == 0) &&
-                           (desc1.ex_badpix == desc2.ex_badpix) &&
-                           (desc1.fits_type == desc2.fits_type) &&
-                           (desc1.frame_type == desc2.frame_type),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "MASTER_FLAT isn't in the correct format!!!");
+                    (desc1.ex_badpix == desc2.ex_badpix) &&
+                    (desc1.fits_type == desc2.fits_type) &&
+                    (desc1.frame_type == desc2.frame_type),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "MASTER_FLAT isn't in the correct format!!!");
             kmo_free_fits_desc(&desc2);
             kmo_init_fits_desc(&desc2);
         }
 
         if (has_illum_corr) {
-            KMO_TRY_EXIT_IF_NULL(
-                illum_frame = kmo_dfs_get_frame(frameset, ILLUM_CORR));
-            desc2 = kmo_identify_fits_header(
-                        cpl_frame_get_filename(illum_frame));
+            KMO_TRY_EXIT_IF_NULL(illum_frame = kmo_dfs_get_frame(frameset,
+                        ILLUM_CORR));
+            desc2=kmo_identify_fits_header(cpl_frame_get_filename(illum_frame));
             KMO_TRY_CHECK_ERROR_STATE();
             KMO_TRY_ASSURE(((desc2.nr_ext == 24) || (desc2.nr_ext == 48)) &&
-                           (desc2.ex_badpix == FALSE) &&
-                           (desc2.fits_type == f2i_fits) &&
-                           (desc2.frame_type == ifu_frame),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "ILLUM_CORR isn't in the correct format!!!");
+                    (desc2.ex_badpix == FALSE) &&
+                    (desc2.fits_type == f2i_fits) &&
+                    (desc2.frame_type == ifu_frame),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "ILLUM_CORR isn't in the correct format!!!");
             kmo_free_fits_desc(&desc2);
             kmo_init_fits_desc(&desc2);
         }
 
         if (has_telluric) {
-            KMO_TRY_EXIT_IF_NULL(
-                telluric_frame = kmo_dfs_get_frame(frameset, TELLURIC));
-            desc_telluric = kmo_identify_fits_header(
-                                        cpl_frame_get_filename(telluric_frame));
+            KMO_TRY_EXIT_IF_NULL(telluric_frame = kmo_dfs_get_frame(frameset, 
+                        TELLURIC));
+            desc_telluric=kmo_identify_fits_header(
+                    cpl_frame_get_filename(telluric_frame));
             KMO_TRY_CHECK_ERROR_STATE();
-            KMO_TRY_ASSURE(((desc_telluric.nr_ext == 24) || (desc_telluric.nr_ext == 48)) &&
-                           (desc_telluric.ex_badpix == FALSE) &&
-                           (desc_telluric.fits_type == f1i_fits) &&
-                           (desc_telluric.frame_type == ifu_frame),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "TELLURIC isn't in the correct format!!!");
+            KMO_TRY_ASSURE(((desc_telluric.nr_ext == 24) ||
+                        (desc_telluric.nr_ext == 48)) &&
+                    (desc_telluric.ex_badpix == FALSE) &&
+                    (desc_telluric.fits_type == f1i_fits) &&
+                    (desc_telluric.frame_type == ifu_frame),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "TELLURIC isn't in the correct format!!!");
         }
         kmo_free_fits_desc(&desc2);
 
-        KMO_TRY_EXIT_IF_NULL(
-            tmp_frame = kmo_dfs_get_frame(frameset, SCIENCE));
+        KMO_TRY_EXIT_IF_NULL(tmp_frame = kmo_dfs_get_frame(frameset, SCIENCE));
         while (tmp_frame != NULL ) {
             desc2 = kmo_identify_fits_header(cpl_frame_get_filename(tmp_frame));
             KMO_TRY_CHECK_ERROR_STATE();
             KMO_TRY_ASSURE((desc2.nr_ext == 3) &&
-                           (desc2.ex_badpix == FALSE) &&
-                           (desc2.fits_type == raw_fits) &&
-                           (desc2.frame_type == detector_frame),
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "SCIENCE isn't in the correct format!!!");
+                    (desc2.ex_badpix == FALSE) &&
+                    (desc2.fits_type == raw_fits) &&
+                    (desc2.frame_type == detector_frame),
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "SCIENCE isn't in the correct format!!!");
             kmo_free_fits_desc(&desc2);
             kmo_init_fits_desc(&desc2);
 
             if (mapping_mode == NULL) {
                 KMO_TRY_EXIT_IF_NULL(
-                    tmp_header =
-                          kmclipm_propertylist_load(
-                                         cpl_frame_get_filename(tmp_frame), 0));
+                    tmp_header = kmclipm_propertylist_load(
+                        cpl_frame_get_filename(tmp_frame), 0));
                 if (cpl_propertylist_has(tmp_header, TPL_ID)) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        tmp_str = cpl_propertylist_get_string(tmp_header,
-                                                              TPL_ID));
-
-                    if (strcmp(tmp_str, MAPPING8) == 0)
-                    {
+                    KMO_TRY_EXIT_IF_NULL(tmp_str = 
+                            cpl_propertylist_get_string(tmp_header, TPL_ID));
+                    if (strcmp(tmp_str, MAPPING8) == 0) {
                         mapping_mode = cpl_sprintf("%s", "mapping8");
                     }
-                    if (strcmp(tmp_str, MAPPING24) == 0)
-                    {
+                    if (strcmp(tmp_str, MAPPING24) == 0) {
                         mapping_mode = cpl_sprintf("%s", "mapping24");
                     }
                 }
                 cpl_propertylist_delete(tmp_header); tmp_header = NULL;
             }
-
             tmp_frame = kmo_dfs_get_frame(frameset, NULL);
             KMO_TRY_CHECK_ERROR_STATE();
         }
 
         if (mapping_mode != NULL) {
             // we are in mapping mode
-            if ((ifus != NULL) || (strcmp(name, "") != 0))
-            {
-                cpl_msg_warning("","The SCIENCE frames have been taken in one of the "
-                                   "mapping modes AND specific IFUs have been "
-                                   "specified! --> Only processing these!");
+            if ((ifus != NULL) || (strcmp(name, "") != 0)) {
+                cpl_msg_warning(__func__,\
+                        "The SCIENCE frames have been taken in one of the "
+                        "mapping modes AND specific IFUs have been "
+                        "specified! --> Only processing these!");
             } else {
                 if (strcmp(smethod, "BCS") == 0) {
                     extrapol_enum = BCS_NATURAL;
-                    cpl_msg_info("","Detected frames taken in mapping mode. "
-                                    "Changing extrapolation mode to TRUE.");
+                    cpl_msg_info(__func__,
+                            "Detected frames taken in mapping mode. "
+                            "Changing extrapolation mode to TRUE.");
                 }
             }
             if (fast_mode) {
-                cpl_msg_info("", "Creating map in fast_mode.");
+                cpl_msg_info(__func__, "Creating map in fast_mode.");
             }
         } else {
             if (fast_mode) {
-                cpl_msg_info("", "fast_mode has been selected but we aren't in "
-                             "mapping mode. So your choice for fast_mode is ignored.");
+                cpl_msg_info(__func__, 
+                        "fast_mode has been selected but we aren't in "
+                        "mapping mode. The choice for fast_mode is ignored.");
             }
         }
 
         KMO_TRY_EXIT_IF_NULL(
             suffix = kmo_dfs_get_suffix(xcal_frame, TRUE, FALSE));
 
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_check_frame_setup_md5_xycal(frameset));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_check_frame_setup_md5(frameset));
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_check_frame_setup_sampling(frameset));
+        /* Verify that XCAL / YCAL were generated together */
+        KMO_TRY_EXIT_IF_ERROR(kmo_check_frame_setup_md5_xycal(frameset));
+        /* Verify that XCAL and YCAL / LCAL were generated together */
+        KMO_TRY_EXIT_IF_ERROR(kmo_check_frame_setup_md5(frameset));
+        /* b_start/b_end/b_samples used for LCAL and TELLURIC were the same */
+        KMO_TRY_EXIT_IF_ERROR(kmo_check_frame_setup_sampling(frameset));
 
         cpl_msg_info("", "Detected instrument setup:   %s", suffix+1);
         cpl_msg_info("", "(grating 1, 2 & 3)");
 
-        //
-        // check which IFUs are active for all frames
-        //
-        KMO_TRY_EXIT_IF_NULL(
-            unused_ifus_before = kmo_get_unused_ifus(frameset, 1, 1));
-
-        KMO_TRY_EXIT_IF_NULL(
-            unused_ifus_after = kmo_duplicate_unused_ifus(unused_ifus_before));
-
+        /* Check which IFUs are active for all frames */
+        KMO_TRY_EXIT_IF_NULL(unused_ifus_before = 
+                kmo_get_unused_ifus(frameset, 1, 1));
+        KMO_TRY_EXIT_IF_NULL(unused_ifus_after = 
+                kmo_duplicate_unused_ifus(unused_ifus_before));
         kmo_print_unused_ifus(unused_ifus_before, FALSE);
 
-        //
-        // get bounds, setup grid, setup arm_name-struct
-        //
-
-        // get left and right bounds of IFUs
+        /* Get bounds, setup grid, setup arm_name-struct */
+        /* Get left and right bounds of IFUs from XCAL */
         KMO_TRY_EXIT_IF_NULL(
             tmp_header = kmo_dfs_load_primary_header(frameset, XCAL));
-        KMO_TRY_EXIT_IF_NULL(
-            bounds = kmclipm_extract_bounds(tmp_header));
+        KMO_TRY_EXIT_IF_NULL(bounds = kmclipm_extract_bounds(tmp_header));
         cpl_propertylist_delete(tmp_header); tmp_header = NULL;
 
-        // setup grid definition, wavelength start and end points will be set
-        // in the detector loop
+        /* Setup grid definition, wavelength start and end points will be */
+        /* set in the detector loop */
         KMO_TRY_EXIT_IF_ERROR(
             kmclipm_setup_grid(&gd, imethod, neighborhoodRange, pix_scale, 0.));
 
-        // get valid STD frames with objects in it and associated sky exposures and
-        // get valid object names to process, either one object name across
-        // several SCIENCE frames, or all object names
+        /*
+            Create armNameStruct : Contains info about objects that need
+            to be reconstructed and for each of them which sky need to be used
+            Get valid STD frames with objects in it and associated sky 
+            exposures and get valid object names to process, either one object
+            name across several SCIENCE frames, or all object names
+        */
         if (strcmp(fn_obj_sky_table, "") == 0) {
             KMO_TRY_EXIT_IF_NULL(
-                arm_name_struct = kmo_create_armNameStruct(frameset,
-                                                           SCIENCE,
-                                                           ifus,
-                                                           name,
-                                                           unused_ifus_after,
-                                                           bounds,
-                                                           mapping_mode,
-                                                           no_subtract));
+                arm_name_struct = kmo_create_armNameStruct(frameset, SCIENCE,
+                    ifus, name, unused_ifus_after, bounds, mapping_mode,
+                    no_subtract));
             KMO_TRY_EXIT_IF_ERROR(
                 kmo_save_objSkyStruct(arm_name_struct->obj_sky_struct));
         } else {
@@ -1403,15 +1275,16 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
 
             KMO_TRY_EXIT_IF_NULL(
                 obj_sky_struct = kmo_read_objSkyStruct(fn_obj_sky_table,
-                                                       frameset,
-                                                       SCIENCE));
+                    frameset, SCIENCE));
 
-            // check if any sky-IFUs have been specified not beeing the same IFU# for objects.
+            /* Check if any sky-IFUs have been specified not beeing the */
+            /* same IFU# for objects. */
             // In this case sky_tweak must be activated
             for (i = 0; i < obj_sky_struct->size; i++) {
                 if (obj_sky_struct->table[i].objFrame != NULL) {
                     for (jj = 0; jj < KMOS_NR_IFUS; jj++) {
-                        if ((obj_sky_struct->table[i].skyIfus[jj] > 0) && (sky_tweak == FALSE)) {
+                        if ((obj_sky_struct->table[i].skyIfus[jj] > 0) && 
+                                (sky_tweak == FALSE)) {
                             kmo_print_objSkyStruct(obj_sky_struct);
 
                             cpl_msg_error("","*************************************************************************");
@@ -1422,9 +1295,7 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
 
                             kmo_delete_objSkyStruct(obj_sky_struct);
 
-                            KMO_TRY_ASSURE(1 == 0,
-                                           CPL_ERROR_ILLEGAL_INPUT,
-                                           " ");
+                            KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT," ");
                         }
                     }
                 }
@@ -1432,103 +1303,86 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
 
             KMO_TRY_EXIT_IF_NULL(
                 arm_name_struct = kmo_create_armNameStruct2(obj_sky_struct,
-                                                            frameset,
-                                                            SCIENCE,
-                                                            ifus,
-                                                            name,
-                                                            unused_ifus_after,
-                                                            bounds,
-                                                            mapping_mode,
-                                                            no_subtract));
-
+                    frameset, SCIENCE, ifus, name, unused_ifus_after, bounds,
+                    mapping_mode, no_subtract));
         }
         kmo_print_armNameStruct(frameset, arm_name_struct);
 
-        // in mapping-mode check if for all IFUs there is either no telluric at all
-        // or the same number of tellurics than object names
+        /* Check Telluric availability for each Object */
+        /* Why only mapping  ? Not clear */
+        /* in mapping-mode check if for all IFUs there is either no  */
+        /* telluric at all or the same number of tellurics than object names */
         if ((has_telluric) && (mapping_mode != NULL)) {
             telluric_ok = TRUE;
             for (jj = 0; jj < arm_name_struct->nrNames; jj++) {
                 if (!((arm_name_struct->telluricCnt[jj] == arm_name_struct->namesCnt[jj]) ||
-                    (arm_name_struct->telluricCnt[jj] == 0)))
-                {
+                    (arm_name_struct->telluricCnt[jj] == 0))) {
                     telluric_ok = FALSE;
                     break;
                 }
             }
             if (!telluric_ok) {
-                KMO_TRY_ASSURE(1==0,
-                               CPL_ERROR_UNSUPPORTED_MODE,
-                               "Mosaics need a TELLURIC frame with at least a telluric correction per detector available! "
-                               "Omit the TELLURIC from your sof-file or choose another TELLURIC!");
+                KMO_TRY_ASSURE(1==0, CPL_ERROR_UNSUPPORTED_MODE,
+                        "Mosaics need a TELLURIC frame with at least a telluric correction per detector available! "
+                        "Omit the TELLURIC from your sof-file or choose another TELLURIC!");
             }
         }
 
-        //
-        // load lcal-frames
-        //
-        KMO_TRY_EXIT_IF_NULL(
-            lcal = (cpl_image**) cpl_calloc(KMOS_NR_DETECTORS, sizeof(cpl_image*)));
+        /* Load lcal-frames */
+        KMO_TRY_EXIT_IF_NULL(lcal = (cpl_image**)cpl_calloc(KMOS_NR_DETECTORS, 
+                    sizeof(cpl_image*)));
         for (i = 0; i < KMOS_NR_DETECTORS; i++) {
-            KMO_TRY_EXIT_IF_NULL(
-                lcal[i] = kmo_dfs_load_image(frameset, LCAL, i+1, FALSE, FALSE, NULL));
+            KMO_TRY_EXIT_IF_NULL(lcal[i] = kmo_dfs_load_image(frameset, LCAL, 
+                        i+1, FALSE, FALSE, NULL));
         }
 
         nr_data_alloc = KMOS_NR_IFUS;
-        KMO_TRY_EXIT_IF_NULL(
-            cube_data =  (cpl_imagelist**)cpl_calloc(nr_data_alloc,
-                                                     sizeof(cpl_imagelist*)));
-        KMO_TRY_EXIT_IF_NULL(
-            cube_noise = (cpl_imagelist**)cpl_calloc(nr_data_alloc,
-                                                     sizeof(cpl_imagelist*)));
-        KMO_TRY_EXIT_IF_NULL(
-            header_data =  (cpl_propertylist**)cpl_calloc(nr_data_alloc,
-                                                     sizeof(cpl_propertylist*)));
-        KMO_TRY_EXIT_IF_NULL(
-            header_noise = (cpl_propertylist**)cpl_calloc(nr_data_alloc,
-                                                     sizeof(cpl_propertylist*)));
+        KMO_TRY_EXIT_IF_NULL(cube_data = (cpl_imagelist**)cpl_calloc(
+                    nr_data_alloc, sizeof(cpl_imagelist*)));
+        KMO_TRY_EXIT_IF_NULL(cube_noise = (cpl_imagelist**)cpl_calloc(
+                    nr_data_alloc, sizeof(cpl_imagelist*)));
+        KMO_TRY_EXIT_IF_NULL(header_data = (cpl_propertylist**)cpl_calloc(
+                    nr_data_alloc, sizeof(cpl_propertylist*)));
+        KMO_TRY_EXIT_IF_NULL(header_noise = (cpl_propertylist**)cpl_calloc(
+                    nr_data_alloc, sizeof(cpl_propertylist*)));
 
         if (save_interims) {
-            KMO_TRY_EXIT_IF_NULL(
-                cube_interim_object =  (cpl_imagelist**)cpl_calloc(nr_data_alloc,
-                                                         sizeof(cpl_imagelist*)));
-            KMO_TRY_EXIT_IF_NULL(
-                cube_interim_sky =  (cpl_imagelist**)cpl_calloc(nr_data_alloc,
-                                                         sizeof(cpl_imagelist*)));
-            KMO_TRY_EXIT_IF_NULL(
-                header_sky =  (cpl_propertylist**)cpl_calloc(nr_data_alloc,
-                                                         sizeof(cpl_propertylist*)));
+            KMO_TRY_EXIT_IF_NULL(cube_interim_object=(cpl_imagelist**)cpl_calloc(
+                        nr_data_alloc, sizeof(cpl_imagelist*)));
+            KMO_TRY_EXIT_IF_NULL(cube_interim_sky =(cpl_imagelist**)cpl_calloc(
+                        nr_data_alloc, sizeof(cpl_imagelist*)));
+            KMO_TRY_EXIT_IF_NULL(header_sky = (cpl_propertylist**)cpl_calloc(
+                        nr_data_alloc, sizeof(cpl_propertylist*)));
         }
 
         if (cpl_frameset_count_tags(frameset, SCIENCE) == 1) {
             no_combine = TRUE;
-            cpl_msg_info("", "--no_combine has been set to TRUE since there is only one SCIENCE frame!");
+            cpl_msg_info(__func__, 
+                    "--no_combine set to TRUE since there is 1 SCIENCE frame");
         }
 
         if (no_subtract) {
             no_combine = TRUE;
-            cpl_msg_info("", "--no_combine has been set to TRUE since --no_subtract has been specified by the user!");
-            cpl_msg_info("", "Combining cubes would combine skies and objects which is meaningless.");
-            cpl_msg_info("", "This can be done manually with the recipe kmo_combine afterwards!");
+            cpl_msg_info(__func__, 
+                    "--no_combine set to TRUE since --no_subtract is set");
         }
-
         actual_msg_level = cpl_msg_get_level();
-
         cpl_msg_info("", "-------------------------------------------");
 
-        if (cpl_frameset_count_tags(frameset, OH_SPEC) != 0) {
-            int is_all_obs = TRUE,
-                has_all_origfile = TRUE;
+        /* Check if input SCIENCE frames are really ALL observations */
+        /* If not, Omit the OH_SPEC, even if it is passed - issue a Warning */
+        if (has_oh_spec) {
+            int is_all_obs          = TRUE,
+                has_all_origfile    = TRUE;
 
             KMO_TRY_EXIT_IF_NULL(
                 tmp_frame = kmo_dfs_get_frame(frameset, SCIENCE));
             while (tmp_frame != NULL ) {
-                KMO_TRY_EXIT_IF_NULL(
-                    tmp_header = kmclipm_propertylist_load(cpl_frame_get_filename(tmp_frame), 0));
-
+                KMO_TRY_EXIT_IF_NULL(tmp_header = kmclipm_propertylist_load(
+                            cpl_frame_get_filename(tmp_frame), 0));
                 if (cpl_propertylist_has(tmp_header, ORIGFILE)) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        tmp_str = cpl_propertylist_get_string(tmp_header, ORIGFILE));
+                    KMO_TRY_EXIT_IF_NULL(tmp_str = 
+                            cpl_propertylist_get_string(tmp_header, ORIGFILE));
                     if (strstr(tmp_str, "OBS") == NULL) {
                         is_all_obs = FALSE;
                     }
@@ -1542,71 +1396,60 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
 
             if (has_all_origfile) {
                 if (is_all_obs) {
-                    // we are reconstructing an OBS-frame, allow OH_SPEC correction
-                    KMO_TRY_EXIT_IF_NULL(
-                        ref_spectrum_frame = kmo_dfs_get_frame(frameset, OH_SPEC));
+                    /* OBS-frame reconstruction - allow OH_SPEC */
+                    KMO_TRY_EXIT_IF_NULL(ref_spectrum_frame = 
+                            kmo_dfs_get_frame(frameset, OH_SPEC));
+
+                    /* Verify OH_SPEC */
+                    /* TODO */
+
                 } else {
-                    cpl_msg_warning("", "Supplied OH_SPEC is ignored since a calibration "
-                                    "frame is being used as SCIENCE frame.");
+                    cpl_msg_warning(__func__, 
+                            "Supplied OH_SPEC is ignored since a calibration "
+                            "frame is being used as SCIENCE frame.");
                 }
             } else {
-                cpl_msg_warning("", "The supplied SCIENCE frames are all assumed to be "
-                                    "science frames. If any of them is a calibration frame, "
-                                    "omit OH_SPEC from sof-file");
-                KMO_TRY_EXIT_IF_NULL(
-                    ref_spectrum_frame = kmo_dfs_get_frame(frameset, OH_SPEC));
+                cpl_msg_warning(__func__, 
+                        "Supplied OH_SPEC is ignored since a calibration "
+                        "frame is being used as SCIENCE frame.");
             }
         }
 
-        //
-        // loop all science frames containing at least one object
-        //
-        cpl_msg_info("", "Reconstructing & saving cubes containing objects");
-        cpl_msg_info("", " ");
+        /* Loop all science frames containing at least one object */
+        cpl_msg_info(__func__, "Reconstructing & saving cubes with objects");
         for (sf = 0; sf < arm_name_struct->size; sf++) {
-            KMO_TRY_EXIT_IF_NULL(
-                fn_obj = cpl_frame_get_filename(arm_name_struct->obj_sky_struct->table[sf].objFrame));
-
+            KMO_TRY_EXIT_IF_NULL(fn_obj = cpl_frame_get_filename(
+                        arm_name_struct->obj_sky_struct->table[sf].objFrame));
             KMO_TRY_EXIT_IF_NULL(
                 main_header = kmclipm_propertylist_load(fn_obj, 0));
-
             actual_msg_level = cpl_msg_get_level();
 
-            //
-            // reconstruct science frame
-            //
-            cpl_msg_info("", "   > processing frame: %s", fn_obj);
-            for (ifu_nr = 1; ifu_nr <= KMOS_NR_IFUS; ifu_nr++)
-            {
+            /* Reconstruct science frame */
+            cpl_msg_info(__func__, "   > processing frame: %s", fn_obj);
+            for (ifu_nr = 1; ifu_nr <= KMOS_NR_IFUS; ifu_nr++) {
                 sky_ifu_nr = ifu_nr;
                 det_nr = (ifu_nr - 1)/KMOS_IFUS_PER_DETECTOR + 1;
 
-                KMO_TRY_ASSURE((det_nr >= 1) &&
-                               (det_nr <= KMOS_NR_DETECTORS),
-                               CPL_ERROR_ILLEGAL_INPUT,
-                               "The provided ifu-numbers are incorrect! They "
-                               "must be between 1 and %d", KMOS_NR_IFUS);
-
-                // get subheader data
-                KMO_TRY_EXIT_IF_NULL(
-                    header_data[ifu_nr-1] = kmclipm_propertylist_load(fn_obj,
-                                                                      det_nr));
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = kmo_extname_creator(ifu_frame, ifu_nr,
-                                                  EXT_DATA));
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_string(header_data[ifu_nr-1],
-                                                   EXTNAME, extname,
-                                                   "FITS extension name"));
+                KMO_TRY_ASSURE((det_nr >= 1) && (det_nr <= KMOS_NR_DETECTORS),
+                        CPL_ERROR_ILLEGAL_INPUT,
+                        "The provided ifu-numbers are incorrect! They "
+                        "must be between 1 and %d", KMOS_NR_IFUS);
+
+                /* Get subheader data */
+                KMO_TRY_EXIT_IF_NULL(header_data[ifu_nr-1] = 
+                        kmclipm_propertylist_load(fn_obj, det_nr));
+                KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(ifu_frame, 
+                            ifu_nr, EXT_DATA));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(
+                            header_data[ifu_nr-1], EXTNAME, extname,
+                            "FITS extension name"));
                 cpl_free(extname); extname = NULL;
 
                 if (arm_name_struct->name_ids[ifu_nr-1+sf*KMOS_NR_IFUS] >= 1) {
                     // IFU is valid
 
-                    if ((arm_name_struct->obj_sky_struct->table[sf].skyFrames[ifu_nr-1] != NO_CORRESPONDING_SKYFRAME) &&
-                        (cpl_frameset_count_tags(frameset, SCIENCE) != 1) &&
-                        !no_subtract)
-                    {
+                    /* Fill do_sky_subtraction and sky_frame */
+                    if ((arm_name_struct->obj_sky_struct->table[sf].skyFrames[ifu_nr-1] != NO_CORRESPONDING_SKYFRAME) && !no_subtract) {
                         do_sky_subtraction = TRUE;
                         if (no_subtract) {
                             sky_frame = NULL;
@@ -1623,315 +1466,291 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         }
 
                         if (no_subtract) {
-                            cpl_msg_warning("", "      > Omit sky subtraction on IFU %d", ifu_nr);
+                            cpl_msg_warning(__func__, 
+                                    "      > Omit sky subtraction on IFU %d", 
+                                    ifu_nr);
                         } else {
                             if (sky_ifu_nr == ifu_nr) {
-                                cpl_msg_info("", "      > IFU %d (with sky in frame: %s)", ifu_nr, fn_sky);
+                                cpl_msg_info(__func__, 
+                                        "      > IFU %d (sky in frame: %s)",
+                                        ifu_nr, fn_sky);
                             } else {
-                                cpl_msg_info("", "      > IFU %d (with sky in IFU %d of frame: %s)", ifu_nr, sky_ifu_nr, fn_sky);
+                                cpl_msg_info(__func__, 
+                                        "      > IFU %d (sky in IFU %d of frame: %s)",
+                                        ifu_nr, sky_ifu_nr, fn_sky);
                             }
                         }
                     } else {
                         do_sky_subtraction = FALSE;
                         sky_frame = NULL;
-                        if ((cpl_frameset_count_tags(frameset, SCIENCE) != 1) && (!no_subtract)) {
-                            cpl_msg_warning("", "      > IFU %d with no corresponding sky frame", ifu_nr);
+                        if (!no_subtract) {
+                            cpl_msg_warning(__func__, 
+                                    "      > IFU %d with no corresponding sky frame", 
+                                    ifu_nr);
                         }
                     }
 
-                    // get filter for this detector and setup grid definition
-                    // ESO INS FILTi ID
-                    char *tmp_band_method = getenv("KMO_BAND_METHOD");
-                    int band_method = 0;
-                    if (tmp_band_method != NULL) {
-                        band_method = atoi(tmp_band_method);
-                    }
-
-                    KMO_TRY_EXIT_IF_NULL(
-                        keyword = cpl_sprintf("%s%d%s",
-                                              IFU_FILTID_PREFIX, det_nr,
-                                              IFU_FILTID_POSTFIX));
-                    KMO_TRY_EXIT_IF_NULL(
-                        filter_id = cpl_propertylist_get_string(main_header,
-                                                                keyword));
+                    /* Get filter for this detector and setup grid definition using WAVE_BAND */
+                    KMO_TRY_EXIT_IF_NULL(keyword = cpl_sprintf("%s%d%s", 
+                                IFU_FILTID_PREFIX, det_nr, IFU_FILTID_POSTFIX));
+                    KMO_TRY_EXIT_IF_NULL(filter_id = 
+                            cpl_propertylist_get_string(main_header, keyword));
                     cpl_free(keyword); keyword = NULL;
 
-                    if (print_once) {
-                        cpl_msg_set_level(CPL_MSG_WARNING);
-                    }
+                    /* TODO : Review print_once mechanism */
+                    /* Used to print once per detector - problematic for parallelisation */
+                    if (print_once)     cpl_msg_set_level(CPL_MSG_WARNING);
 
-                    KMO_TRY_EXIT_IF_NULL(
-                        band_table = kmo_dfs_load_table(frameset, WAVE_BAND,
-                                                        1, 0));
-                    // lcal just needed when band_method==1
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_setup_grid_band_lcal(&gd, lcal[det_nr-1],
-                                                     filter_id, band_method,
-                                                     band_table));
+                    KMO_TRY_EXIT_IF_NULL(band_table = kmo_dfs_load_table(
+                                frameset, WAVE_BAND, 1, 0));
+                    KMO_TRY_EXIT_IF_ERROR(kmclipm_setup_grid_band_lcal(&gd, 
+                                filter_id, band_table));
                     cpl_table_delete(band_table); band_table = NULL;
 
                     print_once = TRUE;
                     cpl_msg_set_level(actual_msg_level);
 
-                    //
-                    // calc WCS & update subheader
-                    //
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_calc_wcs_gd(main_header, header_data[ifu_nr-1], ifu_nr, gd));
+                    /* calc WCS & update subheader */
+                    KMO_TRY_EXIT_IF_ERROR(kmo_calc_wcs_gd(main_header, 
+                                header_data[ifu_nr-1], ifu_nr, gd));
 
+                    /* Update some keywords  */
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_update_property_int(header_data[ifu_nr-1],
-                                                    NAXIS, 3,
-                                                    "number of data axes"));
+                            NAXIS, 3, "number of data axes"));
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_update_property_int(header_data[ifu_nr-1],
-                                                    NAXIS1, gd.x.dim,
-                                                    "length of data axis 1"));
+                            NAXIS1, gd.x.dim, "length of data axis 1"));
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_update_property_int(header_data[ifu_nr-1],
-                                                    NAXIS2, gd.y.dim,
-                                                    "length of data axis 2"));
+                            NAXIS2, gd.y.dim, "length of data axis 2"));
                     KMO_TRY_EXIT_IF_ERROR(
                         kmclipm_update_property_int(header_data[ifu_nr-1],
-                                                    NAXIS3, gd.l.dim,
-                                                    "length of data axis 3"));
+                            NAXIS3, gd.l.dim, "length of data axis 3"));
 
+                    /* Option save_interim only applies if sky_tweak is used */
                     if (save_interims && (sky_as_object_frame != NULL)) {
                         KMO_TRY_EXIT_IF_NULL(
                                 main_sky_header = kmclipm_propertylist_load(
-                                        cpl_frame_get_filename(sky_as_object_frame), 0));
-
-                        KMO_TRY_EXIT_IF_NULL(
-                                header_sky[ifu_nr-1] = kmclipm_propertylist_load(
-                                        cpl_frame_get_filename(sky_as_object_frame),
-                                        det_nr));
-
+                                        cpl_frame_get_filename(
+                                            sky_as_object_frame), 0));
                         KMO_TRY_EXIT_IF_NULL(
-                            extname = kmo_extname_creator(ifu_frame, ifu_nr,
-                                                          EXT_DATA));
-
+                                header_sky[ifu_nr-1]=kmclipm_propertylist_load(
+                                    cpl_frame_get_filename(
+                                        sky_as_object_frame), det_nr));
+                        KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(
+                                    ifu_frame, ifu_nr, EXT_DATA));
                         KMO_TRY_EXIT_IF_ERROR(
-                                kmclipm_update_property_string(header_sky[ifu_nr-1],
-                                        EXTNAME, extname,
-                                        "FITS extension name"));
-
+                                kmclipm_update_property_string(
+                                    header_sky[ifu_nr-1], EXTNAME, extname,
+                                    "FITS extension name"));
                         cpl_free(extname); extname = NULL;
 
-                        KMO_TRY_EXIT_IF_ERROR(
-                                kmo_calc_wcs_gd(main_sky_header, header_sky[ifu_nr-1], ifu_nr, gd));
-
-                        KMO_TRY_EXIT_IF_ERROR(
-                                kmclipm_update_property_int(header_sky[ifu_nr-1],
-                                        NAXIS, 3,
-                                        "number of data axes"));
-                        KMO_TRY_EXIT_IF_ERROR(
-                                kmclipm_update_property_int(header_sky[ifu_nr-1],
-                                        NAXIS1, gd.x.dim,
-                                        "length of data axis 1"));
-                        KMO_TRY_EXIT_IF_ERROR(
-                                kmclipm_update_property_int(header_sky[ifu_nr-1],
-                                        NAXIS2, gd.y.dim,
-                                        "length of data axis 2"));
-                        KMO_TRY_EXIT_IF_ERROR(
-                                kmclipm_update_property_int(header_sky[ifu_nr-1],
-                                        NAXIS3, gd.l.dim,
-                                        "length of data axis 3"));
-
-                        cpl_propertylist_delete(main_sky_header); main_sky_header = NULL;
+                        KMO_TRY_EXIT_IF_ERROR(kmo_calc_wcs_gd(main_sky_header,
+                                    header_sky[ifu_nr-1], ifu_nr, gd));
+
+                        KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                                    header_sky[ifu_nr-1], NAXIS, 3,
+                                    "number of data axes"));
+                        KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                                    header_sky[ifu_nr-1], NAXIS1, gd.x.dim,
+                                    "length of data axis 1"));
+                        KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                                    header_sky[ifu_nr-1], NAXIS2, gd.y.dim,
+                                    "length of data axis 2"));
+                        KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_int(
+                                    header_sky[ifu_nr-1], NAXIS3, gd.l.dim,
+                                    "length of data axis 3"));
+                        cpl_propertylist_delete(main_sky_header); 
+                        main_sky_header = NULL;
                     }
 
-                    //
-                    // reconstruct object
-                    //
-
-                    if (ref_spectrum_frame == NULL) { // no lambda correction using OH lines
+                    /* Reconstruct object */
+                    if (ref_spectrum_frame == NULL) {
+                        /* No lambda correction using OH lines */
                         KMO_TRY_EXIT_IF_ERROR(
-                                kmo_reconstruct_sci(ifu_nr,
-                                                    bounds[2*(ifu_nr-1)],
-                                                    bounds[2*(ifu_nr-1)+1],
-                                                    arm_name_struct->obj_sky_struct->table[sf].objFrame,
-                                                    SCIENCE,
-                                                    sky_frame,
-                                                    SCIENCE,
-                                                    flat_frame,
-                                                    xcal_frame,
-                                                    ycal_frame,
-                                                    lcal_frame,
-                                                    NULL,
-                                                    velo_corr_ptr,
-                                                    &gd,
-                                                    &cube_data[ifu_nr-1],
-                                                    &cube_noise[ifu_nr-1],
-                                                    flux,
-                                                    background,
-                                                    xcal_interpolation));
-
-                    } else {                    //  lambda correction using OH lines
+                                kmo_reconstruct_sci(
+                                    ifu_nr,
+                                    bounds[2*(ifu_nr-1)],
+                                    bounds[2*(ifu_nr-1)+1],
+                            arm_name_struct->obj_sky_struct->table[sf].objFrame,
+                                    SCIENCE,
+                                    sky_frame,
+                                    SCIENCE,
+                                    flat_frame,
+                                    xcal_frame,
+                                    ycal_frame,
+                                    lcal_frame,
+                                    NULL,
+                                    velo_corr_ptr,
+                                    &gd,
+                                    &cube_data[ifu_nr-1],
+                                    &cube_noise[ifu_nr-1],
+                                    flux,
+                                    background,
+                                    xcal_interpolation));
+                    } else { 
+                        /* Lambda correction using OH lines */
                         KMO_TRY_EXIT_IF_ERROR(
-                                kmo_reconstruct_sci(ifu_nr,
-                                                    bounds[2*(ifu_nr-1)],
-                                                    bounds[2*(ifu_nr-1)+1],
-                                                    arm_name_struct->obj_sky_struct->table[sf].objFrame,
-                                                    SCIENCE,
-                                                    NULL,
-                                                    NULL,
-                                                    flat_frame,
-                                                    xcal_frame,
-                                                    ycal_frame,
-                                                    lcal_frame,
-                                                    NULL,
-                                                    NULL,
-                                                    &gd,
-                                                    &cube_data[ifu_nr-1],
-                                                    &cube_noise[ifu_nr-1],
-                                                    FALSE,
-                                                    FALSE,
-                                                    xcal_interpolation));
-
-
+                                kmo_reconstruct_sci(
+                                    ifu_nr,
+                                    bounds[2*(ifu_nr-1)],
+                                    bounds[2*(ifu_nr-1)+1],
+                            arm_name_struct->obj_sky_struct->table[sf].objFrame,
+                                    SCIENCE,
+                                    NULL,
+                                    NULL,
+                                    flat_frame,
+                                    xcal_frame,
+                                    ycal_frame,
+                                    lcal_frame,
+                                    NULL,
+                                    NULL,
+                                    &gd,
+                                    &cube_data[ifu_nr-1],
+                                    &cube_noise[ifu_nr-1],
+                                    FALSE,
+                                    FALSE,
+                                    xcal_interpolation));
                         if (cube_data[ifu_nr-1] != NULL) {
                             KMO_TRY_EXIT_IF_NULL(
-                                oh_lcorr_coeffs = kmo_lcorr_get(cube_data[ifu_nr-1],
-                                                             header_data[ifu_nr-1],
-                                                             ref_spectrum_frame,
-                                                             gd,
-                                                             filter_id,
-                                                             ifu_nr));
-
-                            cpl_imagelist_delete(cube_data[ifu_nr-1]); cube_data[ifu_nr-1] = NULL;
+                                oh_lcorr_coeffs = kmo_lcorr_get(
+                                    cube_data[ifu_nr-1], header_data[ifu_nr-1],
+                                    ref_spectrum_frame, gd, filter_id, ifu_nr));
+                            cpl_imagelist_delete(cube_data[ifu_nr-1]); 
+                            cube_data[ifu_nr-1] = NULL;
                             if (cube_noise[ifu_nr-1] != NULL) {
-                                cpl_imagelist_delete(cube_noise[ifu_nr-1]); cube_noise[ifu_nr-1] = NULL;
+                                cpl_imagelist_delete(cube_noise[ifu_nr-1]); 
+                                cube_noise[ifu_nr-1] = NULL;
                             }
 
                             KMO_TRY_EXIT_IF_ERROR(
-                                    kmo_reconstruct_sci(ifu_nr,
-                                                        bounds[2*(ifu_nr-1)],
-                                                        bounds[2*(ifu_nr-1)+1],
-                                                        arm_name_struct->obj_sky_struct->table[sf].objFrame,
-                                                        SCIENCE,
-                                                        sky_frame,
-                                                        SCIENCE,
-                                                        flat_frame,
-                                                        xcal_frame,
-                                                        ycal_frame,
-                                                        lcal_frame,
-                                                        oh_lcorr_coeffs,
-                                                        velo_corr_ptr,
-                                                        &gd,
-                                                        &cube_data[ifu_nr-1],
-                                                        &cube_noise[ifu_nr-1],
-                                                        flux,
-                                                        background,
-                                                        xcal_interpolation));
-
-                            cpl_polynomial_delete(oh_lcorr_coeffs); oh_lcorr_coeffs = NULL;
+                                    kmo_reconstruct_sci(
+                                        ifu_nr,
+                                        bounds[2*(ifu_nr-1)],
+                                        bounds[2*(ifu_nr-1)+1],
+                            arm_name_struct->obj_sky_struct->table[sf].objFrame,
+                                        SCIENCE,
+                                        sky_frame,
+                                        SCIENCE,
+                                        flat_frame,
+                                        xcal_frame,
+                                        ycal_frame,
+                                        lcal_frame,
+                                        oh_lcorr_coeffs,
+                                        velo_corr_ptr,
+                                        &gd,
+                                        &cube_data[ifu_nr-1],
+                                        &cube_noise[ifu_nr-1],
+                                        flux,
+                                        background,
+                                        xcal_interpolation));
+                            cpl_polynomial_delete(oh_lcorr_coeffs); 
+                            oh_lcorr_coeffs = NULL;
                         }
                     }
 
-                    // if sky_tweak is set to TRUE reconstruct sky frame as object
-                    // ans use kmo_priv_sky_tweak to subtract a modified sky cube
+                    /* If sky_tweak is set,reconstruct sky frame as object */
+                    /* and  use kmo_priv_sky_tweak to subtract  */
+                    /* a modified sky cube */
                     if (do_sky_subtraction && sky_tweak) {
-                        if (ref_spectrum_frame == NULL) { // no lambda correction using OH lines
+                        if (ref_spectrum_frame == NULL) {
+                            /* No lambda correction using OH lines */
                             KMO_TRY_EXIT_IF_ERROR(
-                                    kmo_reconstruct_sci(sky_ifu_nr,
-                                                        bounds[2*(sky_ifu_nr-1)],
-                                                        bounds[2*(sky_ifu_nr-1)+1],
-                                                        sky_as_object_frame,
-                                                        SCIENCE,
-                                                        sky_frame,
-                                                        SCIENCE,
-                                                        flat_frame,
-                                                        xcal_frame,
-                                                        ycal_frame,
-                                                        lcal_frame,
-                                                        NULL,
-                                                        velo_corr_ptr,
-                                                        &gd,
-                                                        &sky_data,
-                                                        &sky_noise,
-                                                        flux,
-                                                        background,
-                                                        xcal_interpolation));
-
-                        } else {                    //  lambda correction using OH lines
+                                    kmo_reconstruct_sci(
+                                        sky_ifu_nr,
+                                        bounds[2*(sky_ifu_nr-1)],
+                                        bounds[2*(sky_ifu_nr-1)+1],
+                                        sky_as_object_frame,
+                                        SCIENCE,
+                                        sky_frame,
+                                        SCIENCE,
+                                        flat_frame,
+                                        xcal_frame,
+                                        ycal_frame,
+                                        lcal_frame,
+                                        NULL,
+                                        velo_corr_ptr,
+                                        &gd,
+                                        &sky_data,
+                                        &sky_noise,
+                                        flux,
+                                        background,
+                                        xcal_interpolation));
+                        } else {     
+                            /* Lambda correction using OH lines */
                             KMO_TRY_EXIT_IF_ERROR(
-                                    kmo_reconstruct_sci(sky_ifu_nr,
-                                                        bounds[2*(sky_ifu_nr-1)],
-                                                        bounds[2*(sky_ifu_nr-1)+1],
-                                                        sky_as_object_frame,
-                                                        SCIENCE,
-                                                        NULL,
-                                                        NULL,
-                                                        flat_frame,
-                                                        xcal_frame,
-                                                        ycal_frame,
-                                                        lcal_frame,
-                                                        NULL,
-                                                        NULL,
-                                                        &gd,
-                                                        &sky_data,
-                                                        &sky_noise,
-                                                        FALSE,
-                                                        FALSE,
-                                                        xcal_interpolation));
-
-
+                                    kmo_reconstruct_sci(
+                                        sky_ifu_nr,
+                                        bounds[2*(sky_ifu_nr-1)],
+                                        bounds[2*(sky_ifu_nr-1)+1],
+                                        sky_as_object_frame,
+                                        SCIENCE,
+                                        NULL,
+                                        NULL,
+                                        flat_frame,
+                                        xcal_frame,
+                                        ycal_frame,
+                                        lcal_frame,
+                                        NULL,
+                                        NULL,
+                                        &gd,
+                                        &sky_data,
+                                        &sky_noise,
+                                        FALSE,
+                                        FALSE,
+                                        xcal_interpolation));
                             if (sky_data != NULL) {
                                 KMO_TRY_EXIT_IF_NULL(
                                     oh_lcorr_coeffs = kmo_lcorr_get(sky_data,
-                                                                    header_data[ifu_nr-1],
-                                                                    ref_spectrum_frame,
-                                                                    gd,
-                                                                    filter_id,
-                                                                    ifu_nr));
-
+                                        header_data[ifu_nr-1],
+                                        ref_spectrum_frame, gd, filter_id,
+                                        ifu_nr));
                                 cpl_imagelist_delete(sky_data); sky_data = NULL;
                                 if (sky_noise != NULL) {
-                                    cpl_imagelist_delete(sky_noise); sky_noise = NULL;
+                                    cpl_imagelist_delete(sky_noise); 
+                                    sky_noise = NULL;
                                 }
-
                                 KMO_TRY_EXIT_IF_ERROR(
-                                        kmo_reconstruct_sci(sky_ifu_nr,
-                                                            bounds[2*(sky_ifu_nr-1)],
-                                                            bounds[2*(sky_ifu_nr-1)+1],
-                                                            sky_as_object_frame,
-                                                            SCIENCE,
-                                                            sky_frame,
-                                                            SCIENCE,
-                                                            flat_frame,
-                                                            xcal_frame,
-                                                            ycal_frame,
-                                                            lcal_frame,
-                                                            oh_lcorr_coeffs,
-                                                            velo_corr_ptr,
-                                                            &gd,
-                                                            &sky_data,
-                                                            &sky_noise,
-                                                            flux,
-                                                            background,
-                                                            xcal_interpolation));
-
-                                cpl_polynomial_delete(oh_lcorr_coeffs); oh_lcorr_coeffs = NULL;
+                                        kmo_reconstruct_sci(
+                                            sky_ifu_nr,
+                                            bounds[2*(sky_ifu_nr-1)],
+                                            bounds[2*(sky_ifu_nr-1)+1],
+                                            sky_as_object_frame,
+                                            SCIENCE,
+                                            sky_frame,
+                                            SCIENCE,
+                                            flat_frame,
+                                            xcal_frame,
+                                            ycal_frame,
+                                            lcal_frame,
+                                            oh_lcorr_coeffs,
+                                            velo_corr_ptr,
+                                            &gd,
+                                            &sky_data,
+                                            &sky_noise,
+                                            flux,
+                                            background,
+                                            xcal_interpolation));
+                                cpl_polynomial_delete(oh_lcorr_coeffs);
+                                oh_lcorr_coeffs = NULL;
                             }
                         } // end if (ref_spectrum_frame == NULL)
 
                         if (save_interims && (sky_as_object_frame != NULL)) {
-                            KMO_TRY_EXIT_IF_NULL(
-                                    cube_interim_object[ifu_nr-1] =
-                                            cpl_imagelist_duplicate(cube_data[ifu_nr-1]));
-                            KMO_TRY_EXIT_IF_NULL(
-                                    cube_interim_sky[ifu_nr-1] =
-                                            cpl_imagelist_duplicate(sky_data));
+                            KMO_TRY_EXIT_IF_NULL(cube_interim_object[ifu_nr-1]=
+                                    cpl_imagelist_duplicate(cube_data[ifu_nr-1]));
+                            KMO_TRY_EXIT_IF_NULL(cube_interim_sky[ifu_nr-1]=
+                                    cpl_imagelist_duplicate(sky_data));
                         }
 
                         cpl_imagelist *tmp_object_cube = cube_data[ifu_nr-1];
-                        KMO_TRY_EXIT_IF_NULL(
-                                cube_data[ifu_nr-1] = kmo_priv_sky_tweak (tmp_object_cube,
-                                                                   sky_data,
-                                                                   header_data[ifu_nr-1],
-                                                                   .3, tbsub));
+                        KMO_TRY_EXIT_IF_NULL(cube_data[ifu_nr-1] = 
+                                kmo_priv_sky_tweak (tmp_object_cube, sky_data,
+                                    header_data[ifu_nr-1], .3, tbsub));
                         if (tmp_object_cube != NULL) {
-                            cpl_imagelist_delete(tmp_object_cube); tmp_object_cube = NULL;
+                            cpl_imagelist_delete(tmp_object_cube); 
+                            tmp_object_cube = NULL;
                         }
                         if (sky_data != NULL) {
                             cpl_imagelist_delete(sky_data); sky_data = NULL;
@@ -1941,93 +1760,98 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         }
                     } // end if (do_sky_subtraction && sky_tweak)
 
-                    // scale flux according to pixel_scale
+                    /* Maintain flux constant in case the pixscale is diff */
+                    /* For example, pixscale=0.1 => images 28x28 => scaling=4 */
                     KMO_TRY_EXIT_IF_NULL(
                         tmpImg = cpl_imagelist_get(cube_data[ifu_nr-1], 0));
-                    double scaling = (cpl_image_get_size_x(tmpImg)*cpl_image_get_size_y(tmpImg)) /
-                                     (KMOS_SLITLET_X*KMOS_SLITLET_Y);
+                    double scaling = (cpl_image_get_size_x(tmpImg)*
+                            cpl_image_get_size_y(tmpImg)) /
+                        (KMOS_SLITLET_X*KMOS_SLITLET_Y);
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_imagelist_divide_scalar(cube_data[ifu_nr-1], scaling));
+                        cpl_imagelist_divide_scalar(cube_data[ifu_nr-1], 
+                            scaling));
                     if (cube_noise[ifu_nr-1] != NULL) {
                         KMO_TRY_EXIT_IF_ERROR(
-                            cpl_imagelist_divide_scalar(cube_noise[ifu_nr-1], scaling));
+                            cpl_imagelist_divide_scalar(cube_noise[ifu_nr-1],
+                                scaling));
                     }
 
-                    // get object name
-                    KMO_TRY_EXIT_IF_NULL(
-                        keyword = cpl_sprintf("%s%d%s", IFU_NAME_PREFIX, ifu_nr,
-                                              IFU_NAME_POSTFIX));
-                    KMO_TRY_EXIT_IF_NULL(
-                        tmp_str = cpl_propertylist_get_string(header_data[ifu_nr-1],
-                                                              keyword));
+                    /* Get object name */
+                    KMO_TRY_EXIT_IF_NULL(keyword = cpl_sprintf("%s%d%s",
+                                IFU_NAME_PREFIX, ifu_nr, IFU_NAME_POSTFIX));
+                    KMO_TRY_EXIT_IF_NULL(tmp_str = cpl_propertylist_get_string(
+                                header_data[ifu_nr-1], keyword));
                     cpl_free(keyword); keyword = NULL;
 
-                    //
-                    // divide cube by telluric correction
-                    //
+                    /* Divide cube by telluric correction */
                     if (has_telluric) {
-                        // check if the number of occurences of the actual object name is the
-                        // same as the number of found tellurics for this object (which can be on different arms)
+                        /* Check if the nb of occurences of the object name  */
+                        /* is the same as the number of found tellurics for */
+                        /* this object (which can be on different arms) */
                         telluric_ok = FALSE;
                         for (jj = 0; jj < arm_name_struct->nrNames; jj++) {
                             if (((strcmp(arm_name_struct->names[jj], tmp_str) == 0) ||
                                  (strcmp(arm_name_struct->names[jj], IFUS_USER_DEFINED) == 0)) &&
-                                (arm_name_struct->telluricCnt[jj] == arm_name_struct->namesCnt[jj]))
-                            {
+                                (arm_name_struct->telluricCnt[jj] == arm_name_struct->namesCnt[jj])) {
                                 telluric_ok = TRUE;
                                 break;
                             }
                         }
 
                         if (telluric_ok) {
-                            telluric_data = kmo_tweak_load_telluric(frameset, ifu_nr, FALSE, no_subtract);
+                            telluric_data = kmo_tweak_load_telluric(frameset,
+                                    ifu_nr, FALSE, no_subtract);
                             KMO_TRY_CHECK_ERROR_STATE();
                             if (telluric_data != NULL) {
-                                index = kmo_identify_index_desc(desc_telluric, ifu_nr, TRUE);
+                                /* Get the index of the telluric noise */
+                                index = kmo_identify_index_desc(desc_telluric,
+                                        ifu_nr, TRUE);
                                 KMO_TRY_CHECK_ERROR_STATE();
-                                if (desc_telluric.sub_desc[index-1].valid_data == TRUE) {
+                                if (desc_telluric.sub_desc[index-1].valid_data 
+                                        == TRUE) {
                                     // load noise if present
-                                    telluric_noise = kmo_tweak_load_telluric(frameset, ifu_nr, TRUE, no_subtract);
+                                    telluric_noise = kmo_tweak_load_telluric(
+                                            frameset,ifu_nr, TRUE, no_subtract);
                                     KMO_TRY_CHECK_ERROR_STATE();
                                 } else {
-                                    if (print_warning_once_tweak_std_noise && (cube_noise[ifu_nr-1] != NULL)) {
-                                        cpl_msg_warning("","************************************************************");
-                                        cpl_msg_warning("","* Noise cubes were calculated, but won't be divided by     *");
-                                        cpl_msg_warning("","* telluric error since it is missing.                      *");
-                                        cpl_msg_warning("","* In order to get a telluric with errors, execute          *");
-                                        cpl_msg_warning("","* kmo_std_star with one of the nearest neighbour methods   *");
-                                        cpl_msg_warning("","* (set --imethod to NN, lwNN or swNN)                      *");
-                                        cpl_msg_warning("","************************************************************");
-                                        print_warning_once_tweak_std_noise = FALSE;
+                                    if (print_warning_once_tweak_std_noise && 
+                                            (cube_noise[ifu_nr-1] != NULL)) {
+                                        cpl_msg_warning(__func__,"************************************************************");
+                                        cpl_msg_warning(__func__,"* Noise cubes were calculated, but won't be divided by     *");
+                                        cpl_msg_warning(__func__,"* telluric error since it is missing.                      *");
+                                        cpl_msg_warning(__func__,"* In order to get a telluric with errors, execute          *");
+                                        cpl_msg_warning(__func__,"* kmo_std_star with one of the nearest neighbour methods   *");
+                                        cpl_msg_warning(__func__,"* (set --imethod to NN, lwNN or swNN)                      *");
+                                        cpl_msg_warning(__func__,"************************************************************");
+                                        print_warning_once_tweak_std_noise = 
+                                            FALSE;
                                     }
                                 }
 
-                                KMO_TRY_EXIT_IF_ERROR(
-                                    kmo_arithmetic_3D_1D(
+                                KMO_TRY_EXIT_IF_ERROR(kmo_arithmetic_3D_1D(
                                             cube_data[ifu_nr-1], telluric_data,
-                                            cube_noise[ifu_nr-1], telluric_noise, "/"));
+                                            cube_noise[ifu_nr-1],
+                                            telluric_noise, "/"));
                             }
                         }
                     }
 
-                    //
-                    // divide cube by illumination correction
-                    //
+                    /* Divide cube by illumination correction */
                     if (has_illum_corr) {
                         illum_data = kmo_dfs_load_image(frameset, ILLUM_CORR,
-                                                        ifu_nr, FALSE, FALSE, NULL);
+                                ifu_nr, FALSE, FALSE, NULL);
                         if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                            cpl_msg_warning("","No illumination correction for IFU %d available! "
+                            cpl_msg_warning(__func__,
+                            "No illumination correction for IFU %d available! "
                                             "Proceeding anyway.", ifu_nr);
                             cpl_error_reset();
                         } else {
                             illum_noise = kmo_dfs_load_image(frameset,
-                                                             ILLUM_CORR,
-                                                             ifu_nr, TRUE,
-                                                             FALSE, NULL);
+                                    ILLUM_CORR, ifu_nr, TRUE, FALSE, NULL);
                             if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                                cpl_msg_warning("","No illumination correction for IFU %d "
-                                                "available! Proceeding anyway.", ifu_nr);
+                                cpl_msg_warning(__func__,
+                            "No illumination correction for IFU %d available! "
+                                            "Proceeding anyway.", ifu_nr);
                                 cpl_image_delete(illum_data); illum_data = NULL;
                                 cpl_error_reset();
                             }
@@ -2035,60 +1859,40 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
 
                         if (illum_data != NULL) {
                             KMO_TRY_EXIT_IF_ERROR(
-                                kmo_arithmetic_3D_2D(
-                                            cube_data[ifu_nr-1], illum_data,
-                                            cube_noise[ifu_nr-1], illum_noise, "/"));
+                                kmo_arithmetic_3D_2D(cube_data[ifu_nr-1],
+                                    illum_data, cube_noise[ifu_nr-1],
+                                    illum_noise, "/"));
                             cpl_image_delete(illum_data); illum_data = NULL;
                             cpl_image_delete(illum_noise); illum_noise = NULL;
                         }
                     }
 
-                    // get object name and store if not already present
-                    KMO_TRY_EXIT_IF_NULL(
-                        keyword = cpl_sprintf("%s%d%s", IFU_NAME_PREFIX, ifu_nr,
-                                              IFU_NAME_POSTFIX));
-                    KMO_TRY_EXIT_IF_NULL(
-                        tmp_str = cpl_propertylist_get_string(header_data[ifu_nr-1],
-                                                              keyword));
-                    cpl_free(keyword); keyword = NULL;
-
                     kmclipm_vector_delete(telluric_data); telluric_data = NULL;
-                    kmclipm_vector_delete(telluric_noise); telluric_noise = NULL;
+                    kmclipm_vector_delete(telluric_noise);telluric_noise= NULL;
                 } else {
                     // IFU is invalid
                 }
 
                 // duplicate subheader data
-                KMO_TRY_EXIT_IF_NULL(
-                    header_noise[ifu_nr-1] =
-                         cpl_propertylist_duplicate(header_data[ifu_nr-1]));
-
-                KMO_TRY_EXIT_IF_NULL(
-                    extname = kmo_extname_creator(ifu_frame, ifu_nr, EXT_NOISE));
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_update_property_string(header_noise[ifu_nr-1],
-                                                   EXTNAME, extname,
-                                                   "FITS extension name"));
+                KMO_TRY_EXIT_IF_NULL(header_noise[ifu_nr-1] =
+                        cpl_propertylist_duplicate(header_data[ifu_nr-1]));
+                KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(ifu_frame,
+                            ifu_nr, EXT_NOISE));
+                KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(
+                            header_noise[ifu_nr-1], EXTNAME, extname,
+                            "FITS extension name"));
                 cpl_free(extname); extname = NULL;
             } // end for ifu_nr
 
-            //
-            // count number of reconstructed data- and noise-cubes
-            //
+            /* Count number of reconstructed data- and noise-cubes */
             for (ifu_nr = 1; ifu_nr <= nr_data_alloc; ifu_nr++) {
-                if (cube_data[ifu_nr-1] != NULL) {
-                    cube_counter_data++;
-                }
-                if (cube_noise[ifu_nr-1] != NULL) {
-                    cube_counter_noise++;
-                }
+                if (cube_data[ifu_nr-1] != NULL)    cube_counter_data++;
+                if (cube_noise[ifu_nr-1] != NULL)   cube_counter_noise++;
             }
 
-            //
-            // save reconstructed cubes of science frame
-            //
+            /* Save reconstructed cubes of science frame */
             if (cube_counter_data > 0) {
-                cpl_msg_info("", "   > saving...");
+                cpl_msg_info(__func__, "   > saving...");
 
                 if (!suppress_extension) {
                     fn_out = fn_obj;
@@ -2116,46 +1920,55 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 fn_interim_object = INTERIM_OBJECT_CUBE;
                 fn_interim_sky = INTERIM_OBJECT_SKY;
 
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_main_header(frameset, fn_out, fn_suffix,
-                                             arm_name_struct->obj_sky_struct->table[sf].objFrame,
-                                             NULL, parlist, cpl_func));
+                /* Create Primary Header */
+                KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, 
+                            fn_out, fn_suffix,
+                            arm_name_struct->obj_sky_struct->table[sf].objFrame,
+                            NULL, parlist, cpl_func));
+                /* save intermediate products (only in sky tweak case) */
                 if (save_interims && (sky_as_object_frame != NULL)) {
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_main_header(frameset, fn_interim_object, fn_suffix,
-                                                 arm_name_struct->obj_sky_struct->table[sf].objFrame,
-                                                 NULL, parlist, cpl_func));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_main_header(frameset, fn_interim_sky, fn_suffix,
-                                                 arm_name_struct->obj_sky_struct->table[sf].objFrame,
-                                                 NULL, parlist, cpl_func));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, 
+                                fn_interim_object, fn_suffix,
+                            arm_name_struct->obj_sky_struct->table[sf].objFrame,
+                            NULL, parlist, cpl_func));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, 
+                                fn_interim_sky, fn_suffix,
+                                arm_name_struct->obj_sky_struct->table[sf].objFrame,
+                                NULL, parlist, cpl_func));
                 }
 
+                /* Loop on IFUs */
                 for (ifu_nr = 1; ifu_nr <= KMOS_NR_IFUS; ifu_nr++) {
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_cube(cube_data[ifu_nr-1], fn_out,
-                                          fn_suffix, header_data[ifu_nr-1], 0./0.));
+                    /* Save data Extension */
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_cube(cube_data[ifu_nr-1],
+                                fn_out,fn_suffix,header_data[ifu_nr-1], 0./0.));
 
+                    /* Save noise Extension */
                     if (cube_counter_noise > 0) {
-                        KMO_TRY_EXIT_IF_ERROR(
-                            kmo_dfs_save_cube(cube_noise[ifu_nr-1], fn_out,
-                                              fn_suffix, header_noise[ifu_nr-1],
-                                              0./0.));
+                        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_cube(
+                                    cube_noise[ifu_nr-1], fn_out, fn_suffix,
+                                    header_noise[ifu_nr-1], 0./0.));
                     }
 
+                    /* save intermediate products (only in sky tweak case */
                     if (save_interims && (sky_as_object_frame != NULL)) {
-                        KMO_TRY_EXIT_IF_ERROR(
-                                kmo_dfs_save_cube(cube_interim_object[ifu_nr-1], fn_interim_object,
-                                        fn_suffix, header_data[ifu_nr-1], 0./0.));
-                        KMO_TRY_EXIT_IF_ERROR(
-                                kmo_dfs_save_cube(cube_interim_sky[ifu_nr-1], fn_interim_sky,
-                                        fn_suffix, header_sky[ifu_nr-1], 0./0.));
+                        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_cube(
+                                    cube_interim_object[ifu_nr-1],
+                                    fn_interim_object, fn_suffix,
+                                    header_data[ifu_nr-1], 0./0.));
+                        KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_cube(
+                                    cube_interim_sky[ifu_nr-1], fn_interim_sky,
+                                    fn_suffix, header_sky[ifu_nr-1], 0./0.));
                     }
 
-                    cpl_imagelist_delete(cube_data[ifu_nr-1]); cube_data[ifu_nr-1] = NULL;
-                    cpl_imagelist_delete(cube_noise[ifu_nr-1]); cube_noise[ifu_nr-1] = NULL;
-                    cpl_propertylist_delete(header_data[ifu_nr-1]); header_data[ifu_nr-1] = NULL;
-                    cpl_propertylist_delete(header_noise[ifu_nr-1]); header_noise[ifu_nr-1] = NULL;
+                    cpl_imagelist_delete(cube_data[ifu_nr-1]); 
+                    cube_data[ifu_nr-1] = NULL;
+                    cpl_imagelist_delete(cube_noise[ifu_nr-1]);
+                    cube_noise[ifu_nr-1] = NULL;
+                    cpl_propertylist_delete(header_data[ifu_nr-1]);
+                    header_data[ifu_nr-1] = NULL;
+                    cpl_propertylist_delete(header_noise[ifu_nr-1]);
+                    header_noise[ifu_nr-1] = NULL;
                     if (save_interims) {
                         cpl_imagelist_delete(cube_interim_object[ifu_nr-1]);
                         cube_interim_object[ifu_nr-1] = NULL;
@@ -2167,10 +1980,12 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 } // end for ifu_nr
                 cpl_free(fn_suffix); fn_suffix = NULL;
             } else {
-                cpl_msg_info("", "   > all IFUs invalid, don't save");
+                cpl_msg_info(__func__, "   > all IFUs invalid, don't save");
                 for (ifu_nr = 1; ifu_nr <= KMOS_NR_IFUS; ifu_nr++) {
-                    cpl_propertylist_delete(header_data[ifu_nr-1]); header_data[ifu_nr-1] = NULL;
-                    cpl_propertylist_delete(header_noise[ifu_nr-1]); header_noise[ifu_nr-1] = NULL;
+                    cpl_propertylist_delete(header_data[ifu_nr-1]); 
+                    header_data[ifu_nr-1] = NULL;
+                    cpl_propertylist_delete(header_noise[ifu_nr-1]); 
+                    header_noise[ifu_nr-1] = NULL;
                 }
             } // if (cube_counter_data > 0) {
 
@@ -2197,114 +2012,108 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
         }
         cpl_free(lcal); lcal = NULL;
 
-        //
-        // combine
-        //
+        /* Combine */
         suppress_index = 0;
         if (!no_combine) {
-            cpl_msg_info("", "Combining reconstructed objects");
-            cpl_msg_info("", " ");
-
-            nr_reconstructed_frames = cpl_frameset_count_tags(frameset, RECONSTRUCTED_CUBE);
-
-            if ( (mapping_mode == NULL) || ((mapping_mode != NULL) &&
-                                            ((ifus != NULL) || (strcmp(name, "") != 0)))
-               )
-            {
+            cpl_msg_info(__func__, "Combining reconstructed objects");
+            nr_reconstructed_frames = cpl_frameset_count_tags(frameset,
+                    RECONSTRUCTED_CUBE);
+            if ((mapping_mode == NULL) || ((mapping_mode != NULL) &&
+                        ((ifus != NULL) || (strcmp(name, "") != 0)))) {
                 // loop all available objects
                 for (i = 0; i < arm_name_struct->nrNames; i++) {
-                    cpl_msg_info("", "   > object: %s", arm_name_struct->names[i]);
+                    cpl_msg_info(__func__, 
+                            "   > object: %s", arm_name_struct->names[i]);
                     nr_data_alloc = arm_name_struct->namesCnt[i];
-                    KMO_TRY_EXIT_IF_NULL(
-                        cube_data =  (cpl_imagelist**)cpl_calloc(nr_data_alloc,
-                                                           sizeof(cpl_imagelist*)));
-                    KMO_TRY_EXIT_IF_NULL(
-                        cube_noise = (cpl_imagelist**)cpl_calloc(nr_data_alloc,
-                                                           sizeof(cpl_imagelist*)));
-                    KMO_TRY_EXIT_IF_NULL(
-                        header_data =  (cpl_propertylist**)cpl_calloc(nr_data_alloc,
-                                                        sizeof(cpl_propertylist*)));
-                    KMO_TRY_EXIT_IF_NULL(
-                        header_noise = (cpl_propertylist**)cpl_calloc(nr_data_alloc,
-                                                        sizeof(cpl_propertylist*)));
+                    KMO_TRY_EXIT_IF_NULL(cube_data=(cpl_imagelist**)cpl_calloc(
+                                nr_data_alloc, sizeof(cpl_imagelist*)));
+                    KMO_TRY_EXIT_IF_NULL(cube_noise=(cpl_imagelist**)cpl_calloc(
+                                nr_data_alloc, sizeof(cpl_imagelist*)));
+                    KMO_TRY_EXIT_IF_NULL(header_data=
+                            (cpl_propertylist**)cpl_calloc(nr_data_alloc,
+                                sizeof(cpl_propertylist*)));
+                    KMO_TRY_EXIT_IF_NULL(header_noise=
+                            (cpl_propertylist**)cpl_calloc(nr_data_alloc,
+                                sizeof(cpl_propertylist*)));
 
                     // setup cube-list and header-list for kmo_priv_combine()
                     cube_counter_data = 0;
                     cube_counter_noise = 0;
-                    KMO_TRY_EXIT_IF_NULL(
-                        tmp_frame = kmo_dfs_get_frame(frameset, RECONSTRUCTED_CUBE));
+                    KMO_TRY_EXIT_IF_NULL(tmp_frame = kmo_dfs_get_frame(frameset,
+                                RECONSTRUCTED_CUBE));
                     while (tmp_frame != NULL ) {
                         KMO_TRY_EXIT_IF_NULL(
                             fn_reconstr = cpl_frame_get_filename(tmp_frame));
-
-                        KMO_TRY_EXIT_IF_NULL(
-                            tmp_header = kmclipm_propertylist_load(fn_reconstr, 0));
-
+                        KMO_TRY_EXIT_IF_NULL(tmp_header = 
+                                kmclipm_propertylist_load(fn_reconstr, 0));
                         kmo_free_fits_desc(&desc1);
                         kmo_init_fits_desc(&desc1);
                         desc1 = kmo_identify_fits_header(fn_reconstr);
 
                         for (ifu_nr = 1; ifu_nr <= KMOS_NR_IFUS; ifu_nr++) {
                             // check if object-name equals the one in our list
-                            KMO_TRY_EXIT_IF_NULL(
-                                keyword = cpl_sprintf("%s%d%s", IFU_NAME_PREFIX,
-                                                      ifu_nr, IFU_NAME_POSTFIX));
-                            KMO_TRY_EXIT_IF_NULL(
-                                tmp_str = cpl_propertylist_get_string(tmp_header,
-                                                                      keyword));
+                            KMO_TRY_EXIT_IF_NULL(keyword = cpl_sprintf("%s%d%s",
+                                        IFU_NAME_PREFIX, ifu_nr, 
+                                        IFU_NAME_POSTFIX));
+                            KMO_TRY_EXIT_IF_NULL(tmp_str = 
+                                    cpl_propertylist_get_string(tmp_header,
+                                        keyword));
                             cpl_free(keyword); keyword = NULL;
 
-                            if ((strcmp(arm_name_struct->names[i], tmp_str) == 0) ||
-                                (strcmp(arm_name_struct->names[i], IFUS_USER_DEFINED) == 0))
-                            {
+                            if ((strcmp(arm_name_struct->names[i],tmp_str)==0)
+                                    || (strcmp(arm_name_struct->names[i],
+                                            IFUS_USER_DEFINED) == 0)) {
                                 // found object-IFU with matching name
                                 // load data & subheader
-                                index = kmo_identify_index(fn_reconstr, ifu_nr, FALSE);
+                                index = kmo_identify_index(fn_reconstr, ifu_nr,
+                                        FALSE);
                                 KMO_TRY_CHECK_ERROR_STATE();
 
                                 if (desc1.sub_desc[index-1].valid_data) {
                                     KMO_TRY_EXIT_IF_NULL(
                                         cube_data[cube_counter_data] =
                                             kmclipm_imagelist_load(fn_reconstr,
-                                                                   CPL_TYPE_FLOAT,
-                                                                   index));
+                                                CPL_TYPE_FLOAT, index));
+        /* Set cubes borders (1 pixel) to Nan to avoid jumps in combined cube */
                                     if (edge_nan) {
-                                        KMO_TRY_EXIT_IF_ERROR(
-                                            kmo_edge_nan(cube_data[cube_counter_data], ifu_nr));
+                                        KMO_TRY_EXIT_IF_ERROR(kmo_edge_nan(
+                                                    cube_data[cube_counter_data], 
+                                                    ifu_nr));
                                     }
 
                                     KMO_TRY_EXIT_IF_NULL(
                                         header_data[cube_counter_data] =
-                                            kmclipm_propertylist_load(fn_reconstr,
-                                                                      index));
-                                    cpl_propertylist_update_string(header_data[cube_counter_data],
-                                                                   "ESO PRO FRNAME",
-                                                                   fn_reconstr);
-                                    cpl_propertylist_update_int(header_data[cube_counter_data],
-                                                                "ESO PRO IFUNR",
-                                                                index);
+                                            kmclipm_propertylist_load(
+                                                fn_reconstr, index));
+                                    cpl_propertylist_update_string(
+                                            header_data[cube_counter_data],
+                                            "ESO PRO FRNAME", fn_reconstr);
+                                    cpl_propertylist_update_int(
+                                            header_data[cube_counter_data],
+                                            "ESO PRO IFUNR", ifu_nr);
                                     cube_counter_data++;
                                 }
 
                                 // load noise & subheader (if existing)
                                 if (desc1.ex_noise) {
-                                    index = kmo_identify_index(fn_reconstr, ifu_nr, TRUE);
+                                    index = kmo_identify_index(fn_reconstr,
+                                            ifu_nr, TRUE);
                                     KMO_TRY_CHECK_ERROR_STATE();
 
                                     if (desc1.sub_desc[index-1].valid_data) {
                                         KMO_TRY_EXIT_IF_NULL(
                                             cube_noise[cube_counter_noise] =
-                                                kmclipm_imagelist_load(fn_reconstr,
-                                                                       CPL_TYPE_FLOAT,
-                                                                       index));
+                                                kmclipm_imagelist_load(
+                                                    fn_reconstr, CPL_TYPE_FLOAT,
+                                                    index));
                                         if (edge_nan) {
                                             KMO_TRY_EXIT_IF_ERROR(
                                                 kmo_edge_nan(cube_noise[cube_counter_noise], ifu_nr));
                                         }
                                         KMO_TRY_EXIT_IF_NULL(
                                             header_noise[cube_counter_noise] =
-                                                kmclipm_propertylist_load(fn_reconstr,
-                                                                          index));
+                                                kmclipm_propertylist_load(
+                                                    fn_reconstr, index));
                                         cube_counter_noise++;
                                     }
                                 }
@@ -2321,83 +2130,81 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         if (cube_counter_data == cube_counter_noise) {
                             KMO_TRY_EXIT_IF_ERROR(
                                 kmo_priv_combine(cube_data,
-                                                 cube_noise,
-                                                 header_data,
-                                                 header_noise,
-                                                 cube_counter_data,
-                                                 cube_counter_noise,
-                                                 arm_name_struct->names[i],
-                                                 "",
-                                                 comb_method,
-                                                 smethod,
-                                                 fmethod,
-                                                 filename,
-                                                 cmethod,
-                                                 cpos_rej,
-                                                 cneg_rej,
-                                                 citer,
-                                                 cmin,
-                                                 cmax,
-                                                 extrapol_enum,
-                                                 flux,
-                                                 &combined_data,
-                                                 &combined_noise,
-                                                 &exp_mask));
+                                    cube_noise,
+                                    header_data,
+                                    header_noise,
+                                    cube_counter_data,
+                                    cube_counter_noise,
+                                    arm_name_struct->names[i],
+                                    "",
+                                    comb_method,
+                                    smethod,
+                                    fmethod,
+                                    filename,
+                                    cmethod,
+                                    cpos_rej,
+                                    cneg_rej,
+                                    citer,
+                                    cmin,
+                                    cmax,
+                                    extrapol_enum,
+                                    flux,
+                                    &combined_data,
+                                    &combined_noise,
+                                    &exp_mask));
                         } else if (cube_counter_noise == 0) {
-                            // if imethod == "CS"
                             KMO_TRY_EXIT_IF_ERROR(
                                 kmo_priv_combine(cube_data,
-                                                 NULL,
-                                                 header_data,
-                                                 header_noise,
-                                                 cube_counter_data,
-                                                 cube_counter_noise,
-                                                 arm_name_struct->names[i],
-                                                 "",
-                                                 comb_method,
-                                                 smethod,
-                                                 fmethod,
-                                                 filename,
-                                                 cmethod,
-                                                 cpos_rej,
-                                                 cneg_rej,
-                                                 citer,
-                                                 cmin,
-                                                 cmax,
-                                                 extrapol_enum,
-                                                 flux,
-                                                 &combined_data,
-                                                 &combined_noise,
-                                                 &exp_mask));
+                                    NULL,
+                                    header_data,
+                                    header_noise,
+                                    cube_counter_data,
+                                    cube_counter_noise,
+                                    arm_name_struct->names[i],
+                                    "",
+                                    comb_method,
+                                    smethod,
+                                    fmethod,
+                                    filename,
+                                    cmethod,
+                                    cpos_rej,
+                                    cneg_rej,
+                                    citer,
+                                    cmin,
+                                    cmax,
+                                    extrapol_enum,
+                                    flux,
+                                    &combined_data,
+                                    &combined_noise,
+                                    &exp_mask));
                         } else {
-                            KMO_TRY_ASSURE(1 == 0,
-                                           CPL_ERROR_ILLEGAL_INPUT,
-                                           "The number of cube-data and cube-noise "
-                                           "isn't the same (%d vs. %d)!",
-                                           cube_counter_data, cube_counter_noise);
+                            KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                                    "The number of cube-data and cube-noise "
+                                    "isn't the same (%d vs. %d)!",
+                                    cube_counter_data, cube_counter_noise);
                         }
                     } else if (cube_counter_data == 1) {
-                        cpl_msg_warning("", "There is only one reconstructed cube with "
-                                        "this object! Saving it as it is.");
-                        KMO_TRY_EXIT_IF_NULL(
-                            combined_data = cpl_imagelist_duplicate(cube_data[0]));
-                        KMO_TRY_EXIT_IF_NULL(
-                            tmpImg = cpl_imagelist_get(combined_data, 0));
-                        KMO_TRY_EXIT_IF_NULL(
-                            exp_mask = cpl_image_new(cpl_image_get_size_x(tmpImg),
-                                                     cpl_image_get_size_y(tmpImg),
-                                                     CPL_TYPE_FLOAT));
-                        KMO_TRY_EXIT_IF_ERROR(
-                            kmo_image_fill(exp_mask, 1.));
+                        cpl_msg_warning(__func__, 
+                                "There is only one reconstructed cube with "
+                                "this object! Saving it as it is.");
+                        KMO_TRY_EXIT_IF_NULL(combined_data = 
+                                cpl_imagelist_duplicate(cube_data[0]));
+                        KMO_TRY_EXIT_IF_NULL(tmpImg = 
+                                cpl_imagelist_get(combined_data, 0));
+                        KMO_TRY_EXIT_IF_NULL(exp_mask = cpl_image_new(
+                                    cpl_image_get_size_x(tmpImg),
+                                    cpl_image_get_size_y(tmpImg), 
+                                    CPL_TYPE_FLOAT));
+                        KMO_TRY_EXIT_IF_ERROR(kmo_image_fill(exp_mask, 1.));
 
                         if (cube_noise[0] != NULL) {
                             KMO_TRY_EXIT_IF_NULL(
-                                combined_noise = cpl_imagelist_duplicate(cube_noise[0]));
+                                combined_noise = cpl_imagelist_duplicate(
+                                    cube_noise[0]));
                         }
                     } else {
-                        KMO_TRY_ASSURE(1==0,
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "No cubes found with this object name!");
+                        KMO_TRY_ASSURE(1==0, CPL_ERROR_ILLEGAL_INPUT,
+                                "No cubes found with this object name!");
                     } // end if (cube_counter_data > 1)
 
                     fn_out = COMBINED_CUBE;
@@ -2406,22 +2213,21 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         char tmp_suffix[1024];
                         tmp_suffix[0] = '\0';
 
-                        if (arm_name_struct->telluricCnt[i] == arm_name_struct->namesCnt[i]) {
+                        if (arm_name_struct->telluricCnt[i] == 
+                                arm_name_struct->namesCnt[i]) {
                             strcat(tmp_suffix, "_telluric");
                         }
-                        if (has_illum_corr) {
-                            strcat(tmp_suffix, "_illum");
-                        }
-                        if (sky_tweak) {
-                            strcat(tmp_suffix, "_skytweak");
-                        }
+                        if (has_illum_corr)     strcat(tmp_suffix, "_illum");
+                        if (sky_tweak)          strcat(tmp_suffix, "_skytweak");
 
                         if (strlen(tmp_suffix) > 0) {
                             KMO_TRY_EXIT_IF_NULL(
-                                fn_suffix = cpl_sprintf("_%s_%s", arm_name_struct->names[i], tmp_suffix));
+                                fn_suffix = cpl_sprintf("_%s_%s", 
+                                    arm_name_struct->names[i], tmp_suffix));
                         } else {
                             KMO_TRY_EXIT_IF_NULL(
-                                fn_suffix = cpl_sprintf("_%s", arm_name_struct->names[i]));
+                                fn_suffix = cpl_sprintf("_%s", 
+                                    arm_name_struct->names[i]));
                         }
                     } else {
                         KMO_TRY_EXIT_IF_NULL(
@@ -2429,43 +2235,47 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     }
 
                     // save combined cube
-                    KMO_TRY_EXIT_IF_NULL(
-                        tmp_frame = kmo_dfs_get_frame(frameset, RECONSTRUCTED_CUBE));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_main_header(frameset, fn_out, fn_suffix, tmp_frame, NULL, parlist, cpl_func));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_main_header(frameset, fn_out_mask, fn_suffix, tmp_frame, NULL, parlist, cpl_func));
-
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_cube(combined_data, fn_out, fn_suffix, header_data[0], 0./0.));
-                    KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_image(exp_mask, fn_out_mask, fn_suffix, header_data[0], 0./0.));
-
-    //                if (combined_noise != NULL) {
-                        if (header_noise[0] == NULL) {
-                            KMO_TRY_EXIT_IF_NULL(
-                                header_noise[0] = cpl_propertylist_duplicate(header_data[0]));
-
-                            KMO_TRY_EXIT_IF_NULL(
-                                tmp_str = cpl_propertylist_get_string(header_data[0], EXTNAME));
-                            KMO_TRY_EXIT_IF_ERROR(
-                                kmo_extname_extractor(tmp_str, &ft, &tmp_int, content));
-                            KMO_TRY_EXIT_IF_NULL(
-                                extname = kmo_extname_creator(ifu_frame, tmp_int, EXT_NOISE));
-                            KMO_TRY_EXIT_IF_ERROR(
-                                kmclipm_update_property_string(header_noise[0], EXTNAME, extname,
-                                                               "FITS extension name"));
-                            cpl_free(extname); extname = NULL;
-                        }
-                        KMO_TRY_EXIT_IF_ERROR(
-                            kmo_dfs_save_cube(combined_noise, fn_out, fn_suffix, header_noise[0], 0./0.));
-    //                }
+                    KMO_TRY_EXIT_IF_NULL(tmp_frame = 
+                            kmo_dfs_get_frame(frameset, RECONSTRUCTED_CUBE));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, 
+                                fn_out, fn_suffix, tmp_frame, NULL, parlist, 
+                                cpl_func));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, 
+                                fn_out_mask, fn_suffix, tmp_frame, NULL, 
+                                parlist, cpl_func));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_cube(combined_data, 
+                                fn_out, fn_suffix, header_data[0], 0./0.));
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_image(exp_mask, 
+                                fn_out_mask, fn_suffix, header_data[0], 0./0.));
+                        
+                    if (header_noise[0] == NULL) {
+                        KMO_TRY_EXIT_IF_NULL(header_noise[0] = 
+                                cpl_propertylist_duplicate(header_data[0]));
+
+                        KMO_TRY_EXIT_IF_NULL(tmp_str = 
+                                cpl_propertylist_get_string(header_data[0], 
+                                    EXTNAME));
+                        KMO_TRY_EXIT_IF_ERROR(kmo_extname_extractor(tmp_str, 
+                                    &ft, &tmp_int, content));
+                        KMO_TRY_EXIT_IF_NULL(extname = kmo_extname_creator(
+                                    ifu_frame, tmp_int, EXT_NOISE));
+                        KMO_TRY_EXIT_IF_ERROR(kmclipm_update_property_string(
+                                    header_noise[0], EXTNAME, extname,
+                                    "FITS extension name"));
+                        cpl_free(extname); extname = NULL;
+                    }
+                    KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_cube(combined_noise, 
+                                fn_out, fn_suffix, header_noise[0], 0./0.));
 
                     for (jj = 0; jj < nr_data_alloc; jj++) {
-                        cpl_imagelist_delete(cube_data[jj]); cube_data[jj] = NULL;
-                        cpl_imagelist_delete(cube_noise[jj]); cube_noise[jj] = NULL;
-                        cpl_propertylist_delete(header_data[jj]); header_data[jj] = NULL;
-                        cpl_propertylist_delete(header_noise[jj]); header_noise[jj] = NULL;
+                        cpl_imagelist_delete(cube_data[jj]); 
+                        cube_data[jj] = NULL;
+                        cpl_imagelist_delete(cube_noise[jj]); 
+                        cube_noise[jj] = NULL;
+                        cpl_propertylist_delete(header_data[jj]); 
+                        header_data[jj] = NULL;
+                        cpl_propertylist_delete(header_noise[jj]); 
+                        header_noise[jj] = NULL;
                     }
                     cpl_free(cube_data);    cube_data = NULL;
                     cpl_free(cube_noise);   cube_noise = NULL;
@@ -2479,23 +2289,22 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
             } else {
                 // we are in mapping_mode
                 nr_data_alloc = nr_reconstructed_frames*KMOS_NR_IFUS;
-                KMO_TRY_EXIT_IF_NULL(
-                    cube_data = (cpl_imagelist**)cpl_calloc(nr_data_alloc, sizeof(cpl_imagelist*)));
-                KMO_TRY_EXIT_IF_NULL(
-                    cube_noise = (cpl_imagelist**)cpl_calloc(nr_data_alloc, sizeof(cpl_imagelist*)));
-                KMO_TRY_EXIT_IF_NULL(
-                    header_data = (cpl_propertylist**)cpl_calloc(nr_data_alloc, sizeof(cpl_propertylist*)));
-                KMO_TRY_EXIT_IF_NULL(
-                    header_noise = (cpl_propertylist**)cpl_calloc(nr_data_alloc, sizeof(cpl_propertylist*)));
+                KMO_TRY_EXIT_IF_NULL(cube_data = (cpl_imagelist**)cpl_calloc(
+                            nr_data_alloc, sizeof(cpl_imagelist*)));
+                KMO_TRY_EXIT_IF_NULL(cube_noise = (cpl_imagelist**)cpl_calloc(
+                            nr_data_alloc, sizeof(cpl_imagelist*)));
+                KMO_TRY_EXIT_IF_NULL(header_data=(cpl_propertylist**)cpl_calloc(
+                            nr_data_alloc, sizeof(cpl_propertylist*)));
+                KMO_TRY_EXIT_IF_NULL(header_noise=(cpl_propertylist**)cpl_calloc(
+                            nr_data_alloc, sizeof(cpl_propertylist*)));
 
                 cube_counter_data = 0;
                 cube_counter_noise = 0;
-                KMO_TRY_EXIT_IF_NULL(
-                    tmp_frame = kmo_dfs_get_frame(frameset, RECONSTRUCTED_CUBE));
+                KMO_TRY_EXIT_IF_NULL(tmp_frame = 
+                        kmo_dfs_get_frame(frameset, RECONSTRUCTED_CUBE));
                 while (tmp_frame != NULL ) {
                     KMO_TRY_EXIT_IF_NULL(
                         fn_reconstr = cpl_frame_get_filename(tmp_frame));
-
                     KMO_TRY_EXIT_IF_NULL(
                         tmp_header = kmclipm_propertylist_load(fn_reconstr, 0));
 
@@ -2507,17 +2316,19 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         KMO_TRY_CHECK_ERROR_STATE();
 
                         if (desc1.sub_desc[index-1].valid_data) {
-                            KMO_TRY_EXIT_IF_NULL(
-                                cube_data[cube_counter_data] =
-                                    kmclipm_imagelist_load(fn_reconstr, CPL_TYPE_FLOAT, index));
+                            KMO_TRY_EXIT_IF_NULL(cube_data[cube_counter_data] =
+                                    kmclipm_imagelist_load(fn_reconstr, 
+                                        CPL_TYPE_FLOAT, index));
                             if (edge_nan) {
                                 KMO_TRY_EXIT_IF_ERROR(
-                                    kmo_edge_nan(cube_data[cube_counter_data], ifu_nr));
+                                    kmo_edge_nan(cube_data[cube_counter_data], 
+                                        ifu_nr));
                             }
 
                             if (fast_mode) {
-                                KMO_TRY_EXIT_IF_NULL(
-                                    tmpImg = cpl_imagelist_collapse_median_create(cube_data[cube_counter_data]));
+                                KMO_TRY_EXIT_IF_NULL(tmpImg = 
+                                        cpl_imagelist_collapse_median_create(
+                                            cube_data[cube_counter_data]));
                                 KMO_TRY_EXIT_IF_NULL(
                                     tmpCube = cpl_imagelist_new());
                                 KMO_TRY_EXIT_IF_ERROR(
@@ -2529,28 +2340,34 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                             KMO_TRY_EXIT_IF_NULL(
                                 header_data[cube_counter_data] =
                                     kmclipm_propertylist_load(fn_reconstr, index));
-                            cpl_propertylist_update_string(header_data[cube_counter_data], "ESO PRO FRNAME", fn_reconstr);
-                            cpl_propertylist_update_int(header_data[cube_counter_data], "ESO PRO IFUNR", index);
+                            cpl_propertylist_update_string(
+                                    header_data[cube_counter_data], 
+                                    "ESO PRO FRNAME", fn_reconstr);
+                            cpl_propertylist_update_int(
+                                    header_data[cube_counter_data], 
+                                    "ESO PRO IFUNR", ifu_nr);
                             cube_counter_data++;
                         }
 
                         // load noise & subheader (if existing)
                         if (desc1.ex_noise) {
-                            index = kmo_identify_index(fn_reconstr, ifu_nr, TRUE);
+                            index = kmo_identify_index(fn_reconstr,ifu_nr,TRUE);
                             KMO_TRY_CHECK_ERROR_STATE();
                             if (desc1.sub_desc[index-1].valid_data) {
                                 KMO_TRY_EXIT_IF_NULL(
                                     cube_noise[cube_counter_noise] =
-                                        kmclipm_imagelist_load(fn_reconstr, CPL_TYPE_FLOAT, index));
+                                        kmclipm_imagelist_load(fn_reconstr, 
+                                            CPL_TYPE_FLOAT, index));
 
                                 if (edge_nan) {
-                                    KMO_TRY_EXIT_IF_ERROR(
-                                        kmo_edge_nan(cube_noise[cube_counter_noise], ifu_nr));
+                                    KMO_TRY_EXIT_IF_ERROR(kmo_edge_nan(
+                                                cube_noise[cube_counter_noise],
+                                                ifu_nr));
                                 }
 
                                 if (fast_mode) {
-                                    KMO_TRY_EXIT_IF_NULL(
-                                        tmpImg = cpl_imagelist_collapse_median_create(cube_noise[cube_counter_noise]));
+                                    KMO_TRY_EXIT_IF_NULL(tmpImg = 
+                                            cpl_imagelist_collapse_median_create(cube_noise[cube_counter_noise]));
                                     KMO_TRY_EXIT_IF_NULL(
                                         tmpCube = cpl_imagelist_new());
                                     KMO_TRY_EXIT_IF_ERROR(
@@ -2559,7 +2376,9 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                                     cube_noise[cube_counter_noise] = tmpCube;
                                 }
                                 KMO_TRY_EXIT_IF_NULL(
-                                    header_noise[cube_counter_noise] = kmclipm_propertylist_load(fn_reconstr, index));
+                                    header_noise[cube_counter_noise] = 
+                                    kmclipm_propertylist_load(fn_reconstr,
+                                        index));
                                 cube_counter_noise++;
                             }
                         }
@@ -2575,70 +2394,69 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     if (cube_counter_data == cube_counter_noise) {
                         KMO_TRY_EXIT_IF_ERROR(
                             kmo_priv_combine(cube_data,
-                                             cube_noise,
-                                             header_data,
-                                             header_noise,
-                                             cube_counter_data,
-                                             cube_counter_noise,
-                                             mapping_mode,
-                                             "",
-                                             comb_method,
-                                             smethod,
-                                             fmethod,
-                                             filename,
-                                             cmethod,
-                                             cpos_rej,
-                                             cneg_rej,
-                                             citer,
-                                             cmin,
-                                             cmax,
-                                             extrapol_enum,
-                                             flux,
-                                             &combined_data,
-                                             &combined_noise,
-                                             NULL));
+                                cube_noise,
+                                header_data,
+                                header_noise,
+                                cube_counter_data,
+                                cube_counter_noise,
+                                mapping_mode,
+                                "",
+                                comb_method,
+                                smethod,
+                                fmethod,
+                                filename,
+                                cmethod,
+                                cpos_rej,
+                                cneg_rej,
+                                citer,
+                                cmin,
+                                cmax,
+                                extrapol_enum,
+                                flux,
+                                &combined_data,
+                                &combined_noise,
+                                NULL));
                     } else if (cube_counter_noise == 0) {
-                        // if imethod == "CS"
                         KMO_TRY_EXIT_IF_ERROR(
                             kmo_priv_combine(cube_data,
-                                             NULL,
-                                             header_data,
-                                             header_noise,
-                                             cube_counter_data,
-                                             cube_counter_noise,
-                                             mapping_mode,
-                                             "",
-                                             comb_method,
-                                             smethod,
-                                             fmethod,
-                                             filename,
-                                             cmethod,
-                                             cpos_rej,
-                                             cneg_rej,
-                                             citer,
-                                             cmin,
-                                             cmax,
-                                             extrapol_enum,
-                                             flux,
-                                             &combined_data,
-                                             &combined_noise,
-                                             NULL));
+                                NULL,
+                                header_data,
+                                header_noise,
+                                cube_counter_data,
+                                cube_counter_noise,
+                                mapping_mode,
+                                "",
+                                comb_method,
+                                smethod,
+                                fmethod,
+                                filename,
+                                cmethod,
+                                cpos_rej,
+                                cneg_rej,
+                                citer,
+                                cmin,
+                                cmax,
+                                extrapol_enum,
+                                flux,
+                                &combined_data,
+                                &combined_noise,
+                                NULL));
                     } else {
-                        KMO_TRY_ASSURE(1 == 0,
-                                       CPL_ERROR_ILLEGAL_INPUT,
-                                       "The number of cube-data and cube-noise "
-                                       "isn't the same (%d vs. %d)!",
-                                       cube_counter_data, cube_counter_noise);
+                        KMO_TRY_ASSURE(1 == 0, CPL_ERROR_ILLEGAL_INPUT,
+                                "The number of cube-data and cube-noise "
+                                "isn't the same (%d vs. %d)!",
+                                cube_counter_data, cube_counter_noise);
                     }
                 } else {
-                    cpl_msg_warning("", "There is only one reconstructed cube! "
-                                        "Saving it as it is.");
+                    cpl_msg_warning(__func__, 
+                            "There is only one reconstructed cube - Save it");
                     KMO_TRY_EXIT_IF_NULL(
                         combined_data = cpl_imagelist_duplicate(cube_data[0]));
 
                     if (cube_noise[0] != NULL) {
                         KMO_TRY_EXIT_IF_NULL(
-                            combined_noise = cpl_imagelist_duplicate(cube_noise[0]));
+                            combined_noise = cpl_imagelist_duplicate(
+                                cube_noise[0]));
                     }
                 }
 
@@ -2647,41 +2465,45 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     fn_suffix = cpl_sprintf("_%s", mapping_mode));
 
                 // save combined cube
-                KMO_TRY_EXIT_IF_NULL(
-                    tmp_frame = kmo_dfs_get_frame(frameset, RECONSTRUCTED_CUBE));
+                KMO_TRY_EXIT_IF_NULL(tmp_frame = kmo_dfs_get_frame(frameset,
+                            RECONSTRUCTED_CUBE));
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_main_header(frameset, fn_out, fn_suffix, tmp_frame,
-                                             NULL, parlist, cpl_func));
+                    kmo_dfs_save_main_header(frameset, fn_out, fn_suffix, 
+                        tmp_frame, NULL, parlist, cpl_func));
 
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_cube(combined_data, fn_out, fn_suffix, header_data[0], 0./0.));
+                    kmo_dfs_save_cube(combined_data, fn_out, fn_suffix,
+                        header_data[0], 0./0.));
 
-    //            if (combined_noise != NULL) {
-                    if (header_noise[0] == NULL) {
-                        KMO_TRY_EXIT_IF_NULL(
-                            header_noise[0] =
-                                 cpl_propertylist_duplicate(header_data[0]));
+                if (header_noise[0] == NULL) {
+                    KMO_TRY_EXIT_IF_NULL(
+                        header_noise[0] =
+                             cpl_propertylist_duplicate(header_data[0]));
 
-                        KMO_TRY_EXIT_IF_NULL(
-                            tmp_str = cpl_propertylist_get_string(header_data[0], EXTNAME));
-                        KMO_TRY_EXIT_IF_ERROR(
-                            kmo_extname_extractor(tmp_str, &ft, &tmp_int, content));
-                        KMO_TRY_EXIT_IF_NULL(
-                            extname = kmo_extname_creator(ifu_frame, tmp_int, EXT_NOISE));
-                        KMO_TRY_EXIT_IF_ERROR(
-                            kmclipm_update_property_string(header_noise[0], EXTNAME, extname,
-                                                           "FITS extension name"));
-                        cpl_free(extname); extname = NULL;
-                    }
+                    KMO_TRY_EXIT_IF_NULL(
+                        tmp_str = cpl_propertylist_get_string(header_data[0],
+                            EXTNAME));
+                    KMO_TRY_EXIT_IF_ERROR(
+                        kmo_extname_extractor(tmp_str, &ft, &tmp_int, content));
+                    KMO_TRY_EXIT_IF_NULL(
+                        extname = kmo_extname_creator(ifu_frame, tmp_int,
+                            EXT_NOISE));
                     KMO_TRY_EXIT_IF_ERROR(
-                        kmo_dfs_save_cube(combined_noise, fn_out, fn_suffix, header_noise[0], 0./0.));
-    //            }
+                        kmclipm_update_property_string(header_noise[0], EXTNAME,
+                            extname, "FITS extension name"));
+                    cpl_free(extname); extname = NULL;
+                }
+                KMO_TRY_EXIT_IF_ERROR(
+                    kmo_dfs_save_cube(combined_noise, fn_out, fn_suffix,
+                        header_noise[0], 0./0.));
 
                 for (i = 0; i < nr_data_alloc; i++) {
                     cpl_imagelist_delete(cube_data[i]); cube_data[i] = NULL;
                     cpl_imagelist_delete(cube_noise[i]); cube_noise[i] = NULL;
-                    cpl_propertylist_delete(header_data[i]); header_data[i] = NULL;
-                    cpl_propertylist_delete(header_noise[i]); header_noise[i] = NULL;
+                    cpl_propertylist_delete(header_data[i]); 
+                    header_data[i] = NULL;
+                    cpl_propertylist_delete(header_noise[i]); 
+                    header_noise[i] = NULL;
                 }
                 cpl_free(cube_data);    cube_data = NULL;
                 cpl_free(cube_noise);   cube_noise = NULL;
@@ -2692,9 +2514,8 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 cpl_imagelist_delete(combined_noise); combined_noise = NULL;
             } // if mapping_mode
         } else {
-            cpl_msg_info("", "NOT combining reconstructed objects (--no_combine is set)");
+            cpl_msg_info("", "Reconstructed objects are not combined");
         } // if (!no_combine)
-
         cpl_msg_info("", "-------------------------------------------");
     }
     KMO_CATCH
@@ -2702,28 +2523,31 @@ static int kmo_sci_red(cpl_parameterlist *parlist, cpl_frameset *frameset)
         KMO_CATCH_MSG();
         ret_val = -1;
     }
-
     if (cube_data != NULL) {
         for (ifu_nr = 1; ifu_nr <= nr_data_alloc; ifu_nr++) {
-            cpl_imagelist_delete(cube_data[ifu_nr-1]); cube_data[ifu_nr-1] = NULL;
+            cpl_imagelist_delete(cube_data[ifu_nr-1]); 
+            cube_data[ifu_nr-1] = NULL;
         }
     }
     cpl_free(cube_data);    cube_data = NULL;
     if (cube_noise != NULL) {
         for (ifu_nr = 1; ifu_nr <= nr_data_alloc; ifu_nr++) {
-            cpl_imagelist_delete(cube_noise[ifu_nr-1]); cube_noise[ifu_nr-1] = NULL;
+            cpl_imagelist_delete(cube_noise[ifu_nr-1]); 
+            cube_noise[ifu_nr-1] = NULL;
         }
     }
     cpl_free(cube_noise);   cube_noise = NULL;
     if (header_data != NULL) {
         for (ifu_nr = 1; ifu_nr <= nr_data_alloc; ifu_nr++) {
-            cpl_propertylist_delete(header_data[ifu_nr-1]); header_data[ifu_nr-1] = NULL;
+            cpl_propertylist_delete(header_data[ifu_nr-1]);
+            header_data[ifu_nr-1] = NULL;
         }
     }
     cpl_free(header_data);  header_data = NULL;
     if (header_noise != NULL) {
         for (ifu_nr = 1; ifu_nr <= nr_data_alloc; ifu_nr++) {
-            cpl_propertylist_delete(header_noise[ifu_nr-1]); header_noise[ifu_nr-1] = NULL;
+            cpl_propertylist_delete(header_noise[ifu_nr-1]);
+            header_noise[ifu_nr-1] = NULL;
         }
     }
     cpl_free(header_noise); header_noise = NULL;
diff --git a/recipes/kmo_shift.c b/recipes/kmo_shift.c
index de5a94d..bfc9eab 100644
--- a/recipes/kmo_shift.c
+++ b/recipes/kmo_shift.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_shift.c,v 1.14 2013-06-07 15:41:21 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-06-07 15:41:21 $
- * $Revision: 1.14 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -138,7 +130,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Shift a cube spatially",
                         kmo_shift_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_shift_create,
                         kmo_shift_exec,
diff --git a/recipes/kmo_sky_mask.c b/recipes/kmo_sky_mask.c
index cf32e2e..1c9dd84 100644
--- a/recipes/kmo_sky_mask.c
+++ b/recipes/kmo_sky_mask.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_sky_mask.c,v 1.9 2013-08-02 15:46:38 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-08-02 15:46:38 $
- * $Revision: 1.9 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -146,7 +138,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "pixels can be considered as sky.",
                         kmo_sky_mask_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_sky_mask_create,
                         kmo_sky_mask_exec,
@@ -398,22 +390,24 @@ static int kmo_sky_mask(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     data_in = kmo_dfs_load_cube(frameset, "0", devnr, FALSE));
 
                 if (ranges != NULL) {
-                    ifu_crpix = cpl_propertylist_get_double(sub_header_data,
-                                                            CRPIX3);
+                    ifu_crpix = cpl_propertylist_get_double(sub_header_data, CRPIX3);
                     KMO_TRY_CHECK_ERROR_STATE_MSG(
                                    "CRPIX3 keyword in FITS-header is missing!");
 
-                    ifu_crval = cpl_propertylist_get_double(sub_header_data,
-                                                            CRVAL3);
+                    ifu_crval = cpl_propertylist_get_double(sub_header_data, CRVAL3);
                     KMO_TRY_CHECK_ERROR_STATE_MSG(
                                    "CRVAL3 keyword in FITS-header is missing!");
 
-                    ifu_cdelt = cpl_propertylist_get_double(sub_header_data,
-                                                            CDELT3);
+                    ifu_cdelt = cpl_propertylist_get_double(sub_header_data, CDELT3);
                     KMO_TRY_CHECK_ERROR_STATE_MSG(
                                    "CDELT3 keyword in FITS-header is missing!");
                 }
 
+                cpl_propertylist_erase(sub_header_data, CRPIX3);
+                cpl_propertylist_erase(sub_header_data, CRVAL3);
+                cpl_propertylist_erase(sub_header_data, CDELT3);
+                cpl_propertylist_erase(sub_header_data, CTYPE3);
+
                 // calc mode and noise
                 KMO_TRY_EXIT_IF_NULL(
                     data_out = kmo_calc_sky_mask(data_in,
diff --git a/recipes/kmo_sky_tweak.c b/recipes/kmo_sky_tweak.c
index bc0a03b..98df4c2 100644
--- a/recipes/kmo_sky_tweak.c
+++ b/recipes/kmo_sky_tweak.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_sky_tweak.c,v 1.4 2013-09-13 09:10:28 erw Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,17 +17,14 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: erw $
- * $Date: 2013-09-13 09:10:28 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
+/*-----------------------------------------------------------------------------
+ *                                  Includes
+ *----------------------------------------------------------------------------*/
+
 #include <cpl.h>
 #include <cpl_wcs.h>
 
@@ -37,11 +33,19 @@
 #include "kmo_constants.h"
 #include "kmo_priv_sky_tweak.h"
 
+/*-----------------------------------------------------------------------------
+ *                          Functions prototypes
+ *----------------------------------------------------------------------------*/
+
 static int kmo_sky_tweak_create(cpl_plugin *);
 static int kmo_sky_tweak_exec(cpl_plugin *);
 static int kmo_sky_tweak_destroy(cpl_plugin *);
 static int kmo_sky_tweak(cpl_parameterlist *, cpl_frameset *);
 
+/*-----------------------------------------------------------------------------
+ *                          Static variables
+ *----------------------------------------------------------------------------*/
+
 static char kmo_sky_tweak_description[] =
 " This recipes is an advanced tool to remove OH sky lines.\n"
 "\n"
@@ -51,32 +55,29 @@ static char kmo_sky_tweak_description[] =
 "If set to TRUE subtract the thermal background from the input cube.\n"
 "Default value is TRUE.\n"
 "\n"
-"-------------------------------------------------------------------------------\n"
+"---------------------------------------------------------------------------\n"
 "  Input files:\n"
-"\n"
-"   DO                    KMOS                                                  \n"
-"   category              Type   Explanation                    Required #Frames\n"
-"   --------              -----  -----------                    -------- -------\n"
-"   CUBE_OBJECT           F3I    object cubes                       Y      >=1  \n"
-"   CUBE_SKY              F3I    sky cube                           Y       1   \n"
+"   DO CATG           Type   Explanation                    Required #Frames\n"
+"   --------          -----  -----------                    -------- -------\n"
+"   CUBE_OBJECT       F3I    object cubes                       Y      >=1  \n"
+"   CUBE_SKY          F3I    sky cube                           Y       1   \n"
 "\n"
 "  Output files:\n"
-"\n"
-"   DO                    KMOS\n"
-"   category              Type   Explanation\n"
-"   --------              -----  -----------\n"
-"   OBJECT_S              F3I    Corrected object cubes\n"
-"-------------------------------------------------------------------------------\n"
+"   DO_CATG           Type   Explanation\n"
+"   --------          -----  -----------\n"
+"   OBJECT_S          F3I    Corrected object cubes\n"
+"---------------------------------------------------------------------------\n"
 "\n";
 
+/*----------------------------------------------------------------------------*/
 /**
- * @defgroup kmo_sky_tweak kmo_sky_tweak OH line removal
- *
- * See recipe description for details.
+  @defgroup kmo_sky_tweak kmo_sky_tweak OH line removal
  */
+/*----------------------------------------------------------------------------*/
 
 /**@{*/
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Build the list of available plugins, for this module.
   @param    list    the plugin list
@@ -85,30 +86,30 @@ static char kmo_sky_tweak_description[] =
   Create the recipe instance and make it available to the application using the
   interface. This function is exported.
 */
+/*----------------------------------------------------------------------------*/
 int cpl_plugin_get_info(cpl_pluginlist *list)
 {
     cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
     cpl_plugin *plugin = &recipe->interface;
 
     cpl_plugin_init(plugin,
-                        CPL_PLUGIN_API,
-                        KMOS_BINARY_VERSION,
-                        CPL_PLUGIN_TYPE_RECIPE,
-                        "kmo_sky_tweak",
-                        "Removal of OH sky lines",
-                        kmo_sky_tweak_description,
-                        "Erich Wiezorrek",
-                        "kmos-spark at mpe.mpg.de",
-                        kmos_get_license(),
-                        kmo_sky_tweak_create,
-                        kmo_sky_tweak_exec,
-                        kmo_sky_tweak_destroy);
-
+            CPL_PLUGIN_API,
+            KMOS_BINARY_VERSION,
+            CPL_PLUGIN_TYPE_RECIPE,
+            "kmo_sky_tweak",
+            "Removal of OH sky lines",
+            kmo_sky_tweak_description,
+            "Erich Wiezorrek",
+            "usd-help at eso.org",
+            kmos_get_license(),
+            kmo_sky_tweak_create,
+            kmo_sky_tweak_exec,
+            kmo_sky_tweak_destroy);
     cpl_pluginlist_append(list, plugin);
-
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Setup the recipe options
   @param    plugin  the plugin
@@ -116,6 +117,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
 
   Defining the command-line/configuration parameters for the recipe.
 */
+/*----------------------------------------------------------------------------*/
 static int kmo_sky_tweak_create(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -133,13 +135,10 @@ static int kmo_sky_tweak_create(cpl_plugin *plugin)
     /* Fill the parameters list */
 
     /* --tbsub */
-    p = cpl_parameter_new_value("kmos.kmo_sky_tweak.tbsub",
-                                CPL_TYPE_BOOL,
-                                "Subtract thermal background from input cube."
-                                "(TRUE (apply) or "
-                                "FALSE (don't apply)",
-                                "kmos.kmo_sky_tweak",
-                                TRUE);
+    p = cpl_parameter_new_value("kmos.kmo_sky_tweak.tbsub", CPL_TYPE_BOOL,
+            "Subtract thermal background from input cube."
+            "(TRUE (apply) or FALSE (don't apply)",
+            "kmos.kmo_sky_tweak", TRUE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "tbsub");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
@@ -148,11 +147,13 @@ static int kmo_sky_tweak_create(cpl_plugin *plugin)
 
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Execute the plugin instance given by the interface
   @param    plugin  the plugin
   @return   0 if everything is ok
 */
+/*----------------------------------------------------------------------------*/
 static int kmo_sky_tweak_exec(cpl_plugin *plugin)
 {
     cpl_recipe  *recipe;
@@ -165,11 +166,13 @@ static int kmo_sky_tweak_exec(cpl_plugin *plugin)
     return kmo_sky_tweak(recipe->parameters, recipe->frames);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Destroy what has been created by the 'create' function
   @param    plugin  the plugin
   @return   0 if everything is ok
 */
+/*----------------------------------------------------------------------------*/
 static int kmo_sky_tweak_destroy(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -183,20 +186,20 @@ static int kmo_sky_tweak_destroy(cpl_plugin *plugin)
     return 0 ;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Interpret the command line options and execute the data processing
   @param    parlist     the parameters list
   @param    frameset   the frames list
   @return   0 if everything is ok
-
   Possible _cpl_error_code_ set in this function:
-
-    @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
-                                     if first operand not 3d or
-                                     if second operand not valid
-    @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands do
-                                     not match
+  @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
+                                   if first operand not 3d or
+                                   if second operand not valid
+  @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands do
+                                   not match
 */
+/*----------------------------------------------------------------------------*/
 static int kmo_sky_tweak(cpl_parameterlist *parlist, cpl_frameset *frameset)
 {
     int              ret_val                = 0;
@@ -206,7 +209,8 @@ static int kmo_sky_tweak(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      nr_obj_devices         = 0,
                      nr_sky_devices         = 0,
                      ifu_nr                 = 0,
-                     index                  = 0,
+                     sky_index              = 0,
+                     obj_index              = 0,
                      tbsub                  = TRUE;
     const char       *obj_fn                = NULL,
                      *sky_fn                = NULL;
@@ -214,11 +218,9 @@ static int kmo_sky_tweak(cpl_parameterlist *parlist, cpl_frameset *frameset)
     cpl_frame        **object_frames        = NULL,
                      *object_frame          = NULL,
                      *sky_frame             = NULL;
-    cpl_imagelist    *obj_data              = NULL/*,
-                     *obj_noise             = NULL*/,
+    cpl_imagelist    *obj_data              = NULL,
                      *sky_data              = NULL,
-                     *tweaked_data          = NULL/*,
-                     *tweaked_noise         = NULL*/;
+                     *tweaked_data          = NULL;
     cpl_propertylist *main_header           = NULL,
                      *sub_header            = NULL;
     main_fits_desc   obj_fits_desc,
@@ -226,27 +228,21 @@ static int kmo_sky_tweak(cpl_parameterlist *parlist, cpl_frameset *frameset)
 
     KMO_TRY
     {
-        //
-        // check frameset
-        //
-        KMO_TRY_ASSURE((parlist != NULL) &&
-                       (frameset != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
-
-        KMO_TRY_ASSURE(! ((cpl_frameset_count_tags(frameset, CUBE_OBJECT) == 0) &&
-                          (cpl_frameset_count_tags(frameset, CUBE_SKY) == 0)    ),
-                          CPL_ERROR_FILE_NOT_FOUND,
-                          "CUBE_OBJECT or  CUBE_SKY frames missing in "
-                          "frameset!!");
+        /* Check entries */
+        KMO_TRY_ASSURE((parlist != NULL) && (frameset != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided");
+
+        KMO_TRY_ASSURE(!((cpl_frameset_count_tags(frameset, CUBE_OBJECT) == 0)
+                    && (cpl_frameset_count_tags(frameset, CUBE_SKY) == 0)),
+                CPL_ERROR_FILE_NOT_FOUND,
+                "CUBE_OBJECT or CUBE_SKY frames missing in frameset");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, CUBE_SKY) == 1,
-                       CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one CUBE_SKY frame is expected in frameset!");
+                CPL_ERROR_FILE_NOT_FOUND,
+                "Exactly one CUBE_SKY frame is expected in frameset");
 
         KMO_TRY_ASSURE(kmo_dfs_set_groups(frameset, "kmo_sky_tweak") == 1,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Cannot identify RAW and CALIB frames!");
+                CPL_ERROR_ILLEGAL_INPUT,"Cannot identify RAW and CALIB frames");
 
         tbsub = kmo_dfs_get_parameter_bool(parlist, "kmos.kmo_sky_tweak.tbsub");
         KMO_TRY_CHECK_ERROR_STATE();
@@ -255,116 +251,118 @@ static int kmo_sky_tweak(cpl_parameterlist *parlist, cpl_frameset *frameset)
         KMO_TRY_CHECK_ERROR_STATE();
 
         KMO_TRY_EXIT_IF_NULL(
-                object_frames = cpl_malloc(nr_object_frames * sizeof(cpl_frame*)));
+            object_frames = cpl_malloc(nr_object_frames * sizeof(cpl_frame*)));
 
-        for (ox=0; ox<nr_object_frames; ox++) {
+        for (ox = 0; ox < nr_object_frames; ox++) {
             if (ox == 0) {
-                KMO_TRY_EXIT_IF_NULL(
-                        object_frames[ox] = cpl_frameset_find(frameset, CUBE_OBJECT));
+                KMO_TRY_EXIT_IF_NULL(object_frames[ox] = 
+                        cpl_frameset_find(frameset, CUBE_OBJECT));
             } else {
-                KMO_TRY_EXIT_IF_NULL(
-                        object_frames[ox] =  cpl_frameset_find(frameset, NULL));
+                KMO_TRY_EXIT_IF_NULL(object_frames[ox] = 
+                        cpl_frameset_find(frameset, NULL));
             }
             obj_fits_desc = kmo_identify_fits_header(
-                        cpl_frame_get_filename(object_frames[ox]));
-            KMO_TRY_CHECK_ERROR_STATE_MSG("Provided object fits file doesn't seem to be "
-                                          "in KMOS-format!");
+                    cpl_frame_get_filename(object_frames[ox]));
+            KMO_TRY_CHECK_ERROR_STATE_MSG("Wrong FITS file format");
             KMO_TRY_ASSURE(obj_fits_desc.fits_type == f3i_fits,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "Provided object fits file hasn't correct data type "
-                           "(KMOSTYPE must be F3I)!");
+                    CPL_ERROR_ILLEGAL_INPUT,
+                    "Object fits file type must be F3I");
             kmo_free_fits_desc(&obj_fits_desc);
-
         }
 
-        KMO_TRY_EXIT_IF_NULL(
-                sky_frame = cpl_frameset_find(frameset, CUBE_SKY));
+        KMO_TRY_EXIT_IF_NULL(sky_frame = cpl_frameset_find(frameset, CUBE_SKY));
         sky_fits_desc = kmo_identify_fits_header(
-                    cpl_frame_get_filename(sky_frame));
-        KMO_TRY_CHECK_ERROR_STATE_MSG("Provided sky fits file doesn't seem to be "
-                                      "in KMOS-format!");
+                cpl_frame_get_filename(sky_frame));
+        KMO_TRY_CHECK_ERROR_STATE_MSG("Wrong FITS file format");
         KMO_TRY_ASSURE(sky_fits_desc.fits_type == f3i_fits,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Provided sky fits file hasn't correct data type "
-                       "(KMOSTYPE must be F3I)!");
+                CPL_ERROR_ILLEGAL_INPUT, "Sky fits file type must be F3I");
+
         if (sky_fits_desc.ex_noise == TRUE) {
             nr_sky_devices = sky_fits_desc.nr_ext / 2;
         } else {
             nr_sky_devices = sky_fits_desc.nr_ext;
         }
-        KMO_TRY_EXIT_IF_NULL(
-            sky_fn = cpl_frame_get_filename(sky_frame));
 
-        for (ox=0; ox<nr_object_frames; ox++) {
-            printf("ox: %d\n",ox);
+        KMO_TRY_EXIT_IF_NULL(sky_fn = cpl_frame_get_filename(sky_frame));
+
+        for (ox = 0; ox < nr_object_frames; ox++) {
             object_frame = object_frames[ox];
-            obj_fits_desc = kmo_identify_fits_header(cpl_frame_get_filename(object_frame));
-            KMO_TRY_CHECK_ERROR_STATE_MSG("Provided object fits file doesn't seem to be "
-                                          "in KMOS-format!");
+            obj_fits_desc = kmo_identify_fits_header(
+                    cpl_frame_get_filename(object_frame));
+            KMO_TRY_CHECK_ERROR_STATE_MSG("Wrong Object FITS file format");
             if (obj_fits_desc.ex_noise == TRUE) {
                 nr_obj_devices = obj_fits_desc.nr_ext / 2;
             } else {
                 nr_obj_devices = obj_fits_desc.nr_ext;
             }
-            KMO_TRY_ASSURE((nr_sky_devices == nr_obj_devices) || (nr_sky_devices == 1),
-                    CPL_ERROR_ILLEGAL_INPUT,
-                    "Number of extensions for the SKY frame must be either 1"
-                    " or the same as for OBJECT frame");
+            KMO_TRY_ASSURE((nr_sky_devices == nr_obj_devices) || 
+                    (nr_sky_devices == 1), CPL_ERROR_ILLEGAL_INPUT,
+                    "SKY frame ext. number must be 1 or match OBJECT frame");
 
-            KMO_TRY_EXIT_IF_NULL(
-                obj_fn = cpl_frame_get_filename(object_frame));
+            KMO_TRY_EXIT_IF_NULL(obj_fn = cpl_frame_get_filename(object_frame));
 
-            KMO_TRY_EXIT_IF_NULL(
-                main_header = kmclipm_propertylist_load(obj_fn, 0));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_dfs_save_main_header(frameset, SKY_TWEAK, "",
-                                         object_frame,
-                                         main_header, parlist, cpl_func));
+            KMO_TRY_EXIT_IF_NULL(main_header = kmclipm_propertylist_load(
+                        obj_fn, 0));
 
+            KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_main_header(frameset, SKY_TWEAK,
+                        "", object_frame, main_header, parlist, cpl_func));
 
             for (ifu_nr = 1; ifu_nr <= nr_obj_devices; ifu_nr++) {
-                printf("ifu_nr: %d\n", ifu_nr);
+                cpl_msg_info(cpl_func, "Processing IFU#: %d", ifu_nr);
+
+                /* Get sky index */
                 if (nr_sky_devices == nr_obj_devices) {
-                    index = kmo_identify_index(sky_fn, ifu_nr, FALSE);
+                    sky_index = kmo_identify_index(sky_fn, ifu_nr, FALSE);
                 } else {
-                    index = kmo_identify_index(sky_fn, 1, FALSE);
+                    sky_index = kmo_identify_index(sky_fn, 1, FALSE);
                 }
-                KMO_TRY_CHECK_ERROR_STATE();
-                KMO_TRY_EXIT_IF_NULL(
-                    sky_data = kmclipm_imagelist_load(sky_fn, CPL_TYPE_FLOAT, index));
+                
+                /* Get Object index */
+                obj_index = kmo_identify_index(obj_fn, ifu_nr, FALSE);
 
-                index = kmo_identify_index(obj_fn, ifu_nr, FALSE);
+                /* Load Object header */
+                sub_header = kmclipm_propertylist_load(obj_fn, obj_index);
+                                
                 KMO_TRY_CHECK_ERROR_STATE();
-                KMO_TRY_EXIT_IF_NULL(
-                    sub_header = kmclipm_propertylist_load(obj_fn, index));
-                KMO_TRY_EXIT_IF_NULL(
-                    obj_data = kmclipm_imagelist_load(obj_fn, CPL_TYPE_FLOAT, index));
-//                index = kmo_identify_index(obj_fn, ifu_nr, TRUE);
-//                KMO_TRY_CHECK_ERROR_STATE();
-//                KMO_TRY_EXIT_IF_NULL(
-//                    obj_noise = kmclipm_imagelist_load(obj_fn, CPL_TYPE_FLOAT, index));
-
-                KMO_TRY_EXIT_IF_NULL(
-                        tweaked_data = kmo_priv_sky_tweak (obj_data, sky_data,
-                                sub_header, .3, tbsub));
-
-                KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_cube(tweaked_data, SKY_TWEAK, "", sub_header, 0./0.));
+                
+                /* Only reduce valid IFUs */
+                if (obj_fits_desc.sub_desc[obj_index-1].valid_data &&
+                        sky_fits_desc.sub_desc[sky_index-1].valid_data) {
+                    /* Load sky and object */
+                    sky_data = kmclipm_imagelist_load(sky_fn, CPL_TYPE_FLOAT, 
+                            sky_index);
+                    KMO_TRY_EXIT_IF_NULL(sky_data) ;
+                    obj_data=kmclipm_imagelist_load(obj_fn, CPL_TYPE_FLOAT,
+                            obj_index);
+                    KMO_TRY_EXIT_IF_NULL(obj_data) ;
+                    tweaked_data = kmo_priv_sky_tweak(obj_data, sky_data, 
+                            sub_header, .3, tbsub);
+                    KMO_TRY_EXIT_IF_NULL(tweaked_data) ;
+                } else {
+                    /* Empty IFU */
+                    cpl_msg_warning(__func__, "Empty IFU - skip") ;
+                } 
+
+                KMO_TRY_EXIT_IF_ERROR(kmo_dfs_save_cube(tweaked_data, 
+                            SKY_TWEAK, "", sub_header, 0./0.));
+
+                cpl_propertylist_delete(sub_header); sub_header = NULL;
+                cpl_imagelist_delete(obj_data); obj_data = NULL;
+                cpl_imagelist_delete(sky_data); sky_data = NULL;
+                cpl_imagelist_delete(tweaked_data); tweaked_data = NULL;
             }
 
             kmo_free_fits_desc(&obj_fits_desc);
-
+            cpl_propertylist_delete(main_header); main_header = NULL;
         }
         kmo_free_fits_desc(&sky_fits_desc);
+        cpl_free(object_frames); object_frames = NULL;
     }
     KMO_CATCH
     {
         KMO_CATCH_MSG();
         ret_val = -1;
     }
-
-
     return ret_val;
 }
 
diff --git a/recipes/kmo_stats.c b/recipes/kmo_stats.c
index 7c3ded3..5c09562 100644
--- a/recipes/kmo_stats.c
+++ b/recipes/kmo_stats.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_stats.c,v 1.16 2013-05-24 13:35:28 aagudo Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-05-24 13:35:28 $
- * $Revision: 1.16 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -160,7 +152,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Perform basic statistics on a KMOS-conform fits-file",
                         kmo_stats_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_stats_create,
                         kmo_stats_exec,
diff --git a/recipes/kmo_std_star.c b/recipes/kmo_std_star.c
index 14ab3ef..8487c8f 100644
--- a/recipes/kmo_std_star.c
+++ b/recipes/kmo_std_star.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_std_star.c,v 1.79 2013/10/08 14:55:01 erw Exp $
- *
+/* 
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: erw $
- * $Date: 2013/10/08 14:55:01 $
- * $Revision: 1.79 $
- * $Name:  $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -461,7 +453,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "Create the telluric correction frame.",
                         kmo_std_star_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_std_star_create,
                         kmo_std_star_exec,
@@ -709,7 +701,6 @@ static int kmo_std_star(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      print_warning_once      = TRUE,
                      flux                    = FALSE,
                      background              = FALSE,
-                     band_method             = 0,
                      save_cubes              = FALSE,
                      no_noise                = FALSE,
                      has_magnitude           = TRUE,
@@ -781,7 +772,6 @@ static int kmo_std_star(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      spec_class[256],
                      lum_class[256],
                      star_type[2],
-                     *tmp_band_method        = getenv("KMO_BAND_METHOD"),
                      **split_mag             = NULL,
                      *grat_id                = NULL,
                      *tplid                  = NULL;
@@ -1439,9 +1429,6 @@ static int kmo_std_star(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     print_cal_angle_msg_once = TRUE;
                     print_xcal_angle_msg_once = TRUE;
                 }
-                if (tmp_band_method != NULL) {
-                    band_method = atoi(tmp_band_method);
-                }
 
                 // get filter for this detector
                 // ESO INS FILTi ID
@@ -1453,8 +1440,8 @@ static int kmo_std_star(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 KMO_TRY_EXIT_IF_NULL(
                     band_table = kmo_dfs_load_table(frameset, WAVE_BAND, 1, 0));
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmclipm_setup_grid_band_lcal(&gd, lcal, filter_id,
-                                                 band_method, band_table));
+                    kmclipm_setup_grid_band_lcal(&gd, filter_id,
+                                                 band_table));
                 cpl_image_delete(lcal); lcal = NULL;
                 cpl_table_delete(band_table); band_table = NULL;
 
diff --git a/recipes/kmo_wave_cal.c b/recipes/kmo_wave_cal.c
index a5ea729..518388b 100644
--- a/recipes/kmo_wave_cal.c
+++ b/recipes/kmo_wave_cal.c
@@ -1,5 +1,4 @@
-/* $Id: kmo_wave_cal.c,v 1.54 2013-09-17 08:54:03 aagudo Exp $
- *
+/*
  * This file is part of the KMOS Pipeline
  * Copyright (C) 2002,2003 European Southern Observatory
  *
@@ -18,13 +17,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*
- * $Author: aagudo $
- * $Date: 2013-09-17 08:54:03 $
- * $Revision: 1.54 $
- * $Name: not supported by cvs2svn $
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -32,6 +24,7 @@
 /*-----------------------------------------------------------------------------
  *                              Includes
  *----------------------------------------------------------------------------*/
+
 #include <string.h>
 #include <math.h>
 
@@ -72,22 +65,23 @@ static int kmo_wave_cal(cpl_parameterlist *, cpl_frameset *);
 static char kmo_wave_cal_description[] =
 "This recipe creates the wavelength calibration frame needed for all three\n"
 "detectors. It must be called after the kmo_flat recipe, which generates the\n"
-"two spatial calibration frames needed in this recipe. As input a lamp-on frame,\n"
-"a lamp-off frame, the spatial calibration frames and the list with the\n"
-"reference arclines are required."
+"two spatial calibration frames needed in this recipe. As input a lamp-on \n"
+"frame, a lamp-off frame, the spatial calibration frames and the list with \n"
+"the reference arclines are required.\n"
 "An additional output frame is the resampled image of the reconstructed arc\n"
-"frame. All slitlets of all IFUs are aligned one next to the other. This frame\n"
-"serves for quality control. One can immediately see if the calibration was\n"
-"successful.\n"
+"frame. All slitlets of all IFUs are aligned one next to the other. This \n"
+"frame serves for quality control. One can immediately see if the \n"
+"calibration was successful.\n"
 "The lists of reference arclines are supposed to contain the lines for both\n"
-"available calibration arc-lamps, i.e. Argon and Neon. The list is supposed to\n"
-"be a F2L KMOS FITS file with three columns:\n"
-"1. Reference wavelength\n"
-"2. Relative strength\n"
-"3. String either containing “Ar” or “Ne”\n"
-"The recipe extracts, based on the header keywords, either the applying argon\n"
-"and/or neon emission lines. Below are the plots of the emission lines for both\n"
-"argon and neon. The marked lines are the ones used for wavelength calibration.\n"
+"available calibration arc-lamps, i.e. Argon and Neon. The list is supposed\n"
+"to be a F2L KMOS FITS file with three columns:\n"
+"\t1. Reference wavelength\n"
+"\t2. Relative strength\n"
+"\t3. String either containing “Ar” or “Ne”\n"
+"The recipe extracts, based on the header keywords, either the applying\n"
+"argon and/or neon emission lines. Below are the plots of the emission lines\n"
+"for both argon and neon. The marked lines are the ones used for wavelength \n"
+"calibration.\n"
 "\n"
 "Furthermore frames can be provided for several rotator angles. In this case\n"
 "the resulting calibration frames for each detector are repeatedly saved as \n"
@@ -97,9 +91,8 @@ static char kmo_wave_cal_description[] =
 "-----------------\n"
 "--order\n"
 "The polynomial order to use for the fit of the wavelength solution.\n"
-"0: (default) The appropriate order is choosen automatically depending on the\n"
-"waveband. Otherwise an order of 6 is recommended, except for IZ-band, there\n"
-"order 4 should be used.\n"
+"0: (default) The appropriate order is choosen automatically depending on\n"
+"the waveband (4 for IZ band, 5 for HK, 6 for the others)\n"
 "\n"
 "ADVANCED PARAMETERS\n"
 "-------------------\n"
@@ -113,36 +106,34 @@ static char kmo_wave_cal_description[] =
 "cube. By default the internally defined values are used.\n"
 "\n"
 "--suppress_extension\n"
-"If set to TRUE, the arbitrary filename extensions are supressed. If multiple\n"
-"products with the same category are produced, they will be numered consecutively\n"
-"starting from 0.\n"
+"If set to TRUE, the arbitrary filename extensions are supressed. If\n"
+"multiple products with the same category are produced, they will be numered\n"
+"consecutively starting from 0.\n"
 "\n"
-"-------------------------------------------------------------------------------\n"
-"  Input files:\n"
+"----------------------------------------------------------------------------\n"
+"Input files:\n"
 "\n"
-"   DO                    KMOS                                                  \n"
-"   category              Type   Explanation                    Required #Frames\n"
-"   --------              -----  -----------                    -------- -------\n"
-"   ARC_ON                RAW    Arclamp-on exposure                Y        >=1\n"
-"   ARC_OFF               RAW    Arclamp-off exposure               Y          1\n"
-"   XCAL                  F2D    x calibration frame                Y          1\n"
-"   YCAL                  F2D    y calibration frame                Y          1\n"
-"   ARC_LIST              F2L    List of arclines                   Y          1\n"
-"   FLAT_EDGE             F2L    Fitted edge parameters             Y          1\n"
-"   REF_LINES             F2L    Reference line table               Y          1\n"
-"   WAVE_BAND             F2L    Table with start-/end-wavelengths  Y          1\n"
+"   DO category       Type   Explanation                    Required #Frames\n"
+"   -----------       -----  -----------                    -------- -------\n"
+"   ARC_ON            RAW    Arclamp-on exposure                Y        >=1\n"
+"   ARC_OFF           RAW    Arclamp-off exposure               Y          1\n"
+"   XCAL              F2D    x calibration frame                Y          1\n"
+"   YCAL              F2D    y calibration frame                Y          1\n"
+"   ARC_LIST          F2L    List of arclines                   Y          1\n"
+"   FLAT_EDGE         F2L    Fitted edge parameters             Y          1\n"
+"   REF_LINES         F2L    Reference line table               Y          1\n"
+"   WAVE_BAND         F2L    Table with start-/end-wavelengths  Y          1\n"
 "\n"
-"  Output files:\n"
+"Output files:\n"
 "\n"
-"   DO                    KMOS\n"
-"   category              Type   Explanation\n"
-"   --------              -----  -----------\n"
-"   LCAL                  F2D    Wavelength calibration frame\n"
-"                                (3 Extensions)\n"
-"   DET_IMG_WAVE          F2D    reconstructed arclamp-on exposure\n"
-"                                (4 extensions: 3 detector images + \n"
-"                                the arclines list table)\n"
-"-------------------------------------------------------------------------------\n"
+"   DO category       Type   Explanation\n"
+"   -----------       -----  -----------\n"
+"   LCAL              F2D    Wavelength calibration frame\n"
+"                            (3 Extensions)\n"
+"   DET_IMG_WAVE      F2D    reconstructed arclamp-on exposure\n"
+"                            (4 extensions: 3 detector images + \n"
+"                            the arclines list table)\n"
+"----------------------------------------------------------------------------\n"
 "\n";
 
 /*-----------------------------------------------------------------------------
@@ -150,13 +141,12 @@ static char kmo_wave_cal_description[] =
  *----------------------------------------------------------------------------*/
 
 /**
- * @defgroup kmo_wave_cal kmo_wave_cal Create a calibration frame encoding the spectral position
- *
- * See recipe description for details.
+ * @defgroup kmo_wave_cal Creates a frame encoding the spectral position
  */
 
 /**@{*/
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Build the list of available plugins, for this module. 
   @param    list    the plugin list
@@ -165,6 +155,7 @@ static char kmo_wave_cal_description[] =
   Create the recipe instance and make it available to the application using the 
   interface. This function is exported.
  */
+/*----------------------------------------------------------------------------*/
 int cpl_plugin_get_info(cpl_pluginlist *list)
 {
     cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
@@ -180,7 +171,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
                         "detector.",
                         kmo_wave_cal_description,
                         "Alex Agudo Berbel",
-                        "kmos-spark at mpe.mpg.de",
+                        "usd-help at eso.org",
                         kmos_get_license(),
                         kmo_wave_cal_create,
                         kmo_wave_cal_exec,
@@ -191,6 +182,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Setup the recipe options    
   @param    plugin  the plugin
@@ -198,6 +190,7 @@ int cpl_plugin_get_info(cpl_pluginlist *list)
 
   Defining the command-line/configuration parameters for the recipe.
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_wave_cal_create(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -213,66 +206,35 @@ static int kmo_wave_cal_create(cpl_plugin *plugin)
     recipe->parameters = cpl_parameterlist_new();
 
     // Fill the parameters list
-    p = cpl_parameter_new_value("kmos.kmo_wave_cal.order",
-                                CPL_TYPE_INT,
-                                "The polynomial order to use for the fit of "
-                                "the wavelength solution. 0: (default) The "
-                                "appropriate order is choosen automatically "
-                                "depending on the waveband. Otherwise an order "
-                                "of 6 is recommended, except for IZ-band, there "
-                                "order 4 should be used",
-                                "kmos.kmo_wave_cal",
-                                0);
+    p = cpl_parameter_new_value("kmos.kmo_wave_cal.order", CPL_TYPE_INT,
+            "The fitting polynomial order used for the wavelength solution. "
+            "By default, 4 for IZ band, 5 for HK, 6 for the others",
+            "kmos.kmo_wave_cal", 0);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "order");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
-    p = cpl_parameter_new_value("kmos.kmo_wave_cal.dev_flip",
-                                CPL_TYPE_BOOL,
-                                "Set this parameter to TRUE if the wavelengths"
-                                " are ascending on the detector from top to "
-                                "bottom.",
-                                "kmos.kmo_wave_cal",
-                                FALSE);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dev_flip");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
-    p = cpl_parameter_new_value("kmos.kmo_wave_cal.dev_disp",
-                                CPL_TYPE_DOUBLE,
-                                "The expected dispersion of the wavelength "
-                                "in microns/pixel. If the default isn't "
-                                "changed it will automatically be selected "
-                                "upon header keywords.",
-                                "kmos.kmo_wave_cal",
-                                -1.0);
-    cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dev_disp");
-    cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
-    cpl_parameterlist_append(recipe->parameters, p);
-
     /* --suppress_extension */
     p = cpl_parameter_new_value("kmos.kmo_wave_cal.suppress_extension",
-                                CPL_TYPE_BOOL,
-                                "Suppress arbitrary filename extension."
-                                "(TRUE (apply) or FALSE (don't apply)",
-                                "kmos.kmo_wave_cal",
-                                FALSE);
+            CPL_TYPE_BOOL, "Suppress arbitrary filename extension"
+            "kmos.kmo_wave_cal", FALSE);
     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "suppress_extension");
     cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
     cpl_parameterlist_append(recipe->parameters, p);
 
     // add parameters for band-definition
-    kmo_band_pars_create(recipe->parameters,
-                         "kmos.kmo_wave_cal");
+    kmo_band_pars_create(recipe->parameters, "kmos.kmo_wave_cal");
 
     return 0;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Execute the plugin instance given by the interface
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_wave_cal_exec(cpl_plugin *plugin)
 {
     cpl_recipe  *recipe;
@@ -285,11 +247,13 @@ static int kmo_wave_cal_exec(cpl_plugin *plugin)
     return kmo_wave_cal(recipe->parameters, recipe->frames);
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Destroy what has been created by the 'create' function
   @param    plugin  the plugin
   @return   0 if everything is ok
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_wave_cal_destroy(cpl_plugin *plugin)
 {
     cpl_recipe *recipe;
@@ -303,6 +267,7 @@ static int kmo_wave_cal_destroy(cpl_plugin *plugin)
     return 0 ;
 }
 
+/*----------------------------------------------------------------------------*/
 /**
   @brief    Interpret the command line options and execute the data processing
   @param    parlist     the parameters list
@@ -311,12 +276,13 @@ static int kmo_wave_cal_destroy(cpl_plugin *plugin)
 
   Possible _cpl_error_code_ set in this function:
 
-    @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
-                                     if first operand not 3d or
-                                     if second operand not valid
-    @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands
-                                     do not match
+  @li CPL_ERROR_ILLEGAL_INPUT      if operator not valid,
+                                   if first operand not 3d or
+                                   if second operand not valid
+  @li CPL_ERROR_INCOMPATIBLE_INPUT if the dimensions of the two operands
+                                   do not match
  */
+/*----------------------------------------------------------------------------*/
 static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
 {
     cpl_image        *det_lamp_on                   = NULL,
@@ -340,7 +306,6 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      ny                             = 0,
                      nz                             = 0,
                      *stored_qc_arc_sat             = NULL,
-                     flip_trace                     = FALSE,
                      fit_order_par                  = 0,
                      fit_order                      = 0,
                      ndit                           = 0,
@@ -353,7 +318,6 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                      gain                           = 0.0,
                      *stored_qc_ar_eff              = NULL,
                      *stored_qc_ne_eff              = NULL,
-                     disp                           = 0.0,
                      angle_found                    = 0.0;
 
     cpl_table        *arclines                      = NULL,
@@ -401,228 +365,186 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
         if (str_line_estimate_method != NULL) {
             line_estimate_method = atoi(str_line_estimate_method);
         }
-        cpl_msg_debug(cpl_func, "Line estimation method: %d\n",
+        cpl_msg_debug(__func__, "Line estimation method: %d\n",
                                 line_estimate_method);
 
-// #############################################################################
-// ###           check inputs
-// #############################################################################
-        KMO_TRY_ASSURE((parlist != NULL) &&
-                       (frameset != NULL),
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all input data is provided!");
+        /* Check inputs */
+        KMO_TRY_ASSURE((parlist != NULL) && (frameset != NULL),
+                CPL_ERROR_NULL_INPUT, "Not all input data is provided!");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, ARC_ON) >= 1,
-                       CPL_ERROR_NULL_INPUT,
-                       "At least one ARC_ON frame is required!");
+                CPL_ERROR_NULL_INPUT, "At least 1 ARC_ON frame is required!");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, ARC_OFF) >= 1,
-                       CPL_ERROR_NULL_INPUT,
-                       "Exactly one ARC_OFF frame is required!");
+                CPL_ERROR_NULL_INPUT, "Exactly 1 ARC_OFF frame is required!");
 
         if (cpl_frameset_count_tags(frameset, ARC_OFF) > 1) {
-            cpl_msg_warning("", "Exactly one ARC_OFF frame is required. "
-                                "Just the first frame will be used");
+            cpl_msg_warning(__func__, 
+                    "Only 1 ARC_OFF frame required. Frame #1 will be used");
         }
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, XCAL) == 1,
-                       CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one XCAL frame is required!");
+                CPL_ERROR_FILE_NOT_FOUND, "Exactly 1 XCAL frame is required!");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, YCAL) == 1,
-                       CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one YCAL frame is required!");
+                CPL_ERROR_FILE_NOT_FOUND, "Exactly 1 YCAL frame is required!");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, ARC_LIST) == 1,
-                       CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one ARC_LIST frame is required!");
+                CPL_ERROR_FILE_NOT_FOUND, "Exactly 1 ARC_LIST is required!");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, FLAT_EDGE) == 1,
-                       CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one FLAT_EDGE frame is required!");
+                CPL_ERROR_FILE_NOT_FOUND, "Exactly 1 FLAT_EDGE is required!");
 
         KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, WAVE_BAND) == 1,
-                       CPL_ERROR_FILE_NOT_FOUND,
-                       "Exactly one WAVE_BAND frame is required!");
+                CPL_ERROR_FILE_NOT_FOUND, "Exactly 1 WAVE_BAND is required!");
 
         if (line_estimate_method == 2) {
             KMO_TRY_ASSURE(cpl_frameset_count_tags(frameset, REF_LINES) == 1,
-                           CPL_ERROR_FILE_NOT_FOUND,
-                           "Exactly one REF_LINES frame is required!");
+                    CPL_ERROR_FILE_NOT_FOUND, "Exactly 1 REF_LINES required!");
         }
         
         KMO_TRY_ASSURE(kmo_dfs_set_groups(frameset, "kmo_wave_cal") == 1,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Cannot identify RAW and CALIB frames!");
+                CPL_ERROR_ILLEGAL_INPUT, 
+                "Cannot identify RAW and CALIB frames!");
 
-        //
-        // ------------ get parameters ------------
-        //
-        cpl_msg_info("", "--- Parameter setup for kmo_wave_cal ------");
+        /* Get Parameters */
+        cpl_msg_info(__func__, "--- Parameter setup for kmo_wave_cal ------");
 
         fit_order_par = kmo_dfs_get_parameter_int(parlist,
-                                              "kmos.kmo_wave_cal.order");
+                "kmos.kmo_wave_cal.order");
         KMO_TRY_CHECK_ERROR_STATE();
         KMO_TRY_EXIT_IF_ERROR(
             kmo_dfs_print_parameter_help(parlist, "kmos.kmo_wave_cal.order"));
-        KMO_TRY_ASSURE((fit_order_par >= 0) &&
-                       (fit_order_par <= 8),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "order must be between 1 and 8!");
-
-        flip_trace = kmo_dfs_get_parameter_bool(parlist,
-                                           "kmos.kmo_wave_cal.dev_flip");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_wave_cal.dev_flip"));
-        KMO_TRY_ASSURE((flip_trace == TRUE) ||
-                       (flip_trace == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "flip must be TRUE or FALSE!");
-
-        disp = kmo_dfs_get_parameter_double(parlist,
-                                           "kmos.kmo_wave_cal.dev_disp");
-        KMO_TRY_CHECK_ERROR_STATE();
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_wave_cal.dev_disp"));
-
-        KMO_TRY_ASSURE((disp > 0.0) || (disp == -1.0),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "dispersion must be greater than 0.0!");
+        KMO_TRY_ASSURE((fit_order_par >= 0) && (fit_order_par <= 7),
+                CPL_ERROR_ILLEGAL_INPUT, "order must be between 1 and 7");
 
         suppress_extension = kmo_dfs_get_parameter_bool(parlist,
-                                          "kmos.kmo_wave_cal.suppress_extension");
+                "kmos.kmo_wave_cal.suppress_extension");
         KMO_TRY_CHECK_ERROR_STATE();
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_print_parameter_help(parlist, "kmos.kmo_wave_cal.suppress_extension"));
+            kmo_dfs_print_parameter_help(parlist, 
+                "kmos.kmo_wave_cal.suppress_extension"));
 
-        KMO_TRY_ASSURE((suppress_extension == TRUE) || (suppress_extension == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "suppress_extension must be TRUE or FALSE!");
+        KMO_TRY_ASSURE((suppress_extension == TRUE) || 
+                (suppress_extension == FALSE), CPL_ERROR_ILLEGAL_INPUT,
+                "suppress_extension must be TRUE or FALSE!");
 
         kmo_band_pars_load(parlist, "kmos.kmo_wave_cal");
 
-        cpl_msg_info("", "-------------------------------------------");
-
-        //
-        // ------------ check EXPTIME, NDIT, READMODE and lamps ------------
-        //
+        cpl_msg_info(__func__, "-------------------------------------------");
 
-        // check ARC_OFF
+        /* check EXPTIME, NDIT, READMODE and lamps  */
+        /* check ARC_OFF */
         KMO_TRY_EXIT_IF_NULL(
             frame = kmo_dfs_get_frame(frameset, ARC_OFF));
 
-        main_header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
+        main_header=kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
 
         ndit = cpl_propertylist_get_int(main_header, NDIT);
-        KMO_TRY_CHECK_ERROR_STATE("NDIT keyword in main header "
-                                  "missing!");
+        KMO_TRY_CHECK_ERROR_STATE("NDIT keyword in main header missing!");
 
         exptime = cpl_propertylist_get_double(main_header, EXPTIME);
-        KMO_TRY_CHECK_ERROR_STATE("EXPTIME keyword in main header "
-                                  "missing!");
+        KMO_TRY_CHECK_ERROR_STATE("EXPTIME keyword in main header missing!");
 
-        readmode = cpl_strdup(cpl_propertylist_get_string(main_header, READMODE));
-        KMO_TRY_CHECK_ERROR_STATE("ESO DET READ CURNAME keyword in main "
-                                  "header missing!");
+        readmode = cpl_strdup(cpl_propertylist_get_string(main_header, 
+                    READMODE));
+        KMO_TRY_CHECK_ERROR_STATE(
+                "ESO DET READ CURNAME keyword in main header missing!");
 
-        desc1 = kmo_identify_fits_header(
-                    cpl_frame_get_filename(frame));
-        KMO_TRY_CHECK_ERROR_STATE_MSG("ARC_OFF frame doesn't seem to "
-                                      "be in KMOS-format!");
+        desc1 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
+        KMO_TRY_CHECK_ERROR_STATE_MSG(
+                "ARC_OFF frame doesn't seem to be in KMOS-format!");
 
-        KMO_TRY_ASSURE(desc1.fits_type == raw_fits,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "ARC_OFF frame hasn't correct data type "
-                       "(%s must be a raw, unprocessed file)!",
-                       cpl_frame_get_filename(frame));
+        KMO_TRY_ASSURE(desc1.fits_type == raw_fits, CPL_ERROR_ILLEGAL_INPUT,
+                "ARC_OFF frame hasn't correct data type "
+                "(%s must be a raw, unprocessed file)!",
+                cpl_frame_get_filename(frame));
 
         nx = desc1.naxis1;
         ny = desc1.naxis2;
         nz = desc1.naxis3;
         nr_devices = desc1.nr_ext;
 
-        // assure that flat lamps are off
+        /* assure that flat lamps are off */
         KMO_TRY_ASSURE((kmo_check_lamp(main_header, INS_LAMP3_ST) == FALSE) &&
-                       (kmo_check_lamp(main_header, INS_LAMP4_ST) == FALSE),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "Flat lamps must be switched off (%s)!",
-                       cpl_frame_get_filename(frame));
+                (kmo_check_lamp(main_header, INS_LAMP4_ST) == FALSE),
+                CPL_ERROR_ILLEGAL_INPUT,"Flat lamps must be switched off (%s)!",
+                cpl_frame_get_filename(frame));
 
-        // check if arc lamps are off (or at least blocked by filter wheel)
+        /* check if arc lamps are off (or at least blocked by filter wheel) */
         if ((kmo_check_lamp(main_header, INS_LAMP1_ST) == TRUE) ||
-            (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE))
-        {
-            if (!(strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT1 ID"), "Block") == 0) ||
-                !(strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT3 ID"), "Block") == 0) ||
-                !(strcmp(cpl_propertylist_get_string(main_header, "ESO INS FILT3 ID"), "Block") == 0))
-            {
-                cpl_msg_warning("","At least one arc lamp is on! Check if the lamps are blocked!");
+            (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE)) {
+            if (!(strcmp(cpl_propertylist_get_string(main_header, 
+                                "ESO INS FILT1 ID"), "Block") == 0) ||
+                !(strcmp(cpl_propertylist_get_string(main_header, 
+                            "ESO INS FILT3 ID"), "Block") == 0) ||
+                !(strcmp(cpl_propertylist_get_string(main_header, 
+                            "ESO INS FILT3 ID"), "Block") == 0)) {
+                cpl_msg_warning(__func__, 
+                "At least one arc lamp is on! Check if the lamps are blocked!");
             }
         }
         cpl_propertylist_delete(main_header); main_header = NULL;
 
-        // check REF_LINES
+        /* check REF_LINES */
         if (line_estimate_method == 2) {
             KMO_TRY_EXIT_IF_NULL(
                 frame = kmo_dfs_get_frame(frameset, REF_LINES));
             desc2 = kmo_identify_fits_header(
                         cpl_frame_get_filename(frame));
-            KMO_TRY_CHECK_ERROR_STATE_MSG("REF_LINES frame doesn't seem to "
-                                          "be in KMOS-format!");
-
-            KMO_TRY_ASSURE(desc2.fits_type == f2l_fits,
-                           CPL_ERROR_ILLEGAL_INPUT,
-                           "REF_LINES frame hasn't correct frame type "
-                           "(%s must be a F2L frame)!",
-                           cpl_frame_get_filename(frame));
+            KMO_TRY_CHECK_ERROR_STATE_MSG(
+                    "REF_LINES frame doesn't seem to be in KMOS-format!");
+
+            KMO_TRY_ASSURE(desc2.fits_type == f2l_fits, CPL_ERROR_ILLEGAL_INPUT,
+                    "REF_LINES frame hasn't correct frame type "
+                    "(%s must be a F2L frame)!",
+                    cpl_frame_get_filename(frame));
             kmo_free_fits_desc(&desc2);
         }
 
-        // check ARC_ON
+        /* check ARC_ON */
         KMO_TRY_EXIT_IF_NULL(
             frame = kmo_dfs_get_frame(frameset, ARC_ON));
 
         while (frame != NULL) {
-            main_header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
+            main_header = kmclipm_propertylist_load(
+                    cpl_frame_get_filename(frame), 0);
 
             KMO_TRY_ASSURE(cpl_propertylist_get_int(main_header, NDIT) == ndit,
                     CPL_ERROR_ILLEGAL_INPUT,
                     "NDIT isn't the same for all frames: (is %d and %d).",
                     cpl_propertylist_get_int(main_header, NDIT), ndit);
 
-            KMO_TRY_ASSURE(cpl_propertylist_get_double(main_header, EXPTIME) == exptime,
+            KMO_TRY_ASSURE(
+                    cpl_propertylist_get_double(main_header, EXPTIME)==exptime,
                     CPL_ERROR_ILLEGAL_INPUT,
                     "EXPTIME isn't the same for all frames: (is %g and %g).",
                     cpl_propertylist_get_double(main_header, EXPTIME), exptime);
 
-            KMO_TRY_ASSURE(strcmp(cpl_propertylist_get_string(main_header, READMODE), readmode) == 0,
+            KMO_TRY_ASSURE(
+    strcmp(cpl_propertylist_get_string(main_header, READMODE), readmode) == 0,
                     CPL_ERROR_ILLEGAL_INPUT,
                     "ESO DET READ CURNAME isn't the same for all frames: (is %s and %s).",
                     cpl_propertylist_get_string(main_header, READMODE), readmode);
 
-            desc2 = kmo_identify_fits_header(
-                    cpl_frame_get_filename(frame));
-            KMO_TRY_CHECK_ERROR_STATE_MSG("ARC_ON frame doesn't seem to "
-                    "be in KMOS-format!");
+            desc2 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
+            KMO_TRY_CHECK_ERROR_STATE_MSG(
+                    "ARC_ON frame doesn't seem to be in KMOS-format!");
 
-            KMO_TRY_ASSURE(desc2.fits_type == raw_fits,
-                    CPL_ERROR_ILLEGAL_INPUT,
+            KMO_TRY_ASSURE(desc2.fits_type == raw_fits, CPL_ERROR_ILLEGAL_INPUT,
                     "ARC_ON frame hasn't correct data type "
                     "(%s must be a raw, unprocessed file)!",
                     cpl_frame_get_filename(frame));
 
-            KMO_TRY_ASSURE((desc2.naxis1 == nx) &&
-                    (desc2.naxis2 == ny) &&
-                    (desc2.naxis3 == nz),
-                    CPL_ERROR_ILLEGAL_INPUT,
-                    "ARC_ON frame hasn't correct dimensions! (x,y): (%d,%d) "
-                    "vs (%d,%d)", desc2.naxis1, desc2.naxis2, nx, ny);
-
+            KMO_TRY_ASSURE((desc2.naxis1 == nx) && (desc2.naxis2 == ny) &&
+                    (desc2.naxis3 == nz), CPL_ERROR_ILLEGAL_INPUT,
+            "ARC_ON frame hasn't correct dimensions! (x,y): (%d,%d) vs (%d,%d)",
+                    desc2.naxis1, desc2.naxis2, nx, ny);
 
             // assure that flat lamp is off (LAMP3 and 4)
             // and that either arc lamp is on (LAMP1 and 2)
-            KMO_TRY_ASSURE(((kmo_check_lamp(main_header, INS_LAMP1_ST) == TRUE) ||
+            KMO_TRY_ASSURE(
+                    ((kmo_check_lamp(main_header, INS_LAMP1_ST) == TRUE) ||
                     (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE)) &&
                     (kmo_check_lamp(main_header, INS_LAMP3_ST) == FALSE) &&
                     (kmo_check_lamp(main_header, INS_LAMP4_ST) == FALSE),
@@ -639,82 +561,67 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
         }
 
         // load first ARC_ON main header
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, ARC_ON));
         KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, ARC_ON));
-        KMO_TRY_EXIT_IF_NULL(
-            main_header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0));
+            main_header = kmclipm_propertylist_load(
+                cpl_frame_get_filename(frame), 0));
 
         // check FLAT_EDGE
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, FLAT_EDGE));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, FLAT_EDGE));
 
         desc2 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
         KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_ASSURE((desc2.nr_ext % 24== 0) &&
-                       (desc2.fits_type == f2l_fits),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "FLAT_EDGE isn't in the correct format!!!");
+        KMO_TRY_ASSURE((desc2.nr_ext % 24== 0) && (desc2.fits_type == f2l_fits),
+                CPL_ERROR_ILLEGAL_INPUT, "FLAT_EDGE has a wrong format.");
 
         kmo_free_fits_desc(&desc2);
         kmo_init_fits_desc(&desc2);
 
-        //
         // ------------ check filter_id, grating_id and rotator offset ---------
         // assure that filters, grating and rotation offsets match for
         // ARC_ON, XCAL and YCAL
         // check if filter_id, grating_id and rotator offset match for all
         // detectors
-        //
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_check_frame_setup(frameset, ARC_ON, XCAL,
-                                       TRUE, FALSE, FALSE));
+                kmo_check_frame_setup(frameset, ARC_ON, XCAL,TRUE,FALSE,FALSE));
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_check_frame_setup(frameset, ARC_ON, YCAL,
-                                       TRUE, FALSE, FALSE));
+            kmo_check_frame_setup(frameset, ARC_ON, YCAL, TRUE, FALSE, FALSE));
 
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_check_frame_setup_md5_xycal(frameset));
+        KMO_TRY_EXIT_IF_ERROR(kmo_check_frame_setup_md5_xycal(frameset));
 
         strcpy(filename_lcal, LCAL);
         strcpy(filename_det_img, DET_IMG_WAVE);
 
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, XCAL));
-        KMO_TRY_EXIT_IF_NULL(
-            suffix = kmo_dfs_get_suffix(frame, TRUE, FALSE));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, XCAL));
+        KMO_TRY_EXIT_IF_NULL(suffix = kmo_dfs_get_suffix(frame, TRUE, FALSE));
 
-        cpl_msg_info("", "Detected instrument setup:   %s", suffix+1);
-        cpl_msg_info("", "(grating 1, 2 & 3)");
+        cpl_msg_info(__func__, "Detected instrument setup:   %s", suffix+1);
+        cpl_msg_info(__func__, "(grating 1, 2 & 3)");
 
         // setup lamp config
         if ((kmo_check_lamp(main_header, INS_LAMP1_ST) == TRUE) &&
-            (kmo_check_lamp(main_header, INS_LAMP2_ST) == FALSE))
-        {
+            (kmo_check_lamp(main_header, INS_LAMP2_ST) == FALSE)) {
             lamp_config = ARGON;
             strcpy(tmpstr, "Argon");
         } else if ((kmo_check_lamp(main_header, INS_LAMP1_ST) == FALSE) &&
-                   (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE))
-        {
+                   (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE)) {
            lamp_config = NEON;
            strcpy(tmpstr, "Neon");
         } else if ((kmo_check_lamp(main_header, INS_LAMP1_ST) == TRUE) &&
-                   (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE))
-        {
+                   (kmo_check_lamp(main_header, INS_LAMP2_ST) == TRUE)) {
            lamp_config = ARGON_NEON;
            strcpy(tmpstr, "Argon + Neon");
         }
 
-        cpl_msg_info("", "Detected arc lamp configuration: %s", tmpstr);
+        cpl_msg_info(__func__, "Detected arc lamp configuration: %s", tmpstr);
 
-        //assert that filter and grating match for each detector
-        // filter/grating can be different for each detector
+        /* assert that filter and grating match for each detector */
+        /* filter/grating can be different for each detector */
         KMO_TRY_EXIT_IF_NULL(
             filter_ids =  kmo_get_filter_setup(main_header, nr_devices, TRUE));
 
-        //
-        // ---- scan for rotator angles
-        //
+        /* scan for rotator angles */
         #define ANGLE_DIM 360
         int rotang_found[ANGLE_DIM];
         int rotang_cnt[ANGLE_DIM];
@@ -725,21 +632,15 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
         KMO_TRY_EXIT_IF_NULL(
             frame = kmo_dfs_get_frame(frameset, ARC_ON));
         while (frame != NULL) {
-            header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
+            header = kmclipm_propertylist_load(
+                    cpl_frame_get_filename(frame), 0);
             if (cpl_propertylist_has(header, ROTANGLE)) {
-                int rot_angle = (int) rint(cpl_propertylist_get_double(header, ROTANGLE));
-                if (rot_angle < 0) {
-                    rot_angle += 360;
-                }
-                if (rot_angle < 360 && rot_angle >= 0) {
-                    rotang_cnt[rot_angle]++;
-//                    char * tag = cpl_sprintf("FLAT_ON_%3.3d",rot_angle);
-//                    KMO_TRY_EXIT_IF_ERROR(
-//                            cpl_frame_set_tag(frame, tag));
-//                    cpl_free(tag);
-                }
+                int rot_angle = (int)rint(cpl_propertylist_get_double(
+                            header, ROTANGLE));
+                if (rot_angle < 0)                      rot_angle += 360;
+                if (rot_angle < 360 && rot_angle >= 0)  rotang_cnt[rot_angle]++;
             } else {
-                cpl_msg_warning("","File %s has no keyword \"ROTANGLE\"",
+                cpl_msg_warning(__func__,"File %s has no keyword \"ROTANGLE\"",
                         cpl_frame_get_filename(frame));
             }
 
@@ -750,9 +651,12 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
         for (ax = 0; ax < ANGLE_DIM; ax++) {
             if (rotang_cnt[ax] != 0) {
                 if (rotang_cnt[ax] == 1 ) {
-                    cpl_msg_info("","Found %d frame with rotator angle %d",rotang_cnt[ax],ax);
+                    cpl_msg_info(__func__, 
+                            "Found %d frame with rotator angle %d",
+                            rotang_cnt[ax],ax);
                 } else {
-                    cpl_msg_warning("","Found %d frames with rotator angle %d but only one will be used",
+                    cpl_msg_warning(__func__,
+            "Found %d frames with rotator angle %d but only one will be used",
                                     rotang_cnt[ax],ax);
                 }
                 rotang_found[nr_angles] = ax;
@@ -761,20 +665,19 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
         }
 
         KMO_TRY_EXIT_IF_NULL (
-            angle_frameset = (cpl_frameset **) cpl_malloc(nr_angles * sizeof(cpl_frameset*)));
+            angle_frameset = (cpl_frameset **)cpl_malloc(
+                nr_angles * sizeof(cpl_frameset*)));
         for (i = 0; i < nr_angles; i++) {
             angle_frameset[i] = cpl_frameset_new();
         }
 
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, ARC_ON));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, ARC_ON));
         while (frame != NULL) {
-            header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
+            header=kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0);
             if (cpl_propertylist_has(header, ROTANGLE)) {
-                int rot_angle = (int) rint(cpl_propertylist_get_double(header, ROTANGLE));
-                if (rot_angle < 0) {
-                    rot_angle += 360;
-                }
+                int rot_angle = (int)rint(cpl_propertylist_get_double(
+                            header, ROTANGLE));
+                if (rot_angle < 0)  rot_angle += 360;
                 int ix = -1;
                 for (ix = 0; ix<nr_angles; ix++) {
                     if (rotang_found[ix] == rot_angle) {
@@ -783,7 +686,8 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 }
                 if (ix<nr_angles) {
                     KMO_TRY_EXIT_IF_ERROR(
-                        cpl_frameset_insert(angle_frameset[ix], cpl_frame_duplicate(frame)));
+                            cpl_frameset_insert(angle_frameset[ix], 
+                                cpl_frame_duplicate(frame)));
                 }
             }
 
@@ -792,87 +696,79 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
             KMO_TRY_CHECK_ERROR_STATE();
         }
 
-// #############################################################################
-// ###           allocate temporary memory
-// #############################################################################
-        // allocate here a edge table structure for all detectors
+        /* allocate temporary memory */
+        /* allocate here a edge table structure for all detectors */
         KMO_TRY_EXIT_IF_NULL(
-            edge_table = (cpl_table***)cpl_calloc(nr_devices,
-                                                  sizeof(cpl_table**)));
+            edge_table = (cpl_table***)cpl_calloc(nr_devices, 
+                sizeof(cpl_table**)));
         for (i = 0; i < nr_devices; i++) {
             KMO_TRY_EXIT_IF_NULL(
                 edge_table[i] = (cpl_table**)cpl_calloc(KMOS_IFUS_PER_DETECTOR,
-                                                        sizeof(cpl_table*)));
+                    sizeof(cpl_table*)));
         }
 
-        // the frames have to be stored temporarily because the QC parameters
-        // for the main header are calculated from each detector. So they can be
-        // stored only when all detectors are processed
+        /* the frames have to be stored temporarily because the QC params */
+        /* for the main header are calculated per detector. So they can be */
+        /* stored only when all detectors are processed */
         KMO_TRY_EXIT_IF_NULL(
             stored_lcal = (cpl_image**)cpl_calloc(nr_devices * nr_angles,
-                                                    sizeof(cpl_image*)));
+                sizeof(cpl_image*)));
         KMO_TRY_EXIT_IF_NULL(
             stored_det_img = (cpl_image**)cpl_calloc(nr_devices * nr_angles,
-                                                    sizeof(cpl_image*)));
+                sizeof(cpl_image*)));
         KMO_TRY_EXIT_IF_NULL(
-            stored_sub_headers_lcal = (cpl_propertylist**)cpl_calloc(nr_devices * nr_angles,
-                                                    sizeof(cpl_propertylist*)));
+            stored_sub_headers_lcal = (cpl_propertylist**)cpl_calloc(
+                nr_devices * nr_angles, sizeof(cpl_propertylist*)));
         KMO_TRY_EXIT_IF_NULL(
-            stored_sub_headers_det_img = (cpl_propertylist**)cpl_calloc(nr_devices * nr_angles,
-                                                    sizeof(cpl_propertylist*)));
+            stored_sub_headers_det_img = (cpl_propertylist**)cpl_calloc(
+                nr_devices * nr_angles, sizeof(cpl_propertylist*)));
         KMO_TRY_EXIT_IF_NULL(
-            stored_qc_arc_sat =
-                            (int*)cpl_calloc(nr_devices, nr_angles * sizeof(int)));
+            stored_qc_arc_sat = (int*)cpl_calloc(nr_devices, 
+                nr_angles * sizeof(int)));
         KMO_TRY_EXIT_IF_NULL(
-            stored_qc_ar_eff =
-                            (double*)cpl_calloc(nr_devices, nr_angles * sizeof(double)));
+            stored_qc_ar_eff = (double*)cpl_calloc(nr_devices, 
+                nr_angles * sizeof(double)));
         KMO_TRY_EXIT_IF_NULL(
-            stored_qc_ne_eff =
-                            (double*)cpl_calloc(nr_devices, nr_angles * sizeof(double)));
+            stored_qc_ne_eff = (double*)cpl_calloc(nr_devices, 
+                nr_angles * sizeof(double)));
 
-// #############################################################################
-// ###           process data
-// #############################################################################
-        // load arclines and reference lines
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, ARC_LIST));
+        /* process data */
+        /* load arclines and reference lines */
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, ARC_LIST));
 
-        // check if ARC_LIST is the filter_id-one
-        KMO_TRY_EXIT_IF_NULL(
-            tmp_header = kmclipm_propertylist_load(cpl_frame_get_filename(frame), 0));
+        /* check if ARC_LIST is the filter_id-one */
+        KMO_TRY_EXIT_IF_NULL(tmp_header = kmclipm_propertylist_load(
+                    cpl_frame_get_filename(frame), 0));
         KMO_TRY_EXIT_IF_NULL(
             tmp_str = cpl_propertylist_get_string(tmp_header, FILT_ID));
         KMO_TRY_ASSURE(strcmp(filter_ids[0], tmp_str) == 0,
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "ARC_LIST model must have primary "
-                       "keyword '%s' equal '%s'!!!", FILT_ID, filter_ids[0]);
+                CPL_ERROR_ILLEGAL_INPUT, "ARC_LIST model must have primary "
+                "keyword '%s' equal '%s'!!!", FILT_ID, filter_ids[0]);
         cpl_propertylist_delete(tmp_header); tmp_header = NULL;
 
         desc2 = kmo_identify_fits_header(cpl_frame_get_filename(frame));
         KMO_TRY_CHECK_ERROR_STATE();
 
-        KMO_TRY_ASSURE((desc2.nr_ext == 1) &&
-                       (desc2.fits_type == f2l_fits),
-                       CPL_ERROR_ILLEGAL_INPUT,
-                       "ARC_LIST isn't in the correct format!!!");
+        KMO_TRY_ASSURE((desc2.nr_ext == 1) && (desc2.fits_type == f2l_fits),
+                CPL_ERROR_ILLEGAL_INPUT, "ARC_LIST has wrong format");
         kmo_free_fits_desc(&desc2);
         kmo_init_fits_desc(&desc2);
 
         KMO_TRY_EXIT_IF_NULL(
             arclines = kmo_dfs_load_table(frameset, ARC_LIST, 1, 0));
 
-        KMO_TRY_EXIT_IF_NULL(
-            lines = kmo_get_lines(arclines, lamp_config));
+        KMO_TRY_EXIT_IF_NULL(lines = kmo_get_lines(arclines, lamp_config));
 
-        cpl_msg_info("", "Nr. of lines in arclist for this configuration: %lld",
-                     cpl_bivector_get_size(lines));
+        cpl_msg_info(__func__, 
+                "Nr. of lines in arclist for this configuration: %lld",
+                cpl_bivector_get_size(lines));
 
         if (line_estimate_method == 2) {
             KMO_TRY_EXIT_IF_NULL(
                 reflines = kmo_dfs_load_table(frameset, REF_LINES, 1, 0));
         }
 
-        // check which IFUs are active for all FLAT frames
+        /* check which IFUs are active for all FLAT frames */
         KMO_TRY_EXIT_IF_NULL(
             unused_ifus_before = kmo_get_unused_ifus(frameset, 0, 0));
 
@@ -881,21 +777,21 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
 
         kmo_print_unused_ifus(unused_ifus_before, FALSE);
 
-        // make sure no reconstruction lookup table (LUT) is used
+        /* make sure no reconstruction lookup table (LUT) is used */
         if (getenv("KMCLIPM_PRIV_RECONSTRUCT_LUT_MODE") != NULL) {
             last_env = getenv("KMCLIPM_PRIV_RECONSTRUCT_LUT_MODE");
         }
         setenv("KMCLIPM_PRIV_RECONSTRUCT_LUT_MODE","NONE",1);
 
-        //
-        // ------------ loop all rotator angles and detectors ------------
-        //
+        /* loop all rotator angles and detectors  */
         for (a = 0; a < nr_angles; a++) {
-            cpl_msg_info("","Processing rotator angle %d -> %d degree", a,rotang_found[a]);
+            cpl_msg_info(__func__,
+                    "Processing rotator angle %d -> %d degree", 
+                    a,rotang_found[a]);
 
             for (i = 1; i <= nr_devices; i++) {
                 // use loop below for line identification
-                cpl_msg_info("","Processing detector No. %d", i);
+                cpl_msg_info(__func__,"Processing detector No. %d", i);
 
                 int sx = a * nr_devices + (i - 1);
 
@@ -904,9 +800,10 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     frame = kmo_dfs_get_frame(frameset, FLAT_EDGE));
 
                 for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
-                    edge_table[i-1][j] = kmclipm_cal_table_load(cpl_frame_get_filename(frame),
-                                                                (i-1) * KMOS_IFUS_PER_DETECTOR + j + 1,
-                                                                rotang_found[a], 0, &angle_found);
+                    edge_table[i-1][j] = kmclipm_cal_table_load(
+                            cpl_frame_get_filename(frame), 
+                            (i-1) * KMOS_IFUS_PER_DETECTOR + j + 1,
+                            rotang_found[a], 0, &angle_found);
                     if (cpl_error_get_code() == CPL_ERROR_ILLEGAL_INPUT) {
                         // IFU is inactive: proceed
                         cpl_error_reset();
@@ -914,7 +811,7 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 }
 
                 if (fit_order_par == 0) {
-                    // set default fit orders for the different bands
+                    /* set default fit orders for the different bands */
                     if ((strcmp(filter_ids[i-1], "H") == 0) ||
                         (strcmp(filter_ids[i-1], "K") == 0) ||
                         (strcmp(filter_ids[i-1], "YJ") == 0))
@@ -925,34 +822,35 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     } else if (strcmp(filter_ids[i-1], "HK") == 0) {
                         fit_order = 5;
                     }
-                    cpl_msg_info("", "Order of wavelength spectrum fit for %s-band: %d",
-                                 filter_ids[i-1],
-                                 fit_order);
+                    cpl_msg_info(__func__, 
+                            "Order of wavelength spectrum fit for %s-band: %d",
+                            filter_ids[i-1], fit_order);
                 } else {
                     fit_order = fit_order_par;
                 }
 
-                // lamp_on
+                /* lamp_on */
                 KMO_TRY_EXIT_IF_NULL(
                     frame = kmo_dfs_get_frame(angle_frameset[a], ARC_ON));
 
-                // if sat_mode is set to TRUE here, then the calculation of the
-                // saturated pixels has to be updated like in kmo_flat-recipe
+                /* if sat_mode is set to TRUE here, then the calc. of the */
+                /* saturated pixels has to be updated like in kmo_flat-recipe */
                 KMO_TRY_EXIT_IF_NULL(
-                    det_lamp_on = kmo_dfs_load_image_frame(frame, i, FALSE, TRUE, &nr_sat));
+                    det_lamp_on = kmo_dfs_load_image_frame(frame, i, FALSE, 
+                        TRUE, &nr_sat));
 
-                // count saturated pixels for each detector
-                if (strcmp(cpl_propertylist_get_string(main_header, READMODE), "Nondest") == 0) {
-                    // NDR: non-destructive readout mode
+                /* count saturated pixels for each detector */
+                if (strcmp(cpl_propertylist_get_string(main_header, 
+                                READMODE), "Nondest") == 0) {
+                    /* NDR: non-destructive readout mode */
                     stored_qc_arc_sat[sx] = nr_sat;
                 } else {
-                    // normal readout mode
-                    stored_qc_arc_sat[sx] = kmo_image_get_saturated(det_lamp_on,
-                                                                    KMO_FLAT_SATURATED);
+                    /* normal readout mode */
+                    stored_qc_arc_sat[sx] = kmo_image_get_saturated(
+                            det_lamp_on, KMO_FLAT_SATURATED);
                 }
                 KMO_TRY_CHECK_ERROR_STATE();
 
-
                 KMO_TRY_EXIT_IF_NULL(
                     det_lamp_on_copy = cpl_image_duplicate(det_lamp_on));
 
@@ -961,31 +859,30 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     frame = kmo_dfs_get_frame(frameset, ARC_OFF));
 
                 KMO_TRY_EXIT_IF_NULL(
-                    det_lamp_off = kmo_dfs_load_image_frame(frame, i, FALSE, FALSE, NULL));
+                    det_lamp_off = kmo_dfs_load_image_frame(frame, i, FALSE, 
+                        FALSE, NULL));
 
-                //
-                // process imagelist
-                //
+                /* process imagelist */
                 KMO_TRY_CHECK_ERROR_STATE();
 
-                // subtract lamp_off from lamp_on
+                /* subtract lamp_off from lamp_on */
                 KMO_TRY_EXIT_IF_ERROR(
                     cpl_image_subtract(det_lamp_on, det_lamp_off));
 
-                // load flat calibration frames
+                /* load flat calibration frames */
                 KMO_TRY_EXIT_IF_NULL(
                     xcal = kmo_dfs_load_cal_image(frameset, XCAL, i, 0,
-                                                  (double) rotang_found[a], FALSE,
-                                                  NULL, &angle_found, -1, 0, 0));
+                        (double)rotang_found[a], FALSE, NULL, &angle_found, -1,
+                        0, 0));
 
                 KMO_TRY_EXIT_IF_NULL(
                     ycal = kmo_dfs_load_cal_image(frameset, YCAL, i, 0,
-                                                  (double) rotang_found[a], FALSE,
-                                                  NULL,  &angle_found, -1, 0, 0));
+                        (double)rotang_found[a], FALSE, NULL,  &angle_found, -1,
+                        0, 0));
 
-                // load bad pixel mask from XCAL and set NaNs to 0 and all other values to 1
-                KMO_TRY_EXIT_IF_NULL(
-                    bad_pix_mask = cpl_image_duplicate(xcal));
+                /* load bad pixel mask from XCAL and set NaNs to 0  */
+                /* and all other values to 1 */
+                KMO_TRY_EXIT_IF_NULL(bad_pix_mask = cpl_image_duplicate(xcal));
 
                 KMO_TRY_EXIT_IF_NULL(
                     pbad_pix_mask = cpl_image_get_data_float(bad_pix_mask));
@@ -999,25 +896,13 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                     }
                 }
 
-                // calculate spectral curvature here
-                err = kmo_calc_wave_calib(det_lamp_on,
-                                          bad_pix_mask,
-                                          xcal,
-                                          ycal,
-                                          filter_ids[i-1],
-                                          lamp_config,
-                                          i,
-                                          unused_ifus_after[i-1],
-                                          edge_table[i-1],
-                                          lines,
-                                          reflines,
-                                          disp,
-                                          &lcal,
-                                          &(stored_qc_ar_eff[sx]),
-                                          &(stored_qc_ne_eff[sx]),
-                                          flip_trace,
-                                          fit_order,
-                                          line_estimate_method);
+                /* calculate spectral curvature here */
+                err = kmo_calc_wave_calib(det_lamp_on, bad_pix_mask, xcal,
+                        ycal, filter_ids[i-1], lamp_config, i,
+                        unused_ifus_after[i-1], edge_table[i-1], lines,
+                        reflines, -1.0, &lcal, &(stored_qc_ar_eff[sx]),
+                        &(stored_qc_ne_eff[sx]), FALSE, fit_order,
+                        line_estimate_method);
 
                 if (err == CPL_ERROR_NONE) {
                     // calculate QC parameters
@@ -1028,123 +913,102 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                         stored_qc_ne_eff[sx] /= exptime;
                     }
 
-                    // apply the badpixel mask to the produced frame
-
+                    /* apply the badpixel mask to the produced frame */
                     KMO_TRY_EXIT_IF_ERROR(
                         cpl_image_multiply(lcal, bad_pix_mask));
 
                     KMO_TRY_EXIT_IF_ERROR(
                         kmo_image_reject_from_mask(lcal, bad_pix_mask));
 
-                    // store flat frames, badpixel mask and calibration frames
+                    /* store flat frames, badpixel mask and calib frames */
                     stored_lcal[sx] = lcal;
                 } else if (err == CPL_ERROR_UNSPECIFIED) {
-                    // all IFUs seem to be deativated, continue processing
-                    // just save empty frame
+                    /* all IFUs seem to be deativated, continue processing */
+                    /* just save empty frame */
                     cpl_error_reset();
                     stored_lcal[sx] = cpl_image_new(nx, ny, CPL_TYPE_FLOAT);
                     kmo_image_fill(stored_lcal[sx], 0.0);
                 } else {
-                    cpl_msg_warning(cpl_func,
-                                    "Couldn't identify any lines! Is the line "
-                                    "list defined correctly?");
-                    cpl_msg_warning(cpl_func,
-                                    "Band defined in header of detector %d: %s",
-                                    i, filter_ids[i-1]);
-                    cpl_msg_warning(cpl_func,
-                                    "Arc line file defined: %s",
-                                    cpl_frame_get_filename(
-                                          kmo_dfs_get_frame(frameset, ARC_LIST)));
+                    cpl_msg_warning(__func__,
+                            "Couldn't identify any line - Check the line list");
+                    cpl_msg_warning(__func__,
+                            "Band defined in header of detector %d: %s",
+                            i, filter_ids[i-1]);
+                    cpl_msg_warning(__func__, "Arc line file defined: %s",
+                            cpl_frame_get_filename(
+                                kmo_dfs_get_frame(frameset, ARC_LIST)));
                     cpl_error_reset();
                 }
 
-
-                //
-                // create reconstructed and resampled arc frame
-                //
+                /* create reconstructed and resampled arc frame */
                 stored_det_img[sx] = kmo_reconstructed_arc_image(frameset,
-                                                                 det_lamp_on_copy,
-                                                                 det_lamp_off,
-                                                                 xcal,
-                                                                 ycal,
-                                                                 stored_lcal[sx],
-                                                                 unused_ifus_after[i-1],
-                                                                 flip_trace,
-                                                                 i,
-                                                                 suffix,
-                                                                 filter_ids[i-1],
-                                                                 lamp_config,
-                                                                 &qc_header);
+                        det_lamp_on_copy, det_lamp_off, xcal, ycal,
+                        stored_lcal[sx], unused_ifus_after[i-1], FALSE, i,
+                        suffix, filter_ids[i-1], lamp_config, &qc_header);
                 if (cpl_error_get_code() != CPL_ERROR_NONE) {
-                    // couldn't reconstruct
-                    cpl_msg_error("","Couldn't reconstruct IFUs on detector %d", i);
+                    /* couldn't reconstruct */
+                    cpl_msg_error(__func__, 
+                            "Couldn't reconstruct IFUs on detector %d", i);
                     cpl_error_reset();
                 }
 
-                // load and update sub_header with QC parameters
+                /* load and update sub_header with QC parameters */
                 KMO_TRY_EXIT_IF_NULL(
-                    stored_sub_headers_lcal[sx] = kmo_dfs_load_sub_header(frameset,
-                                                                          ARC_ON, i,
-                                                                          FALSE));
-
-                // update EXTNAME
+                    stored_sub_headers_lcal[sx] = kmo_dfs_load_sub_header(
+                        frameset, ARC_ON, i, FALSE));
+                /* update EXTNAME */
                 KMO_TRY_EXIT_IF_NULL(
                     extname = kmo_extname_creator(detector_frame, i, EXT_DATA));
                 KMO_TRY_EXIT_IF_ERROR(
                     kmclipm_update_property_string(stored_sub_headers_lcal[sx],
-                                                   EXTNAME,
-                                                   extname,
-                                                   "FITS extension name"));
+                        EXTNAME, extname, "FITS extension name"));
                 cpl_free(extname); extname = NULL;
 
                 KMO_TRY_EXIT_IF_ERROR(
                     kmclipm_update_property_int(stored_sub_headers_lcal[sx],
-                                                EXTVER,
-                                                sx+1,
-                                                "FITS extension ver"));
+                        EXTVER, sx+1, "FITS extension ver"));
 
                 // add first QC parameters
                 KMO_TRY_EXIT_IF_ERROR(
                     kmclipm_update_property_int(stored_sub_headers_lcal[sx],
-                                                QC_ARC_SAT,
-                                                stored_qc_arc_sat[sx],
-                                                "[] nr. saturated pixels of arc exp."));
+                        QC_ARC_SAT, stored_qc_arc_sat[sx], 
+                        "[] nr. saturated pixels of arc exp."));
 
-                gain = kmo_dfs_get_property_double(stored_sub_headers_lcal[sx], GAIN);
+                gain = kmo_dfs_get_property_double(stored_sub_headers_lcal[sx],
+                        GAIN);
                 KMO_TRY_CHECK_ERROR_STATE_MSG(
                     "GAIN-keyword in fits-header is missing!");
 
                 if (stored_qc_ar_eff[sx] != -1.0) {
                     KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(stored_sub_headers_lcal[sx],
-                                                       QC_ARC_AR_EFF,
-                                                       stored_qc_ar_eff[sx]/gain,
-                                                       "[e-/s] Argon lamp efficiency"));
+                        kmclipm_update_property_double(
+                            stored_sub_headers_lcal[sx], QC_ARC_AR_EFF, 
+                            stored_qc_ar_eff[sx]/gain,
+                            "[e-/s] Argon lamp efficiency"));
                 }
 
                 if (stored_qc_ne_eff[sx] != -1.0) {
                     KMO_TRY_EXIT_IF_ERROR(
-                        kmclipm_update_property_double(stored_sub_headers_lcal[sx],
-                                                       QC_ARC_NE_EFF,
-                                                       stored_qc_ne_eff[sx]/gain,
-                                                       "[e-/s] Neon lamp efficiency"));
+                        kmclipm_update_property_double(
+                            stored_sub_headers_lcal[sx], QC_ARC_NE_EFF, 
+                            stored_qc_ne_eff[sx]/gain,
+                            "[e-/s] Neon lamp efficiency"));
                 }
 
                 KMO_TRY_EXIT_IF_ERROR(
                     kmclipm_update_property_double(stored_sub_headers_lcal[sx],
-                                                   CAL_ROTANGLE,
-                                                   ((double) rotang_found[a]),
-                                                   "[deg] Rotator relative to nasmyth"));
+                        CAL_ROTANGLE, ((double) rotang_found[a]),
+                        "[deg] Rotator relative to nasmyth"));
 
-                // append QC parameters
+                /* append QC parameters */
                 KMO_TRY_EXIT_IF_ERROR(
                     cpl_propertylist_append(stored_sub_headers_lcal[sx],
-                                            qc_header));
+                        qc_header));
                 cpl_propertylist_delete(qc_header); qc_header = NULL;
 
                 KMO_TRY_EXIT_IF_NULL(
-                    stored_sub_headers_det_img[sx] = cpl_propertylist_duplicate(
-                                                     stored_sub_headers_lcal[sx]));
+                    stored_sub_headers_det_img[sx]=cpl_propertylist_duplicate(
+                        stored_sub_headers_lcal[sx]));
 
                 cpl_propertylist_erase(stored_sub_headers_lcal[sx], CRVAL1);
                 cpl_propertylist_erase(stored_sub_headers_lcal[sx], CRVAL2);
@@ -1153,17 +1017,7 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 cpl_propertylist_erase(stored_sub_headers_lcal[sx], CDELT1);
                 cpl_propertylist_erase(stored_sub_headers_lcal[sx], CDELT2);
 
-// leave keywords in for proper fitsverify output
-//                cpl_propertylist_erase(stored_sub_headers_lcal[sx], CRPIX1);
-//                cpl_propertylist_erase(stored_sub_headers_lcal[sx], CRPIX2);
-//                if (cpl_propertylist_has(stored_sub_headers_lcal[sx], CRPIX1)) {
-//                    cpl_propertylist_erase(stored_sub_headers_lcal[sx], CRPIX1);
-//                }
-//                if (cpl_propertylist_has(stored_sub_headers_lcal[sx], CRPIX2)) {
-//                    cpl_propertylist_erase(stored_sub_headers_lcal[sx], CRPIX2);
-//                }
-
-                // free memory
+                /* free memory */
                 cpl_image_delete(det_lamp_on); det_lamp_on = NULL;
                 cpl_image_delete(det_lamp_on_copy); det_lamp_on_copy = NULL;
                 cpl_image_delete(det_lamp_off); det_lamp_off = NULL;
@@ -1172,7 +1026,8 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
                 cpl_image_delete(ycal); ycal = NULL;
 
                 for (j = 0; j < KMOS_IFUS_PER_DETECTOR; j++) {
-                    cpl_table_delete(edge_table[i-1][j]); edge_table[i-1][j] = NULL;
+                    cpl_table_delete(edge_table[i-1][j]); 
+                    edge_table[i-1][j] = NULL;
                 }
             } // for i devices
         } // for a angles
@@ -1180,59 +1035,51 @@ static int kmo_wave_cal(cpl_parameterlist *parlist, cpl_frameset *frameset)
         if (line_estimate_method == 2) {
             cpl_table_delete(reflines); reflines = NULL;
         }
-// ###########################################################################
-// ###           QC parameters & saving
-// ###########################################################################
-        cpl_msg_info("","Saving data...");
-
-        //
-        // ------------ load, update & save primary header ------------
-        //
+        
+        /* QC parameters & saving */
+        cpl_msg_info(__func__, "Saving data...");
+
+        /* load, update & save primary header */
         if (!suppress_extension) {
-            KMO_TRY_EXIT_IF_NULL(
-                fn_suffix = cpl_sprintf("%s", suffix));
+            KMO_TRY_EXIT_IF_NULL(fn_suffix = cpl_sprintf("%s", suffix));
         } else {
-            KMO_TRY_EXIT_IF_NULL(
-                fn_suffix = cpl_sprintf("%s", ""));
+            KMO_TRY_EXIT_IF_NULL(fn_suffix = cpl_sprintf("%s", ""));
         }
 
-        // update which IFUs are not used
+        /* update which IFUs are not used */
         KMO_TRY_EXIT_IF_ERROR(
             kmo_set_unused_ifus(unused_ifus_after, main_header,
-                                "kmo_wave_cal"));
+                "kmo_wave_cal"));
 
-        KMO_TRY_EXIT_IF_NULL(
-            frame = kmo_dfs_get_frame(frameset, ARC_ON));
+        KMO_TRY_EXIT_IF_NULL(frame = kmo_dfs_get_frame(frameset, ARC_ON));
 
         KMO_TRY_EXIT_IF_ERROR(
             kmo_dfs_save_main_header(frameset, filename_lcal, fn_suffix, frame,
-                                     main_header, parlist, cpl_func));
+                main_header, parlist, cpl_func));
 
         KMO_TRY_EXIT_IF_ERROR(
-            kmo_dfs_save_main_header(frameset, filename_det_img, fn_suffix, frame,
-                                     main_header, parlist, cpl_func));
+            kmo_dfs_save_main_header(frameset, filename_det_img, fn_suffix, 
+                frame, main_header, parlist, cpl_func));
 
         cpl_propertylist_delete(main_header); main_header = NULL;
 
-        //
-        // --- save sub-frames ---
-        //
+        /* save sub-frames */
         for (a = 0; a < nr_angles; a++) {
             for (i = 1; i <= nr_devices; i++) {
                 int sx = a * nr_devices + (i - 1);
-                // save lcal-frame
+                /* save lcal-frame */
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_image(stored_lcal[sx], filename_lcal, fn_suffix,
-                                       stored_sub_headers_lcal[sx], 0./0.));
+                    kmo_dfs_save_image(stored_lcal[sx], filename_lcal, 
+                        fn_suffix, stored_sub_headers_lcal[sx], 0./0.));
 
-                // save detector image
+                /* save detector image */
                 KMO_TRY_EXIT_IF_ERROR(
-                    kmo_dfs_save_image(stored_det_img[sx], filename_det_img, fn_suffix,
-                                       stored_sub_headers_det_img[sx], 0./0.));
+                    kmo_dfs_save_image(stored_det_img[sx], filename_det_img, 
+                        fn_suffix, stored_sub_headers_det_img[sx], 0./0.));
             } // for i = nr_devices
         } // for a angles
 
-        // print which IFUs are not used
+        /* print which IFUs are not used */
         kmo_print_unused_ifus(unused_ifus_after, TRUE);
     }
     KMO_CATCH
diff --git a/recipes/tests/Makefile.am b/recipes/tests/Makefile.am
deleted file mode 100644
index 13a39f0..0000000
--- a/recipes/tests/Makefile.am
+++ /dev/null
@@ -1,180 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-##   This file is part of the KMOS Pipeline Library
-##   Copyright (C) 2002,2003 European Southern Observatory
-
-##   This library is free software; you can redistribute it and/or modify
-##   it under the terms of the GNU General Public License as published by
-##   the Free Software Foundation; either version 2 of the License, or
-##   (at your option) any later version.
-
-##   This program is distributed in the hope that it will be useful,
-##   but WITHOUT ANY WARRANTY; without even the implied warranty of
-##   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-##   GNU General Public License for more details.
-
-##   You should have received a copy of the GNU General Public License
-##   along with this program; if not, write to the Free Software
-##   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-AUTOMAKE_OPTIONS = 1.8 foreign
-
-DISTCLEANFILES = *~
-
-EXTRA_DIST = ref_data
-
-if MAINTAINER_MODE
-
-MAINTAINERCLEANFILES = Makefile.in
-
-endif
-
-INCLUDES = $(all_includes) 
-#INCLUDES = $(all_includes) -I../../kmclipm/include/
-
-LDADD = $(LIBCPLDFS) $(LIBCPLUI) $(LIBCPLDRS) $(LIBCPLCORE) $(LIBKMOS)
-
-# Test programs
-check_PROGRAMS = kmo_init-test \
-                 kmo_arithmetic-test \
-                 kmo_combine-test \
-                 kmo_copy-test \
-                 kmo_dev_setup-test \
-                 kmo_extract_spec-test \
-                 kmo_fit_profile-test \
-                 kmo_fits_check-test \
-                 kmo_fits_stack-test \
-                 kmo_make_image-test \
-                 kmo_noise_map-test \
-                 kmo_rotate-test \
-                 kmo_shift-test \
-                 kmo_sky_mask-test \
-                 kmo_stats-test \
-                 kmo_dark-test \
-                 kmo_flat-test \
-                 kmo_wave_cal-test \
-                 kmo_reconstruct-test \
-                 kmo_illumination-test \
-                 kmo_illumination_flat-test \
-                 kmo_std_star-test \
-                 kmo_sci_red-test \
-                 kmo_multi_reconstruct-test \
-                 kmo_fits_strip-test \
-                 kmo_final-test
-
-kmo_init_test_SOURCES = create_data_recipes.c kmo_init-test.c
-kmo_init_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_init_test_LDADD = $(LDADD)
-                 
-kmo_arithmetic_test_SOURCES = create_data_recipes.c kmo_arithmetic-test.c
-kmo_arithmetic_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_arithmetic_test_LDADD = $(LDADD)
- 
-kmo_combine_test_SOURCES = create_data_recipes.c kmo_combine-test.c
-kmo_combine_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_combine_test_LDADD = $(LDADD)
-
-kmo_copy_test_SOURCES = create_data_recipes.c kmo_copy-test.c
-kmo_copy_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_copy_test_LDADD = $(LDADD)
-
-kmo_dev_setup_test_SOURCES = create_data_recipes.c kmo_dev_setup-test.c
-kmo_dev_setup_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_dev_setup_test_LDADD = $(LDADD)
-
-kmo_extract_spec_test_SOURCES = create_data_recipes.c kmo_extract_spec-test.c
-kmo_extract_spec_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_extract_spec_test_LDADD = $(LDADD)
-
-kmo_fit_profile_test_SOURCES = create_data_recipes.c kmo_fit_profile-test.c
-kmo_fit_profile_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_fit_profile_test_LDADD = $(LDADD)
-
-kmo_fits_check_test_SOURCES = create_data_recipes.c kmo_fits_check-test.c
-kmo_fits_check_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_fits_check_test_LDADD = $(LDADD)
-
-kmo_fits_stack_test_SOURCES = create_data_recipes.c kmo_fits_stack-test.c
-kmo_fits_stack_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_fits_stack_test_LDADD = $(LDADD)
-
-kmo_make_image_test_SOURCES = create_data_recipes.c kmo_make_image-test.c
-kmo_make_image_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_make_image_test_LDADD = $(LDADD)
-
-kmo_noise_map_test_SOURCES = create_data_recipes.c kmo_noise_map-test.c
-kmo_noise_map_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_noise_map_test_LDADD = $(LDADD)
-
-kmo_rotate_test_SOURCES = create_data_recipes.c kmo_rotate-test.c
-kmo_rotate_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_rotate_test_LDADD = $(LDADD)
-
-kmo_shift_test_SOURCES = create_data_recipes.c kmo_shift-test.c
-kmo_shift_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_shift_test_LDADD = $(LDADD)
-
-kmo_sky_mask_test_SOURCES = create_data_recipes.c kmo_sky_mask-test.c
-kmo_sky_mask_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_sky_mask_test_LDADD = $(LDADD)
-
-kmo_stats_test_SOURCES = create_data_recipes.c kmo_stats-test.c
-kmo_stats_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_stats_test_LDADD = $(LDADD)
-
-kmo_dark_test_SOURCES = create_data_recipes.c kmo_dark-test.c
-kmo_dark_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_dark_test_LDADD = $(LDADD)
-
-kmo_flat_test_SOURCES = create_data_recipes.c kmo_flat-test.c
-kmo_flat_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_flat_test_LDADD = $(LDADD)
-
-kmo_wave_cal_test_SOURCES = create_data_recipes.c kmo_wave_cal-test.c
-kmo_wave_cal_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_wave_cal_test_LDADD = $(LDADD)
-
-kmo_reconstruct_test_SOURCES = create_data_recipes.c kmo_reconstruct-test.c
-kmo_reconstruct_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_reconstruct_test_LDADD = $(LDADD)
-
-kmo_illumination_test_SOURCES = create_data_recipes.c kmo_illumination-test.c
-kmo_illumination_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_illumination_test_LDADD = $(LDADD)
-
-kmo_illumination_flat_test_SOURCES = create_data_recipes.c kmo_illumination_flat-test.c
-kmo_illumination_flat_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_illumination_flat_test_LDADD = $(LDADD)
-
-kmo_std_star_test_SOURCES = create_data_recipes.c kmo_std_star-test.c
-kmo_std_star_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_std_star_test_LDADD = $(LDADD)
-
-kmo_sci_red_test_SOURCES = create_data_recipes.c kmo_sci_red-test.c
-kmo_sci_red_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_sci_red_test_LDADD = $(LDADD)
-
-kmo_multi_reconstruct_test_SOURCES = create_data_recipes.c kmo_multi_reconstruct-test.c
-kmo_multi_reconstruct_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_multi_reconstruct_test_LDADD = $(LDADD)
-
-kmo_fits_strip_test_SOURCES = create_data_recipes.c kmo_fits_strip-test.c
-kmo_fits_strip_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_fits_strip_test_LDADD = $(LDADD)
-
-kmo_final_test_SOURCES = kmo_final-test.c
-kmo_final_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_final_test_LDADD = $(LDADD)
-
-TESTS          = $(check_PROGRAMS)
-
-# Be sure to reexport important environment variables.
-TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
-        CPPFLAGS="$(CPPFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" \
-        LIBS="$(LIBS)" LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" \
-        OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)"
-
-# We need to remove any files that the above tests created.
-clean-local:
-	 $(RM) *.fits *.paf *.log *.sof lut_* *.txt
-	 $(RM) -rf test_data
diff --git a/recipes/tests/Makefile.in b/recipes/tests/Makefile.in
deleted file mode 100644
index 718872b..0000000
--- a/recipes/tests/Makefile.in
+++ /dev/null
@@ -1,1045 +0,0 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
- at SET_MAKE@
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-target_triplet = @target@
-check_PROGRAMS = kmo_init-test$(EXEEXT) kmo_arithmetic-test$(EXEEXT) \
-	kmo_combine-test$(EXEEXT) kmo_copy-test$(EXEEXT) \
-	kmo_dev_setup-test$(EXEEXT) kmo_extract_spec-test$(EXEEXT) \
-	kmo_fit_profile-test$(EXEEXT) kmo_fits_check-test$(EXEEXT) \
-	kmo_fits_stack-test$(EXEEXT) kmo_make_image-test$(EXEEXT) \
-	kmo_noise_map-test$(EXEEXT) kmo_rotate-test$(EXEEXT) \
-	kmo_shift-test$(EXEEXT) kmo_sky_mask-test$(EXEEXT) \
-	kmo_stats-test$(EXEEXT) kmo_dark-test$(EXEEXT) \
-	kmo_flat-test$(EXEEXT) kmo_wave_cal-test$(EXEEXT) \
-	kmo_reconstruct-test$(EXEEXT) kmo_illumination-test$(EXEEXT) \
-	kmo_illumination_flat-test$(EXEEXT) kmo_std_star-test$(EXEEXT) \
-	kmo_sci_red-test$(EXEEXT) kmo_multi_reconstruct-test$(EXEEXT) \
-	kmo_fits_strip-test$(EXEEXT) kmo_final-test$(EXEEXT)
-subdir = recipes/tests
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4macros/cpl.m4 \
-	$(top_srcdir)/m4macros/eso.m4 \
-	$(top_srcdir)/m4macros/libtool.m4 \
-	$(top_srcdir)/m4macros/ltoptions.m4 \
-	$(top_srcdir)/m4macros/ltsugar.m4 \
-	$(top_srcdir)/m4macros/ltversion.m4 \
-	$(top_srcdir)/m4macros/lt~obsolete.m4 \
-	$(top_srcdir)/m4macros/purify.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
-	$(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-am_kmo_arithmetic_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_arithmetic-test.$(OBJEXT)
-kmo_arithmetic_test_OBJECTS = $(am_kmo_arithmetic_test_OBJECTS)
-am__DEPENDENCIES_1 =
-am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
-kmo_arithmetic_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_arithmetic_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_arithmetic_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_combine_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_combine-test.$(OBJEXT)
-kmo_combine_test_OBJECTS = $(am_kmo_combine_test_OBJECTS)
-kmo_combine_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_combine_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_combine_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_copy_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_copy-test.$(OBJEXT)
-kmo_copy_test_OBJECTS = $(am_kmo_copy_test_OBJECTS)
-kmo_copy_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_copy_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_copy_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_dark_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_dark-test.$(OBJEXT)
-kmo_dark_test_OBJECTS = $(am_kmo_dark_test_OBJECTS)
-kmo_dark_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_dark_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_dark_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_dev_setup_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_dev_setup-test.$(OBJEXT)
-kmo_dev_setup_test_OBJECTS = $(am_kmo_dev_setup_test_OBJECTS)
-kmo_dev_setup_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_dev_setup_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_dev_setup_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_extract_spec_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_extract_spec-test.$(OBJEXT)
-kmo_extract_spec_test_OBJECTS = $(am_kmo_extract_spec_test_OBJECTS)
-kmo_extract_spec_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_extract_spec_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_extract_spec_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_final_test_OBJECTS = kmo_final-test.$(OBJEXT)
-kmo_final_test_OBJECTS = $(am_kmo_final_test_OBJECTS)
-kmo_final_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_final_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_final_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_fit_profile_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_fit_profile-test.$(OBJEXT)
-kmo_fit_profile_test_OBJECTS = $(am_kmo_fit_profile_test_OBJECTS)
-kmo_fit_profile_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_fit_profile_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_fit_profile_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_fits_check_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_fits_check-test.$(OBJEXT)
-kmo_fits_check_test_OBJECTS = $(am_kmo_fits_check_test_OBJECTS)
-kmo_fits_check_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_fits_check_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_fits_check_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_fits_stack_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_fits_stack-test.$(OBJEXT)
-kmo_fits_stack_test_OBJECTS = $(am_kmo_fits_stack_test_OBJECTS)
-kmo_fits_stack_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_fits_stack_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_fits_stack_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_fits_strip_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_fits_strip-test.$(OBJEXT)
-kmo_fits_strip_test_OBJECTS = $(am_kmo_fits_strip_test_OBJECTS)
-kmo_fits_strip_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_fits_strip_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_fits_strip_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_flat_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_flat-test.$(OBJEXT)
-kmo_flat_test_OBJECTS = $(am_kmo_flat_test_OBJECTS)
-kmo_flat_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_flat_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_flat_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_illumination_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_illumination-test.$(OBJEXT)
-kmo_illumination_test_OBJECTS = $(am_kmo_illumination_test_OBJECTS)
-kmo_illumination_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_illumination_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_illumination_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_illumination_flat_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_illumination_flat-test.$(OBJEXT)
-kmo_illumination_flat_test_OBJECTS =  \
-	$(am_kmo_illumination_flat_test_OBJECTS)
-kmo_illumination_flat_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_illumination_flat_test_LINK = $(LIBTOOL) --tag=CC \
-	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
-	$(AM_CFLAGS) $(CFLAGS) $(kmo_illumination_flat_test_LDFLAGS) \
-	$(LDFLAGS) -o $@
-am_kmo_init_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_init-test.$(OBJEXT)
-kmo_init_test_OBJECTS = $(am_kmo_init_test_OBJECTS)
-kmo_init_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_init_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_init_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_make_image_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_make_image-test.$(OBJEXT)
-kmo_make_image_test_OBJECTS = $(am_kmo_make_image_test_OBJECTS)
-kmo_make_image_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_make_image_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_make_image_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_multi_reconstruct_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_multi_reconstruct-test.$(OBJEXT)
-kmo_multi_reconstruct_test_OBJECTS =  \
-	$(am_kmo_multi_reconstruct_test_OBJECTS)
-kmo_multi_reconstruct_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_multi_reconstruct_test_LINK = $(LIBTOOL) --tag=CC \
-	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
-	$(AM_CFLAGS) $(CFLAGS) $(kmo_multi_reconstruct_test_LDFLAGS) \
-	$(LDFLAGS) -o $@
-am_kmo_noise_map_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_noise_map-test.$(OBJEXT)
-kmo_noise_map_test_OBJECTS = $(am_kmo_noise_map_test_OBJECTS)
-kmo_noise_map_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_noise_map_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_noise_map_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_reconstruct_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_reconstruct-test.$(OBJEXT)
-kmo_reconstruct_test_OBJECTS = $(am_kmo_reconstruct_test_OBJECTS)
-kmo_reconstruct_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_reconstruct_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_reconstruct_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_rotate_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_rotate-test.$(OBJEXT)
-kmo_rotate_test_OBJECTS = $(am_kmo_rotate_test_OBJECTS)
-kmo_rotate_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_rotate_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_rotate_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_sci_red_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_sci_red-test.$(OBJEXT)
-kmo_sci_red_test_OBJECTS = $(am_kmo_sci_red_test_OBJECTS)
-kmo_sci_red_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_sci_red_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_sci_red_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_shift_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_shift-test.$(OBJEXT)
-kmo_shift_test_OBJECTS = $(am_kmo_shift_test_OBJECTS)
-kmo_shift_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_shift_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_shift_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_sky_mask_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_sky_mask-test.$(OBJEXT)
-kmo_sky_mask_test_OBJECTS = $(am_kmo_sky_mask_test_OBJECTS)
-kmo_sky_mask_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_sky_mask_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_sky_mask_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_stats_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_stats-test.$(OBJEXT)
-kmo_stats_test_OBJECTS = $(am_kmo_stats_test_OBJECTS)
-kmo_stats_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_stats_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_stats_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_std_star_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_std_star-test.$(OBJEXT)
-kmo_std_star_test_OBJECTS = $(am_kmo_std_star_test_OBJECTS)
-kmo_std_star_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_std_star_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_std_star_test_LDFLAGS) $(LDFLAGS) -o $@
-am_kmo_wave_cal_test_OBJECTS = create_data_recipes.$(OBJEXT) \
-	kmo_wave_cal-test.$(OBJEXT)
-kmo_wave_cal_test_OBJECTS = $(am_kmo_wave_cal_test_OBJECTS)
-kmo_wave_cal_test_DEPENDENCIES = $(am__DEPENDENCIES_2)
-kmo_wave_cal_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(kmo_wave_cal_test_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/admin/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
-SOURCES = $(kmo_arithmetic_test_SOURCES) $(kmo_combine_test_SOURCES) \
-	$(kmo_copy_test_SOURCES) $(kmo_dark_test_SOURCES) \
-	$(kmo_dev_setup_test_SOURCES) $(kmo_extract_spec_test_SOURCES) \
-	$(kmo_final_test_SOURCES) $(kmo_fit_profile_test_SOURCES) \
-	$(kmo_fits_check_test_SOURCES) $(kmo_fits_stack_test_SOURCES) \
-	$(kmo_fits_strip_test_SOURCES) $(kmo_flat_test_SOURCES) \
-	$(kmo_illumination_test_SOURCES) \
-	$(kmo_illumination_flat_test_SOURCES) $(kmo_init_test_SOURCES) \
-	$(kmo_make_image_test_SOURCES) \
-	$(kmo_multi_reconstruct_test_SOURCES) \
-	$(kmo_noise_map_test_SOURCES) $(kmo_reconstruct_test_SOURCES) \
-	$(kmo_rotate_test_SOURCES) $(kmo_sci_red_test_SOURCES) \
-	$(kmo_shift_test_SOURCES) $(kmo_sky_mask_test_SOURCES) \
-	$(kmo_stats_test_SOURCES) $(kmo_std_star_test_SOURCES) \
-	$(kmo_wave_cal_test_SOURCES)
-DIST_SOURCES = $(kmo_arithmetic_test_SOURCES) \
-	$(kmo_combine_test_SOURCES) $(kmo_copy_test_SOURCES) \
-	$(kmo_dark_test_SOURCES) $(kmo_dev_setup_test_SOURCES) \
-	$(kmo_extract_spec_test_SOURCES) $(kmo_final_test_SOURCES) \
-	$(kmo_fit_profile_test_SOURCES) $(kmo_fits_check_test_SOURCES) \
-	$(kmo_fits_stack_test_SOURCES) $(kmo_fits_strip_test_SOURCES) \
-	$(kmo_flat_test_SOURCES) $(kmo_illumination_test_SOURCES) \
-	$(kmo_illumination_flat_test_SOURCES) $(kmo_init_test_SOURCES) \
-	$(kmo_make_image_test_SOURCES) \
-	$(kmo_multi_reconstruct_test_SOURCES) \
-	$(kmo_noise_map_test_SOURCES) $(kmo_reconstruct_test_SOURCES) \
-	$(kmo_rotate_test_SOURCES) $(kmo_sci_red_test_SOURCES) \
-	$(kmo_shift_test_SOURCES) $(kmo_sky_mask_test_SOURCES) \
-	$(kmo_stats_test_SOURCES) $(kmo_std_star_test_SOURCES) \
-	$(kmo_wave_cal_test_SOURCES)
-ETAGS = etags
-CTAGS = ctags
-am__tty_colors = \
-red=; grn=; lgn=; blu=; std=
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-AMTAR = @AMTAR@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPL_INCLUDES = @CPL_INCLUDES@
-CPL_LDFLAGS = @CPL_LDFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CX_INCLUDES = @CX_INCLUDES@
-CX_LDFLAGS = @CX_LDFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DLLTOOL = @DLLTOOL@
-DOXYGEN = @DOXYGEN@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-ESO_DEBUG_FLAGS = @ESO_DEBUG_FLAGS@
-EXEEXT = @EXEEXT@
-FGREP = @FGREP@
-GREP = @GREP@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-KMOS_BINARY_AGE = @KMOS_BINARY_AGE@
-KMOS_BINARY_VERSION = @KMOS_BINARY_VERSION@
-KMOS_INCLUDES = @KMOS_INCLUDES@
-KMOS_INTERFACE_AGE = @KMOS_INTERFACE_AGE@
-KMOS_LDFLAGS = @KMOS_LDFLAGS@
-KMOS_MAJOR_VERSION = @KMOS_MAJOR_VERSION@
-KMOS_MICRO_VERSION = @KMOS_MICRO_VERSION@
-KMOS_MINOR_VERSION = @KMOS_MINOR_VERSION@
-KMOS_VERSION = @KMOS_VERSION@
-LATEX = @LATEX@
-LD = @LD@
-LDFLAGS = @LDFLAGS@
-LIBCEXT = @LIBCEXT@
-LIBCPLCORE = @LIBCPLCORE@
-LIBCPLDFS = @LIBCPLDFS@
-LIBCPLDRS = @LIBCPLDRS@
-LIBCPLUI = @LIBCPLUI@
-LIBIRPLIB = @LIBIRPLIB@
-LIBKMCLIPMLIB = @LIBKMCLIPMLIB@
-LIBKMOS = @LIBKMOS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-LIPO = @LIPO@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-LT_AGE = @LT_AGE@
-LT_CURRENT = @LT_CURRENT@
-LT_REVISION = @LT_REVISION@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MANIFEST_TOOL = @MANIFEST_TOOL@
-MKDIR_P = @MKDIR_P@
-NM = @NM@
-NMEDIT = @NMEDIT@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-OTOOL = @OTOOL@
-OTOOL64 = @OTOOL64@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PURIFY_CMD = @PURIFY_CMD@
-RANLIB = @RANLIB@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-all_includes = @all_includes@
-all_ldflags = @all_ldflags@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-apidocdir = @apidocdir@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-configdir = @configdir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-pipedocsdir = @pipedocsdir@
-plugindir = @plugindir@
-prefix = @prefix@
-privatelibdir = @privatelibdir@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target = @target@
-target_alias = @target_alias@
-target_cpu = @target_cpu@
-target_os = @target_os@
-target_vendor = @target_vendor@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-wkfcopydir = @wkfcopydir@
-wkfextradir = @wkfextradir@
-AUTOMAKE_OPTIONS = 1.8 foreign
-DISTCLEANFILES = *~
-EXTRA_DIST = ref_data
- at MAINTAINER_MODE_TRUE@MAINTAINERCLEANFILES = Makefile.in
-INCLUDES = $(all_includes) 
-#INCLUDES = $(all_includes) -I../../kmclipm/include/
-LDADD = $(LIBCPLDFS) $(LIBCPLUI) $(LIBCPLDRS) $(LIBCPLCORE) $(LIBKMOS)
-kmo_init_test_SOURCES = create_data_recipes.c kmo_init-test.c
-kmo_init_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_init_test_LDADD = $(LDADD)
-kmo_arithmetic_test_SOURCES = create_data_recipes.c kmo_arithmetic-test.c
-kmo_arithmetic_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_arithmetic_test_LDADD = $(LDADD)
-kmo_combine_test_SOURCES = create_data_recipes.c kmo_combine-test.c
-kmo_combine_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_combine_test_LDADD = $(LDADD)
-kmo_copy_test_SOURCES = create_data_recipes.c kmo_copy-test.c
-kmo_copy_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_copy_test_LDADD = $(LDADD)
-kmo_dev_setup_test_SOURCES = create_data_recipes.c kmo_dev_setup-test.c
-kmo_dev_setup_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_dev_setup_test_LDADD = $(LDADD)
-kmo_extract_spec_test_SOURCES = create_data_recipes.c kmo_extract_spec-test.c
-kmo_extract_spec_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_extract_spec_test_LDADD = $(LDADD)
-kmo_fit_profile_test_SOURCES = create_data_recipes.c kmo_fit_profile-test.c
-kmo_fit_profile_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_fit_profile_test_LDADD = $(LDADD)
-kmo_fits_check_test_SOURCES = create_data_recipes.c kmo_fits_check-test.c
-kmo_fits_check_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_fits_check_test_LDADD = $(LDADD)
-kmo_fits_stack_test_SOURCES = create_data_recipes.c kmo_fits_stack-test.c
-kmo_fits_stack_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_fits_stack_test_LDADD = $(LDADD)
-kmo_make_image_test_SOURCES = create_data_recipes.c kmo_make_image-test.c
-kmo_make_image_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_make_image_test_LDADD = $(LDADD)
-kmo_noise_map_test_SOURCES = create_data_recipes.c kmo_noise_map-test.c
-kmo_noise_map_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_noise_map_test_LDADD = $(LDADD)
-kmo_rotate_test_SOURCES = create_data_recipes.c kmo_rotate-test.c
-kmo_rotate_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_rotate_test_LDADD = $(LDADD)
-kmo_shift_test_SOURCES = create_data_recipes.c kmo_shift-test.c
-kmo_shift_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_shift_test_LDADD = $(LDADD)
-kmo_sky_mask_test_SOURCES = create_data_recipes.c kmo_sky_mask-test.c
-kmo_sky_mask_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_sky_mask_test_LDADD = $(LDADD)
-kmo_stats_test_SOURCES = create_data_recipes.c kmo_stats-test.c
-kmo_stats_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_stats_test_LDADD = $(LDADD)
-kmo_dark_test_SOURCES = create_data_recipes.c kmo_dark-test.c
-kmo_dark_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_dark_test_LDADD = $(LDADD)
-kmo_flat_test_SOURCES = create_data_recipes.c kmo_flat-test.c
-kmo_flat_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_flat_test_LDADD = $(LDADD)
-kmo_wave_cal_test_SOURCES = create_data_recipes.c kmo_wave_cal-test.c
-kmo_wave_cal_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_wave_cal_test_LDADD = $(LDADD)
-kmo_reconstruct_test_SOURCES = create_data_recipes.c kmo_reconstruct-test.c
-kmo_reconstruct_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_reconstruct_test_LDADD = $(LDADD)
-kmo_illumination_test_SOURCES = create_data_recipes.c kmo_illumination-test.c
-kmo_illumination_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_illumination_test_LDADD = $(LDADD)
-kmo_illumination_flat_test_SOURCES = create_data_recipes.c kmo_illumination_flat-test.c
-kmo_illumination_flat_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_illumination_flat_test_LDADD = $(LDADD)
-kmo_std_star_test_SOURCES = create_data_recipes.c kmo_std_star-test.c
-kmo_std_star_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_std_star_test_LDADD = $(LDADD)
-kmo_sci_red_test_SOURCES = create_data_recipes.c kmo_sci_red-test.c
-kmo_sci_red_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_sci_red_test_LDADD = $(LDADD)
-kmo_multi_reconstruct_test_SOURCES = create_data_recipes.c kmo_multi_reconstruct-test.c
-kmo_multi_reconstruct_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_multi_reconstruct_test_LDADD = $(LDADD)
-kmo_fits_strip_test_SOURCES = create_data_recipes.c kmo_fits_strip-test.c
-kmo_fits_strip_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_fits_strip_test_LDADD = $(LDADD)
-kmo_final_test_SOURCES = kmo_final-test.c
-kmo_final_test_LDFLAGS = $(CPL_LDFLAGS)
-kmo_final_test_LDADD = $(LDADD)
-TESTS = $(check_PROGRAMS)
-
-# Be sure to reexport important environment variables.
-TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
-        CPPFLAGS="$(CPPFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" \
-        LIBS="$(LIBS)" LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" \
-        OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)"
-
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
-	@for dep in $?; do \
-	  case '$(am__configure_deps)' in \
-	    *$$dep*) \
-	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
-	        && { if test -f $@; then exit 0; else break; fi; }; \
-	      exit 1;; \
-	  esac; \
-	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign recipes/tests/Makefile'; \
-	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign recipes/tests/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
-	@case '$?' in \
-	  *config.status*) \
-	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
-	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
-	esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-clean-checkPROGRAMS:
-	@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
-	echo " rm -f" $$list; \
-	rm -f $$list || exit $$?; \
-	test -n "$(EXEEXT)" || exit 0; \
-	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
-	echo " rm -f" $$list; \
-	rm -f $$list
-kmo_arithmetic-test$(EXEEXT): $(kmo_arithmetic_test_OBJECTS) $(kmo_arithmetic_test_DEPENDENCIES) $(EXTRA_kmo_arithmetic_test_DEPENDENCIES) 
-	@rm -f kmo_arithmetic-test$(EXEEXT)
-	$(kmo_arithmetic_test_LINK) $(kmo_arithmetic_test_OBJECTS) $(kmo_arithmetic_test_LDADD) $(LIBS)
-kmo_combine-test$(EXEEXT): $(kmo_combine_test_OBJECTS) $(kmo_combine_test_DEPENDENCIES) $(EXTRA_kmo_combine_test_DEPENDENCIES) 
-	@rm -f kmo_combine-test$(EXEEXT)
-	$(kmo_combine_test_LINK) $(kmo_combine_test_OBJECTS) $(kmo_combine_test_LDADD) $(LIBS)
-kmo_copy-test$(EXEEXT): $(kmo_copy_test_OBJECTS) $(kmo_copy_test_DEPENDENCIES) $(EXTRA_kmo_copy_test_DEPENDENCIES) 
-	@rm -f kmo_copy-test$(EXEEXT)
-	$(kmo_copy_test_LINK) $(kmo_copy_test_OBJECTS) $(kmo_copy_test_LDADD) $(LIBS)
-kmo_dark-test$(EXEEXT): $(kmo_dark_test_OBJECTS) $(kmo_dark_test_DEPENDENCIES) $(EXTRA_kmo_dark_test_DEPENDENCIES) 
-	@rm -f kmo_dark-test$(EXEEXT)
-	$(kmo_dark_test_LINK) $(kmo_dark_test_OBJECTS) $(kmo_dark_test_LDADD) $(LIBS)
-kmo_dev_setup-test$(EXEEXT): $(kmo_dev_setup_test_OBJECTS) $(kmo_dev_setup_test_DEPENDENCIES) $(EXTRA_kmo_dev_setup_test_DEPENDENCIES) 
-	@rm -f kmo_dev_setup-test$(EXEEXT)
-	$(kmo_dev_setup_test_LINK) $(kmo_dev_setup_test_OBJECTS) $(kmo_dev_setup_test_LDADD) $(LIBS)
-kmo_extract_spec-test$(EXEEXT): $(kmo_extract_spec_test_OBJECTS) $(kmo_extract_spec_test_DEPENDENCIES) $(EXTRA_kmo_extract_spec_test_DEPENDENCIES) 
-	@rm -f kmo_extract_spec-test$(EXEEXT)
-	$(kmo_extract_spec_test_LINK) $(kmo_extract_spec_test_OBJECTS) $(kmo_extract_spec_test_LDADD) $(LIBS)
-kmo_final-test$(EXEEXT): $(kmo_final_test_OBJECTS) $(kmo_final_test_DEPENDENCIES) $(EXTRA_kmo_final_test_DEPENDENCIES) 
-	@rm -f kmo_final-test$(EXEEXT)
-	$(kmo_final_test_LINK) $(kmo_final_test_OBJECTS) $(kmo_final_test_LDADD) $(LIBS)
-kmo_fit_profile-test$(EXEEXT): $(kmo_fit_profile_test_OBJECTS) $(kmo_fit_profile_test_DEPENDENCIES) $(EXTRA_kmo_fit_profile_test_DEPENDENCIES) 
-	@rm -f kmo_fit_profile-test$(EXEEXT)
-	$(kmo_fit_profile_test_LINK) $(kmo_fit_profile_test_OBJECTS) $(kmo_fit_profile_test_LDADD) $(LIBS)
-kmo_fits_check-test$(EXEEXT): $(kmo_fits_check_test_OBJECTS) $(kmo_fits_check_test_DEPENDENCIES) $(EXTRA_kmo_fits_check_test_DEPENDENCIES) 
-	@rm -f kmo_fits_check-test$(EXEEXT)
-	$(kmo_fits_check_test_LINK) $(kmo_fits_check_test_OBJECTS) $(kmo_fits_check_test_LDADD) $(LIBS)
-kmo_fits_stack-test$(EXEEXT): $(kmo_fits_stack_test_OBJECTS) $(kmo_fits_stack_test_DEPENDENCIES) $(EXTRA_kmo_fits_stack_test_DEPENDENCIES) 
-	@rm -f kmo_fits_stack-test$(EXEEXT)
-	$(kmo_fits_stack_test_LINK) $(kmo_fits_stack_test_OBJECTS) $(kmo_fits_stack_test_LDADD) $(LIBS)
-kmo_fits_strip-test$(EXEEXT): $(kmo_fits_strip_test_OBJECTS) $(kmo_fits_strip_test_DEPENDENCIES) $(EXTRA_kmo_fits_strip_test_DEPENDENCIES) 
-	@rm -f kmo_fits_strip-test$(EXEEXT)
-	$(kmo_fits_strip_test_LINK) $(kmo_fits_strip_test_OBJECTS) $(kmo_fits_strip_test_LDADD) $(LIBS)
-kmo_flat-test$(EXEEXT): $(kmo_flat_test_OBJECTS) $(kmo_flat_test_DEPENDENCIES) $(EXTRA_kmo_flat_test_DEPENDENCIES) 
-	@rm -f kmo_flat-test$(EXEEXT)
-	$(kmo_flat_test_LINK) $(kmo_flat_test_OBJECTS) $(kmo_flat_test_LDADD) $(LIBS)
-kmo_illumination-test$(EXEEXT): $(kmo_illumination_test_OBJECTS) $(kmo_illumination_test_DEPENDENCIES) $(EXTRA_kmo_illumination_test_DEPENDENCIES) 
-	@rm -f kmo_illumination-test$(EXEEXT)
-	$(kmo_illumination_test_LINK) $(kmo_illumination_test_OBJECTS) $(kmo_illumination_test_LDADD) $(LIBS)
-kmo_illumination_flat-test$(EXEEXT): $(kmo_illumination_flat_test_OBJECTS) $(kmo_illumination_flat_test_DEPENDENCIES) $(EXTRA_kmo_illumination_flat_test_DEPENDENCIES) 
-	@rm -f kmo_illumination_flat-test$(EXEEXT)
-	$(kmo_illumination_flat_test_LINK) $(kmo_illumination_flat_test_OBJECTS) $(kmo_illumination_flat_test_LDADD) $(LIBS)
-kmo_init-test$(EXEEXT): $(kmo_init_test_OBJECTS) $(kmo_init_test_DEPENDENCIES) $(EXTRA_kmo_init_test_DEPENDENCIES) 
-	@rm -f kmo_init-test$(EXEEXT)
-	$(kmo_init_test_LINK) $(kmo_init_test_OBJECTS) $(kmo_init_test_LDADD) $(LIBS)
-kmo_make_image-test$(EXEEXT): $(kmo_make_image_test_OBJECTS) $(kmo_make_image_test_DEPENDENCIES) $(EXTRA_kmo_make_image_test_DEPENDENCIES) 
-	@rm -f kmo_make_image-test$(EXEEXT)
-	$(kmo_make_image_test_LINK) $(kmo_make_image_test_OBJECTS) $(kmo_make_image_test_LDADD) $(LIBS)
-kmo_multi_reconstruct-test$(EXEEXT): $(kmo_multi_reconstruct_test_OBJECTS) $(kmo_multi_reconstruct_test_DEPENDENCIES) $(EXTRA_kmo_multi_reconstruct_test_DEPENDENCIES) 
-	@rm -f kmo_multi_reconstruct-test$(EXEEXT)
-	$(kmo_multi_reconstruct_test_LINK) $(kmo_multi_reconstruct_test_OBJECTS) $(kmo_multi_reconstruct_test_LDADD) $(LIBS)
-kmo_noise_map-test$(EXEEXT): $(kmo_noise_map_test_OBJECTS) $(kmo_noise_map_test_DEPENDENCIES) $(EXTRA_kmo_noise_map_test_DEPENDENCIES) 
-	@rm -f kmo_noise_map-test$(EXEEXT)
-	$(kmo_noise_map_test_LINK) $(kmo_noise_map_test_OBJECTS) $(kmo_noise_map_test_LDADD) $(LIBS)
-kmo_reconstruct-test$(EXEEXT): $(kmo_reconstruct_test_OBJECTS) $(kmo_reconstruct_test_DEPENDENCIES) $(EXTRA_kmo_reconstruct_test_DEPENDENCIES) 
-	@rm -f kmo_reconstruct-test$(EXEEXT)
-	$(kmo_reconstruct_test_LINK) $(kmo_reconstruct_test_OBJECTS) $(kmo_reconstruct_test_LDADD) $(LIBS)
-kmo_rotate-test$(EXEEXT): $(kmo_rotate_test_OBJECTS) $(kmo_rotate_test_DEPENDENCIES) $(EXTRA_kmo_rotate_test_DEPENDENCIES) 
-	@rm -f kmo_rotate-test$(EXEEXT)
-	$(kmo_rotate_test_LINK) $(kmo_rotate_test_OBJECTS) $(kmo_rotate_test_LDADD) $(LIBS)
-kmo_sci_red-test$(EXEEXT): $(kmo_sci_red_test_OBJECTS) $(kmo_sci_red_test_DEPENDENCIES) $(EXTRA_kmo_sci_red_test_DEPENDENCIES) 
-	@rm -f kmo_sci_red-test$(EXEEXT)
-	$(kmo_sci_red_test_LINK) $(kmo_sci_red_test_OBJECTS) $(kmo_sci_red_test_LDADD) $(LIBS)
-kmo_shift-test$(EXEEXT): $(kmo_shift_test_OBJECTS) $(kmo_shift_test_DEPENDENCIES) $(EXTRA_kmo_shift_test_DEPENDENCIES) 
-	@rm -f kmo_shift-test$(EXEEXT)
-	$(kmo_shift_test_LINK) $(kmo_shift_test_OBJECTS) $(kmo_shift_test_LDADD) $(LIBS)
-kmo_sky_mask-test$(EXEEXT): $(kmo_sky_mask_test_OBJECTS) $(kmo_sky_mask_test_DEPENDENCIES) $(EXTRA_kmo_sky_mask_test_DEPENDENCIES) 
-	@rm -f kmo_sky_mask-test$(EXEEXT)
-	$(kmo_sky_mask_test_LINK) $(kmo_sky_mask_test_OBJECTS) $(kmo_sky_mask_test_LDADD) $(LIBS)
-kmo_stats-test$(EXEEXT): $(kmo_stats_test_OBJECTS) $(kmo_stats_test_DEPENDENCIES) $(EXTRA_kmo_stats_test_DEPENDENCIES) 
-	@rm -f kmo_stats-test$(EXEEXT)
-	$(kmo_stats_test_LINK) $(kmo_stats_test_OBJECTS) $(kmo_stats_test_LDADD) $(LIBS)
-kmo_std_star-test$(EXEEXT): $(kmo_std_star_test_OBJECTS) $(kmo_std_star_test_DEPENDENCIES) $(EXTRA_kmo_std_star_test_DEPENDENCIES) 
-	@rm -f kmo_std_star-test$(EXEEXT)
-	$(kmo_std_star_test_LINK) $(kmo_std_star_test_OBJECTS) $(kmo_std_star_test_LDADD) $(LIBS)
-kmo_wave_cal-test$(EXEEXT): $(kmo_wave_cal_test_OBJECTS) $(kmo_wave_cal_test_DEPENDENCIES) $(EXTRA_kmo_wave_cal_test_DEPENDENCIES) 
-	@rm -f kmo_wave_cal-test$(EXEEXT)
-	$(kmo_wave_cal_test_LINK) $(kmo_wave_cal_test_OBJECTS) $(kmo_wave_cal_test_LDADD) $(LIBS)
-
-mostlyclean-compile:
-	-rm -f *.$(OBJEXT)
-
-distclean-compile:
-	-rm -f *.tab.c
-
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_data_recipes.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_arithmetic-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_combine-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_copy-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_dark-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_dev_setup-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_extract_spec-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_final-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_fit_profile-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_fits_check-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_fits_stack-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_fits_strip-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_flat-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_illumination-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_illumination_flat-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_init-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_make_image-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_multi_reconstruct-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_noise_map-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_reconstruct-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_rotate-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_sci_red-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_shift-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_sky_mask-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_stats-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_std_star-test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/kmo_wave_cal-test.Po at am__quote@
-
-.c.o:
- at am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(COMPILE) -c $<
-
-.c.obj:
- at am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
- at am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
-	-rm -f *.lo
-
-clean-libtool:
-	-rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	set x; \
-	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	shift; \
-	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
-	  test -n "$$unique" || unique=$$empty_fix; \
-	  if test $$# -gt 0; then \
-	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	      "$$@" $$unique; \
-	  else \
-	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	      $$unique; \
-	  fi; \
-	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$unique" \
-	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$unique
-
-GTAGS:
-	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && $(am__cd) $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) "$$here"
-
-distclean-tags:
-	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-check-TESTS: $(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list=' $(TESTS) '; \
-	$(am__tty_colors); \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *[\ \	]$$tst[\ \	]*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		col=$$red; res=XPASS; \
-	      ;; \
-	      *) \
-		col=$$grn; res=PASS; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *[\ \	]$$tst[\ \	]*) \
-		xfail=`expr $$xfail + 1`; \
-		col=$$lgn; res=XFAIL; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		col=$$red; res=FAIL; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      col=$$blu; res=SKIP; \
-	    fi; \
-	    echo "$${col}$$res$${std}: $$tst"; \
-	  done; \
-	  if test "$$all" -eq 1; then \
-	    tests="test"; \
-	    All=""; \
-	  else \
-	    tests="tests"; \
-	    All="All "; \
-	  fi; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="$$All$$all $$tests passed"; \
-	    else \
-	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
-	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all $$tests failed"; \
-	    else \
-	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
-	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
-	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    if test "$$skip" -eq 1; then \
-	      skipped="($$skip test was not run)"; \
-	    else \
-	      skipped="($$skip tests were not run)"; \
-	    fi; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  if test "$$failed" -eq 0; then \
-	    col="$$grn"; \
-	  else \
-	    col="$$red"; \
-	  fi; \
-	  echo "$${col}$$dashes$${std}"; \
-	  echo "$${col}$$banner$${std}"; \
-	  test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
-	  test -z "$$report" || echo "$${col}$$report$${std}"; \
-	  echo "$${col}$$dashes$${std}"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
-
-distdir: $(DISTFILES)
-	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	list='$(DISTFILES)'; \
-	  dist_files=`for file in $$list; do echo $$file; done | \
-	  sed -e "s|^$$srcdirstrip/||;t" \
-	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
-	case $$dist_files in \
-	  */*) $(MKDIR_P) `echo "$$dist_files" | \
-			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
-			   sort -u` ;; \
-	esac; \
-	for file in $$dist_files; do \
-	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-	  if test -d $$d/$$file; then \
-	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
-	    if test -d "$(distdir)/$$file"; then \
-	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
-	    fi; \
-	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
-	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
-	    fi; \
-	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
-	  else \
-	    test -f "$(distdir)/$$file" \
-	    || cp -p $$d/$$file "$(distdir)/$$file" \
-	    || exit 1; \
-	  fi; \
-	done
-check-am: all-am
-	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
-check: check-am
-all-am: Makefile
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
-	if test -z '$(STRIP)'; then \
-	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	      install; \
-	else \
-	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
-	fi
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
-
-maintainer-clean-generic:
-	@echo "This command is intended for maintainers to use"
-	@echo "it deletes files that may require special tools to rebuild."
-	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-clean: clean-am
-
-clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \
-	mostlyclean-am
-
-distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am:
-
-.MAKE: check-am install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
-	clean-checkPROGRAMS clean-generic clean-libtool clean-local \
-	ctags distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-compile \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags uninstall uninstall-am
-
-
-# We need to remove any files that the above tests created.
-clean-local:
-	 $(RM) *.fits *.paf *.log *.sof lut_* *.txt
-	 $(RM) -rf test_data
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/recipes/tests/create_data_recipes.c b/recipes/tests/create_data_recipes.c
deleted file mode 100644
index 2b1ebb4..0000000
--- a/recipes/tests/create_data_recipes.c
+++ /dev/null
@@ -1,2349 +0,0 @@
-/* $Id: kmo_test_create_data.c,v 1.10 2013-02-28 10:10:23 aagudo Exp $
- *
- * This file is part of the KMOS Pipeline
- * Copyright (C) 2002,2003 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Automatic data generation functions
- *
- * who       when        what
- * --------  ----------  ----------------------------------------------
- * aagudo    2008-02-06  created
- *
- * The functions in this file are only used in functions generating test data
- * in kmos/tests and recipes/tests, therefore no test functions are provided
- * for the functions present here. (This file has to be loccated here since it
- * is referred to from kmos/tests and recipes/tests)
- *
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-02-28 10:10:23 $,
-                               ""
- * $Revision: 1.10 $
- * $Name: not supported by cvs2svn $
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#include "kmo_dfs.h"
-#include "kmo_constants.h"
-#include "kmo_debug.h"
-#include "kmo_error.h"
-#include "kmo_utils.h"
-#include "kmo_cpl_extensions.h"
-
-/*----------------------------------------------------------------------------*/
-/**
-    @defgroup kmos_test_create_data     Helper functions for recipe kmo_test_create_data.
-
-    This is used for internal unit tests only.
-
-    @{
- */
-/*----------------------------------------------------------------------------*/
-
-float   test_global_seed_data            = 1.1,
-        test_global_seed_noise           = 0.1;
-
-int     test_global_size_x               = 5,
-        test_global_size_y               = 6,
-        test_global_size_z               = 7,
-        test_global_nr_frames            = 5;
-
-const char  *test_global_path_test_data  = "test_data/";
-
-// !!! global_valid MUST have size of nr_ifus !!!
-int test_global_valid[] =  {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, \
-                       TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, \
-                       TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE};
-
-/**
-    @brief Checks if a file or folder of a given name exists.
-
-    @param name The name of the file or folder to check.
-
-    @return
-        TRUE if the file or folder exists, FALSE otherwise.
-*/
-int kmo_test_file_exists(const char *name)
-{
-    struct stat buf;
-
-    if (stat(name, &buf) == 0) {
-        return TRUE;
-    }
-    return FALSE;
-}
-
-/**
-    @brief Concatenates to strings.
-
-    @param new      The concatenated string.
-    @param string1  The first string.
-    @param string2  The second string.
-
-    @return         The concatenated string.
-*/
-const char* kmo_test_cat_strings(char *newstr, const char *string1, const char *string2)
-{
-    KMO_TRY
-    {
-        KMO_TRY_ASSURE(newstr != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "First char pointer has to be allocated!");
-
-        KMO_TRY_ASSURE(string1 != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Second char pointer mustn't be NULL!");
-
-        KMO_TRY_ASSURE(string2 != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Third char pointer mustn't be NULL!");
-
-        strcpy(newstr, string1);
-        strcat(newstr, string2);
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-
-    }
-
-    return newstr;
-}
-
-/**
-    @brief Switches off error-messages.
-*/
-void kmo_test_verbose_off()
-{
-    if (getenv("KMO_TEST_VERBOSE") == NULL) {
-        cpl_msg_set_level(CPL_MSG_OFF);
-    }
-}
-
-/**
-    @brief Switches on error-messages.
-*/
-void kmo_test_verbose_on()
-{
-    if (getenv("KMO_TEST_VERBOSE") == NULL) {
-        cpl_msg_set_level(CPL_MSG_WARNING);
-    }
-}
-
-/**
-    @brief Switches on or off error-messages for esorex-calls.
-*/
-const char* kmo_test_esorex_verbose()
-{
-    if (getenv("KMO_TEST_VERBOSE") == NULL) {
-        return " --msg-level=off ";
-    } else {
-        return " --msg-level=info ";
-    }
-}
-
-void kmo_get_pipe_command(char *cmd, const char *filename, const char *sof, int extend)
-{
-    FILE *fd = NULL;
-    if (extend) {
-        fd = fopen(filename, "a+");
-    } else {
-        fd = fopen(filename, "w");
-    }
-    fprintf(fd, "%s\n", "**********************************************************");
-    fprintf(fd, "%s\n", cmd);
-    if (sof != NULL) {
-        fprintf(fd, "\nWith %s:\n------------------\n", sof);
-        fclose(fd);
-
-        char sofcmd[1024];
-        sprintf(sofcmd, "cat %s >> %s", sof, filename);
-        system(sofcmd);
-        fd = fopen(filename, "a+");
-    }
-    fprintf(fd, "%s\n", "**********************************************************");
-    fclose(fd);
-
-    strcat(cmd, " >> ");
-    strcat(cmd, filename);
-    strcat(cmd, " 2>&1 ");
-}
-
-/**
-    @brief
-        Calculates the sum of the mean of all data extensions (data and noise).
-
-    @param filename     The keyword belonging to the recipe. Internally it is
-                        converted to the corresponding filename generated by
-                        esorex
-    @paraam dont_lower  TRUE if @c filename shouldn't be set lowercase,
-                        FALSE otherwise
-
-    @return The sum of the mean of all valid data extensions.
-*/
-double kmo_test_esorex_data(const char* filename, int dont_lower)
-{
-    double          ret_val     = 0.0,
-                    data_val    = 0.0,
-                    noise_val   = 0.0;
-
-    main_fits_desc  desc;
-
-    int             nr_devices  = 0,
-                    i           = 0,
-                    j           = 0,
-                    valid_ifu   = FALSE,
-                    index_data  = 0,
-                    index_noise = 0,
-                    devnr       = 0;
-
-    char            name[256];
-
-    const char      **ptbl_names    = NULL;
-
-    cpl_image       *img        = NULL;
-
-    cpl_imagelist   *img_list   = NULL;
-
-    kmclipm_vector  *vec        = NULL;
-
-    cpl_table       *tbl        = NULL;
-
-    cpl_array       *tbl_names  = NULL;
-
-    KMO_TRY
-    {
-        KMO_TRY_ASSURE(filename != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "No filename is provided!");
-
-        // setup correct filename
-        strcpy(name, filename);
-        if (!dont_lower) {
-            kmo_strlower(name);
-        }
-        strcat(name, ".fits");
-
-        kmo_init_fits_desc(&desc);
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        desc = kmo_identify_fits_header(name);
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        // --- load data ---
-        if (desc.ex_noise == TRUE) {
-            nr_devices = desc.nr_ext / 2;
-        } else {
-            nr_devices = desc.nr_ext;
-        }
-
-        for (i = 1; i <= nr_devices; i++) {
-            if (desc.ex_noise == FALSE) {
-                devnr = desc.sub_desc[i - 1].device_nr;
-            } else {
-                devnr = desc.sub_desc[2 * i - 1].device_nr;
-            }
-
-            valid_ifu = FALSE;
-            if (desc.ex_badpix == FALSE) {
-                index_data = kmo_identify_index(name, devnr, FALSE);
-            } else {
-                index_data = kmo_identify_index(name, devnr, 2);
-            }
-            KMO_TRY_CHECK_ERROR_STATE();
-
-//            if (desc.ex_noise == FALSE) {
-                if (desc.sub_desc[index_data-1].valid_data == TRUE) {
-                    valid_ifu = TRUE;
-                }
-//            } else {
-//                if (desc.sub_desc[2 * i - 1].valid_data == TRUE) {
-//                    valid_ifu = TRUE;
-//                }
-//            }
-            KMO_TRY_CHECK_ERROR_STATE();
-
-            if (valid_ifu) {
-                if ((desc.fits_type == f2i_fits) ||
-                    (desc.fits_type == f2d_fits) ||
-                    (desc.fits_type == b2d_fits) ||
-                    (desc.fits_type == raw_fits))
-                {
-                    KMO_TRY_EXIT_IF_NULL(
-                        img = kmclipm_image_load(name, CPL_TYPE_FLOAT, 0,
-                                                 index_data));
-
-                    data_val += cpl_image_get_mean(img);
-                    if (cpl_error_get_code() ==  CPL_ERROR_DATA_NOT_FOUND) {
-                        // whole image is rejected
-                        cpl_error_reset();
-                    }
-
-                    cpl_image_delete(img); img = NULL;
-
-                    if (desc.ex_noise == TRUE) {
-                        index_noise = kmo_identify_index(name, devnr, TRUE);
-                        KMO_TRY_CHECK_ERROR_STATE();
-
-                        if (desc.sub_desc[index_noise-1].valid_data) {
-                            KMO_TRY_EXIT_IF_NULL(
-                                img = kmclipm_image_load(name, CPL_TYPE_FLOAT,
-                                                         0, index_noise));
-
-                            noise_val += cpl_image_get_mean(img);
-                            if (cpl_error_get_code()==CPL_ERROR_DATA_NOT_FOUND) {
-                                // whole image is rejected
-                                cpl_error_reset();
-                            }
-                            cpl_image_delete(img); img = NULL;
-                        }
-                    }
-                } else if (desc.fits_type == f3i_fits) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        img_list = kmclipm_imagelist_load(name,
-                                                          CPL_TYPE_FLOAT,
-                                                          index_data));
-
-                    KMO_TRY_EXIT_IF_NULL(
-                        img = cpl_imagelist_collapse_create (img_list));
-
-                    data_val += cpl_image_get_mean(img);
-                    if (cpl_error_get_code() ==  CPL_ERROR_DATA_NOT_FOUND) {
-                        // whole image is rejected
-                        cpl_error_reset();
-                    }
-
-                    cpl_image_delete(img); img = NULL;
-                    cpl_imagelist_delete(img_list); img_list = NULL;
-
-                    if (desc.ex_noise == TRUE) {
-                        index_noise = kmo_identify_index(name, devnr, TRUE);
-                        KMO_TRY_CHECK_ERROR_STATE();
-
-                        if (desc.sub_desc[index_noise-1].valid_data) {
-                            KMO_TRY_EXIT_IF_NULL(
-                                img_list = kmclipm_imagelist_load(name,
-                                                                  CPL_TYPE_FLOAT,
-                                                                  index_noise));
-
-
-                            img = cpl_imagelist_collapse_create(img_list);
-                            if (cpl_error_get_code()==CPL_ERROR_DIVISION_BY_ZERO)
-                            {
-                                // Fix for CPL 6.1.1 and above (if NaN-cube
-                                // provided cpl_imagelist_collapse_create() now
-                                // throws, before it returned a 0-image)
-                                cpl_error_reset();
-                                cpl_image *tmp = cpl_imagelist_get(img_list, 0);
-                                img = cpl_image_new(cpl_image_get_size_x(tmp),
-                                                    cpl_image_get_size_y(tmp),
-                                                    CPL_TYPE_FLOAT);
-                                kmo_image_fill(img, 0.0);
-                            }
-
-                            noise_val += cpl_image_get_mean(img);
-                            if (cpl_error_get_code()==CPL_ERROR_DATA_NOT_FOUND) {
-                                // whole image is rejected
-                                cpl_error_reset();
-                            }
-
-                            cpl_image_delete(img); img = NULL;
-                            cpl_imagelist_delete(img_list); img_list = NULL;
-                        }
-                    }
-                }  else if ((desc.fits_type == f1i_fits) ||
-                            (desc.fits_type == f1d_fits)) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        vec = kmclipm_vector_load(name, index_data));
-
-                    data_val += kmclipm_vector_get_mean(vec);
-
-                    kmclipm_vector_delete(vec); vec = NULL;
-
-                    if (desc.ex_noise == TRUE) {
-                        index_noise = kmo_identify_index(name, devnr, TRUE);
-                        KMO_TRY_CHECK_ERROR_STATE();
-
-                        if (desc.sub_desc[index_noise-1].valid_data) {
-                            KMO_TRY_EXIT_IF_NULL(
-                                vec = kmclipm_vector_load(name, index_noise));
-
-                            noise_val += kmclipm_vector_get_mean(vec);
-
-                            kmclipm_vector_delete(vec); vec = NULL;
-                        }
-                    }
-                }   else if (desc.fits_type == f1s_fits) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        vec = kmclipm_vector_load(name, index_data));
-
-                    data_val += kmclipm_vector_get_mean(vec);
-
-                    kmclipm_vector_delete(vec); vec = NULL;
-                }   else if ((desc.fits_type == f1l_fits) ||
-                             (desc.fits_type == f2l_fits)) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        tbl = kmclipm_table_load(name, index_data, 0));
-
-                    KMO_TRY_EXIT_IF_NULL(
-                        tbl_names = cpl_table_get_column_names(tbl));
-
-                    KMO_TRY_EXIT_IF_NULL(
-                        ptbl_names = cpl_array_get_data_string_const(
-                                                                    tbl_names));
-
-                    for (j = 0; j < cpl_array_get_size(tbl_names); j++) {
-                        data_val += cpl_table_get_column_mean(tbl,
-                                                              ptbl_names[j]);
-                    }
-
-                    cpl_table_delete(tbl); tbl = NULL;
-                    cpl_array_delete(tbl_names); tbl_names = NULL;
-                } else {
-                    KMO_TRY_ERROR_SET_MSG(CPL_ERROR_ILLEGAL_INPUT,
-                                          "Fits-format not yet supported!!!");
-                }
-                KMO_TRY_CHECK_ERROR_STATE();
-            }
-
-            ret_val += data_val + noise_val;
-            data_val = 0.0;
-            noise_val = 0.0;
-        }
-    }
-    KMO_CATCH
-    {
-        KMO_CATCH_MSG();
-        ret_val     = -DBL_MAX;
-    }
-
-    kmo_free_fits_desc(&desc);
-
-    return ret_val;
-}
-
-/**
-    @brief
-        Frame constructor
-
-    @param   filename         frame filename
-    @param   tag              frame tag
-    @param   group            frame group
-
-    @return  Newly allocated frame with the given contents.
- */
-cpl_frame* kmo_test_frame_new(const char *filename,
-                              const char *tag,
-                              cpl_frame_group group)
-{
-    cpl_frame   *f      = NULL;
-
-    KMO_TRY
-    {
-        f = cpl_frame_new();
-        KMO_TRY_EXIT_IF_NOT(f != NULL);
-
-        cpl_frame_set_filename(f, filename);
-
-        cpl_frame_set_tag(f, tag);
-
-        cpl_frame_set_group(f, group);
-    }
-    KMO_CATCH
-    {
-        f = NULL;
-    }
-
-    return f;
-}
-
-/**
-    @brief Updates (or adds) additional keywords to a fits-header.
-
-    @param   pl         The propertylist to update.
-    @param   keys       The array containing the keywords.
-    @param   vals       The array containing the values as strings.
-    @param   types      The array containing the CPL-types for the keywords.
-    @param   nr_keys    The number of keywords to add.
-
-    @return CPL_ERROR_NONE in case of success.
-
-    Possible cpl_error_code set in this function:
-
-    @li CPL_ERROR_ILLEGAL_INPUT    if an invalid CPL_TYPE has been provided.
- */
-cpl_error_code kmo_test_update_keywords(cpl_propertylist *pl,
-                                        char *keys[],
-                                        char *vals[],
-                                        int types[],
-                                        int nr_keys)
-{
-    int             i   = 0;
-    cpl_error_code  ret = CPL_ERROR_NONE;
-
-    KMO_TRY
-    {
-        KMO_TRY_ASSURE(pl != NULL,
-                       CPL_ERROR_NULL_INPUT,
-                       "Not all inputs provided!");
-
-        for (i = 0; i < nr_keys; i++) {
-            switch (types[i]) {
-                case CPL_TYPE_DOUBLE:
-                    cpl_propertylist_update_double(pl,
-                                                   keys[i],
-                                                   atof(vals[i]));
-                    break;
-                case CPL_TYPE_INT:
-                    cpl_propertylist_update_int(pl,
-                                                keys[i],
-                                                atoi(vals[i]));
-
-                    break;
-                case CPL_TYPE_FLOAT:
-                    cpl_propertylist_update_float(pl,
-                                                  keys[i],
-                                                  atof(vals[i]));
-                    break;
-                case CPL_TYPE_STRING:
-                    cpl_propertylist_update_string(pl,
-                                                   keys[i],
-                                                   vals[i]);
-                    break;
-                case CPL_TYPE_BOOL:
-                    cpl_propertylist_update_bool(pl,
-                                                   keys[i],
-                                                   atoi(vals[i]));
-                    break;
-                default:
-                    ret = CPL_ERROR_ILLEGAL_INPUT;
-                    break;
-            }
-        }
-    }
-    KMO_CATCH
-    {
-    }
-
-    return ret;
-}
-
-/**
-    @brief Fills a vector with increasing values.
-
-    @param   vec         The vector to fill with values.
-    @param   seed        The starting value.
-    @param   offset      The offset for the values.
-
- */
-void kmo_test_fill_vector(cpl_vector *vec,
-                          float seed,
-                          float offset)
-{
-    int         i       = 0,
-                size    = 0;
-    double      *data   = NULL;
-
-    KMO_TRY
-    {
-        size = cpl_vector_get_size(vec);
-        KMO_TRY_EXIT_IF_NOT(size > 0);
-
-        data = cpl_vector_get_data(vec);
-        KMO_TRY_EXIT_IF_NOT(data != NULL);
-
-        // horizontal stripes: bottom = 0, top = seed * (y-1)
-        for (i = 0; i < size; i++) {
-                data[i] = seed + i * offset;
-        }
-    }
-    KMO_CATCH
-    {
-    }
-}
-
-/**
-    @brief Fills an image with increasing values.
-
-    @param   img         The image to fill with values.
-    @param   seed        The starting value.
-    @param   offset      The offset for the values.
-
- */
-void kmo_test_fill_image(cpl_image *img,
-                         float seed,
-                         float offset)
-{
-    int         i       = 0,
-                j       = 0;
-    cpl_size    d       = 0,
-                x       = 0,
-                y       = 0;
-    float       *data   = NULL,
-                f       = 0.0;
-
-    KMO_TRY
-    {
-        x = cpl_image_get_size_x(img);
-        y = cpl_image_get_size_y(img);
-
-
-        data = cpl_image_get_data_float(img);
-        KMO_TRY_EXIT_IF_NOT(data != NULL);
-
-        // horizontal stripes: bottom = 0, top = seed * (y-1)
-        for (i = 0; i < y; i++) {
-            for (j = 0; j < x; j++) {
-                data[d] = seed + f;
-                d++;
-                f += offset;
-            }
-        }
-    }
-    KMO_CATCH
-    {
-    }
-}
-
-/**
-    @brief Fills a cube with increasing values.
-
-    @param   cube        The cube to fill with values.
-    @param   seed        The starting value.
-    @param   offset      The offset for the values.
-
- */
-void kmo_test_fill_cube(cpl_imagelist *cube,
-                        float seed,
-                        float offset)
-{
-    int         i       = 0,
-                size    = 0;
-
-    KMO_TRY
-    {
-        size = cpl_imagelist_get_size(cube);
-        KMO_TRY_EXIT_IF_NOT(size > 0);
-
-        for (i = 0; i < size; i++) {
-            kmo_test_fill_image(cpl_imagelist_get(cube, i),
-                                seed, offset);
-                seed += offset;
-        }
-    }
-    KMO_CATCH
-    {
-    }
-}
-
-/**
-    @brief Fills an image with a mask. Border is zero, the middle contains ones.
-
-    @param   img         The image to fill with a mask.
-
- */
-void kmo_test_fill_mask(cpl_image *img)
-{
-    int         i       = 0,
-                j       = 0,
-                x       = 0,
-                y       = 0;
-
-    float       *data   = NULL;
-
-    KMO_TRY
-    {
-        x = cpl_image_get_size_x(img);
-        y = cpl_image_get_size_y(img);
-
-
-        data = cpl_image_get_data_float(img);
-        KMO_TRY_EXIT_IF_NOT(data != NULL);
-
-        // horizontal stripes: bottom = 0, top = seed * (y-1)
-        for (i = 0; i < y; i++) {
-            for (j = 0; j < x; j++) {
-
-                if ((i == 0) || (i == y-1) || (j == 0) || (j == x-1)) {
-                    data[j+i*x] = 0.0;
-                } else {
-                    data[j+i*x] = 1.0;
-                }
-            }
-        }
-    }
-    KMO_CATCH
-    {
-    }
-}
-
-/**
-    @brief Allocates images in an empty imagelist.
-
-    @param   cube        The cube to allocate.
-    @param   x           Size in x-dimension.
-    @param   y           Size in y-dimension.
-    @param   z           Size in z-dimension.
-
- */
-void kmo_test_alloc_cube(cpl_imagelist *cube,
-                         int x,
-                         int y,
-                         int z)
-{
-    int         i       = 0;
-    cpl_image   *img    = NULL;
-
-    KMO_TRY
-    {
-        KMO_TRY_EXIT_IF_NOT(cpl_imagelist_get_size(cube) == 0);
-
-        for (i = 0; i < z; i++) {
-            KMO_TRY_EXIT_IF_NULL(
-                img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-            KMO_TRY_EXIT_IF_ERROR(
-                cpl_imagelist_set(cube, img, i));
-        }
-    }
-    KMO_CATCH
-    {
-    }
-}
-
-/**
-    @brief Initialises a vector to zero.
-
-    @param   vec         The vector to initialise.
-
- */
-void kmo_test_init_vec(cpl_vector *vec)
-{
-    double      *data   = NULL;
-    int         i       = 0;
-
-    KMO_TRY
-    {
-        data = cpl_vector_get_data (vec);
-        KMO_TRY_EXIT_IF_NOT(data != NULL);
-
-        for (i = 0; i < cpl_vector_get_size(vec); i++) {
-            data[i] = 0.0;
-        }
-    }
-    KMO_CATCH
-    {
-    }
-}
-
-/**
-    @brief Fills a cube with data either serial or gaussian data.
-
-    @param   x      The 1st dimension.
-    @param   y      The 2nd dimension.
-    @param   z      The 3rd dimension.
-    @param   gauss  TRUE if images should contain a gauss, FALSE otherwise.
-
-    @return  The generated imagelist.
- */
-cpl_imagelist* kmo_test_create_cube(int x, int y, int z, int gauss, int *offset)
-{
-    cpl_imagelist   *imglist    = NULL;
-    cpl_image       *img        = NULL;
-
-    int             i           = 0;
-
-    KMO_TRY
-    {
-        imglist = cpl_imagelist_new();
-        KMO_TRY_EXIT_IF_NOT(imglist != NULL);
-
-        for (i = 0; i < z; i++) {
-            img = cpl_image_new(x, y, CPL_TYPE_FLOAT);
-            KMO_TRY_EXIT_IF_NOT(img != NULL);
-
-            if (gauss == FALSE) {
-                kmo_test_fill_image(img, (*offset)++, test_global_seed_data);
-            } else {
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_image_fill_gaussian(img, x/2, y/2,
-                                            *offset + test_global_seed_data,
-                                            x/4, y/4));
-            }
-
-            cpl_imagelist_set(imglist, img, i);
-        }
-    }
-    KMO_CATCH
-    {
-    }
-
-    return imglist;
-}
-
-/**
-    @brief Creates the primary extension and saves it.
-
-    @param   filename        The filename where to save the primary extension.
-    @param   kmos_type       The type of KMOS-fits-file format.
-    @param   primary_keys    The array containing additional keywords.
-    @param   primary_vals    The array containing the additional values as
-                             strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords.
-    @param   nr_primary_keys The number of additional keywords to add.
-
- */
-void kmo_test_create_primary_extension(const char *filename,
-                                       char *primary_keys[],
-                                       char *primary_vals[],
-                                       int primary_types[],
-                                       int nr_primary_keys)
-{
-    cpl_propertylist    *header = NULL;
-
-    KMO_TRY
-    {
-        char *test_global_raw_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
-
-        header = kmclipm_propertylist_load(test_global_raw_path, 0);
-        KMO_TRY_EXIT_IF_NOT(header != NULL);
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_test_update_keywords(header,
-                                     primary_keys, primary_vals,
-                                     primary_types, nr_primary_keys));
-
-        KMO_TRY_EXIT_IF_ERROR(
-            cpl_propertylist_save(header, filename, CPL_IO_CREATE));
-        cpl_free(test_global_raw_path); test_global_raw_path = NULL;
-    }
-    KMO_CATCH
-    {
-    }
-
-    cpl_propertylist_delete(header); header = NULL;
-}
-
-/**
-    @brief Creates a RAW file initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
-*/
-int  kmo_test_create_RAW_data(int x,
-                              int y,
-                              const char *filename,
-                              char *primary_keys[],
-                              char *primary_vals[],
-                              int primary_types[],
-                              int nr_primary_keys,
-                              char *sub_keys[],
-                              char *sub_vals[],
-                              int sub_types[],
-                              int nr_sub_keys,
-                              float seed,
-                              float offset)
-{
-    int                 i           = 0,
-                        ret         = 0;
-    cpl_image           *img        = NULL;
-    cpl_propertylist    *header     = NULL;
-
-    KMO_TRY
-    {
-        char *test_global_raw_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
-
-        // load header from dummy
-        KMO_TRY_EXIT_IF_NULL(
-            header = kmclipm_propertylist_load(test_global_raw_path, 0));
-
-        KMO_TRY_EXIT_IF_ERROR(
-            kmo_test_update_keywords(header, primary_keys, primary_vals,
-                                     primary_types, nr_primary_keys));
-
-        cpl_image_save(NULL, filename, CPL_BPP_IEEE_FLOAT, header,
-                        CPL_IO_DEFAULT);
-
-        cpl_propertylist_delete(header); header = NULL;
-
-        // copy extensions
-        for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-            KMO_TRY_EXIT_IF_NULL(
-                img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-            kmo_test_fill_image(img, i - 1+offset, seed);
-
-//            KMO_TRY_EXIT_IF_NULL(
-//                header = kmclipm_propertylist_load(test_global_raw_path, i));
-            KMO_TRY_EXIT_IF_NULL(
-                header = cpl_propertylist_new());
-            char *tmpstr = cpl_sprintf("CHIP%d.INT1", i);
-            kmclipm_update_property_string(header, EXTNAME, tmpstr,
-                                           "FITS extension name");
-            cpl_free(tmpstr); tmpstr = NULL;
-            kmclipm_update_property_int(header, CHIPINDEX, i, "Chip index");
-            kmclipm_update_property_double(header, GAIN, 1, "Gain in e-/ADU");
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            cpl_image_save(img, filename, CPL_BPP_IEEE_FLOAT,
-                            header, CPL_IO_EXTEND);
-
-            cpl_image_delete(img); img = NULL;
-            cpl_propertylist_delete(header); header = NULL;
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-        cpl_free(test_global_raw_path); test_global_raw_path = NULL;
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_image_delete(img); img = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a RAW file with zero values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   filename        The filename where to save the primary extension.
- */
-int  kmo_test_create_RAW_data_zero(int x,
-                                   int y,
-                                   const char *filename)
-{
-    int                 i           = 0,
-                        ret         = 0;
-    cpl_image           *img        = NULL;
-    cpl_propertylist    *header     = NULL;
-
-    KMO_TRY
-    {
-        char *test_global_raw_path = cpl_sprintf("%s/ref_data/KMOS_dummy.fits", getenv("srcdir"));
-
-        // load header from dummy
-        KMO_TRY_EXIT_IF_NULL(
-            header = kmclipm_propertylist_load(test_global_raw_path, 0));
-
-        cpl_image_save(NULL, filename, CPL_BPP_IEEE_FLOAT, header,
-                        CPL_IO_DEFAULT);
-
-        cpl_propertylist_delete(header); header = NULL;
-
-        // copy extensions
-        for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-            KMO_TRY_EXIT_IF_NULL(
-                img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-//            KMO_TRY_EXIT_IF_NULL(
-//                header = kmclipm_propertylist_load(test_global_raw_path, i));
-            KMO_TRY_EXIT_IF_NULL(
-                header = cpl_propertylist_new());
-            char *tmpstr = cpl_sprintf("CHIP%d.INT1", i);
-            kmclipm_update_property_string(header, EXTNAME, tmpstr,
-                                           "FITS extension name");
-            cpl_free(tmpstr); tmpstr = NULL;
-            kmclipm_update_property_int(header, CHIPINDEX, i, "Chip index");
-            kmclipm_update_property_double(header, GAIN, 1, "Gain in e-/ADU");
-
-            cpl_image_save(img, filename, CPL_BPP_IEEE_FLOAT,
-                            header, CPL_IO_EXTEND);
-
-            cpl_image_delete(img); img = NULL;
-            cpl_propertylist_delete(header); header = NULL;
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-
-        cpl_free(test_global_raw_path); test_global_raw_path = NULL;
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_image_delete(img); img = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F2D file with data only initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
- */
-int  kmo_test_create_F2D_data(int x,
-                              int y,
-                              int mask,
-                              const char *filename,
-                              char *primary_keys[],
-                              char *primary_vals[],
-                              int primary_types[],
-                              int nr_primary_keys,
-                              char *sub_keys[],
-                              char *sub_vals[],
-                              int sub_types[],
-                              int nr_sub_keys)
-{
-    cpl_image           *img        = NULL;
-    cpl_propertylist    *header     = NULL;
-    int                 i           = 0,
-                        ret         = 0;
-
-    KMO_TRY
-    {
-        kmo_test_create_primary_extension(filename,
-                                          primary_keys, primary_vals,
-                                          primary_types,nr_primary_keys);
-
-        // create sub-headers and extensions
-        KMO_TRY_EXIT_IF_NULL(
-            img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-        for (i = 0; i < KMOS_NR_DETECTORS; i++) {
-//            KMO_TRY_EXIT_IF_NULL(
-//                header = kmclipm_propertylist_load(test_global_raw_path, i + 1));
-            KMO_TRY_EXIT_IF_NULL(
-                header = cpl_propertylist_new());
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_update_sub_keywords(header, FALSE, FALSE,
-                                        detector_frame, i + 1));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            if (mask == FALSE) {
-                kmo_test_fill_image(img, i, test_global_seed_data);
-            } else {
-                kmo_test_fill_mask(img);
-            }
-
-            cpl_image_save(img, filename, CPL_BPP_IEEE_FLOAT, header,
-                           CPL_IO_EXTEND);
-
-            cpl_propertylist_delete(header); header = NULL;
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_image_delete(img); img = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F2D file with data and noise initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
- */
-int  kmo_test_create_F2D_data_noise(int x,
-                                    int y,
-                                    const char *filename,
-                                    char *primary_keys[],
-                                    char *primary_vals[],
-                                    int primary_types[],
-                                    int nr_primary_keys,
-                                    char *sub_keys[],
-                                    char *sub_vals[],
-                                    int sub_types[],
-                                    int nr_sub_keys)
-{
-    cpl_propertylist    *header     = NULL;
-    cpl_image           *img        = NULL;
-    int                 i           = 0,
-                        ret         = 0;
-
-    KMO_TRY
-    {
-
-        kmo_test_create_F2D_data(x, y, FALSE, filename,
-                                 primary_keys, primary_vals, primary_types,
-                                 nr_primary_keys,
-                                 sub_keys, sub_vals, sub_types, nr_sub_keys);
-
-        KMO_TRY_EXIT_IF_NULL(
-            header = kmclipm_propertylist_load(filename, 0));
-
-        cpl_image_save(NULL, "tmp.fits", CPL_BPP_IEEE_FLOAT,
-                       header, CPL_IO_DEFAULT);
-
-        cpl_propertylist_delete(header); header = NULL;
-
-         // subsequent extensions, noise
-        for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-            // load and resave data
-            KMO_TRY_EXIT_IF_NULL(
-                img = kmclipm_image_load(filename, CPL_TYPE_FLOAT, 0, i));
-
-            KMO_TRY_EXIT_IF_NULL(
-                header = kmclipm_propertylist_load(filename, i));
-
-            cpl_image_save(img, "tmp.fits", CPL_BPP_IEEE_FLOAT, header,
-                           CPL_IO_EXTEND);
-
-            cpl_propertylist_delete(header); header = NULL;
-            cpl_image_delete(img); img = NULL;
-
-            // load noise header, generate noise, save
-//            KMO_TRY_EXIT_IF_NULL(
-//                header = kmclipm_propertylist_load(test_global_raw_path, i));
-            KMO_TRY_EXIT_IF_NULL(
-                header = cpl_propertylist_new());
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_update_sub_keywords(header, TRUE, FALSE, detector_frame, i));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            KMO_TRY_EXIT_IF_NULL(
-                img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-            kmo_test_fill_image(img, i - 1, test_global_seed_noise);
-
-            cpl_image_save(img, "tmp.fits", CPL_BPP_IEEE_FLOAT, header,
-                           CPL_IO_EXTEND);
-
-            cpl_propertylist_delete(header); header = NULL;
-            cpl_image_delete(img); img = NULL;
-        }
-        rename("tmp.fits", filename);
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_image_delete(img); img = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F2I file with data only initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   mask            If output should be a mask.
-    @param   nr_images       The number of extensions the file will have.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
- */
-int  kmo_test_create_F2I_data(int x,
-                              int y,
-                              int mask,
-                              int nr_images,
-                              const char *filename,
-                              char *primary_keys[],
-                              char *primary_vals[],
-                              int primary_types[],
-                              int nr_primary_keys,
-                              char *sub_keys[],
-                              char *sub_vals[],
-                              int sub_types[],
-                              int nr_sub_keys)
-{
-    cpl_image        *img           = NULL,
-                     *tmp           = NULL;
-    cpl_propertylist *header        = NULL;
-    int              i              = 0,
-                     offset         = 0,
-                     ret            = 0;
-
-    KMO_TRY
-    {
-        kmo_test_create_primary_extension(filename,
-                                          primary_keys, primary_vals,
-                                          primary_types,nr_primary_keys);
-
-
-        // create sub-headers and extensions
-        KMO_TRY_EXIT_IF_NULL(
-            img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-        KMO_TRY_EXIT_IF_NULL(
-            header = cpl_propertylist_new());
-
-        for (i = 0; i < nr_images; i++) {
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_update_sub_keywords(header, FALSE, FALSE, ifu_frame, i + 1));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            if (test_global_valid[i] == TRUE) {
-                if (mask == FALSE) {
-                    kmo_test_fill_image(img, offset++, test_global_seed_data);
-                } else {
-                    kmo_test_fill_mask(img);
-                }
-
-                tmp = img;
-            } else {
-                tmp = NULL;
-            }
-
-            cpl_image_save(tmp, filename, CPL_BPP_IEEE_FLOAT, header,
-                           CPL_IO_EXTEND);
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_image_delete(img); img = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F2I file with data and noise initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   nr_images       The number of extensions the file will have.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
- */
-int  kmo_test_create_F2I_data_noise(int x,
-                                    int y,
-                                    int nr_images,
-                                    const char *filename,
-                                    char *primary_keys[],
-                                    char *primary_vals[],
-                                    int primary_types[],
-                                    int nr_primary_keys,
-                                    char *sub_keys[],
-                                    char *sub_vals[],
-                                    int sub_types[],
-                                    int nr_sub_keys)
-{
-    cpl_propertylist    *header         = NULL;
-    cpl_image           *img            = NULL;
-    int                 i               = 0,
-                        offset          = 0,
-                        ret             = 0,
-                        id              = -1;
-    enum kmo_frame_type ttype           = illegal_frame;
-    char                content[64],
-                        *extname        = NULL;
-
-    KMO_TRY
-    {
-        kmo_test_create_F2I_data(x, y, FALSE, nr_images, filename,
-                                 primary_keys, primary_vals, primary_types,
-                                 nr_primary_keys,
-                                 sub_keys, sub_vals, sub_types, nr_sub_keys);
-
-        KMO_TRY_EXIT_IF_NULL(
-            header = kmclipm_propertylist_load(filename, 0));
-
-        cpl_image_save(NULL, "tmp.fits", CPL_BPP_IEEE_FLOAT,
-                       header, CPL_IO_DEFAULT);
-
-        cpl_propertylist_delete(header); header = NULL;
-
-        // create subsequent noise extensions
-        for (i = 1; i <= nr_images; i++) {
-            // load and resave data
-            KMO_TRY_EXIT_IF_NULL(
-                header = kmclipm_propertylist_load(filename, i));
-
-            if (test_global_valid[i - 1] == TRUE) {
-                KMO_TRY_EXIT_IF_NULL(
-                    img = kmclipm_image_load(filename, CPL_TYPE_FLOAT, 0, i));
-
-                cpl_image_save(img, "tmp.fits", CPL_BPP_IEEE_FLOAT, header,
-                               CPL_IO_EXTEND);
-
-                cpl_image_delete(img); img = NULL;
-            } else {
-                cpl_propertylist_save(header, "tmp.fits", CPL_IO_EXTEND);
-            }
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_extname_extractor(cpl_propertylist_get_string(header,
-                                                                  EXTNAME),
-                                      &ttype,
-                                      &id,
-                                      content));
-
-            // update noise header, generate noise, save
-            KMO_TRY_EXIT_IF_NULL(
-                extname = kmo_extname_creator(ttype, id, EXT_NOISE));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_string(header,
-                                        EXTNAME,
-                                        extname,
-                                        "FITS extension name"));
-            cpl_free(extname); extname = NULL;
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            if (test_global_valid[i - 1] == TRUE) {
-                KMO_TRY_EXIT_IF_NULL(
-                    img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-                kmo_test_fill_image(img, offset++, test_global_seed_noise);
-
-                cpl_image_save(img, "tmp.fits", CPL_BPP_IEEE_FLOAT, header,
-                            CPL_IO_EXTEND);
-
-                cpl_image_delete(img); img = NULL;
-            } else {
-                cpl_propertylist_save(header, "tmp.fits", CPL_IO_EXTEND);
-            }
-
-            cpl_propertylist_delete(header); header = NULL;
-        }
-        rename("tmp.fits", filename);
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_image_delete(img); img = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F3I file with data only initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   z               The size of the 3rd dimension.
-    @param   gauss           TRUE if cube should be filled with gaussian data,
-                             FALSE if it should be filled with linearly
-                             increasing values.
-    @param   nr_cubes        The number of extensions the file will have.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
- */
-int  kmo_test_create_F3I_data(int x,
-                              int y,
-                              int z,
-                              int gauss,
-                              int nr_cubes,
-                              const char *filename,
-                              char *primary_keys[],
-                              char *primary_vals[],
-                              int primary_types[],
-                              int nr_primary_keys,
-                              char *sub_keys[],
-                              char *sub_vals[],
-                              int sub_types[],
-                              int nr_sub_keys)
-{
-    cpl_imagelist       *cube           = NULL;
-    cpl_propertylist    *header         = NULL;
-    int                 j               = 0,
-                        ret             = 0,
-                        offset          = 0;
-
-    KMO_TRY
-    {
-        kmo_test_create_primary_extension(filename,
-                                          primary_keys, primary_vals,
-                                          primary_types,nr_primary_keys);
-
-        // generate data
-        KMO_TRY_EXIT_IF_NULL(
-            header = cpl_propertylist_new());
-
-        for (j = 0; j < nr_cubes; j++) {
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_update_sub_keywords(header, FALSE, FALSE, ifu_frame, j + 1));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-            if (test_global_valid[j] == TRUE) {
-                KMO_TRY_EXIT_IF_NULL(
-                    cube = kmo_test_create_cube(x, y, z, gauss, &offset));
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_imagelist_save(cube, filename, CPL_BPP_IEEE_FLOAT,
-                                       header, CPL_IO_EXTEND));
-                cpl_imagelist_delete(cube); cube = NULL;
-            } else {
-                KMO_TRY_EXIT_IF_ERROR(
-                    cpl_propertylist_save(header, filename, CPL_IO_EXTEND));
-            }
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief
-        Creates a F3I file with data only initialised with some values.
-        Some values are inifinite
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   z               The size of the 3rd dimension.
-    @param   nr_cubes        The number of extensions the file will have.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
- */
-int  kmo_test_create_F3I_data_infinite(int x,
-                              int y,
-                              int z,
-                              int nr_cubes,
-                              const char *filename,
-                              char *primary_keys[],
-                              char *primary_vals[],
-                              int primary_types[],
-                              int nr_primary_keys,
-                              char *sub_keys[],
-                              char *sub_vals[],
-                              int sub_types[],
-                              int nr_sub_keys)
-{
-    cpl_imagelist       *imglist        = NULL;
-    cpl_propertylist    *header         = NULL;
-    cpl_image           *img            = NULL;
-    int                 i               = 0,
-                        j               = 0,
-                        offset          = 0,
-                        ret             = 0,
-                        count           = 0;
-
-    KMO_TRY
-    {
-        kmo_test_create_primary_extension(filename,
-                                          primary_keys, primary_vals,
-                                          primary_types,nr_primary_keys);
-
-        // generate data
-        KMO_TRY_EXIT_IF_NULL(
-            imglist = cpl_imagelist_new());
-
-        KMO_TRY_EXIT_IF_NULL(
-            header = cpl_propertylist_new());
-
-        for (j = 0; j < nr_cubes; j++) {
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_update_sub_keywords(header, FALSE, FALSE, ifu_frame, j + 1));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-            if (test_global_valid[j] == TRUE) {
-                for (i = 0; i < z; i++) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-                    kmo_test_fill_image(img, offset++, test_global_seed_data);
-                    KMO_TRY_CHECK_ERROR_STATE();
-
-                    // add infinite values here
-                    if (count == 2) {
-                        // add -inf
-                        cpl_image_set(img, 2, 1, -1.0/0.0);
-                        count++;
-                    }
-                    if (count == 1) {
-                        // add inf
-                        cpl_image_set(img, 2, 1, 1.0/0.0);
-                        count++;
-                    }
-                    if (count == 0) {
-                        // add nan
-                        cpl_image_set(img, 1, 1, 0.0/0.0);
-                        count++;
-                    }
-
-                    cpl_imagelist_set(imglist, img, i);
-                }
-
-                cpl_imagelist_save(imglist, filename, CPL_BPP_IEEE_FLOAT,
-                                header, CPL_IO_EXTEND);
-            } else {
-                cpl_propertylist_save(header, filename, CPL_IO_EXTEND);
-            }
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_imagelist_delete(imglist); imglist = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F3I file with data only initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   z               The size of the 3rd dimension.
-    @param   nr_cubes        The number of extensions the file will have.
-    @param   val             The Array defining if the IFUs are active or not.
-                             It must have the same length as @c nr_cubes .
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
-*/
-int  kmo_test_create_F3I_data2(int x,
-                              int y,
-                              int z,
-                              int nr_cubes,
-                              int val[],
-                              const char *filename,
-                              char *primary_keys[],
-                              char *primary_vals[],
-                              int primary_types[],
-                              int nr_primary_keys,
-                              char *sub_keys[],
-                              char *sub_vals[],
-                              int sub_types[],
-                              int nr_sub_keys)
-{
-    cpl_imagelist       *imglist        = NULL;
-    cpl_propertylist    *header         = NULL;
-    cpl_image           *img            = NULL;
-    int                 i               = 0,
-                        j               = 0,
-                        offset          = 0,
-                        ret             = 0;
-
-    KMO_TRY
-    {
-        kmo_test_create_primary_extension(filename,
-                                          primary_keys, primary_vals,
-                                          primary_types,nr_primary_keys);
-
-        // generate data
-        KMO_TRY_EXIT_IF_NULL(
-            imglist = cpl_imagelist_new());
-
-        KMO_TRY_EXIT_IF_NULL(
-            header = cpl_propertylist_new());
-
-        for (j = 0; j < nr_cubes; j++) {
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_update_sub_keywords(header, FALSE, FALSE, ifu_frame, j + 1));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            if (val[j] == TRUE) {
-                for (i = 0; i < z; i++) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-                    kmo_test_fill_image(img, offset++, test_global_seed_data);
-
-                    cpl_imagelist_set(imglist, img, i);
-                }
-
-                cpl_imagelist_save(imglist, filename, CPL_BPP_IEEE_FLOAT,
-                                header, CPL_IO_EXTEND);
-            } else {
-                cpl_propertylist_save(header, filename, CPL_IO_EXTEND);
-            }
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_imagelist_delete(imglist); imglist = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F3I file with data and noise initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   z               The size of the 3rd dimension.
-    @param   nr_cubes        The number of extensions the file will have.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
-*/
-int  kmo_test_create_F3I_data_noise(int x,
-                                    int y,
-                                    int z,
-                                    int gauss,
-                                    int nr_cubes,
-                                    const char *filename,
-                                    char *primary_keys[],
-                                    char *primary_vals[],
-                                    int primary_types[],
-                                    int nr_primary_keys,
-                                    char *sub_keys[],
-                                    char *sub_vals[],
-                                    int sub_types[],
-                                    int nr_sub_keys)
-{
-    cpl_image           *img            = NULL;
-    cpl_imagelist       *imglist        = NULL;
-    int                 i               = 0,
-                        j               = 0,
-                        offset          = 0,
-                        ret             = 0,
-                        id              = -1;
-    cpl_propertylist    *header         = NULL;
-    enum kmo_frame_type ttype           = illegal_frame;
-    char                content[64],
-                        *extname        = NULL;
-    KMO_TRY
-    {
-        kmo_test_create_F3I_data(x, y, z, gauss, nr_cubes, filename,
-                                 primary_keys, primary_vals, primary_types,
-                                 nr_primary_keys,
-                                 sub_keys, sub_vals, sub_types, nr_sub_keys);
-
-        KMO_TRY_EXIT_IF_NULL(
-            header = kmclipm_propertylist_load(filename, 0));
-
-        cpl_image_save(NULL, "tmp.fits", CPL_BPP_IEEE_FLOAT,
-                       header, CPL_IO_DEFAULT);
-
-        cpl_propertylist_delete(header); header = NULL;
-
-        // create subsequent noise extensions
-        for (j = 1; j <= nr_cubes; j++) {
-            // load and resave data
-            KMO_TRY_EXIT_IF_NULL(
-                header = kmclipm_propertylist_load(filename, j));
-
-            if (test_global_valid[j - 1] == TRUE) {
-                KMO_TRY_EXIT_IF_NULL(
-                    imglist = kmclipm_imagelist_load(filename, CPL_TYPE_FLOAT, j));
-
-                cpl_imagelist_save(imglist, "tmp.fits", CPL_BPP_IEEE_FLOAT,
-                                   header, CPL_IO_EXTEND);
-
-                cpl_imagelist_delete(imglist); imglist = NULL;
-            } else {
-                cpl_propertylist_save(header, "tmp.fits", CPL_IO_EXTEND);
-            }
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_extname_extractor(cpl_propertylist_get_string(header, EXTNAME),
-                                      &ttype, &id, content));
-            // update noise header, generate noise, save
-            KMO_TRY_EXIT_IF_NULL(
-                extname = kmo_extname_creator(ttype, id, EXT_NOISE));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_string(header,
-                                        EXTNAME,
-                                        extname,
-                                        "FITS extension name"));
-            cpl_free(extname); extname = NULL;
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            if (test_global_valid[j - 1] == TRUE) {
-                KMO_TRY_EXIT_IF_NULL(
-                    imglist = cpl_imagelist_new());
-
-                for (i = 0; i < z; i++) {
-                    KMO_TRY_EXIT_IF_NULL(
-                        img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-                    if (gauss == FALSE) {
-                        kmo_test_fill_image(img, offset++, test_global_seed_noise);
-                    } else {
-                        KMO_TRY_EXIT_IF_ERROR(
-                            cpl_image_fill_gaussian(img, x/2, y/2,
-                                                    offset + test_global_seed_noise,
-                                                    x/4, y/4));
-                    }
-
-                    cpl_imagelist_set(imglist, img, i);
-                }
-
-                cpl_imagelist_save(imglist, "tmp.fits", CPL_BPP_IEEE_FLOAT,
-                                   header, CPL_IO_EXTEND);
-
-                cpl_imagelist_delete(imglist); imglist = NULL;
-            } else {
-                cpl_propertylist_save(header, "tmp.fits", CPL_IO_EXTEND);
-
-            }
-
-            cpl_propertylist_delete(header); header = NULL;
-        }
-        rename("tmp.fits", filename);
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-    cpl_imagelist_delete(imglist); imglist = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F1I file with data only initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   nr_vectors      The number of extensions the file will have.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
-*/
-int  kmo_test_create_F1I_data(int x,
-                              int nr_vectors,
-                              const char *filename,
-                              char *primary_keys[],
-                              char *primary_vals[],
-                              int primary_types[],
-                              int nr_primary_keys,
-                              char *sub_keys[],
-                              char *sub_vals[],
-                              int sub_types[],
-                              int nr_sub_keys)
-{
-    cpl_vector          *vec            = NULL,
-                        *tmp            = NULL;
-    cpl_propertylist    *header         = NULL;
-    int                 i               = 0,
-                        ret             = 0;
-
-    KMO_TRY
-    {
-        kmo_test_create_primary_extension(filename,
-                                          primary_keys, primary_vals,
-                                          primary_types,nr_primary_keys);
-
-        // generate data
-        KMO_TRY_EXIT_IF_NULL(
-            vec = cpl_vector_new(x));
-
-        KMO_TRY_EXIT_IF_NULL(
-            header = cpl_propertylist_new());
-
-        for (i = 0; i < nr_vectors; i++) {
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_update_sub_keywords(header, FALSE, FALSE, ifu_frame, i + 1));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            if (test_global_valid[i] == TRUE) {
-                kmo_test_init_vec(vec);
-
-                kmo_test_fill_vector(vec, i, test_global_seed_data);
-                tmp = vec;
-            } else {
-                tmp = NULL;
-            }
-
-            cpl_vector_save(tmp, filename, CPL_BPP_IEEE_FLOAT, header,
-                            CPL_IO_EXTEND);
-        }
-
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_vector_delete(vec); vec = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a F1I file with data and noise initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   nr_vectors      The number of extensions the file will have.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
-*/
-int  kmo_test_create_F1I_data_noise(int x,
-                                    int nr_vectors,
-                                    const char *filename,
-                                    char *primary_keys[],
-                                    char *primary_vals[],
-                                    int primary_types[],
-                                    int nr_primary_keys,
-                                    char *sub_keys[],
-                                    char *sub_vals[],
-                                    int sub_types[],
-                                    int nr_sub_keys)
-{
-    cpl_propertylist    *header     = NULL;
-    kmclipm_vector      *vec        = NULL;
-    int                 i           = 0,
-                        ret         = 0,
-                        id          = -1;
-    enum kmo_frame_type ttype       = illegal_frame;
-    char                content[64],
-                        *extname    = NULL;
-
-    KMO_TRY
-    {
-        kmo_test_create_F1I_data(x, nr_vectors, filename,
-                                 primary_keys, primary_vals, primary_types,
-                                 nr_primary_keys,
-                                 sub_keys, sub_vals, sub_types, nr_sub_keys);
-
-
-        KMO_TRY_EXIT_IF_NULL(
-            header = kmclipm_propertylist_load(filename, 0));
-
-        cpl_vector_save(NULL, "tmp.fits", CPL_BPP_IEEE_FLOAT,
-                       header, CPL_IO_DEFAULT);
-
-        cpl_propertylist_delete(header); header = NULL;
-
-        // create subsequent noise extensions
-        for (i = 1; i <= nr_vectors; i++) {
-            // load and resave data
-            KMO_TRY_EXIT_IF_NULL(
-                header = kmclipm_propertylist_load(filename, i));
-
-            if (test_global_valid[i - 1] == TRUE) {
-                KMO_TRY_EXIT_IF_NULL(
-                    vec = kmclipm_vector_load(filename, i));
-
-               kmclipm_vector_save(vec, "tmp.fits", CPL_BPP_IEEE_FLOAT, header,
-                                   CPL_IO_EXTEND, 0./0.);
-
-                kmclipm_vector_delete(vec); vec = NULL;
-            } else {
-                cpl_propertylist_save(header, "tmp.fits", CPL_IO_EXTEND);
-            }
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_extname_extractor(cpl_propertylist_get_string(header, EXTNAME),
-                                      &ttype, &id, content));
-            // update noise header, generate noise, save
-            KMO_TRY_EXIT_IF_NULL(
-                extname = kmo_extname_creator(ttype, id, EXT_NOISE));
-            KMO_TRY_EXIT_IF_ERROR(
-                kmclipm_update_property_string(header,
-                                        EXTNAME,
-                                        extname,
-                                        "FITS extension name"));
-            cpl_free(extname); extname = NULL;
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            if (test_global_valid[i - 1] == TRUE) {
-                cpl_vector *vec2 = NULL;
-                KMO_TRY_EXIT_IF_NULL(
-                    vec2 = cpl_vector_new(x));
-
-                kmo_test_init_vec(vec2);
-
-                kmo_test_fill_vector(vec2, i - 1, test_global_seed_noise);
-
-                vec = kmclipm_vector_create(vec2);
-
-                kmclipm_vector_save(vec, "tmp.fits", CPL_BPP_IEEE_FLOAT, header,
-                               CPL_IO_EXTEND, 0./0.);
-
-                kmclipm_vector_delete(vec); vec = NULL;
-            } else {
-                cpl_propertylist_save(header, "tmp.fits", CPL_IO_EXTEND);
-            }
-
-            cpl_propertylist_delete(header); header = NULL;
-        }
-        rename("tmp.fits", filename);
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    kmclipm_vector_delete(vec); vec = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates a B2D file with data only initialised with some values.
-
-    @param   x               The size of the 1st dimension.
-    @param   y               The size of the 2nd dimension.
-    @param   filename        The filename where to save the primary extension.
-    @param   primary_keys    The array containing additional keywords for the
-                             primary header.
-    @param   primary_vals    The array containing the additional values for the
-                             primary header as strings.
-    @param   primary_types   The array containing the additional CPL-types for
-                             the keywords for the primary header.
-    @param   nr_primary_keys The number of additional keywords to add to the
-                             primary header.
-    @param   sub_keys        The array containing additional keywords for the
-                             subsequent headers.
-    @param   sub_vals        The array containing the additional values for the
-                             subsequent headers as strings.
-    @param   sub_types       The array containing the additional CPL-types for
-                             the keywords for the subsequent headers.
-    @param   nr_sub_keys     The number of additional keywords to add to the
-                             subsequent headers.
- */
-int  kmo_test_create_B2D_data(int x,
-                              int y,
-                              int mask,
-                              const char *filename,
-                              char *primary_keys[],
-                              char *primary_vals[],
-                              int primary_types[],
-                              int nr_primary_keys,
-                              char *sub_keys[],
-                              char *sub_vals[],
-                              int sub_types[],
-                              int nr_sub_keys)
-{
-    cpl_image           *img        = NULL;
-    cpl_propertylist    *header     = NULL;
-    int                 i           = 0,
-                        ret         = 0;
-
-    KMO_TRY
-    {
-        kmo_test_create_primary_extension(filename,
-                                          primary_keys, primary_vals,
-                                          primary_types,nr_primary_keys);
-
-        // create sub-headers and extensions
-        KMO_TRY_EXIT_IF_NULL(
-            img = cpl_image_new(x, y, CPL_TYPE_FLOAT));
-
-        for (i = 0; i < KMOS_NR_DETECTORS; i++) {
-//            KMO_TRY_EXIT_IF_NULL(
-//                header = kmclipm_propertylist_load(test_global_raw_path, i + 1));
-            KMO_TRY_EXIT_IF_NULL(
-                header = cpl_propertylist_new());
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_update_sub_keywords(header, FALSE, TRUE,
-                                        detector_frame, i + 1));
-
-            KMO_TRY_EXIT_IF_ERROR(
-                kmo_test_update_keywords(header, sub_keys, sub_vals,
-                                         sub_types, nr_sub_keys));
-
-            if (mask == FALSE) {
-                kmo_test_fill_image(img, i, test_global_seed_data);
-            } else {
-                kmo_test_fill_mask(img);
-            }
-
-            cpl_image_save(img, filename, CPL_BPP_IEEE_FLOAT, header,
-                           CPL_IO_EXTEND);
-
-            cpl_propertylist_delete(header); header = NULL;
-        }
-        KMO_TRY_CHECK_ERROR_STATE();
-    }
-    KMO_CATCH
-    {
-        ret = -1;
-    }
-
-    cpl_image_delete(img); img = NULL;
-    cpl_propertylist_delete(header); header = NULL;
-
-    return ret;
-}
-
-/**
-    @brief Creates 2048x2048pixel data to test the pipeline
- */
-void kmo_test_create_pipeline_data_core(const char * subpath, const char* log_path)
-{
-    char darkpath[1024],
-         flatpath[1024],
-         arcpath[1024],
-         skypath[1024],
-         stdpath[1024];
-    strcpy(darkpath, getenv("srcdir"));
-    strcat(darkpath, "/ref_data/K_only_sky_dark.fits");
-    strcpy(flatpath, getenv("srcdir"));
-    strcat(flatpath, "/ref_data/K_only_sky_flat.fits");
-    strcpy(arcpath, getenv("srcdir"));
-    strcat(arcpath, "/ref_data/K_only_sky_arc.fits");
-    strcpy(skypath, getenv("srcdir"));
-    strcat(skypath, "/ref_data/K_only_sky.fits");
-    strcpy(stdpath, getenv("srcdir"));
-    strcat(stdpath, "/ref_data/K_stars+obj_rot0.25.fits");
-
-    const char  *valid      = "\"1;1;1;1;1;1;1;1\"",
-                *filter     = "\"K\"",
-                *grating    = "\"K\"",
-                *sub_key    = "\"ESO DET CHIP GAIN;double;1.1;ESO DET CHIP RON;double;0.1\"";
-
-    char        cmd[2048],
-                path[1024];
-    double      rotangle    = 0.0;
-
-    // setup directories
-    if (kmo_test_file_exists(test_global_path_test_data) == FALSE) {
-        mkdir(test_global_path_test_data, 0777);
-    }
-
-    strcpy(path, test_global_path_test_data);
-    strcat(path, subpath);
-
-    if (kmo_test_file_exists(path) == FALSE) {
-        mkdir(path, 0777);
-    }
-
-    // DARK
-    sprintf(cmd, "esorex kmo_dev_setup --type=DARK --rotangle=%f --valid=%s"
-            " --subkey=%s %s",
-            rotangle, valid, sub_key, darkpath);
-    kmo_get_pipe_command(cmd, log_path, NULL, FALSE);
-    system(cmd);
-    sprintf(cmd, "mv dark_123.fits %s", path); system(cmd);
-    sprintf(cmd, "mv dark_231.fits %s", path); system(cmd);
-    sprintf(cmd, "mv dark_312.fits %s", path); system(cmd);
-
-    // FLAT_ON
-    sprintf(cmd, "esorex kmo_dev_setup --type=FLAT_ON  --rotangle=%f --valid=%s"
-            " --filt=%s --grat=%s --subkey=%s %s",
-            rotangle, valid, filter, grating,
-            sub_key, flatpath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv flat_on_123.fits %s", path); system(cmd);
-    sprintf(cmd, "mv flat_on_231.fits %s", path); system(cmd);
-    sprintf(cmd, "mv flat_on_312.fits %s", path); system(cmd);
-
-    // FLAT_OFF
-    sprintf(cmd, "esorex kmo_dev_setup --type=FLAT_OFF --rotangle=%f "
-            "--valid=%s --filt=%s --grat=%s %s",
-            rotangle, valid, filter, grating,
-            darkpath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv flat_off_123.fits %s", path); system(cmd);
-    sprintf(cmd, "mv flat_off_231.fits %s", path); system(cmd);
-    sprintf(cmd, "mv flat_off_312.fits %s", path); system(cmd);
-
-    // ARC_ON
-    sprintf(cmd, "esorex kmo_dev_setup --type=ARC_ON   --rotangle=%f "
-            "--valid=%s --filt=%s --grat=%s --subkey=%s %s",
-            rotangle, valid, filter, grating,
-            sub_key, arcpath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv arc_on_123.fits %s", path); system(cmd);
-
-    // ARC_OFF
-    sprintf(cmd, "esorex kmo_dev_setup --type=ARC_OFF  --rotangle=%f "
-            "--valid=%s --filt=%s --grat=%s --subkey=%s %s",
-           rotangle, valid, filter, grating,
-            sub_key, darkpath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv arc_off_123.fits %s", path); system(cmd);
-
-    // SKY
-    sprintf(cmd, "esorex kmo_dev_setup --type=SKY --rotangle=%f --valid=%s"
-            " --filt=%s --grat=%s %s",
-            rotangle, valid, filter, grating,
-            skypath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv sky_123.fits %s", path); system(cmd);
-    sprintf(cmd, "mv sky_231.fits %s", path); system(cmd);
-    sprintf(cmd, "mv sky_312.fits %s", path); system(cmd);
-
-    // STD OBJ
-    sprintf(cmd, "esorex kmo_dev_setup --type=STD --rotangle=%f --valid=%s"
-            " --filt=%s --grat=%s  --subkey=%s "
-            " --mainkey=\"ESO TPL ID;string;KMOS_spec_cal_stdstarscipatt\" "
-            " --date=\"2011-01-12T11:10:00.0000\" "
-            " --objects=\"0;1;0;0;1;0;0;0\" %s ",
-            rotangle, valid, filter, grating,
-            sub_key, stdpath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv std_123.fits %s/std_obj_123.fits", path); system(cmd);
-
-    // STD SKY
-    sprintf(cmd, "esorex kmo_dev_setup --type=STD --rotangle=%f --valid=%s"
-            " --filt=%s --grat=%s  --subkey=%s "
-            " --mainkey=\"ESO TPL ID;string;KMOS_spec_cal_stdstarscipatt\" "
-            " --date=\"2011-01-12T11:12:00.0000\" "
-            " --objects=\"0;0;0;0;0;0;0;0\" %s ",
-            rotangle, valid, filter, grating,
-            sub_key, skypath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv std_123.fits %s/std_sky_123.fits", path); system(cmd);
-
-    // SCIENCE OBJ
-    sprintf(cmd, "esorex kmo_dev_setup --type=STD --rotangle=%f --valid=%s"
-            " --filt=%s --grat=%s  --subkey=%s "
-            "--date=\"2011-01-12T12:12:00.0000\" "
-            "--mainkey=\"ESO OCS ARM5 NAME;string;AAA;"
-            "ESO OCS ARM10 NAME;string;BBB;"
-            "ESO OCS ARM18 NAME;string;CCC;ESO OCS ARM21 NAME;string;DDD\""
-            " --objects=\"0;1;0;0;1;0;0;0\" %s",
-            rotangle, valid, filter, grating,
-            sub_key, stdpath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv std_123.fits %s/science_obj_123.fits", path); system(cmd);
-
-    // SCIENCE SKY
-    sprintf(cmd, "esorex kmo_dev_setup --type=STD --rotangle=%f --valid=%s"
-            " --filt=%s --grat=%s  --subkey=%s "
-            "--date=\"2011-01-12T12:13:00.0000\""
-            " --objects=\"0;0;0;0;0;0;0;0\" %s",
-            rotangle, valid, filter, grating,
-            sub_key, skypath);
-    kmo_get_pipe_command(cmd, log_path, NULL, TRUE);
-    system(cmd);
-    sprintf(cmd, "mv std_123.fits %s/science_sky_123.fits", path); system(cmd);
-
-    system("rm tmp_delete1.fits tmp_delete2.fits tmp_delete3.fits");
-}
diff --git a/recipes/tests/kmo_arithmetic-test.c b/recipes/tests/kmo_arithmetic-test.c
deleted file mode 100644
index 1acdbac..0000000
--- a/recipes/tests/kmo_arithmetic-test.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/* $Id: kmo_arithmetic-test.c,v 1.7 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.7 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_math.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-double          scalar              = 6.7;
-int             ifu_nr              = 4;
-
-const char      *path_recipe        = "kmo_arithmetic/";
-
-const char      *valid_files[]      = {"v_data_RAW.fits",
-                                       "v_data_F2D.fits",
-                                       "v_data_noise_F2D.fits",
-                                       "v_data_F3I_all.fits",
-                                       "v_data_noise_F3I_all.fits",
-                                       "v_data_noise_F3I_1.fits",
-                                       "v_data_F2I_1.fits",
-                                       "v_data_noise_F2I_all.fits",
-                                       "v_data_F1I_all.fits",
-                                       "v_data_noise_F1I_1.fits",
-                                       "v_data_RAW_zero.fits",
-                                       "v_data_F3I_2_true_false.fits",
-                                       "v_data_F3I_2_false_true.fits",
-                                       "v_data_F3I_false.fits"};
-
-const char      *invalid_files[]    = {"i_data_F3I_too_small.fits"};
-
-/**
-    @defgroup kmo_arithmetic_test   kmo_arithmetic unit tests
-
-    @{
-*/
-
-/**
- * @brief   test with two frames
- */
-static void test_arithmetic(const char *path_op1,
-                            const char *path_op2,
-                            const char *op,
-                            int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_arithmetic.sof";
-    FILE *fh = fopen( sof_path, "w" );
-    fprintf (fh, "%s\n%s\n",
-             path_op1, path_op2);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_arithmetic "
-            "--operator=\"%s\" %s",
-            op, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_arithmetic.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
- * @brief   test with one frame and a scalar
- */
-static void test_arithmetic_scalar(const char *path_op1,
-                                   double scalar,
-                                   const char *op)
-{
-    // create sof-file
-    const char *sof_path = "test_arithmetic_scalar.sof";
-    FILE *fh = fopen( sof_path, "w" );
-    fprintf (fh, "%s\n", path_op1);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_arithmetic "
-            "--operator=\"%s\" --scalar=\"%g\" %s",
-            op, scalar, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_arithmetic.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    cpl_test_eq(0, system(esorex_command));
-}
-
-/**
-    @brief
-        Generates test data for kmo_arithmetic.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_arithmetic(const char *path)
-{
-    char        file_path[256];
-
-    /* ----- valid test data ----- */
-    /* RAW */
-    cpl_test_eq(0,
-    kmo_test_create_RAW_data(test_global_size_x, test_global_size_y,
-                        kmo_test_cat_strings(file_path, path, valid_files[0]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0, test_global_seed_data, 0.0));
-
-    /* F2D */
-    cpl_test_eq(0,
-                kmo_test_create_F2D_data(test_global_size_x, test_global_size_y, FALSE,
-                        kmo_test_cat_strings(file_path, path, valid_files[1]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-                kmo_test_create_F2D_data_noise(test_global_size_x, test_global_size_y,
-                        kmo_test_cat_strings(file_path, path, valid_files[2]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    /* F3I */
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data(test_global_size_x, test_global_size_y, test_global_size_z,  FALSE,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[3]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-               kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y, test_global_size_z,  FALSE,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[4]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y, test_global_size_z,  FALSE,1,
-                          kmo_test_cat_strings(file_path, path, valid_files[5]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    /* F2I */
-    cpl_test_eq(0,
-                kmo_test_create_F2I_data(test_global_size_x, test_global_size_y, FALSE, 1,
-                          kmo_test_cat_strings(file_path, path, valid_files[6]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-                kmo_test_create_F2I_data_noise(test_global_size_x, test_global_size_y, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[7]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    /* F1I */
-    cpl_test_eq(0,
-                kmo_test_create_F1I_data(test_global_size_z, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[8]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-                kmo_test_create_F1I_data_noise(test_global_size_z, 1,
-                          kmo_test_cat_strings(file_path, path, valid_files[9]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    /* RAW zero */
-    cpl_test_eq(0,
-                kmo_test_create_RAW_data_zero(test_global_size_x, test_global_size_y,
-                        kmo_test_cat_strings(file_path, path, valid_files[10])));
-
-    /* F3I (valid, invalid) & F3I (invalid, valid) */
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data(test_global_size_x, test_global_size_y, test_global_size_z,  FALSE, 2,
-                          kmo_test_cat_strings(file_path, path, valid_files[11]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    int val1[] = {FALSE, TRUE};
-
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data2(test_global_size_x, test_global_size_y, test_global_size_z, 2, val1,
-                          kmo_test_cat_strings(file_path, path, valid_files[12]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    int val2[] = {FALSE};
-
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data2(test_global_size_x, test_global_size_y, test_global_size_z, 1, val2,
-                          kmo_test_cat_strings(file_path, path, valid_files[13]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    /* ----- invalid test data ----- */
-    /* 2nd operator too small */
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data(test_global_size_x, test_global_size_y, test_global_size_z - 1,  FALSE,
-                        test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    return 0;
-}
-
-
-/**
-  @brief	Test of kmo_arithmetic recipe.
-  @param	argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_arithmetic-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_arithmetic-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            op1_file[256],
-            op2_file[256];
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_arithmetic(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_arithmetic.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-    cpl_msg_info(cpl_func, "Testing kmo_aithmetic with valid data.");
-
-    //
-    // RAW
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-
-    test_arithmetic(op1_file, op1_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 101.7, tol);
-
-    test_arithmetic(op1_file, op1_file, "-", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 0.0, tol);
-
-    test_arithmetic(op1_file, op1_file, "*", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 1135.86, tol);
-
-    test_arithmetic(op1_file, op1_file, "/", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 3.0, tol);
-
-    // divide RAW by zero
-    kmo_test_cat_strings(op2_file, test_path, valid_files[10]);
-    test_arithmetic(op1_file, op2_file, "/", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 0.0, tol);
-
-    // RAW scalar
-    test_arithmetic_scalar(op1_file, scalar, "+");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 70.95, tol);
-
-    test_arithmetic_scalar(op1_file, scalar, "-");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 30.75, tol);
-
-    test_arithmetic_scalar(op1_file, scalar, "*");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 340.695, tol);
-
-    test_arithmetic_scalar(op1_file, scalar, "/");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 7.58955, tol);
-
-    test_arithmetic_scalar(op1_file, scalar, "^");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 6540364687.17815, tol);
-
-    test_arithmetic_scalar(op1_file, 0.0, "^");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 3, tol);
-
-    test_arithmetic_scalar(op1_file, 0.0, "/");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 0.0, tol);
-
-    //
-    // RAW & F2D and vice versa
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[0]);
-    test_arithmetic(op1_file, op2_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 101.7, tol);
-
-    test_arithmetic(op2_file, op1_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 101.7, tol);
-
-    //
-    // F2D with and without noise
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    test_arithmetic(op1_file, op1_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 101.7, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[2]);
-    test_arithmetic(op1_file, op1_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0),112.094, tol);
-
-    test_arithmetic(op1_file, op1_file, "-", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 10.395, tol);
-
-    test_arithmetic(op1_file, op1_file, "*", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 1351.36, tol);
-
-    test_arithmetic(op1_file, op1_file, "/", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 3.79259, tol);
-
-    test_arithmetic_scalar(op1_file, scalar, "^");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 1.21047e+10, tol*1000000000);
-
-    test_arithmetic_scalar(op1_file, 0.0, "^");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 3.0, tol);
-
-    test_arithmetic_scalar(op1_file, 0.0, "/");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 7.35, tol);
-
-    //
-    // F3I & F3I
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[3]);
-    test_arithmetic(op1_file, op1_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 155.7, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    test_arithmetic(op1_file, op1_file, "*", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 3853.39, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-    test_arithmetic(op1_file, op2_file, "-", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 0, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[5]);
-    test_arithmetic(op1_file, op1_file, "/", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 1.41408, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[5]);
-    test_arithmetic(op1_file, op2_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 172.3973, tol);
-
-    //
-    // F3I & F2I
-    //
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[6]);
-    test_arithmetic(op1_file, op2_file, "-", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 30.0, tol);
-
-    kmo_test_verbose_off();
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[7]);
-    test_arithmetic(op1_file, op2_file, "/", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 9.9311, tol);
-    kmo_test_cat_strings(op1_file, test_path, valid_files[11]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[12]);
-    test_arithmetic(op1_file, op2_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 0.0, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[13]);
-    test_arithmetic(op1_file, op1_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 0.0, tol);
-    kmo_test_verbose_on();
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[12]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[6]);
-    test_arithmetic(op1_file, op2_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 34.9, tol);
-
-    //
-    // F3I & F1I
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[9]);
-    test_arithmetic(op1_file, op2_file, "+", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 122.119, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[3]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[8]);
-    test_arithmetic(op1_file, op2_file, "-", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 62.95, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[9]);
-    test_arithmetic(op1_file, op2_file, "*", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 420.986, tol);
-
-    kmo_test_cat_strings(op1_file, test_path, valid_files[3]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[8]);
-    test_arithmetic(op1_file, op2_file, "/", 0);
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 18.6431, tol);
-
-    //
-    // F3I & scalar
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    test_arithmetic_scalar(op1_file, scalar, "*");
-    cpl_test_abs(kmo_test_esorex_data(ARITHMETIC, 0), 555.945, tol);
-
-    /* ----- invalid tests ----- */
-    cpl_msg_info(cpl_func, "Testing kmo_aithmetic with invalid data.");
-    // first: empty F3I, second: filled F2I
-    kmo_test_cat_strings(op1_file, test_path, valid_files[13]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[6]);
-    test_arithmetic(op1_file, op2_file, "*", -1);
-
-    // first op has one IFU, second one has more than one IFUs
-    kmo_test_cat_strings(op1_file, test_path, valid_files[5]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[4]);
-    test_arithmetic(op1_file, op2_file, "+", -1);
-
-    // 2nd operator too small
-    kmo_test_cat_strings(op1_file, test_path, valid_files[3]);
-    kmo_test_cat_strings(op2_file, test_path, invalid_files[0]);
-    test_arithmetic(op1_file, op2_file, "+", -1);
-
-    // invalid operator
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    test_arithmetic(op1_file, op2_file, "x", -1);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_combine-test.c b/recipes/tests/kmo_combine-test.c
deleted file mode 100644
index 31693b8..0000000
--- a/recipes/tests/kmo_combine-test.c
+++ /dev/null
@@ -1,1082 +0,0 @@
-/* $Id: kmo_combine-test.c,v 1.9 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.9 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_constants.h"
-#include "kmclipm_math.h"
-#include "kmclipm_functions.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_combine/";
-
-const char      *valid_files[]      = {"pyramid_orig.fits",
-                                       "pyramid_shift.fits",
-                                       "pyramid_shift2.fits",
-                                       "pyramid_shift_small.fits",
-                                       "gauss_orig.fits",
-                                       "gauss_shift.fits",
-                                       "pyramid_orig_noise.fits",
-                                       "pyramid_shift_noise.fits",
-                                       "gauss_shift_sub.fits",
-                                       "pyramid_shift3.fits"
-                                       };
-
-/**
-    @defgroup kmo_combine   kmo_combine unit tests
-
-    @{
-*/
-
-/**
-    @brief test with data and mask
-*/
-static void test_combine(const char *sof_path,
-                         const char *pars,
-                         int ret_val)
-{
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_combine %s %s",
-            pars, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_combine.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_combine.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_combine(const char *path)
-{
-    int         i                   = 0,
-                shift_size          = 0;
-
-    double      sigma               = 0.0;
-    char        file_path[256],
-                file_path_noise[256],
-                file_path_far[256],
-                file_ref[256],
-                name1[256],
-                name2[256],
-                cmd[256];
-
-    char *test_global_path_ref_data = cpl_sprintf("%s/ref_data/", getenv("srcdir"));
-
-    kmo_test_cat_strings(file_ref, test_global_path_ref_data, "ref_cube_arc.fits");
-
-    cpl_imagelist       *cube_in = kmclipm_imagelist_load(file_ref,
-                                                      CPL_TYPE_FLOAT, 1),
-                        *cube_out = NULL;
-    cpl_propertylist    *pl;
-    cpl_image           *img;
-    int                 ix = 0,
-                        iy = 0;
-    double              x_shift,
-                        y_shift;
-    float               *p = NULL;
-
-    strcpy(name1, IFU_NAME_PREFIX);
-    strcat(name1, "1");
-    strcat(name1, IFU_NAME_POSTFIX);
-
-    strcpy(name2, IFU_NAME_PREFIX);
-    strcat(name2, "2");
-    strcat(name2, IFU_NAME_POSTFIX);
-
-    /* ----- valid test data ----- */
-    //
-    // create pyramid_orig.fits (center at (5,3), object in IFU1)
-    //
-    kmo_test_cat_strings(file_path, path, valid_files[0]);
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    float o14[14] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9};
-    float o13[14] = {10,10,10,10,10,10,10,10,10,10,10,10,10,10};
-    float o12[14] = {11,11,11,11,11,11,11,11,11,11,11,11,11,11};
-    float o11[14] = {12,12,12,12,12,12,12,12,12,12,12,12,12,11};
-    float o10[14] = {13,13,13,13,13,13,13,13,13,13,13,13,12,11};
-    float  o9[14] = {14,14,14,14,14,14,14,14,14,14,14,13,12,11};
-    float  o8[14] = {15,15,15,15,15,15,15,15,15,15,14,13,12,11};
-    float  o7[14] = {16,16,16,16,16,16,16,16,16,15,14,13,12,11};
-    float  o6[14] = {16,17,17,17,17,17,17,17,16,15,14,13,12,11};
-    float  o5[14] = {16,17,18,18,18,18,18,17,16,15,14,13,12,11};
-    float  o4[14] = {16,17,18,19,19,19,18,17,16,15,14,13,12,11};
-    float  o3[14] = {16,17,18,19,20,19,18,17,16,15,14,13,12,11};
-    float  o2[14] = {16,17,18,19,19,19,18,17,16,15,14,13,12,11};
-    float  o1[14] = {16,17,18,18,18,18,18,17,16,15,14,13,12,11};
-
-    cube_out = cpl_imagelist_new();
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o1[ix];
-        iy =  1; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o2[ix];
-        iy =  2; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o3[ix];
-        iy =  3; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o4[ix];
-        iy =  4; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o5[ix];
-        iy =  5; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o6[ix];
-        iy =  6; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o7[ix];
-        iy =  7; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o8[ix];
-        iy =  8; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o9[ix];
-        iy =  9; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o10[ix];
-        iy = 10; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o11[ix];
-        iy = 11; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o12[ix];
-        iy = 12; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o13[ix];
-        iy = 13; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o14[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, name1, "XXX");
-    cpl_propertylist_erase (pl, name2);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-
-    // adding noise toy pyramid_orig(_noise).fits
-    kmo_test_cat_strings(file_path_noise, path, valid_files[6]);
-    strcpy(cmd, "cp ");
-    strcat(cmd, file_path);
-    strcat(cmd, " ");
-    strcat(cmd, file_path_noise);
-    system(cmd);
-
-    float n14[14] = { .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9};
-    float n13[14] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
-    float n12[14] = {1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1};
-    float n11[14] = {1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.1};
-    float n10[14] = {1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.2,1.1};
-    float  n9[14] = {1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.3,1.2,1.1};
-    float  n8[14] = {1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.4,1.3,1.2,1.1};
-    float  n7[14] = {1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n6[14] = {1.6,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n5[14] = {1.6,1.7,1.8,1.8,1.8,1.8,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n4[14] = {1.6,1.7,1.8,1.9,1.9,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n3[14] = {1.6,1.7,1.8,1.9,2.0,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n2[14] = {1.6,1.7,1.8,1.9,1.9,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n1[14] = {1.6,1.7,1.8,1.8,1.8,1.8,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-
-    cube_out = cpl_imagelist_new();
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n1[ix];
-        iy =  1; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n2[ix];
-        iy =  2; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n3[ix];
-        iy =  3; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n4[ix];
-        iy =  4; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n5[ix];
-        iy =  5; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n6[ix];
-        iy =  6; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n7[ix];
-        iy =  7; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n8[ix];
-        iy =  8; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n9[ix];
-        iy =  9; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n10[ix];
-        iy = 10; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n11[ix];
-        iy = 11; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n12[ix];
-        iy = 12; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n13[ix];
-        iy = 13; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n14[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    kmclipm_update_property_string(pl, EXTNAME, "IFU.1.NOISE",
-                                   "FITS extension name");
-    cpl_imagelist_save(cube_out, file_path_noise, CPL_BPP_IEEE_FLOAT, pl,
-                       CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    //
-    // create pyramid_shift.fits (center at (8,4), object in IFU2)
-    //
-    kmo_test_cat_strings(file_path, path, valid_files[1]);
-    kmo_test_cat_strings(file_path_noise, path, valid_files[7]);
-    x_shift = 3;
-    y_shift = 1;
-
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_save(pl, file_path_noise, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    float s14[14] = {10,10,10,10,10,10,10,10,10,10,10,10,10,10};
-    float s13[14] = {11,11,11,11,11,11,11,11,11,11,11,11,11,11};
-    float s12[14] = {12,12,12,12,12,12,12,12,12,12,12,12,12,12};
-    float s11[14] = {13,13,13,13,13,13,13,13,13,13,13,13,13,13};
-    float s10[14] = {13,14,14,14,14,14,14,14,14,14,14,14,14,14};
-    float  s9[14] = {13,14,15,15,15,15,15,15,15,15,15,15,15,14};
-    float  s8[14] = {13,14,15,16,16,16,16,16,16,16,16,16,15,14};
-    float  s7[14] = {13,14,15,16,17,17,17,17,17,17,17,16,15,14};
-    float  s6[14] = {13,14,15,16,17,18,18,18,18,18,17,16,15,14};
-    float  s5[14] = {13,14,15,16,17,18,19,19,19,18,17,16,15,14};
-    float  s4[14] = {13,14,15,16,17,18,19,0./0.,19,18,17,16,15,14};
-    float  s3[14] = {13,14,15,16,17,18,19,19,19,18,17,16,15,14};
-    float  s2[14] = {13,14,15,16,17,18,18,18,18,18,17,16,15,14};
-    float  s1[14] = {13,14,15,16,17,17,17,17,17,17,17,16,15,14};
-
-    cube_out = cpl_imagelist_new();
-    shift_size = 14;
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(shift_size, shift_size, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s1[ix];
-        iy =  1; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s2[ix];
-        iy =  2; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s3[ix];
-        iy =  3; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s4[ix];
-        iy =  4; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s5[ix];
-        iy =  5; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s6[ix];
-        iy =  6; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s7[ix];
-        iy =  7; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s8[ix];
-        iy =  8; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s9[ix];
-        iy =  9; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s10[ix];
-        iy = 10; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s11[ix];
-        iy = 11; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s12[ix];
-        iy = 12; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s13[ix];
-        iy = 13; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s14[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    // save empty 1st ext shift (data)
-    pl = kmclipm_propertylist_load(file_ref, 2);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.1.DATA");
-    cpl_propertylist_update_string(pl, name1, "YYY");
-    cpl_propertylist_erase (pl, name2);
-    cpl_propertylist_save(pl, file_path, CPL_IO_EXTEND);
-    cpl_propertylist_save(pl, file_path_noise, CPL_IO_EXTEND);
-
-    // save empty 1st ext shift (noise)
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.1.NOISE");
-    cpl_propertylist_save(pl, file_path_noise, CPL_IO_EXTEND);
-
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    // save 2nd ext shift (data)
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, name2, "XXX");
-    cpl_propertylist_erase (pl, name1);
-    cpl_propertylist_update_string(pl, EXTNAME, "IFU.2.DATA");
-    cpl_propertylist_update_double(pl, CRPIX1,
-                                   cpl_propertylist_get_double(pl, CRPIX1)+x_shift);
-    cpl_propertylist_update_double(pl, CRPIX2,
-                                   cpl_propertylist_get_double(pl, CRPIX2)+y_shift);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_save(cube_out, file_path_noise, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-
-    // save 2nd ext shift (noise)
-    float sn14[14] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
-    float sn13[14] = {1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1};
-    float sn12[14] = {1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2};
-    float sn11[14] = {1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3};
-    float sn10[14] = {1.3,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4};
-    float  sn9[14] = {1.3,1.4,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.4};
-    float  sn8[14] = {1.3,1.4,1.5,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.5,1.4};
-    float  sn7[14] = {1.3,1.4,1.5,1.6,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.6,1.5,1.4};
-    float  sn6[14] = {1.3,1.4,1.5,1.6,1.7,1.8,1.8,1.8,1.8,1.8,1.7,1.6,1.5,1.4};
-    float  sn5[14] = {1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.9,1.9,1.8,1.7,1.6,1.5,1.4};
-    float  sn4[14] = {1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,1.9,1.8,1.7,1.6,1.5,1.4};
-    float  sn3[14] = {1.3,1.4,1.5,1.6,0./0.,1.8,1.9,1.9,1.9,1.8,1.7,1.6,1.5,1.4};
-    float  sn2[14] = {1.3,1.4,1.5,1.6,1.7,1.8,1.8,1.8,1.8,1.8,1.7,1.6,1.5,1.4};
-    float  sn1[14] = {1.3,1.4,1.5,1.6,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.6,1.5,1.4};
-
-    cube_out = cpl_imagelist_new();
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn1[ix];
-        iy =  1; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn2[ix];
-        iy =  2; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn3[ix];
-        iy =  3; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn4[ix];
-        iy =  4; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn5[ix];
-        iy =  5; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn6[ix];
-        iy =  6; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn7[ix];
-        iy =  7; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn8[ix];
-        iy =  8; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn9[ix];
-        iy =  9; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn10[ix];
-        iy = 10; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn11[ix];
-        iy = 11; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn12[ix];
-        iy = 12; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn13[ix];
-        iy = 13; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = sn14[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    cpl_propertylist_update_string(pl, EXTNAME, "IFU.2.NOISE");
-    cpl_imagelist_save(cube_out, file_path_noise, CPL_BPP_IEEE_FLOAT, pl,
-                       CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    //
-    // create pyramid_shift2.fits (center at (4,11), object in IFU2)
-    //
-    kmo_test_cat_strings(file_path, path, valid_files[2]);
-    kmo_test_cat_strings(file_path_far, path, valid_files[9]);
-    x_shift = -1;
-    y_shift = 8;
-
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_save(pl, file_path_far, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    float s14_2[14] = {17,17,17,17,17,17,17,16,15,14,13,12,11,10};
-    float s13_2[14] = {17,18,18,18,18,18,17,16,15,14,13,12,11,10};
-    float s12_2[14] = {17,18,19,19,19,18,17,16,15,14,13,12,11,10};
-    float s11_2[14] = {17,18,19,20,19,18,17,16,15,14,13,12,11,10};
-    float s10_2[14] = {17,18,19,19,19,18,17,16,15,14,13,12,11,10};
-    float  s9_2[14] = {17,18,18,18,18,18,17,16,15,14,13,12,11,10};
-    float  s8_2[14] = {17,17,17,17,17,17,17,16,15,14,13,12,11,10};
-    float  s7_2[14] = {16,16,16,16,16,16,16,16,15,14,13,12,11,10};
-    float  s6_2[14] = {15,15,15,15,15,15,15,15,15,14,13,12,11,10};
-    float  s5_2[14] = {14,14,14,14,14,14,14,14,14,14,13,12,11,10};
-    float  s4_2[14] = {13,13,13,13,13,13,13,13,13,13,13,12,11,10};
-    float  s3_2[14] = {12,12,12,12,12,12,12,12,12,12,12,12,11,10};
-    float  s2_2[14] = {11,11,11,11,11,11,11,11,11,11,11,11,11,10};
-    float  s1_2[14] = {10,10,10,10,10,10,10,10,10,10,10,10,10,10};
-
-
-    cube_out = cpl_imagelist_new();
-    shift_size = 14;
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(shift_size, shift_size, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s1_2[ix];
-        iy =  1; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s2_2[ix];
-        iy =  2; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s3_2[ix];
-        iy =  3; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s4_2[ix];
-        iy =  4; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s5_2[ix];
-        iy =  5; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s6_2[ix];
-        iy =  6; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s7_2[ix];
-        iy =  7; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s8_2[ix];
-        iy =  8; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s9_2[ix];
-        iy =  9; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s10_2[ix];
-        iy = 10; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s11_2[ix];
-        iy = 11; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s12_2[ix];
-        iy = 12; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s13_2[ix];
-        iy = 13; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s14_2[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    // save empty 1st ext shift
-    pl = kmclipm_propertylist_load(file_ref, 2);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.1.DATA");
-    cpl_propertylist_update_string(pl, name1, "YYY");
-    cpl_propertylist_erase (pl, name2);
-    cpl_propertylist_save(pl, file_path, CPL_IO_EXTEND);
-    cpl_propertylist_save(pl, file_path_far, CPL_IO_EXTEND);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    // save 2nd ext shift
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.2.DATA");
-    cpl_propertylist_update_string(pl, name2, "XXX");
-    cpl_propertylist_erase (pl, name1);
-    cpl_propertylist_update_double(pl, CRPIX1,
-                                   cpl_propertylist_get_double(pl, CRPIX1)+x_shift);
-    cpl_propertylist_update_double(pl, CRPIX2,
-                                   cpl_propertylist_get_double(pl, CRPIX2)+y_shift);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_propertylist_update_double(pl, CRPIX1,
-                                   cpl_propertylist_get_double(pl, CRPIX1)+x_shift-5);
-    cpl_propertylist_update_double(pl, CRPIX2,
-                                   cpl_propertylist_get_double(pl, CRPIX2)+y_shift+5);
-    cpl_imagelist_save(cube_out, file_path_far, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    //
-    // create pyramid_shift_small.fits (center at (8,2), object in IFU2)
-    //
-    kmo_test_cat_strings(file_path, path, valid_files[3]);
-    x_shift = 3;
-    y_shift = -1;
-
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    float s12s[12] = {10,10,10,10,10,10,10,10,10,10,10,10};
-    float s11s[12] = {11,11,11,11,11,11,11,11,11,11,11,11};
-    float s10s[12] = {12,12,12,12,12,12,12,12,12,12,12,12};
-    float  s9s[12] = {13,13,13,13,13,13,13,13,13,13,13,13};
-    float  s8s[12] = {13,14,14,14,14,14,14,14,14,14,14,14};
-    float  s7s[12] = {13,14,15,15,15,15,15,15,15,15,15,15};
-    float  s6s[12] = {13,14,15,16,16,16,16,16,16,16,16,16};
-    float  s5s[12] = {13,14,15,16,17,17,17,17,17,17,17,16};
-    float  s4s[12] = {13,14,15,16,17,18,18,18,18,18,17,16};
-    float  s3s[12] = {13,14,15,16,17,18,19,19,19,18,17,16};
-    float  s2s[12] = {13,14,15,16,17,18,19,20,19,18,17,16};
-    float  s1s[12] = {13,14,15,16,17,18,19,19,19,18,17,16};
-
-    cube_out = cpl_imagelist_new();
-    shift_size = 12;
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(shift_size, shift_size, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s1s[ix];
-        iy =  1; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s2s[ix];
-        iy =  2; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s3s[ix];
-        iy =  3; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s4s[ix];
-        iy =  4; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s5s[ix];
-        iy =  5; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s6s[ix];
-        iy =  6; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s7s[ix];
-        iy =  7; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s8s[ix];
-        iy =  8; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s9s[ix];
-        iy =  9; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s10s[ix];
-        iy = 10; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s11s[ix];
-        iy = 11; for (ix = 0; ix < shift_size; ix++) p[ix+iy*shift_size] = s12s[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    // save empty 1st ext shift
-    pl = kmclipm_propertylist_load(file_ref, 2);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.1.DATA");
-    cpl_propertylist_update_string(pl, name1, "YYY");
-    cpl_propertylist_erase (pl, name2);
-    cpl_propertylist_save(pl, file_path, CPL_IO_EXTEND);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    // save 2nd ext shift
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.2.DATA");
-    cpl_propertylist_update_string(pl, name2, "XXX");
-    cpl_propertylist_erase (pl, name1);
-    cpl_propertylist_update_double(pl, CRPIX1,
-                             cpl_propertylist_get_double(pl, CRPIX1)+x_shift);
-    cpl_propertylist_update_double(pl, CRPIX2,
-                             cpl_propertylist_get_double(pl, CRPIX2)+y_shift);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    //
-    // create gauss_orig.fits (center at (5,3), object in IFU1)
-    //
-
-    // load & save primary
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    kmo_test_cat_strings(file_path, path, valid_files[4]);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    cube_out = cpl_imagelist_new();
-    sigma = 2.0;
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-        cpl_image_fill_gaussian(img, 5, 3,
-                                CPL_MATH_2PI*sigma*sigma, sigma, sigma);
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    // save 1st orig
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, name1, "XXX");
-    cpl_propertylist_erase (pl, name2);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    //
-    // create gauss_shift.fits (center at (10,6), object in IFU2)
-    //
-    x_shift = 5;
-    y_shift = 3;
-
-    // load & save primary
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    kmo_test_cat_strings(file_path, path, valid_files[5]);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    cube_out = cpl_imagelist_new();
-    sigma = 2.0;
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-
-        cpl_image_fill_gaussian(img, 5+x_shift, 3+y_shift,
-                                CPL_MATH_2PI*sigma*sigma, sigma, sigma);
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    // save 1st ext shift
-    pl = kmclipm_propertylist_load(file_ref, 2);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.1.DATA");
-    cpl_propertylist_update_string(pl, name1, "YYY");
-    cpl_propertylist_erase (pl, name2);
-    cpl_propertylist_save(pl, file_path, CPL_IO_EXTEND);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    // save 2nd ext shift
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.2.DATA");
-    cpl_propertylist_update_string(pl, name2, "XXX");
-    cpl_propertylist_erase (pl, name1);
-    cpl_propertylist_update_double(pl, CRPIX1, cpl_propertylist_get_double(pl, CRPIX1)+x_shift);
-    cpl_propertylist_update_double(pl, CRPIX2, cpl_propertylist_get_double(pl, CRPIX2)+y_shift);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    //
-    // create gauss_shift_sub.fits (center at (10.2,6.1), object in IFU2)
-    //
-    x_shift = 5.2;
-    y_shift = 3.1;
-
-    // load & save primary
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    kmo_test_cat_strings(file_path, path, valid_files[8]);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    cube_out = cpl_imagelist_new();
-    sigma = 2.0;
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-
-        cpl_image_fill_gaussian(img, 5+x_shift, 3+y_shift,
-                                CPL_MATH_2PI*sigma*sigma, sigma, sigma);
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    // save 1st ext shift
-    pl = kmclipm_propertylist_load(file_ref, 2);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.1.DATA");
-    cpl_propertylist_update_string(pl, name1, "YYY");
-    cpl_propertylist_erase (pl, name2);
-    cpl_propertylist_save(pl, file_path, CPL_IO_EXTEND);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    // save 2nd ext shift
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, "EXTNAME", "IFU.2.DATA");
-    cpl_propertylist_update_string(pl, name2, "XXX");
-    cpl_propertylist_erase (pl, name1);
-    cpl_propertylist_update_double(pl, CRPIX1, cpl_propertylist_get_double(pl, CRPIX1)+x_shift);
-    cpl_propertylist_update_double(pl, CRPIX2, cpl_propertylist_get_double(pl, CRPIX2)+y_shift);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    cpl_imagelist_delete(cube_in); cube_in = NULL;
-
-    cpl_free(test_global_path_ref_data);
-
-    return 0;
-}
-
-/**
-  @brief    Test of kmo_combine recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_combine-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_combine-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float               tol         = 0.01;
-
-    int                 tmp_int;
-
-    cpl_image           *img        = NULL;
-
-    cpl_propertylist    *h          = NULL;
-
-    char                test_path[256],
-                        file_path[256],
-                        out_path[256];
-
-    FILE *fh;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    /* ----- check if test data exists ----- */
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_combine(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_combine.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-    const char *sof_path = "test_combine.sof",
-               *user_path = "vectors.txt";
-
-    //
-    // method 'none'
-    //
-
-    // combine 2 files: pyramid orig/shift
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2\" --cmethod=\"sum\" --method=\"none\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu1;2");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 29.3865, tol);
-
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 7.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 7.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 14);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 14);
-    cpl_propertylist_delete(h); h = NULL;
-
-    //
-    // method 'header'
-    //
-
-    // combine 2 files: pyramid orig/shift
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2\" --cmethod=\"sum\" --method=\"header\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu1;2");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 22.1888, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 10.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 8.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 17);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 15);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // combine 2 files with noise: pyramid orig/shift
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[6]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[7]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2\" --cmethod=\"sum\" --method=\"header\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu1;2");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 23.6657, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 10.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 8.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 17);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 15);
-    cpl_propertylist_delete(h); h = NULL;
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 1);
-    cpl_test_abs(cpl_image_get(img, 10, 6, &tmp_int), 36, tol);
-    cpl_image_delete(img); img = NULL;
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 2);
-    cpl_test_abs(cpl_image_get(img, 10, 6, &tmp_int), 1.8, tol);
-    cpl_image_delete(img); img = NULL;
-
-    // combine 2 files: pyramid shift/orig (same result as above)
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"2;1\" --cmethod=\"sum\" --method=\"header\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu2;1");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 22.1888, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 10.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 8.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 17);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 15);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // combine 3 files: pyramid orig/shift/shift2
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[2]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2;2\" --cmethod=\"sum\" --method=\"header\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu1;2;2");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 23.1036, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 10.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 15.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 18);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 22);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // combine 3 files: pyramid orig/shift/shift2
-    // combine by name
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[2]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--name=\"XXX\" --cmethod=\"sum\" --method=\"header\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_xxx");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 23.1036, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 10.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 15.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 18);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 22);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // combine 2 files: pyramid orig/shift
-    // combine by name
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--name=\"YYY\" --cmethod=\"sum\" --method=\"header\"",
-                 0);
-
-    // doesn't fail, produces no output
-
-    // combine 2 files: pyramid orig/shift_small
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[3]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2\" --cmethod=\"sum\" --method=\"header\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu1;2");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 21.8627, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 10.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 7.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 15);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 14);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // combine 2 files: pyramids don't overlap
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[9]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"2;2\" --cmethod=\"sum\" --method=\"header\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu2;2");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 14.1633, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 10.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 28.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 24);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 34);
-    cpl_propertylist_delete(h); h = NULL;
-
-    //
-    // method 'center'
-    //
-
-    // combine 2 files: gauss orig/shift
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[4]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[5]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2\" --cmethod=\"sum\" --method=\"center\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu1;2");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 0.160596, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 12.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 10.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 19);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 17);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // combine 2 files (sub-pixel combining): gauss orig/shift
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[4]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[8]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2\" --cmethod=\"sum\" --method=\"center\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu1;2");
-    // this test fails because output fits contaions NaN values
-//        cpl_test_abs(kmo_test_esorex_data(out_path, 0), 0.0974214, tol);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 12.5, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 10.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 18);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 17);
-    cpl_propertylist_delete(h); h = NULL;
-
-    //
-    // method 'user'
-    //
-
-    // combine 2 files: gauss shift/orig
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[5]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[4]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    fh = fopen(user_path, "w" );
-    fprintf (fh, "-5  -3\n");
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"2;1\" --cmethod=\"sum\" "
-                 "--method=\"user\" --filename=\"vectors.txt\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu2;1");
-    switch(sizeof(void*)){
-        case 4:
-        // 32bit system
-        cpl_test_abs(kmo_test_esorex_data(out_path, 0), 0.356464, tol*50);
-        break;
-        case 8:
-        // 64bit system
-        cpl_test_abs(kmo_test_esorex_data(out_path, 0), 0.356464, tol);
-       break;
-    }
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    switch(sizeof(void*)){
-        case 4:
-        // 32bit system
-        cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 17.5, tol);
-        break;
-        case 8:
-        // 64bit system
-        cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 12.5, tol);
-       break;
-    }
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 13.5, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 19);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 17);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // combine 3 files: pyramid orig/shift/shift2
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[2]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    fh = fopen(user_path, "w" );
-    fprintf (fh, "3  1\n");
-    fprintf (fh, "-1  8\n");
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2;2\" --cmethod=\"sum\" "
-                 "--method=\"user\" --filename=\"vectors.txt\"",
-                 0);
-
-    strcpy(out_path, "combine_cube_arc_ifu1;2;2");
-    switch(sizeof(void*)){
-        case 4:
-        // 32bit system
-        cpl_test_abs(kmo_test_esorex_data(out_path, 0), 24.4501, tol);
-        break;
-        case 8:
-        // 64bit system
-        cpl_test_abs(kmo_test_esorex_data(out_path, 0), 24.1194, tol);
-       break;
-    }
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), 10.5, tol);
-    switch(sizeof(void*)){
-        case 4:
-        // 32bit system
-        cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 8.5, tol);
-        break;
-        case 8:
-        // 64bit system
-        cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), 7.5, tol);
-       break;
-    }
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), 18);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), 22);
-    cpl_propertylist_delete(h); h = NULL;
-
-    /* ----- invalid tests ----- */
-    //
-    // method 'user'
-    //
-
-    // combine 2 files: gauss shift/orig
-    // either --name or --ifus parameter missing
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[5]);
-    fprintf (fh, "%s\n", file_path);
-    kmo_test_cat_strings(file_path, test_path, valid_files[4]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2\" --cmethod=\"sum\" --method=\"user\"",
-                 -1);
-
-    // combine 1 file: gauss shift/orig
-    // either --name or --ifus parameter missing
-    fh = fopen(sof_path, "w" );
-    kmo_test_cat_strings(file_path, test_path, valid_files[5]);
-    fprintf (fh, "%s\n", file_path);
-    fclose(fh);
-
-    test_combine(sof_path,
-                 "--ifus=\"1;2\" --cmethod=\"sum\" --method=\"user\"",
-                 -1);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_copy-test.c b/recipes/tests/kmo_copy-test.c
deleted file mode 100644
index b78a71b..0000000
--- a/recipes/tests/kmo_copy-test.c
+++ /dev/null
@@ -1,455 +0,0 @@
-/* $Id: kmo_copy-test.c,v 1.4 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe       = "kmo_copy/";
-
-const char      *valid_files[]     = {"v_data_F3I.fits",
-                                      "v_data_noise_F3I.fits",
-                                      "v_data_F2I.fits",
-                                      "v_data_noise_F2I.fits",
-                                      "v_data_F1I.fits",
-                                      "v_data_noise_F1I.fits",
-                                      "v_data_F3I_2_false_true.fits"};
-
-const char      *invalid_files[]   = {"i_data_RAW.fits",
-                                      "i_data_F2D.fits",
-                                      "i_data_F3I_false.fits"};
-
-/**
-    @defgroup kmo_copy_test  kmo_copy_test unit tests
-
-    @{
-*/
-
-/**
-  @brief   test
-  @param   ifu     If equal to INT_MIN then --ifu isn't specified
-  @param   x       If equal to INT_MIN then --x1 isn't specified
-  @param   y       If equal to INT_MIN then --y1 isn't specified
-  @param   z       If equal to INT_MIN then --z1 isn't specified
-  @param   xsize   If equal to INT_MIN then --x2 isn't specified
-  @param   ysize   If equal to INT_MIN then --y2 isn't specified
-  @param   zsize   If equal to INT_MIN then --z2 isn't specified
- */
-static void
-test_copy(const char *path_op1,
-          int ifu,
-          int x, int xsize,
-          int y, int ysize,
-          int z, int zsize,
-          int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_copy.sof";
-    FILE *fh = fopen( sof_path, "w" );
-    fprintf (fh, "%s\n", path_op1);
-    fclose(fh);
-
-    // create esorex-command
-    char tmp[512];
-    char esorex_command[512];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_copy ");
-
-    if (ifu != INT_MIN) {
-        sprintf(tmp, "--ifu=%d ", ifu);
-        strcat(esorex_command, tmp);
-    }
-    if (x != INT_MIN) {
-        sprintf(tmp, "--x=%d ", x);
-        strcat(esorex_command, tmp);
-    }
-    if (y != INT_MIN) {
-        sprintf(tmp, "--y=%d ", y);
-        strcat(esorex_command, tmp);
-    }
-    if (z != INT_MIN) {
-        sprintf(tmp, "--z=%d ", z);
-        strcat(esorex_command, tmp);
-    }
-    if (xsize != INT_MIN) {
-        sprintf(tmp, "--xsize=%d ", xsize);
-        strcat(esorex_command, tmp);
-    }
-    if (ysize != INT_MIN) {
-        sprintf(tmp, "--ysize=%d ", ysize);
-        strcat(esorex_command, tmp);
-    }
-    if (zsize != INT_MIN) {
-        sprintf(tmp, "--zsize=%d ", zsize);
-        strcat(esorex_command, tmp);
-    }
-
-    strcat(esorex_command, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_copy.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_copy.
-
-    @param path      Path where the generated test data should be saved to.
-*/
-static int kmo_generate_test_data_copy(const char *path)
-{
-    char        file_path[256];
-
-    /* ----- valid test data ----- */
-    /* F3I */
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data(test_global_size_x, test_global_size_y, test_global_size_z,  FALSE, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[0]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y, test_global_size_z,  FALSE,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[1]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    /* F2I */
-    cpl_test_eq(0,
-            kmo_test_create_F2I_data(test_global_size_x, test_global_size_y, FALSE, test_global_size_z,
-                          kmo_test_cat_strings(file_path, path, valid_files[2]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-            kmo_test_create_F2I_data_noise(test_global_size_x, test_global_size_y, test_global_size_z,
-                          kmo_test_cat_strings(file_path, path, valid_files[3]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    /* F1I */
-    cpl_test_eq(0,
-            kmo_test_create_F1I_data(test_global_size_z, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[4]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-            kmo_test_create_F1I_data_noise(test_global_size_z, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[5]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    int val1[] = {FALSE, TRUE};
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data2(test_global_size_x, test_global_size_y, test_global_size_z, 2, val1,
-                          kmo_test_cat_strings(file_path, path, valid_files[6]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    /* ----- invalid test data ----- */
-    /* RAW */
-    cpl_test_eq(0,
-            kmo_test_create_RAW_data(test_global_size_x, test_global_size_y,
-                        kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0, test_global_seed_data, 0.0));
-
-    /* F2D */
-    cpl_test_eq(0,
-            kmo_test_create_F2D_data(test_global_size_x, test_global_size_y, FALSE,
-                        kmo_test_cat_strings(file_path, path, invalid_files[1]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    int val2[] = {FALSE};
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data2(test_global_size_x, test_global_size_y, test_global_size_z, 1, val2,
-                         kmo_test_cat_strings(file_path, path, invalid_files[2]),
-                         NULL, NULL, NULL, 0,
-                         NULL, NULL, NULL, 0));
-
-    return 0;
-}
-
-/**
-  @brief    Test of kmo_copy recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_copy-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_copy-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            in_file[256];
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_copy(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        /* just generate the data */
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_copy.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-    //
-    // in-file: F3I, data only
-    //
-    kmo_test_verbose_off();
-
-    kmo_test_cat_strings(in_file, test_path, valid_files[0]);
-
-    // copy scalar (invalid IFU selected)
-    test_copy(in_file, 2, 1, INT_MIN, 3, INT_MIN, 1, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 0.0, tol);
-
-    kmo_test_verbose_on();
-
-    // copy scalar
-    test_copy(in_file, 3, 1, INT_MIN, 3, INT_MIN, 1, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 18.0, tol);
-
-    //   copy x-vector
-    test_copy(in_file, INT_MIN, 1, 3, 3, INT_MIN, 1, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 57.3, tol);
-
-    //
-    // in-file: F3I, data and noise
-    //
-    kmo_test_cat_strings(in_file, test_path, valid_files[1]);
-
-    // copy scalar
-    test_copy(in_file, INT_MIN, 1, INT_MIN, 3, INT_MIN, 1, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 78.0, tol);
-
-    // copy x-vector
-    test_copy(in_file, 1, 1, 3, 3, INT_MIN, 1, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 13.2, tol);
-
-    // copy y-vector
-    test_copy(in_file, INT_MIN, 4, INT_MIN, 1, 6, 3, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 109.8, tol);
-
-    test_copy(in_file, 4, 5, INT_MIN, 5, 2, 7, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 71.8, tol);
-
-    // copy z-vector
-    test_copy(in_file, INT_MIN, 1, INT_MIN, 1, INT_MIN, 1, 7, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 60.0, tol);
-
-    test_copy(in_file, 4, 5, INT_MIN, 6, INT_MIN, 4, 2, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 69.8, tol);
-
-    // copy z-image
-    test_copy(in_file, INT_MIN, 1, 5, 1, 6, 1, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 94.2, tol);
-
-    test_copy(in_file, 4, 4, 2, 5, 2, 7, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 71.2, tol);
-
-    // copy x-image
-    test_copy(in_file, 4, 5, INT_MIN, 1, 6, 1, 7, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 53.8, tol);
-
-    test_copy(in_file, INT_MIN, 1, INT_MIN, 1, 2, 1, 2, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 54, tol);
-
-    // copy y-image
-    test_copy(in_file, 4, 3, 3, 6, INT_MIN, 6, 2, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 72.6, tol);
-
-    test_copy(in_file, INT_MIN, 1, 5, 1, INT_MIN, 1, 7, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 67.1999, tol);
-
-    // copy whole cube
-    test_copy(in_file, 1, 1, test_global_size_x, 1, test_global_size_y, 1, test_global_size_z, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 23.4, tol);
-
-    // copy sub cube
-    test_copy(in_file, INT_MIN, 1, 2, 4, 3, 4, 4, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 142.8, tol);
-
-    // test --x1=5 --xsize=1 equals copy x-image
-    test_copy(in_file, 4, 5, 1, 1, 6, 1, 7, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 53.8, tol);
-
-    //
-    // in-file: F2I, data and noise
-    //
-    kmo_test_cat_strings(in_file, test_path, valid_files[3]);
-
-    // copy scalar
-    test_copy(in_file, INT_MIN, 5, INT_MIN, 6, INT_MIN, INT_MIN, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 151.2, tol);
-
-    // copy x-vector
-    test_copy(in_file, INT_MIN, 1, 5, 1, INT_MIN, INT_MIN, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 21.6, tol);
-
-    // copy y-vector
-    test_copy(in_file, INT_MIN, 4, INT_MIN, 1, 6, INT_MIN, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 86.4, tol);
-
-    // copy whole image
-    test_copy(in_file, 1, 1, test_global_size_x, 1, test_global_size_y, INT_MIN, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 17.4, tol);
-
-    // copy sub image
-    test_copy(in_file, INT_MIN, 2, 2, 2, 4, INT_MIN, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 79.2, tol);
-
-    //
-    // in-file: F1I, data and noise
-    //
-    kmo_test_cat_strings(in_file, test_path, valid_files[5]);
-
-    // copy scalar
-    test_copy(in_file, INT_MIN, 7, INT_MIN, INT_MIN, INT_MIN, INT_MIN,
-              INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 31.6, tol);
-
-    // copy vector
-    test_copy(in_file, 3, 1, 7, INT_MIN, INT_MIN, INT_MIN, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 7.6, tol);
-
-    // copy vector
-    test_copy(in_file, INT_MIN, 2, 2, INT_MIN, INT_MIN, INT_MIN, INT_MIN, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 15.3999, tol);
-
-    // copy sub cube, first IFU is invalid
-    kmo_test_cat_strings(in_file, test_path, valid_files[6]);
-    test_copy(in_file, INT_MIN, 1, 2, 4, 3, 4, 4, 0);
-    cpl_test_abs(kmo_test_esorex_data(COPY, 0), 27.05, tol);
-
-    /* ----- invalid data ----- */
-    // RAW
-    kmo_test_cat_strings(in_file, test_path, invalid_files[0]);
-    test_copy(in_file, 100, 100, 100, 100, 100, 100, 100, -1);
-
-    // F2D
-    kmo_test_cat_strings(in_file, test_path, invalid_files[1]);
-    test_copy(in_file, 100, 100, 100, 100, 100, 100, 100, -1);
-
-    kmo_test_cat_strings(in_file, test_path, valid_files[0]);
-
-    // F3I too large x1
-    test_copy(in_file, 1, 100, 1, 1, test_global_size_y, 1, test_global_size_z, -1);
-
-    // F3I too large y1
-    test_copy(in_file, 1, 1, 2, 100, 1, 1, test_global_size_z, -1);
-
-    // F3I too large z1
-    test_copy(in_file, 1, 1, 2, 1, 3, 100, 1, -1);
-
-    // F3I too large xsize
-    test_copy(in_file, 1, 1, 100, 1, test_global_size_y, 1, test_global_size_z, -1);
-
-    // F3I too large ysize
-    test_copy(in_file, 1, 1, 2, 1, 100, 1, test_global_size_z, -1);
-
-    // F3I too large zsize
-    test_copy(in_file, 1, 1, 2, 1, 3, 1, 100, -1);
-
-    // F3I too small x1
-    test_copy(in_file, 1, 0, 1, 1, test_global_size_y, 1, test_global_size_z, -1);
-
-    // F3I too small y1
-    test_copy(in_file, 1, 1, 3, 0, test_global_size_y, 1, test_global_size_z, -1);
-
-    // F3I too small z1
-    test_copy(in_file, 1, 1, 4, 1, test_global_size_y, 0, test_global_size_z, -1);
-
-    // copy sub cube, IFU is invalid
-    kmo_test_cat_strings(in_file, test_path, invalid_files[2]);
-    test_copy(in_file, INT_MIN, 1, 2, 4, 3, 4, 7, -1);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_dark-test.c b/recipes/tests/kmo_dark-test.c
deleted file mode 100644
index d314256..0000000
--- a/recipes/tests/kmo_dark-test.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/* $Id: kmo_dark-test.c,v 1.10 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.10 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-#include <math.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-#include "kmclipm_constants.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_dark/";
-
-const char      *valid_files[]      = {"v_raw_123_600sec.fits",
-                                       "v_raw_234_600sec.fits",
-                                       "v_raw_345_600sec.fits",
-                                       "dark_123.fits",
-                                       "dark_231.fits",
-                                       "dark_312.fits"};
-
-const char      *invalid_files[]    = {"i_data_F2D.fits"};
-
-/**
-    @defgroup kmo_dark   kmo_dark unit tests
-
-    @{
-*/
-
-/**
- * @brief test with data and mask
- */
-static void test_dark(const char *path_op1,
-                      const char *path_op2,
-                      const char *path_op3,
-                      int ret_val,
-                      const char* extra_pars)
-{
-    // create sof-file
-    const char *sof_path = "test_dark.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh,
-             "%s   DARK\n%s   DARK\n%s   DARK\n",
-             path_op1, path_op2, path_op3);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_dark %s %s", extra_pars, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_dark.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-static void test_dark2(const char *path_op1,
-                      const char *path_op2,
-                      int ret_val,
-                      const char* extra_pars)
-{
-    // create sof-file
-    const char *sof_path = "test_dark2.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh,
-             "%s   DARK\n%s   DARK\n",
-             path_op1, path_op2);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_dark %s %s", extra_pars, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_dark.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-static void test_dark1(const char *path_op1,
-                      int ret_val,
-                      const char* extra_pars)
-{
-    // create sof-file
-    const char *sof_path = "test_dark1.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   DARK\n", path_op1);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_dark %s %s", extra_pars, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_dark.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-void check_headers_dark(const char *path, int ext, double tol, int offset,
-                        int nr_badpix, double dark, double ron,
-                        double dark_median, double ron_median, double darkcur)
-{
-    cpl_propertylist *h = kmclipm_propertylist_load(path, ext);
-
-    if (cpl_propertylist_get_int(h, QC_NR_BAD_PIX) == nr_badpix) {
-        // Linux
-        cpl_test_eq(cpl_propertylist_get_int(h, QC_NR_BAD_PIX),
-                    nr_badpix);
-    } else {
-        // Mac
-        cpl_test_eq(cpl_propertylist_get_int(h, QC_NR_BAD_PIX),
-                    nr_badpix+19);
-    }
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_READNOISE),
-                 ron, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_DARK),
-                 dark+offset, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_DARK_MEDIAN),
-                 dark_median+offset, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_READNOISE_MEDIAN),
-                 ron_median, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_DARK_CURRENT),
-                 fabs(darkcur), tol);
-
-    cpl_propertylist_delete(h); h = NULL;
-}
-
-
-/**
-    @brief
-        Generates test data for kmo_dark.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_dark(const char *path)
-{
-    char        file_path[256];
-    int         size_x              = 300,
-                size_y              = 509;
-    int         nr_primary_keys     = 3,
-                nr_sub_keys         = 1;
-    char        *primary_keys[nr_primary_keys],
-                *primary_vals[nr_primary_keys],
-                *sub_keys[nr_sub_keys],
-                *sub_vals[nr_sub_keys];
-    int         primary_types[nr_primary_keys],
-                sub_types[nr_primary_keys];
-
-    /* ----- valid test data ----- */
-    /* DARK, 600 sec */
-    primary_keys[0] = MINDIT;
-    primary_types[0] = CPL_TYPE_DOUBLE;
-    primary_vals[0] = "1.0";
-
-    primary_keys[1] = EXPTIME;
-    primary_types[1] = CPL_TYPE_DOUBLE;
-    primary_vals[1] = "600.0";
-
-    primary_keys[2] = NDIT;
-    primary_types[2] = CPL_TYPE_INT;
-    primary_vals[2] = "1.0";
-
-    sub_keys[0] = EXPTIME;
-    sub_types[0] = CPL_TYPE_DOUBLE;
-    sub_vals[0] = "600.0";
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[0]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys,
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 1.1, 0.0));
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[1]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys,
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 1.3, 0.0));
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[2]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys,
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 1.5, 0.0));
-
-    /* ----- invalid test data ----- */
-    /* F2D */
-    cpl_test_eq(0,
-                kmo_test_create_F2D_data(test_global_size_x, test_global_size_y, FALSE,
-                        kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    return 0;
-}
-
-
-/**
-  @brief    Test of kmo_dark recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_dark-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_dark-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[1024],
-            op1_file[1024],
-            op2_file[1024],
-            op3_file[1024],
-            file_path[1024],
-            tmp[1024];
-
-    int nr_badpix = 0;
-
-    double dark         = 0.0,
-           ron          = 0.0,
-           dark_median  = 0.0,
-           ron_median   = 0.0,
-           dark_cur     = 0.0;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_dark(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_dark.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- invalid tests ----- */
-    cpl_msg_info(cpl_func, "Testing kmo_dark with invalid data.");
-
-    // invalid data (F2D)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[1]);
-    kmo_test_cat_strings(op3_file, test_path, invalid_files[0]);
-    test_dark(op1_file, op2_file, op3_file, -1, "");
-
-    /* ----- valid tests ----- */
-    cpl_msg_info(cpl_func, "Testing kmo_dark with valid data.");
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[1]);
-    kmo_test_cat_strings(op3_file, test_path, valid_files[2]);
-
-    //
-    // test with just one frame
-    //
-    test_dark1(op1_file, 0, "");
-
-    nr_badpix    = 0;
-    dark         = 84026.834;
-    ron          = 47746.096;
-    dark_median  = 84048.96875;
-    ron_median   = 47746.101;
-    dark_cur     = 140.046;
-
-    // check MASTER_DARK
-    cpl_test_abs(kmo_test_esorex_data(MASTER_DARK, 0), 395322, tol*100);
-
-    strcpy(tmp, MASTER_DARK);
-    sprintf(file_path, "%s.fits", kmo_strlower(tmp));
-
-    int i = 0;
-    for (i = 1; i <= 2*KMOS_NR_DETECTORS; i+=2) {
-        check_headers_dark(file_path, i, tol, (i-1)/2,
-                           nr_badpix, dark, ron, dark_median, ron_median, dark_cur);
-    }
-
-    // check BADPIXEL_DARK
-    cpl_test_abs(kmo_test_esorex_data(BADPIXEL_DARK, 0), 2.874105, tol);
-    strcpy(tmp, BADPIXEL_DARK);
-    sprintf(file_path, "%s.fits", kmo_strlower(tmp));
-    for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-        check_headers_dark(file_path, i, tol, i-1,
-                           nr_badpix, dark, ron, dark_median, ron_median, dark_cur);
-    }
-
-    //
-    // test with just two frames
-    //
-    test_dark2(op1_file, op2_file, 0, "");
-
-    nr_badpix    = 0;
-    dark         = 91598.4;
-    ron          = 8564.77;
-    dark_median  =  91624.9921875;
-    ron_median   = 8564.77;
-    dark_cur     = 152.667;
-
-    // check MASTER_DARK
-    cpl_test_abs(kmo_test_esorex_data(MASTER_DARK, 0), 306922, tol*100);
-
-    strcpy(tmp, MASTER_DARK);
-    sprintf(file_path, "%s.fits", kmo_strlower(tmp));
-
-    for (i = 1; i <= 2*KMOS_NR_DETECTORS; i+=2) {
-        check_headers_dark(file_path, i, tol, (i-1)/2,
-                           nr_badpix, dark, ron, dark_median, ron_median, dark_cur);
-    }
-
-    // check BADPIXEL_DARK
-    cpl_test_abs(kmo_test_esorex_data(BADPIXEL_DARK, 0), 2.87411, tol);
-    strcpy(tmp, BADPIXEL_DARK);
-    sprintf(file_path, "%s.fits", kmo_strlower(tmp));
-    for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-        check_headers_dark(file_path, i, tol, i-1,
-                           nr_badpix, dark, ron, dark_median, ron_median, dark_cur);
-    }
-
-    //
-    // tests with three frames
-    //
-    test_dark(op1_file, op2_file, op3_file, 0, "");
-
-    // expected values
-    nr_badpix    = 0;
-    dark         = 99257.281;
-    ron          = 8798.0377;
-    dark_median  = 99260.0234375;
-    ron_median   = 8797.673828125;
-
-    // expected values
-    dark_cur = 7.27596e-14;
-
-    // check MASTER_DARK
-    cpl_test_abs(kmo_test_esorex_data(MASTER_DARK, 0), 324136, tol*100);
-    strcpy(tmp, MASTER_DARK);
-    sprintf(file_path, "%s.fits", kmo_strlower(tmp));
-    for (i = 1; i <= 2*KMOS_NR_DETECTORS; i+=2) {
-        check_headers_dark(file_path, i, tol/1e-10, (i-1)/2,
-                           nr_badpix, dark, ron, dark_median, ron_median, dark_cur);
-    }
-
-    // check BADPIXEL_DARK
-    cpl_test_abs(kmo_test_esorex_data(BADPIXEL_DARK, 0), 2.87411, tol);
-    strcpy(tmp, BADPIXEL_DARK);
-    sprintf(file_path, "%s.fits", kmo_strlower(tmp));
-    for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-        check_headers_dark(file_path, i, tol/1e-10, i-1,
-                           nr_badpix, dark, ron, dark_median, ron_median, dark_cur);
-    }
-
-    // keep 'small' badpixel_dark.fits for kmo_flat-test
-    strcpy(test_path, "mv badpixel_dark.fits badpixel_dark_small.fits");
-    system(test_path);
-
-    //
-    // PIPELINE TEST (must be the last test,since the following recipes
-    //   rely on this output)
-    //
-    cpl_msg_info(cpl_func, "Testing kmo_dark with real pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    //
-    // test MASTER_DARK pipeline
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[3]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op3_file, test_path, valid_files[5]);
-    test_dark(op1_file, op2_file, op3_file, 0, " --pos_b=11.0 --neg_b=11.0 ");
-
-    // expected values
-    dark_cur    = 5.3829e-18;
-    nr_badpix   = 33237;
-
-    // check MASTER_DARK
-    cpl_test_abs(kmo_test_esorex_data(MASTER_DARK, 0), 29.4568, tol);
-    strcpy(tmp, MASTER_DARK);
-    sprintf(file_path, "%s.fits", kmo_strlower(tmp));
-    for (i = 1; i <= 2*KMOS_NR_DETECTORS; i++) {
-        check_headers_dark(file_path, i, tol/1e-10, (i-1)/2,
-                           nr_badpix, dark, ron, dark_median, ron_median, dark_cur);
-    }
-
-    //check BADPIXEL_DARK
-    cpl_test_abs(kmo_test_esorex_data(BADPIXEL_DARK, 0), 2.95284, tol);
-    strcpy(tmp, BADPIXEL_DARK);
-    sprintf(file_path, "%s.fits", kmo_strlower(tmp));
-    for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-        check_headers_dark(file_path, i, tol/1e-10, i-1,
-                nr_badpix, dark, ron, dark_median, ron_median, dark_cur);
-    }
-
-    return cpl_test_end(0);
-}
-
-/**@}*/
diff --git a/recipes/tests/kmo_dev_setup-test.c b/recipes/tests/kmo_dev_setup-test.c
deleted file mode 100644
index 09eea55..0000000
--- a/recipes/tests/kmo_dev_setup-test.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* $Id: kmo_dev_setup-test.c,v 1.5 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.5 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-#include "kmclipm_constants.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-void kmo_test_create_pipeline_data_core(const char*, const char*);
-
-const char      *path_recipe       = "kmo_dev_setup/";
-
-/**
-    @defgroup kmo_dev_setup_test  kmo_dev_setup_test unit tests
-
-    @{
-*/
-
-/**
-  @brief    Test of kmo_dev_setup recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_dev_setup-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_dev_setup-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            file_path[256];
-
-    cpl_propertylist *h = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    // get rid of warning...
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) {
-    }
-
-    // run kmo_dev_setup repeatedly
-    kmo_test_create_pipeline_data_core(path_recipe, "log_kmo_dev_setup.txt");
-
-    sprintf(test_path, "%s%s", test_global_path_test_data, path_recipe);
-
-    // check arc_on_123.fits
-    sprintf(file_path, "%s%s", test_path, "arc_on_123");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 252.872, tol*1.5);
-    strcat(file_path, ".fits");
-
-    h = kmclipm_propertylist_load(file_path, 0);
-    cpl_test_eq(cpl_propertylist_get_bool(h, INS_LAMP1_ST), 1);
-    cpl_test_eq(cpl_propertylist_get_int(h, OBS_ID), -2147);
-    cpl_test_eq(cpl_propertylist_get_double(h, ROTANGLE), 0.0);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, "ESO INS FILT1 ID"), "K"), 0);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, "ESO INS FILT2 ID"), "K"), 0);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, "ESO INS FILT3 ID"), "K"), 0);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, "ESO INS GRAT1 ID"), "K"), 0);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, "ESO INS GRAT2 ID"), "K"), 0);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, "ESO INS GRAT3 ID"), "K"), 0);
-    cpl_test_eq(cpl_propertylist_get_double(h, EXPTIME), 600);
-    cpl_propertylist_delete(h); h = NULL;
-
-    h = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(cpl_propertylist_get_double(h, GAIN), 1.1);
-    cpl_test_eq(cpl_propertylist_get_double(h, RON), 0.1);
-    cpl_test_eq(cpl_propertylist_get_double(h, EXPTIME), 600);
-    cpl_propertylist_delete(h); h = NULL;
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_extract_spec-test.c b/recipes/tests/kmo_extract_spec-test.c
deleted file mode 100644
index 1eae6a9..0000000
--- a/recipes/tests/kmo_extract_spec-test.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/* $Id: kmo_extract_spec-test.c,v 1.10 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.10 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <math.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_constants.h"
-#include "kmclipm_functions.h"
-#include "kmclipm_math.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_extract_spec/";
-
-const char      *valid_files[]      = {"v_data_F3I_all.fits",
-                                       "v_data_noise_F3I_all.fits",
-                                       "v_data_F3I_all_infinite.fits",
-                                       "v_mask_F2I.fits",
-                                       "gauss_cube.fits",
-                                       "gauss_cube_noise.fits"};
-
-const char      *invalid_files[]    = {"i_data_F2D.fits",
-                                       "i_mask_F3I.fits"};
-
-/**
-    @defgroup kmo_extract_spec   kmo_extract_spec unit tests
-
-    @{
- */
-
-/**
- * @brief test with data and mask
- */
-static void test_extract_spec(const char *path_op1,
-                              const char *path_op2,
-                              int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_extract_spec.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh,
-             "%s\n%s\n",
-             path_op1, path_op2);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-           "esorex --suppress-prefix=TRUE kmo_extract_spec "
-            "--mask_method=\"mask\" %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_extract_spec.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
- * @brief test with data and centre/radius
- */
-static void test_extract_spec_integrated(const char *path_op1,
-                                         double centre_x,
-                                         double centre_y,
-                                         double radius,
-                                         int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_extract_spec_integrated.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   EXTRACT_DATA\n", path_op1);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_extract_spec "
-            "--centre=\"%g,%g\" --radius=%g %s",
-            centre_x, centre_y, radius, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_extract_spec.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
- * @brief test with data and optimal
- */
-static void test_extract_spec_optimal(const char *path_op1,
-                                         int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_extract_spec_optimal.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   EXTRACT_DATA\n", path_op1);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_extract_spec "
-            "--mask_method=\"optimal\" %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_extract_spec.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_extract_spec.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_extract_spec(const char *path)
-{
-    char        file_path[512];
-
-    int         nr_sub_keys         = 21;
-    char        *sub_keys[nr_sub_keys],
-                *sub_vals[nr_sub_keys];
-    int         sub_types[nr_sub_keys];
-
-    sub_keys[0] = CRPIX1;
-    sub_types[0] = CPL_TYPE_DOUBLE;
-    sub_vals[0] = "17.4";
-
-    sub_keys[1] = CRPIX2;
-    sub_types[1] = CPL_TYPE_DOUBLE;
-    sub_vals[1] = "17.4.0";
-
-    sub_keys[2] = CRPIX3;
-    sub_types[2] = CPL_TYPE_DOUBLE;
-    sub_vals[2] = "1.0";
-
-    sub_keys[3] = CRVAL1;
-    sub_types[3] = CPL_TYPE_DOUBLE;
-    sub_vals[3] = "999.0";
-
-    sub_keys[4] = CRVAL2;
-    sub_types[4] = CPL_TYPE_DOUBLE;
-    sub_vals[4] = "999.0";
-
-    sub_keys[5] = CRVAL3;
-    sub_types[5] = CPL_TYPE_DOUBLE;
-    sub_vals[5] = "1.9999999";
-
-    sub_keys[6] = CDELT1;
-    sub_types[6] = CPL_TYPE_DOUBLE;
-    sub_vals[6] = "1.9";
-
-    sub_keys[7] = CDELT2;
-    sub_types[7] = CPL_TYPE_DOUBLE;
-    sub_vals[7] = "1.9";
-
-    sub_keys[8] = CDELT3;
-    sub_types[8] = CPL_TYPE_DOUBLE;
-    sub_vals[8] = "0.001";
-
-    sub_keys[9] = CTYPE1;
-    sub_types[9] = CPL_TYPE_STRING;
-    sub_vals[9] = "RA---TAN";
-
-    sub_keys[10] = CTYPE2;
-    sub_types[10] = CPL_TYPE_STRING;
-    sub_vals[10] = "DEC--TAN";
-
-    sub_keys[11] = CTYPE3;
-    sub_types[11] = CPL_TYPE_STRING;
-    sub_vals[11] = "WAVE";
-
-    sub_keys[12] = CD1_1;
-    sub_types[12] = CPL_TYPE_DOUBLE;
-    sub_vals[12] = "1.9";
-
-    sub_keys[13] = CD1_2;
-    sub_types[13] = CPL_TYPE_DOUBLE;
-    sub_vals[13] = "0.0";
-
-    sub_keys[14] = CD1_3;
-    sub_types[14] = CPL_TYPE_DOUBLE;
-    sub_vals[14] = "0.0";
-
-    sub_keys[15] = CD2_1;
-    sub_types[15] = CPL_TYPE_DOUBLE;
-    sub_vals[15] = "0.0";
-
-    sub_keys[16] = CD2_2;
-    sub_types[16] = CPL_TYPE_DOUBLE;
-    sub_vals[16] = "1.9";
-
-    sub_keys[17] = CD2_3;
-    sub_types[17] = CPL_TYPE_DOUBLE;
-    sub_vals[17] = "0.0";
-
-    sub_keys[18] = CD3_1;
-    sub_types[18] = CPL_TYPE_DOUBLE;
-    sub_vals[18] = "0.0";
-
-    sub_keys[19] = CD3_2;
-    sub_types[19] = CPL_TYPE_DOUBLE;
-    sub_vals[19] = "0.0";
-
-    sub_keys[20] = CD3_3;
-    sub_types[20] = CPL_TYPE_DOUBLE;
-    sub_vals[20] = "0.001";
-
-    /* ----- valid test data ----- */
-    // F3I
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                         test_global_size_z,  FALSE, test_global_nr_frames,
-                         kmo_test_cat_strings(file_path, path, valid_files[0]),
-                         NULL, NULL, NULL, 0,
-                         sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y,
-                        test_global_size_z,  FALSE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[1]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_infinite(test_global_size_x, test_global_size_y,
-                                              test_global_size_z, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[2]),
-                          NULL, NULL, NULL, 0,
-                          sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    cpl_test_eq(0,
-                kmo_test_create_F2I_data(test_global_size_x, test_global_size_y, FALSE,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[3]),
-                          NULL, NULL, NULL, 0,
-                          sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                         test_global_size_z,  TRUE, test_global_nr_frames,
-                         kmo_test_cat_strings(file_path, path, valid_files[4]),
-                         NULL, NULL, NULL, 0,
-                         sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y,
-                        test_global_size_z,  TRUE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[5]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    /* ----- invalid test data ----- */
-    // F2D
-    cpl_test_eq(0,
-                kmo_test_create_F2D_data(test_global_size_x, test_global_size_y, FALSE,
-                        kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                         test_global_size_z,  FALSE, test_global_nr_frames,
-                         kmo_test_cat_strings(file_path, path, invalid_files[1]),
-                         NULL, NULL, NULL, 0,
-                         sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    return 0;
-}
-
-
-/**
-  @brief    Test of kmo_extract_spec recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_extract_spec-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_extract_spec-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[256],
-            op1_file[256],
-            op2_file[256],
-            out_path[256];
-
-    cpl_propertylist *h = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_extract_spec(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_extract_spec.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-
-    //
-    // F3I, all slices
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    test_extract_spec(op1_file, op2_file, 0);
-    cpl_test_abs(kmo_test_esorex_data(EXTRACT_SPEC, 0), 93.9315, tol);
-    test_extract_spec_integrated(op1_file, 4.0, 5.0, 3.0, 0);
-    cpl_test_abs(kmo_test_esorex_data(EXTRACT_SPEC, 0), 104.1, tol);
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    test_extract_spec_optimal(op1_file, 0);
-    cpl_test_abs(kmo_test_esorex_data(EXTRACT_SPEC, 0), 0.27742, tol);
-
-    strcpy(out_path, EXTRACT_SPEC);
-    kmo_strlower(out_path);
-    strcat(out_path, ".fits");
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, CDELT1), 0.01, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    //
-    // F3I with noise, all slices
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    test_extract_spec(op1_file, op2_file, 0);
-    cpl_test_abs(kmo_test_esorex_data(EXTRACT_SPEC, 0), 130.561, tol);
-    test_extract_spec_integrated(op1_file, 4.0, 5.0, 3.0, 0);
-    cpl_test_abs(kmo_test_esorex_data(EXTRACT_SPEC, 0), 140.877, tol);
-    kmo_test_cat_strings(op1_file, test_path, valid_files[5]);
-    test_extract_spec_optimal(op1_file, 0);
-    cpl_test_abs(kmo_test_esorex_data(EXTRACT_SPEC, 0), 0.31184, tol);
-
-    //
-    // F3I with infinites and without noise, all slices
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[2]);
-    test_extract_spec(op1_file, op2_file, 0);
-    cpl_test_eq(isnan(kmo_test_esorex_data(EXTRACT_SPEC, 0)), FALSE);
-    test_extract_spec_integrated(op1_file, 4.0, 5.0, 3.0, 0);
-    cpl_test_eq(isnan(kmo_test_esorex_data(EXTRACT_SPEC, 0)), FALSE);
-    test_extract_spec_optimal(op1_file, 0);
-    cpl_test_abs(kmclipm_is_nan_or_inf(kmo_test_esorex_data(EXTRACT_SPEC, 0)),
-                 0., tol);
-
-    /* ----- invalid tests ----- */
-    // invalid data (F2D)
-    kmo_test_cat_strings(op1_file, test_path, invalid_files[0]);
-    test_extract_spec(op1_file, op2_file, -1);
-    test_extract_spec_integrated(op1_file, 4.0, 5.0, 3.0, -1);
-    test_extract_spec_optimal(op1_file, -1);
-
-    // invalid mask (F3I)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    kmo_test_cat_strings(op2_file, test_path, invalid_files[1]);
-    test_extract_spec(op1_file, op2_file, -1);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_final-test.c b/recipes/tests/kmo_final-test.c
deleted file mode 100644
index 655b1a0..0000000
--- a/recipes/tests/kmo_final-test.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* $Id: leak_check-test.c,v 1.3 2013-10-08 11:18:57 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:57 $
- * $Revision: 1.3 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-
-#include <cpl.h>
-
-/**
-    @defgroup leak_check_test  check memory leaks in unit tests
-
-    @{
-*/
-
-/**
-  @brief    Check memory leaks in unit tests
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
- */
-int main()
-{
-    int ret = 0;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    // run bash-script to examine all generated log_*.txt files in
-    // kmosp/recipes/tests
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/kmo_final_test.sh", getenv("srcdir"));
-    ret = system(my_path);
-    cpl_free(my_path);
-
-    // have to shift by 8 (divide by 256) to get back
-    //correct exit status from kmo_final_test.sh
-    ret = ret >> 8;
-
-    // test if zero active pointers
-    cpl_test_eq(ret, 0);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_final_test.sh b/recipes/tests/kmo_final_test.sh
deleted file mode 100755
index 00723b9..0000000
--- a/recipes/tests/kmo_final_test.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-#
-# Script executed via leak_check-test.c
-# The unit tests in kmosp/recipes are setup to do esorex calls,
-# if any memory leaks occur there, they won't be detected by executing 'make check'
-# The script analyzes the log-files created during each unit test
-#
-
-
-sum=0;
-for fn in $(ls log_*.txt)
-do 
-   # extract all active pointers from log file and remove "Number of active pointers:"-string
-   fn_vals=$(grep "Number of" $fn | sed 's/[[:alpha:]]//g' | sed 's/[[:punct:]]//g')
-
-   # sum up all active pointers for this fn
-   fn_sum=0;
-   for i in $fn_vals; do ((fn_sum += i)); done
-   if [ $fn_sum -ne 0 ]
-   then
-      echo "[ ERROR ] " $fn "indicates" $fn_sum "active pointers!"
-   fi
-
-   # calculate total sum
-   ((sum += fn_sum))
-done
-
-exit $sum
diff --git a/recipes/tests/kmo_fit_profile-test.c b/recipes/tests/kmo_fit_profile-test.c
deleted file mode 100644
index 097c513..0000000
--- a/recipes/tests/kmo_fit_profile-test.c
+++ /dev/null
@@ -1,822 +0,0 @@
-/* $Id: kmo_fit_profile-test.c,v 1.5 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.5 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-
-#include "kmo_priv_fit_profile.h"
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_fit_profile/";
-
-const char      *valid_files[]      = {"gauss1d_f1i_wcs.fits",
-                                       "gauss1d_f1i.fits",
-                                       "moffat1d_f1i.fits",
-                                       "moffat1d_f1i_wcs.fits",
-                                       "moffat1d_f1i_noise.fits",
-                                       "lorentz1d_f1i.fits",
-                                       "gauss2d_f2i.fits",
-                                       "gauss2d_f2i_noise.fits",
-                                       "moffat2d_f2d.fits",
-                                       "moffat1d_2_f1i_noise.fits"};
-
-/**
-    @defgroup kmo_fit_profile   kmo_fit_profile unit tests
-
-    @{
-*/
-
-/**
- * @brief test with data and mask
- */
-static void test_fit_profile(const char *path,
-                             const char *method,
-                             const char *range,
-                             int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_fit_profile.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   DATA\n", path);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[512], tmp[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_fit_profile --method=%s ",
-            method);
-
-    if (strcmp(range, "") != 0) {
-        sprintf(tmp, " --range=%s ", range);
-        strcat(esorex_command, tmp);
-    }
-    strcat(esorex_command, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_fit_profile.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_fit_profile.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_fit_profile(const char *path)
-{
-    char        out_path[256],
-                cmd[512];
-
-    int         size                = 256,
-                i                   = 0,
-                j                   = 0,
-                nx                  = 100,
-                ny                  = 70;
-
-    cpl_vector  *data_out           = cpl_vector_new(size),
-                *par                = NULL;
-
-    cpl_image   *img_out            = cpl_image_new(nx, ny, CPL_TYPE_FLOAT);
-
-    double      xx[1],
-                xxx[2],
-                result              = 0.0,
-                *pdata_out          = cpl_vector_get_data(data_out),
-                *ppar               = NULL;
-
-    float       *pimg_out           = NULL;
-
-    char        *tmpstr             = NULL;
-    
-    FILE        *fh                 = NULL;
-
-    /* ----- valid test data ----- */
-
-
-    //
-    // create simple 1d gauss curve
-    //
-    par = cpl_vector_new(4);
-    cpl_vector_set(par, 0, 2);      // offset
-    cpl_vector_set(par, 1, 3);      // intensity
-    cpl_vector_set(par, 2, 129);    // center
-    cpl_vector_set(par, 3, 21);     // sigma
-    ppar = cpl_vector_get_data(par);
-
-    for(i = 0; i < size; i++) {
-        xx[0] = i;
-        kmo_priv_gauss1d_fnc(xx, ppar, &result);
-        pdata_out[i] = result;
-    }
-    cpl_vector_delete(par); par = NULL;
-
-    // save gauss curve
-    sprintf(out_path, "%s%s", path, "gauss1d.fits");
-    cpl_vector_save(data_out, out_path, CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-
-    // create sof file "stack.sof"
-    sprintf(out_path, "%s%s", path, "stack.sof");
-    fh = fopen(out_path, "w");
-    fprintf (fh, "test_data/kmo_fit_profile/gauss1d.fits   STACK_DATA\n");
-    fclose(fh);
-
-    //
-    // create 1d gauss curve with WCS and no noise
-    //
-    // stack gauss1d
-    tmpstr = cpl_sprintf("%s", valid_files[0]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F1I "
-            "--filename=%s "
-            "--s=\"CRPIX1;double;1.0;CRVAL1;double;0.2;CDELT1;double;0.01\" %s",
-            tmpstr, out_path);
-
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    //
-    // create 1d gauss curve without WCS and no noise
-    //
-    tmpstr = cpl_sprintf("%s", valid_files[1]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    // stack gauss1d
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F1I "
-            "--filename=%s %s", tmpstr, out_path);
-
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    //
-    // create simple 1d moffat curve
-    //
-    par = cpl_vector_new(5);
-    cpl_vector_set(par, 0, 2);      // offset
-    cpl_vector_set(par, 1, 3);      // intensity
-    cpl_vector_set(par, 2, 129);    // center
-    cpl_vector_set(par, 3, 21);     // alpha
-    cpl_vector_set(par, 4, 2);      // beta
-    ppar = cpl_vector_get_data(par);
-
-    for(i = 0; i < size; i++) {
-        xx[0] = i;
-        kmo_priv_moffat1d_fnc(xx, ppar, &result);
-        pdata_out[i] = result;
-    }
-    cpl_vector_delete(par); par = NULL;
-
-    // save moffat curve
-    sprintf(out_path, "%s%s", path, "moffat1d.fits");
-    cpl_vector_save(data_out, out_path, CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-    // create sof file "stack.sof"
-    sprintf(out_path, "%s%s", path, "stack.sof");
-    fh = fopen(out_path, "w");
-    fprintf (fh, "test_data/kmo_fit_profile/moffat1d.fits   STACK_DATA\n");
-    fclose(fh);
-
-    //
-    // create 1d moffat curve with WCS and no noise
-    //
-    // stack moffat1d
-    tmpstr = cpl_sprintf("%s", valid_files[3]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F1I --filename=%s "
-            "--s=\"CRPIX1;double;1.0;CRVAL1;double;0.2;CDELT1;double;0.01\" %s",
-            tmpstr, out_path);
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    //
-    // create 1d moffat curve without WCS and no noise
-    //
-    tmpstr = cpl_sprintf("%s", valid_files[2]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    // stack moffat1d
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F1I --filename=%s %s",
-            tmpstr, out_path);
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    //
-    // create simple 1d moffat curve with noise
-    //
-    sprintf(out_path, "%s%s", path, "stack.sof");
-    fh = fopen(out_path, "w");
-    fprintf (fh, "test_data/kmo_fit_profile/moffat1d.fits   STACK_DATA\n");
-    char *my_path = cpl_sprintf("%s/ref_data/noise1d.fits", getenv("srcdir"));
-    fprintf (fh, "%s                     STACK_NOISE\n", my_path);
-    fclose(fh);
-
-    //
-    // create 1d moffat curve without WCS and with noise
-    //
-    tmpstr = cpl_sprintf("%s", valid_files[4]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    // stack moffat1d
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F1I --filename=%s %s",
-            tmpstr, out_path);
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    // create sof file "stack.sof"
-    sprintf(out_path, "%s%s", path, "stack.sof");
-    fh = fopen(out_path, "w");
-    fprintf (fh, "test_data/kmo_fit_profile/moffat1d.fits   STACK_DATA\n");
-    fprintf (fh, "%s                     STACK_NOISE\n", my_path);
-    fprintf (fh, "test_data/kmo_fit_profile/moffat1d.fits   STACK_DATA\n");
-    fprintf (fh, "%s                     STACK_NOISE\n", my_path);
-    fclose(fh);
-    cpl_free(my_path);
-
-    //
-    // create 1d moffat curve without WCS and with noise
-    //
-    tmpstr = cpl_sprintf("%s", valid_files[9]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    // stack moffat1d with 2 extensions
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F1I --filename=%s %s",
-            tmpstr, out_path);
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    //
-    // create simple 1d lorentz curve
-    //
-    par = cpl_vector_new(5);
-    ppar = cpl_vector_get_data(par);
-    ppar[0] = 2;      // offset
-    ppar[1] = 1;      // intensity
-    ppar[2] = 129;    // center
-    ppar[3] = 10;     // scale
-    ppar[4] = 0;     // slope
-
-    for(i = 0; i < size; i++) {
-        xx[0] = i;
-        kmo_priv_lorentz1d_fnc(xx, ppar, &result);
-        pdata_out[i] = result;
-    }
-    cpl_vector_delete(par); par = NULL;
-
-    // save lorentz curve
-    sprintf(out_path, "%s%s", path, "lorentz1d.fits");
-    cpl_vector_save(data_out, out_path, CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-    // create sof file "stack.sof"
-    sprintf(out_path, "%s%s", path, "stack.sof");
-    fh = fopen(out_path, "w");
-    fprintf (fh, "test_data/kmo_fit_profile/lorentz1d.fits   STACK_DATA\n");
-    fclose(fh);
-
-    //
-    // create 1d lorentz curve without WCS and without noise
-    //
-    tmpstr = cpl_sprintf("%s", valid_files[5]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    // stack lorentz1d
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F1I --filename=%s %s",
-            tmpstr, out_path);
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    //
-    // create simple 2d gauss curve
-    //
-    par = cpl_vector_new(7);
-    cpl_vector_set(par, 0, 2);      // offset
-    cpl_vector_set(par, 1, 3);      // intensity
-    cpl_vector_set(par, 2, 50);     // center x
-    cpl_vector_set(par, 3, 30);     // center y
-    cpl_vector_set(par, 4, 10);     // axis x
-    cpl_vector_set(par, 5, 20);     // axis y
-    cpl_vector_set(par, 6, 1.2);     // rotation
-    ppar = cpl_vector_get_data(par);
-
-    pimg_out = cpl_image_get_data_float(img_out);
-
-    for (j = 0; j < ny; j++) {
-        xxx[1] = j;
-        for (i = 0; i < nx; i++) {
-            xxx[0] = i;
-            kmo_priv_gauss2d_fnc(xxx, ppar, &result);
-            pimg_out[i+j*nx] = result;
-        }
-    }
-    cpl_vector_delete(par); par = NULL;
-
-    // save gauss 2d curve
-    sprintf(out_path, "%s%s", path, "gauss2d.fits");
-    cpl_image_save(img_out, out_path, CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-
-    // create sof file "stack.sof"
-    sprintf(out_path, "%s%s", path, "stack.sof");
-    fh = fopen(out_path, "w");
-    fprintf (fh, "test_data/kmo_fit_profile/gauss2d.fits   STACK_DATA\n");
-    fclose(fh);
-
-    //
-    // create 2D gauss curve without WCS and without noise
-    //
-    tmpstr = cpl_sprintf("%s", valid_files[6]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    // stack gauss2D
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F2I --filename=%s %s",
-            tmpstr, out_path);
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    //
-    // create 2D gauss curve without WCS and with noise
-    //
-    sprintf(out_path, "%s%s", path, "stack.sof");
-    fh = fopen(out_path, "w");
-    fprintf (fh, "test_data/kmo_fit_profile/gauss2d.fits   STACK_DATA\n");
-    my_path = cpl_sprintf("%s/ref_data/noise2d.fits", getenv("srcdir"));
-    fprintf (fh, "%s                    STACK_NOISE\n", my_path);
-    cpl_free(my_path);
-    fclose(fh);
-
-    tmpstr = cpl_sprintf("%s", valid_files[7]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    // stack gauss2D
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F2I --filename=%s %s",
-            tmpstr, out_path);
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    //
-    // create simple 2d moffat curve
-    //
-    par = cpl_vector_new(8);
-    cpl_vector_set(par, 0, 2);      // offset
-    cpl_vector_set(par, 1, 3);      // intensity
-    cpl_vector_set(par, 2, 50);     // center x
-    cpl_vector_set(par, 3, 30);     // center y
-    cpl_vector_set(par, 4, 10);     // axis x
-    cpl_vector_set(par, 5, 20);     // axis y
-    cpl_vector_set(par, 6, 1.2);    // rotation
-    cpl_vector_set(par, 7, 2);      // beta
-    ppar = cpl_vector_get_data(par);
-
-    pimg_out = cpl_image_get_data_float(img_out);
-
-    for (j = 0; j < ny; j++) {
-        xxx[1] = j;
-        for (i = 0; i < nx; i++) {
-            xxx[0] = i;
-            kmo_priv_moffat2d_fnc(xxx, ppar, &result);
-            pimg_out[i+j*nx] = result;
-        }
-    }
-    cpl_vector_delete(par); par = NULL;
-
-    // save moffat 2d curve
-    sprintf(out_path, "%s%s", path, "moffat2d.fits");
-    cpl_image_save(img_out, out_path, CPL_BPP_IEEE_FLOAT, NULL,CPL_IO_DEFAULT);
-
-    // create sof file "stack.sof"
-    sprintf(out_path, "%s%s", path, "stack.sof");
-    fh = fopen(out_path, "w");
-    fprintf (fh, "test_data/kmo_fit_profile/moffat2d.fits   STACK_DATA\n");
-    fclose(fh);
-
-    //
-    // create 2D moffat curve without WCS and without noise
-    //
-    tmpstr = cpl_sprintf("%s", valid_files[8]);
-    tmpstr[strlen(tmpstr)-5] = '\0';
-    // stack moffat2D
-    sprintf(cmd,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=F2I --filename=%s %s",
-            tmpstr, out_path);
-    kmo_get_pipe_command(cmd,
-                         "log_kmo_fit_profile.txt", NULL, TRUE);
-    system(cmd);
-
-    // move file to right place
-    sprintf(cmd, "mv %s.fits %s", tmpstr, path);
-    system(cmd);
-    cpl_free(tmpstr);
-
-    cpl_vector_delete(data_out); data_out = NULL;
-    cpl_image_delete(img_out); img_out = NULL;
-
-    /* ----- invalid test data ----- */
-
-    return 0;
-}
-
-/**
-  @brief    Test of kmo_fit_profile recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_fit_profile-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_fit_profile-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            out_path[256];
-
-    cpl_propertylist *h = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    FILE *fd = fopen("log_kmo_fit_profile.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_fit_profile(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    strcpy(out_path, FIT_PROFILE);
-    kmo_strlower(out_path);
-    strcat(out_path, ".fits");
-
-    /* ----- valid tests ----- */
-
-    // gauss 1d
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-    test_fit_profile(file_path, "\"gauss\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.61928, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_SIGMA), 21, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_SIGMA), 0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // gauss 1d, wcs
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-    test_fit_profile(file_path, "\"gauss\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.61687, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 1.49, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 1.49, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_SIGMA), 0.21, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_SIGMA), 0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    test_fit_profile(file_path, "\"gauss\"", "\"0.9,2.1\"", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 3.29988, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 1.49, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 1.49, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_SIGMA), 0.21, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_SIGMA), 0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // moffat 1d
-    kmo_test_cat_strings(file_path, test_path, valid_files[2]);
-    test_fit_profile(file_path, "\"moffat\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.38737, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ALPHA), 21, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_BETA), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_ALPHA), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_BETA), 0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // moffat 1d with wcs
-    kmo_test_cat_strings(file_path, test_path, valid_files[3]);
-    test_fit_profile(file_path, "\"moffat\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.38737, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 1.49, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 1.49, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ALPHA), 0.21, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_BETA), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_ALPHA), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_BETA), 0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // moffat 1d with noise
-    kmo_test_cat_strings(file_path, test_path, valid_files[4]);
-    test_fit_profile(file_path, "\"moffat\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.38737, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ALPHA), 21, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_BETA), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_ALPHA), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_BETA), 0, tol);
-
-    cpl_propertylist_delete(h); h = NULL;
-
-    // lorentz 1d
-    kmo_test_cat_strings(file_path, test_path, valid_files[5]);
-    test_fit_profile(file_path, "\"lorentz\"", "", 0);
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.00382, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 1, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_SCALE), 10, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_SCALE), 0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // gauss2d
-    kmo_test_cat_strings(file_path, test_path, valid_files[6]);
-    test_fit_profile(file_path, "\"gauss\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.53135, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX_X), 51, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX_Y), 31, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID_X), 51, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID_Y), 31, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RADIUS_X), 20, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RADIUS_Y), 10, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ROTATION), -21.2451, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // gauss2d with noise
-    kmo_test_cat_strings(file_path, test_path, valid_files[7]);
-    test_fit_profile(file_path, "\"gauss\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.53135, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX_X), 51, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX_Y), 31, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID_X), 51, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID_Y), 31, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RADIUS_X), 20, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RADIUS_Y), 10, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ROTATION), -21.2451, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID_X), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID_Y), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_RADIUS_X), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_RADIUS_Y), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_ROTATION), 0.0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // moffat2d
-    kmo_test_cat_strings(file_path, test_path, valid_files[8]);
-    test_fit_profile(file_path, "\"moffat\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 2.24427, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX_X), 51, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX_Y), 31, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID_X), 51, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID_Y), 31, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RADIUS_X), 20, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RADIUS_Y), 10, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ROTATION), -0.370796*180/CPL_MATH_PI, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_BETA), 2, tol);
-
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID_X), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID_Y), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_RADIUS_X), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_RADIUS_Y), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_ROTATION), 0.0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_BETA), 0.0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-
-    // moffat 1d with noise and two extensions
-    kmo_test_cat_strings(file_path, test_path, valid_files[9]);
-    test_fit_profile(file_path, "\"moffat\"", "", 0);
-
-    cpl_test_abs(kmo_test_esorex_data(FIT_PROFILE, 0), 4.77473, tol);
-    h = kmclipm_propertylist_load(out_path, 1);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ALPHA), 21, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_BETA), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_ALPHA), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_BETA), 0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    h = kmclipm_propertylist_load(out_path, 2);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_MAX_PIX), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_CENTROID), 130, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_OFFSET), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_INTENSITY), 3, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ALPHA), 21, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_BETA), 2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_RED_CHISQ), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_CENTROID), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_OFFSET), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_INTENSITY), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_ALPHA), 0, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, FIT_ERR_BETA), 0, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    /* ----- invalid tests ----- */
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_fits_check-test.c b/recipes/tests/kmo_fits_check-test.c
deleted file mode 100644
index d0275fe..0000000
--- a/recipes/tests/kmo_fits_check-test.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* $Id: kmo_fits_check-test.c,v 1.4 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-/**
-    @defgroup kmo_fits_check_test   kmo_fits_check unit tests
-
-    @{
-*/
-
-/**
- * @brief   test
- */
-static void test_fits_check(const char *option, int ret_val)
-{
-    // create esorex-command
-    char esorex_command[256];
-    char *my_path = cpl_sprintf("%s/../../recipes/tests/ref_data/KMOS_dummy.fits", getenv("srcdir"));
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_fits_check %s  %s", option, my_path);
-    cpl_free(my_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_fits_check.txt", NULL, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-  @brief	Test of kmo_fits_check recipe.
- */
-int main()
-{
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_fits_check.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    test_fits_check("", 0);
-    test_fits_check("--h=-1", 0);
-    test_fits_check("--d=-1", 0);
-    test_fits_check("--h=1", 0);
-    test_fits_check("--d=1", 0);
-    test_fits_check("--h=2", 0);
-    test_fits_check("--d=2", 0);
-    test_fits_check("--h=3", 0);
-    test_fits_check("--d=3", 0);
-    test_fits_check("--gaga", -1);
-    
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_fits_stack-test.c b/recipes/tests/kmo_fits_stack-test.c
deleted file mode 100644
index 3859fd4..0000000
--- a/recipes/tests/kmo_fits_stack-test.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/* $Id: kmo_fits_stack-test.c,v 1.4 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.4 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-#include "kmclipm_constants.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-const char* kmo_test_esorex_verbose();
-
-const char      *path_recipe        = "kmo_fits_stack/";
-
-const char      *valid_files[]      = {"v_vec1.fits",
-                                       "v_vec2.fits",
-                                       "v_vec3.fits",
-                                       "ohspec.fits",
-                                       "Ar_prediction_K.txt",
-                                       "f2l.txt",
-                                       "Ar_prediction_K_2.txt"};
-
-// const char      *invalid_files[]    = {};
-
-/**
-    @defgroup kmo_fits_stack   kmo_fits_stack unit tests
-
-    @{
-*/
-
-/**
- * @brief test with data and mask
- */
-static void test_fits_stack(const char *file1,
-                              const char *file2,
-                              const char *file3,
-                              int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_fits_stack.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, file1);
-    fprintf (fh, "   STACK_DATA\n");
-    fprintf (fh, file2);
-    fprintf (fh, "   STACK_DATA\n");
-    fprintf (fh, file3);
-    fprintf (fh, "   STACK_DATA\n");
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE %s kmo_fits_stack --type=F1I %s",
-            kmo_test_esorex_verbose(), sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_fits_stack.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
- * @brief stack a F1S
- */
-static void test_fits_stack2(const char *file,
-                             const char *type,
-                             const char *format,
-                             const char *title,
-                             int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_fits_stack2.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   STACK_DATA\n", file);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[512], tmp[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack --type=%s ", type);
-    if (strlen(format) > 0) {
-        sprintf(tmp, " --format=%s ", format);
-        strcat(esorex_command, tmp);
-    }
-    if (strlen(title) > 0) {
-        sprintf(tmp, " --title=%s ",title);
-        strcat(esorex_command, tmp);
-    }
-    strcat(esorex_command, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_fits_stack.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_fits_stack.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_fits_stack(const char *path)
-{
-    char        file_path[256];
-    cpl_vector  *vec;
-    /* ----- valid test data ----- */
-    vec = cpl_vector_new(5);
-    cpl_vector_fill(vec, 0.5);
-    cpl_vector_save(vec, kmo_test_cat_strings(file_path, path, valid_files[0]),
-                    CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_DEFAULT);
-
-    cpl_vector_fill(vec, 0.6);
-    cpl_vector_save(vec, kmo_test_cat_strings(file_path, path, valid_files[1]),
-                    CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_DEFAULT);
-
-    cpl_vector_fill(vec, 0.7);
-    cpl_vector_save(vec, kmo_test_cat_strings(file_path, path, valid_files[2]),
-                    CPL_BPP_IEEE_FLOAT, NULL, CPL_IO_DEFAULT);
-
-
-    /* ----- invalid test data ----- */
-    /* none */
-    cpl_vector_delete(vec);
-    return 0;
-}
-
-/**
-  @brief    Test of kmo_fits_stack recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_fits_stack-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_fits_stack-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            name[256],
-            file1[256],
-            file2[256],
-            file3[256];
-
-    cpl_propertylist *prl = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_fits_stack(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_fits_stack.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-    // stack F1I
-    kmo_test_cat_strings(file1, test_path, valid_files[0]);
-    kmo_test_cat_strings(file2, test_path, valid_files[1]);
-    kmo_test_cat_strings(file3, test_path, valid_files[2]);
-
-    test_fits_stack(file1, file2, file3, 0);
-    cpl_test_abs(kmo_test_esorex_data(FITS_STACK, 0), 1.8, tol);
-
-    strcpy(name, FITS_STACK);
-    kmo_strlower(name);
-    kmo_test_cat_strings(file_path, name, ".fits");
-    prl = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, EXTNAME), "IFU.1.DATA"));
-    cpl_propertylist_delete(prl);
-    prl = kmclipm_propertylist_load(file_path, 2);
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, EXTNAME), "IFU.2.DATA"));
-    cpl_propertylist_delete(prl);
-
-    // stack F1S
-    char *test_global_path_ref_data = cpl_sprintf("%s/ref_data/", getenv("srcdir"));
-    kmo_test_cat_strings(file1, test_global_path_ref_data, valid_files[3]);
-
-    test_fits_stack2(file1, F1S, "", "", 0);
-    cpl_test_abs(kmo_test_esorex_data(FITS_STACK, 0), 1.29, tol);
-
-    strcpy(name, FITS_STACK);
-    kmo_strlower(name);
-    kmo_test_cat_strings(file_path, name, ".fits");
-    prl = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, EXTNAME), "SPEC"));
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, "CUNIT1"), "MICRON"));
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, "CTYPE1"), "WAVE"));
-    cpl_test_abs(cpl_propertylist_get_float(prl, "CRVAL1"), 0.8, tol);
-    cpl_propertylist_delete(prl);
-
-    // stack F1L from ascii-file
-    kmo_test_cat_strings(file1, test_global_path_ref_data, valid_files[6]);
-
-    test_fits_stack2(file1, F1L, "\"%f;%f\"", "\"wavelength;strength\"", 0);
-    cpl_test_abs(kmo_test_esorex_data(FITS_STACK, 0), 883.872, tol);
-
-    strcpy(name, FITS_STACK);
-    kmo_strlower(name);
-    kmo_test_cat_strings(file_path, name, ".fits");
-    prl = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, EXTNAME), "LIST"));
-    cpl_propertylist_delete(prl);
-
-    cpl_test_eq(0, system("mv fits_stack.fits table_f1l.fits"));
-
-    // stack F1L from binary FITS-table-file
-    strcpy(file1, "table_f1l.fits");
-
-    test_fits_stack2(file1, F1L, "", "", 0);
-    cpl_test_abs(kmo_test_esorex_data(FITS_STACK, 0), 883.872, tol);
-
-    strcpy(name, FITS_STACK);
-    kmo_strlower(name);
-    kmo_test_cat_strings(file_path, name, ".fits");
-    prl = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, EXTNAME), "LIST"));
-    cpl_propertylist_delete(prl);
-
-    // stack F2L from ascii-file
-    kmo_test_cat_strings(file1, test_global_path_ref_data, valid_files[5]);
-
-    test_fits_stack2(file1, F2L, "\"%f;%f;%f;%f\"", "\"A;B;C;D\"", 0);
-    cpl_test_abs(kmo_test_esorex_data(FITS_STACK, 0), 13.0033, tol);
-
-    strcpy(name, FITS_STACK);
-    kmo_strlower(name);
-    kmo_test_cat_strings(file_path, name, ".fits");
-    prl = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, EXTNAME), "LIST"));
-    cpl_propertylist_delete(prl);
-
-    cpl_test_eq(0, system("mv fits_stack.fits table_f2l.fits"));
-
-    // stack F2L from binary FITS-table-file
-    strcpy(file1, "table_f2l.fits");
-
-    test_fits_stack2(file1, F2L, "", "", 0);
-    cpl_test_abs(kmo_test_esorex_data(FITS_STACK, 0), 13.0033, tol);
-
-    strcpy(name, FITS_STACK);
-    kmo_strlower(name);
-    kmo_test_cat_strings(file_path, name, ".fits");
-    prl = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(0, strcmp(cpl_propertylist_get_string(prl, EXTNAME), "LIST"));
-
-    cpl_propertylist_delete(prl);
-
-    /* ----- invalid tests ----- */
-    // stack F1L as F2L
-    kmo_test_cat_strings(file1, test_global_path_ref_data, valid_files[4]);
-
-    test_fits_stack2(file1, F2L, "\"%f;%f;%f;%f\"", "\"A;B;C;D\"", 1);
-
-    // stack F2L as F1L
-    kmo_test_cat_strings(file1, test_global_path_ref_data, valid_files[5]);
-
-    test_fits_stack2(file1, F1L, "\"%f;%f\"", "\"A;B\"", 1);
-
-    cpl_free(test_global_path_ref_data);
-
-    return cpl_test_end(0);
-}
-
-/**@}*/
diff --git a/recipes/tests/kmo_fits_strip-test.c b/recipes/tests/kmo_fits_strip-test.c
deleted file mode 100644
index 0f95d78..0000000
--- a/recipes/tests/kmo_fits_strip-test.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/* $Id: kmo_fits_strip-test.c,v 1.6 2013-10-09 10:44:55 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-09 10:44:55 $
- * $Revision: 1.6 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-/**
-    @defgroup kmo_fits_strip_test   kmo_fits_strip unit tests
-
-    @{
-*/
-
-/**
- * @brief   test
- */
-static void test_fits_strip(const char *option, const char *file, int ret_val)
-{
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_fits_strip %s %s", option, file);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_fits_strip.txt", NULL, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-  @brief	Test of kmo_fits_strip recipe.
- */
-int main()
-{
-    double tol = 0.01;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_fits_strip.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    test_fits_strip("", "master_dark.fits", 0);
-    test_fits_strip("--noise", "master_dark.fits", 0);
-    cpl_test_abs(kmo_test_esorex_data("strip", 1), 26.9946, tol);
-
-    test_fits_strip("--empty", "telluric_KKK.fits", 0);
-    cpl_test_abs(kmo_test_esorex_data("strip", 1), 5.61881, 0.3);
-
-    test_fits_strip("--angle=0", "master_flat_KKK.fits", 0);
-    cpl_test_abs(kmo_test_esorex_data("strip", 1), 3.00054, tol);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_flat-test.c b/recipes/tests/kmo_flat-test.c
deleted file mode 100644
index cfb00e3..0000000
--- a/recipes/tests/kmo_flat-test.c
+++ /dev/null
@@ -1,775 +0,0 @@
-/* $Id: kmo_flat-test.c,v 1.12 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.12 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-#include <math.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-#include "kmclipm_constants.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_flat/";
-
-const char      *valid_files[]      = {"v_raw_123_on.fits",
-                                       "v_raw_234_on.fits",
-                                       "v_raw_345_on.fits",
-                                       "v_raw_123_off.fits",
-                                       "v_raw_234_off.fits",
-                                       "v_raw_345_off.fits",
-                                       "flat_on_123.fits",
-                                       "flat_on_231.fits",
-                                       "flat_on_312.fits",
-                                       "flat_off_123.fits",
-                                       "flat_off_231.fits",
-                                       "flat_off_312.fits"};
-
-const char      *invalid_files[]    = {"i_data_F2D.fits"};
-
-/**
-    @defgroup kmo_flat   kmo_flat unit tests
-
-    @{
-*/
-
-/**
- * @brief test with data and mask
- */
-static void test_flat(const char *path_op_on1,
-                      const char *path_op_on2,
-                      const char *path_op_on3,
-                      const char *path_op_off1,
-                      const char *path_op_off2,
-                      const char *path_op_off3,
-                      int small,
-                      int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_flat.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   FLAT_ON\n%s   FLAT_ON\n%s   FLAT_ON\n"
-                 "%s   FLAT_OFF\n%s   FLAT_OFF\n%s   FLAT_OFF\n",
-                 path_op_on1, path_op_on2, path_op_on3,
-                 path_op_off1, path_op_off2, path_op_off3);
-
-    if (small == 1) {
-        fprintf (fh, "badpixel_dark_small.fits   BADPIXEL_DARK\n");
-    } else  {
-        fprintf (fh, "badpixel_dark.fits   BADPIXEL_DARK\n");
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_flat %s",
-            sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_flat.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-static void test_flat1(const char *path_op_on1,
-                       const char *path_op_off1,
-                       int small,
-                       int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_flat1.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   FLAT_ON\n"
-                 "%s   FLAT_OFF\n",
-                 path_op_on1,
-                 path_op_off1);
-
-    if (small == 1) {
-        fprintf (fh, "badpixel_dark_small.fits   BADPIXEL_DARK\n");
-    } else  {
-        fprintf (fh, "badpixel_dark.fits   BADPIXEL_DARK\n");
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_flat %s", sof_path);
-
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_flat.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-static void test_flat2(const char *path_op_on1,
-                      const char *path_op_on2,
-                      const char *path_op_off1,
-                      const char *path_op_off2,
-                      int small,
-                      int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_flat2.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   FLAT_ON\n%s   FLAT_ON\n"
-                 "%s   FLAT_OFF\n%s   FLAT_OFF\n",
-                 path_op_on1, path_op_on2,
-                 path_op_off1, path_op_off2);
-
-    if (small == 1) {
-        fprintf (fh, "badpixel_dark_small.fits   BADPIXEL_DARK\n");
-    } else  {
-        fprintf (fh, "badpixel_dark.fits   BADPIXEL_DARK\n");
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_flat -cmethod=sum %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_flat.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-static void test_flat23(const char *path_op_on1,
-                      const char *path_op_on2,
-                      const char *path_op_off1,
-                      const char *path_op_off2,
-                      const char *path_op_off3,
-                      int small,
-                      int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_flat23.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   FLAT_ON\n%s   FLAT_ON\n"
-                 "%s   FLAT_OFF\n%s   FLAT_OFF\n%s   FLAT_OFF\n",
-                 path_op_on1, path_op_on2,
-                 path_op_off1, path_op_off2, path_op_off3);
-
-    if (small == 1) {
-        fprintf (fh, "badpixel_dark_small.fits   BADPIXEL_DARK\n");
-    } else  {
-        fprintf (fh, "badpixel_dark.fits   BADPIXEL_DARK\n");
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_flat -cmethod=sum %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_flat.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-static void test_flat32(const char *path_op_on1,
-                      const char *path_op_on2,
-                      const char *path_op_on3,
-                      const char *path_op_off1,
-                      const char *path_op_off2,
-                      int small,
-                      int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_flat32.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   FLAT_ON\n%s   FLAT_ON\n%s   FLAT_ON\n"
-                 "%s   FLAT_OFF\n%s   FLAT_OFF\n",
-                 path_op_on1, path_op_on2, path_op_on3,
-                 path_op_off1, path_op_off2);
-
-    if (small == 1) {
-        fprintf (fh, "badpixel_dark_small.fits   BADPIXEL_DARK\n");
-    } else  {
-        fprintf (fh, "badpixel_dark.fits   BADPIXEL_DARK\n");
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_flat -cmethod=sum %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_flat.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-void check_headers(const char *path, int ext, double tol) {
-    cpl_propertylist *h = kmclipm_propertylist_load(path, ext);
-
-    cpl_test_eq(cpl_propertylist_get_int(h, QC_FLAT_SAT), 3);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_FLAT_EFF),
-                 26.6846, tol*10);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_FLAT_SN), 5579.42, tol*400);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_GAP_MEAN),
-                 4.93731, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_GAP_SDV),
-                 0.0698977, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_GAP_MAXDEV),
-                 0.187894, tol*40);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SLIT_MEAN),
-                 12.8606, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SLIT_SDV),
-                 0.0653653, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SLIT_MAXDEV),
-                 0.190067, tol*20);
-
-    cpl_propertylist_delete(h); h = NULL;
-}
-
-/**
-    @brief
-        Generates test data for kmo_flat.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_flat(const char *path)
-{
-    char        file_path[256];
-
-    int         nr_primary_keys     = 7,
-                nr_sub_keys         = 1;
-
-    int         size_x              = 300,
-                size_y              = 509;
-
-    char        *primary_keys[nr_primary_keys],
-                *primary_vals[nr_primary_keys],
-                *sub_keys[nr_sub_keys],
-                *sub_vals[nr_sub_keys];
-    int         primary_types[nr_primary_keys],
-                sub_types[nr_primary_keys];
-
-    /* ----- valid test data ----- */
-    primary_keys[0] = INS_LAMP1_ST;
-    primary_types[0] = CPL_TYPE_BOOL;
-    primary_vals[0] = "0";
-
-    primary_keys[1] = INS_LAMP2_ST;
-    primary_types[1] = CPL_TYPE_BOOL;
-    primary_vals[1] = "0";
-
-    sub_keys[0] = EXPTIME;
-    sub_types[0] = CPL_TYPE_DOUBLE;
-    sub_vals[0] = "1.0";
-
-    // Lamp on
-    primary_keys[2] = INS_LAMP3_ST;
-    primary_types[2] = CPL_TYPE_BOOL;
-    primary_vals[2] = "1";
-
-    primary_keys[4] = EXPTIME;
-    primary_types[4] = CPL_TYPE_DOUBLE;
-    primary_vals[4] = "1.0";
-
-    primary_keys[5] = "ESO INS FILT1 ID";
-    primary_types[5] = CPL_TYPE_STRING;
-    primary_vals[5] = "K";
-
-    primary_keys[6] = "ESO INS FILT2 ID";
-    primary_types[6] = CPL_TYPE_STRING;
-    primary_vals[6] = "K";
-
-    primary_keys[3] = "ESO INS FILT3 ID";
-    primary_types[3] = CPL_TYPE_STRING;
-    primary_vals[3] = "K";
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[0]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys,
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 2.1, 0.1));
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[1]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys,
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 3.3, 0.2));
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[2]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys,
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 4.5, 0.3));
-
-    // Lamp off
-    primary_keys[2] = INS_LAMP3_ST;
-    primary_types[2] = CPL_TYPE_BOOL;
-    primary_vals[2] = "0";
-
-    primary_keys[3] = INS_LAMP4_ST;
-    primary_types[3] = CPL_TYPE_BOOL;
-    primary_vals[3] = "0";
-
-    primary_keys[4] = EXPTIME;
-    primary_types[4] = CPL_TYPE_DOUBLE;
-    primary_vals[4] = "1.0";
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[3]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys-3, // set no filter id
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 1.1, 0.4));
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[4]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys-3, // set no filter id
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 1.3, 0.5));
-
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(size_x,
-                                 size_y,
-                               kmo_test_cat_strings(file_path, path, valid_files[5]),
-                                 primary_keys,
-                                 primary_vals,
-                                 primary_types,
-                                 nr_primary_keys-3, // set no filter id
-                                 sub_keys,
-                                 sub_vals,
-                                 sub_types,
-                                 nr_sub_keys,
-                                 1.5, 0.6));
-
-    /* ----- invalid test data ----- */
-    // F2D
-    cpl_test_eq(0,
-                kmo_test_create_F2D_data(size_x, size_y, FALSE,
-                        kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    return 0;
-}
-
-
-/**
-  @brief    Test of kmo_flat recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_flat-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_flat-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            tmp[256],
-            op1_file_on[256],
-            op2_file_on[256],
-            op3_file_on[256],
-            op1_file_off[256],
-            op2_file_off[256],
-            op3_file_off[256];
-
-    cpl_propertylist *h = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_flat(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    kmo_test_cat_strings(op1_file_on, test_path, valid_files[0]);
-    kmo_test_cat_strings(op2_file_on, test_path, valid_files[1]);
-    kmo_test_cat_strings(op3_file_on, test_path, valid_files[2]);
-    kmo_test_cat_strings(op1_file_off, test_path, valid_files[3]);
-    kmo_test_cat_strings(op3_file_off, test_path, valid_files[5]);
-
-    FILE *fd = fopen("log_kmo_flat.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- invalid tests ----- */
-    cpl_msg_info(cpl_func, "Testing kmo_flat with invalid data.");
-
-    // invalid data (F2D)
-    kmo_test_cat_strings(op2_file_off, test_path, invalid_files[0]);
-    test_flat(op1_file_on, op2_file_on, op3_file_on,
-              op1_file_off, op2_file_off, op3_file_off, 1, -1);
-
-    // invalid data (doesn't conatin any slitlets)
-    kmo_test_cat_strings(op2_file_off, test_path, valid_files[4]);
-    test_flat(op1_file_on, op2_file_on, op3_file_on,
-              op1_file_off, op2_file_off, op3_file_off, 1, -1);
-
-    /* ----- valid tests ----- */
-    //
-    //  PIPELINE TEST (must be called after kmo_dark-test, since the
-    //  following recipes rely on this output)
-    //
-    cpl_msg_info(cpl_func, "Testing kmo_flat with real pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    kmo_test_cat_strings(op1_file_on, test_path, valid_files[6]);
-    kmo_test_cat_strings(op2_file_on, test_path, valid_files[7]);
-    kmo_test_cat_strings(op3_file_on, test_path, valid_files[8]);
-    kmo_test_cat_strings(op1_file_off, test_path, valid_files[9]);
-    kmo_test_cat_strings(op2_file_off, test_path, valid_files[10]);
-    kmo_test_cat_strings(op3_file_off, test_path, valid_files[11]);
-
-    //
-    // test with 1 FLAT/DARK frame
-    //
-    test_flat1(op1_file_on,
-               op1_file_off, 0,  0);
-
-    strcpy(tmp, MASTER_FLAT);
-    sprintf(file_path, "%s_KKK.fits", kmo_strlower(tmp));
-
-    h = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.DATA"), 0);
-    cpl_test_abs(0.0, cpl_propertylist_get_double(h, QC_FLAT_SN), tol);
-    cpl_test_eq(0, cpl_propertylist_get_int(h, QC_FLAT_SAT));
-    cpl_test_abs(26.6846, cpl_propertylist_get_double(h, QC_FLAT_EFF), tol*10);
-    cpl_test_abs(4.93827, cpl_propertylist_get_double(h, QC_GAP_MEAN), tol);
-    cpl_test_abs(0.0698976, cpl_propertylist_get_double(h, QC_GAP_SDV), tol);
-    cpl_test_abs(0.187887, cpl_propertylist_get_double(h, QC_GAP_MAXDEV), tol);
-    cpl_test_abs(12.865489, cpl_propertylist_get_double(h, QC_SLIT_MEAN), tol);
-    cpl_test_abs(0.0621559, cpl_propertylist_get_double(h, QC_SLIT_SDV), tol);
-    cpl_test_abs(0.19006, cpl_propertylist_get_double(h, QC_SLIT_MAXDEV), tol*2.1);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 2);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 3);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 4);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 5);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 6);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-
-    //
-    // test with 2 FLAT/DARK frames
-    //
-    test_flat2(op1_file_on, op2_file_on,
-               op1_file_off, op2_file_off, 0, 0);
-
-    strcpy(tmp, MASTER_FLAT);
-    sprintf(file_path, "%s_KKK.fits", kmo_strlower(tmp));
-
-    h = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.DATA"), 0);
-    cpl_test_abs(6958.76, cpl_propertylist_get_double(h, QC_FLAT_SN), tol*1000);
-    cpl_test_eq(3, cpl_propertylist_get_int(h, QC_FLAT_SAT));
-    cpl_test_abs(53.3692, cpl_propertylist_get_double(h, QC_FLAT_EFF), tol*10);
-    cpl_test_abs(4.93827, cpl_propertylist_get_double(h, QC_GAP_MEAN), tol);
-    cpl_test_abs(0.0698928, cpl_propertylist_get_double(h, QC_GAP_SDV), tol);
-    cpl_test_abs(0.187897, cpl_propertylist_get_double(h, QC_GAP_MAXDEV), tol);
-    cpl_test_abs(12.865489, cpl_propertylist_get_double(h, QC_SLIT_MEAN), tol);
-    cpl_test_abs(0.0590724, cpl_propertylist_get_double(h, QC_SLIT_SDV), tol);
-    cpl_test_abs(0.190071, cpl_propertylist_get_double(h, QC_SLIT_MAXDEV), tol*2.1);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 2);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 3);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 4);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 5);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 6);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-
-    //
-    // test with 2 FLAT/3 DARK frames
-    //
-    test_flat23(op1_file_on, op2_file_on,
-               op1_file_off, op2_file_off, op3_file_off, 0, 0);
-
-    strcpy(tmp, MASTER_FLAT);
-    sprintf(file_path, "%s_KKK.fits", kmo_strlower(tmp));
-
-    h = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 2);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 3);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 4);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 5);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 6);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-
-    //
-    // test with 3 FLAT/2 DARK frames
-    //
-    test_flat32(op1_file_on, op2_file_on, op3_file_on,
-               op1_file_off, op2_file_off, 0, 0);
-
-    strcpy(tmp, MASTER_FLAT);
-    sprintf(file_path, "%s_KKK.fits", kmo_strlower(tmp));
-
-    h = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 2);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 3);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 4);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 5);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 6);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-
-    //
-    // test with 3 frames
-    //
-    test_flat(op1_file_on, op2_file_on, op3_file_on,
-              op1_file_off, op2_file_off, op3_file_off, 0, 0);
-
-    // check BADPIXEL_FLAT
-    strcpy(tmp, BADPIXEL_FLAT);
-    sprintf(file_path, "%s_KKK", kmo_strlower(tmp));
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 2.09073, tol);
-    strcat(file_path, ".fits");
-    int i = 0;
-    for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-        check_headers(file_path, i, tol);
-    }
-
-    // check XCAL
-    strcpy(tmp, XCAL);
-    sprintf(file_path, "%s_KKK", kmo_strlower(tmp));
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), -0.900974, tol*60);
-    strcat(file_path, ".fits");
-    for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-        check_headers(file_path, i, tol);
-    }
-
-    // check YCAL
-    strcpy(tmp, YCAL);
-    sprintf(file_path, "%s_KKK", kmo_strlower(tmp));
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 0.875022, tol*6);
-    strcat(file_path, ".fits");
-    for (i = 1; i <= KMOS_NR_DETECTORS; i++) {
-        check_headers(file_path, i, tol);
-    }
-
-    // check FLAT_EDGE
-    strcpy(tmp, FLAT_EDGE);
-    sprintf(file_path, "%s_KKK", kmo_strlower(tmp));
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 24554.7, 50*tol);
-    strcat(file_path, ".fits");
-    for (i = 1; i <= KMOS_NR_DETECTORS*KMOS_IFUS_PER_DETECTOR; i++) {
-        check_headers(file_path, i, tol);
-    }
-
-    // check MASTER_FLAT
-    strcpy(tmp, MASTER_FLAT);
-    sprintf(file_path, "%s_KKK.fits", kmo_strlower(tmp));
-
-    h = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.DATA"), 0);
-    cpl_test_abs(5579.42, cpl_propertylist_get_double(h, QC_FLAT_SN), tol*1000);
-    cpl_test_eq(3, cpl_propertylist_get_int(h, QC_FLAT_SAT));
-    cpl_test_abs(26.6846, cpl_propertylist_get_double(h, QC_FLAT_EFF), tol*10);
-    cpl_test_abs(4.93827, cpl_propertylist_get_double(h, QC_GAP_MEAN), tol);
-    cpl_test_abs(0.0698977, cpl_propertylist_get_double(h, QC_GAP_SDV), tol/8);
-    cpl_test_abs(0.187894, cpl_propertylist_get_double(h, QC_GAP_MAXDEV), tol);
-    cpl_test_abs(12.865489, cpl_propertylist_get_double(h, QC_SLIT_MEAN), tol);
-    cpl_test_abs(0.0590769, cpl_propertylist_get_double(h, QC_SLIT_SDV), tol/4);
-    cpl_test_abs(0.190067, cpl_propertylist_get_double(h, QC_SLIT_MAXDEV), tol*2.1);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 2);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.1.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 3);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 4);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.2.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 5);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.DATA"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-    h = kmclipm_propertylist_load(file_path, 6);
-    cpl_test_eq(strcmp(cpl_propertylist_get_string(h, EXTNAME), "DET.3.NOISE"), 0);
-    cpl_propertylist_delete(h); h = NULL;
-
-    strcpy(tmp, MASTER_FLAT);
-    sprintf(file_path, "%s_KKK", kmo_strlower(tmp));
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 3.00055, tol);
-    strcat(file_path, ".fits");
-    for (i = 1; i <= 2*KMOS_NR_DETECTORS; i++) {
-        check_headers(file_path, i, tol);
-    }
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_illumination-test.c b/recipes/tests/kmo_illumination-test.c
deleted file mode 100644
index 036a545..0000000
--- a/recipes/tests/kmo_illumination-test.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* $Id: kmo_illumination-test.c,v 1.17 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.17 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_illumination/";
-
-const char      *valid_files[]      = {"sky_123.fits",
-                                       "sky_231.fits",
-                                       "sky_312.fits"};
-
-/**
-    @defgroup kmo_illumination   kmo_illumination unit tests
-*/
-
-/**
-  @brief    Test of kmo_illumination recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_illumination-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_illumination-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            op1_file[256],
-            op2_file[256],
-            op3_file[256],
-            esorex_command[512];
-
-    const char *sof_path = "test_illumination.sof";
-
-    cpl_propertylist *h = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    cpl_msg_info(cpl_func, "Testing kmo_illumination with real "
-                           "pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    // get rid of warning...
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) {
-    }
-
-    FILE *fd = fopen("log_kmo_illumination.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    //
-    //  PIPELINE TEST (must be called after kmo_wave_cal-test, since the
-    //  following recipes rely on this output)
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[1]);
-    kmo_test_cat_strings(op3_file, test_path, valid_files[2]);
-
-    // create sof-file
-    FILE *fh = fopen(sof_path, "w");
-    char *my_path = cpl_sprintf("%s/ref_data/kmos_wave_band.fits", getenv("srcdir"));
-    fprintf (fh,
-             "%s                           FLAT_SKY\n"
-             "%s                           FLAT_SKY\n"
-             "%s                           FLAT_SKY\n"
-             "master_dark.fits             MASTER_DARK\n"
-             "master_flat_KKK.fits         MASTER_FLAT\n"
-             "xcal_KKK.fits                XCAL\n"
-             "ycal_KKK.fits                YCAL\n"
-             "lcal_KKK.fits                LCAL\n"
-             "%s WAVE_BAND\n",
-             op1_file, op2_file, op3_file, my_path);
-    fclose(fh);
-    cpl_free(my_path);
-
-    // create esorex-command
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_illumination "
-            "--add-all --imethod=NN --b_start=1.948 --b_end=2.351 %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_illumination.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    cpl_test_eq(0, system(esorex_command));
-
-    // checking output
-    strcpy(file_path, "illum_corr_KKK");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 24.7136, tol);
-    strcat(file_path, ".fits");
-
-    h = kmclipm_propertylist_load(file_path, 0);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SPAT_UNIF),
-                 0.00265038, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SPAT_MAX_DEV),
-                 0.00448508 , tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SPAT_MAX_NONUNIF),
-                 0.0332622, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_illumination_flat-test.c b/recipes/tests/kmo_illumination_flat-test.c
deleted file mode 100644
index 74a22a1..0000000
--- a/recipes/tests/kmo_illumination_flat-test.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* $Id: kmo_illumination_flat-test.c,v 1.1 2013-10-21 13:44:55 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-21 13:44:55 $
- * $Revision: 1.1 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_illumination_flat/";
-
-const char      *valid_files[]      = {"flat_on_123.fits",
-                                       "flat_on_231.fits",
-                                       "flat_on_312.fits"};
-
-/**
-    @defgroup kmo_illumination_flat   kmo_illumination_flat unit tests
-*/
-
-/**
-  @brief    Test of kmo_illumination_flat recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_illumination_flat-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_illumination_flat-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            op1_file[256],
-            op2_file[256],
-            op3_file[256],
-            esorex_command[512];
-
-    const char *sof_path = "test_illumination.sof";
-
-    cpl_propertylist *h = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    cpl_msg_info(cpl_func, "Testing kmo_illumination_flat with real "
-                           "pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    // get rid of warning...
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) {
-    }
-
-    FILE *fd = fopen("log_kmo_illumination_flat.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    //
-    //  PIPELINE TEST (must be called after kmo_wave_cal-test, since the
-    //  following recipes rely on this output)
-    //
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[1]);
-    kmo_test_cat_strings(op3_file, test_path, valid_files[2]);
-
-    // create sof-file
-    FILE *fh = fopen(sof_path, "w");
-    char *my_path = cpl_sprintf("%s/ref_data/kmos_wave_band.fits", getenv("srcdir"));
-    fprintf (fh,
-             "%s                           FLAT_SKY_FLAT\n"
-             "%s                           FLAT_SKY_FLAT\n"
-             "%s                           FLAT_SKY_FLAT\n"
-             "xcal_KKK.fits                XCAL\n"
-             "ycal_KKK.fits                YCAL\n"
-             "lcal_KKK.fits                LCAL\n"
-             "%s WAVE_BAND\n",
-             op1_file, op2_file, op3_file, my_path);
-    fclose(fh);
-    cpl_free(my_path);
-
-    // create esorex-command
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_illumination_flat "
-            "--imethod=NN --b_start=1.948 --b_end=2.351 %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_illumination_flat.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    cpl_test_eq(0, system(esorex_command));
-
-    // checking output
-    strcpy(file_path, "illum_corr_KKK");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 24.0035, tol);
-    strcat(file_path, ".fits");
-
-    h = kmclipm_propertylist_load(file_path, 0);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SPAT_UNIF),
-                 0.00265038, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SPAT_MAX_DEV),
-                 0.00448508 , tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SPAT_MAX_NONUNIF),
-                 0.00131134, tol);
-    cpl_propertylist_delete(h); h = NULL;
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_init-test.c b/recipes/tests/kmo_init-test.c
deleted file mode 100644
index 0099925..0000000
--- a/recipes/tests/kmo_init-test.c
+++ /dev/null
@@ -1,39 +0,0 @@
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <cpl.h>
-
-const char  *test_global_path_test_data;
-int kmo_test_file_exists(const char*);
-void kmo_test_create_pipeline_data_core(const char*, const char*);
-
-char *pipeline_test_path = "pipeline/";
-
-/**
-  @brief	Do init for recipe-tests
-  @param	argc   the number of parameters
-  @param    argv   the parameter list
- */
-int main(int argc, char *argv[])
-{
-    char path[1024];
-    if (kmo_test_file_exists(test_global_path_test_data) == FALSE) {
-        mkdir(test_global_path_test_data, 0777);
-    }
-
-    strcpy(path, test_global_path_test_data);
-    strcat(path, pipeline_test_path);
-
-    if (kmo_test_file_exists(path) == FALSE) {
-        mkdir(path, 0777);
-        kmo_test_create_pipeline_data_core(pipeline_test_path,
-                                           "log_generate_pipeline_data.txt");
-    }
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) { }
-
-    return cpl_test_end(0);
-}
diff --git a/recipes/tests/kmo_make_image-test.c b/recipes/tests/kmo_make_image-test.c
deleted file mode 100644
index f79037f..0000000
--- a/recipes/tests/kmo_make_image-test.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/* $Id: kmo_make_image-test.c,v 1.7 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.7 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_make_image/";
-
-const char      *valid_files[]      = {"v_data_F3I_all.fits",
-                                       "v_data_noise_F3I_all.fits",
-                                       "v_data_F3I_all_w_oh_all.fits",
-                                       "v_data_F3I_all_w_oh_2.fits",
-                                       "v_data_noise_F3I_all_w_oh_small.fits",
-                                       "ohspec.fits",
-                                       "oh_spec_f1s.fits"};
-
-const char      *invalid_files[]    = {"i_data_F2D.fits"};
-
-/**
-    @defgroup kmo_make_image_test   kmo_make_image unit tests
-
-    @{
-*/
-
-/**
- * @brief   test with two frames
- */
-static void test_make_image(const char *path_op1,
-                            const char *path_op2,
-                            const char *method,
-                            int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_make_image.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s\n", path_op1);
-    if (path_op2 != NULL) {
-        fprintf (fh, "%s\n", path_op2);
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_make_image --cmethod=%s %s",
-            method, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_make_image.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-static void test_make_image_ranges(const char *path_op1,
-                                   const char *path_op2,
-                                   const char *method,
-                                   int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_make_image_ranges.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s\n", path_op1);
-    if (path_op2 != NULL) {
-        fprintf (fh, "%s\n", path_op2);
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_make_image "
-            "--range=\"0.9,0.95;1.0,1.5\" --cmethod=%s %s",
-            method, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_make_image.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_make_image.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_make_image(const char *path)
-{
-    char        file_path[256];
-    char        *sub_keys[3];
-    char        *sub_vals[3];
-    int         sub_types[3];
-
-    /* ----- valid test data ----- */
-    // F3I
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                         test_global_size_z,  FALSE, test_global_nr_frames,
-                         kmo_test_cat_strings(file_path, path, valid_files[0]),
-                         NULL, NULL, NULL, 0,
-                         NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y,
-                        test_global_size_z,  FALSE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[1]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    // F3I with CRPIX3, CDELT3, CRVAL3 in a way that all 7 slices are valid
-    // and whole IFU-spectrum lies in oh-spectrum
-    sub_keys[0] = "CRPIX3";
-    sub_vals[0] = "1";
-    sub_types[0] = CPL_TYPE_DOUBLE;
-
-    sub_keys[1] = "CRVAL3";
-    sub_vals[1] = "1.2";        // all 7 slices valid
-    sub_types[1] = CPL_TYPE_DOUBLE;
-
-    sub_keys[2] = "CDELT3";
-    sub_vals[2] = "1.0000E-04";
-    sub_types[2] = CPL_TYPE_DOUBLE;
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                        test_global_size_z,  FALSE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[2]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, 3));
-
-    // F3I with CRPIX3, CDELT3, CRVAL3 in a way that only 2 slices are valid
-    // and whole IFU-spectrum lies in oh-spectrum
-    sub_keys[0] = "CRPIX3";
-    sub_vals[0] = "1";
-    sub_types[0] = CPL_TYPE_DOUBLE;
-
-    sub_keys[1] = "CRVAL3";
-    sub_vals[1] = "1.4182";   // only first 2 slices valid
-    sub_types[1] = CPL_TYPE_DOUBLE;
-
-    sub_keys[2] = "CDELT3";
-    sub_vals[2] = "1.0000E-04";
-    sub_types[2] = CPL_TYPE_DOUBLE;
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                        test_global_size_z,  FALSE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[3]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, 3));
-
-    // F3I with CRPIX3, CDELT3, CRVAL3 in a way that not the whole IFU-spectrum
-    // lies in oh-spectrum AND noise
-    sub_keys[0] = "CRPIX3";
-    sub_vals[0] = "1";
-    sub_types[0] = CPL_TYPE_DOUBLE;
-
-    sub_keys[1] = "CRVAL3";
-    sub_vals[1] = "0.7";
-    sub_types[1] = CPL_TYPE_DOUBLE;
-
-    sub_keys[2] = "CDELT3";
-    sub_vals[2] = "0.4";
-    sub_types[2] = CPL_TYPE_DOUBLE;
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y,
-                        test_global_size_z,  FALSE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[4]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, 3));
-
-    /* ----- invalid test data ----- */
-    // F2D
-    cpl_test_eq(0,
-            kmo_test_create_F2D_data(test_global_size_x, test_global_size_y, FALSE,
-                        kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    return 0;
-}
-
-
-/**
-  @brief    Test of kmo_make_image recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_make_image-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_make_image-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[256],
-            op1_file[256],
-            op2_file[256],
-            esorex_command[256];
-
-    const char *sof_path = "oh.sof";
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    strcpy(op2_file, valid_files[6]);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_make_image(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_make_image.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    FILE *fh = fopen(sof_path, "w");
-    char *test_global_path_ref_data = cpl_sprintf("%s/ref_data/", getenv("srcdir"));
-    fprintf (fh, "%s%s     STACK_DATA\n", test_global_path_ref_data, valid_files[5]);
-    fclose(fh);
-    cpl_free(test_global_path_ref_data);
-
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_fits_stack -type=F1S "
-            "-filename=oh_spec_f1s %s", sof_path);
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_make_image.txt", sof_path, TRUE);
-    cpl_test_eq(0, system(esorex_command));
-
-    /* ----- valid tests ----- */
-    // F3I, all slices
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    test_make_image(op1_file, NULL, "median", 0);
-    cpl_test_abs(kmo_test_esorex_data(MAKE_IMAGE, 0), 77.85, tol);
-
-    // F3I with noise, all slices
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    test_make_image(op1_file, NULL, "median", 0);
-    cpl_test_abs(kmo_test_esorex_data(MAKE_IMAGE, 0), 80.2995, tol);
-
-    // F3I with noise, all slices
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    test_make_image(op1_file, NULL, "ksigma", 0);
-    cpl_test_abs(kmo_test_esorex_data(MAKE_IMAGE, 0), 80.2995, tol);
-
-    // F3I with noise, all slices
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    test_make_image(op1_file, NULL, "min_max", 0);
-    cpl_test_abs(kmo_test_esorex_data(MAKE_IMAGE, 0), 79.9713, tol);
-
-    // F3I without noise, with ohspec (all slices)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[2]);
-    test_make_image(op1_file, op2_file, "ksigma", 0);
-    cpl_test_abs(kmo_test_esorex_data(MAKE_IMAGE, 0), 77.85, tol);
-
-    // F3I without noise and ranges, with ohspec (all slices)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[2]);
-    test_make_image_ranges(op1_file, op2_file, "ksigma", 0);
-    cpl_test_abs(kmo_test_esorex_data(MAKE_IMAGE, 0), 77.85, tol);
-
-    // F3I without noise, with ohspec (2 slices)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[3]);
-    test_make_image(op1_file, op2_file, "median", 0);
-    cpl_test_abs(kmo_test_esorex_data(MAKE_IMAGE, 0), 70.35, tol);
-
-    // F3I with noise, with IFU-spec larger than ohspec (all slices)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    test_make_image(op1_file, op2_file, "ksigma", 0);
-    cpl_test_abs(kmo_test_esorex_data(MAKE_IMAGE, 0), 78.2865, tol);
-
-    /* ----- invalid tests ----- */
-    // NULL input
-    test_make_image(NULL, NULL, "median", -1);
-
-    // F2D
-    kmo_test_cat_strings(op1_file, test_path, invalid_files[0]);
-    test_make_image(op1_file, NULL, "median", -1);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_multi_reconstruct-test.c b/recipes/tests/kmo_multi_reconstruct-test.c
deleted file mode 100644
index 7ab9e8f..0000000
--- a/recipes/tests/kmo_multi_reconstruct-test.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* $Id: kmo_multi_reconstruct-test.c,v 1.12 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.12 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-#include <math.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe       = "kmo_multi_reconstruct/";
-
-const char      *valid_files[]     = {"science_obj_123.fits",
-                                      "science_sky_123.fits",
-                                      "kmos_wave_band.fits"};
-
-/**
-    @defgroup kmo_multi_reconstruct_test  kmo_multi_reconstruct_test unit tests
-
-    @{
-*/
-
-/**
-  @brief   test
- */
-static void test_multi_reconstruct(const char *path1, const char *path2, int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_multi_reconstruct.sof";
-    FILE *fh = fopen(sof_path, "w");
-    char *my_path = cpl_sprintf("%s/ref_data/%s", getenv("srcdir"), valid_files[2]);
-    fprintf (fh,
-             "%s                          SCIENCE\n"
-             "%s                          SCIENCE\n"
-             "master_flat_KKK.fits        MASTER_FLAT\n"
-             "xcal_KKK.fits               XCAL\n"
-             "ycal_KKK.fits               YCAL\n"
-             "lcal_KKK.fits               LCAL\n"
-             "%s WAVE_BAND\n",
-             path1, path2, my_path);
-    fclose(fh);
-    cpl_free(my_path);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_multi_reconstruct --b_start=1.948 "
-            "--b_end=2.351 --name=\"FDF_086\" --method=\"header\"  %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_multi_reconstruct.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-  @brief    Test of kmo_multi_reconstruct recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_multi_reconstruct-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_multi_reconstruct-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.1;
-
-    char    test_path[256],
-            file_path[256],
-            op_file1[256],
-            op_file2[256];
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    // get rid of warning...
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) {
-    }
-
-    FILE *fd = fopen("log_kmo_multi_reconstruct.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    //
-    //  PIPELINE TEST (must be called after kmo_illumination-test, since the
-    //  following recipes rely on this output)
-    //
-    cpl_msg_info(cpl_func, "Testing kmo_multi_reconstruct with real pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    kmo_test_cat_strings(op_file1, test_path, valid_files[0]);
-    kmo_test_cat_strings(op_file2, test_path, valid_files[1]);
-    test_multi_reconstruct(op_file1, op_file2, 0);
-
-    strcpy(file_path, "cube_multi_FDF_086");
-    if (fabs(kmo_test_esorex_data(file_path, 1)-291.216) < tol) {
-        // Linux
-        cpl_test_abs(kmo_test_esorex_data(file_path, 1), 291.216, tol);
-    } else {
-        // Mac
-        cpl_test_abs(kmo_test_esorex_data(file_path, 1), 8132.22, tol);
-    }
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_noise_map-test.c b/recipes/tests/kmo_noise_map-test.c
deleted file mode 100644
index 6ca5efc..0000000
--- a/recipes/tests/kmo_noise_map-test.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/* $Id: kmo_noise_map-test.c,v 1.5 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.5 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_constants.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe     = "kmo_noise_map/";
-
-const char      *valid_files[]      = {"v_data_RAW.fits",
-                                       "v_data_RAW_zero_gain.fits"};
-
-const char      *invalid_files[]    = {"i_data_F3I.fits"};
-
-/**
-    @defgroup kmo_noise_map_test  kmo_noise_map_test unit tests
-
-    @{
- */
-
-/**
-    @brief   test
-*/
-static void kmo_test_noise_map(const char *file,
-                               int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_noise_map.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, file);
-    fprintf (fh, "   DATA\n");
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_noise_map %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_noise_map.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_noise_map.
-
-    @param path      Path where the generated test data should be saved to.
-*/
-static int kmo_generate_test_data_noise_map(const char *path)
-{
-    char        file_path[256];
-
-    int         nr_sub_keys         = 2;
-    char        *sub_keys[nr_sub_keys],
-                *sub_vals[nr_sub_keys];
-    int         sub_types[nr_sub_keys];
-
-    sub_keys[0] = GAIN;
-    sub_vals[0] = "9.9";
-    sub_types[0] = CPL_TYPE_DOUBLE;
-
-    sub_keys[1] = RON;
-    sub_vals[1] = "0.3";
-    sub_types[1] = CPL_TYPE_DOUBLE;
-
-    /* ----- valid test data ----- */
-    // RAW
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(test_global_size_x, test_global_size_y,
-                kmo_test_cat_strings(file_path, path, valid_files[0]),
-                NULL, NULL, NULL, 0,
-                sub_keys, sub_vals, sub_types, nr_sub_keys, test_global_seed_data,
-                0.0));
-
-    // RAW, zero gain
-    sub_vals[0] = "0.0";
-    cpl_test_eq(0,
-        kmo_test_create_RAW_data(test_global_size_x, test_global_size_y,
-                kmo_test_cat_strings(file_path, path, valid_files[1]),
-                NULL, NULL, NULL, 0,
-                sub_keys, sub_vals, sub_types, nr_sub_keys, test_global_seed_data,
-                0.0));
-
-    sub_vals[0] = "9.9";
-
-    /* ----- invalid test data ----- */
-    // F3I
-    cpl_test_eq(0,
-        kmo_test_create_F3I_data(test_global_size_x, test_global_size_y, test_global_size_z,
-                FALSE, test_global_nr_frames,
-                kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                NULL, NULL, NULL, 0,
-                sub_keys, sub_vals, sub_types, nr_sub_keys));
-
-    return 0;
-}
-
-/**
-    @brief
-        Main entrance point for testing kmo_noise_map recipe.
-*/
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            file[256];
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_noise_map(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_noise_map.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-    kmo_test_cat_strings(file, test_path, valid_files[0]);
-    kmo_test_noise_map(file, 0);
-    cpl_test_abs(kmo_test_esorex_data(NOISE_MAP, 0), 54.5645, tol);
-
-    kmo_test_cat_strings(file, test_path, valid_files[1]);
-    kmo_test_noise_map(file, 0);
-    cpl_test_abs(kmo_test_esorex_data(NOISE_MAP, 0), 50.85, tol);
-
-    /* ----- invalid tests ----- */
-    kmo_test_cat_strings(file, test_path, invalid_files[0]);
-    kmo_test_noise_map(file, -1);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_reconstruct-test.c b/recipes/tests/kmo_reconstruct-test.c
deleted file mode 100644
index 9c4bb78..0000000
--- a/recipes/tests/kmo_reconstruct-test.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/* $Id: kmo_reconstruct-test.c,v 1.12 2013-10-08 11:19:14 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:19:14 $
- * $Revision: 1.12 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-#include <math.h>
-
-#include <cpl.h>
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe       = "kmo_reconstruct/";
-
-const char      *valid_files[]     = {"arc_on_123.fits",
-                                      "kmos_wave_band.fits"};
-
-/**
-    @defgroup kmo_reconstruct_test  kmo_reconstruct_test unit tests
-
-    @{
-*/
-
-/**
-  @brief   test
- */
-static void
-test_reconstruct(const char *file_path,
-                 int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_reconstruct.sof";
-    FILE *fh = fopen(sof_path, "w");
-    char *my_path = cpl_sprintf("%s/ref_data/%s", getenv("srcdir"), valid_files[1]);
-    fprintf (fh,
-             "%s                    ARC_ON\n"
-             "xcal_KKK.fits         XCAL\n"
-             "ycal_KKK.fits         YCAL\n"
-             "lcal_KKK.fits         LCAL\n"
-             "%s WAVE_BAND\n",
-             file_path, my_path);
-    fclose(fh);
-    cpl_free(my_path);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_reconstruct --flux=false "
-            "--detimg=TRUE --b_start=1.948 --b_end=2.351 "
-            "--imethod=\"NN\" %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_reconstruct.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-  @brief    Test of kmo_reconstruct recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_reconstruct-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_reconstruct-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            op_file[256];
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    // get rid of warning...
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) {
-    }
-
-    FILE *fd = fopen("log_kmo_reconstruct.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    //
-    //  PIPELINE TEST (must be called after kmo_wave_cal-test, since the
-    //  following recipes rely on this output)
-    //
-    cpl_msg_info(cpl_func, "Testing reconstruct with real pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    kmo_test_cat_strings(op_file, test_path, valid_files[0]);
-    test_reconstruct(op_file, 0);
-
-    // check cube_arc.fits
-    cpl_test_abs(kmo_test_esorex_data("cube_arc", 0), 2919.59, tol*400);
-
-    // check det_img_rec.fits
-    cpl_test_abs(kmo_test_esorex_data("det_img_rec", 0), 364.942, tol*100);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_rotate-test.c b/recipes/tests/kmo_rotate-test.c
deleted file mode 100644
index d380300..0000000
--- a/recipes/tests/kmo_rotate-test.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/* $Id: kmo_rotate-test.c,v 1.8 2013-10-08 11:18:56 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:56 $
- * $Revision: 1.8 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-#include "kmclipm_constants.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe       = "kmo_rotate/";
-
-const char      *valid_files[]     = {"pyramid_orig.fits",
-                                      "pyramid_orig_noise.fits"};
-
-/**
-    @defgroup kmo_rotate_test  kmo_rotate_test unit tests
-
-    @{
-*/
-
-/**
-  @brief   test
- */
-static void
-test_rotate(const char *file_path,
-             const char *pars,
-             int ret_val)
-{
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_rotate %s %s", pars, file_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_rotate.txt", NULL, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_rotate.
-
-    @param path      Path where the generated test data should be saved to.
-*/
-static int kmo_generate_test_data_rotate(const char *path)
-{
-    int         i                   = 0;
-
-    char        file_path[256],
-                file_path_noise[256],
-                file_ref[256],
-                name1[256],
-                name2[256],
-                cmd[256];
-
-    char *test_global_path_ref_data = cpl_sprintf("%s/ref_data/", getenv("srcdir"));
-    kmo_test_cat_strings(file_ref, test_global_path_ref_data, "ref_cube_arc.fits");
-
-    cpl_imagelist       *cube_in = kmclipm_imagelist_load(file_ref,
-                                                      CPL_TYPE_FLOAT, 1),
-                        *cube_out = NULL;
-    cpl_propertylist    *pl;
-    cpl_image           *img;
-    int                 ix = 0,
-                        iy = 0;
-
-    float               *p = NULL;
-
-    strcpy(name1, IFU_NAME_PREFIX);
-    strcat(name1, "1");
-    strcat(name1, IFU_NAME_POSTFIX);
-
-    strcpy(name2, IFU_NAME_PREFIX);
-    strcat(name2, "2");
-    strcat(name2, IFU_NAME_POSTFIX);
-
-    /* ----- valid test data ----- */
-    //
-    // create pyramid_orig.fits (center at (5,3), object in IFU1)
-    //
-    kmo_test_cat_strings(file_path, path, valid_files[0]);
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    float o14[14] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9};
-    float o13[14] = {10,10,10,10,10,10,10,10,10,10,10,10,10,10};
-    float o12[14] = {11,11,11,11,11,11,11,11,11,11,11,11,11,11};
-    float o11[14] = {12,12,12,12,12,12,12,12,12,12,12,12,12,11};
-    float o10[14] = {13,13,13,13,13,13,13,13,13,13,13,13,12,11};
-    float  o9[14] = {14,14,14,14,14,14,14,14,14,14,14,13,12,11};
-    float  o8[14] = {15,15,15,15,15,15,15,15,15,15,14,13,12,11};
-    float  o7[14] = {16,16,16,16,16,16,16,16,16,15,14,13,12,11};
-    float  o6[14] = {16,17,17,17,17,17,17,17,16,15,14,13,12,11};
-    float  o5[14] = {16,17,18,18,18,18,18,17,16,15,14,13,12,11};
-    float  o4[14] = {16,17,18,19,19,19,18,17,16,15,14,13,12,11};
-    float  o3[14] = {16,17,18,19,20,19,18,17,16,15,14,13,12,11};
-    float  o2[14] = {16,17,18,19,19,19,18,17,16,15,14,13,12,11};
-    float  o1[14] = {16,17,18,18,18,18,18,17,16,15,14,13,12,11};
-
-    cube_out = cpl_imagelist_new();
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o1[ix];
-        iy =  1; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o2[ix];
-        iy =  2; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o3[ix];
-        iy =  3; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o4[ix];
-        iy =  4; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o5[ix];
-        iy =  5; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o6[ix];
-        iy =  6; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o7[ix];
-        iy =  7; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o8[ix];
-        iy =  8; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o9[ix];
-        iy =  9; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o10[ix];
-        iy = 10; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o11[ix];
-        iy = 11; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o12[ix];
-        iy = 12; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o13[ix];
-        iy = 13; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o14[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, name1, "XXX");
-    cpl_propertylist_erase (pl, name2);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-
-    // adding noise
-    kmo_test_cat_strings(file_path_noise, path, valid_files[1]);
-    strcpy(cmd, "cp ");
-    strcat(cmd, file_path);
-    strcat(cmd, " ");
-    strcat(cmd, file_path_noise);
-    system(cmd);
-
-    float n14[14] = { .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9};
-    float n13[14] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
-    float n12[14] = {1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1};
-    float n11[14] = {1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.1};
-    float n10[14] = {1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.2,1.1};
-    float  n9[14] = {1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.3,1.2,1.1};
-    float  n8[14] = {1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.4,1.3,1.2,1.1};
-    float  n7[14] = {1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n6[14] = {1.6,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n5[14] = {1.6,1.7,1.8,1.8,1.8,1.8,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n4[14] = {1.6,1.7,1.8,1.9,1.9,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n3[14] = {1.6,1.7,1.8,1.9,2.0,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n2[14] = {1.6,1.7,1.8,1.9,1.9,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n1[14] = {1.6,1.7,1.8,1.8,1.8,1.8,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-
-    cube_out = cpl_imagelist_new();
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n1[ix];
-        iy =  1; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n2[ix];
-        iy =  2; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n3[ix];
-        iy =  3; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n4[ix];
-        iy =  4; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n5[ix];
-        iy =  5; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n6[ix];
-        iy =  6; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n7[ix];
-        iy =  7; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n8[ix];
-        iy =  8; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n9[ix];
-        iy =  9; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n10[ix];
-        iy = 10; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n11[ix];
-        iy = 11; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n12[ix];
-        iy = 12; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n13[ix];
-        iy = 13; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n14[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    cpl_propertylist_update_string(pl, EXTNAME, "IFU.1.NOISE");
-    cpl_imagelist_save(cube_out, file_path_noise, CPL_BPP_IEEE_FLOAT, pl,
-                       CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_in); cube_in = NULL;
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    cpl_free(test_global_path_ref_data);
-
-    return 0;
-}
-
-void check_headers(cpl_propertylist *h_orig, const char *out_path, int ext,
-                   int nax1, int nax2, double crpix1, double crpix2,
-                   double cd1_1, double cd1_2, double cd1_3,
-                   double cd2_1, double cd2_2, double cd2_3,
-                   double tol)
-{
-    cpl_propertylist *h = kmclipm_propertylist_load(out_path, ext);
-
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), crpix1, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), crpix2, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), nax1);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), nax2);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRVAL1),
-                 cpl_propertylist_get_double(h_orig, CRVAL1), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRVAL2),
-                 cpl_propertylist_get_double(h_orig, CRVAL2), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRVAL3),
-                 cpl_propertylist_get_double(h_orig, CRVAL3), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CDELT1),
-                 cpl_propertylist_get_double(h_orig, CDELT1), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CDELT2),
-                 cpl_propertylist_get_double(h_orig, CDELT2), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CDELT3),
-                 cpl_propertylist_get_double(h_orig, CDELT3), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX3),
-                 cpl_propertylist_get_double(h_orig, CRPIX3), tol);
-
-    cpl_test_abs(cpl_propertylist_get_double(h, CD1_1), cd1_1, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD1_2), cd1_2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD1_3), cd1_3, tol);
-
-    cpl_test_abs(cpl_propertylist_get_double(h, CD2_1), cd2_1, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD2_2), cd2_2, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD2_3), cd2_3, tol);
-
-    cpl_test_abs(cpl_propertylist_get_double(h, CD3_1),
-                 cpl_propertylist_get_double(h_orig, CD3_1), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD3_2),
-                 cpl_propertylist_get_double(h_orig, CD3_2), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD3_3),
-                 cpl_propertylist_get_double(h_orig, CD3_3), tol);
-
-    cpl_propertylist_delete(h); h = NULL;
-}
-
-/**
-  @brief    Test of kmo_rotate recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_rotate-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_rotate-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            orig_file_path[256],
-            out_path[256];
-
-    cpl_propertylist    *h = NULL,
-                        *h_orig = NULL;
-
-    cpl_image   *img = NULL;
-
-    int tmp_int;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_rotate(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_rotate.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-
-    h_orig = kmclipm_propertylist_load(file_path, 1);
-
-    // rotate 90deg CW
-    test_rotate(file_path,
-                 "--ifu=1 --rot=\"-90.0\" --flux=true",
-                 0);
-
-    strcpy(out_path, "rotate");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 13.7551, tol);
-    // test for correctness of flux conservation
-    kmo_test_cat_strings(orig_file_path, test_path, "pyramid_orig");
-    cpl_test_abs(kmo_test_esorex_data(orig_file_path, 0),
-                 kmo_test_esorex_data(out_path, 0), tol);
-    strcat(out_path, ".fits");
-
-    h = kmclipm_propertylist_load(out_path, 1);
-    check_headers(h_orig, out_path, 1,
-                  14, 14, 7.5, 7.5,
-                  0.0, -cpl_propertylist_get_double(h, CDELT1),
-                                cpl_propertylist_get_double(h_orig, CD1_3),
-                  cpl_propertylist_get_double(h, CDELT2), 0.0,
-                                cpl_propertylist_get_double(h_orig, CD2_3),
-                  tol/1000);
-    cpl_propertylist_delete(h); h = NULL;
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 1);
-    cpl_test_abs(cpl_image_get(img, 3, 10, &tmp_int), 20.0, tol);
-    cpl_image_delete(img); img = NULL;
-
-    system("mv rotate.fits rot.fits");
-
-    // rotate back again, 90deg CCW
-    kmo_test_cat_strings(file_path, "", "rot.fits");
-    test_rotate(file_path,
-                 "--ifu=1 --rot=\"90.0\" --flux=true",
-                 0);
-
-    strcpy(out_path, "rotate");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 13.7551, tol);
-    // test for correctness of flux conservation
-    cpl_test_abs(kmo_test_esorex_data(orig_file_path, 0),
-                 kmo_test_esorex_data(out_path, 0), tol);
-    strcat(out_path, ".fits");
-
-    check_headers(h_orig, out_path, 1,
-                  14, 14, 7.5, 7.5,
-                  cpl_propertylist_get_double(h_orig, CD1_1),
-                                cpl_propertylist_get_double(h_orig, CD1_2),
-                                cpl_propertylist_get_double(h_orig, CD1_3),
-                  cpl_propertylist_get_double(h_orig, CD2_1),
-                                cpl_propertylist_get_double(h_orig, CD2_2),
-                                cpl_propertylist_get_double(h_orig, CD2_3),
-                  tol/1000);
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 1);
-    cpl_test_abs(cpl_image_get(img, 5, 3, &tmp_int), 20.0, tol);
-    cpl_image_delete(img); img = NULL;
-
-    // rotate 45degrees CCW (interpolation) with extrapolate=1
-    // (image won't grow, flux conservation can be tested)
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-
-    test_rotate(file_path,
-                 "--ifu=1 --rot=\"45.0\" --imethod=\"BCS\" --flux=true "
-                 "--extra=TRUE",
-                 0);
-
-    cpl_test_abs(kmo_test_esorex_data("rotate", 0), 16.439, tol);
-    // test for correctness of flux conservation
-    kmo_test_cat_strings(orig_file_path, test_path, "pyramid_orig");
-    cpl_test_abs(kmo_test_esorex_data(orig_file_path, 0),
-                 kmo_test_esorex_data("rotate", 0)-2.68392, tol);
-    strcpy(out_path, "rotate.fits");
-
-    check_headers(h_orig, out_path, 1,
-                  14, 14, 7.5, 7.5,
-                  -3.928371e-5, -3.928371e-5, cpl_propertylist_get_double(h_orig, CD1_3),
-                  -3.928371e-5, 3.928371e-5, cpl_propertylist_get_double(h_orig, CD2_3),
-                  tol/1000);
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 1);
-    cpl_test_abs(cpl_image_get(img, 9, 3, &tmp_int), 23.2852, tol);
-    cpl_image_delete(img); img = NULL;
-
-    // rotate 10 degrees CW (interpolation) with extrapolate=1 (in order to
-    // get a result from kmo_test_esorex_data())
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-
-    test_rotate(file_path,
-                 "--ifu=1 --rot=\"-10.0\" --imethod=\"BCS\" --flux=true "
-                 "--extra=FALSE",
-                 0);
-
-    cpl_test_abs(kmo_test_esorex_data("rotate", 0), 15.238, tol);
-
-    // check data
-    strcpy(out_path, "rotate.fits");
-    check_headers(h_orig, out_path, 1,
-                  16, 16, 8.5, 8.5,
-                  -5.47115e-05, 9.64712e-06, cpl_propertylist_get_double(h_orig, CD1_3),
-                  9.64712e-06, 5.47115e-05, cpl_propertylist_get_double(h_orig, CD2_3),
-                  tol/1000);
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 1);
-    cpl_test_abs(cpl_image_get(img, 4, 4, &tmp_int), 19.6199, tol);
-    cpl_image_delete(img); img = NULL;
-
-    // check noise
-    check_headers(h_orig, out_path, 1,
-                  16, 16, 8.5, 8.5,
-                  -5.47115e-05, 9.64712e-06, cpl_propertylist_get_double(h_orig, CD1_3),
-                  9.64712e-06, 5.47115e-05, cpl_propertylist_get_double(h_orig, CD2_3),
-                  tol/1000);
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 2);
-    cpl_test_abs(cpl_image_get(img, 4, 4, &tmp_int), 1.8936, tol/10);
-    cpl_image_delete(img); img = NULL;
-
-    /* ----- invalid data ----- */
-
-    cpl_propertylist_delete(h_orig); h_orig = NULL;
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_sci_red-test.c b/recipes/tests/kmo_sci_red-test.c
deleted file mode 100644
index 3a8fd0e..0000000
--- a/recipes/tests/kmo_sci_red-test.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* $Id: kmo_sci_red-test.c,v 1.15 2013-10-08 11:18:57 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:57 $
- * $Revision: 1.15 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-#include <math.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe       = "kmo_sci_red/";
-
-const char      *valid_files[]     = {"science_obj_123.fits",
-                                      "science_sky_123.fits",
-                                      "kmos_wave_band.fits"};
-
-/**
-    @defgroup kmo_sci_red_test  kmo_sci_red_test unit tests
-
-    @{
-*/
-
-/**
-  @brief   test
- */
-static void test_sci_red(const char *path1, const char *path2, int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_sci_red.sof";
-    FILE *fh = fopen(sof_path, "w");
-    char *my_path = cpl_sprintf("%s/ref_data/%s", getenv("srcdir"), valid_files[2]);
-    fprintf (fh,
-             "%s                          SCIENCE\n"
-             "%s                          SCIENCE\n"
-             "xcal_KKK.fits               XCAL\n"
-             "ycal_KKK.fits               YCAL\n"
-             "lcal_KKK.fits               LCAL\n"
-             "master_flat_KKK.fits        MASTER_FLAT\n"
-             "illum_corr_KKK.fits         ILLUM_CORR\n"
-             "telluric_KKK.fits           TELLURIC\n"
-             "%s WAVE_BAND\n",
-             path1, path2, my_path);
-    fclose(fh);
-    cpl_free(my_path);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_sci_red --b_start=1.948 "
-            "--b_end=2.351 %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_sci_red.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-  @brief    Test of kmo_sci_red recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_sci_red-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_sci_red-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.1;
-
-    char    test_path[256],
-            file_path[256],
-            op_file1[256],
-            op_file2[256];
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    // get rid of warning...
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) {
-    }
-
-    FILE *fd = fopen("log_kmo_sci_red.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    //
-    //  PIPELINE TEST (must be called after kmo_illumination-test, since the
-    //  following recipes rely on this output)
-    //
-    cpl_msg_info(cpl_func, "Testing kmo_sci_red with real pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    kmo_test_cat_strings(op_file1, test_path, valid_files[0]);
-    kmo_test_cat_strings(op_file2, test_path, valid_files[1]);
-    test_sci_red(op_file1, op_file2, 0);
-
-    strcpy(file_path, "sci_reconstructed_science_obj_123");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 1.44976e+08, tol*1.6e9);
-    strcpy(file_path, "sci_combined_AAA__telluric_illum");
-    if (fabs(kmo_test_esorex_data(file_path, 1) - 256.167) < tol*1e4) {
-        // Linux
-        cpl_test_abs(kmo_test_esorex_data(file_path, 1), 256.167, tol*1e4);
-    } else {
-        // Mac
-        cpl_test_abs(kmo_test_esorex_data(file_path, 1), 12200.1, tol*1e4);
-    }
-    strcpy(file_path, "sci_combined_BBB__telluric_illum");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 24788.7, tol*1e8);
-    strcpy(file_path, "sci_combined_CCC__telluric_illum");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 33555.5, tol*1e8);
-    strcpy(file_path, "sci_combined_DDD__telluric_illum");
-    if (fabs(kmo_test_esorex_data(file_path, 1) - 511.939) < tol*1e4) {
-        // Linux
-        cpl_test_abs(kmo_test_esorex_data(file_path, 1), 511.939, tol*1e4);
-    } else {
-        // Mac
-        cpl_test_abs(kmo_test_esorex_data(file_path, 1), 41467.9, tol*1e4);
-    }
-    strcpy(file_path, "sci_combined_FDF_070__telluric_illum");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 24788.7, tol*1e8);
-    strcpy(file_path, "sci_combined_FDF_086__telluric_illum");
-    if (fabs(kmo_test_esorex_data(file_path, 1) - 255.589) < tol*1e4) {
-        // Linux
-        cpl_test_abs(kmo_test_esorex_data(file_path, 1), 255.589, tol*1e4);
-    } else {
-        // Mac
-        cpl_test_abs(kmo_test_esorex_data(file_path, 1), 122365, tol*1e4);
-    }
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_shift-test.c b/recipes/tests/kmo_shift-test.c
deleted file mode 100644
index c14b421..0000000
--- a/recipes/tests/kmo_shift-test.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/* $Id: kmo_shift-test.c,v 1.7 2013-10-08 11:18:57 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:57 $
- * $Revision: 1.7 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-#include "kmclipm_constants.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe       = "kmo_shift/";
-
-const char      *valid_files[]     = {"pyramid_orig.fits",
-                                      "pyramid_orig_noise.fits"};
-
-/**
-    @defgroup kmo_shift_test  kmo_shift_test unit tests
-
-    @{
-*/
-
-/**
-  @brief   test
- */
-static void
-test_shift(const char *sof_path,
-             const char *pars,
-             int ret_val)
-{
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_shift %s %s", pars, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_shift.txt", NULL, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-
-}
-
-/**
-    @brief
-        Generates test data for kmo_shift.
-
-    @param path      Path where the generated test data should be saved to.
-*/
-static int kmo_generate_test_data_shift(const char *path)
-{
-    int         i                   = 0;
-
-    char        file_path[256],
-                file_path_noise[256],
-                file_ref[256],
-                name1[256],
-                name2[256],
-                cmd[256];
-
-    char *test_global_path_ref_data = cpl_sprintf("%s/ref_data/", getenv("srcdir"));
-    kmo_test_cat_strings(file_ref, test_global_path_ref_data, "ref_cube_arc.fits");
-
-    cpl_imagelist       *cube_in = kmclipm_imagelist_load(file_ref,
-                                                      CPL_TYPE_FLOAT, 1),
-                        *cube_out = NULL;
-    cpl_propertylist    *pl;
-    cpl_image           *img;
-    int                 ix = 0,
-                        iy = 0;
-
-    float               *p = NULL;
-
-    strcpy(name1, IFU_NAME_PREFIX);
-    strcat(name1, "1");
-    strcat(name1, IFU_NAME_POSTFIX);
-
-    strcpy(name2, IFU_NAME_PREFIX);
-    strcat(name2, "2");
-    strcat(name2, IFU_NAME_POSTFIX);
-
-    /* ----- valid test data ----- */
-    //
-    // create pyramid_orig.fits (center at (5,3), object in IFU1)
-    //
-    kmo_test_cat_strings(file_path, path, valid_files[0]);
-    pl = kmclipm_propertylist_load(file_ref, 0);
-    cpl_propertylist_save(pl, file_path, CPL_IO_DEFAULT);
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    float o14[14] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9};
-    float o13[14] = {10,10,10,10,10,10,10,10,10,10,10,10,10,10};
-    float o12[14] = {11,11,11,11,11,11,11,11,11,11,11,11,11,11};
-    float o11[14] = {12,12,12,12,12,12,12,12,12,12,12,12,12,11};
-    float o10[14] = {13,13,13,13,13,13,13,13,13,13,13,13,12,11};
-    float  o9[14] = {14,14,14,14,14,14,14,14,14,14,14,13,12,11};
-    float  o8[14] = {15,15,15,15,15,15,15,15,15,15,14,13,12,11};
-    float  o7[14] = {16,16,16,16,16,16,16,16,16,15,14,13,12,11};
-    float  o6[14] = {16,17,17,17,17,17,17,17,16,15,14,13,12,11};
-    float  o5[14] = {16,17,18,18,18,18,18,17,16,15,14,13,12,11};
-    float  o4[14] = {16,17,18,19,19,19,18,17,16,15,14,13,12,11};
-    float  o3[14] = {16,17,18,19,20,19,18,17,16,15,14,13,12,11};
-    float  o2[14] = {16,17,18,19,19,19,18,17,16,15,14,13,12,11};
-    float  o1[14] = {16,17,18,18,18,18,18,17,16,15,14,13,12,11};
-
-    cube_out = cpl_imagelist_new();
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o1[ix];
-        iy =  1; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o2[ix];
-        iy =  2; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o3[ix];
-        iy =  3; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o4[ix];
-        iy =  4; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o5[ix];
-        iy =  5; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o6[ix];
-        iy =  6; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o7[ix];
-        iy =  7; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o8[ix];
-        iy =  8; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o9[ix];
-        iy =  9; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o10[ix];
-        iy = 10; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o11[ix];
-        iy = 11; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o12[ix];
-        iy = 12; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o13[ix];
-        iy = 13; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = o14[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    pl = kmclipm_propertylist_load(file_ref, 1);
-    cpl_propertylist_update_string(pl, name1, "XXX");
-    cpl_propertylist_erase (pl, name2);
-    cpl_imagelist_save(cube_out, file_path, CPL_BPP_IEEE_FLOAT, pl, CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-
-    // adding noise
-    kmo_test_cat_strings(file_path_noise, path, valid_files[1]);
-    strcpy(cmd, "cp ");
-    strcat(cmd, file_path);
-    strcat(cmd, " ");
-    strcat(cmd, file_path_noise);
-    system(cmd);
-
-    float n14[14] = { .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9, .9};
-    float n13[14] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
-    float n12[14] = {1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1,1.1};
-    float n11[14] = {1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.1};
-    float n10[14] = {1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.3,1.2,1.1};
-    float  n9[14] = {1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.3,1.2,1.1};
-    float  n8[14] = {1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.4,1.3,1.2,1.1};
-    float  n7[14] = {1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n6[14] = {1.6,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n5[14] = {1.6,1.7,1.8,1.8,1.8,1.8,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n4[14] = {1.6,1.7,1.8,1.9,1.9,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n3[14] = {1.6,1.7,1.8,1.9,2.0,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n2[14] = {1.6,1.7,1.8,1.9,1.9,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-    float  n1[14] = {1.6,1.7,1.8,1.8,1.8,1.8,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1};
-
-    cube_out = cpl_imagelist_new();
-    for (i = 0; i < cpl_imagelist_get_size(cube_in); i++) {
-        img = cpl_image_new(14, 14, CPL_TYPE_FLOAT);
-        p = cpl_image_get_data_float(img);
-        iy =  0; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n1[ix];
-        iy =  1; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n2[ix];
-        iy =  2; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n3[ix];
-        iy =  3; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n4[ix];
-        iy =  4; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n5[ix];
-        iy =  5; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n6[ix];
-        iy =  6; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n7[ix];
-        iy =  7; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n8[ix];
-        iy =  8; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n9[ix];
-        iy =  9; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n10[ix];
-        iy = 10; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n11[ix];
-        iy = 11; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n12[ix];
-        iy = 12; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n13[ix];
-        iy = 13; for (ix = 0; ix < 14; ix++) p[ix+iy*14] = n14[ix];
-        cpl_imagelist_set(cube_out, img, i);
-    }
-
-    cpl_propertylist_update_string(pl, EXTNAME, "IFU.1.NOISE");
-    cpl_imagelist_save(cube_out, file_path_noise, CPL_BPP_IEEE_FLOAT, pl,
-                       CPL_IO_EXTEND);
-    cpl_imagelist_delete(cube_in); cube_in = NULL;
-    cpl_imagelist_delete(cube_out); cube_out = NULL;
-
-    cpl_propertylist_delete(pl); pl = NULL;
-
-    cpl_free(test_global_path_ref_data);
-
-    return 0;
-}
-
-void check_headers(const char *orig_path, const char *out_path, int ext,
-                   double crpix1, double crpix2, int nax1, int nax2,
-                   double tol)
-{
-    cpl_propertylist *h_orig = kmclipm_propertylist_load(orig_path, 1);
-    cpl_propertylist *h = kmclipm_propertylist_load(out_path, ext);
-
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX1), crpix1, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX2), crpix2, tol);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS1), nax1);
-    cpl_test_eq(cpl_propertylist_get_int(h, NAXIS2), nax2);
-
-    cpl_test_abs(cpl_propertylist_get_double(h, CRVAL1),
-                 cpl_propertylist_get_double(h_orig, CRVAL1), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRVAL2),
-                 cpl_propertylist_get_double(h_orig, CRVAL2), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRVAL3),
-                 cpl_propertylist_get_double(h_orig, CRVAL3), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CDELT1),
-                 cpl_propertylist_get_double(h_orig, CDELT1), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CDELT2),
-                 cpl_propertylist_get_double(h_orig, CDELT2), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CDELT3),
-                 cpl_propertylist_get_double(h_orig, CDELT3), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CRPIX3),
-                 cpl_propertylist_get_double(h_orig, CRPIX3), tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD1_1),
-                 cpl_propertylist_get_double(h_orig, CD1_1), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD1_2),
-                 cpl_propertylist_get_double(h_orig, CD1_2), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD1_3),
-                 cpl_propertylist_get_double(h_orig, CD1_3), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD2_1),
-                 cpl_propertylist_get_double(h_orig, CD2_1), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD2_2),
-                 cpl_propertylist_get_double(h_orig, CD2_2), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD2_3),
-                 cpl_propertylist_get_double(h_orig, CD2_3), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD3_1),
-                 cpl_propertylist_get_double(h_orig, CD3_1), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD3_2),
-                 cpl_propertylist_get_double(h_orig, CD3_2), tol/1000);
-    cpl_test_abs(cpl_propertylist_get_double(h, CD3_3),
-                 cpl_propertylist_get_double(h_orig, CD3_3), tol/1000);
-    cpl_propertylist_delete(h); h = NULL;
-    cpl_propertylist_delete(h_orig); h_orig = NULL;
-}
-
-/**
-  @brief    Test of kmo_shift recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_shift-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_shift-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            orig_file_path[256],
-            out_path[256];
-
-    cpl_image *img = NULL;
-
-    int tmp_int;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_shift(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_shift.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-
-    //
-    // whole pixel shift of IFU#1, one pix left, one pix up
-    //
-    kmo_test_cat_strings(file_path, test_path, valid_files[0]);
-
-    test_shift(file_path,
-                 "--ifu=1 --shifts=\"0.2,0.2\" --imethod=\"NN\" --flux=true"
-                 " --wcs-only=true",
-                 0);
-
-    // check output
-    strcpy(out_path, "shift");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 13.7551, tol);
-    // test for correctness of flux conservation
-    kmo_test_cat_strings(orig_file_path, test_path, "pyramid_orig");
-    cpl_test_abs(kmo_test_esorex_data(orig_file_path, 0),
-                 kmo_test_esorex_data(out_path, 0), tol);
-    strcat(out_path, ".fits");
-    check_headers(file_path, out_path, 1, 5.5, 9.5, 14, 14, tol);
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 1);
-    cpl_test_abs(cpl_image_get(img, 5, 3, &tmp_int), 20.0, tol);
-    cpl_image_delete(img); img = NULL;
-
-    //
-    // sub pixel shift of IFU#1, 1.5 pix right, 1.5 pix down
-    //
-    test_shift(file_path,
-                 "--ifu=1 --shifts=\"-0.3,-0.3\" --imethod=\"BCS\" "
-                 "--flux=false --extrapolate=true",
-                 0);
-
-    // check output
-    strcpy(out_path, "shift");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 13.5845, tol);
-    strcat(out_path, ".fits");
-    check_headers(file_path, out_path, 1, 10.5, 4.5, 14, 14, tol);
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 1);
-    cpl_test_abs(cpl_image_get(img, 5, 3, &tmp_int), 18.4395, tol);
-    cpl_image_delete(img); img = NULL;
-
-    //
-    // sub pixel shift with noise of IFU#1, 1.2 pix left, 1.2 pix down
-    //
-    kmo_test_cat_strings(file_path, test_path, valid_files[1]);
-
-    test_shift(file_path,
-                 "--ifu=1 --shifts=\"-0.222,-0.222\" --imethod=\"BCS\" "
-                 "--flux=false --extrapolate=true",
-                 0);
-    
-    // check output data
-    strcpy(out_path, "shift");
-    cpl_test_abs(kmo_test_esorex_data(out_path, 0), 15.1473, tol);
-    strcat(out_path, ".fits");
-    check_headers(file_path, out_path, 1, 9.72, 5.28, 14, 14, tol);
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 1);
-    cpl_test_abs(cpl_image_get(img, 5, 3, &tmp_int), 18.8881, tol);
-    cpl_image_delete(img); img = NULL;
-
-    // check output noise
-    check_headers(file_path, out_path, 2, 9.72, 5.28, 14, 14, tol);
-
-    img = kmclipm_image_load(out_path, CPL_TYPE_FLOAT, 0, 2);
-    cpl_test_abs(cpl_image_get(img, 5, 3, &tmp_int), 1.88881, tol);
-    cpl_image_delete(img); img = NULL;
-
-    /* ----- invalid data ----- */
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_sky_mask-test.c b/recipes/tests/kmo_sky_mask-test.c
deleted file mode 100644
index 8521392..0000000
--- a/recipes/tests/kmo_sky_mask-test.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/* $Id: kmo_sky_mask-test.c,v 1.5 2013-10-08 11:18:57 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:57 $
- * $Revision: 1.5 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-double          scalar              = 6.7;
-int             ifu_nr              = 4;
-
-const char      *path_recipe        = "kmo_sky_mask/";
-
-const char      *valid_files[]      = {"v_data_F3I_all.fits",
-                                       "v_data_noise_F3I_all.fits",
-                                       "v_data_F3I_all_infinite.fits",
-                                       "v_data_F3I_all_no_keywords.fits"};
-
-const char      *invalid_files[]    = {"i_data_F2I.fits"};
-
-/**
-    @defgroup kmo_sky_mask_test   kmo_sky_mask unit tests
-
-    @{
-*/
-
-/**
- * @brief   test with two frames
- */
-static void test_sky_mask(const char *path_op1, int range, int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_sky_mask.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s   DATA\n", path_op1);
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_sky_mask ");
-    if (range == 1) {
-        strcat(esorex_command, " -range=\"0.8,0.9\" ");
-    }
-    strcat(esorex_command, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_sky_mask.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_stats.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_stats(const char *path)
-{
-    char        file_path[256];
-    char        *sub_keys[3];
-    char        *sub_vals[3];
-    int         sub_types[3];
-
-    sub_keys[0] = "CRPIX3";
-    sub_vals[0] = "1";
-    sub_types[0] = CPL_TYPE_DOUBLE;
-
-    sub_keys[1] = "CRVAL3";
-    sub_vals[1] = "0.8";
-    sub_types[1] = CPL_TYPE_DOUBLE;
-
-    sub_keys[2] = "CDELT3";
-    sub_vals[2] = "0.001";
-    sub_types[2] = CPL_TYPE_DOUBLE;
-    /* ----- valid test data ----- */
-    // F3I
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                        test_global_size_z, TRUE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[0]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, 3));
-
-    cpl_test_eq(0,
-               kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y,
-                        test_global_size_z, TRUE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[1]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, 3));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_infinite(test_global_size_x, test_global_size_y,
-                        test_global_size_z, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[2]),
-                        NULL, NULL, NULL, 0,
-                        sub_keys, sub_vals, sub_types, 3));
-
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                        test_global_size_z, TRUE, test_global_nr_frames,
-                        kmo_test_cat_strings(file_path, path, valid_files[3]),
-                        NULL, NULL, NULL, 0,
-                        NULL, NULL, NULL, 0));
-
-    /* ----- invalid test data ----- */
-    // F2I instead of F3I
-    cpl_test_eq(0,
-                kmo_test_create_F2I_data(test_global_size_x, test_global_size_y, FALSE, 1,
-                          kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                          NULL, NULL, NULL, 0,
-                          sub_keys, sub_vals, sub_types, 3));
-
-    return 0;
-}
-
-
-/**
-  @brief	Test of kmo_stats recipe.
-  @param	argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_stats-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_stats-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            op1_file[256];
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_stats(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_sky_mask.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-    // F3I all finite
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    test_sky_mask(op1_file, 0, 0);
-    cpl_test_abs(kmo_test_esorex_data(SKY_MASK, 0), 0.1, tol);
-
-    // F3I all finite with range
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    test_sky_mask(op1_file, 1, 0);
-    cpl_test_abs(kmo_test_esorex_data(SKY_MASK, 0), 0.1, tol);
-
-    // F3I with noise all finite (should give same result)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    test_sky_mask(op1_file, 0, 0);
-    cpl_test_abs(kmo_test_esorex_data(SKY_MASK, 0), 0.1, tol);
-
-    // F3I with infinite
-    kmo_test_cat_strings(op1_file, test_path, valid_files[2]);
-    test_sky_mask(op1_file, 0, 0);
-    cpl_test_abs(kmo_test_esorex_data(SKY_MASK, 0), 0.0333333, tol);
-
-    // F3I without keywords  and without range
-    kmo_test_cat_strings(op1_file, test_path, valid_files[3]);
-    test_sky_mask(op1_file, 0, 0);
-    cpl_test_abs(kmo_test_esorex_data(SKY_MASK, 0), 0.1, tol);
-
-    /* ----- invalid tests ----- */
-    // F2I
-    kmo_test_cat_strings(op1_file, test_path, invalid_files[0]);
-    test_sky_mask(op1_file, 0, -1);
-
-    // F3I without keywords and with range
-    kmo_test_cat_strings(op1_file, test_path, valid_files[3]);
-    test_sky_mask(op1_file, 1, -1);
-
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_stats-test.c b/recipes/tests/kmo_stats-test.c
deleted file mode 100644
index 9a73336..0000000
--- a/recipes/tests/kmo_stats-test.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/* $Id: kmo_stats-test.c,v 1.9 2013-10-08 11:18:57 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:57 $
- * $Revision: 1.9 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-
-#include <cpl.h>
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-double          scalar              = 6.7;
-int             ifu_nr              = 4;
-
-const char      *path_recipe        = "kmo_stats/";
-
-const char      *valid_files[]      = {"v_data_F3I_all.fits",
-                                       "v_data_noise_F3I_all.fits",
-                                       "v_data_F3I_all_infinite.fits",
-                                       "v_mask_F2I.fits",
-                                       "v_data_F2I.fits",
-                                       "v_data_F1I.fits",
-                                       "v_data_RAW.fits",
-                                       "v_mask_F2D_large.fits",
-                                       "v_data_F2D.fits",
-                                       "v_data_B2D.fits",
-                                       "v_data_noise_F2D.fits",
-                                       "v_data_noise_F2I.fits",
-                                       "v_data_noise_F1I.fits",
-                                       "v_mask_F2I_single.fits",
-                                       "v_mask_F2D_single.fits"};
-
-const char      *invalid_files[]    = {"i_mask.fits"};
-
-/**
-    @defgroup kmo_stats_test   kmo_stats unit tests
-
-    @{
-*/
-
-/**
- * @brief   test with two frames
- */
-static void test_stats(const char *path_op1,
-                       double pos_thres, double neg_thres,
-                       int ret_val, int mask, const char *path_op2)
-{
-    // create sof-file
-    const char *sof_path = "test_stats.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s\n", path_op1);
-    if (mask == TRUE) {
-        fprintf (fh, "%s\n", path_op2);
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[512];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_stats --cpos_rej=%g  --cneg_rej=%g %s",
-            pos_thres, neg_thres, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_stats.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-static void test_stats2(const char *path_op1,
-                       double pos_thres, double neg_thres,
-                       int ret_val, int mask, const char *path_op2, int ext)
-{
-    // create sof-file
-    const char *sof_path = "test_stats2.sof";
-    FILE *fh = fopen(sof_path, "w");
-    fprintf (fh, "%s\n", path_op1);
-    if (mask == TRUE) {
-        fprintf (fh, "%s\n", path_op2);
-    }
-    fclose(fh);
-
-    // create esorex-command
-    char esorex_command[512];
-
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_stats --cpos_rej=%g --cneg_rej=%g --ext=%d %s",
-            pos_thres, neg_thres, ext, sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_stats.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-    @brief
-        Generates test data for kmo_stats.
-
-    @param path Path where the generated test date should be saved to.
-*/
-static int kmo_generate_test_data_stats(const char *path)
-{
-    char        file_path[256];
-
-    /* ----- valid test data ----- */
-    // F3I
-    cpl_test_eq(0,
-                kmo_test_create_F3I_data(test_global_size_x, test_global_size_y,
-                          test_global_size_z, FALSE, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[0]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // F3I with noise
-    cpl_test_eq(0,
-               kmo_test_create_F3I_data_noise(test_global_size_x, test_global_size_y,
-                          test_global_size_z, FALSE, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[1]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // F3I with infinite
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_infinite(test_global_size_x, test_global_size_y,
-                          test_global_size_z, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[2]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-            kmo_test_create_F3I_data_infinite(test_global_size_x, test_global_size_y,
-                          test_global_size_z, test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[2]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // mask
-    cpl_test_eq(0,
-            kmo_test_create_F2I_data(test_global_size_x, test_global_size_y, TRUE,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[3]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    cpl_test_eq(0,
-            kmo_test_create_F2D_data(test_global_size_x, test_global_size_y, TRUE,
-                          kmo_test_cat_strings(file_path, path, valid_files[7]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // mask, single extension
-    cpl_test_eq(0,
-            kmo_test_create_F2I_data(test_global_size_x, test_global_size_y, TRUE,
-                          1,
-                          kmo_test_cat_strings(file_path, path, valid_files[13]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // F2I
-    cpl_test_eq(0,
-                kmo_test_create_F2I_data(test_global_size_x, test_global_size_y, FALSE,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[4]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // F1I
-    cpl_test_eq(0,
-                kmo_test_create_F1I_data(test_global_size_x,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[5]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // RAW
-    cpl_test_eq(0,
-                kmo_test_create_RAW_data(test_global_size_x, test_global_size_y,
-                          kmo_test_cat_strings(file_path, path, valid_files[6]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0,
-                          1.0, 0.1));
-
-    // F2D
-    cpl_test_eq(0,
-                kmo_test_create_F2D_data(test_global_size_x, test_global_size_y, FALSE,
-                          kmo_test_cat_strings(file_path, path, valid_files[8]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // B2D
-    cpl_test_eq(0,
-                kmo_test_create_B2D_data(test_global_size_x, test_global_size_y, TRUE,
-                          kmo_test_cat_strings(file_path, path, valid_files[9]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // F2D with noise
-    cpl_test_eq(0,
-               kmo_test_create_F2D_data_noise(test_global_size_x, test_global_size_y,
-                          kmo_test_cat_strings(file_path, path, valid_files[10]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // F2I with noise
-    cpl_test_eq(0,
-                kmo_test_create_F2I_data_noise(test_global_size_x, test_global_size_y,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[11]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    // F1I with noise
-    cpl_test_eq(0,
-                kmo_test_create_F1I_data_noise(test_global_size_x,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, valid_files[12]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    /* ----- invalid test data ----- */
-    // to small mask
-    cpl_test_eq(0,
-            kmo_test_create_F2I_data(test_global_size_x, test_global_size_y-1, TRUE,
-                          test_global_nr_frames,
-                          kmo_test_cat_strings(file_path, path, invalid_files[0]),
-                          NULL, NULL, NULL, 0,
-                          NULL, NULL, NULL, 0));
-
-    return 0;
-}
-
-
-/**
-  @brief	Test of kmo_stats recipe.
-  @param	argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_stats-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_stats-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-FALSE
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            op1_file[256],
-            op2_file[256];
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    if ((argc == 1) || ((argc > 1) && (strcmp(argv[1], "--no-gen") != 0))) {
-        cpl_test_zero(kmo_generate_test_data_stats(test_path));
-    }
-
-    if ((argc > 1) && (strcmp(argv[1], "--generate") == 0)) {
-        // just generate the data
-        return cpl_test_end(0);
-    }
-
-    /* ----- run the tests ----- */
-    FILE *fd = fopen("log_kmo_stats.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    /* ----- valid tests ----- */
-
-    //
-    // w/o mask, w/o noise
-    //
-
-    // F3I all finite
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 167.798, tol);
-
-    // F3I with infinite
-    kmo_test_cat_strings(op1_file, test_path, valid_files[2]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 167.353, tol);
-
-    // F3I all finite, with rejection
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    test_stats(op1_file, 1.0, 1.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 165.66, tol);
-
-    // F2I
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 51.9522, tol);
-
-    // F1I
-    kmo_test_cat_strings(op1_file, test_path, valid_files[5]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 10.3756, tol);
-
-    // RAW
-    kmo_test_cat_strings(op1_file, test_path, valid_files[6]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 49.0105, tol);
-
-    // F2D
-    kmo_test_cat_strings(op1_file, test_path, valid_files[8]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 51.9522, tol);
-
-    // B2D
-    kmo_test_cat_strings(op1_file, test_path, valid_files[9]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 17.1263, tol);
-
-    //
-    // w/o mask, with noise
-    //
-
-    // F3I
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 303.162, tol);
-
-    // F2I
-    kmo_test_cat_strings(op1_file, test_path, valid_files[11]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 73.0388, tol);
-
-    // F1I
-    kmo_test_cat_strings(op1_file, test_path, valid_files[12]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 16.2775, tol);
-
-    // F2D
-    kmo_test_cat_strings(op1_file, test_path, valid_files[10]);
-    test_stats(op1_file, 3.0, 3.0, 0, FALSE, NULL);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 73.0388, tol);
-
-    //
-    // with mask, w/o noise
-    //
-
-    // F3I all finite with mask
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 94.7123, tol);
-
-    // F2I with mask
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 39.3168, tol);
-
-    // RAW with mask (F2D), specific extension
-    kmo_test_cat_strings(op1_file, test_path, valid_files[6]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[7]);
-    test_stats2(op1_file, 3.0, 3.0, 0, TRUE, op2_file, 1);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 11.6712, tol);
-
-    // F2D with mask (F2D)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[8]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[7]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 39.3168, tol);
-
-    // B2D with mask (F2D)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[9]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[7]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 7.90909, tol);
-
-    // RAW with mask (B2D), specific extension
-    kmo_test_cat_strings(op1_file, test_path, valid_files[6]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[9]);
-    test_stats2(op1_file, 3.0, 3.0, 0, TRUE, op2_file, 1);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 11.6712, tol);
-
-    // F2D with mask (B2D)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[8]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[9]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 39.3168, tol);
-
-    // B2D with mask (B2D)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[9]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[9]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 7.90909, tol);
-
-    // F2I with mask (single extension in mask)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[4]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[13]);
-    test_stats2(op1_file, 3.0, 3.0, 0, TRUE, op2_file, 2);
-
-    // no output created, since ext=2 is empty
-    test_stats2(op1_file, 3.0, 3.0, 0, TRUE, op2_file, 3);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 13.1056, tol);
-
-    //
-    // with mask, with noise
-    //
-    // F3I
-    kmo_test_cat_strings(op1_file, test_path, valid_files[1]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 230.077, tol);
-
-    // F2I
-    kmo_test_cat_strings(op1_file, test_path, valid_files[11]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 60.4033, tol);
-
-    // F2D
-    kmo_test_cat_strings(op1_file, test_path, valid_files[10]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[9]);
-    test_stats(op1_file, 3.0, 3.0, 0, TRUE, op2_file);
-    cpl_test_abs(kmo_test_esorex_data(STATS, 0), 60.4033, tol);
-
-    /* ----- invalid tests ----- */
-    // F1I with mask
-    kmo_test_cat_strings(op1_file, test_path, valid_files[5]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[5]);
-    test_stats(op1_file, 3.0, 3.0, -1, TRUE, op2_file);
-
-    // F1I with mask with noise
-    kmo_test_cat_strings(op1_file, test_path, valid_files[12]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[5]);
-    test_stats(op1_file, 3.0, 3.0, -1, TRUE, op2_file);
-
-    // RAW with mask (F2I)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[6]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-    test_stats(op1_file, 3.0, 3.0, -1, TRUE, op2_file);
-
-    // F2D with mask (RAW)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[8]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[6]);
-    test_stats(op1_file, 3.0, 3.0, -1, TRUE, op2_file);
-
-    // F2D with mask (F2I)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[8]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-    test_stats(op1_file, 3.0, 3.0, -1, TRUE, op2_file);
-
-    // B2D with mask (F2I)
-    kmo_test_cat_strings(op1_file, test_path, valid_files[9]);
-    kmo_test_cat_strings(op2_file, test_path, valid_files[3]);
-    test_stats(op1_file, 3.0, 3.0, -1, TRUE, op2_file);
-
-    // F3I all finite with too small mask
-    kmo_test_cat_strings(op1_file, test_path, valid_files[0]);
-    kmo_test_cat_strings(op2_file, test_path, invalid_files[0]);
-    test_stats(op1_file, 3.0, 3.0, -1, TRUE, op2_file);
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_std_star-test.c b/recipes/tests/kmo_std_star-test.c
deleted file mode 100644
index b403fe3..0000000
--- a/recipes/tests/kmo_std_star-test.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/* $Id: kmo_std_star-test.c,v 1.28 2013-10-21 13:44:55 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-21 13:44:55 $
- * $Revision: 1.28 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-#include <math.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe       = "kmo_std_star/";
-
-const char      *valid_files[]     = {"std_obj_123.fits",
-                                      "std_sky_123.fits",
-                                      "kmos_solar_k_1700.fits",
-                                      "kmos_atmos_k.fits",
-                                      "kmos_spec_type.fits",
-                                      "kmos_wave_band.fits"};
-
-/**
-    @defgroup kmo_std_star_test  kmo_std_star_test unit tests
-
-    @{
-*/
-
-/**
-  @brief   test
- */
-static void test_std_star(const char *star_path, const char *sky_path,
-                          const char *solar_path, const char *atmos_path,
-                          const char *spec_path, int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_std_star.sof";
-    FILE *fh = fopen(sof_path, "w");
-    char *my_path = cpl_sprintf("%s/ref_data", getenv("srcdir"));
-    fprintf (fh,
-             "%s                          STD\n"
-             "%s                          STD\n"
-             "xcal_KKK.fits               XCAL\n"
-             "ycal_KKK.fits               YCAL\n"
-             "lcal_KKK.fits               LCAL\n"
-             "master_flat_KKK.fits        MASTER_FLAT\n"
-             "illum_corr_KKK.fits         ILLUM_CORR\n"
-             "%s/%s             WAVE_BAND\n",
-             star_path, sky_path, my_path, valid_files[5]);
-    if (solar_path != NULL) {
-        fprintf(fh,
-                "%s/%s              SOLAR_SPEC\n", my_path, solar_path);
-    }
-    if (atmos_path != NULL) {
-        fprintf(fh,
-                "%s/%s              ATMOS_MODEL\n", my_path, atmos_path);
-    }
-    if (spec_path != NULL) {
-        fprintf(fh,
-                "%s/%s              SPEC_TYPE_LOOKUP\n", my_path, spec_path);
-    }
-    fclose(fh);
-    cpl_free(my_path);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_std_star  --startype=\"A0I\" "
-            "--imethod=NN --magnitude=8 --b_start=1.948 --b_end=2.351 %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_std_star.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-  @brief    Test of kmo_std_star recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_std_star-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_std_star-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            op_file1[256],
-            op_file2[256],
-            op_file3[256],
-            op_file4[256],
-            op_file5[256];
-
-    cpl_propertylist *h = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    // get rid of warning...
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) {
-    }
-
-    FILE *fd = fopen("log_kmo_std_star.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    //
-    //  PIPELINE TEST (must be called after kmo_illumination-test, since the
-    //  following recipes rely on this output)
-    //
-    cpl_msg_info(cpl_func, "Testing kmo_std_star with real pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    kmo_test_cat_strings(op_file1, test_path, valid_files[0]);
-    kmo_test_cat_strings(op_file2, test_path, valid_files[1]);
-    strcpy(op_file3, valid_files[2]);
-    strcpy(op_file4, valid_files[3]);
-    strcpy(op_file5, valid_files[4]);
-    test_std_star(op_file1, op_file2, op_file3, op_file4, op_file5, 0);
-
-    // check std_image_KKK.fits
-    strcpy(file_path, "std_image_KKK");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 10943.4, tol*10500);
-    strcat(file_path, ".fits");
-
-    h = kmclipm_propertylist_load(file_path, 0);
-    cpl_test_eq(cpl_propertylist_get_int(h, QC_NR_STD_STARS), 6);
-    cpl_test_eq(cpl_propertylist_has(h, QC_STD_TRACE), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_SDV), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_MEAN), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_SPAT_RES), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_ZEROPOINT), 0);
-
-    cpl_propertylist_delete(h); h = NULL;
-
-    h = kmclipm_propertylist_load(file_path, 2);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_SPAT_RES), 0.544499, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_STD_TRACE), 0.906642, tol);
-    cpl_test_eq(cpl_propertylist_has(h, QC_NR_STD_STARS), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_SDV), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_MEAN), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_ZEROPOINT), 0);
-
-    cpl_propertylist_delete(h); h = NULL;
-
-    // check telluric_KKK.fits
-    strcpy(file_path, "telluric_KKK");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 5.61881, .3);
-    strcat(file_path, ".fits");
-
-    h = kmclipm_propertylist_load(file_path, 0);
-    cpl_test_eq(cpl_propertylist_get_int(h, QC_NR_STD_STARS), 6);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_THROUGHPUT_MEAN), 0.0228217, tol*2);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_THROUGHPUT_SDV), 0.00958603, tol*1.5);
-    cpl_test_eq(cpl_propertylist_has(h, QC_STD_TRACE), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_SPAT_RES), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_ZEROPOINT), 0);
-    cpl_propertylist_delete(h); h = NULL;
-
-    h = kmclipm_propertylist_load(file_path, 3);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_THROUGHPUT), 0.0424846, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ZEROPOINT), 15.657, tol*2);
-    cpl_test_eq(cpl_propertylist_has(h, QC_NR_STD_STARS), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_STD_TRACE), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_SDV), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_MEAN), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_SPAT_RES), 0);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // check star_spec_KKK.fits
-    strcpy(file_path, "star_spec_KKK");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 2.10111e6, tol*4e6);
-    strcat(file_path, ".fits");
-
-    h = kmclipm_propertylist_load(file_path, 0);
-    cpl_test_eq(cpl_propertylist_get_int(h, QC_NR_STD_STARS), 6);
-    cpl_test_eq(cpl_propertylist_has(h, QC_STD_TRACE), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_SDV), 1);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_MEAN), 1);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_SPAT_RES), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_ZEROPOINT), 0);
-
-    cpl_propertylist_delete(h); h = NULL;
-
-    h = kmclipm_propertylist_load(file_path, 3);
-    cpl_test_eq(cpl_propertylist_has(h, QC_NR_STD_STARS), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_STD_TRACE), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_SDV), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT_MEAN), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_THROUGHPUT), 1);
-    cpl_test_eq(cpl_propertylist_has(h, QC_SPAT_RES), 0);
-    cpl_test_eq(cpl_propertylist_has(h, QC_ZEROPOINT), 1);
-    cpl_propertylist_delete(h); h = NULL;
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/recipes/tests/kmo_wave_cal-test.c b/recipes/tests/kmo_wave_cal-test.c
deleted file mode 100644
index d16e8c8..0000000
--- a/recipes/tests/kmo_wave_cal-test.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/* $Id: kmo_wave_cal-test.c,v 1.22 2013-10-08 11:18:57 aagudo Exp $
- *
- * This file is part of the KMOS Library
- * Copyright (C) 2002-2006 European Southern Observatory
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * $Author: aagudo $
- * $Date: 2013-10-08 11:18:57 $
- * $Revision: 1.22 $
- * $Name: not supported by cvs2svn $
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <sys/stat.h>
-#include <math.h>
-
-#include <cpl.h>
-
-#include "kmclipm_functions.h"
-
-#include "kmo_dfs.h"
-
-const char  *test_global_path_test_data;
-float   test_global_seed_data, test_global_seed_noise;
-int     test_global_size_x, test_global_size_y, test_global_size_z, test_global_nr_frames;
-void kmo_get_pipe_command(char*, const char*, const char*, int);
-int kmo_test_file_exists(const char*);
-void kmo_test_verbose_off();
-void kmo_test_verbose_on();
-double kmo_test_esorex_data(const char*, int);
-const char* kmo_test_cat_strings(char*, const char*, const char*);
-int  kmo_test_create_RAW_data(int, int, const char*, char**, char**, int*, int, char**, char**, int*, int, float, float);
-int  kmo_test_create_RAW_data_zero(int, int, const char*);
-int  kmo_test_create_F2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2D_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F2I_data_noise(int, int, int, const char*, char *, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_infinite(int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data2(int, int, int, int, int*, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F3I_data_noise(int, int, int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_F1I_data_noise(int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-int  kmo_test_create_B2D_data(int, int, int, const char*, char*, char*, int*, int, char**, char**, int*, int);
-
-const char      *path_recipe        = "kmo_wave_cal/";
-
-const char      *valid_files[]      = {"arc_on_123.fits",
-                                       "arc_off_123.fits",
-                                       "Ar_prediction_K.txt",
-                                       "kmos_ar_k_full_sim.fits",
-                                       "kmos_wave_ref_table_test2.fits",
-                                       "kmos_wave_band.fits"};
-
-/**
-    @defgroup kmo_wave_cal   kmo_wave_cal unit tests
-
-    @{
-*/
-
-/**
- * @brief test with data and mask
- */
-static void test_wave_cal(const char *path_op_on1,
-                          const char *path_op_off1,
-                          int ret_val)
-{
-    // create sof-file
-    const char *sof_path = "test_wave_cal.sof";
-    FILE *fh = fopen(sof_path, "w");
-    char *my_path = cpl_sprintf("%s/ref_data", getenv("srcdir"));
-    fprintf (fh,
-             "%s                            ARC_ON\n"
-             "%s                            ARC_OFF\n"
-             "badpixel_flat_KKK.fits        BADPIXEL_FLAT\n"
-             "xcal_KKK.fits                 XCAL\n"
-             "ycal_KKK.fits                 YCAL\n"
-             "flat_edge_KKK.fits            FLAT_EDGE\n"
-             "master_flat_KKK.fits          MASTER_FLAT\n"
-             "%s/%s                   ARC_LIST\n"
-             "%s/%s                   REF_LINES\n"
-             "%s/%s                   WAVE_BAND\n",
-             path_op_on1, path_op_off1,
-             my_path, valid_files[3], my_path, valid_files[4], my_path, valid_files[5]);
-    fclose(fh);
-    cpl_free(my_path);
-
-    // create esorex-command
-    char esorex_command[256];
-    sprintf(esorex_command,
-            "esorex --suppress-prefix=TRUE kmo_wave_cal --b_start=1.948 "
-                                  "--b_end=2.351 --dev_disp=0.0002 "
-                                  "--dev_flip=TRUE %s", sof_path);
-
-    kmo_get_pipe_command(esorex_command,
-                         "log_kmo_wave_cal.txt", sof_path, TRUE);
-
-    // execute esorex-command
-    if (ret_val == 0) {
-        cpl_test_eq(0, system(esorex_command));
-    } else {
-        cpl_test_noneq(0, system(esorex_command));
-    }
-}
-
-/**
-  @brief    Test of kmo_wave_cal recipe.
-  @param    argc   the number of parameters
-  @param    argv   the parameter list
-
-  Call @c kmo_wave_cal-test @c --generate when only the test data for this
-  recipe should be generated.
-  Call @c kmo_wave_cal-test @c --no-gen when only the tests should be
-  executed and no data should be generated.
-
- */
-int main(int argc, char *argv[])
-{
-    float   tol     = 0.01;
-
-    char    test_path[256],
-            file_path[256],
-            tmp[256],
-            op1_file_on[256],
-            op1_file_off[256];
-
-    cpl_propertylist *h = NULL;
-
-    cpl_test_init("<kmos-spark at mpe.mpg.de>", CPL_MSG_WARNING);
-
-    strcpy(test_path, test_global_path_test_data);
-    strcat(test_path, path_recipe);
-
-    if (kmo_test_file_exists(test_path) == FALSE) {
-        mkdir(test_path, 0777);
-    }
-
-    // get rid of warning...
-    if ((argc == 5) && (strcmp(argv[1], "xxx") != 0)) {
-    }
-
-    FILE *fd = fopen("log_kmo_wave_cal.txt", "w");
-    fprintf(fd, "%s\n", " ");
-    fclose(fd);
-
-    //
-    //  PIPELINE TEST (must be called after kmo_flat-test, since the
-    //  following recipes rely on this output)*/
-    //
-    cpl_msg_info(cpl_func, "Testing kmo_wave_cal with real pipeline data.");
-    sprintf(test_path, "%s%s", test_global_path_test_data, "pipeline/");
-
-    kmo_test_cat_strings(op1_file_on, test_path, valid_files[0]);
-    kmo_test_cat_strings(op1_file_off, test_path, valid_files[1]);
-    test_wave_cal(op1_file_on, op1_file_off, 0);
-
-    // check LCAL
-    strcpy(tmp, LCAL);
-    sprintf(file_path, "%s_KKK",kmo_strlower(tmp));
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 6.45113, tol*10);
-    strcat(file_path, ".fits");
-
-    h = kmclipm_propertylist_load(file_path, 1);
-    cpl_test_eq(cpl_propertylist_get_int(h, QC_ARC_SAT), 372);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ARC_AR_EFF),
-                 17.3546, tol*10);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ARC_AR_POS_MEAN),
-                 0.222684, tol*20);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ARC_AR_POS_MAXDIFF),
-                 0.486981, tol*22);
-    cpl_test_abs(cpl_propertylist_get_int(h, QC_ARC_AR_POS_MAXDIFF_ID),
-                 7, tol);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ARC_AR_POS_STDEV),
-                 1.76018, tol*3);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ARC_AR_POS_95ILE),
-                 3.74018, tol*5);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ARC_AR_FWHM_MEAN),
-                 45.2934, tol*7);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ARC_AR_FWHM_STDEV),
-                 3.95828, tol*4);
-    cpl_test_abs(cpl_propertylist_get_double(h, QC_ARC_AR_FWHM_95ILE),
-                 51.2953, tol*40);
-    cpl_propertylist_delete(h); h = NULL;
-
-    // check det_img_wave
-    strcpy(file_path, "det_img_wave_KKK");
-    cpl_test_abs(kmo_test_esorex_data(file_path, 1), 327.862, tol*15);
-
-    strcat(file_path, ".fits");
-    h = kmclipm_propertylist_load(file_path, 1);
-// ADD HERE THE OTHER QC PARAMETERS
-    cpl_propertylist_delete(h); h = NULL;
-
-    return cpl_test_end(0);
-}
-
-/** @} */
diff --git a/reflex/Makefile.am b/reflex/Makefile.am
index 788e4cc..2cf0692 100644
--- a/reflex/Makefile.am
+++ b/reflex/Makefile.am
@@ -6,9 +6,9 @@ AUTOMAKE_OPTIONS = foreign
 #to the OCA rules (grep for OCA in the xml file) or Python scripts
 WORKFLOWS = kmos.xml
 #Put here the OCA rules used by the workflow
-OCAWKF =  kmos_wkf.oca
+OCAWKF =  kmos_wkf.oca 
 #Put Python scripts used by the workflows
-PYTHONWKF = kmo_wave_cal.py
+PYTHONWKF = kmo_wave_cal.py kmo_std_star.py kmo_sci_red.py
 
 #This installs the workflow and the OCA rules in reflexaux directory
 wkfextra_DATA = $(WORKFLOWS) $(OCAWKF) $(PYTHONWKF)
diff --git a/reflex/Makefile.in b/reflex/Makefile.in
index 78f855e..8bb0415 100644
--- a/reflex/Makefile.in
+++ b/reflex/Makefile.in
@@ -249,9 +249,9 @@ AUTOMAKE_OPTIONS = foreign
 #to the OCA rules (grep for OCA in the xml file) or Python scripts
 WORKFLOWS = kmos.xml
 #Put here the OCA rules used by the workflow
-OCAWKF = kmos_wkf.oca
+OCAWKF = kmos_wkf.oca 
 #Put Python scripts used by the workflows
-PYTHONWKF = kmo_wave_cal.py
+PYTHONWKF = kmo_wave_cal.py kmo_std_star.py kmo_sci_red.py
 
 #This installs the workflow and the OCA rules in reflexaux directory
 wkfextra_DATA = $(WORKFLOWS) $(OCAWKF) $(PYTHONWKF)
diff --git a/reflex/kmo_sci_red.py b/reflex/kmo_sci_red.py
new file mode 100755
index 0000000..661f572
--- /dev/null
+++ b/reflex/kmo_sci_red.py
@@ -0,0 +1,336 @@
+from __future__ import with_statement
+import sys
+
+try:
+    import numpy
+    import os
+    import re
+    import reflex
+    from pipeline_product import PipelineProduct
+    import pipeline_display
+    import reflex_plot_widgets
+    import matplotlib.gridspec as gridspec
+    from matplotlib.text import Text
+    from pylab import *
+
+    import_success = True
+except ImportError:
+    import_success = False
+    print "Error importing modules pyfits, wx, matplotlib, numpy"
+
+def paragraph(text, width=None):
+    """ wrap text string into paragraph
+       text:  text to format, removes leading space and newlines
+       width: if not None, wraps text, not recommended for tooltips as
+              they are wrapped by wxWidgets by default
+    """
+    import textwrap
+    if width is None:
+        return textwrap.dedent(text).replace('\n', ' ').strip()
+    else:
+        return textwrap.fill(textwrap.dedent(text), width=width)
+
+class DataPlotterManager(object):
+    # static members
+    recipe_name = "kmo_sci_red"
+    reconstructed_cat = "SCI_RECONSTRUCTED"
+    oh_spec_cat = "OH_SPEC"
+    
+    IFU_stat_color = {'Active':'summer', 'Locked':'copper', 'NotInPAF':'winter', 'NotInPAF & Locked':'autumn', 'Coll.':'cool'}
+
+    def setInteractiveParameters(self):
+        return [
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="imethod",
+                    group="Recons.", description="Interpolation Method (NN, lwNN, swNN, MS, CS)"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="xcal_interpolation",
+                    group="Recons.", description="Interpolate xcal between rotator angles"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="b_samples",
+                    group="Recons.", description="The number of samples in wavelength"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="b_start",
+                    group="Recons.", description="The lowest wavelength"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="b_end",
+                    group="Recons.", description="The highest wavelength"),
+
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="fmethod",
+                    group="Extr.", description="Fitting Method (gauss, moffat)"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="neighborhoodRange",
+                    group="Extr.", description="Range for Neighbors"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="flux",
+                    group="Extr.", description="Apply flux conservation"),
+
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cmethod",
+                    group="Comb.", description="Combination Method (average, median, sum, min_max, ksigma)"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cpos_rej",
+                    group="Comb.", description="The positive rejection threshold"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cneg_rej",
+                    group="Comb.", description="The negative rejection threshold"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="citer",
+                    group="Comb.", description="The number of iterations"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cmax",
+                    group="Comb.", description="The number of maximum pixel values"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cmin",
+                    group="Comb.", description="The number of minimum pixel values"),
+
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="smethod",
+                    group="Other", description="Method to use for interpolation during shifting (NN, CS)"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="background",
+                    group="Other", description="Apply background removal"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="pix_scale",
+                    group="Other", description="Pixel Scale"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="no_subtract",
+                    group="Other", description="Don't sky subtract object and references"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="ifus",
+                    group="Other", description="The indices of the IFUs to combine"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="method",
+                    group="Other", description="The shifting method"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="filename",
+                    group="Other", description="The path to the file with the shift vectors"),
+        ]
+
+    def readFitsData(self, fitsFiles):
+        # Initialise
+        self.files = dict()
+        self.oh_spec = dict()
+        self.oh_spec["Found"] = False
+
+        # Loop on all FITS files 
+        for f in fitsFiles:
+            # Use OH_SPEC if found
+            if f.category == self.oh_spec_cat :
+                oh_spec_file = PipelineProduct(f)
+                self.oh_spec["Found"] = True
+                self.oh_spec["CRVAL1"] = oh_spec_file.all_hdu[1].header["CRVAL1"]
+                self.oh_spec["CDELT1"] = oh_spec_file.all_hdu[1].header["CDELT1"]
+                self.oh_spec["Spectrum"] = oh_spec_file.all_hdu[1].data
+
+            # For each reconstructed image
+            if f.category == self.reconstructed_cat :
+                recons_file = PipelineProduct(f)
+                filename = os.path.basename(f.name)
+                # Create a Dictionary per file
+                self.files[filename] = dict()
+                # Loop on extensions
+                for recons_ext in recons_file.all_hdu:
+                    # EXTNAME is missing in the primary header - Skip it anyway
+                    try:
+                        extname = recons_ext.header['EXTNAME']
+                    except KeyError:
+                        continue
+                   
+                    # Create Entry for the extension
+                    self.files[filename][extname]=dict()
+                        
+                    # Get the IFU number from extname to get the IFU status
+                    m = re.search(r"\d+", extname)
+                    ifu_number = m.group()
+                    self.files[filename][extname]["IFU_NUMBER"] = int(ifu_number)
+                    keyword_name = 'ESO OCS ARM'+ifu_number+' NOTUSED'
+                    if (keyword_name in recons_file.all_hdu[0].header)  :
+                        self.files[filename][extname]["IFU_STATUS"] = recons_file.all_hdu[0].header[keyword_name]
+                    else :
+                        self.files[filename][extname]["IFU_STATUS"] = 'Active'
+
+                    naxis = recons_ext.header['NAXIS']
+                    if (naxis == 3):
+                        # Get Keyword infos  
+                        self.files[filename][extname]["CRPIX3"] = recons_ext.header['CRPIX3']
+                        self.files[filename][extname]["CRVAL3"] = recons_ext.header['CRVAL3']
+                        self.files[filename][extname]["CDELT3"] = recons_ext.header['CDELT3']
+                        
+                        # Fill Spectrum
+                        self.files[filename][extname]["Spectrum"] = []
+                        for cube_plane in recons_ext.data:
+                            cube_plane_nan_free = cube_plane[~numpy.isnan(cube_plane)]
+                            if (len(cube_plane_nan_free) > 0):
+                                mean = cube_plane_nan_free.mean()
+                            else:
+                                mean = numpy.nan
+                            self.files[filename][extname]["Spectrum"].append(mean)
+
+        # If proper files are there...
+        if (len(self.files.keys()) > 0):
+            # Set the plotting functions
+            self._add_subplots = self._add_subplots
+            self._plot = self._data_plot
+        else:
+            self._add_subplots = self._add_nodata_subplots
+            self._plot = self._nodata_plot
+
+    def addSubplots(self, figure):
+        self._add_subplots(figure)
+
+    def plotProductsGraphics(self):
+        self._plot()
+
+    def plotWidgets(self) :
+        widgets = list()
+
+        # Files Selector radiobutton
+        self.radiobutton = reflex_plot_widgets.InteractiveRadioButtons(self.files_selector, self.setFSCallback, self.files.keys(), 0, 
+                title='Files Selection (Mouse left button)')
+        widgets.append(self.radiobutton)
+        
+        self.clickable_ifus =reflex_plot_widgets.InteractiveClickableSubplot(self.ifus_selector, self.setIFUSCallback)
+        widgets.append(self.clickable_ifus)
+
+        return widgets
+
+    def extension_has_spectrum(self, filename, extname):
+        if ("Spectrum" in self.files[self.selected_file][extname].keys()):
+            return True
+        else:
+            return False
+
+    def setIFUSCallback(self, point) :
+        if (1 < point.ydata < 3) :
+            extname = "IFU."+str(int((point.xdata/2)+0.5))+".DATA"
+            if (self.extension_has_spectrum(self.selected_file, extname)):
+                # Update selected extension
+                self.selected_extension = extname
+                # Redraw IFUs selection
+                self._plot_ifus_selector(self.selected_file)
+                # Redraw spectrum
+                self._plot_spectrum()
+
+    def setFSCallback(self, filename) :
+        # Keep track of the selected file
+        self.selected_file = filename
+
+        # Check that the new file currently selected extensin is valid
+        if (not self.extension_has_spectrum(self.selected_file, self.selected_extension)):
+            self.selected_extension = self._get_first_valid_extname(self.selected_file)
+            self._plot_ifus_selector(self.selected_file)
+
+        # Redraw spectrum
+        self._plot_spectrum()
+        
+    def _add_subplots(self, figure):
+        gs = gridspec.GridSpec(3, 1)
+        self.files_selector = figure.add_subplot(gs[0,0])
+        self.ifus_selector = figure.add_subplot(gs[1,0])
+        self.spec_plot = figure.add_subplot(gs[2,0])
+
+    def _data_plot_get_tooltip(self):
+        return self.selected_file+" ["+self.selected_extension+"]"
+
+    def _plot_spectrum(self):
+        extension_dict = self.files[self.selected_file][self.selected_extension] 
+        
+        # Define wave
+        pix = numpy.arange(len(extension_dict["Spectrum"]))
+        wave = extension_dict["CRVAL3"] + pix * extension_dict["CDELT3"]
+
+        # Plot Spectrum
+        self.spec_plot.clear()
+        specdisp = pipeline_display.SpectrumDisplay()
+        specdisp.setLabels("Wavelength (microns)", "Flux (ADU)")
+        specdisp.display(self.spec_plot, "Spectrum", self._data_plot_get_tooltip(), wave, extension_dict["Spectrum"])
+
+        if (self.oh_spec["Found"]):
+            # Overplot the OH spectrum
+            pix = numpy.arange(len(self.oh_spec["Spectrum"]))
+            wave = self.oh_spec["CRVAL1"] + pix * self.oh_spec["CDELT1"]
+            specdisp.overplot(self.spec_plot, wave, self.oh_spec["Spectrum"], 'red')
+
+    def _plot_ifus_selector(self, filename):
+        self.ifus_selector.clear()
+
+        # Loop on the different kind of Status to Print the Legend
+        box_y_start = 4
+        box_y_stop  = 6
+        box_x_width  = 8
+        box_x_start = 1
+        box_x_stop = box_x_start + box_x_width
+        gap = 2
+        for status in self.IFU_stat_color.keys() :
+            self.ifus_selector.imshow(numpy.zeros((1,1)), extent=(box_x_start, box_x_stop, box_y_start, box_y_stop),
+                    cmap=self.IFU_stat_color[status])
+            my_label = status
+            if (status == "Coll."):
+                my_label = "Collision"
+            self.ifus_selector.text(box_x_start+1, 4.5, my_label, fontsize=11,color='white')
+            box_x_start = box_x_stop + gap
+            box_x_stop = box_x_start + box_x_width
+
+        # Display the IFUs selection squares
+        box_y_start = 1
+        box_y_stop  = 3
+        box_xwidth  = 1.5
+        for extname in self.files[filename].keys():
+            # Compute the IFU number
+            ifu_number  = self.files[filename][extname]['IFU_NUMBER']
+            # Draw the little IFU image
+            box_xstart  = 2 * ifu_number - 1
+            box_xstop = box_xstart + box_xwidth
+            self.ifus_selector.imshow(numpy.zeros((1,1)), extent=(box_xstart,box_xstop,box_y_start,box_y_stop), 
+                    cmap=self.IFU_stat_color[self.files[filename][extname]["IFU_STATUS"]])
+            # Write the IFU number in the image
+            self.ifus_selector.text(2 * (ifu_number-1) + 1.2, 1.5, str(ifu_number), fontsize=13,color='white')
+            # Mark the selected IFU
+            if (extname == self.selected_extension):
+                self.ifus_selector.imshow(numpy.zeros((1,1)), extent=(box_xstart,box_xstop,0.5,0.7), 
+                        cmap=self.IFU_stat_color[self.files[filename][extname]["IFU_STATUS"]])
+
+        self.ifus_selector.axis([0,50,0,7])
+        self.ifus_selector.set_title("IFU Selection (Mouse middle button)")
+        self.ifus_selector.get_xaxis().set_ticks([])
+        self.ifus_selector.get_yaxis().set_ticks([])
+
+    # Get the first valid extension name (ie containing a spectrum) in a file - "" if None 
+    def _get_first_valid_extname(self, filename):
+        for extname in sorted(self.files[filename].keys()):
+            if (self.extension_has_spectrum(filename, extname)) :
+                return extname
+        return ""
+
+    def _data_plot(self):
+        # Initial file is the first one
+        self.selected_file = self.files.keys()[0]
+        self.selected_extension = self._get_first_valid_extname(self.selected_file)
+        
+        # Plot the IFUS selection
+        self._plot_ifus_selector(self.selected_file)
+
+        # Draw Spectrum
+        self._plot_spectrum()
+
+    def _add_nodata_subplots(self, figure):
+        self.img_plot = figure.add_subplot(1,1,1)
+
+    def _nodata_plot(self):
+        # could be moved to reflex library?
+        self.img_plot.set_axis_off()
+        text_nodata = "Data not found. Input files should contain this" \
+                       " type:\n%s" % self.det_img_wave_cat
+        self.img_plot.text(0.1, 0.6, text_nodata, color='#11557c',
+                      fontsize=18, ha='left', va='center', alpha=1.0)
+        self.img_plot.tooltip = 'No data found'
+
+#This is the 'main' function
+if __name__ == '__main__':
+    from reflex_interactive_app import PipelineInteractiveApp
+
+    # Create interactive application
+    interactive_app = PipelineInteractiveApp()
+
+    # get inputs from the command line
+    interactive_app.parse_args()
+
+    #Check if import failed or not
+    if not import_success:
+        interactive_app.setEnableGUI(False)
+
+    #Open the interactive window if enabled
+    if interactive_app.isGUIEnabled():
+        #Get the specific functions for this window
+        dataPlotManager = DataPlotterManager()
+
+        interactive_app.setPlotManager(dataPlotManager)
+        interactive_app.showGUI()
+    else:
+        interactive_app.set_continue_mode()
+
+    #Print outputs. This is parsed by the Reflex python actor to
+    #get the results. Do not remove
+    interactive_app.print_outputs()
+    sys.exit()
diff --git a/reflex/kmo_std_star.py b/reflex/kmo_std_star.py
new file mode 100755
index 0000000..c475a25
--- /dev/null
+++ b/reflex/kmo_std_star.py
@@ -0,0 +1,245 @@
+from __future__ import with_statement
+import sys
+
+try:
+    import numpy
+    import re
+    import reflex
+    from pipeline_product import PipelineProduct
+    import pipeline_display
+    import reflex_plot_widgets
+    import matplotlib.gridspec as gridspec
+    import_success = True
+except ImportError:
+    import_success = False
+    print "Error importing modules pyfits, wx, matplotlib, numpy"
+
+def paragraph(text, width=None):
+    """ wrap text string into paragraph
+       text:  text to format, removes leading space and newlines
+       width: if not None, wraps text, not recommended for tooltips as
+              they are wrapped by wxWidgets by default
+    """
+    import textwrap
+    if width is None:
+        return textwrap.dedent(text).replace('\n', ' ').strip()
+    else:
+        return textwrap.fill(textwrap.dedent(text), width=width)
+
+
+class DataPlotterManager(object):
+    # static members
+    recipe_name = "kmo_std_star"
+    star_spec_cat = "STAR_SPEC"
+    telluric_cat = "TELLURIC"
+    std_image_cat = "STD_IMAGE"
+
+    def setInteractiveParameters(self):
+        return [
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="imethod",
+                    group="Recons.", description="Interpolation Method (NN, lwNN, swNN, MS, CS)"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="xcal_interpolation",
+                    group="Recons.", description="Interpolate xcal between rotator angles"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="b_samples",
+                    group="Recons.", description="The number of samples in wavelength"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="b_start",
+                    group="Recons.", description="The lowest wavelength"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="b_end",
+                    group="Recons.", description="The highest wavelength"),
+
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="fmethod",
+                    group="Extr.", description="Fitting Method (gauss, moffat)"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="neighborhoodRange",
+                    group="Extr.", description="Range for Neighbors"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="flux",
+                    group="Extr.", description="Apply flux conservation"),
+
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cmethod",
+                    group="Comb.", description="Combination Method (average, median, sum, min_max, ksigma)"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cpos_rej",
+                    group="Comb.", description="The positive rejection threshold"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cneg_rej",
+                    group="Comb.", description="The negative rejection threshold"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="citer",
+                    group="Comb.", description="The number of iterations"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cmax",
+                    group="Comb.", description="The number of maximum pixel values"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="cmin",
+                    group="Comb.", description="The number of minimum pixel values"),
+            
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="startype",
+                    group="Star", description="The star spectral type (O, B, A, F, G)"),
+            reflex.RecipeParameter(recipe=self.recipe_name, displayName="magnitude",
+                    group="Star", description="Star Magnitude"),
+        ]
+
+    def readFitsData(self, fitsFiles):
+        self.frames = dict()
+        for f in fitsFiles:
+            self.frames[f.category] = PipelineProduct(f)
+
+        # Two cases: the file category is found or not found.
+        # Define the plotting functions in both cases
+        if self.std_image_cat in self.frames and self.star_spec_cat in self.frames and self.telluric_cat in self.frames:
+            # Get the wished files
+            std_image = self.frames[self.std_image_cat]
+            star_spec = self.frames[self.star_spec_cat]
+            telluric = self.frames[self.telluric_cat]
+           
+            # Initialise
+            self.star_data_extnames = []
+            self.qc_std_trace = dict()
+            self.qc_spat_res = dict()
+            self.image_std = dict()
+            self.qc_thruput = dict()
+            self.qc_zpoint = dict()
+            self.crpix1 = dict()
+            self.crval1 = dict()
+            self.cdelt1 = dict()
+            self.spec_data = dict()
+            self.spec_noise = dict()
+            
+            # READ data
+            self.qc_nr_std_stars = star_spec.all_hdu[0].header['ESO QC NR STD STARS']
+            self.qc_thruput_mean = star_spec.all_hdu[0].header['ESO QC THRUPUT MEAN']
+            self.qc_thruput_sdv  = star_spec.all_hdu[0].header['ESO QC THRUPUT SDV']
+            
+            # Loop on all extensions of std_image to find the std stars extensions
+            for std_image_ext in std_image.all_hdu:
+                naxis = std_image_ext.header['NAXIS']
+                # NAXIS is 2 if there is an image, 0 otherwise
+                if (naxis == 2):
+                    # extname is like IFU.3.DATA 
+                    extname = std_image_ext.header['EXTNAME']
+                    self.star_data_extnames.append(extname)
+                    self.qc_std_trace[extname] = std_image_ext.header['ESO QC STD TRACE']
+                    self.qc_spat_res[extname] = std_image_ext.header['ESO QC SPAT RES']
+                    self.image_std[extname] = std_image_ext.data
+
+                    # Get infos from star_spec using the extname
+                    self.qc_thruput[extname] = star_spec.all_hdu[extname].header['ESO QC THRUPUT']
+                    self.qc_zpoint[extname] = star_spec.all_hdu[extname].header['ESO QC ZPOINT']
+                    self.crpix1[extname] = star_spec.all_hdu[extname].header['CRPIX1']
+                    self.crval1[extname] = star_spec.all_hdu[extname].header['CRVAL1']
+                    self.cdelt1[extname] = star_spec.all_hdu[extname].header['CDELT1']
+                    self.spec_data[extname] = star_spec.all_hdu[extname].data
+
+                    # noise_extname is like IFU.3.NOISE
+                    noise_extname = re.sub("DATA", "NOISE", extname)    
+                    self.spec_noise[extname] = star_spec.all_hdu[noise_extname].data
+
+            # Set the plotting functions
+            self._add_subplots = self._add_subplots
+            self._plot = self._data_plot
+        else:
+            # Set the plotting functions to NODATA ones
+            self._add_subplots = self._add_nodata_subplots
+            self._plot = self._nodata_plot
+
+    def addSubplots(self, figure):
+        self._add_subplots(figure)
+
+    def plotProductsGraphics(self):
+        self._plot()
+
+    def plotWidgets(self) :
+        widgets = list()
+        # Radio button
+        self.radiobutton = reflex_plot_widgets.InteractiveRadioButtons(self.axradiobutton, self.setRadioCallback, 
+                self.star_data_extnames, 0, title='Standard star selection')
+        widgets.append(self.radiobutton)
+        return widgets
+
+    def setRadioCallback(self, label) :
+            
+        # Setup the image display
+        imgdisp = pipeline_display.ImageDisplay()
+        imgdisp.setAspect('equal')
+        imgdisp.display(self.img_plot, "Median collapsed cube (STD_IMAGE)", self._data_plot_get_tooltip(label), 
+                self.image_std[label])
+
+        # Define wave
+        pix = numpy.arange(len(self.spec_data[label]))
+        wave = self.crval1[label] + pix * self.cdelt1[label]  
+          
+        # Plot Spectrum
+        specdisp = pipeline_display.SpectrumDisplay()
+        self.spec_plot.clear()
+        specdisp.setLabels("Wavelength (microns)", "Flux (ADU)")
+        specdisp.display(self.spec_plot, "Extracted Standard Star Spectrum (STAR_SPEC)", self._data_plot_get_tooltip(label), 
+                wave, self.spec_data[label])
+
+    def _add_subplots(self, figure):
+        gs = gridspec.GridSpec(2, 2)
+        self.axradiobutton =    figure.add_subplot(gs[0,0])
+        self.img_plot =         figure.add_subplot(gs[0,1])
+        self.spec_plot =        figure.add_subplot(gs[1,:])
+
+    def _data_plot_get_tooltip(self, extname):
+        # Create the tooltip
+        tooltip = " \
+            ESO QC NR STD STARS : %f \n \
+            ESO QC THRUPUT MEAN : %f \n \
+            ESO QC THRUPUT SDV  : %f \n \
+            ESO QC STD TRACE    : %f \n \
+            ESO QC SPAT RES     : %f \n \
+            ESO QC THRUPUT      : %f \n \
+            ESO QC ZPOINT       : %f \
+            " % (self.qc_nr_std_stars, self.qc_thruput_mean, self.qc_thruput_sdv, self.qc_std_trace[extname], self.qc_spat_res[extname], self.qc_thruput[extname], self.qc_zpoint[extname])
+        return tooltip
+
+    def _data_plot(self):
+        extname = self.star_data_extnames[0]
+        imgdisp = pipeline_display.ImageDisplay()
+        imgdisp.setAspect('equal')
+        imgdisp.display(self.img_plot, "Median collapsed cube (STD_IMAGE)", self._data_plot_get_tooltip(extname), 
+                self.image_std[extname])
+
+        # Define wave
+        pix = numpy.arange(len(self.spec_data[extname]))
+        wave = self.crval1[extname] + pix * self.cdelt1[extname]  
+        
+        # Plot Spectrum
+        specdisp = pipeline_display.SpectrumDisplay()
+        specdisp.setLabels("Wavelength (microns)", "Flux (ADU)")
+        specdisp.display(self.spec_plot, "Extracted Standard Star Spectrum (STAR_SPEC)", self._data_plot_get_tooltip(extname), 
+                wave, self.spec_data[extname])
+
+    def _add_nodata_subplots(self, figure):
+        self.img_plot = figure.add_subplot(1,1,1)
+
+    def _nodata_plot(self):
+        # could be moved to reflex library?
+        self.img_plot.set_axis_off()
+        text_nodata = "Data not found"
+        self.img_plot.text(0.1, 0.6, text_nodata, color='#11557c', fontsize=18, ha='left', va='center', alpha=1.0)
+        self.img_plot.tooltip = text_nodata
+
+#This is the 'main' function
+if __name__ == '__main__':
+    from reflex_interactive_app import PipelineInteractiveApp
+
+    # Create interactive application
+    interactive_app = PipelineInteractiveApp()
+
+    # get inputs from the command line
+    interactive_app.parse_args()
+
+    #Check if import failed or not
+    if not import_success:
+        interactive_app.setEnableGUI(False)
+
+    #Open the interactive window if enabled
+    if interactive_app.isGUIEnabled():
+        #Get the specific functions for this window
+        dataPlotManager = DataPlotterManager()
+
+        interactive_app.setPlotManager(dataPlotManager)
+        interactive_app.showGUI()
+    else:
+        interactive_app.set_continue_mode()
+
+    #Print outputs. This is parsed by the Reflex python actor to
+    #get the results. Do not remove
+    interactive_app.print_outputs()
+    sys.exit()
diff --git a/reflex/kmo_wave_cal.py b/reflex/kmo_wave_cal.py
index 1c8cf9f..bb6cb47 100755
--- a/reflex/kmo_wave_cal.py
+++ b/reflex/kmo_wave_cal.py
@@ -6,16 +6,13 @@ try:
     import reflex
     from pipeline_product import PipelineProduct
     import pipeline_display
+    import reflex_plot_widgets
+    import matplotlib.gridspec as gridspec
     import_success = True
-
 except ImportError:
     import_success = False
     print "Error importing modules pyfits, wx, matplotlib, numpy"
 
-class ScatterDisplayLocal(pipeline_display.ScatterDisplay):
-    def setErrorBar(self, subplot, x, y, error):
-        subplot.errorbar(x, y, yerr=error, fmt='-o')
-
 def paragraph(text, width=None):
     """ wrap text string into paragraph
        text:  text to format, removes leading space and newlines
@@ -30,31 +27,12 @@ def paragraph(text, width=None):
 
 
 class DataPlotterManager(object):
-    """
-    This class must be added to the PipelineInteractiveApp with setPlotManager
-    It must have following member functions which will be called by the app:
-     - setInteractiveParameters(self)
-     - readFitsData(self, fitsFiles):
-     - addSubplots(self, figure):
-     - plotProductsGraphics(self, figure, canvas)
-    Following members are optional:
-     - setWindowHelp(self)
-     - setWindowTitle(self)
-    """
-
     # static members
     recipe_name = "kmo_wave_cal"
     det_img_wave_cat = "DET_IMG_WAVE"
     lcal_cat = "LCAL"
 
     def setInteractiveParameters(self):
-        """
-        This function specifies which are the parameters that should be presented
-        in the window to be edited.  Note that the parameter has to also be in the
-        in_sop port (otherwise it won't appear in the window). The descriptions are
-        used to show a tooltip. They should match one to one with the parameter
-        list.
-        """
         return [
             reflex.RecipeParameter(recipe=self.recipe_name, displayName="order",
                     group="Wavelength Calibration", description="The wavelength polynomial order"),
@@ -73,14 +51,6 @@ class DataPlotterManager(object):
         ]
 
     def readFitsData(self, fitsFiles):
-        """
-        This function should be used to read and organize the raw fits files
-        produced by the recipes.
-        It receives as input a list of reflex.FitsFiles
-        """
-        # organize the files into a dictionary, here we assume we only have 
-        # one file per category if there are more, one must use a
-        # dictionary of lists
         self.frames = dict()
         for f in fitsFiles:
             self.frames[f.category] = PipelineProduct(f)
@@ -88,107 +58,139 @@ class DataPlotterManager(object):
         # Two cases: the file category is found or not found.
         # Define the plotting functions in both cases
         if self.det_img_wave_cat in self.frames:
+            # Get the wished files
+            det_img_wave = self.frames[self.det_img_wave_cat]
+            self.det_img_wave_name = det_img_wave.fits_file.name
+
+            # Get the angle values
+            self.angles_list = dict()
+            for i in range(18):
+                angle = det_img_wave.readKeyword('ESO PRO ROT NAANGLE', i+1)
+
+                if not (angle in self.angles_list) :
+                    self.angles_list[angle] = []
+                self.angles_list[angle].append(i+1)
+
+            # Sorted angles list
+            self.sorted_angles = self.angles_list.keys()
+            self.sorted_angles.sort() 
+
+            # Read the Plotting Data
+            self.argon_pos_data = []
+            self.argon_fwhm_data = []
+            self.neon_pos_data = []
+            self.neon_fwhm_data = []
+            for i in range(18):
+                key1 = det_img_wave.readKeyword('ESO QC ARC AR POS MEAN', i+1)
+                key2 = det_img_wave.readKeyword('ESO QC ARC AR FWHM MEAN', i+1)
+                ar_vscale = det_img_wave.readKeyword('ESO QC ARC AR VSCALE', i+1)
+
+                key3 = det_img_wave.readKeyword('ESO QC ARC NE POS MEAN', i+1)
+                key4 = det_img_wave.readKeyword('ESO QC ARC NE FWHM MEAN', i+1)
+                ne_vscale = det_img_wave.readKeyword('ESO QC ARC NE VSCALE', i+1)
+           
+                # Correct Key2 and Key4 units
+                key2 /= ar_vscale
+                key4 /= ne_vscale
+
+                # Fill the Argon Data for the scatter plot
+                self.argon_pos_data.append(key1)
+                self.argon_fwhm_data.append(key2)
+                
+                # Fill the Neon Data for the scatter plot
+                self.neon_pos_data.append(key3)
+                self.neon_fwhm_data.append(key4)
+
+            # Read the images
+            self.images = []
+            for i in range(18):
+                det_img_wave.readImage(i+1)
+                self.images.append(det_img_wave.image) 
+
+            # Set the plotting functions
             self._add_subplots = self._add_subplots
             self._plot = self._data_plot
         else:
+            # Set the plotting functions to NODATA ones
             self._add_subplots = self._add_nodata_subplots
             self._plot = self._nodata_plot
 
     def addSubplots(self, figure):
-        """
-        This function should be used to setup the subplots of the gui.  The the
-        matplotlib documentation for a description of subplots.
-        """
         self._add_subplots(figure)
 
-    def plotProductsGraphics(self, figure, canvas):
-        """
-        This function should be used to plot the data onto the subplots.
-        """
-        self._plot(figure, canvas)
+    def plotProductsGraphics(self):
+        self._plot()
 
-    def _add_nodata_subplots(self, figure):
-        self.img_plot = figure.add_subplot(1,1,1)
+    def plotWidgets(self) :
+        widgets = list()
+
+        # Radio button
+        self.radiobutton = reflex_plot_widgets.InteractiveRadioButtons(self.axradiobutton, self.setRadioCallback, self.sorted_angles, 0, title='Angle selection')
+        
+        widgets.append(self.radiobutton)
+        return widgets
+
+    def setRadioCallback(self, label) :
+        # Get Extensions as list
+        extensions = self.angles_list[float(label)] 
+        if (len(extensions) == 3):
+            # Setup the image display
+            for i in range(3):
+                imgdisp = pipeline_display.ImageDisplay()
+                imgdisp.setAspect('equal')
+                imgdisp.display(self.img_plot[i], "Extension {}".format(extensions[i]), self._data_plot_get_tooltip(extensions[i]), self.images[extensions[i]-1])
+        else:
+            print "Wrong number of extensions for this angle"
 
     def _add_subplots(self, figure):
+      
+        gs = gridspec.GridSpec(5, 3)
         self.img_plot = []
-        for i in range(18):
-            self.img_plot.append(figure.add_subplot(8,3,i+1))
-        self.argon_plot = figure.add_subplot(817)
-        self.neon_plot = figure.add_subplot(818)
-
-    def _data_plot_get_tooltip(self, fits_file, extension):
-        key1 = fits_file.readKeyword('ESO QC ARC AR POS MEAN', extension)
-        key2 = fits_file.readKeyword('ESO QC ARC AR FWHM MEAN', extension)
-        key3 = fits_file.readKeyword('ESO QC ARC NE POS MEAN', extension)
-        key4 = fits_file.readKeyword('ESO QC ARC NE FWHM MEAN', extension)
-        
-        # Fill the Argon Data for the scatter plot
-        self.argon_pos_data.append(key1)
-        self.argon_fwhm_data.append(key2)
-        self.neon_pos_data.append(key3)
-        self.neon_fwhm_data.append(key4)
-        
-        # Fill the Neon Data for the scatter plot
+        for i in range(3):
+            self.img_plot.append(figure.add_subplot(gs[0:2,i]))
+        self.axradiobutton = figure.add_subplot(gs[3:,0])
+        self.argon_plot = figure.add_subplot(gs[3,1:])
+        self.neon_plot = figure.add_subplot(gs[4,1:])
 
+    def _data_plot_get_tooltip(self, extension):
         # Create the tooltip
         tooltip = " \
                 ESO QC ARC AR POS MEAN : %f \n \
                 ESO QC ARC AR FWHM MEAN : %f \n \
                 ESO QC ARC NE POS MEAN : %f \n \
                 ESO QC ARC NE FWHM MEAN : %f \
-        " % (key1,key2,key3,key4)
+        " % (self.argon_pos_data[extension-1],self.argon_fwhm_data[extension-1],self.neon_pos_data[extension-1],self.neon_fwhm_data[extension-1])
         return tooltip
 
-    def _data_plot(self, figure, canvas):
-
-        # Get the wished files
-        det_img_wave = self.frames[self.det_img_wave_cat]
-        lcal = self.frames[self.lcal_cat]
-
-        # Initialise the data holders for the scatter plots
-        self.argon_pos_data = []
-        self.argon_fwhm_data = []
-        self.neon_pos_data = []
-        self.neon_fwhm_data = []
-
-        # Setup the image display
-        for i in range(18):
-            imgdisp = pipeline_display.ImageDisplay()
-            # Title gives the Detector number at the top of the column
-            if i == 0:
-                title = "Detector 1"
-            elif i == 1:
-                title = "Detector 2"
-            elif i == 2:
-                title = "Detector 3"
-            else:
-                title = ""
-            
-            # Y Label gives the angle at the start of the ROW
-            if i in [0,3,6,9,12,15]:
-                angle = det_img_wave.readKeyword('ESO PRO ROT NAANGLE', i+1)
-                ylabel = "Angle %.0f d." % angle
-            else:
-                ylabel = ""
-
-            # Read the image
-            det_img_wave.readImage(i+1)
-
-            # Display the image
-            imgdisp.setLabels('', ylabel)
-            imgdisp.display(self.img_plot[i], title, self._data_plot_get_tooltip(lcal,i+1), det_img_wave.image)
-       
-        scadsp = ScatterDisplayLocal()
+    def _data_plot(self):
+        # Get Extensions as list
+        extensions = self.angles_list[self.sorted_angles[0]] 
+        if (len(extensions) == 3):
+            # Setup the image display
+            for i in range(3):
+                imgdisp = pipeline_display.ImageDisplay()
+                imgdisp.setAspect('equal')
+                imgdisp.display(self.img_plot[i], "Extension {}".format(extensions[i]), self._data_plot_get_tooltip(extensions[i]), self.images[extensions[i]-1])
+        else:
+            print "Wrong number of extensions for this angle"
+
+        # Define x
         x = numpy.linspace(1, 18, num=18)
-        scadsp.display(self.argon_plot, "Argon Lines", "Argon Lines Positions and FWH", x, self.argon_pos_data)
-        scadsp.setErrorBar(self.argon_plot, x, self.argon_pos_data, self.argon_fwhm_data)
+        
+        # Plot Argon and Neon plots
+        scadsp = pipeline_display.ScatterDisplay()
+        scadsp.display(self.argon_plot, "Argon Lines", "Mean Argon line positional offset, with error bars equal to the FWH", x, self.argon_pos_data,
+                self.argon_fwhm_data)
+
+        scadsp = pipeline_display.ScatterDisplay()
+        scadsp.setLabels('File Extensions 1 -> 18','Line Pos. (pix)')
+        scadsp.display(self.neon_plot, "Neon Lines", "Mean Neon line positional offset, with error bars equal to the FWH", x, self.neon_pos_data,
+                self.neon_fwhm_data)
 
-        scadsp = ScatterDisplayLocal()
-        scadsp.display(self.neon_plot, "Neon Lines", "Neon Lines Positions and FWH", x, self.neon_pos_data)
-        scadsp.setErrorBar(self.neon_plot, x, self.neon_pos_data, self.neon_fwhm_data)
+    def _add_nodata_subplots(self, figure):
+        self.img_plot = figure.add_subplot(1,1,1)
 
-    def _nodata_plot(self, figure, canvas):
+    def _nodata_plot(self):
         # could be moved to reflex library?
         self.img_plot.set_axis_off()
         text_nodata = "Data not found. Input files should contain this" \
diff --git a/reflex/kmos.xml.in b/reflex/kmos.xml.in
index 8417d1c..7faa0ea 100644
--- a/reflex/kmos.xml.in
+++ b/reflex/kmos.xml.in
@@ -2,7 +2,7 @@
 <!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN"
     "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd">
 <entity name="kmos" class="org.kepler.moml.CompositeClassEntity">
-    <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:4:12">
+    <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:4:547">
     </property>
     <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.kepler.moml.CompositeClassEntity">
         <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
@@ -34,11 +34,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
-<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -83,11 +83,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
-<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -132,11 +132,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
-<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -394,13 +394,13 @@
         <property name="allowDirectories" class="ptolemy.data.expr.Parameter" value="true">
         </property>
     </property>
-    <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={87, 1, 1833, 1155}, maximized=false}">
+    <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={65, 0, 1833, 1155}, maximized=false}">
     </property>
     <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[1523, 1005]">
     </property>
-    <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="0.7334706462887">
+    <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="0.7520756797899855">
     </property>
-    <property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" value="{591.4574018960379, 453.2304984261011}">
+    <property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" value="{436.53107960178454, 632.1508437293456}">
     </property>
     <property name="Annotation13" class="ptolemy.vergil.kernel.attributes.TextAttribute">
         <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
@@ -493,11 +493,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
-<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -607,11 +607,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
-<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -869,7 +869,7 @@
         </property>
         <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#WorkflowDocumentation">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[780.0, 355.0]">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[775.0, 310.0]">
         </property>
         <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:436:1">
         </property>
@@ -905,7 +905,7 @@
         </property>
         <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 345.0]">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 300.0]">
         </property>
     </property>
     <property name="ESORexArgs" class="ptolemy.data.expr.StringParameter" value="--suppress-prefix=TRUE">
@@ -973,10 +973,10 @@
         </property>
         <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 275.0]">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 245.0]">
         </property>
     </property>
-    <property name="END_PRODUCTS_SUBDIR" class="ptolemy.data.expr.StringParameter" value="2013-10-29T11:50:16/KMOS.2013-06-30T23:48:06.049_tpl">
+    <property name="END_PRODUCTS_SUBDIR" class="ptolemy.data.expr.StringParameter" value="2014-02-24T13:23:04/KMOS.2013-06-30T23:48:06.049_tpl">
 <property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
 <property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
@@ -1012,7 +1012,7 @@
         <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
         </property>
     </property>
-    <property name="GLOBAL_TIMESTAMP" class="ptolemy.data.expr.StringParameter" value="2013-10-29T11:50:16">
+    <property name="GLOBAL_TIMESTAMP" class="ptolemy.data.expr.StringParameter" value="2014-02-24T13:23:04">
 <property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
 <property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
@@ -1090,7 +1090,7 @@
         </property>
         <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#WorkflowDocumentation">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[775.0, 285.0]">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[775.0, 250.0]">
         </property>
         <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:436:1">
         </property>
@@ -1121,11 +1121,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
-<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -1213,11 +1213,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
-<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -1358,11 +1358,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
-<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -1436,8 +1436,8 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Gang Zhou</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
            <p> The dynamic dataflow (DDF) domain is a superset of the synchronous
            dataflow(SDF) and Boolean dataflow(BDF) domains. In the SDF domain,
            an actor consumes and produces a fixed number of tokens per firing.
            This static information makes possible compile-time scheduling. In the
            DDF domain, there are few  [...]
-<property name="prop:maximumReceiverCapacity" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A Parameter representing the maximum capacity of each receiver controlled by this director. This is an integer that defaults to 0, which means the queue in each receiver is unbounded. To specify bounded queues, set this to a positive integer. </configure></property>
 <property name="prop:iterations" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify the number of times a workflow is iterated. By default, this parameter is set to "0". Note that "0" does not mean "no iterations." Rather, "0" means that the workflow will iterate forever. Values greater than zero specify the actual number of times the director should execute the entire workflow. </configure></property>
+<property name="prop:maximumReceiverCapacity" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A Parameter representing the maximum capacity of each receiver controlled by this director. This is an integer that defaults to 0, which means the queue in each receiver is unbounded. To specify bounded queues, set this to a positive integer. </configure></property>
 <property name="prop:runUntilDeadlockInOneIteration" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A parameter indicating whether one iteration consists of repeated basic iterations until deadlock. If this parameter is true, the model will be executed until deadlock in one iteration. The default value is a BooleanToken with the value false. It cannot be set to true if this director is at the top level.</configure></property>
 </property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org:director:5:1">
         </property>
@@ -1452,14 +1452,14 @@
         <property name="_location" class="ptolemy.kernel.util.Location" value="[-530.0, -20.0]">
         </property>
     </property>
-    <property name="RAWDATA_DIR" class="ptolemy.data.expr.FileParameter" value="$ROOT_DATA_DIR/reflex_input/kmos">
+    <property name="RAW_DATA_DIR" class="ptolemy.data.expr.FileParameter" value="$ROOT_DATA_DIR/reflex_input/kmos">
 <property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
 <property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>none</configure></property>
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>yang zhao, edward lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>none</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The FileParameter specifies a file or URL. The value of the parameter is a string that may contain references to variables within scope (i.e., variables defined at the same level of the hierarchy or higher) using the $ID ${ID}, or $(ID) syntax. </p>

<p>Change the name of the FileParameter to better identify the file it specifies (right-click the parameter and [...]
 <property name="prop:fileParameter" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The specified file or URL.</configure></property>
-</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org:actor:422:1">
+</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:44:1">
         </property>
         <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.FileParameter">
             <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1186:1">
@@ -1498,6 +1498,8 @@
         </property>
         <property name="allowDirectories" class="ptolemy.data.expr.Parameter" value="true">
         </property>
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:422:1">
+        </property>
     </property>
     <property name="Annotation19" class="ptolemy.vergil.kernel.attributes.TextAttribute">
         <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
@@ -1699,7 +1701,7 @@
         </property>
         <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 165.0]">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 160.0]">
         </property>
         <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
         </property>
@@ -1748,7 +1750,7 @@
         </property>
         <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#WorkflowDocumentation">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[770.0, 175.0]">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[770.0, 165.0]">
         </property>
         <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:436:1:urn:lsid:kepler-project.org/ns/:16482:52:1:urn:lsid:kepler-project.org/ns/:16989:16:1:urn:lsid:kepler-project.org/ns/:18725:2:3">
         </property>
@@ -2023,11 +2025,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
-<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -2184,11 +2186,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
-<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -2269,11 +2271,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
-<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
 <property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -2336,7 +2338,7 @@
         </property>
         <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#WorkflowDocumentation">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[785.0, 410.0]">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[775.0, 350.0]">
         </property>
         <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:436:1:urn:lsid:kepler-project.org/ns/:43289:29:1">
         </property>
@@ -2372,11 +2374,194 @@
         </property>
         <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 400.0]">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 340.0]">
+        </property>
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
+        </property>
+    </property>
+    <property name="Rectangle8" class="ptolemy.vergil.kernel.attributes.RectangleAttribute">
+        <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
+        </property>
+        <property name="_hideAllParameters" class="ptolemy.data.expr.Parameter" value="true">
+        </property>
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[920.0, 865.0]">
+        </property>
+        <property name="lineWidth" class="ptolemy.data.expr.Parameter" value="5">
+        </property>
+        <property name="lineColor" class="ptolemy.actor.gui.ColorAttribute" value="{1.0,0.5,0.0,1.0}">
+        </property>
+        <property name="width" class="ptolemy.data.expr.Parameter" value="94.0">
+        </property>
+        <property name="height" class="ptolemy.data.expr.Parameter" value="65.0">
+        </property>
+        <property name="centered" class="ptolemy.data.expr.Parameter" value="false">
+        </property>
+        <property name="fillColor" class="ptolemy.actor.gui.ColorAttribute" value="{1.0,0.5,0.0,1.0}">
+        </property>
+        <property name="rounding" class="ptolemy.data.expr.Parameter" value="0.0">
+        </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
+<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
+<property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
+<property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
+</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:55:3">
+        </property>
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.vergil.kernel.attributes.RectangleAttribute">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1197:1">
+            </property>
+        </property>
+        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#DecorativeActor">
+        </property>
+        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#WorkflowDocumentation">
+        </property>
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:434:1:urn:lsid:kepler-project.org/ns/:13961:219:11:urn:lsid:kepler-project.org/ns/:25158:19:2">
+        </property>
+        <property name="_renderFirst" class="ptolemy.kernel.util.SingletonAttribute">
+        </property>
+    </property>
+    <property name="Rectangle9" class="ptolemy.vergil.kernel.attributes.RectangleAttribute">
+        <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
+        </property>
+        <property name="_hideAllParameters" class="ptolemy.data.expr.Parameter" value="true">
+        </property>
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[690.0, 935.0]">
+        </property>
+        <property name="lineWidth" class="ptolemy.data.expr.Parameter" value="5">
+        </property>
+        <property name="lineColor" class="ptolemy.actor.gui.ColorAttribute" value="{1.0,0.5,0.0,1.0}">
+        </property>
+        <property name="width" class="ptolemy.data.expr.Parameter" value="95.0">
+        </property>
+        <property name="height" class="ptolemy.data.expr.Parameter" value="75.0">
+        </property>
+        <property name="centered" class="ptolemy.data.expr.Parameter" value="false">
+        </property>
+        <property name="fillColor" class="ptolemy.actor.gui.ColorAttribute" value="{1.0,0.5,0.0,1.0}">
+        </property>
+        <property name="rounding" class="ptolemy.data.expr.Parameter" value="0.0">
+        </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
+<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
+<property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
+<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
+<property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
+<property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
+<property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
+</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:34:1">
+        </property>
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.vergil.kernel.attributes.RectangleAttribute">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1197:1">
+            </property>
+        </property>
+        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#DecorativeActor">
+        </property>
+        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#WorkflowDocumentation">
+        </property>
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:434:1:urn:lsid:kepler-project.org/ns/:13961:219:11:urn:lsid:kepler-project.org/ns/:25158:19:2:urn:lsid:kepler-project.org/ns/:43289:55:3">
+        </property>
+        <property name="_renderFirst" class="ptolemy.kernel.util.SingletonAttribute">
+        </property>
+    </property>
+    <property name="SelectDatasetMethod" class="ptolemy.data.expr.StringParameter" value="Interactive">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:5:2">
+        </property>
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+            </property>
+        </property>
+        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+        </property>
+        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+        </property>
+        <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+        </property>
+        <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+            <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+            </property>
+        </property>
+        <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+            <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+        </property>
+        <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+        </property>
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[745.0, 385.0]">
         </property>
         <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
         </property>
     </property>
+    <property name="Annotation9" class="ptolemy.vergil.kernel.attributes.TextAttribute">
+        <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
+        </property>
+        <property name="_hideAllParameters" class="ptolemy.data.expr.Parameter" value="true">
+        </property>
+        <property name="textSize" class="ptolemy.data.expr.Parameter" value="14">
+        </property>
+        <property name="textColor" class="ptolemy.actor.gui.ColorAttribute" value="{0.4,0.4,0.0,1.0}">
+        </property>
+        <property name="fontFamily" class="ptolemy.data.expr.StringParameter" value="SansSerif">
+        </property>
+        <property name="bold" class="ptolemy.data.expr.Parameter" value="false">
+        </property>
+        <property name="italic" class="ptolemy.data.expr.Parameter" value="false">
+        </property>
+        <property name="text" class="ptolemy.kernel.util.StringAttribute" value="Data Selection Method (Interactive, All, Complete, Incomplete)">
+            <property name="_style" class="ptolemy.actor.gui.style.TextStyle">
+                <property name="height" class="ptolemy.data.expr.Parameter" value="20">
+                </property>
+                <property name="width" class="ptolemy.data.expr.Parameter" value="80">
+                </property>
+            </property>
+        </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Use the Annotation attribute to annotate a workflow. Double-click the attribute to customize the content, font size, color, and basic formatting (bold and italics).</configure></property>
+<property name="prop:fontFamily" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The font face. Select a font from the drop-down menu. The default is "SansSerif".</configure></property>
+<property name="prop:italic" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Select to indicate that the type should be italics. By default, type will not be italicized.</configure></property>
+<property name="prop:bold" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Select to indicate that the type should be bold. By default, type will not be bold.</configure></property>
+<property name="prop:textColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The font color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
+<property name="prop:textSize" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The font size. Select an integer from the drop-down menu or specify a new size by typing it directly into the value field.  The default is 14.</configure></property>
+<property name="prop:text" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The text of the annotation.</configure></property>
+</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:6:4">
+        </property>
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.vergil.kernel.attributes.TextAttribute">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1199:1">
+            </property>
+        </property>
+        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#DocumentationActor">
+        </property>
+        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#WorkflowDocumentation">
+        </property>
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[775.0, 395.0]">
+        </property>
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:436:1:urn:lsid:kepler-project.org/ns/:43289:29:1">
+        </property>
+    </property>
     <entity name="FitsRouter" class="org.eso.FitsRouter">
 <property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
 <property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
@@ -2575,8 +2760,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets based on the purpose. This smaller sets can then be sent to e.g. a RecipeExecuter</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
 <property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -2621,8 +2806,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the PurposeSerializer (and usually processed by the RecipeExecuter)</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
 <property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -2834,8 +3019,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets based on the purpose. This smaller sets can then be sent to e.g. a RecipeExecuter</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
 <property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -2882,8 +3067,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the PurposeSerializer (and usually processed by the RecipeExecuter)</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
 <property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -2964,180 +3149,6 @@
         <link port="kmo_flat_1.sof in" relation="relation3"/>
         <link port="kmo_flat_1.sof out" relation="relation"/>
     </entity>
-    <entity name="KMOS_SCIENCE_REDUCTION" class="ptolemy.actor.TypedCompositeActor">
-        <display name="KMOS_SCI_RED"/>
-        <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
-        </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:678:7">
-        </property>
-        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
-            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
-            </property>
-        </property>
-        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
-        </property>
-        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
-        </property>
-        <property name="semanticType22" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Workflow">
-        </property>
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
-</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[915.0, 860.0]">
-        </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:15314:200:45:urn:lsid:kepler-project.org/ns/:21155:66:74:urn:lsid:kepler-project.org/ns/:29452:38:14:urn:lsid:kepler-project.org/ns/:21155:435:935:urn:lsid:kepler-project.org/ns/:31617:272:1">
-        </property>
-        <port name="sof_out" class="ptolemy.actor.TypedIOPort">
-            <property name="output"/>
-            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[615.0, -5.0]">
-            </property>
-            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
-            </property>
-        </port>
-        <port name="port" class="ptolemy.actor.TypedIOPort">
-            <property name="input"/>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[-10.0, -5.0]">
-            </property>
-        </port>
-        <entity name="kmo_sci_red_1" class="org.eso.RecipeExecuter">
-            <property name="File Purpose Processing" class="ptolemy.data.expr.StringParameter" value="Set to universal">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[250.0, -75.0]">
-            </property>
-            <port name="sof in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="multiport"/>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-                </property>
-            </port>
-            <port name="sop in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-                </property>
-            </port>
-        </entity>
-        <entity name="SofSplitter2" class="org.eso.SofSplitter">
-            <property name="Group purposes" class="ptolemy.data.expr.Parameter" value="true">
-            </property>
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets, grouping them by purpose. Files with universal purpose are attached to every subset. This smaller sets can then be sent to e.g. a RecipeExecuter. Please refer to the user manual for more information.</configure></property>
-<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
-<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:622:1">
-            </property>
-            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofSplitter">
-                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
-                </property>
-            </property>
-            <property name="semanticType" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[45.0, -25.0]">
-            </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org/ns/:12925:5:1">
-            </property>
-            <port name="sof in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="multiport"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-            </port>
-            <port name="sof out" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="multiport"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-            </port>
-            <port name="#groups" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
-                </property>
-            </port>
-        </entity>
-        <entity name="SofAccumulator2" class="org.eso.SofAccumulator">
-            <property name="same dataset" class="ptolemy.data.expr.Parameter" value="true">
-            </property>
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the SofSplitter (and usually processed by the RecipeExecuter)</configure></property>
-<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
-<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:same dataset" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If true the SofAccumulator throws an error if the input tokens do not belong all to the same dataset</configure></property>
-</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:621:1">
-            </property>
-            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofAccumulator">
-                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
-                </property>
-            </property>
-            <property name="semanticType" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[480.0, -30.0]">
-            </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org/ns/:12925:7:1">
-            </property>
-            <port name="sof in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="multiport"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
-                </property>
-            </port>
-            <port name="#groups" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-                </property>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
-                </property>
-            </port>
-            <port name="sof out" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="multiport"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-            </port>
-        </entity>
-        <relation name="relation7" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <relation name="relation3" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <relation name="relation5" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <relation name="relation" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <relation name="relation2" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <link port="sof_out" relation="relation3"/>
-        <link port="port" relation="relation7"/>
-        <link port="kmo_sci_red_1.sof in" relation="relation"/>
-        <link port="kmo_sci_red_1.sof out" relation="relation5"/>
-        <link port="SofSplitter2.sof in" relation="relation7"/>
-        <link port="SofSplitter2.sof out" relation="relation"/>
-        <link port="SofSplitter2.#groups" relation="relation2"/>
-        <link port="SofAccumulator2.sof in" relation="relation5"/>
-        <link port="SofAccumulator2.#groups" relation="relation2"/>
-        <link port="SofAccumulator2.sof out" relation="relation3"/>
-    </entity>
     <entity name="SofCombiner4" class="org.eso.SofCombiner">
 <property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
 <property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -3187,7 +3198,7 @@
     <entity name="WAVE_CAL" class="ptolemy.actor.TypedCompositeActor">
         <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
         </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:7:1">
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:7:247">
         </property>
         <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
             <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
@@ -3280,78 +3291,6 @@
             <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
             </property>
         </property>
-        <property name="dev_flip" class="ptolemy.data.expr.StringParameter" value="FALSE">
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
-</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:57:1">
-            </property>
-            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
-                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
-                </property>
-            </property>
-            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
-            </property>
-            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
-            </property>
-            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
-            </property>
-            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
-                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
-                </property>
-            </property>
-            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
-                <configure>
-        <svg>
-          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
-        </svg>
-      </configure>
-            </property>
-            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 10.0]">
-            </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
-            </property>
-        </property>
-        <property name="dev_disp" class="ptolemy.data.expr.StringParameter" value="-1.0">
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
-</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:58:2">
-            </property>
-            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
-                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
-                </property>
-            </property>
-            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
-            </property>
-            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
-            </property>
-            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
-            </property>
-            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
-                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
-                </property>
-            </property>
-            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
-                <configure>
-        <svg>
-          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
-        </svg>
-      </configure>
-            </property>
-            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 30.0]">
-            </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
-            </property>
-        </property>
         <property name="suppress_extension" class="ptolemy.data.expr.StringParameter" value="FALSE">
 <property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
 <property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
@@ -3383,7 +3322,7 @@
             </property>
             <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
             </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 50.0]">
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 10.0]">
             </property>
             <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
             </property>
@@ -3419,7 +3358,7 @@
             </property>
             <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
             </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 70.0]">
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 30.0]">
             </property>
             <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
             </property>
@@ -3455,7 +3394,7 @@
             </property>
             <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
             </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 90.0]">
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 50.0]">
             </property>
             <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
             </property>
@@ -3491,12 +3430,12 @@
             </property>
             <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
             </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 110.0]">
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[190.0, 70.0]">
             </property>
             <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
             </property>
         </property>
-        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={327, 103, 1384, 614}, maximized=false}">
+        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={227, 297, 1384, 614}, maximized=false}">
         </property>
         <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[1074, 464]">
         </property>
@@ -3525,8 +3464,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets based on the purpose. This smaller sets can then be sent to e.g. a RecipeExecuter</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
 <property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -3564,103 +3503,47 @@
                 </property>
             </port>
         </entity>
-        <entity name="kmo_wave_cal_1" class="org.eso.RecipeExecuter">
-            <display name="kmo_wave_cal"/>
-            <property name="recipe_param_1" class="ptolemy.data.expr.Parameter" value="order=PORT">
-            </property>
-            <property name="recipe_param_2" class="ptolemy.data.expr.Parameter" value="dev_flip=PORT">
-            </property>
-            <property name="recipe_param_3" class="ptolemy.data.expr.Parameter" value="dev_disp=PORT">
-            </property>
-            <property name="recipe_param_4" class="ptolemy.data.expr.Parameter" value="suppress_extension=PORT">
+        <entity name="RecipeLooper" class="org.eso.RecipeLooper">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The RecipeLooper is an actor designed to allow multiple execution of the same recipe on the same data with different parameters in order to optimize the data reduction.
At the begininning of an iteration it accepts input tokens from the sof in and sop in ports and sends them to the output ports, then it reads tokens from the sof loop and sop loop ports until the token on the iteration [...]
+<property name="port:sof loop" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The loop input sof</configure></property>
+<property name="port:iteration complete" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The signal to terminate the current iteration</configure></property>
+<property name="port:sop in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sop</configure></property>
+<property name="port:sop loop" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The loop input sop</configure></property>
+<property name="port:sop out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sop</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sof</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:41:1">
             </property>
-            <property name="recipe_param_5" class="ptolemy.data.expr.Parameter" value="b_samples=PORT">
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.RecipeLooper">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
             </property>
-            <property name="recipe_param_6" class="ptolemy.data.expr.Parameter" value="b_start=PORT">
+            <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
             </property>
-            <property name="recipe_param_7" class="ptolemy.data.expr.Parameter" value="b_end=PORT">
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[385.0, 290.0]">
             </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[660.0, 300.0]">
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:905:1">
             </property>
             <port name="sof in" class="ptolemy.actor.TypedIOPort">
                 <property name="input"/>
                 <property name="multiport"/>
                 <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
                 </property>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
-                </property>
-                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
                 </property>
             </port>
             <port name="sop in" class="ptolemy.actor.TypedIOPort">
                 <property name="input"/>
                 <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
                 </property>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
-                </property>
-                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-                </property>
-            </port>
-            <port name="logs" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
-                </property>
-            </port>
-            <port name="sof out" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="multiport"/>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
-                </property>
-                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-                </property>
-            </port>
-            <port name="sop out" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
-                </property>
-            </port>
-        </entity>
-        <entity name="RecipeLooper" class="org.eso.RecipeLooper">
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The RecipeLooper is an actor designed to allow multiple execution of the same recipe on the same data with different parameters in order to optimize the data reduction.
At the begininning of an iteration it accepts input tokens from the sof in and sop in ports and sends them to the output ports, then it reads tokens from the sof loop and sop loop ports until the token on the iteration [...]
-<property name="port:iteration complete" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The signal to terminate the current iteration</configure></property>
-<property name="port:sof loop" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The loop input sof</configure></property>
-<property name="port:sop loop" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The loop input sop</configure></property>
-<property name="port:sop in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sop</configure></property>
-<property name="port:sop out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sop</configure></property>
-<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sof</configure></property>
-<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:41:1">
-            </property>
-            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.RecipeLooper">
-                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
-                </property>
-            </property>
-            <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[385.0, 290.0]">
-            </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:905:1">
-            </property>
-            <port name="sof in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="multiport"/>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-                </property>
-                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
-                </property>
-            </port>
-            <port name="sop in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-                </property>
-                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
                 </property>
             </port>
             <port name="sof loop" class="ptolemy.actor.TypedIOPort">
@@ -3850,7 +3733,7 @@
         <entity name="CreateInitialSOP" class="ptolemy.actor.TypedCompositeActor">
             <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
             </property>
-            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:44:40">
+            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:70:2">
             </property>
             <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
                 <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
@@ -3869,7 +3752,7 @@
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
 </property>            <property name="_location" class="ptolemy.kernel.util.Location" value="[240.0, 320.0]">
             </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1">
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:43289:44:40">
             </property>
             <port name="trigger" class="ptolemy.actor.TypedIOPort">
                 <property name="input"/>
@@ -3891,7 +3774,7 @@
                 </property>
             </port>
             <entity name="InitPredictParam" class="ptolemy.actor.lib.StringConst">
-                <property name="value" class="ptolemy.data.expr.Parameter" value="kmo_wave_cal:order=$order
kmo_wave_cal:dev_flip=$dev_flip
kmo_wave_cal:dev_disp=$dev_disp
kmo_wave_cal:suppress_extension=$suppress_extension
kmo_wave_cal:b_samples=$b_samples
kmo_wave_cal:b_start=$b_start
kmo_wave_cal:b_end=$b_end">
+                <property name="value" class="ptolemy.data.expr.Parameter" value="kmo_wave_cal:order=$order
kmo_wave_cal:suppress_extension=$suppress_extension
kmo_wave_cal:b_samples=$b_samples
kmo_wave_cal:b_start=$b_start
kmo_wave_cal:b_end=$b_end">
                     <property name="style" class="ptolemy.actor.gui.style.TextStyle">
                         <property name="height" class="ptolemy.data.expr.Parameter" value="10">
                         </property>
@@ -3912,7 +3795,7 @@
 <property name="port:trigger" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A multiport that has no declared type (in other words, the port can accept any data type: double, int, array, etc.) If the port is connected, the actor will not fire until the trigger port receives an input token. Connecting the port is optional, but useful when scheduling the actor to perform at a certain time. </configure></property>
 <property name="prop:firingCountLimit" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The limit on the number of times the actor will fire. The default value is 'NONE', meaning there is no limit on the number of time the constant will be provided to the output port. Any integer can be provided as a value for this parameter.</configure></property>
 <property name="prop:value" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The value produced by the actor. Specified strings do not require enclosing quotes. (To include a '$' sign in the string, enter '$$'.)</configure></property>
-</property>                <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:47:19">
+</property>                <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:69:1">
                 </property>
                 <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.StringConst">
                     <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1052:1">
@@ -3930,7 +3813,7 @@
                 </property>
                 <property name="_location" class="ptolemy.kernel.util.Location" value="{145, 260}">
                 </property>
-                <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:204:1">
+                <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:204:1:urn:lsid:kepler-project.org/ns/:43289:47:19">
                 </property>
                 <port name="trigger" class="ptolemy.actor.TypedIOPort">
                     <property name="input"/>
@@ -3993,8 +3876,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the PurposeSerializer (and usually processed by the RecipeExecuter)</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
 <property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -4078,6 +3961,49 @@
                 </property>
             </port>
         </entity>
+        <entity name="kmo_wave_cal_1" class="org.eso.RecipeExecuter">
+            <display name="kmo_wave_cal"/>
+            <property name="recipe_param_1" class="ptolemy.data.expr.Parameter" value="order=PORT">
+            </property>
+            <property name="recipe_param_2" class="ptolemy.data.expr.Parameter" value="suppress_extension=PORT">
+            </property>
+            <property name="recipe_param_3" class="ptolemy.data.expr.Parameter" value="b_samples=PORT">
+            </property>
+            <property name="recipe_param_4" class="ptolemy.data.expr.Parameter" value="b_start=PORT">
+            </property>
+            <property name="recipe_param_5" class="ptolemy.data.expr.Parameter" value="b_end=PORT">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[650.0, 290.0]">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sop in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sop out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+            </port>
+        </entity>
         <relation name="relation4" class="ptolemy.actor.TypedIORelation">
         </relation>
         <relation name="relation3" class="ptolemy.actor.TypedIORelation">
@@ -4094,18 +4020,12 @@
             <vertex name="vertex1" value="[475.0, 265.0]">
             </vertex>
         </relation>
-        <relation name="relation8" class="ptolemy.actor.TypedIORelation">
-        </relation>
         <relation name="relation9" class="ptolemy.actor.TypedIORelation">
         </relation>
         <relation name="relation10" class="ptolemy.actor.TypedIORelation">
         </relation>
         <relation name="relation11" class="ptolemy.actor.TypedIORelation">
         </relation>
-        <relation name="relation" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <relation name="relation12" class="ptolemy.actor.TypedIORelation">
-        </relation>
         <relation name="relation13" class="ptolemy.actor.TypedIORelation">
         </relation>
         <relation name="relation5" class="ptolemy.actor.TypedIORelation">
@@ -4114,22 +4034,24 @@
         </relation>
         <relation name="relation15" class="ptolemy.actor.TypedIORelation">
         </relation>
+        <relation name="relation16" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation8" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation" class="ptolemy.actor.TypedIORelation">
+        </relation>
         <link port="sof_in" relation="relation4"/>
         <link port="sof_out" relation="relation5"/>
         <link port="SofSplitter.sof in" relation="relation4"/>
         <link port="SofSplitter.sof out" relation="relation3"/>
         <link port="SofSplitter.#groups" relation="relation6"/>
-        <link port="kmo_wave_cal_1.sof in" relation="relation7"/>
-        <link port="kmo_wave_cal_1.sop in" relation="relation8"/>
-        <link port="kmo_wave_cal_1.sof out" relation="relation"/>
-        <link port="kmo_wave_cal_1.sop out" relation="relation12"/>
         <link port="RecipeLooper.sof in" relation="relation3"/>
         <link port="RecipeLooper.sop in" relation="relation2"/>
         <link port="RecipeLooper.sof loop" relation="relation9"/>
         <link port="RecipeLooper.iteration complete" relation="relation10"/>
         <link port="RecipeLooper.sop loop" relation="relation11"/>
         <link port="RecipeLooper.sof out" relation="relation7"/>
-        <link port="RecipeLooper.sop out" relation="relation8"/>
+        <link port="RecipeLooper.sop out" relation="relation16"/>
         <link port="SetInteractivity.input" relation="relation13"/>
         <link port="PythonActor.out_sof_loop" relation="relation9"/>
         <link port="PythonActor.out_sof" relation="relation14"/>
@@ -4137,8 +4059,8 @@
         <link port="PythonActor.out_sop_loop" relation="relation11"/>
         <link port="PythonActor.enable" relation="relation15"/>
         <link port="PythonActor.in_sof_rec_orig" relation="relation7"/>
-        <link port="PythonActor.in_sof" relation="relation"/>
-        <link port="PythonActor.in_sop" relation="relation12"/>
+        <link port="PythonActor.in_sof" relation="relation8"/>
+        <link port="PythonActor.in_sop" relation="relation"/>
         <link port="PythonActor.set_enable" relation="relation13"/>
         <link port="CreateInitialSOP.trigger" relation="relation3"/>
         <link port="CreateInitialSOP.sop_out" relation="relation2"/>
@@ -4147,12 +4069,16 @@
         <link port="SofAccumulator.sof out" relation="relation5"/>
         <link port="String Constant.output" relation="relation15"/>
         <link port="String Constant.trigger" relation="relation7"/>
+        <link port="kmo_wave_cal_1.sof in" relation="relation7"/>
+        <link port="kmo_wave_cal_1.sop in" relation="relation16"/>
+        <link port="kmo_wave_cal_1.sof out" relation="relation8"/>
+        <link port="kmo_wave_cal_1.sop out" relation="relation"/>
     </entity>
     <entity name="ILLUMINATION" class="ptolemy.actor.TypedCompositeActor">
-        <display name="ILLUMINATION (SKYFLATS)"/>
+        <display name="ILLUMINATION 
(SKYFLATS)"/>
         <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
         </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:427:264">
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:56:1">
         </property>
         <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
             <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
@@ -4171,7 +4097,7 @@
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
 </property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[430.0, 840.0]">
         </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:15314:197:41:urn:lsid:kepler-project.org/ns/:21155:64:67:urn:lsid:kepler-project.org/ns/:29452:30:11">
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:15314:197:41:urn:lsid:kepler-project.org/ns/:21155:64:67:urn:lsid:kepler-project.org/ns/:29452:30:11:urn:lsid:kepler-project.org/ns/:21155:427:264">
         </property>
         <port name="sof_in" class="ptolemy.actor.TypedIOPort">
             <property name="input"/>
@@ -4192,8 +4118,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets based on the purpose. This smaller sets can then be sent to e.g. a RecipeExecuter</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
 <property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -4240,8 +4166,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the PurposeSerializer (and usually processed by the RecipeExecuter)</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
 <property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -4425,7 +4351,7 @@
         <display name="Initialise"/>
         <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="7.0.2">
         </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46342:26:5">
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:50:2">
         </property>
         <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
             <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
@@ -4444,7 +4370,7 @@
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
 </property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[-520.0, 700.0]">
         </property>
-        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={156, 133, 1603, 963}, maximized=false}">
+        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={-1, 0, 1922, 1155}, maximized=true}">
         </property>
         <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[1657, 1009]">
         </property>
@@ -4460,7 +4386,7 @@
             <property name="version" class="ptolemy.kernel.util.StringAttribute" value="null">
             </property>
         </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:14094:70:17:urn:lsid:kepler-project.org/ns/:15314:48:9:urn:lsid:kepler-project.org/ns/:21155:108:26:urn:lsid:kepler-project.org/ns/:29452:63:3">
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:14094:70:17:urn:lsid:kepler-project.org/ns/:15314:48:9:urn:lsid:kepler-project.org/ns/:21155:108:26:urn:lsid:kepler-project.org/ns/:29452:63:3:urn:lsid:kepler-project.org/ns/:46342:26:5">
         </property>
         <property name="Annotation" class="ptolemy.vergil.kernel.attributes.TextAttribute">
             <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
@@ -4521,8 +4447,8 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Gang Zhou</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
            <p> The dynamic dataflow (DDF) domain is a superset of the synchronous
            dataflow(SDF) and Boolean dataflow(BDF) domains. In the SDF domain,
            an actor consumes and produces a fixed number of tokens per firing.
            This static information makes possible compile-time scheduling. In the
            DDF domain, there are few  [...]
-<property name="prop:iterations" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify the number of times a workflow is iterated. By default, this parameter is set to "0". Note that "0" does not mean "no iterations." Rather, "0" means that the workflow will iterate forever. Values greater than zero specify the actual number of times the director should execute the entire workflow. </configure></property>
 <property name="prop:maximumReceiverCapacity" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A Parameter representing the maximum capacity of each receiver controlled by this director. This is an integer that defaults to 0, which means the queue in each receiver is unbounded. To specify bounded queues, set this to a positive integer. </configure></property>
+<property name="prop:iterations" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify the number of times a workflow is iterated. By default, this parameter is set to "0". Note that "0" does not mean "no iterations." Rather, "0" means that the workflow will iterate forever. Values greater than zero specify the actual number of times the director should execute the entire workflow. </configure></property>
 <property name="prop:runUntilDeadlockInOneIteration" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A parameter indicating whether one iteration consists of repeated basic iterations until deadlock. If this parameter is true, the model will be executed until deadlock in one iteration. The default value is a BooleanToken with the value false. It cannot be set to true if this director is at the top level.</configure></property>
 </property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:31989:107:1">
             </property>
@@ -4566,7 +4492,7 @@
             </property>
             <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#LocalInput">
             </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="{696.1733333333523, 571.311666666679}">
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[695.0, 575.0]">
             </property>
             <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
             </property>
@@ -4584,8 +4510,8 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
<p>The ElementsToArray actor reads individual elements via its input port and outputs an array consisting of those elements.</p>

<p>The actor accepts input elements of any one type (int, double, etc.). The type must be consistent. Each time the actor fires, it reads one token from each channel of the input port and outputs a corresponding array.</p>&# [...]
-<property name="port:input" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A multiport that accepts tokens of any one type. The type must be consistent.</configure></property>
 <property name="port:output" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts an assembled array. The type of the array elements matches that of the input.</configure></property>
+<property name="port:input" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A multiport that accepts tokens of any one type. The type must be consistent.</configure></property>
 </property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org:actor:32:1">
             </property>
             <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.ElementsToArray">
@@ -4673,7 +4599,7 @@
             </property>
         </entity>
         <entity name="String Constant2" class="ptolemy.actor.lib.StringConst">
-            <property name="value" class="ptolemy.data.expr.Parameter" value="$RAWDATA_DIR">
+            <property name="value" class="ptolemy.data.expr.Parameter" value="$RAW_DATA_DIR">
             </property>
             <property name="firingCountLimit" class="ptolemy.data.expr.Parameter" value="1">
             </property>
@@ -4688,7 +4614,7 @@
 <property name="port:trigger" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A multiport that has no declared type (in other words, the port can accept any data type: double, int, array, etc.) If the port is connected, the actor will not fire until the trigger port receives an input token. Connecting the port is optional, but useful when scheduling the actor to perform at a certain time. </configure></property>
 <property name="prop:firingCountLimit" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The limit on the number of times the actor will fire. The default value is 'NONE', meaning there is no limit on the number of time the constant will be provided to the output port. Any integer can be provided as a value for this parameter.</configure></property>
 <property name="prop:value" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The value produced by the actor. Specified strings do not require enclosing quotes. (To include a '$' sign in the string, enter '$$'.)</configure></property>
-</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org:actor:204:1">
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:49:1">
             </property>
             <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.StringConst">
                 <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1052:1">
@@ -4706,6 +4632,8 @@
             </property>
             <property name="_location" class="ptolemy.kernel.util.Location" value="{1011.1733333333523, 521.311666666679}">
             </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:204:1">
+            </property>
         </entity>
         <entity name="DirectoryEraser" class="ptolemy.actor.lib.Exec">
             <property name="NONE" class="ptolemy.data.expr.Parameter" value="0">
@@ -4729,10 +4657,10 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Xiaojun Liu, Edward A. Lee, Steve Neuendorffer</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
<p>The External Execution actor executes a system command from a workflow. The actor accepts a command, a directory and environment in which to execute the command, and a command input string. Once the command has finished executing, the actor will output the execution results along with any errors. If no results are generated, the actor will output an empty string.</p>&# [...]
-<property name="port:output" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts data generated by the executed command, output as a string after the command has finished executing. If the command generates no data on standard out, then the empty string (a string of length zero) is generated. </configure></property>
 <property name="port:input" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An input port that accepts strings to pass to the standard input of the subprocess. Note that a newline is not appended to the string. If you require a newline, add one using the AddSubtract actor. This port is an input port of type String.</configure></property>
-<property name="port:error" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts any errors generated by the command execution. Errors are output as a string after the command has finished executing. If the execution generates no errors, an empty string is output. </configure></property>
+<property name="port:output" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts data generated by the executed command, output as a string after the command has finished executing. If the command generates no data on standard out, then the empty string (a string of length zero) is generated. </configure></property>
 <property name="port:trigger" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If connected, a token must be available on this port before actor will execute.</configure></property>
+<property name="port:error" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts any errors generated by the command execution. Errors are output as a string after the command has finished executing. If the execution generates no errors, an empty string is output. </configure></property>
 <property name="port:exitCode" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts the command's exit code. A non-zero value signifies an error.</configure></property>
 <property name="prop:environment" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An array of records that name an environment variable and a value:
 
  {{name = "NAME1", value = "value1"}...}
  
Where NAME1 is the name of the environment variable, and value1 is the value. 
For example, {{name = "PTII", value = "c:/ptII"}} would set the value of the PTII to c:/ptII. 
If the parameter is set to {{name="&quot [...]
 <property name="prop:directory" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The directory in which to execute the command. The default value of this parameter $CWD, which represents the user's current working or home directory. </configure></property>
@@ -4895,7 +4823,7 @@
     <entity name="Data Set Selection" class="ptolemy.actor.TypedCompositeActor">
         <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
         </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:472:2">
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:52:4">
         </property>
         <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
             <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
@@ -4912,9 +4840,9 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
-</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[-520.0, 910.0]">
+</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[-525.0, 895.0]">
         </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:31989:70:2">
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:31989:70:2:urn:lsid:kepler-project.org/ns/:21155:472:2">
         </property>
         <property name="DDF Director" class="ptolemy.domains.ddf.kernel.DDFDirector">
             <property name="iterations" class="ptolemy.data.expr.Parameter" value="0">
@@ -4928,8 +4856,8 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Gang Zhou</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
            <p> The dynamic dataflow (DDF) domain is a superset of the synchronous
            dataflow(SDF) and Boolean dataflow(BDF) domains. In the SDF domain,
            an actor consumes and produces a fixed number of tokens per firing.
            This static information makes possible compile-time scheduling. In the
            DDF domain, there are few  [...]
-<property name="prop:iterations" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify the number of times a workflow is iterated. By default, this parameter is set to "0". Note that "0" does not mean "no iterations." Rather, "0" means that the workflow will iterate forever. Values greater than zero specify the actual number of times the director should execute the entire workflow. </configure></property>
 <property name="prop:maximumReceiverCapacity" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A Parameter representing the maximum capacity of each receiver controlled by this director. This is an integer that defaults to 0, which means the queue in each receiver is unbounded. To specify bounded queues, set this to a positive integer. </configure></property>
+<property name="prop:iterations" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify the number of times a workflow is iterated. By default, this parameter is set to "0". Note that "0" does not mean "no iterations." Rather, "0" means that the workflow will iterate forever. Values greater than zero specify the actual number of times the director should execute the entire workflow. </configure></property>
 <property name="prop:runUntilDeadlockInOneIteration" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A parameter indicating whether one iteration consists of repeated basic iterations until deadlock. If this parameter is true, the model will be executed until deadlock in one iteration. The default value is a BooleanToken with the value false. It cannot be set to true if this director is at the top level.</configure></property>
 </property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:31617:99:1">
             </property>
@@ -4968,11 +4896,13 @@
         </port>
         <entity name="DataSetChooser" class="org.eso.DataSetChooser">
             <display name="Data Set Chooser"/>
+            <property name="Selection mode" class="ptolemy.data.expr.StringParameter" value="$SelectDatasetMethod">
+            </property>
             <property name="FITS Viewer" class="ptolemy.data.expr.StringParameter" value="$FITS_VIEWER">
             </property>
             <property name="Mode" class="ptolemy.data.expr.StringParameter" value="Select">
             </property>
-            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:31617:78:3">
+            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:51:3">
             </property>
             <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.DataSetChooser">
                 <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
@@ -5004,7 +4934,7 @@
             </property>
             <property name="_location" class="ptolemy.kernel.util.Location" value="{85.0, 405.0}">
             </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:workflow:5:1:urn:lsid:kepler-project.org/ns/:12776:6:1:urn:lsid:kepler-project.org/ns/:13961:210:1">
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:workflow:5:1:urn:lsid:kepler-project.org/ns/:12776:6:1:urn:lsid:kepler-project.org/ns/:13961:210:1:urn:lsid:kepler-project.org/ns/:31617:78:3">
             </property>
             <port name="datasets in" class="ptolemy.actor.TypedIOPort">
                 <property name="input"/>
@@ -5091,9 +5021,10 @@
         <link port="Variable Setter.input" relation="relation2"/>
     </entity>
     <entity name="Initialise Current Dataset" class="ptolemy.actor.TypedCompositeActor">
+        <display name="Initialise 
Current 
Dataset"/>
         <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="7.0.2">
         </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46342:38:12">
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:58:1">
         </property>
         <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
             <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
@@ -5110,7 +5041,7 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
-</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[-520.0, 1015.0]">
+</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[-475.0, 1015.0]">
         </property>
         <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={-228, 141, 1321, 809}, maximized=false}">
         </property>
@@ -5128,7 +5059,7 @@
             <property name="version" class="ptolemy.kernel.util.StringAttribute" value="null">
             </property>
         </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:12776:22:11:urn:lsid:kepler-project.org/ns/:2745:94:5:urn:lsid:kepler-project.org/ns/:13757:119:12:urn:lsid:kepler-project.org/ns/:14094:9:50:urn:lsid:kepler-project.org/ns/:15314:21:358:urn:lsid:kepler-project.org/ns/:25158:32:9:urn:lsid:kepler-project.org/ns/:31989:31:7">
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:12776:22:11:urn:lsid:kepler-project.org/ns/:2745:94:5:urn:lsid:kepler-project.org/ns/:13757:119:12:urn:lsid:kepler-project.org/ns/:14094:9:50:urn:lsid:kepler-project.org/ns/:15314:21:358:urn:lsid:kepler-project.org/ns/:25158:32:9:urn:lsid:kepler-project.org/ns/:31989:31:7:urn:lsid:kepler-project.org/ns/:46342:38:12">
         </property>
         <property name="Annotation" class="ptolemy.vergil.kernel.attributes.TextAttribute">
             <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
@@ -5205,11 +5136,11 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The Rectangle attribute renders a rectangle on the Workflow canvas. Single-click the rectangle to drag the resize handles and adjust the shape's size, or double-click the rectangle to customize its height, width, line width, color, and fill color.</p></configure></property>
-<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineWidth" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line width. The value is a double that defaults to 1.0.</configure></property>
-<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
-<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:height" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The vertical extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:dashArray" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify a dash-pattern for dashed or dotted lines. The value consists of an array of doubles that specify the length of the alternating solid and transparent segments. An empty value indicates that the line should not be dashed (the default).</configure></property>
+<property name="prop:centered" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Indicate whether the shape should be centered on its origin. By default, the location is the upper-left corner.</configure></property>
+<property name="prop:rounding" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The amount of rounding of the corners. The value is a double that defaults to 0.0, which indicates no rounding.</configure></property>
 <property name="prop:width" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The horizontal extent. The value is a double that defaults to 100.0.</configure></property>
 <property name="prop:lineColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The line color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. The default is an opaque black, {0.0, 0.0, 0.0, 1.0}</configure></property>
 <property name="prop:fillColor" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The fill color. Specify a string representing an array of four elements: red, green, blue, and alpha, where alpha is transparency. By default, the value is "none."</configure></property>
@@ -5238,8 +5169,8 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Gang Zhou</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
            <p> The dynamic dataflow (DDF) domain is a superset of the synchronous
            dataflow(SDF) and Boolean dataflow(BDF) domains. In the SDF domain,
            an actor consumes and produces a fixed number of tokens per firing.
            This static information makes possible compile-time scheduling. In the
            DDF domain, there are few  [...]
-<property name="prop:maximumReceiverCapacity" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A Parameter representing the maximum capacity of each receiver controlled by this director. This is an integer that defaults to 0, which means the queue in each receiver is unbounded. To specify bounded queues, set this to a positive integer. </configure></property>
 <property name="prop:iterations" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify the number of times a workflow is iterated. By default, this parameter is set to "0". Note that "0" does not mean "no iterations." Rather, "0" means that the workflow will iterate forever. Values greater than zero specify the actual number of times the director should execute the entire workflow. </configure></property>
+<property name="prop:maximumReceiverCapacity" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A Parameter representing the maximum capacity of each receiver controlled by this director. This is an integer that defaults to 0, which means the queue in each receiver is unbounded. To specify bounded queues, set this to a positive integer. </configure></property>
 <property name="prop:runUntilDeadlockInOneIteration" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A parameter indicating whether one iteration consists of repeated basic iterations until deadlock. If this parameter is true, the model will be executed until deadlock in one iteration. The default value is a BooleanToken with the value false. It cannot be set to true if this director is at the top level.</configure></property>
 </property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:31617:88:4">
             </property>
@@ -5450,7 +5381,7 @@
             </port>
         </entity>
         <entity name="Directory Maker" class="org.resurgence.actor.DirectoryMaker">
-            <property name="Directory name" class="ptolemy.actor.parameters.PortParameter" value="/home/yjung/P_kmos/reflex//OUT/2013-10-29T11:50:16/KMOS.2013-06-30T23:48:06.049_tpl">
+            <property name="Directory name" class="ptolemy.actor.parameters.PortParameter" value="/home/yjung/P_kmos/reflex//OUT/2014-02-24T13:23:04/KMOS.2013-06-30T23:48:06.049_tpl">
             </property>
 <property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
 <property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
@@ -5729,7 +5660,7 @@
             </property>
         </entity>
         <entity name="Display" class="ptolemy.actor.lib.gui.Display">
-            <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={1367, 140, 510, 392}, maximized=false}">
+            <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={1092, 193, 510, 392}, maximized=false}">
             </property>
             <property name="_paneSize" class="ptolemy.actor.gui.SizeAttribute" value="[508, 346]">
             </property>
@@ -5849,284 +5780,108 @@
         <link port="3.whole" relation="relation"/>
         <link port="Display.input" relation="relation"/>
     </entity>
-    <entity name="STANDARD_STAR" class="ptolemy.actor.TypedCompositeActor">
-        <display name="STANDARD_STAR 
(TELLURIC)"/>
-        <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
-        </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:427:41">
+    <entity name="SofCombiner5" class="org.eso.SofCombiner">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofCombiner takes as input a number of set of files and combines them into one set of files that contains only the files whose purposes are present in all the input tokens. With this respect empty tokens are ignored and files with universal purpose are always collected</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The combined sof</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:430:103">
         </property>
-        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
-            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofCombiner">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
             </property>
         </property>
-        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
-        </property>
-        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
+        <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
         </property>
-        <property name="semanticType22" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Workflow">
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[155.0, 825.0]">
         </property>
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
-</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[685.0, 980.0]">
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:908:1">
         </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:15314:197:41:urn:lsid:kepler-project.org/ns/:21155:64:67:urn:lsid:kepler-project.org/ns/:29452:30:11">
+        <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
         </property>
-        <port name="sof_in" class="ptolemy.actor.TypedIOPort">
+        <port name="sof in" class="ptolemy.actor.TypedIOPort">
             <property name="input"/>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="{65.0, 165.0}">
+            <property name="multiport"/>
+            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
             </property>
-            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+        </port>
+        <port name="sof in opt" class="ptolemy.actor.TypedIOPort">
+            <property name="input"/>
+            <property name="multiport"/>
+            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+            </property>
+            <property name="_hide" class="ptolemy.data.expr.SingletonParameter" value="true">
             </property>
         </port>
-        <port name="sof_out" class="ptolemy.actor.TypedIOPort">
+        <port name="sof out" class="ptolemy.actor.TypedIOPort">
             <property name="output"/>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="{675.0, 175.0}">
+            <property name="multiport"/>
+            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+            </property>
+            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
             </property>
         </port>
-        <entity name="SofSplitter" class="org.eso.SofSplitter">
+    </entity>
+    <entity name="SofCombiner7" class="org.eso.SofCombiner">
 <property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets based on the purpose. This smaller sets can then be sent to e.g. a RecipeExecuter</configure></property>
-<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofCombiner takes as input a number of set of files and combines them into one set of files that contains only the files whose purposes are present in all the input tokens. With this respect empty tokens are ignored and files with universal purpose are always collected</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The combined sof</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:15314:198:2">
+</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:490:3">
+        </property>
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofCombiner">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
             </property>
-            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofSplitter">
-                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
-                </property>
+        </property>
+        <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+        </property>
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[370.0, 790.0]">
+        </property>
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:908:1">
+        </property>
+        <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
+        </property>
+        <port name="sof in" class="ptolemy.actor.TypedIOPort">
+            <property name="input"/>
+            <property name="multiport"/>
+            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
             </property>
-            <property name="semanticType" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+        </port>
+        <port name="sof in opt" class="ptolemy.actor.TypedIOPort">
+            <property name="input"/>
+            <property name="multiport"/>
+            <property name="_hide" class="ptolemy.data.expr.SingletonParameter" value="true">
             </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="{160.0, 140.0}">
+            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
             </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org/ns/:12925:5:1">
+        </port>
+        <port name="sof out" class="ptolemy.actor.TypedIOPort">
+            <property name="output"/>
+            <property name="multiport"/>
+            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
             </property>
-            <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
-            </property>
-            <port name="sof in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="multiport"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-            </port>
-            <port name="sof out" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="multiport"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-            </port>
-            <port name="#groups" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
-                </property>
-                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-                </property>
-            </port>
-        </entity>
-        <entity name="SofAccumulator" class="org.eso.SofAccumulator">
-            <property name="same dataset" class="ptolemy.data.expr.Parameter" value="true">
-            </property>
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the PurposeSerializer (and usually processed by the RecipeExecuter)</configure></property>
-<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
-<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:same dataset" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If true the SofAccumulator throws an error if the input tokens do not belong all to the same dataset</configure></property>
-</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:15314:199:2">
-            </property>
-            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofAccumulator">
-                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
-                </property>
-            </property>
-            <property name="semanticType" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="{565.0, 150.0}">
-            </property>
-            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org/ns/:12925:7:1">
-            </property>
-            <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
-            </property>
-            <port name="sof in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="multiport"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
-                </property>
-            </port>
-            <port name="#groups" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-                </property>
-                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
-                </property>
-                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-                </property>
-            </port>
-            <port name="sof out" class="ptolemy.actor.TypedIOPort">
-                <property name="output"/>
-                <property name="multiport"/>
-                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
-                </property>
-            </port>
-        </entity>
-        <entity name="kmo_std_star_1" class="org.eso.RecipeExecuter">
-            <property name="Recipe Failure Mode" class="ptolemy.data.expr.StringParameter" value="Continue">
-            </property>
-            <property name="_location" class="ptolemy.kernel.util.Location" value="[345.0, 120.0]">
-            </property>
-            <port name="sof in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="multiport"/>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-                </property>
-            </port>
-            <port name="sop in" class="ptolemy.actor.TypedIOPort">
-                <property name="input"/>
-                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-                </property>
-            </port>
-        </entity>
-        <relation name="relation2" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <relation name="relation4" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <relation name="relation5" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <relation name="relation3" class="ptolemy.actor.TypedIORelation">
-            <vertex name="vertex1" value="[245.0, 140.0]">
-            </vertex>
-        </relation>
-        <relation name="relation" class="ptolemy.actor.TypedIORelation">
-        </relation>
-        <link port="sof_in" relation="relation4"/>
-        <link port="sof_out" relation="relation5"/>
-        <link port="SofSplitter.sof in" relation="relation4"/>
-        <link port="SofSplitter.sof out" relation="relation3"/>
-        <link port="SofSplitter.#groups" relation="relation2"/>
-        <link port="SofAccumulator.sof in" relation="relation"/>
-        <link port="SofAccumulator.#groups" relation="relation2"/>
-        <link port="SofAccumulator.sof out" relation="relation5"/>
-        <link port="kmo_std_star_1.sof in" relation="relation3"/>
-        <link port="kmo_std_star_1.sof out" relation="relation"/>
-    </entity>
-    <entity name="SofCombiner5" class="org.eso.SofCombiner">
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofCombiner takes as input a number of set of files and combines them into one set of files that contains only the files whose purposes are present in all the input tokens. With this respect empty tokens are ignored and files with universal purpose are always collected</configure></property>
-<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The combined sof</configure></property>
-<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:430:103">
-        </property>
-        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofCombiner">
-            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
-            </property>
-        </property>
-        <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
-        </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[155.0, 825.0]">
-        </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:908:1">
-        </property>
-        <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
-        </property>
-        <port name="sof in" class="ptolemy.actor.TypedIOPort">
-            <property name="input"/>
-            <property name="multiport"/>
-            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-            </property>
-        </port>
-        <port name="sof in opt" class="ptolemy.actor.TypedIOPort">
-            <property name="input"/>
-            <property name="multiport"/>
-            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-            </property>
-            <property name="_hide" class="ptolemy.data.expr.SingletonParameter" value="true">
-            </property>
-        </port>
-        <port name="sof out" class="ptolemy.actor.TypedIOPort">
-            <property name="output"/>
-            <property name="multiport"/>
-            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
-            </property>
-            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-            </property>
-        </port>
-    </entity>
-    <entity name="SofCombiner7" class="org.eso.SofCombiner">
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofCombiner takes as input a number of set of files and combines them into one set of files that contains only the files whose purposes are present in all the input tokens. With this respect empty tokens are ignored and files with universal purpose are always collected</configure></property>
-<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The combined sof</configure></property>
-<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:490:3">
-        </property>
-        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofCombiner">
-            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
-            </property>
-        </property>
-        <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
-        </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[370.0, 790.0]">
-        </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:908:1">
-        </property>
-        <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
-        </property>
-        <port name="sof in" class="ptolemy.actor.TypedIOPort">
-            <property name="input"/>
-            <property name="multiport"/>
-            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-            </property>
-        </port>
-        <port name="sof in opt" class="ptolemy.actor.TypedIOPort">
-            <property name="input"/>
-            <property name="multiport"/>
-            <property name="_hide" class="ptolemy.data.expr.SingletonParameter" value="true">
-            </property>
-            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-            </property>
-        </port>
-        <port name="sof out" class="ptolemy.actor.TypedIOPort">
-            <property name="output"/>
-            <property name="multiport"/>
-            <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
-            </property>
-        </port>
-    </entity>
-    <entity name="CompositeActor" class="ptolemy.actor.TypedCompositeActor">
-        <display name="Collapse datacube"/>
-        <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
-        </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:21155:679:95">
-        </property>
-        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
-            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
+        </port>
+    </entity>
+    <entity name="CompositeActor" class="ptolemy.actor.TypedCompositeActor">
+        <display name="Collapse 
Datacube"/>
+        <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
+        </property>
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:57:1">
+        </property>
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
             </property>
         </property>
         <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
@@ -6142,7 +5897,7 @@
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
 </property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[1025.0, 695.0]">
         </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:21155:635:86:urn:lsid:kepler-project.org/ns/:31617:248:133">
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:21155:635:86:urn:lsid:kepler-project.org/ns/:31617:248:133:urn:lsid:kepler-project.org/ns/:21155:679:95">
         </property>
         <property name="DDF Director" class="ptolemy.domains.ddf.kernel.DDFDirector">
             <property name="iterations" class="ptolemy.data.expr.Parameter" value="0">
@@ -6156,8 +5911,8 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Gang Zhou</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
            <p> The dynamic dataflow (DDF) domain is a superset of the synchronous
            dataflow(SDF) and Boolean dataflow(BDF) domains. In the SDF domain,
            an actor consumes and produces a fixed number of tokens per firing.
            This static information makes possible compile-time scheduling. In the
            DDF domain, there are few  [...]
-<property name="prop:maximumReceiverCapacity" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A Parameter representing the maximum capacity of each receiver controlled by this director. This is an integer that defaults to 0, which means the queue in each receiver is unbounded. To specify bounded queues, set this to a positive integer. </configure></property>
 <property name="prop:iterations" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify the number of times a workflow is iterated. By default, this parameter is set to "0". Note that "0" does not mean "no iterations." Rather, "0" means that the workflow will iterate forever. Values greater than zero specify the actual number of times the director should execute the entire workflow. </configure></property>
+<property name="prop:maximumReceiverCapacity" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A Parameter representing the maximum capacity of each receiver controlled by this director. This is an integer that defaults to 0, which means the queue in each receiver is unbounded. To specify bounded queues, set this to a positive integer. </configure></property>
 <property name="prop:runUntilDeadlockInOneIteration" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A parameter indicating whether one iteration consists of repeated basic iterations until deadlock. If this parameter is true, the model will be executed until deadlock in one iteration. The default value is a BooleanToken with the value false. It cannot be set to true if this director is at the top level.</configure></property>
 </property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:31617:262:1">
             </property>
@@ -6304,8 +6059,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets, grouping them by purpose. Files with universal purpose are attached to every subset. This smaller sets can then be sent to e.g. a RecipeExecuter. Please refer to the user manual for more information.</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
 <property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -6348,8 +6103,8 @@
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the SofSplitter (and usually processed by the RecipeExecuter)</configure></property>
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
-<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
 <property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
@@ -6530,8 +6285,8 @@
 <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Shankar Rao, Steve Neuendorffer</configure></property>
 <property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
 <property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
<p>The Repeat actor reads and repeats a "block" of tokens (i.e., one or more tokens of any type). The actor outputs the block a user-specified number of times.</p>

<p>Specify the block size with the blockSize parameter and the number of times to repeat the block with the numberOfTimes parameter.  Note: because the actor reads multiple input tokens [...]
-<property name="port:input" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An input port that accepts tokens of any type. Specify the number of tokens to read at each iteration with the blockSize parameter.</configure></property>
 <property name="port:output" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts the block of tokens the specified number of times. Specify the number of times to repeat the output with the numberOfTimes parameter.</configure></property>
+<property name="port:input" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An input port that accepts tokens of any type. Specify the number of tokens to read at each iteration with the blockSize parameter.</configure></property>
 <property name="prop:blockSize" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of tokens in a block. The value is an integer and must be greater than zero. The default is 1. </configure></property>
 <property name="prop:numberOfTimes" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The repetition factor. The value is an integer and must be greater than 0. The default is 2. </configure></property>
 </property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:31617:269:5">
@@ -6576,8 +6331,8 @@
 <property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
 <property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sof</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:File Purpose Processing" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>how the purpose of the input files will be sent to the output:
<p>Do nothing: leave the input purpose unmodified</p><p>Strip last: remove the last section of the input purpose, if there is only one section set the purpose to universal</p><p>Set to universal: set the output purpose to universal</p></configure></property>
 <property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:File Purpose Processing" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>how the purpose of the input files will be sent to the output:
<p>Do nothing: leave the input purpose unmodified</p><p>Strip last: remove the last section of the input purpose, if there is only one section set the purpose to universal</p><p>Set to universal: set the output purpose to universal</p></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 </property>            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.ModifyPurpose">
                 <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
@@ -6693,6 +6448,7 @@
         <link port="FitsRouter2.SCI_COMBINED" relation="relation12"/>
     </entity>
     <entity name="ProvenanceExplorer" class="org.eso.ProvenanceExplorer">
+        <display name="Provenance
Explorer"/>
         <property name="_location" class="ptolemy.kernel.util.Location" value="[1310.0, 1080.0]">
         </property>
     </entity>
@@ -6741,121 +6497,38 @@
             </property>
         </port>
     </entity>
-    <entity name="ProductRenamer" class="ptolemy.actor.lib.python.PythonScript">
-        <property name="jythonClassName" class="ptolemy.kernel.util.StringAttribute" value="Main">
-        </property>
-        <property name="script" class="ptolemy.kernel.util.StringAttribute" value="import os
import shutil

from ptolemy.data import StringToken, IntToken
from ptolemy.data.expr import Parameter
from org.eso.util import JSONTools
from nom.tam.fits import Fits
from nom.tam.fits import FitsFactory
from ptolemy.kernel.util import IllegalActionException
from org.eso.service import ExecutionServiceDB
import org.apache.log4j
from java.util import Has [...]
+    <entity name="Close DataSet" class="ptolemy.actor.TypedCompositeActor">
+        <display name="Close 
DataSet"/>
+        <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="7.0.2">
         </property>
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Renames recipe products based on FITS keywords</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure> This actor moves (or copies or links) its input sof to a final product directory based on some FITS keywords.
 Usually, it should be connected to the output of the recipes that produce final products. If the recipe produces more products that are not relevant to rename, an output filter can be put in the recipe.</configure></property>
-<property name="port:sof_out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The final list of files produced</configure></property>
-<property name="port:sof_in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The files to be copied/moved or linked</configure></property>
-<property name="prop:RenameKeywords" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The list of keywords used to create the new name</configure></property>
-<property name="prop:OutputExistsMode" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>This parameter defines the behaviour in case the output files already exists: it can be "append_version" (create a new file with a running index suffix), "overwrite" (replace the existing file), "stop" (stop the workflow)</configure></property>
-<property name="prop:script" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:FinalProductDirectory" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The directory where the files are going to be copied/linked or renamed. It is usually set to END_PRODUCTS_DIR</configure></property>
-<property name="prop:SubDir" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If it is not empty, a subdirectory will be created with this string. The value can contain backslashes (and intermediate directories will be created). It will usually be END_PROD_SUBDIR, created somewhere in the workflow</configure></property>
-<property name="prop:CopyMode" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>There are several options: "copy", "move" or "link".</configure></property>
-</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:38241:57:8">
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:55:1">
         </property>
-        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.python.PythonScript">
-            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
             </property>
         </property>
-        <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
         </property>
-        <property name="_editorFactory" class="ptolemy.vergil.toolbox.TextEditorConfigureFactory">
-            <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="script">
-            </property>
+        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
         </property>
-        <property name="_location" class="ptolemy.kernel.util.Location" value="[1250.0, 815.0]">
+        <property name="semanticType22" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Workflow">
         </property>
-        <property name="RenameKeywords" class="ptolemy.data.expr.StringParameter" value="HIERARCH.ESO.OBS.NAME,'_',HIERARCH.ESO.PRO.CATG">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
+</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[1155.0, 1080.0]">
         </property>
-        <property name="FinalProductDirectory" class="ptolemy.data.expr.StringParameter" value="$END_PRODUCTS_DIR">
+        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={616, 37, 1304, 811}, maximized=false}">
         </property>
-        <property name="SubDir" class="ptolemy.data.expr.StringParameter" value="$END_PRODUCTS_SUBDIR">
+        <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[988, 658]">
         </property>
-        <property name="CopyMode" class="ptolemy.data.expr.StringParameter" value="copy">
-        </property>
-        <property name="OutputExistsMode" class="ptolemy.data.expr.StringParameter" value="append_version">
-        </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:910:1:urn:lsid:kepler-project.org/ns/:24723:4:5:urn:lsid:kepler-project.org/ns/:25047:16:2:urn:lsid:kepler-project.org/ns/:25158:50:1">
-        </property>
-        <property name="" class="ptolemy.vergil.basic.DocAttribute">
-            <property name="description" class="ptolemy.kernel.util.StringAttribute" value=" This actor moves (or copies or links) its input sof to a final product directory based on some FITS keywords.
 Usually, it should be connected to the output of the recipes that produce final products. If the recipe produces more products that are not relevant to rename, an output filter can be put in the recipe.">
-            </property>
-            <property name="author" class="ptolemy.kernel.util.StringAttribute" value="ESO">
-            </property>
-            <property name="version" class="ptolemy.kernel.util.StringAttribute" value="2.0">
-            </property>
-            <property name="RenameKeywords (parameter)" class="ptolemy.data.expr.StringParameter" value="The list of keywords used to create the new name">
-            </property>
-            <property name="FinalProductDirectory (parameter)" class="ptolemy.data.expr.StringParameter" value="The directory where the files are going to be copied/linked or renamed. It is usually set to END_PRODUCTS_DIR">
-            </property>
-            <property name="SubDir (parameter)" class="ptolemy.data.expr.StringParameter" value="If it is not empty, a subdirectory will be created with this string. The value can contain backslashes (and intermediate directories will be created). It will usually be END_PROD_SUBDIR, created somewhere in the workflow">
-            </property>
-            <property name="CopyMode (parameter)" class="ptolemy.data.expr.StringParameter" value="There are several options: "copy", "move" or "link".">
-            </property>
-            <property name="OutputExistsMode (parameter)" class="ptolemy.data.expr.StringParameter" value="This parameter defines the behaviour in case the output files already exists: it can be "append_version" (create a new file with a running index suffix), "overwrite" (replace the existing file), "stop" (stop the workflow)">
-            </property>
-            <property name="script (parameter)" class="ptolemy.data.expr.StringParameter" value="">
-            </property>
-            <property name="sof_out (port)" class="ptolemy.kernel.util.StringAttribute" value="The final list of files produced">
-            </property>
-            <property name="sof_in (port)" class="ptolemy.kernel.util.StringAttribute" value="The files to be copied/moved or linked">
-            </property>
-        </property>
-        <property name="BookkeepingDir" class="ptolemy.data.expr.StringParameter" value="$BOOKKEEPING_DIR">
-        </property>
-        <port name="sof_in" class="ptolemy.actor.TypedIOPort">
-            <property name="input"/>
-            <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
-            </property>
-            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
-            </property>
-        </port>
-        <port name="sof_out" class="ptolemy.actor.TypedIOPort">
-            <property name="output"/>
-            <property name="multiport"/>
-            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
-            </property>
-        </port>
-    </entity>
-    <entity name="Close DataSet" class="ptolemy.actor.TypedCompositeActor">
-        <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="7.0.2">
-        </property>
-        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46342:18:1">
-        </property>
-        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
-            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
-            </property>
-        </property>
-        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
-        </property>
-        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
-        </property>
-        <property name="semanticType22" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Workflow">
-        </property>
-<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
-<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
-<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
-<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
-</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[1155.0, 1080.0]">
-        </property>
-        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={616, 37, 1304, 811}, maximized=false}">
-        </property>
-        <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[988, 658]">
-        </property>
-        <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="1.5267529457215">
+        <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="1.5267529457215">
         </property>
         <property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" value="{1284.5625, 895.4900050607288}">
         </property>
-        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:31989:45:2:urn:lsid:kepler-project.org/ns/:43955:74:3:urn:lsid:kepler-project.org/ns/:44497:3:4:urn:lsid:kepler-project.org/ns/:44576:50:16">
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:31989:45:2:urn:lsid:kepler-project.org/ns/:43955:74:3:urn:lsid:kepler-project.org/ns/:44497:3:4:urn:lsid:kepler-project.org/ns/:44576:50:16:urn:lsid:kepler-project.org/ns/:46342:18:1">
         </property>
         <property name="Annotation" class="ptolemy.vergil.kernel.attributes.TextAttribute">
             <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="true">
@@ -7148,7 +6821,7 @@
             </property>
         </entity>
         <entity name="Write README" class="org.geon.FileWrite">
-            <property name="fileName" class="ptolemy.actor.parameters.FilePortParameter" value="/home/yjung/P_kmos/reflex//OUT/2013-10-29T11:50:16/README">
+            <property name="fileName" class="ptolemy.actor.parameters.FilePortParameter" value="/home/yjung/P_kmos/reflex//OUT/2014-02-24T13:23:04/README">
             </property>
             <property name="append" class="ptolemy.data.expr.Parameter" value="true">
             </property>
@@ -7529,8 +7202,8 @@
 <property name="port:text out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A nicely formatted string</configure></property>
 <property name="port:json in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input JSON object</configure></property>
 <property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
-<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:Include Header and Footer" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>if true the output text will contain a descriptive header and footer</configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 <property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
 </property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org:actor:907:1">
             </property>
@@ -7761,98 +7434,3001 @@
         <link port="String Constant9.output" relation="relation16"/>
         <link port="String Constant9.trigger" relation="relation10"/>
     </entity>
-    <relation name="relation2" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
-        </property>
-    </relation>
-    <relation name="relation" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
-        </property>
-    </relation>
-    <relation name="relation5" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
-        </property>
-    </relation>
-    <relation name="relation11" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
-        </property>
-    </relation>
-    <relation name="relation14" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+    <entity name="SCI_RED" class="ptolemy.actor.TypedCompositeActor">
+        <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
         </property>
-    </relation>
-    <relation name="relation23" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:7:216">
         </property>
-    </relation>
-    <relation name="relation15" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
+            </property>
         </property>
-    </relation>
-    <relation name="relation4" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
         </property>
-    </relation>
-    <relation name="relation31" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
         </property>
-    </relation>
-    <relation name="relation40" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="-1">
+        <property name="semanticType22" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Workflow">
         </property>
-        <vertex name="vertex1" value="[1015.0, 780.0]">
-        </vertex>
-    </relation>
-    <relation name="relation13" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
+</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[935.0, 880.0]">
         </property>
-        <vertex name="vertex1" value="[550.0, 855.0]">
-        </vertex>
-    </relation>
-    <relation name="relation3" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:15314:197:41:urn:lsid:kepler-project.org/ns/:21155:64:67:urn:lsid:kepler-project.org/ns/:29452:30:11:urn:lsid:kepler-project.org/ns/:21155:427:153:urn:lsid:kepler-project.org/ns/:43289:40:241:urn:lsid:kepler-project.org/ns/:46309:10:2">
         </property>
-    </relation>
-    <relation name="relation25" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="EnableInteractivity" class="ptolemy.data.expr.StringParameter" value="$GlobalPlotInteractivity">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:53:2">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[25.0, -215.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
+            </property>
         </property>
-        <vertex name="vertex1" value="[-100.0, 740.0]">
-        </vertex>
-    </relation>
-    <relation name="relation16" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="imethod" class="ptolemy.data.expr.StringParameter" value="CS">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:1">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[60.0, -165.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
         </property>
-    </relation>
-    <relation name="relation24" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={256, 42, 1384, 873}, maximized=false}">
         </property>
-        <vertex name="vertex1" value="[110.0, 685.0]">
-        </vertex>
-    </relation>
-    <relation name="relation12" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[1074, 723]">
         </property>
-        <vertex name="vertex1" value="[320.0, 895.0]">
-        </vertex>
-    </relation>
-    <relation name="relation32" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="0.7148199173391064">
         </property>
-        <vertex name="vertex1" value="[135.0, 975.0]">
-        </vertex>
-    </relation>
-    <relation name="relation22" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" value="{763.2381607929516, 277.72177863436127}">
         </property>
-        <vertex name="vertex1" value="[335.0, 975.0]">
-        </vertex>
-    </relation>
-    <relation name="relation17" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        <property name="smethod" class="ptolemy.data.expr.StringParameter" value="CS">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:2">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[60.0, -140.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
         </property>
-        <vertex name="vertex1" value="[560.0, 1070.0]">
-        </vertex>
-    </relation>
+        <property name="fmethod" class="ptolemy.data.expr.StringParameter" value="gauss">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:4">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[60.0, -90.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="method" class="ptolemy.data.expr.StringParameter" value="header">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:3">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[60.0, -115.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="ifus" class="ptolemy.data.expr.StringParameter" value="">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:20">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[60.0, -65.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="neighborhoodRange" class="ptolemy.data.expr.StringParameter" value="1.001">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:23">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[270.0, -165.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="filename" class="ptolemy.data.expr.StringParameter" value="">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:24">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[270.0, -140.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="background" class="ptolemy.data.expr.StringParameter" value="FALSE">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:26">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[270.0, -90.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="flux" class="ptolemy.data.expr.StringParameter" value="FALSE">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:25">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[270.0, -115.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="xcal_interpolation" class="ptolemy.data.expr.StringParameter" value="TRUE">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:29">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[270.0, -65.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="no_subtract" class="ptolemy.data.expr.StringParameter" value="FALSE">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:32">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[470.0, -165.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="b_samples" class="ptolemy.data.expr.StringParameter" value="2048">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:35">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[470.0, -140.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="b_start" class="ptolemy.data.expr.StringParameter" value="-1.0">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:36">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[470.0, -115.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="b_end" class="ptolemy.data.expr.StringParameter" value="-1.0">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:37">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[470.0, -85.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cneg_rej" class="ptolemy.data.expr.StringParameter" value="3.0">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:43">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[650.0, -120.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cpos_rej" class="ptolemy.data.expr.StringParameter" value="3.0">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:42">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[650.0, -145.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cmethod" class="ptolemy.data.expr.StringParameter" value="ksigma">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:41">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[650.0, -170.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="citer" class="ptolemy.data.expr.StringParameter" value="3">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:44">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[650.0, -95.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cmax" class="ptolemy.data.expr.StringParameter" value="1">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:45">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[650.0, -70.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cmin" class="ptolemy.data.expr.StringParameter" value="1">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:46">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[650.0, -45.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="pix_scale" class="ptolemy.data.expr.StringParameter" value="0.2">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:448">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[470.0, -55.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <port name="sof_in" class="ptolemy.actor.TypedIOPort">
+            <property name="input"/>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[64.58446898496243, 121.30194137687971]">
+            </property>
+            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+            </property>
+        </port>
+        <port name="sof_out" class="ptolemy.actor.TypedIOPort">
+            <property name="output"/>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[925.0, 25.0]">
+            </property>
+            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+            </property>
+        </port>
+        <entity name="SofSplitter" class="org.eso.SofSplitter">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets based on the purpose. This smaller sets can then be sent to e.g. a RecipeExecuter</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:65:1">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofSplitter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
+            </property>
+            <property name="semanticType" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[150.0, 90.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org/ns/:12925:5:1:urn:lsid:kepler-project.org/ns/:15314:198:2">
+            </property>
+            <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="false">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </port>
+            <port name="#groups" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+        </entity>
+        <entity name="RecipeLooper" class="org.eso.RecipeLooper">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The RecipeLooper is an actor designed to allow multiple execution of the same recipe on the same data with different parameters in order to optimize the data reduction.
At the begininning of an iteration it accepts input tokens from the sof in and sop in ports and sends them to the output ports, then it reads tokens from the sof loop and sop loop ports until the token on the iteration [...]
+<property name="port:iteration complete" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The signal to terminate the current iteration</configure></property>
+<property name="port:sof loop" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The loop input sof</configure></property>
+<property name="port:sop loop" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The loop input sop</configure></property>
+<property name="port:sop in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sop</configure></property>
+<property name="port:sop out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sop</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sof</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:41:1">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.RecipeLooper">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
+            </property>
+            <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[365.0, 195.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:905:1">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="sop in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="sof loop" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="iteration complete" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+            </port>
+            <port name="sop loop" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+                </property>
+            </port>
+            <port name="sop out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+                </property>
+            </port>
+        </entity>
+        <entity name="SetInteractivity" class="ptolemy.actor.lib.SetVariable">
+            <property name="variableName" class="ptolemy.kernel.util.StringAttribute" value="EnableInteractivity">
+            </property>
+            <property name="delayed" class="ptolemy.data.expr.Parameter" value="false">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward Lee, Steve Neuendorffer, Jerome Blanc</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
Set the value of a variable. The result may occur at two different times, depending on the value of the delayed parameter. 
If delayed is true, then the change to the value of the variable is implemented in a change request, and consequently will not take hold until the end of the current toplevel iteration. This helps ensure that users of value of the variable will see changes t [...]
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:48:4">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.SetVariable">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:886:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Variable">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#LocalInput">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[705.0, 65.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:10:1">
+            </property>
+        </entity>
+        <entity name="PythonActor" class="org.eso.PythonActor">
+            <property name="Python script" class="ptolemy.data.expr.FileParameter" value="@prefix@/share/esopipes/kmos- at VERSION@/reflex/kmo_sci_red.py">
+            </property>
+            <property name="Run in terminal" class="ptolemy.data.expr.Parameter" value="false">
+            </property>
+            <property name="Lazy Mode" class="ptolemy.data.expr.Parameter" value="false">
+            </property>
+            <property name="Recipe Failure Mode" class="ptolemy.data.expr.StringParameter" value="Stop">
+            </property>
+            <property name="Disable logging" class="ptolemy.data.expr.Parameter" value="false">
+            </property>
+            <property name="Products Dir" class="ptolemy.data.expr.FileParameter" value="$TMP_PRODUCTS_DIR">
+                <property name="allowFiles" class="ptolemy.data.expr.Parameter" value="false">
+                </property>
+                <property name="allowDirectories" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </property>
+            <property name="Logs Dir" class="ptolemy.data.expr.FileParameter" value="$LOGS_DIR">
+                <property name="allowFiles" class="ptolemy.data.expr.Parameter" value="false">
+                </property>
+                <property name="allowDirectories" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </property>
+            <property name="Bookkeeping Dir" class="ptolemy.data.expr.FileParameter" value="$BOOKKEEPING_DIR">
+                <property name="allowFiles" class="ptolemy.data.expr.Parameter" value="false">
+                </property>
+                <property name="allowDirectories" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </property>
+            <property name="Clear Products Dir" class="ptolemy.data.expr.StringParameter" value="Never">
+            </property>
+            <property name="Clear Logs Dir" class="ptolemy.data.expr.StringParameter" value="Never">
+            </property>
+            <property name="Clear Bookkeeping Dir" class="ptolemy.data.expr.StringParameter" value="Never">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>This actor executes a Python script</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The PythonActor executes custom python scripts: in order to use a script with this actor you must include the module reflex.py and add a couple of statements to define inputs and outputs (see example.py in the Reflex distribution).
Upon selecting a script, input and output ports are automatically created. If applicable, output tokens are automatically converted to Reflex objects. If t [...]
+<property name="port:stdout" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>This port emits a token containing the standard output generated by the script execution</configure></property>
+<property name="prop:author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:Run in terminal" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If true, the script is invoked through an external xterm, this is needed for scripts that write on the standard output or require standard input (e.g. some pyraf tasks)</configure></property>
+<property name="prop:Python script" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The filename of the script to be executed (full path)</configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:31:1">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.PythonActor">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[615.0, -10.0]">
+            </property>
+            <property name="prop:Disable logging" class="ptolemy.kernel.util.ConfigurableAttribute">
+                <configure>If true, the script does not save the standard output and the standard error of the script execution in the logging directory. This feature is useful if you are using Pyraf and you experience occasional crashes.</configure>
+            </property>
+            <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute">
+                <configure>ESO</configure>
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:904:1:urn:lsid:kepler-project.org/ns/:43289:49:3">
+            </property>
+            <port name="stdout" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_hide" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </port>
+            <port name="out_sop" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+                </property>
+            </port>
+            <port name="out_sof_loop" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="out_sof" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+                </property>
+            </port>
+            <port name="iteration_complete" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+                </property>
+            </port>
+            <port name="out_sop_loop" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="enable" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+            </port>
+            <port name="in_sof_rec_orig" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="in_sof" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+            </port>
+            <port name="in_sop" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+            </port>
+            <port name="set_enable" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+            </port>
+        </entity>
+        <entity name="CreateInitialSOP" class="ptolemy.actor.TypedCompositeActor">
+            <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
+            </property>
+            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:22:12">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
+            </property>
+            <property name="semanticType22" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Workflow">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
+</property>            <property name="_location" class="ptolemy.kernel.util.Location" value="[220.0, 225.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:43289:44:40">
+            </property>
+            <port name="trigger" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_location" class="ptolemy.kernel.util.Location" value="[-115.0, 280.0]">
+                </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="prop:author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>                <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute">
+                    <configure></configure>
+                </property>
+            </port>
+            <port name="sop_out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_location" class="ptolemy.kernel.util.Location" value="[555.0, 365.0]">
+                </property>
+            </port>
+            <entity name="InitPredictParam" class="ptolemy.actor.lib.StringConst">
+                <property name="value" class="ptolemy.data.expr.Parameter" value="kmo_sci_red:imethod=$imethod
kmo_sci_red:smethod=$smethod
kmo_sci_red:method=$method
kmo_sci_red:fmethod=$fmethod
kmo_sci_red:ifus=$ifus
kmo_sci_red:neighborhoodRange=$neighborhoodRange
kmo_sci_red:filename=$filename
kmo_sci_red:flux=$flux
kmo_sci_red:background=$background
kmo_sci_red:xcal_interpolation=$xcal_interpolation
kmo_sci_red:no_subtract=$no_subtract
kmo [...]
+                    <property name="style" class="ptolemy.actor.gui.style.TextStyle">
+                        <property name="height" class="ptolemy.data.expr.Parameter" value="10">
+                        </property>
+                        <property name="width" class="ptolemy.data.expr.Parameter" value="30">
+                        </property>
+                    </property>
+                </property>
+                <property name="firingCountLimit" class="ptolemy.data.expr.Parameter" value="NONE">
+                </property>
+                <property name="NONE" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The StringConstant actor outputs a string specified via the actor's value parameter.</p>

<p>Specifying strings with the StringConstant actor is convenient, as the actor does not require that strings be surrounded by quotes. The actor is often used to specify file paths, which can be selected using the Browse button available in the actor's parameters.</p&g [...]
+<property name="port:output" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts a string constant specified by the value parameter.  </configure></property>
+<property name="port:trigger" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A multiport that has no declared type (in other words, the port can accept any data type: double, int, array, etc.) If the port is connected, the actor will not fire until the trigger port receives an input token. Connecting the port is optional, but useful when scheduling the actor to perform at a certain time. </configure></property>
+<property name="prop:firingCountLimit" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The limit on the number of times the actor will fire. The default value is 'NONE', meaning there is no limit on the number of time the constant will be provided to the output port. Any integer can be provided as a value for this parameter.</configure></property>
+<property name="prop:value" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The value produced by the actor. Specified strings do not require enclosing quotes. (To include a '$' sign in the string, enter '$$'.)</configure></property>
+</property>                <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:21:11">
+                </property>
+                <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.StringConst">
+                    <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1052:1">
+                    </property>
+                </property>
+                <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#StringFunctionActor">
+                </property>
+                <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Constant">
+                </property>
+                <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
+                    <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="value">
+                    </property>
+                    <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
+                    </property>
+                </property>
+                <property name="_location" class="ptolemy.kernel.util.Location" value="[155.0, 385.0]">
+                </property>
+                <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:204:1:urn:lsid:kepler-project.org/ns/:43289:47:19">
+                </property>
+                <port name="trigger" class="ptolemy.actor.TypedIOPort">
+                    <property name="input"/>
+                    <property name="multiport"/>
+                    <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                    </property>
+                </port>
+            </entity>
+            <entity name="SopCreator" class="org.eso.SopCreator">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>It reads a formatted string and converts it to an SoP.</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SoPCreator reads a formatted string and converts it into an SoP.
The input string must be a list of tokens in the following format: recipe_name:par_name=value separated by either a comma or a newline</configure></property>
+<property name="port:sop out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sop</configure></property>
+<property name="port:param in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input string</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>                <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org:actor:909:1">
+                </property>
+                <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SopCreator">
+                    <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                    </property>
+                </property>
+                <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+                </property>
+                <property name="_location" class="ptolemy.kernel.util.Location" value="[455.0, 330.0]">
+                </property>
+                <port name="param in" class="ptolemy.actor.TypedIOPort">
+                    <property name="input"/>
+                    <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                    </property>
+                </port>
+                <port name="sop out" class="ptolemy.actor.TypedIOPort">
+                    <property name="output"/>
+                    <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                    </property>
+                </port>
+            </entity>
+            <relation name="relation" class="ptolemy.actor.TypedIORelation">
+            </relation>
+            <relation name="relation2" class="ptolemy.actor.TypedIORelation">
+            </relation>
+            <relation name="relation3" class="ptolemy.actor.TypedIORelation">
+            </relation>
+            <link port="trigger" relation="relation"/>
+            <link port="sop_out" relation="relation3"/>
+            <link port="InitPredictParam.output" relation="relation2"/>
+            <link port="InitPredictParam.trigger" relation="relation"/>
+            <link port="SopCreator.param in" relation="relation2"/>
+            <link port="SopCreator.sop out" relation="relation3"/>
+        </entity>
+        <entity name="SofAccumulator" class="org.eso.SofAccumulator">
+            <property name="same dataset" class="ptolemy.data.expr.Parameter" value="true">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the PurposeSerializer (and usually processed by the RecipeExecuter)</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:same dataset" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If true the SofAccumulator throws an error if the input tokens do not belong all to the same dataset</configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:50:4">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofAccumulator">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
+            </property>
+            <property name="semanticType" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[825.0, -5.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org/ns/:12925:7:1:urn:lsid:kepler-project.org/ns/:15314:199:2">
+            </property>
+            <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="false">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+            </port>
+            <port name="#groups" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </port>
+        </entity>
+        <entity name="String Constant" class="ptolemy.actor.lib.StringConst">
+            <property name="value" class="ptolemy.data.expr.Parameter" value="$EnableInteractivity">
+            </property>
+            <property name="firingCountLimit" class="ptolemy.data.expr.Parameter" value="NONE">
+            </property>
+            <property name="NONE" class="ptolemy.data.expr.Parameter" value="0">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The StringConstant actor outputs a string specified via the actor's value parameter.</p>

<p>Specifying strings with the StringConstant actor is convenient, as the actor does not require that strings be surrounded by quotes. The actor is often used to specify file paths, which can be selected using the Browse button available in the actor's parameters.</p&g [...]
+<property name="port:output" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts a string constant specified by the value parameter.  </configure></property>
+<property name="port:trigger" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A multiport that has no declared type (in other words, the port can accept any data type: double, int, array, etc.) If the port is connected, the actor will not fire until the trigger port receives an input token. Connecting the port is optional, but useful when scheduling the actor to perform at a certain time. </configure></property>
+<property name="prop:firingCountLimit" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The limit on the number of times the actor will fire. The default value is 'NONE', meaning there is no limit on the number of time the constant will be provided to the output port. Any integer can be provided as a value for this parameter.</configure></property>
+<property name="prop:value" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The value produced by the actor. Specified strings do not require enclosing quotes. (To include a '$' sign in the string, enter '$$'.)</configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:51:2">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.StringConst">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1052:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#StringFunctionActor">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Constant">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
+                <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="value">
+                </property>
+                <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
+                </property>
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[545.0, 110.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:204:1">
+            </property>
+            <port name="trigger" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+        </entity>
+        <entity name="kmo_sci_red_1" class="org.eso.RecipeExecuter">
+            <display name="kmo_sci_red"/>
+            <property name="recipe_param_1" class="ptolemy.data.expr.Parameter" value="imethod=PORT">
+            </property>
+            <property name="recipe_param_2" class="ptolemy.data.expr.Parameter" value="smethod=PORT">
+            </property>
+            <property name="recipe_param_3" class="ptolemy.data.expr.Parameter" value="method=PORT">
+            </property>
+            <property name="recipe_param_4" class="ptolemy.data.expr.Parameter" value="fmethod=PORT">
+            </property>
+            <property name="recipe_param_6" class="ptolemy.data.expr.Parameter" value="ifus=PORT">
+            </property>
+            <property name="recipe_param_7" class="ptolemy.data.expr.Parameter" value="pix_scale=PORT">
+            </property>
+            <property name="recipe_param_9" class="ptolemy.data.expr.Parameter" value="neighborhoodRange=PORT">
+            </property>
+            <property name="recipe_param_10" class="ptolemy.data.expr.Parameter" value="filename=PORT">
+            </property>
+            <property name="recipe_param_11" class="ptolemy.data.expr.Parameter" value="flux=PORT">
+            </property>
+            <property name="recipe_param_12" class="ptolemy.data.expr.Parameter" value="background=PORT">
+            </property>
+            <property name="recipe_param_15" class="ptolemy.data.expr.Parameter" value="xcal_interpolation=PORT">
+            </property>
+            <property name="recipe_param_18" class="ptolemy.data.expr.Parameter" value="no_subtract=PORT">
+            </property>
+            <property name="recipe_param_21" class="ptolemy.data.expr.Parameter" value="b_samples=PORT">
+            </property>
+            <property name="recipe_param_22" class="ptolemy.data.expr.Parameter" value="b_start=PORT">
+            </property>
+            <property name="recipe_param_23" class="ptolemy.data.expr.Parameter" value="b_end=PORT">
+            </property>
+            <property name="recipe_param_27" class="ptolemy.data.expr.Parameter" value="cmethod=PORT">
+            </property>
+            <property name="recipe_param_28" class="ptolemy.data.expr.Parameter" value="cpos_rej=PORT">
+            </property>
+            <property name="recipe_param_29" class="ptolemy.data.expr.Parameter" value="cneg_rej=PORT">
+            </property>
+            <property name="recipe_param_30" class="ptolemy.data.expr.Parameter" value="citer=PORT">
+            </property>
+            <property name="recipe_param_31" class="ptolemy.data.expr.Parameter" value="cmax=PORT">
+            </property>
+            <property name="recipe_param_32" class="ptolemy.data.expr.Parameter" value="cmin=PORT">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[635.0, 195.0]">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sop in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sop out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+            </port>
+        </entity>
+        <relation name="relation4" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation3" class="ptolemy.actor.TypedIORelation">
+            <vertex name="vertex1" value="[205.0, 165.0]">
+            </vertex>
+        </relation>
+        <relation name="relation6" class="ptolemy.actor.TypedIORelation">
+            <vertex name="vertex1" value="[810.0, 310.0]">
+            </vertex>
+        </relation>
+        <relation name="relation2" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation7" class="ptolemy.actor.TypedIORelation">
+            <vertex name="vertex1" value="[455.0, 170.0]">
+            </vertex>
+        </relation>
+        <relation name="relation9" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation10" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation11" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation13" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation5" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation14" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation15" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation8" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation12" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <link port="sof_in" relation="relation4"/>
+        <link port="sof_out" relation="relation5"/>
+        <link port="SofSplitter.sof in" relation="relation4"/>
+        <link port="SofSplitter.sof out" relation="relation3"/>
+        <link port="SofSplitter.#groups" relation="relation6"/>
+        <link port="RecipeLooper.sof in" relation="relation3"/>
+        <link port="RecipeLooper.sop in" relation="relation2"/>
+        <link port="RecipeLooper.sof loop" relation="relation9"/>
+        <link port="RecipeLooper.iteration complete" relation="relation10"/>
+        <link port="RecipeLooper.sop loop" relation="relation11"/>
+        <link port="RecipeLooper.sof out" relation="relation7"/>
+        <link port="RecipeLooper.sop out" relation="relation8"/>
+        <link port="SetInteractivity.input" relation="relation13"/>
+        <link port="PythonActor.out_sof_loop" relation="relation9"/>
+        <link port="PythonActor.out_sof" relation="relation14"/>
+        <link port="PythonActor.iteration_complete" relation="relation10"/>
+        <link port="PythonActor.out_sop_loop" relation="relation11"/>
+        <link port="PythonActor.enable" relation="relation15"/>
+        <link port="PythonActor.in_sof_rec_orig" relation="relation7"/>
+        <link port="PythonActor.in_sof" relation="relation"/>
+        <link port="PythonActor.in_sop" relation="relation12"/>
+        <link port="PythonActor.set_enable" relation="relation13"/>
+        <link port="CreateInitialSOP.trigger" relation="relation3"/>
+        <link port="CreateInitialSOP.sop_out" relation="relation2"/>
+        <link port="SofAccumulator.sof in" relation="relation14"/>
+        <link port="SofAccumulator.#groups" relation="relation6"/>
+        <link port="SofAccumulator.sof out" relation="relation5"/>
+        <link port="String Constant.output" relation="relation15"/>
+        <link port="String Constant.trigger" relation="relation7"/>
+        <link port="kmo_sci_red_1.sof in" relation="relation7"/>
+        <link port="kmo_sci_red_1.sop in" relation="relation8"/>
+        <link port="kmo_sci_red_1.sof out" relation="relation"/>
+        <link port="kmo_sci_red_1.sop out" relation="relation12"/>
+    </entity>
+    <entity name="STD_STAR" class="ptolemy.actor.TypedCompositeActor">
+        <display name="STD_STAR 
(TELLURIC)"/>
+        <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
+        </property>
+        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:7:209">
+        </property>
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
+            </property>
+        </property>
+        <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
+        </property>
+        <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
+        </property>
+        <property name="semanticType22" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Workflow">
+        </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
+</property>        <property name="_location" class="ptolemy.kernel.util.Location" value="[700.0, 960.0]">
+        </property>
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:15314:197:41:urn:lsid:kepler-project.org/ns/:21155:64:67:urn:lsid:kepler-project.org/ns/:29452:30:11:urn:lsid:kepler-project.org/ns/:21155:427:153:urn:lsid:kepler-project.org/ns/:43289:40:241:urn:lsid:kepler-project.org/ns/:46309:10:2">
+        </property>
+        <property name="EnableInteractivity" class="ptolemy.data.expr.StringParameter" value="$GlobalPlotInteractivity">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:53:2">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[110.0, -140.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1">
+            </property>
+        </property>
+        <property name="imethod" class="ptolemy.data.expr.StringParameter" value="CS">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:1">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[140.0, -70.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={24, 80, 1384, 873}, maximized=false}">
+        </property>
+        <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[1074, 723]">
+        </property>
+        <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="0.7148199173391064">
+        </property>
+        <property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" value="{763.2381607929516, 277.72177863436127}">
+        </property>
+        <property name="fmethod" class="ptolemy.data.expr.StringParameter" value="gauss">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:4">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[140.0, -45.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="neighborhoodRange" class="ptolemy.data.expr.StringParameter" value="1.001">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:23">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[140.0, -20.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="flux" class="ptolemy.data.expr.StringParameter" value="FALSE">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:25">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[365.0, -20.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="startype" class="ptolemy.data.expr.StringParameter" value="FALSE">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:64">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[140.0, -95.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="xcal_interpolation" class="ptolemy.data.expr.StringParameter" value="TRUE">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:29">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[365.0, 5.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="magnitude" class="ptolemy.data.expr.StringParameter" value="FALSE">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:121">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[140.0, 5.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="b_samples" class="ptolemy.data.expr.StringParameter" value="2048">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:35">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[365.0, -100.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="b_start" class="ptolemy.data.expr.StringParameter" value="-1.0">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:36">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[365.0, -75.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="b_end" class="ptolemy.data.expr.StringParameter" value="-1.0">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:37">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[365.0, -50.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cneg_rej" class="ptolemy.data.expr.StringParameter" value="3.0">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:43">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[585.0, -55.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cpos_rej" class="ptolemy.data.expr.StringParameter" value="3.0">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:42">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[585.0, -80.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cmethod" class="ptolemy.data.expr.StringParameter" value="ksigma">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:41">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[585.0, -105.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="citer" class="ptolemy.data.expr.StringParameter" value="3">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:44">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[585.0, -30.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cmax" class="ptolemy.data.expr.StringParameter" value="1">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:45">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[585.0, -5.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <property name="cmin" class="ptolemy.data.expr.StringParameter" value="1">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward A. Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>StringParameter specifies a persistent string. </p>

<p>Change the name of the StringParameter to better identify the specified value (right-click the parameter and select "Customize Name" from the menu). Other actors may refer to the StringParameter using the $NAME syntax (e.g. $Parameter).
</p></configure></property>
+<property name="prop:derivedFrom" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:23:46">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.data.expr.StringParameter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1185:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Parameter">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Parameter">
+            </property>
+            <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+                <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+                </property>
+            </property>
+            <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
+                <configure>
+        <svg>
+          <text x="20" style="font-size:14; font-family:SansSerif; fill:red" y="20">-S-</text>
+        </svg>
+      </configure>
+            </property>
+            <property name="_editorFactory" class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[585.0, 20.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:421:1:urn:lsid:kepler-project.org/ns/:43289:56:1">
+            </property>
+        </property>
+        <port name="sof_in" class="ptolemy.actor.TypedIOPort">
+            <property name="input"/>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[84.58446898496243, 216.3019413768797]">
+            </property>
+            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+            </property>
+        </port>
+        <port name="sof_out" class="ptolemy.actor.TypedIOPort">
+            <property name="output"/>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[945.0, 120.0]">
+            </property>
+            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+            </property>
+        </port>
+        <entity name="SofSplitter" class="org.eso.SofSplitter">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofSplitter takes a set of files as input and split it into smaller sets based on the purpose. This smaller sets can then be sent to e.g. a RecipeExecuter</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sofs</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups generated</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:65:1">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofSplitter">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
+            </property>
+            <property name="semanticType" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[170.0, 185.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org/ns/:12925:5:1:urn:lsid:kepler-project.org/ns/:15314:198:2">
+            </property>
+            <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="false">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </port>
+            <port name="#groups" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+        </entity>
+        <entity name="RecipeLooper" class="org.eso.RecipeLooper">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The RecipeLooper is an actor designed to allow multiple execution of the same recipe on the same data with different parameters in order to optimize the data reduction.
At the begininning of an iteration it accepts input tokens from the sof in and sop in ports and sends them to the output ports, then it reads tokens from the sof loop and sop loop ports until the token on the iteration [...]
+<property name="port:sof loop" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The loop input sof</configure></property>
+<property name="port:iteration complete" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The signal to terminate the current iteration</configure></property>
+<property name="port:sop in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sop</configure></property>
+<property name="port:sop loop" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The loop input sop</configure></property>
+<property name="port:sop out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sop</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sof</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sof</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:41:1">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.RecipeLooper">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
+            </property>
+            <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[385.0, 290.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:905:1">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="sop in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="sof loop" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="iteration complete" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+            </port>
+            <port name="sop loop" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+                </property>
+            </port>
+            <port name="sop out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+                </property>
+            </port>
+        </entity>
+        <entity name="SetInteractivity" class="ptolemy.actor.lib.SetVariable">
+            <property name="variableName" class="ptolemy.kernel.util.StringAttribute" value="EnableInteractivity">
+            </property>
+            <property name="delayed" class="ptolemy.data.expr.Parameter" value="false">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward Lee, Steve Neuendorffer, Jerome Blanc</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>
Set the value of a variable. The result may occur at two different times, depending on the value of the delayed parameter. 
If delayed is true, then the change to the value of the variable is implemented in a change request, and consequently will not take hold until the end of the current toplevel iteration. This helps ensure that users of value of the variable will see changes t [...]
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:48:4">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.SetVariable">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:886:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Variable">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#LocalInput">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[725.0, 160.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:10:1">
+            </property>
+        </entity>
+        <entity name="PythonActor" class="org.eso.PythonActor">
+            <property name="Python script" class="ptolemy.data.expr.FileParameter" value="@prefix@/share/esopipes/kmos- at VERSION@/reflex/kmo_std_star.py">
+            </property>
+            <property name="Run in terminal" class="ptolemy.data.expr.Parameter" value="false">
+            </property>
+            <property name="Lazy Mode" class="ptolemy.data.expr.Parameter" value="false">
+            </property>
+            <property name="Recipe Failure Mode" class="ptolemy.data.expr.StringParameter" value="Stop">
+            </property>
+            <property name="Disable logging" class="ptolemy.data.expr.Parameter" value="false">
+            </property>
+            <property name="Products Dir" class="ptolemy.data.expr.FileParameter" value="$TMP_PRODUCTS_DIR">
+                <property name="allowFiles" class="ptolemy.data.expr.Parameter" value="false">
+                </property>
+                <property name="allowDirectories" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </property>
+            <property name="Logs Dir" class="ptolemy.data.expr.FileParameter" value="$LOGS_DIR">
+                <property name="allowFiles" class="ptolemy.data.expr.Parameter" value="false">
+                </property>
+                <property name="allowDirectories" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </property>
+            <property name="Bookkeeping Dir" class="ptolemy.data.expr.FileParameter" value="$BOOKKEEPING_DIR">
+                <property name="allowFiles" class="ptolemy.data.expr.Parameter" value="false">
+                </property>
+                <property name="allowDirectories" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </property>
+            <property name="Clear Products Dir" class="ptolemy.data.expr.StringParameter" value="Never">
+            </property>
+            <property name="Clear Logs Dir" class="ptolemy.data.expr.StringParameter" value="Never">
+            </property>
+            <property name="Clear Bookkeeping Dir" class="ptolemy.data.expr.StringParameter" value="Never">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>This actor executes a Python script</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The PythonActor executes custom python scripts: in order to use a script with this actor you must include the module reflex.py and add a couple of statements to define inputs and outputs (see example.py in the Reflex distribution).
Upon selecting a script, input and output ports are automatically created. If applicable, output tokens are automatically converted to Reflex objects. If t [...]
+<property name="port:stdout" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>This port emits a token containing the standard output generated by the script execution</configure></property>
+<property name="prop:author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:Run in terminal" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If true, the script is invoked through an external xterm, this is needed for scripts that write on the standard output or require standard input (e.g. some pyraf tasks)</configure></property>
+<property name="prop:Python script" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The filename of the script to be executed (full path)</configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:31:2">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.PythonActor">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[635.0, 85.0]">
+            </property>
+            <property name="prop:Disable logging" class="ptolemy.kernel.util.ConfigurableAttribute">
+                <configure>If true, the script does not save the standard output and the standard error of the script execution in the logging directory. This feature is useful if you are using Pyraf and you experience occasional crashes.</configure>
+            </property>
+            <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute">
+                <configure>ESO</configure>
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:904:1:urn:lsid:kepler-project.org/ns/:43289:49:3">
+            </property>
+            <port name="stdout" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_hide" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </port>
+            <port name="out_sop" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+                </property>
+            </port>
+            <port name="out_sof_loop" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="out_sof" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="EAST">
+                </property>
+            </port>
+            <port name="iteration_complete" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+                </property>
+            </port>
+            <port name="out_sop_loop" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="WEST">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="enable" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+            </port>
+            <port name="in_sof_rec_orig" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="in_sof" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+            </port>
+            <port name="in_sop" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+                </property>
+            </port>
+            <port name="set_enable" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+            </port>
+        </entity>
+        <entity name="CreateInitialSOP" class="ptolemy.actor.TypedCompositeActor">
+            <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel">
+            </property>
+            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:22:10">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.TypedCompositeActor">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:449:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#Actor">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
+            </property>
+            <property name="semanticType22" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Workflow">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Yuhong Xiong</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>A Composite actor is an aggregation of actors. It may have a local director that is responsible for executing the contained actors. A Composite actor with a local director is called an opaque actor. Composite actors do not require a local director. Composite actors with no local director "inherit" the director from the containing workflow and are called non-opaque.</ [...]
+</property>            <property name="_location" class="ptolemy.kernel.util.Location" value="[240.0, 320.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:449:1:urn:lsid:kepler-project.org/ns/:43289:44:40">
+            </property>
+            <port name="trigger" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="_location" class="ptolemy.kernel.util.Location" value="[-115.0, 280.0]">
+                </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="prop:author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>                <property name="author" class="ptolemy.kernel.util.ConfigurableAttribute">
+                    <configure></configure>
+                </property>
+            </port>
+            <port name="sop_out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_location" class="ptolemy.kernel.util.Location" value="[555.0, 365.0]">
+                </property>
+            </port>
+            <entity name="InitPredictParam" class="ptolemy.actor.lib.StringConst">
+                <property name="value" class="ptolemy.data.expr.Parameter" value="kmo_std_star:startype=$startype
kmo_std_star:imethod=$imethod
kmo_std_star:fmethod=$fmethod
kmo_std_star:neighborhoodRange=$neighborhoodRange
kmo_std_star:magnitude=$magnitude
kmo_std_star:flux=$flux
kmo_std_star:xcal_interpolation=$xcal_interpolation
kmo_std_star:b_samples=$b_samples
kmo_std_star:b_start=$b_start
kmo_std_star:b_end=$b_end
kmo_std_star:cmethod=$cmetho [...]
+                    <property name="style" class="ptolemy.actor.gui.style.TextStyle">
+                        <property name="height" class="ptolemy.data.expr.Parameter" value="10">
+                        </property>
+                        <property name="width" class="ptolemy.data.expr.Parameter" value="30">
+                        </property>
+                    </property>
+                </property>
+                <property name="firingCountLimit" class="ptolemy.data.expr.Parameter" value="NONE">
+                </property>
+                <property name="NONE" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The StringConstant actor outputs a string specified via the actor's value parameter.</p>

<p>Specifying strings with the StringConstant actor is convenient, as the actor does not require that strings be surrounded by quotes. The actor is often used to specify file paths, which can be selected using the Browse button available in the actor's parameters.</p&g [...]
+<property name="port:output" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts a string constant specified by the value parameter.  </configure></property>
+<property name="port:trigger" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A multiport that has no declared type (in other words, the port can accept any data type: double, int, array, etc.) If the port is connected, the actor will not fire until the trigger port receives an input token. Connecting the port is optional, but useful when scheduling the actor to perform at a certain time. </configure></property>
+<property name="prop:firingCountLimit" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The limit on the number of times the actor will fire. The default value is 'NONE', meaning there is no limit on the number of time the constant will be provided to the output port. Any integer can be provided as a value for this parameter.</configure></property>
+<property name="prop:value" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The value produced by the actor. Specified strings do not require enclosing quotes. (To include a '$' sign in the string, enter '$$'.)</configure></property>
+</property>                <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:21:9">
+                </property>
+                <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.StringConst">
+                    <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1052:1">
+                    </property>
+                </property>
+                <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#StringFunctionActor">
+                </property>
+                <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Constant">
+                </property>
+                <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
+                    <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="value">
+                    </property>
+                    <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
+                    </property>
+                </property>
+                <property name="_location" class="ptolemy.kernel.util.Location" value="[155.0, 385.0]">
+                </property>
+                <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:204:1:urn:lsid:kepler-project.org/ns/:43289:47:19">
+                </property>
+                <port name="trigger" class="ptolemy.actor.TypedIOPort">
+                    <property name="input"/>
+                    <property name="multiport"/>
+                    <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                    </property>
+                </port>
+            </entity>
+            <entity name="SopCreator" class="org.eso.SopCreator">
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>It reads a formatted string and converts it to an SoP.</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SoPCreator reads a formatted string and converts it into an SoP.
The input string must be a list of tokens in the following format: recipe_name:par_name=value separated by either a comma or a newline</configure></property>
+<property name="port:sop out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The output sop</configure></property>
+<property name="port:param in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input string</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+</property>                <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org:actor:909:1">
+                </property>
+                <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SopCreator">
+                    <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                    </property>
+                </property>
+                <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+                </property>
+                <property name="_location" class="ptolemy.kernel.util.Location" value="[455.0, 330.0]">
+                </property>
+                <port name="param in" class="ptolemy.actor.TypedIOPort">
+                    <property name="input"/>
+                    <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                    </property>
+                </port>
+                <port name="sop out" class="ptolemy.actor.TypedIOPort">
+                    <property name="output"/>
+                    <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                    </property>
+                </port>
+            </entity>
+            <relation name="relation" class="ptolemy.actor.TypedIORelation">
+            </relation>
+            <relation name="relation2" class="ptolemy.actor.TypedIORelation">
+            </relation>
+            <relation name="relation3" class="ptolemy.actor.TypedIORelation">
+            </relation>
+            <link port="trigger" relation="relation"/>
+            <link port="sop_out" relation="relation3"/>
+            <link port="InitPredictParam.output" relation="relation2"/>
+            <link port="InitPredictParam.trigger" relation="relation"/>
+            <link port="SopCreator.param in" relation="relation2"/>
+            <link port="SopCreator.sop out" relation="relation3"/>
+        </entity>
+        <entity name="SofAccumulator" class="org.eso.SofAccumulator">
+            <property name="same dataset" class="ptolemy.data.expr.Parameter" value="true">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The SofAccumulator is meant to be used together with the SofSplitter: it puts back together in a single set of files the tokens generated by the PurposeSerializer (and usually processed by the RecipeExecuter)</configure></property>
+<property name="port:sof in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The input sofs</configure></property>
+<property name="port:#groups" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The number of groups to collect</configure></property>
+<property name="port:sof out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The grouped sof</configure></property>
+<property name="prop:semanticType41" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:entityId" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:class" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:same dataset" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If true the SofAccumulator throws an error if the input tokens do not belong all to the same dataset</configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:50:4">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="org.eso.SofAccumulator">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+                </property>
+            </property>
+            <property name="semanticType" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[845.0, 90.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org/ns/:12925:7:1:urn:lsid:kepler-project.org/ns/:15314:199:2">
+            </property>
+            <property name="_hideName" class="ptolemy.data.expr.SingletonParameter" value="false">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="0">
+                </property>
+            </port>
+            <port name="#groups" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.Parameter" value="true">
+                </property>
+            </port>
+        </entity>
+        <entity name="String Constant" class="ptolemy.actor.lib.StringConst">
+            <property name="value" class="ptolemy.data.expr.Parameter" value="$EnableInteractivity">
+            </property>
+            <property name="firingCountLimit" class="ptolemy.data.expr.Parameter" value="NONE">
+            </property>
+            <property name="NONE" class="ptolemy.data.expr.Parameter" value="0">
+            </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward Lee</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The StringConstant actor outputs a string specified via the actor's value parameter.</p>

<p>Specifying strings with the StringConstant actor is convenient, as the actor does not require that strings be surrounded by quotes. The actor is often used to specify file paths, which can be selected using the Browse button available in the actor's parameters.</p&g [...]
+<property name="port:output" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An output port that broadcasts a string constant specified by the value parameter.  </configure></property>
+<property name="port:trigger" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A multiport that has no declared type (in other words, the port can accept any data type: double, int, array, etc.) If the port is connected, the actor will not fire until the trigger port receives an input token. Connecting the port is optional, but useful when scheduling the actor to perform at a certain time. </configure></property>
+<property name="prop:firingCountLimit" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The limit on the number of times the actor will fire. The default value is 'NONE', meaning there is no limit on the number of time the constant will be provided to the output port. Any integer can be provided as a value for this parameter.</configure></property>
+<property name="prop:value" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The value produced by the actor. Specified strings do not require enclosing quotes. (To include a '$' sign in the string, enter '$$'.)</configure></property>
+</property>            <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:43289:51:2">
+            </property>
+            <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.StringConst">
+                <property name="id" class="ptolemy.kernel.util.StringAttribute" value="urn:lsid:kepler-project.org:class:1052:1">
+                </property>
+            </property>
+            <property name="semanticType00" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:1:1#StringFunctionActor">
+            </property>
+            <property name="semanticType11" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:2:1#Constant">
+            </property>
+            <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
+                <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="value">
+                </property>
+                <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
+                </property>
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[565.0, 205.0]">
+            </property>
+            <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:204:1">
+            </property>
+            <port name="trigger" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="true">
+                </property>
+            </port>
+        </entity>
+        <entity name="kmo_std_star_1" class="org.eso.RecipeExecuter">
+            <display name="kmo_std_star"/>
+            <property name="recipe_param_1" class="ptolemy.data.expr.Parameter" value="startype=PORT">
+            </property>
+            <property name="recipe_param_2" class="ptolemy.data.expr.Parameter" value="imethod=PORT">
+            </property>
+            <property name="recipe_param_3" class="ptolemy.data.expr.Parameter" value="fmethod=PORT">
+            </property>
+            <property name="recipe_param_4" class="ptolemy.data.expr.Parameter" value="neighborhoodRange=PORT">
+            </property>
+            <property name="recipe_param_5" class="ptolemy.data.expr.Parameter" value="magnitude=PORT">
+            </property>
+            <property name="recipe_param_6" class="ptolemy.data.expr.Parameter" value="flux=PORT">
+            </property>
+            <property name="recipe_param_9" class="ptolemy.data.expr.Parameter" value="xcal_interpolation=PORT">
+            </property>
+            <property name="recipe_param_11" class="ptolemy.data.expr.Parameter" value="b_samples=PORT">
+            </property>
+            <property name="recipe_param_12" class="ptolemy.data.expr.Parameter" value="b_start=PORT">
+            </property>
+            <property name="recipe_param_13" class="ptolemy.data.expr.Parameter" value="b_end=PORT">
+            </property>
+            <property name="recipe_param_14" class="ptolemy.data.expr.Parameter" value="cmethod=PORT">
+            </property>
+            <property name="recipe_param_15" class="ptolemy.data.expr.Parameter" value="cpos_rej=PORT">
+            </property>
+            <property name="recipe_param_16" class="ptolemy.data.expr.Parameter" value="cneg_rej=PORT">
+            </property>
+            <property name="recipe_param_17" class="ptolemy.data.expr.Parameter" value="citer=PORT">
+            </property>
+            <property name="recipe_param_18" class="ptolemy.data.expr.Parameter" value="cmax=PORT">
+            </property>
+            <property name="recipe_param_19" class="ptolemy.data.expr.Parameter" value="cmin=PORT">
+            </property>
+            <property name="_location" class="ptolemy.kernel.util.Location" value="[655.0, 290.0]">
+            </property>
+            <port name="sof in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="multiport"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sop in" class="ptolemy.actor.TypedIOPort">
+                <property name="input"/>
+                <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sof out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="multiport"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+                <property name="_showName" class="ptolemy.data.expr.SingletonParameter" value="false">
+                </property>
+            </port>
+            <port name="sop out" class="ptolemy.actor.TypedIOPort">
+                <property name="output"/>
+                <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+                </property>
+            </port>
+        </entity>
+        <relation name="relation4" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation3" class="ptolemy.actor.TypedIORelation">
+            <vertex name="vertex1" value="[225.0, 260.0]">
+            </vertex>
+        </relation>
+        <relation name="relation6" class="ptolemy.actor.TypedIORelation">
+            <vertex name="vertex1" value="[830.0, 405.0]">
+            </vertex>
+        </relation>
+        <relation name="relation2" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation7" class="ptolemy.actor.TypedIORelation">
+            <vertex name="vertex1" value="[475.0, 265.0]">
+            </vertex>
+        </relation>
+        <relation name="relation9" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation10" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation11" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation13" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation5" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation14" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation15" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation8" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation12" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <relation name="relation" class="ptolemy.actor.TypedIORelation">
+        </relation>
+        <link port="sof_in" relation="relation4"/>
+        <link port="sof_out" relation="relation5"/>
+        <link port="SofSplitter.sof in" relation="relation4"/>
+        <link port="SofSplitter.sof out" relation="relation3"/>
+        <link port="SofSplitter.#groups" relation="relation6"/>
+        <link port="RecipeLooper.sof in" relation="relation3"/>
+        <link port="RecipeLooper.sop in" relation="relation2"/>
+        <link port="RecipeLooper.sof loop" relation="relation9"/>
+        <link port="RecipeLooper.iteration complete" relation="relation10"/>
+        <link port="RecipeLooper.sop loop" relation="relation11"/>
+        <link port="RecipeLooper.sof out" relation="relation7"/>
+        <link port="RecipeLooper.sop out" relation="relation8"/>
+        <link port="SetInteractivity.input" relation="relation13"/>
+        <link port="PythonActor.out_sof_loop" relation="relation9"/>
+        <link port="PythonActor.out_sof" relation="relation14"/>
+        <link port="PythonActor.iteration_complete" relation="relation10"/>
+        <link port="PythonActor.out_sop_loop" relation="relation11"/>
+        <link port="PythonActor.enable" relation="relation15"/>
+        <link port="PythonActor.in_sof_rec_orig" relation="relation7"/>
+        <link port="PythonActor.in_sof" relation="relation"/>
+        <link port="PythonActor.in_sop" relation="relation12"/>
+        <link port="PythonActor.set_enable" relation="relation13"/>
+        <link port="CreateInitialSOP.trigger" relation="relation3"/>
+        <link port="CreateInitialSOP.sop_out" relation="relation2"/>
+        <link port="SofAccumulator.sof in" relation="relation14"/>
+        <link port="SofAccumulator.#groups" relation="relation6"/>
+        <link port="SofAccumulator.sof out" relation="relation5"/>
+        <link port="String Constant.output" relation="relation15"/>
+        <link port="String Constant.trigger" relation="relation7"/>
+        <link port="kmo_std_star_1.sof in" relation="relation7"/>
+        <link port="kmo_std_star_1.sop in" relation="relation8"/>
+        <link port="kmo_std_star_1.sof out" relation="relation"/>
+        <link port="kmo_std_star_1.sop out" relation="relation12"/>
+    </entity>
+    <entity name="ProductRenamer" class="ptolemy.actor.lib.python.PythonScript">
+        <display name="Product 
Renamer"/>
+        <property name="jythonClassName" class="ptolemy.kernel.util.StringAttribute" value="Main">
+        </property>
+        <property name="script" class="ptolemy.kernel.util.StringAttribute" value="import os
import shutil

from ptolemy.data import StringToken, IntToken
from ptolemy.data.expr import Parameter
from org.eso.util import JSONTools
from nom.tam.fits import Fits
from nom.tam.fits import FitsFactory
from ptolemy.kernel.util import IllegalActionException
from org.eso.service import ExecutionServiceDB
import org.apache.log4j
from java.util import Has [...]
+        </property>
+<property name="KeplerDocumentation" class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
+<property name="description" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Renames recipe products based on FITS keywords</configure></property>
+<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>ESO</configure></property>
+<property name="version" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>2.0</configure></property>
+<property name="userLevelDocumentation" class="ptolemy.kernel.util.ConfigurableAttribute"><configure> This actor moves (or copies or links) its input sof to a final product directory based on some FITS keywords.
 Usually, it should be connected to the output of the recipes that produce final products. If the recipe produces more products that are not relevant to rename, an output filter can be put in the recipe.</configure></property>
+<property name="port:sof_out" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The final list of files produced</configure></property>
+<property name="port:sof_in" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The files to be copied/moved or linked</configure></property>
+<property name="prop:RenameKeywords" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The list of keywords used to create the new name</configure></property>
+<property name="prop:OutputExistsMode" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>This parameter defines the behaviour in case the output files already exists: it can be "append_version" (create a new file with a running index suffix), "overwrite" (replace the existing file), "stop" (stop the workflow)</configure></property>
+<property name="prop:script" class="ptolemy.kernel.util.ConfigurableAttribute"><configure></configure></property>
+<property name="prop:FinalProductDirectory" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The directory where the files are going to be copied/linked or renamed. It is usually set to END_PRODUCTS_DIR</configure></property>
+<property name="prop:SubDir" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>If it is not empty, a subdirectory will be created with this string. The value can contain backslashes (and intermediate directories will be created). It will usually be END_PROD_SUBDIR, created somewhere in the workflow</configure></property>
+<property name="prop:CopyMode" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>There are several options: "copy", "move" or "link".</configure></property>
+</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" value="urn:lsid:kepler-project.org/ns/:46842:54:1">
+        </property>
+        <property name="class" class="ptolemy.kernel.util.StringAttribute" value="ptolemy.actor.lib.python.PythonScript">
+            <property name="id" class="ptolemy.kernel.util.StringAttribute" value="null">
+            </property>
+        </property>
+        <property name="semanticType41" class="org.kepler.sms.SemanticType" value="urn:lsid:localhost:onto:4:1#ESO">
+        </property>
+        <property name="_editorFactory" class="ptolemy.vergil.toolbox.TextEditorConfigureFactory">
+            <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="script">
+            </property>
+        </property>
+        <property name="_location" class="ptolemy.kernel.util.Location" value="[1235.0, 855.0]">
+        </property>
+        <property name="RenameKeywords" class="ptolemy.data.expr.StringParameter" value="HIERARCH.ESO.OBS.NAME,'_',HIERARCH.ESO.PRO.CATG">
+        </property>
+        <property name="FinalProductDirectory" class="ptolemy.data.expr.StringParameter" value="$END_PRODUCTS_DIR">
+        </property>
+        <property name="SubDir" class="ptolemy.data.expr.StringParameter" value="$END_PRODUCTS_SUBDIR">
+        </property>
+        <property name="CopyMode" class="ptolemy.data.expr.StringParameter" value="copy">
+        </property>
+        <property name="OutputExistsMode" class="ptolemy.data.expr.StringParameter" value="append_version">
+        </property>
+        <property name="derivedFrom" class="org.kepler.moml.NamedObjIdReferralList" value="urn:lsid:kepler-project.org:actor:910:1:urn:lsid:kepler-project.org/ns/:24723:4:5:urn:lsid:kepler-project.org/ns/:25047:16:2:urn:lsid:kepler-project.org/ns/:25158:50:1:urn:lsid:kepler-project.org/ns/:38241:57:8">
+        </property>
+        <property name="" class="ptolemy.vergil.basic.DocAttribute">
+            <property name="description" class="ptolemy.kernel.util.StringAttribute" value=" This actor moves (or copies or links) its input sof to a final product directory based on some FITS keywords.
 Usually, it should be connected to the output of the recipes that produce final products. If the recipe produces more products that are not relevant to rename, an output filter can be put in the recipe.">
+            </property>
+            <property name="author" class="ptolemy.kernel.util.StringAttribute" value="ESO">
+            </property>
+            <property name="version" class="ptolemy.kernel.util.StringAttribute" value="2.0">
+            </property>
+            <property name="RenameKeywords (parameter)" class="ptolemy.data.expr.StringParameter" value="The list of keywords used to create the new name">
+            </property>
+            <property name="FinalProductDirectory (parameter)" class="ptolemy.data.expr.StringParameter" value="The directory where the files are going to be copied/linked or renamed. It is usually set to END_PRODUCTS_DIR">
+            </property>
+            <property name="SubDir (parameter)" class="ptolemy.data.expr.StringParameter" value="If it is not empty, a subdirectory will be created with this string. The value can contain backslashes (and intermediate directories will be created). It will usually be END_PROD_SUBDIR, created somewhere in the workflow">
+            </property>
+            <property name="CopyMode (parameter)" class="ptolemy.data.expr.StringParameter" value="There are several options: "copy", "move" or "link".">
+            </property>
+            <property name="OutputExistsMode (parameter)" class="ptolemy.data.expr.StringParameter" value="This parameter defines the behaviour in case the output files already exists: it can be "append_version" (create a new file with a running index suffix), "overwrite" (replace the existing file), "stop" (stop the workflow)">
+            </property>
+            <property name="script (parameter)" class="ptolemy.data.expr.StringParameter" value="">
+            </property>
+            <property name="sof_out (port)" class="ptolemy.kernel.util.StringAttribute" value="The final list of files produced">
+            </property>
+            <property name="sof_in (port)" class="ptolemy.kernel.util.StringAttribute" value="The files to be copied/moved or linked">
+            </property>
+        </property>
+        <property name="BookkeepingDir" class="ptolemy.data.expr.StringParameter" value="$BOOKKEEPING_DIR">
+        </property>
+        <port name="sof_in" class="ptolemy.actor.TypedIOPort">
+            <property name="input"/>
+            <property name="tokenConsumptionRate" class="ptolemy.data.expr.Parameter" value="1">
+            </property>
+            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="NORTH">
+            </property>
+        </port>
+        <port name="sof_out" class="ptolemy.actor.TypedIOPort">
+            <property name="output"/>
+            <property name="multiport"/>
+            <property name="_cardinal" class="ptolemy.kernel.util.StringAttribute" value="SOUTH">
+            </property>
+        </port>
+    </entity>
+    <relation name="relation2" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation5" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation11" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation14" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation15" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation4" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation31" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation40" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="-1">
+        </property>
+        <vertex name="vertex1" value="[1015.0, 775.0]">
+        </vertex>
+    </relation>
+    <relation name="relation13" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+        <vertex name="vertex1" value="[550.0, 855.0]">
+        </vertex>
+    </relation>
+    <relation name="relation3" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation25" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+        <vertex name="vertex1" value="[-100.0, 740.0]">
+        </vertex>
+    </relation>
+    <relation name="relation16" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+    </relation>
+    <relation name="relation24" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+        <vertex name="vertex1" value="[110.0, 685.0]">
+        </vertex>
+    </relation>
+    <relation name="relation12" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+        <vertex name="vertex1" value="[320.0, 895.0]">
+        </vertex>
+    </relation>
+    <relation name="relation32" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+        <vertex name="vertex1" value="[135.0, 975.0]">
+        </vertex>
+    </relation>
+    <relation name="relation22" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+        <vertex name="vertex1" value="[335.0, 975.0]">
+        </vertex>
+    </relation>
+    <relation name="relation17" class="ptolemy.actor.TypedIORelation">
+        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
+        </property>
+        <vertex name="vertex1" value="[560.0, 1070.0]">
+        </vertex>
+    </relation>
     <relation name="relation18" class="ptolemy.actor.TypedIORelation">
         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
         </property>
@@ -7886,7 +10462,7 @@
     <relation name="relation30" class="ptolemy.actor.TypedIORelation">
         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
         </property>
-        <vertex name="vertex1" value="[780.0, 895.0]">
+        <vertex name="vertex1" value="[770.0, 895.0]">
         </vertex>
     </relation>
     <relation name="relation34" class="ptolemy.actor.TypedIORelation">
@@ -7919,41 +10495,41 @@
         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
         </property>
     </relation>
-    <relation name="relation35" class="ptolemy.actor.TypedIORelation">
+    <relation name="relation10" class="ptolemy.actor.TypedIORelation">
         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
         </property>
     </relation>
-    <relation name="relation7" class="ptolemy.actor.TypedIORelation">
+    <relation name="relation36" class="ptolemy.actor.TypedIORelation">
         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
         </property>
     </relation>
-    <relation name="relation9" class="ptolemy.actor.TypedIORelation">
+    <relation name="relation37" class="ptolemy.actor.TypedIORelation">
         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
         </property>
     </relation>
-    <relation name="relation10" class="ptolemy.actor.TypedIORelation">
+    <relation name="relation41" class="ptolemy.actor.TypedIORelation">
         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
         </property>
     </relation>
-    <relation name="relation8" class="ptolemy.actor.TypedIORelation">
+    <relation name="relation6" class="ptolemy.actor.TypedIORelation">
         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
         </property>
+        <vertex name="vertex1" value="[920.0, 715.0]">
+        </vertex>
     </relation>
-    <relation name="relation28" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
-        </property>
+    <relation name="relation7" class="ptolemy.actor.TypedIORelation">
     </relation>
-    <relation name="relation36" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
-        </property>
+    <relation name="relation9" class="ptolemy.actor.TypedIORelation">
     </relation>
-    <relation name="relation37" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
-        </property>
+    <relation name="relation35" class="ptolemy.actor.TypedIORelation">
     </relation>
-    <relation name="relation41" class="ptolemy.actor.TypedIORelation">
-        <property name="width" class="ptolemy.data.expr.Parameter" value="1">
-        </property>
+    <relation name="relation23" class="ptolemy.actor.TypedIORelation">
+        <vertex name="vertex1" value="[840.7344360351562, 1027.7449035644531]">
+        </vertex>
+    </relation>
+    <relation name="relation42" class="ptolemy.actor.TypedIORelation">
+    </relation>
+    <relation name="relation28" class="ptolemy.actor.TypedIORelation">
     </relation>
     <link port="FitsRouter.in" relation="relation14"/>
     <link port="FitsRouter.DARK" relation="relation4"/>
@@ -7965,6 +10541,7 @@
     <link port="FitsRouter.ARC_STATIC" relation="relation21"/>
     <link port="FitsRouter.WAVE_BAND" relation="relation32"/>
     <link port="FitsRouter.STD_STATIC" relation="relation29"/>
+    <link port="FitsRouter.OH_SPEC" relation="relation23"/>
     <link port="MASTER_DARK.sof_in" relation="relation2"/>
     <link port="MASTER_DARK.sof_out" relation="relation25"/>
     <link port="SofCombiner.sof in" relation="relation16"/>
@@ -7974,14 +10551,13 @@
     <link port="SofCombiner2.sof in" relation="relation13"/>
     <link port="SofCombiner2.sof in" relation="relation30"/>
     <link port="SofCombiner2.sof in" relation="relation33"/>
-    <link port="SofCombiner2.sof in" relation="relation35"/>
+    <link port="SofCombiner2.sof in" relation="relation9"/>
     <link port="SofCombiner2.sof in" relation="relation34"/>
+    <link port="SofCombiner2.sof in" relation="relation23"/>
+    <link port="SofCombiner2.sof out" relation="relation6"/>
     <link port="SofCombiner2.sof out" relation="relation7"/>
-    <link port="SofCombiner2.sof out" relation="relation9"/>
     <link port="LAMP_FLAT.sof_in" relation="relation3"/>
     <link port="LAMP_FLAT.sof_out" relation="relation24"/>
-    <link port="KMOS_SCIENCE_REDUCTION.sof_out" relation="relation40"/>
-    <link port="KMOS_SCIENCE_REDUCTION.port" relation="relation9"/>
     <link port="SofCombiner4.sof in" relation="relation4"/>
     <link port="SofCombiner4.sof out" relation="relation2"/>
     <link port="WAVE_CAL.sof_in" relation="relation15"/>
@@ -7994,7 +10570,7 @@
     <link port="SofCombiner6.sof in" relation="relation38"/>
     <link port="SofCombiner6.sof in" relation="relation29"/>
     <link port="SofCombiner6.sof in" relation="relation17"/>
-    <link port="SofCombiner6.sof out" relation="relation23"/>
+    <link port="SofCombiner6.sof out" relation="relation35"/>
     <link port="DataOrganizer.input data" relation="relation"/>
     <link port="DataOrganizer.datasets out" relation="relation5"/>
     <link port="Initialize.raw_data_dir" relation="relation"/>
@@ -8003,8 +10579,6 @@
     <link port="Initialise Current Dataset.current_dataset" relation="relation41"/>
     <link port="Initialise Current Dataset.dataset_in" relation="relation11"/>
     <link port="Initialise Current Dataset.dataset" relation="relation14"/>
-    <link port="STANDARD_STAR.sof_in" relation="relation23"/>
-    <link port="STANDARD_STAR.sof_out" relation="relation35"/>
     <link port="SofCombiner5.sof in" relation="relation24"/>
     <link port="SofCombiner5.sof in" relation="relation20"/>
     <link port="SofCombiner5.sof in" relation="relation21"/>
@@ -8017,19 +10591,23 @@
     <link port="SofCombiner7.sof in" relation="relation22"/>
     <link port="SofCombiner7.sof out" relation="relation31"/>
     <link port="CompositeActor.output" relation="relation10"/>
-    <link port="CompositeActor.SOF_SCI_RED" relation="relation7"/>
+    <link port="CompositeActor.SOF_SCI_RED" relation="relation6"/>
     <link port="CompositeActor.sci_combined" relation="relation40"/>
     <link port="ProvenanceExplorer.bookkeeping db" relation="relation36"/>
     <link port="ProvenanceExplorer.start date" relation="relation37"/>
     <link port="SofCombiner3.sof in" relation="relation10"/>
     <link port="SofCombiner3.sof in" relation="relation40"/>
-    <link port="SofCombiner3.sof out" relation="relation8"/>
-    <link port="ProductRenamer.sof_in" relation="relation8"/>
-    <link port="ProductRenamer.sof_out" relation="relation28"/>
+    <link port="SofCombiner3.sof out" relation="relation42"/>
     <link port="Close DataSet.current_dataset" relation="relation41"/>
     <link port="Close DataSet.final_files" relation="relation28"/>
     <link port="Close DataSet.bookkeeping_db" relation="relation36"/>
     <link port="Close DataSet.global_timestamp" relation="relation37"/>
+    <link port="SCI_RED.sof_in" relation="relation7"/>
+    <link port="SCI_RED.sof_out" relation="relation40"/>
+    <link port="STD_STAR.sof_in" relation="relation35"/>
+    <link port="STD_STAR.sof_out" relation="relation9"/>
+    <link port="ProductRenamer.sof_in" relation="relation42"/>
+    <link port="ProductRenamer.sof_out" relation="relation28"/>
     <link relation1="relation25" relation2="relation19"/>
     <link relation1="relation24" relation2="relation18"/>
     <link relation1="relation12" relation2="relation27"/>
diff --git a/reflex/kmos_wkf.oca b/reflex/kmos_wkf.oca
index 02efb54..f5997db 100644
--- a/reflex/kmos_wkf.oca
+++ b/reflex/kmos_wkf.oca
@@ -134,7 +134,6 @@ action FLAT
     minRet = 1; maxRet = 1;
     select file as BADPIXEL_DARK_WKF from calibFiles where
         PRO.CATG=="BADPIXEL_DARK_WKF"
-        and EXPTIME >= 30.0 and EXPTIME <= 100.0
         and inputFile.INSTRUME==INSTRUME;
 
     recipe kmo_flat;
@@ -276,7 +275,7 @@ action SCIENCE
     select file as WAVE_BAND from calibFiles where PRO.CATG == "WAVE_BAND";
     
     minRet = 0; maxRet = 1;
-    select file as OH_SPEC from calibFiles where REFLEX.CATG == "OH_SPEC"
+    select file as OH_SPEC from calibFiles where PRO.CATG == "OH_SPEC"
         and inputFile.INS.GRAT1.ID==FILT.ID;
        
     recipe kmo_sci_red{"--imethod=swNN";}
diff --git a/regtests/tests/Makefile.am b/regtests/tests/Makefile.am
index f493e88..d46c913 100644
--- a/regtests/tests/Makefile.am
+++ b/regtests/tests/Makefile.am
@@ -39,6 +39,10 @@ valgrind:
 	esoreg.pl  -valgrind -preload  ../../${PACKAGE}_reg/sof
 
 regcheck:
+	@if test ! -d "${SOF_DATA}" ; then \
+		echo "ERROR: The SOF_DATA environment variable was not set to point to the regression data." 1>&2 ; \
+		exit 1 ; \
+	fi
 	mkdir -p .purifydir
 	@if test -d ../../${PACKAGE}_reg/sof/; then esorex --version ; fi
 	@if test -d ../../${PACKAGE}_reg/sof/; then mkdir -p ../../${PACKAGE}_reg/sof/.purifydir ; fi
@@ -51,6 +55,18 @@ regcheck:
 	@if test "$$?x" != "0x"; then echo FAILED: regtests; fi
 	@if test -d ../../${PACKAGE}_reg/sof/.purifydir; then cp ../../${PACKAGE}_reg/sof/.purifydir/* .purifydir; fi
 
+check:
+	@if test -d /NRI && (echo `hostname` | grep '^vm.*nri$$' > /dev/null 2>&1) && (echo `pwd` | grep '^/disk.*/NRI/DFS' > /dev/null 2>&1) ; then \
+		echo "Detected NRI environment, will run regression tests automatically..." ; \
+		$(MAKE) $(AM_MAKEFLAGS) regcheck ; \
+	else \
+		if test x"${FORCE_REGCHECK}" = xyes ; then \
+			$(MAKE) $(AM_MAKEFLAGS) regcheck ; \
+		else \
+			echo "Skipping regression tests. To execute them, either run 'make regcheck' or set the environment variable FORCE_REGCHECK=yes." ; \
+		fi ; \
+	fi
+
 if PURIFY
 include $(top_builddir)/Makefile.purify
 endif
diff --git a/regtests/tests/Makefile.in b/regtests/tests/Makefile.in
index 25c30f3..90203d3 100644
--- a/regtests/tests/Makefile.in
+++ b/regtests/tests/Makefile.in
@@ -416,6 +416,10 @@ valgrind:
 	esoreg.pl  -valgrind -preload  ../../${PACKAGE}_reg/sof
 
 regcheck:
+	@if test ! -d "${SOF_DATA}" ; then \
+		echo "ERROR: The SOF_DATA environment variable was not set to point to the regression data." 1>&2 ; \
+		exit 1 ; \
+	fi
 	mkdir -p .purifydir
 	@if test -d ../../${PACKAGE}_reg/sof/; then esorex --version ; fi
 	@if test -d ../../${PACKAGE}_reg/sof/; then mkdir -p ../../${PACKAGE}_reg/sof/.purifydir ; fi
@@ -428,6 +432,18 @@ regcheck:
 	@if test "$$?x" != "0x"; then echo FAILED: regtests; fi
 	@if test -d ../../${PACKAGE}_reg/sof/.purifydir; then cp ../../${PACKAGE}_reg/sof/.purifydir/* .purifydir; fi
 
+check:
+	@if test -d /NRI && (echo `hostname` | grep '^vm.*nri$$' > /dev/null 2>&1) && (echo `pwd` | grep '^/disk.*/NRI/DFS' > /dev/null 2>&1) ; then \
+		echo "Detected NRI environment, will run regression tests automatically..." ; \
+		$(MAKE) $(AM_MAKEFLAGS) regcheck ; \
+	else \
+		if test x"${FORCE_REGCHECK}" = xyes ; then \
+			$(MAKE) $(AM_MAKEFLAGS) regcheck ; \
+		else \
+			echo "Skipping regression tests. To execute them, either run 'make regcheck' or set the environment variable FORCE_REGCHECK=yes." ; \
+		fi ; \
+	fi
+
 @PURIFY_TRUE at include $(top_builddir)/Makefile.purify
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/tools/easySPARK/Makefile b/tools/easySPARK/Makefile
index 2563aa0..1131127 100644
--- a/tools/easySPARK/Makefile
+++ b/tools/easySPARK/Makefile
@@ -86,12 +86,12 @@ SCRIPTS = $(dist_bin_SCRIPTS)
 SOURCES =
 DIST_SOURCES =
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/yjung/tmp/kmos-1_2_8/kmosp/admin/missing --run aclocal-1.11
+ACLOCAL = ${SHELL} /home/yjung/rel/kmos-1_3_0/kmosp/admin/missing --run aclocal-1.11
 AMTAR = $${TAR-tar}
 AR = ar
-AUTOCONF = ${SHELL} /home/yjung/tmp/kmos-1_2_8/kmosp/admin/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/yjung/tmp/kmos-1_2_8/kmosp/admin/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/yjung/tmp/kmos-1_2_8/kmosp/admin/missing --run automake-1.11
+AUTOCONF = ${SHELL} /home/yjung/rel/kmos-1_3_0/kmosp/admin/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/yjung/rel/kmos-1_3_0/kmosp/admin/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/yjung/rel/kmos-1_3_0/kmosp/admin/missing --run automake-1.11
 AWK = gawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
@@ -122,15 +122,15 @@ INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-KMOS_BINARY_AGE = 208
-KMOS_BINARY_VERSION = 10208
+KMOS_BINARY_AGE = 300
+KMOS_BINARY_VERSION = 10300
 KMOS_INCLUDES = -I$(top_srcdir)/kmos -I$(top_srcdir)/irplib -I$(top_srcdir)/kmclipm/include
 KMOS_INTERFACE_AGE = 0
 KMOS_LDFLAGS = -L$(top_srcdir)/kmos
 KMOS_MAJOR_VERSION = 1
-KMOS_MICRO_VERSION = 8
-KMOS_MINOR_VERSION = 2
-KMOS_VERSION = 1.2.8
+KMOS_MICRO_VERSION = 0
+KMOS_MINOR_VERSION = 3
+KMOS_VERSION = 1.3.0
 LATEX = /usr/bin/latex
 LD = /usr/bin/ld -m elf_x86_64
 LDFLAGS = 
@@ -153,7 +153,7 @@ LT_AGE = 0
 LT_CURRENT = 0
 LT_REVISION = 0
 MAINT = 
-MAKEINFO = ${SHELL} /home/yjung/tmp/kmos-1_2_8/kmosp/admin/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/yjung/rel/kmos-1_3_0/kmosp/admin/missing --run makeinfo
 MANIFEST_TOOL = :
 MKDIR_P = /bin/mkdir -p
 NM = /usr/bin/nm -B
@@ -163,12 +163,12 @@ OBJEXT = o
 OTOOL = 
 OTOOL64 = 
 PACKAGE = kmos
-PACKAGE_BUGREPORT = kmos-spark at mpe.mpg.de
+PACKAGE_BUGREPORT = usd-help at eso.org
 PACKAGE_NAME = KMOS Instrument Pipeline
-PACKAGE_STRING = KMOS Instrument Pipeline 1.2.8
+PACKAGE_STRING = KMOS Instrument Pipeline 1.3.0
 PACKAGE_TARNAME = kmos
 PACKAGE_URL = 
-PACKAGE_VERSION = 1.2.8
+PACKAGE_VERSION = 1.3.0
 PATH_SEPARATOR = :
 PURIFY_CMD = NONE
 RANLIB = ranlib
@@ -176,11 +176,11 @@ SED = /bin/sed
 SET_MAKE = 
 SHELL = /bin/bash
 STRIP = strip
-VERSION = 1.2.8
-abs_builddir = /home/yjung/tmp/kmos-1_2_8/kmosp/tools/easySPARK
-abs_srcdir = /home/yjung/tmp/kmos-1_2_8/kmosp/tools/easySPARK
-abs_top_builddir = /home/yjung/tmp/kmos-1_2_8/kmosp
-abs_top_srcdir = /home/yjung/tmp/kmos-1_2_8/kmosp
+VERSION = 1.3.0
+abs_builddir = /home/yjung/rel/kmos-1_3_0/kmosp/tools/easySPARK
+abs_srcdir = /home/yjung/rel/kmos-1_3_0/kmosp/tools/easySPARK
+abs_top_builddir = /home/yjung/rel/kmos-1_3_0/kmosp
+abs_top_srcdir = /home/yjung/rel/kmos-1_3_0/kmosp
 ac_ct_AR = ar
 ac_ct_CC = gcc
 ac_ct_DUMPBIN = 
@@ -213,7 +213,7 @@ host_vendor = unknown
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/yjung/tmp/kmos-1_2_8/kmosp/admin/install-sh
+install_sh = ${SHELL} /home/yjung/rel/kmos-1_3_0/kmosp/admin/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cpl-plugin-kmos.git



More information about the debian-science-commits mailing list