Index: src/Helpers/Info.cpp
===================================================================
--- src/Helpers/Info.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/Info.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,43 @@
+/*
+ * Info.cpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/Info.hpp"
+#include "Helpers/Log.hpp"
+#include "Helpers/Verbose.hpp"
+
+int Info::verbosity = 0;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return Info instance
+ */
+Info::Info(const char *msg)
+{
+  verbosity++;
+  FunctionName = msg;
+  DoLog(0) && (Log() << Verbose(0) << "Begin of " << FunctionName << endl);
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+Info::~Info() {
+  DoLog(0) && (Log() << Verbose(0) << "End of " << FunctionName << endl);
+  verbosity--;
+}
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void Info::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
Index: src/Helpers/Info.hpp
===================================================================
--- src/Helpers/Info.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/Info.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,30 @@
+/*
+ * Info.hpp
+ *
+ *  Created on: Nov 25, 2009
+ *      Author: heber
+ */
+
+#ifndef INFO_HPP_
+#define INFO_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+/****************************************** forward declarations *****************************/
+
+/********************************************** definitions *********************************/
+
+class Info {
+public :
+  static int verbosity;
+  const char *FunctionName;
+
+  Info(const char *msg);
+  ~Info();
+  static void setVerbosity(int verbosityLevel);
+
+};
+
+#endif /* INFO_HPP_ */
Index: src/Helpers/Log.cpp
===================================================================
--- src/Helpers/Log.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/Log.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,60 @@
+/*
+ * log.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/logger.hpp"
+#include "Helpers/errorlogger.hpp"
+
+/**
+ * Sets verbosity for the error logger and the standard logger.
+ *
+ * \param int verbosity level
+ */
+void setVerbosity(int verbosityLevel) {
+  logger::getInstance().setVerbosity(verbosityLevel);
+}
+
+/**
+ * Prints a log entry.
+ *
+ * \param indentation level of the message to log
+ */
+class logger& Log() {
+  return logger::getInstance();
+}
+
+/** Checks verbosity for logger.
+ * Is supposed to be used in construct as this:
+ * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
+ * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
+ * \param verbose verbosity level of this message
+ * \return true - print, false - don't
+ */
+bool DoLog(int verbose) {
+  return (verbose <= logger::getInstance().verbosity);
+}
+
+/** Checks verbosity for errorlogger.
+ * Is supposed to be used in construct as this:
+ * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
+ * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
+ * \param verbose verbosity level of this message
+ * \return true - print, false - don't
+ */
+bool DoeLog(int verbose) {
+  return (verbose <= errorLogger::getInstance().verbosity);
+}
+
+/**
+ * Prints an error log entry.
+ *
+ * \param indentation level of the message to log
+ */
+class errorLogger & eLog() {
+  return errorLogger::getInstance();
+}
Index: src/Helpers/Log.hpp
===================================================================
--- src/Helpers/Log.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/Log.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,20 @@
+/*
+ * log.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef LOG_HPP_
+#define LOG_HPP_
+
+#include "Helpers/errorlogger.hpp"
+#include "Helpers/logger.hpp"
+
+class logger * Log();
+class errorLogger * eLog();
+void setVerbosity(int verbosityLevel);
+bool DoLog(int verbose);
+bool DoeLog(int verbose);
+
+#endif /* LOG_HPP_ */
Index: src/Helpers/Makefile.am
===================================================================
--- src/Helpers/Makefile.am	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/Makefile.am	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,70 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+# Position-Independent Code necessary for shared library
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+
+# this includes source files that need to be present at multiple points
+HELPERSSOURCE =  \
+  Assert.cpp \
+  errorlogger.cpp \
+  helpers.cpp \
+  Info.cpp \
+  Log.cpp \
+  logger.cpp \
+  MemDebug.cpp \
+  Verbose.cpp
+
+HELPERSHEADER =  \
+  Assert.hpp \
+  errorlogger.hpp \
+  helpers.hpp \
+  Info.hpp \
+  Log.hpp \
+  logger.hpp \
+  MemDebug.hpp \
+  Verbose.hpp
+
+lib_LTLIBRARIES = libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la
+libMolecuilderHelpers_includedir = $(includedir)/molecuilder-$(MOLECUILDER_API_VERSION)/Actions/
+nobase_libMolecuilderHelpers_include_HEADERS = ${HELPERSHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderHelpers_@MOLECUILDER_API_VERSION@_la_SOURCES = ${HELPERSSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+libMolecuilderHelpers_@MOLECUILDER_API_VERSION@_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+libMolecuilderHelpers_libincludedir = $(libdir)/molecuilder-$(MOLECUILDER_API_VERSION)/include
+nodist_libMolecuilderHelpers_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = $(top_builddir)/molecuilder-$(MOLECUILDER_API_VERSION).pc
+
Index: src/Helpers/Verbose.cpp
===================================================================
--- src/Helpers/Verbose.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/Verbose.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,84 @@
+using namespace std;
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/Info.hpp"
+#include "Helpers/Verbose.hpp"
+#include <iostream>
+
+/** Prints the tabs according to verbosity stored in the temporary constructed class.
+ * \param &ost stream to extend with tabs
+ * \return &ost stream with tabs
+ */
+ostream& Verbose::print (ostream &ost) const
+{
+  for (int i=Verbosity+Info::verbosity;i--;)
+    ost.put('\t');
+  //Log() << Verbose(0) << "Verbose(.) called." << endl;
+  return ost;
+};
+
+/** States whether current output message should be print or not.
+ * Compares Verbose::Verbosity plus Info::verbosity against \a verbosityLevel.
+ * \param verbosityLevel given global level of verbosity
+ * \return true - do output, false - don't
+ */
+bool Verbose::DoOutput(int verbosityLevel) const
+{
+  return (verbosityLevel >= Verbosity+Info::verbosity);
+};
+
+/** States whether current error output message should be print or not.
+ * Compares Verbose::Verbosity against \a verbosityLevel.
+ * \param verbosityLevel given global level of verbosity
+ * \return true - do output, false - don't
+ */
+bool Verbose::DoErrorOutput(int verbosityLevel) const
+{
+  return (verbosityLevel >= Verbosity);
+};
+
+/** Operator for the Verbose(arg) call.
+ * Constructs temporary a Verbose class object, wherein the verbosity is stored.
+ * Then << is called, which calls Verbose's print which adds the tabs and returns the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Verbose object
+ * \return &ost
+ */ 
+ostream& operator<<(ostream& ost,const Verbose& m)
+{
+  return m.print(ost);
+};
+
+/** Prints the tabs according to verbosity stored in the temporary constructed class.
+ * Note that highest bit is set artificially to give number of bits to print
+ * \param &ost stream to extend with tabs
+ * \return &ost stream with tabs
+ */
+ostream& Binary::print (ostream &ost) const
+{
+  int bits = 1, counter = 1;
+  while ((bits = 1 << counter) < BinaryNumber)
+    counter++;
+  for (int i=0;i<counter-1;i++) {
+    if ((BinaryNumber & (1 << i)) == 0)
+      ost.put('0');
+     else
+      ost.put('1');
+  }
+  ost.put('b');
+  //Log() << Verbose(0) << "Binary(.) called." << endl;
+  return ost;
+};
+
+/** Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and returns the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */ 
+ostream& operator<<(ostream& ost,const Binary& m)
+{
+  return m.print(ost);
+};
Index: src/Helpers/Verbose.hpp
===================================================================
--- src/Helpers/Verbose.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/Verbose.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,62 @@
+/*
+ * verbose.hpp
+ *
+ *  Created on: Aug 3, 2009
+ *      Author: heber
+ */
+
+#ifndef VERBOSE_HPP_
+#define VERBOSE_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iosfwd>
+
+/************************************* Class Verbose & Binary *******************************/
+
+/** Verbose is an IO manipulator, that writes tabs according to \a Verbosity level.
+ */
+class Verbose
+{
+  public:
+    Verbose(int value) : Verbosity(value) { }
+
+    // allow access to private variable Verbose::Verbosity
+    friend ostream& operator<<(class errorLogger& l, const Verbose& v);
+    friend ostream& operator<<(class errorLogger* l, const Verbose& v);
+    friend ostream& operator<<(class logger& l, const Verbose& v);
+    friend ostream& operator<<(class logger* l, const Verbose& v);
+
+    ostream& print (ostream &ost) const;
+    bool DoOutput(int verbosityLevel) const;
+    bool DoErrorOutput(int verbosityLevel) const;
+  private:
+    int Verbosity;
+};
+
+ostream& operator<<(ostream& ost,const Verbose& m);
+
+/** Binary is an IO manipulator, that writes 0 and 1 according to number \a Binary.
+ */
+class Binary
+{
+  public:
+    Binary(int value) : BinaryNumber(value) { }
+
+    ostream& print (ostream &ost) const;
+  private:
+    int BinaryNumber;
+};
+
+ostream& operator<<(ostream& ost,const Binary& m);
+
+
+
+#endif /* VERBOSE_HPP_ */
Index: src/Helpers/errorlogger.cpp
===================================================================
--- src/Helpers/errorlogger.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/errorlogger.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,103 @@
+/*
+ * errorLogger.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <fstream>
+#include <iostream>
+#include "Helpers/errorlogger.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+ofstream null("/dev/null");
+int errorLogger::verbosity = 2;
+ostream* errorLogger::nix = &null;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return errorLogger instance
+ */
+errorLogger::errorLogger()
+{
+  verbosity = 2;
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+errorLogger::~errorLogger() {
+  verbosity = 2;
+}
+
+CONSTRUCT_SINGLETON(errorLogger)
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void errorLogger::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
+
+/**
+ * Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and logs
+ * the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */
+ostream& operator<<(class errorLogger& l, const Verbose& v)
+{
+  int verbosityLevel = l.verbosity;
+  l.nix->clear();
+  if (v.DoErrorOutput(verbosityLevel)) {
+    switch(v.Verbosity) {
+      case 0:
+        cerr << "CRITICAL: ";
+        break;
+      case 1:
+        cerr << "ERROR: ";
+        break;
+      case 2:
+        cerr << "WARNING: ";
+        break;
+      default:
+        break;
+    }
+    v.print(cerr);
+    return cerr;
+  } else
+    return *l.nix;
+};
+ostream& operator<<(class errorLogger* l, const Verbose& v)
+{
+  int verbosityLevel = l->verbosity;
+  l->nix->clear();
+  if (v.DoErrorOutput(verbosityLevel)) {
+    switch(v.Verbosity) {
+      case 0:
+        cerr << "CRITICAL: ";
+        break;
+      case 1:
+        cerr << "ERROR: ";
+        break;
+      case 2:
+      default:
+        cerr << "WARNING: ";
+        break;
+    }
+    v.print(cerr);
+    return cerr;
+  } else
+    return *l->nix;
+};
+
+
Index: src/Helpers/errorlogger.hpp
===================================================================
--- src/Helpers/errorlogger.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/errorlogger.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,39 @@
+/*
+ * errorLogger.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef ERRORLOGGER_HPP_
+#define ERRORLOGGER_HPP_
+
+#include <iosfwd>
+
+#include "Patterns/Singleton.hpp"
+
+using namespace std;
+
+class Verbose;
+
+class errorLogger : public Singleton<errorLogger>{
+  friend class Singleton<errorLogger>;
+public :
+  static ostream *nix;
+  static int verbosity;
+
+  static bool DoOutput();
+  static void setVerbosity(int verbosityLevel);
+
+protected:
+  /** Do not call this constructor directly, use getInstance() instead. */
+  errorLogger();
+  /** Do not call this destructor directly, use purgeInstance() instead. */
+  ~errorLogger();
+
+};
+
+ostream& operator<<(class errorLogger&l, const Verbose& ost);
+ostream& operator<<(class errorLogger*l, const Verbose& ost);
+
+#endif /* ERRORLOGGER_HPP_ */
Index: src/Helpers/helpers.cpp
===================================================================
--- src/Helpers/helpers.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/helpers.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,142 @@
+/** \file helpers.cpp
+ *
+ * Implementation of some auxiliary functions for memory dis-/allocation and so on
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Helpers/helpers.hpp"
+#include "Helpers/fast_functions.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Helpers/Log.hpp"
+
+#include <iostream>
+
+/********************************************** helpful functions *********************************/
+
+
+/** Asks for a double value and checks input
+ * \param *text question
+ */
+double ask_value(const char *text)
+{
+  double test = 0.1439851348959832147598734598273456723948652983045928346598365;
+  do {
+    DoLog(0) && (Log() << Verbose(0) << text);
+    cin >> test;
+  } while (test == 0.1439851348959832147598734598273456723948652983045928346598365);
+  return test;
+};
+
+/** Output of a debug message to stderr.
+ * \param *P Problem at hand, points to ParallelSimulationData#me
+ * \param output output string
+ */
+#ifdef HAVE_DEBUG
+void debug_in(const char *output, const char *file, const int line) {
+  if (output) fprintf(stderr,"DEBUG: in %s at line %i: %s\n", file, line, output);
+}
+#else
+void debug_in(const char *output, const char *file, const int line) {}  // print nothing
+#endif
+
+/** modulo operator for doubles.
+ * \param *b pointer to double
+ * \param lower_bound lower bound
+ * \param upper_bound upper bound
+ */
+void bound(double *b, double lower_bound, double upper_bound)
+{
+  double step = (upper_bound - lower_bound);
+  while (*b >= upper_bound)
+    *b -= step;
+  while (*b < lower_bound)
+    *b += step;
+};
+
+/** Counts lines in file.
+ * Note we are scanning lines from current position, not from beginning.
+ * \param InputFile file to be scanned.
+ */
+int CountLinesinFile(ifstream &InputFile)
+{
+  char *buffer = new char[MAXSTRINGSIZE];
+  int lines=0;
+
+  int PositionMarker = InputFile.tellg();  // not needed as Inputfile is copied, given by value, not by ref
+  // count the number of lines, i.e. the number of fragments
+  InputFile.getline(buffer, MAXSTRINGSIZE); // skip comment lines
+  InputFile.getline(buffer, MAXSTRINGSIZE);
+  while(!InputFile.eof()) {
+    InputFile.getline(buffer, MAXSTRINGSIZE);
+    lines++;
+  }
+  InputFile.seekg(PositionMarker, ios::beg);
+  delete[](buffer);
+  return lines;
+};
+
+/** Returns a string with \a i prefixed with 0s to match order of total number of molecules in digits.
+ * \param FragmentNumber total number of fragments to determine necessary number of digits
+ * \param digits number to create with 0 prefixed
+ * \return allocated(!) char array with number in digits, ten base.
+ */
+char *FixedDigitNumber(const int FragmentNumber, const int digits)
+{
+  char *returnstring;
+  int number = FragmentNumber;
+  int order = 0;
+  while (number != 0) { // determine number of digits needed
+    number = (int)floor(((double)number / 10.));
+    order++;
+    //Log() << Verbose(0) << "Number is " << number << ", order is " << order << "." << endl;
+  }
+  // allocate string
+  returnstring = new char[order + 2];
+  // terminate  and fill string array from end backward
+  returnstring[order] = '\0';
+  number = digits;
+  for (int i=order;i--;) {
+    returnstring[i] = '0' + (char)(number % 10);
+    number = (int)floor(((double)number / 10.));
+  }
+  //Log() << Verbose(0) << returnstring << endl;
+  return returnstring;
+};
+
+/** Tests whether a given string contains a valid number or not.
+ * \param *string
+ * \return true - is a number, false - is not a valid number
+ */
+bool IsValidNumber( const char *string)
+{
+  int ptr = 0;
+  if ((string[ptr] == '.') || (string[ptr] == '-')) // number may be negative or start with dot
+    ptr++;
+  if ((string[ptr] >= '0') && (string[ptr] <= '9'))
+    return true;
+  return false;
+};
+
+/** Comparison function for GSL heapsort on distances in two molecules.
+ * \param *a
+ * \param *b
+ * \return <0, \a *a less than \a *b, ==0 if equal, >0 \a *a greater than \a *b
+ */
+int CompareDoubles (const void * a, const void * b)
+{
+  if (*(double *)a > *(double *)b)
+    return -1;
+  else if (*(double *)a < *(double *)b)
+    return 1;
+  else
+    return 0;
+};
+
+
+/**
+ * Calls exit(255).
+ */
+void performCriticalExit() {
+  exit(255);
+}
Index: src/Helpers/helpers.hpp
===================================================================
--- src/Helpers/helpers.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/helpers.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,196 @@
+/** \file helpers.hpp
+ *
+ * Declaration of some auxiliary functions for memory dis-/allocation and so on
+ */
+
+#ifndef HELPERS_HPP_
+#define HELPERS_HPP_
+
+using namespace std;
+
+/*********************************************** includes ***********************************/
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fstream>
+
+#include "defs.hpp"
+#include "Helpers/Log.hpp"
+
+/********************************************** definitions *********************************/
+
+/********************************************** helpful functions *********************************/
+
+// taken out of TREMOLO
+/*@-namechecks@*/
+#ifndef __GNUC__
+# undef __attribute__
+# define __attribute__(x)
+#endif
+/*@=namechecks@*/
+
+/* Behandelt aufgetretene Fehler. error ist der Fehlertyp(enum Errors)
+   void *SpecialData ist ein untypisierter Zeiger auf Spezielle Daten zur Fehlerbehandlung.
+   Man koennte auch noch einen Zeiger auf eine Funktion uebergeben */
+extern void /*@exits@*/ debug(const char *output);
+  //__attribute__ ((__return__));
+#define debug(data) debug_in((data), __FILE__, __LINE__)
+
+extern void /*@exits@*/ debug_in(const char *output,
+    const char *file, const int line);
+  //__attribute__ ((__return__));
+
+double ask_value(const char *text);
+bool check_bounds(double *x, double *cell_size);
+void bound(double *b, double lower_bound, double upper_bound);
+int CountLinesinFile(ifstream &InputFile);
+char *FixedDigitNumber(const int FragmentNumber, const int digits);
+bool IsValidNumber( const char *string);
+int CompareDoubles (const void * a, const void * b);
+void performCriticalExit();
+
+/********************************************** helpful template functions *********************************/
+
+
+/** returns greater of the two values.
+ * \param x first value
+ * \param y second value
+ * \return greater of the two (by operator>())
+ */
+template <typename T> T Max(T x, T y)
+{
+  if (x > y)
+    return x;
+  else return y;
+};
+
+/** returns smaller of the two values.
+ * \param x first value
+ * \param y second value
+ * \return smaller of the two (by operator<())
+ */
+template <typename T> T Min(T x, T y)
+{
+  if (x < y)
+    return x;
+  else return y;
+};
+
+/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
+ * \param *start begin of chain list
+ * \paran *end end of chain list
+ * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
+ * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
+ * \return true - success, false - failure
+ */
+template <typename T> bool CreateFatherLookupTable(T *start, T *end, T **&LookupTable, int count = 0)
+{
+  bool status = true;
+  T *Walker = NULL;
+  int AtomNo;
+
+  if (LookupTable != NULL) {
+    DoeLog(0) && (eLog() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);
+    return false;
+  }
+
+  // count them
+  if (count == 0) {
+    Walker = start;
+    while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
+      Walker = Walker->next;
+      count = (count < Walker->GetTrueFather()->nr) ? Walker->GetTrueFather()->nr : count;
+    }
+  }
+  if (count <= 0) {
+    DoeLog(1) && (eLog() << Verbose(1) << "Count of lookup list is 0 or less." << endl);
+    return false;
+  }
+
+  // allocate and fill
+  LookupTable = new T*[count];
+  if (LookupTable == NULL) {
+    DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl);
+    performCriticalExit();
+    status = false;
+  } else {
+    Walker = start;
+    while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
+      Walker = Walker->next;
+      AtomNo = Walker->GetTrueFather()->nr;
+      if ((AtomNo >= 0) && (AtomNo < count)) {
+        //*out << "Setting LookupTable[" << AtomNo << "] to " << *Walker << endl;
+        LookupTable[AtomNo] = Walker;
+      } else {
+        DoeLog(2) && (eLog() << Verbose(2) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);
+        status = false;
+        break;
+      }
+    }
+  }
+
+  return status;
+};
+
+
+/** Frees a two-dimensional array.
+ * \param *ptr pointer to array
+ * \param dim first dim of array
+ */
+template <typename X> void Free2DArray(X **ptr, int dim)
+{
+  int i;
+  if (ptr != NULL) {
+    for(i=dim;i--;)
+      if (ptr[i] != NULL)
+        free(ptr[i]);
+    free(ptr);
+  }
+};
+
+template <typename T> void Increment(T *value, T *inc)
+{
+  *value += *inc;
+};
+
+template <typename T> void AbsoluteValue(T *value, T *abs)
+{
+  *value = *abs;
+};
+
+template <typename T> void IncrementalAbsoluteValue(T *value, T *abs)
+{
+  *value = *abs;
+  (*abs) += 1;
+};
+
+#define PLURAL_S(v) (((v)==1)?"":"s")
+
+// this is to allow different modes of access for
+// maps and sets
+template<typename Res,typename T>
+struct _take{
+  Res get(T value) const;
+};
+
+// if we have a set,vector etc we can directly access the result
+template<typename Res>
+struct _take<Res,Res>{
+  static inline Res get(Res value){
+    return value;
+  }
+};
+
+// if we have a map we have to access the second part of
+// the pair
+template<typename Res,typename T1>
+struct _take<Res,std::pair<T1,Res> >{
+  static inline Res get(std::pair<T1,Res> value){
+    return value.second;
+  }
+};
+
+#endif /*HELPERS_HPP_*/
Index: src/Helpers/logger.cpp
===================================================================
--- src/Helpers/logger.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/logger.cpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,78 @@
+/*
+ * logger.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#include "Helpers/MemDebug.hpp"
+
+#include <fstream>
+#include <iostream>
+#include "Helpers/logger.hpp"
+#include "Helpers/Verbose.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+ofstream nullStream("/dev/null");
+
+int logger::verbosity = 2;
+ostream* logger::nix = &nullStream;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return logger instance
+ */
+logger::logger()
+{
+  verbosity = 2;
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+logger::~logger() {
+  verbosity = 2;
+}
+
+CONSTRUCT_SINGLETON(logger)
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void logger::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
+
+/**
+ * Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and logs
+ * the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */
+ostream& operator<<(class logger& l, const Verbose& v)
+{
+  int verbosityLevel = l.verbosity;
+  l.nix->clear();
+  if (v.DoOutput(verbosityLevel)) {
+    v.print(cout);
+    return cout;
+  } else
+    return *l.nix;
+};
+ostream& operator<<(class logger* l, const Verbose& v)
+{
+  int verbosityLevel = l->verbosity;
+  l->nix->clear();
+  if (v.DoOutput(verbosityLevel)) {
+    v.print(cout);
+    return cout;
+  } else
+    return *l->nix;
+};
+
Index: src/Helpers/logger.hpp
===================================================================
--- src/Helpers/logger.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
+++ src/Helpers/logger.hpp	(revision b37436fa9715dfb6e1303adf13e96697e9e8306b)
@@ -0,0 +1,38 @@
+/*
+ * logger.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef LOGGER_HPP_
+#define LOGGER_HPP_
+
+#include <iosfwd>
+
+#include "Patterns/Singleton.hpp"
+
+using namespace std;
+
+class Verbose;
+
+class logger : public Singleton<logger> {
+  friend class Singleton<logger>;
+public :
+  static ostream *nix;
+  static int verbosity;
+
+  static bool DoOutput();
+  static void setVerbosity(int verbosityLevel);
+
+protected:
+  /** Do not call this constructor directly, use getInstance() instead. */
+  logger();
+  /** Do not call this destructor directly, use purgeInstance() instead. */
+  ~logger();
+};
+
+ostream& operator<<(class logger&l, const Verbose& ost);
+ostream& operator<<(class logger*l, const Verbose& ost);
+
+#endif /* LOGGER_HPP_ */
