diff --git a/Sampling/GeneralSampler.h b/Sampling/GeneralSampler.h
--- a/Sampling/GeneralSampler.h
+++ b/Sampling/GeneralSampler.h
@@ -1,496 +1,494 @@
 // -*- C++ -*-
 //
 // GeneralSampler.h is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2017 The Herwig Collaboration
 //
 // Herwig is licenced under version 3 of the GPL, see COPYING for details.
 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
 //
 #ifndef Herwig_GeneralSampler_H
 #define Herwig_GeneralSampler_H
 //
 // This is the declaration of the GeneralSampler class.
 //
 
 #include "ThePEG/Handlers/SamplerBase.h"
 #include "BinSampler.h"
 
 namespace Herwig {
 
 using namespace ThePEG;
 
 /**
  * \ingroup Matchbox
  * \author Simon Platzer
  *
  * \brief A GeneralSampler class
  *
  * @see \ref GeneralSamplerInterfaces "The interfaces"
  * defined for GeneralSampler.
  */
 class GeneralSampler: public SamplerBase {
 
 public:
 
   /** @name Standard constructors and destructors. */
   //@{
   /**
    * The default constructor.
    */
   GeneralSampler();
 
   /**
    * The destructor.
    */
   virtual ~GeneralSampler();
   //@}
 
 public:
 
   /** @name Virtual functions from SamplerBase. */
   //@{
   /**
    * Initialize the the sampler, possibly doing presampling of the
    * phase space.
    */
   virtual void initialize();
 
   /**
    * Generarate a new phase space point and return a weight associated
    * with it. This weight should preferably be 1.
    */
   virtual double generate();
 
   /**
    * Reject the last chosen phase space point.
    */
   virtual void rejectLast();
 
   /**
    * If the sampler is able to sample several different functions
    * separately, this function should return the last chosen
    * function. This default version always returns 0.
    */
   virtual int lastBin() const { return lastSampler() ? lastSampler()->bin() : 0; }
 
   /**
    * Return the total integrated cross section determined from the
    * Monte Carlo sampling so far.
    */
   virtual CrossSection integratedXSec() const {
     currentCrossSections();
     return theIntegratedXSec;
   }
 
   /**
    * Return the error on the total integrated cross section determined
    * from the Monte Carlo sampling so far.
    */
   virtual CrossSection integratedXSecErr() const {
     currentCrossSections();
     return theIntegratedXSecErr;
   }
 
   /**
    * Return the overestimated integrated cross section.
    */
   virtual CrossSection maxXSec() const { 
     if ( theAddUpSamplers )
       return SamplerBase::maxXSec();
     return theMaxWeight*nanobarn;
   }
 
   /**
    * Return the sum of the weights returned by generate() so far (of
    * the events that were not rejeted).
    */
   virtual double sumWeights() const { return theSumWeights; }
 
   /**
    * Return the sum of the weights squaredreturned by generate() so far (of
    * the events that were not rejeted).
    */
   virtual double sumWeights2() const { return theSumWeights2; }
 
   /**
    * Return the number of attempts
    */
   virtual double attempts() const { 
     if ( theAddUpSamplers )
       return SamplerBase::attempts();
     return theAttempts;
   }
 
   /**
    * Return the number of accepts
    */
   double accepts() const { return theAccepts; }
 
   //@}
 
   /**
    * Return the samplers
    */
   const map<double,Ptr<BinSampler>::ptr>& samplers() const { return theSamplers; }
 
   /**
    * Return the bin sampler
    */
   Ptr<BinSampler>::ptr binSampler() const { return theBinSampler; }
 
   /**
    * Return the last selected bin sampler
    */
   Ptr<BinSampler>::tptr lastSampler() const { return theLastSampler; }
 
   /**
    * True if we should do weighted events
    */
   bool weighted() const { return eventHandler()->weighted(); }
 
-
   /** 
-   * True if the sampler runs in Allmostunweighted mode.
+   * Return true if this sampler is generating almost unweighted events.
    */ 
-
-  bool almostUnweighted() const { return theAlmostUnweighted; }
+  virtual bool almostUnweighted() const { return theAlmostUnweighted; }
 
 public:
 
   /**
    * Return the XML element containing the grids
    */
   const XML::Element& grids() const { return theGrids; }
 
   /**
    * Access the XML element containing the grids
    */
   XML::Element& grids() { return theGrids; }
 
   /**
    * Write out grids
    */
   void writeGrids() const;
 
   /**
    * Read in grids
    */
   void readGrids();
   
   /**
    * Return the number of integration jobs which were actually created.
    */
   unsigned int integrationJobsCreated() {
     return theIntegrationJobsCreated;
   }
 
   /**
    * An external hook to prepare the sampler for generating events, e.g. by
    * combining grid files from parallel integration runs.
    */
   virtual void prepare();
 
 protected:
 
   /**
    * Access the samplers
    */
   map<double,Ptr<BinSampler>::ptr>& samplers() { return theSamplers; }
 
   /**
    * Set the last selected bin sampler
    */
   void lastSampler(Ptr<BinSampler>::tptr s) { theLastSampler = s; }
 
   /**
    * Calculate cross sections from samplers at current state.
    */
   void currentCrossSections() const;
 
   /**
    * Update the sampler selection
    */
   void updateSamplers();
 
 public:
 
   /** @name Functions used by the persistent I/O system. */
   //@{
   /**
    * Function used to write out object persistently.
    * @param os the persistent output stream written to.
    */
   void persistentOutput(PersistentOStream & os) const;
 
   /**
    * Function used to read in object persistently.
    * @param is the persistent input stream read from.
    * @param version the version number of the object when written.
    */
   void persistentInput(PersistentIStream & is, int version);
   //@}
 
   /**
    * The standard Init function used to initialize the interfaces.
    * Called exactly once for each class by the class description system
    * before the main function starts or
    * when this class is dynamically loaded.
    */
   static void Init();
 
 protected:
 
   /** @name Clone Methods. */
   //@{
   /**
    * Make a simple clone of this object.
    * @return a pointer to the new object.
    */
   virtual IBPtr clone() const;
 
   /** Make a clone of this object, possibly modifying the cloned object
    * to make it sane.
    * @return a pointer to the new object.
    */
   virtual IBPtr fullclone() const;
   //@}
 
 
 // If needed, insert declarations of virtual function defined in the
 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
 
 
 protected:
 
   /**
    * Initialize this object after the setup phase before saving an
    * EventGenerator to disk.
    * @throws InitException if object could not be initialized properly.
    */
   virtual void doinit();
 
   /**
    * Initialize this object. Called in the run phase just before
    * a run begins.
    */
   virtual void doinitrun();
 
   /**
    * Finalize this object. Called in the run phase just after a
    * run has ended. Used eg. to write out statistics.
    */
   virtual void dofinish();
 
   /**
    * Rebind pointer to other Interfaced objects. Called in the setup phase
    * after all objects used in an EventGenerator has been cloned so that
    * the pointers will refer to the cloned objects afterwards.
    * @param trans a TranslationMap relating the original objects to
    * their respective clones.
    * @throws RebindException if no cloned object was found for a given
    * pointer.
    */
   virtual void rebind(const TranslationMap & trans);
 
   /**
    * Return a vector of all pointers to Interfaced objects used in this
    * object.
    * @return a vector of pointers.
    */
   virtual IVector getReferences();
 
 private:
 
   /**
    * Whether or not additional information should be printed to cout.
    */
   bool theVerbose;
 
   /**
    * The XML element containing the grids
    */
   XML::Element theGrids;
 
   /**
    * The bin sampler to use.
    */
   Ptr<BinSampler>::ptr theBinSampler;
 
   /**
    * The selector map for the bin samplers.
    */
   map<double,Ptr<BinSampler>::ptr> theSamplers;
 
   /**
    * The last selected bin sampler.
    */
   Ptr<BinSampler>::tptr theLastSampler;
 
   /**
    * The integrated cross section
    */
   mutable CrossSection theIntegratedXSec;
 
   /**
    * The integrated cross section error
    */
   mutable CrossSection theIntegratedXSecErr;
 
   /**
    * The number of events after which cross sections should truly be
    * updated. This is used to prevent exhaustive combination of
    * statistics when HepMC events are written out.
    */
   size_t theUpdateAfter;
 
   /**
    * The number of calls to currentCrossSections since the last
    * update.
    */
   mutable size_t crossSectionCalls;
 
   /**
    * True, if currentCrossSections has been called since the last call
    * to generate.
    */
   mutable bool gotCrossSections;
 
   /**
    * The sum of weights
    */
   double theSumWeights;
 
   /**
    * The sum of weights squared
    */
   double theSumWeights2;
 
   /**
    * The number of attempts
    */
   double theAttempts;
 
   /**
    * The number of accepts
    */
   double theAccepts;
 
   /**
    * The maximum weight encountered
    */
   double theMaxWeight;
 
   /**
    * True, if cross sections are to be combined from each sampler
    * individually
    */
   bool theAddUpSamplers;
 
   /**
    * True, if the global maximum weight should be used as
    * reference. If not, the maximum weights of individual samplers are
    * used, and selection probabilities fro the samplers are adjusted
    * accordingly.
    */
   bool theGlobalMaximumWeight;
 
   /**
    * True, if subprocesses should be selected flat. This is a debug
    * flag, cross section information and distributions will not be
    * correct.
    */
   bool theFlatSubprocesses;
 
   /**
    * True, if we are generating events.
    */
   bool isSampling;
 
   /**
    * A minimum selection probability for each sampler
    */
   double theMinSelection;
 
   /**
    * True, if information for combining unnormalized runs should be
    * printed out
    */
   bool runCombinationData;
 
   /**
    * True, if we should perform an almost unweighted sampling
    */
   bool theAlmostUnweighted;
 
   /**
    * Number of points which exceeded the maximum
    */
   unsigned long maximumExceeds;
 
   /**
    * The average relative deviation from the maximum weight
    */
   double maximumExceededBy;
 
   /**
    * The correct cross section as one would exspect with
    * almostUnweighted. 
    */
 
   double correctWeights;
 
   /**
    * Enhancement factor to the maximum weight.
    * This is to get less maximumExceeds. 
    */
 
   double theMaxEnhancement;
 
   /**
    * True, if grids have already been read.
    */
   bool didReadGrids;
 
   /**
    * True, if parallel subprocess integration should be enabled
    */
   bool theParallelIntegration;
 
   /**
    * The number of subprocesses to integrate per job
    */
   unsigned int theIntegratePerJob;
 
   /**
    * The maximum number of integration jobs to be created
    */
   unsigned int theIntegrationJobs;
 
   /**
    * The number of integration jobs which were actually created
    */
   unsigned int theIntegrationJobsCreated;
   
   /**
    * Indicate that initialization is only reading a grid.
    */
   bool justAfterIntegrate;
 
   /**
    * True, if grids should be written at the end of a run
    */
   bool theWriteGridsOnFinish;
 
 private:
 
   /**
    * The assignment operator is private and must never be called.
    * In fact, it should not even be implemented.
    */
   GeneralSampler & operator=(const GeneralSampler &);
 
 };
 
 }
 
 #endif /* Herwig_GeneralSampler_H */
diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4
new file mode 100644
--- /dev/null
+++ b/m4/ax_compare_version.m4
@@ -0,0 +1,177 @@
+# ===========================================================================
+#    https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+#
+# DESCRIPTION
+#
+#   This macro compares two version strings. Due to the various number of
+#   minor-version numbers that can exist, and the fact that string
+#   comparisons are not compatible with numeric comparisons, this is not
+#   necessarily trivial to do in a autoconf script. This macro makes doing
+#   these comparisons easy.
+#
+#   The six basic comparisons are available, as well as checking equality
+#   limited to a certain number of minor-version levels.
+#
+#   The operator OP determines what type of comparison to do, and can be one
+#   of:
+#
+#    eq  - equal (test A == B)
+#    ne  - not equal (test A != B)
+#    le  - less than or equal (test A <= B)
+#    ge  - greater than or equal (test A >= B)
+#    lt  - less than (test A < B)
+#    gt  - greater than (test A > B)
+#
+#   Additionally, the eq and ne operator can have a number after it to limit
+#   the test to that number of minor versions.
+#
+#    eq0 - equal up to the length of the shorter version
+#    ne0 - not equal up to the length of the shorter version
+#    eqN - equal up to N sub-version levels
+#    neN - not equal up to N sub-version levels
+#
+#   When the condition is true, shell commands ACTION-IF-TRUE are run,
+#   otherwise shell commands ACTION-IF-FALSE are run. The environment
+#   variable 'ax_compare_version' is always set to either 'true' or 'false'
+#   as well.
+#
+#   Examples:
+#
+#     AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
+#     AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
+#
+#   would both be true.
+#
+#     AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
+#     AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
+#
+#   would both be false.
+#
+#     AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
+#
+#   would be true because it is only comparing two minor versions.
+#
+#     AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
+#
+#   would be true because it is only comparing the lesser number of minor
+#   versions of the two values.
+#
+#   Note: The characters that separate the version numbers do not matter. An
+#   empty string is the same as version 0. OP is evaluated by autoconf, not
+#   configure, so must be a string, not a variable.
+#
+#   The author would like to acknowledge Guido Draheim whose advice about
+#   the m4_case and m4_ifvaln functions make this macro only include the
+#   portions necessary to perform the specific comparison specified by the
+#   OP argument in the final configure script.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 12
+
+dnl #########################################################################
+AC_DEFUN([AX_COMPARE_VERSION], [
+  AC_REQUIRE([AC_PROG_AWK])
+
+  # Used to indicate true or false condition
+  ax_compare_version=false
+
+  # Convert the two version strings to be compared into a format that
+  # allows a simple string comparison.  The end result is that a version
+  # string of the form 1.12.5-r617 will be converted to the form
+  # 0001001200050617.  In other words, each number is zero padded to four
+  # digits, and non digits are removed.
+  AS_VAR_PUSHDEF([A],[ax_compare_version_A])
+  A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+                     -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+                     -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+                     -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+                     -e 's/[[^0-9]]//g'`
+
+  AS_VAR_PUSHDEF([B],[ax_compare_version_B])
+  B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+                     -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+                     -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+                     -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+                     -e 's/[[^0-9]]//g'`
+
+  dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
+  dnl # then the first line is used to determine if the condition is true.
+  dnl # The sed right after the echo is to remove any indented white space.
+  m4_case(m4_tolower($2),
+  [lt],[
+    ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+  ],
+  [gt],[
+    ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+  ],
+  [le],[
+    ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+  ],
+  [ge],[
+    ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+  ],[
+    dnl Split the operator from the subversion count if present.
+    m4_bmatch(m4_substr($2,2),
+    [0],[
+      # A count of zero means use the length of the shorter version.
+      # Determine the number of characters in A and B.
+      ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
+      ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
+
+      # Set A to no more than B's length and B to no more than A's length.
+      A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
+      B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
+    ],
+    [[0-9]+],[
+      # A count greater than zero means use only that many subversions
+      A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+      B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+    ],
+    [.+],[
+      AC_WARNING(
+        [illegal OP numeric parameter: $2])
+    ],[])
+
+    # Pad zeros at end of numbers to make same length.
+    ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
+    B="$B`echo $A | sed 's/./0/g'`"
+    A="$ax_compare_version_tmp_A"
+
+    # Check for equality or inequality as necessary.
+    m4_case(m4_tolower(m4_substr($2,0,2)),
+    [eq],[
+      test "x$A" = "x$B" && ax_compare_version=true
+    ],
+    [ne],[
+      test "x$A" != "x$B" && ax_compare_version=true
+    ],[
+      AC_WARNING([illegal OP parameter: $2])
+    ])
+  ])
+
+  AS_VAR_POPDEF([A])dnl
+  AS_VAR_POPDEF([B])dnl
+
+  dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
+  if test "$ax_compare_version" = "true" ; then
+    m4_ifvaln([$4],[$4],[:])dnl
+    m4_ifvaln([$5],[else $5])dnl
+  fi
+]) dnl AX_COMPARE_VERSION
diff --git a/m4/herwig.m4 b/m4/herwig.m4
--- a/m4/herwig.m4
+++ b/m4/herwig.m4
@@ -1,892 +1,900 @@
 dnl ##### THEPEG #####
 AC_DEFUN([HERWIG_CHECK_THEPEG],
 [
 defaultlocation="${prefix}"
 test "x$defaultlocation" = xNONE && defaultlocation="${ac_default_prefix}"
 AC_MSG_CHECKING([for libThePEG in])
 AC_ARG_WITH(thepeg,
         AC_HELP_STRING([--with-thepeg=DIR],[location of ThePEG installation]),
         [],
 	[with_thepeg="${defaultlocation}"])
 AC_MSG_RESULT([$with_thepeg])
 
 if test "x$with_thepeg" = "xno"; then
 	AC_MSG_ERROR([Cannot build Herwig without ThePEG. Please set --with-thepeg.])
 fi
 
 THEPEGLDFLAGS="-L${with_thepeg}/lib/ThePEG"
 
 THEPEGHASLHAPDF="no"
 if test -e ${with_thepeg}/lib/ThePEG/ThePEGLHAPDF.so ; then
    THEPEGHASLHAPDF="yes"
 fi
 if test "${host_cpu}" == "x86_64" -a -e ${with_thepeg}/lib64/ThePEG/libThePEG.so ; then
   THEPEGLDFLAGS="-L${with_thepeg}/lib64/ThePEG"
   if test -e ${with_thepeg}/lib64/ThePEG/ThePEGLHAPDF.so ; then
       THEPEGHASLHAPDF="yes"
   fi
 fi
 
 if test "x$THEPEGHASLHAPDF" == "xno" ; then
    AC_MSG_ERROR([Herwig requires ThePEG to be build with lhapdf.])
 fi
 
 THEPEGHASFASTJET="no"
 if test -e ${with_thepeg}/lib/ThePEG/FastJetFinder.so ; then
    THEPEGHASFASTJET="yes"
 fi
 if test "${host_cpu}" == "x86_64" -a -e ${with_thepeg}/lib64/ThePEG/libThePEG.so ; then
   THEPEGLDFLAGS="-L${with_thepeg}/lib64/ThePEG"
   if test -e ${with_thepeg}/lib64/ThePEG/FastJetFinder.so ; then
       THEPEGHASFASTJET="yes"
   fi
 fi
 
 if test "x$THEPEGHASFASTJET" == "xno" ; then
    AC_MSG_ERROR([Herwig requires ThePEG to be build with FastJet.])
 fi
 
 THEPEGPATH="${with_thepeg}"
 
 oldldflags="$LDFLAGS"
 oldlibs="$LIBS"
 
 LDFLAGS="$LDFLAGS $THEPEGLDFLAGS"
 AC_CHECK_LIB([ThePEG],[debugThePEG],[],
 	[AC_MSG_ERROR([No ThePEG libraries in $THEPEGLDFLAGS. Please set --with-thepeg.])])
 
 AC_SUBST([THEPEGLIB],[-lThePEG])
 AC_SUBST(THEPEGLDFLAGS)
 AC_SUBST(THEPEGPATH)
 AC_SUBST(THEPEGHASLHAPDF)
 AC_SUBST(THEPEGHASFASTJET)
 
 LIBS="$oldlibs"
 LDFLAGS="$oldldflags"
 
 AC_MSG_CHECKING([for ThePEG headers in])
 AC_ARG_WITH([thepeg-headers],
         AC_HELP_STRING([--with-thepeg-headers=DIR],[location of ThePEG include directory]),
         [],
 	[with_thepeg_headers="${with_thepeg}/include"])
 AC_MSG_RESULT([$with_thepeg_headers])
 
 if test "x$with_thepeg_headers" = "xno"; then
 	AC_MSG_ERROR([Cannot build Herwig without ThePEG headers. Please set --with-thepeg-headers.])
 fi
 
 THEPEGINCLUDE="-I$with_thepeg_headers"
 
 oldcppflags="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS $THEPEGINCLUDE"
 AC_CHECK_HEADER([ThePEG/Config/ThePEG.h],[],
 	[AC_MSG_ERROR([No ThePEG headers in $with_thepeg_headers. Please set --with-thepeg-headers.])])
 CPPFLAGS="$oldcppflags"
 
 AC_SUBST(THEPEGINCLUDE)
 
 AC_MSG_CHECKING([for HepMCAnalysis.so in ThePEG])
 
 THEPEGHASHEPMC="no"
 if test -e ${with_thepeg}/lib/ThePEG/HepMCAnalysis.so ; then
    THEPEGHASHEPMC="yes"
 fi
 if test "${host_cpu}" == "x86_64" -a -e ${with_thepeg}/lib64/ThePEG/libThePEG.so ; then
   THEPEGLDFLAGS="-L${with_thepeg}/lib64/ThePEG"
   if test -e ${with_thepeg}/lib64/ThePEG/HepMCAnalysis.so ; then
     THEPEGHASHEPMC="yes"
   fi
 fi
 
 if test "x$THEPEGHASHEPMC" == "xno" ; then
   CREATE_HEPMC="# create"
   AC_MSG_RESULT([not found])
 else
   CREATE_HEPMC="create"
   AC_MSG_RESULT([found])
 fi
 
 AC_SUBST([CREATE_HEPMC])
 
 AC_MSG_CHECKING([for RivetAnalysis.so in ThePEG])
 
 THEPEGHASRIVET="no"
 if test -e ${with_thepeg}/lib/ThePEG/RivetAnalysis.so ; then
    THEPEGHASRIVET="yes"
 fi
 if test "${host_cpu}" == "x86_64" -a -e ${with_thepeg}/lib64/ThePEG/libThePEG.so ; then
   THEPEGLDFLAGS="-L${with_thepeg}/lib64/ThePEG"
   if test -e ${with_thepeg}/lib64/ThePEG/RivetAnalysis.so ; then
     THEPEGHASRIVET="yes"
   fi
 fi
 
 if test "x$THEPEGHASRIVET" == "xno" ; then
   CREATE_RIVET="# create"
   AC_MSG_RESULT([not found])
 else
   CREATE_RIVET="create"
   AC_MSG_RESULT([found])
 fi
 
 AC_SUBST([CREATE_RIVET])
 ])
 
 dnl ##### LOOPTOOLS #####
 AC_DEFUN([HERWIG_LOOPTOOLS],
 [
 AC_REQUIRE([AC_PROG_FC])
 AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])
 AC_REQUIRE([AC_PROG_CC])
 AC_REQUIRE([HERWIG_COMPILERFLAGS])
 
 AC_MSG_CHECKING([if Looptools build works])
 enable_looptools=yes
 
 if test "x$GCC" = "xyes"; then
    case "${host}" in
       x86_64-*|*-darwin1*)
 	AM_FCFLAGS="$AM_FCFLAGS -fdefault-integer-8"
       	;;
    esac
 
    AC_LANG_PUSH([Fortran])
    	oldFCFLAGS="$FCFLAGS"
    	FCFLAGS="$AM_FCFLAGS"
    	AC_COMPILE_IFELSE(
 	   	AC_LANG_PROGRAM([],[      print *[,]"Hello"]),
 		[],
 		[AC_MSG_RESULT([no])
  		 AC_MSG_ERROR([needs gfortran on 64bit machines])]
 	)
 	FCFLAGS="$oldFCFLAGS"
   AC_LANG_POP([Fortran])
 fi
 AC_MSG_RESULT([$enable_looptools])
 
 AC_SUBST([F77],[$FC])
 AC_SUBST([FFLAGS],[$FCFLAGS])
 AC_SUBST([AM_FFLAGS],[$AM_FCFLAGS])
 AC_SUBST([FLIBS],[$FCLIBS])
 ])
 
 dnl ##### VBFNLO #####
 AC_DEFUN([HERWIG_CHECK_VBFNLO],
 [
 AC_MSG_CHECKING([for VBFNLO])
 
 AC_ARG_WITH([vbfnlo],
     AS_HELP_STRING([--with-vbfnlo=DIR], [Installation path of VBFNLO]),
     [],
     [with_vbfnlo=no]
 
 )
 
 AC_MSG_RESULT([$with_vbfnlo])
 
 AS_IF([test "x$with_vbfnlo" != "xno"],
       [AC_CHECK_FILES(
       ${with_vbfnlo}/lib/VBFNLO/libVBFNLO.so,
       [have_vbfnlo=lib], [have_vbfnlo=no])],
       [have_vbfnlo=no])
 
 AS_IF([test "x$with_vbfnlo" != "xno" -a "x$have_vbfnlo" = "xno" ],
       [AC_CHECK_FILES(
       ${with_vbfnlo}/lib64/VBFNLO/libVBFNLO.so,
       [have_vbfnlo=lib64], [have_vbfnlo=no])])
 
 AS_IF([test "x$with_vbfnlo" != "xno" -a "x$have_vbfnlo" = "xno" ],
       [AC_CHECK_FILES(
       ${with_vbfnlo}/lib/VBFNLO/libVBFNLO.dylib,
       [have_vbfnlo=lib], [have_vbfnlo=no])])
 
 AS_IF([test "x$with_vbfnlo" != "xno" -a "x$have_vbfnlo" = "xno" ],
       [AC_CHECK_FILES(
       ${with_vbfnlo}/lib64/VBFNLO/libVBFNLO.dylib,
       [have_vbfnlo=lib64], [have_vbfnlo=no])])
 
 AS_IF([test "x$have_vbfnlo" = "xlib"],
       [VBFNLOLIBS=${with_vbfnlo}/lib/VBFNLO
       AC_SUBST(VBFNLOLIBS)
       ])
 
 AS_IF([test "x$have_vbfnlo" = "xlib64"],
       [VBFNLOLIBS=${with_vbfnlo}/lib64/VBFNLO
       AC_SUBST(VBFNLOLIBS)
       ])
 
 AS_IF([test "x$with_vbfnlo" != "xno" -a "x$have_vbfnlo" = "xno"],
       [AC_MSG_ERROR([vbfnlo requested but not found])])
 
 AM_CONDITIONAL(HAVE_VBFNLO,[test "x$have_vbfnlo" = "xlib" -o "x$have_vbfnlo" = "xlib64"])
 
 if test "x$have_vbfnlo" = "xlib" -o "x$have_vbfnlo" = "xlib64" ; then
         AC_REQUIRE([AC_PROG_SED])
         VBFNLOINCLUDE=${with_vbfnlo}/include
 	AC_SUBST(VBFNLOINCLUDE)
         VBFNLOLIB=$(echo ${with_vbfnlo}/${have_vbfnlo}/VBFNLO | $SED -e 's%/\+%/%g')
         AC_SUBST(VBFNLOLIB)
      	LOAD_VBFNLO="library"
      	CREATE_VBFNLO="create"
      	INSERT_VBFNLO="insert"
      	SET_VBFNLO="set"
      	DO_VBFNLO="do"
      	MKDIR_VBFNLO="mkdir"
 else
      	LOAD_VBFNLO="# library"
 	CREATE_VBFNLO="# create"
      	INSERT_VBFNLO="# insert"
      	SET_VBFNLO="# set"
      	DO_VBFNLO="# do"
      	MKDIR_VBFNLO="# mkdir"
 fi
 
 AC_SUBST([LOAD_VBFNLO])
 AC_SUBST([CREATE_VBFNLO])
 AC_SUBST([INSERT_VBFNLO])
 AC_SUBST([SET_VBFNLO])
 AC_SUBST([DO_VBFNLO])
 AC_SUBST([MKDIR_VBFNLO])
 
 ])
 
 dnl ##### njet #####
 AC_DEFUN([HERWIG_CHECK_NJET],
 [
 AC_MSG_CHECKING([for njet])
 
 AC_ARG_WITH([njet],
     AS_HELP_STRING([--with-njet=DIR], [Installation path of njet]),
     [],
     [with_njet=no]
 
 )
 
 AC_MSG_RESULT([$with_njet])
 
 AS_IF([test "x$with_njet" != "xno"],
       [AC_CHECK_FILES(
       ${with_njet}/lib/libnjet2.so,
       [have_njet=lib], [have_njet=no])],
       [have_njet=no])
 
 AS_IF([test "x$with_njet" != "xno" -a "x$have_njet" = "xno" ],
       [AC_CHECK_FILES(
       ${with_njet}/lib64/libnjet2.so,
       [have_njet=lib64], [have_njet=no])])
 
 AS_IF([test "x$with_njet" != "xno" -a "x$have_njet" = "xno" ],
       [AC_CHECK_FILES(
       ${with_njet}/lib/libnjet2.dylib,
       [have_njet=lib], [have_njet=no])])
 
 AS_IF([test "x$have_njet" = "xlib"],
       [NJETLIBPATH=${with_njet}/lib
       AC_SUBST(NJETLIBPATH)
       NJETINCLUDEPATH=${with_njet}/include
       AC_SUBST(NJETINCLUDEPATH)
       NJETPREFIX=${with_njet}
       AC_SUBST(NJETPREFIX)
       ])
 
 AS_IF([test "x$have_njet" = "xlib64"],
       [NJETLIBPATH=${with_njet}/lib64
       AC_SUBST(NJETLIBPATH)
       NJETINCLUDEPATH=${with_njet}/include
       AC_SUBST(NJETINCLUDEPATH)
       NJETPREFIX=${with_njet}
       AC_SUBST(NJETPREFIX)
       ])
 
 AS_IF([test "x$with_njet" != "xno"  -a "x$have_njet" = "xno"],
       [AC_MSG_ERROR([njet requested but not found])])
 
 AM_CONDITIONAL(HAVE_NJET,[test "x$have_njet" = "xlib" -o "x$have_njet" = "xlib64"])
 
 if test "x$have_njet" = "xlib" -o "x$have_njet" = "xlib64" ; then
      	LOAD_NJET="library"
      	CREATE_NJET="create"
      	INSERT_NJET="insert"
      	DO_NJET="do"
 else
      	LOAD_NJET="# library"
 	CREATE_NJET="# create"
      	INSERT_NJET="# insert"
      	DO_NJET="# do"
 fi
 
 AC_SUBST([LOAD_NJET])
 AC_SUBST([CREATE_NJET])
 AC_SUBST([INSERT_NJET])
 AC_SUBST([DO_NJET])
 
 ])
 
 
 
 dnl ##### gosam #####
 AC_DEFUN([HERWIG_CHECK_GOSAM],
 [
-AC_MSG_CHECKING([for gosam])
+AC_MSG_CHECKING([for GoSam])
 
 AC_ARG_WITH([gosam],
-    AS_HELP_STRING([--with-gosam=DIR], [Installation path of gosam]),
+    AS_HELP_STRING([--with-gosam=DIR], [Installation path of GoSam]),
     [],
     [with_gosam=no]
 )
 
 AC_MSG_RESULT([$with_gosam])
 
 AS_IF([test "x$with_gosam" != "xno"],
       [AC_CHECK_FILES(
       ${with_gosam}/bin/gosam.py,
       [have_gosam=lib], [have_gosam=no])],
       [have_gosam=no])
 
 AS_IF([test "x$have_gosam" = "xlib"],
       [GOSAMPREFIX=${with_gosam}
       AC_SUBST(GOSAMPREFIX)
       ])
 
 AS_IF([test "x$with_gosam" != "xno"  -a "x$have_gosam" = "xno"],
       [AC_MSG_ERROR([GoSam requested but not found])])
 
+AS_IF([test "x$with_gosam" != "xno"],
+[AC_MSG_CHECKING([for GoSam version >= 2.0.4])
+tmp_gosamversion=[$(${with_gosam}/bin/gosam.py --version | grep 'GoSam.*rev' | cut -d' ' -f2)]
+AX_COMPARE_VERSION([${tmp_gosamversion}],[lt],[2.0.4],
+                   [AC_MSG_RESULT([no])
+                    AC_MSG_ERROR([Herwig requires GoSam 2.0.4 or later, found ${tmp_gosamversion}])],
+                   [AC_MSG_RESULT([yes])])])
+
 AM_CONDITIONAL(HAVE_GOSAM,[test "x$have_gosam" = "xlib" ])
 
 if test "x$have_gosam" = "xlib"  ; then
      	LOAD_GOSAM="library"
      	CREATE_GOSAM="create"
      	INSERT_GOSAM="insert"
      	DO_GOSAM="do"
 else
      	LOAD_GOSAM="# library"
 	CREATE_GOSAM="# create"
      	INSERT_GOSAM="# insert"
      	DO_GOSAM="# do"
 fi
 
 AC_SUBST([LOAD_GOSAM])
 AC_SUBST([CREATE_GOSAM])
 AC_SUBST([INSERT_GOSAM])
 AC_SUBST([DO_GOSAM])
 
 
 ])
 
 
 dnl ##### gosam-contrib #####
 AC_DEFUN([HERWIG_CHECK_GOSAM_CONTRIB],
 [
 AC_MSG_CHECKING([for gosam-contrib])
 
 AC_ARG_WITH([gosam-contrib],
     AS_HELP_STRING([--with-gosam-contrib=DIR], [Installation path of gosam-contrib]),
     [],
     [with_gosam_contrib=no]
 )
 
 AC_MSG_RESULT([$with_gosam_contrib])
 
 AS_IF([test "x$with_gosam_contrib" = "xno" -a "x$with_gosam" != "xno"],
       [AC_CHECK_FILES(
       ${with_gosam}/lib/libsamurai.so,
       [with_gosam_contrib=${with_gosam}], [])
 ])
 
 AS_IF([test "x$with_gosam_contrib" = "xno" -a "x$with_gosam" != "xno"],
       [AC_CHECK_FILES(
       ${with_gosam}/lib64/libsamurai.so,
       [with_gosam_contrib=${with_gosam}], [])
 ])
 
 AS_IF([test "x$with_gosam_contrib" = "xno" -a "x$with_gosam" != "xno"],
       [AC_CHECK_FILES(
       ${with_gosam}/lib/libsamurai.dylib,
       [with_gosam_contrib=${with_gosam}], [])
 ])
 
 AS_IF([test "x$with_gosam_contrib" = "xno" -a "x$with_gosam" != "xno"],
       [AC_CHECK_FILES(
       ${with_gosam}/lib64/libsamurai.dylib,
       [with_gosam_contrib=${with_gosam}], [])
 ])
 
 AS_IF([test "x$with_gosam_contrib" = "xno" -a "x$with_gosam" != "xno"],
       [AC_MSG_ERROR([GoSam requested without requesting GoSam-Contrib])])
 
 AS_IF([test "x$with_gosam_contrib" != "xno"],
       [AC_CHECK_FILES(
       ${with_gosam_contrib}/lib/libsamurai.so,
       [have_gosam_contrib=lib], [have_gosam_contrib=no])],
       [have_gosam_contrib=no])
 
 AS_IF([test "x$with_gosam_contrib" != "xno" -a "x$have_gosam_contrib" = "xno" ],
       [AC_CHECK_FILES(
       ${with_gosam_contrib}/lib64/libsamurai.so,
       [have_gosam_contrib=lib64], [have_gosam_contrib=no])])
 
 AS_IF([test "x$with_gosam_contrib" != "xno" -a "x$have_gosam_contrib" = "xno" ],
       [AC_CHECK_FILES(
       ${with_gosam_contrib}/lib/libsamurai.dylib,
       [have_gosam_contrib=lib], [have_gosam_contrib=no])])
 
 AS_IF([test "x$with_gosam_contrib" != "xno" -a "x$have_gosam_contrib" = "xno" ],
       [AC_CHECK_FILES(
       ${with_gosam_contrib}/lib64/libsamurai.dylib,
       [have_gosam_contrib=lib64], [have_gosam_contrib=no])])
 
 
 
 
 
 
 
 AS_IF([test "x$have_gosam_contrib" != "xno"],
       [GOSAMCONTRIBPREFIX=${with_gosam_contrib}
       AC_SUBST(GOSAMCONTRIBPREFIX)
       ])
 
 AS_IF([test "x$have_gosam_contrib" = "xlib"],
       [GOSAMCONTRIBLIBS=${with_gosam_contrib}/lib
       AC_SUBST(GOSAMCONTRIBLIBS)
       ])
 
 AS_IF([test "x$have_gosam_contrib" = "xlib64"],
       [GOSAMCONTRIBLIBS=${with_gosam_contrib}/lib64
       AC_SUBST(GOSAMCONTRIBLIBS)
       ])
 
 AS_IF([test "x$with_gosam_contrib" != "xno"  -a "x$have_gosam_contrib" = "xno"],
       [AC_MSG_ERROR([GoSam-Contrib requested but not found])])
 
 AM_CONDITIONAL(HAVE_GOSAM_CONTRIB,[test "x$have_gosam_contrib" = "xlib" -o "x$have_gosam_contrib" = "xlib64"])
 
 if test "x$have_gosam_contrib" = "xlib" -o "x$have_gosam_contrib" = "xlib64" ; then
         LOAD_GOSAM_CONTRIB="library"
         CREATE_GOSAM_CONTRIB="create"
         INSERT_GOSAM_CONTRIB="insert"
 else
         LOAD_GOSAM_CONTRIB="# library"
         CREATE_GOSAM_CONTRIB="# create"
         INSERT_GOSAM_CONTRIB="# insert"
 fi
 
 AC_SUBST([LOAD_GOSAM_CONTRIB])
 AC_SUBST([CREATE_GOSAM_CONTRIB])
 AC_SUBST([INSERT_GOSAM_CONTRIB])
 
 
 ])
 
 
 dnl ##### OpenLoops #####
 AC_DEFUN([HERWIG_CHECK_OPENLOOPS],
 [
 AC_MSG_CHECKING([for OpenLoops])
 
 AC_ARG_WITH([openloops],
     AS_HELP_STRING([--with-openloops=DIR], [Installation path of OpenLoops]),
     [],
     [with_openloops=no]
 
 )
 
 AC_MSG_RESULT([$with_openloops])
 
 AS_IF([test "x$with_openloops" != "xno"],
       [AC_CHECK_FILES(
       ${with_openloops}/lib/libopenloops.so,
       [have_openloops=lib], [have_openloops=no])],
       [have_openloops=no])
 
 AS_IF([test "x$with_openloops" != "xno" -a "x$have_openloops" = "xno" ],
       [AC_CHECK_FILES(
       ${with_openloops}/lib/libopenloops.dylib,
       [have_openloops=lib], [have_openloops=no])])
 
 AS_IF([test "x$with_openloops" != "xno" -a "x$have_openloops" = "xno" ],
       [AC_CHECK_FILES(
       ${with_openloops}/lib64/libopenloops.so,
       [have_openloops=lib64], [have_openloops=no])])
 
 
 AS_IF([test "x$with_openloops" != "xno" -a "x$have_openloops" = "xno" ],
       [AC_CHECK_FILES(
       ${with_openloops}/lib64/libopenloops.dylib,
       [have_openloops=lib64], [have_openloops=no])])
 
 
 
 
 
 AS_IF([test "x$have_openloops" = "xlib"],
       [OPENLOOPSLIBS=${with_openloops}/lib
       AC_SUBST(OPENLOOPSLIBS)
       ])
 
 AS_IF([test "x$have_openloops" = "xlib64"],
       [OPENLOOPSLIBS=${with_openloops}/lib64
       AC_SUBST(OPENLOOPSLIBS)
       ])
 
 AS_IF([test "x$with_openloops" != "xno" -a "x$have_openloops" = "xno"],
       [AC_MSG_ERROR([OpenLoops requested but not found])])
 
 AM_CONDITIONAL(HAVE_OPENLOOPS,[test "x$have_openloops" = "xlib" -o "x$have_openloops" = "xlib64"])
 
 if test "x$have_openloops" = "xlib" -o "x$have_openloops" = "xlib64" ; then
         OPENLOOPSPREFIX=${with_openloops}
      	LOAD_OPENLOOPS="library"
      	CREATE_OPENLOOPS="create"
      	INSERT_OPENLOOPS="insert"
      	SET_OPENLOOPS="set"
      	DO_OPENLOOPS="do"
      	MKDIR_OPENLOOPS="mkdir"
 else
      	LOAD_OPENLOOPS="# library"
 	CREATE_OPENLOOPS="# create"
      	INSERT_OPENLOOPS="# insert"
      	SET_OPENLOOPS="# set"
      	DO_OPENLOOPS="# do"
      	MKDIR_OPENLOOPS="# mkdir"
 fi
 
 AC_SUBST([OPENLOOPSPREFIX])
 AC_SUBST([LOAD_OPENLOOPS])
 AC_SUBST([CREATE_OPENLOOPS])
 AC_SUBST([INSERT_OPENLOOPS])
 AC_SUBST([SET_OPENLOOPS])
 AC_SUBST([DO_OPENLOOPS])
 AC_SUBST([MKDIR_OPENLOOPS])
 
 ])
 
 #########################################
 
 dnl ##### madgraph #####
 AC_DEFUN([HERWIG_CHECK_MADGRAPH],
 [
 AC_MSG_CHECKING([for MadGraph])
 
 AC_ARG_WITH([madgraph],
     AS_HELP_STRING([--with-madgraph=DIR], [Installation path of MadGraph]),
     [],
     [with_madgraph=no]
 )
 
 AC_MSG_RESULT([$with_madgraph])
 
 AS_IF([test "x$with_madgraph" != "xno"],
       [AC_CHECK_FILES(
       ${with_madgraph}/bin/mg5_aMC,
       [have_madgraph=yes], [have_madgraph=no])],
       [have_madgraph=no])
 
 AS_IF([test "x$have_madgraph" = "xyes"],
       [MADGRAPHPREFIX=${with_madgraph}
       AC_SUBST(MADGRAPHPREFIX)
       ])
 
 AS_IF([test "x$with_madgraph" != "xno"  -a "x$have_madgraph" = "xno"],
       [AC_MSG_ERROR([MadGraph requested but not found])])
 
 AM_CONDITIONAL(HAVE_MADGRAPH,[test "x$have_madgraph" = "xyes" ])
 
 if test "x$have_madgraph" = "xyes"  ; then
      	LOAD_MADGRAPH="library"
      	CREATE_MADGRAPH="create"
      	INSERT_MADGRAPH="insert"
      	SET_MADGRAPH="set"
      	DO_MADGRAPH="do"
 else
      	LOAD_MADGRAPH="# library"
 	CREATE_MADGRAPH="# create"
      	INSERT_MADGRAPH="# insert"
      	SET_MADGRAPH="# set"
      	DO_MADGRAPH="# do"
 fi
 
 AC_SUBST([LOAD_MADGRAPH])
 AC_SUBST([CREATE_MADGRAPH])
 AC_SUBST([INSERT_MADGRAPH])
 AC_SUBST([SET_MADGRAPH])
 AC_SUBST([DO_MADGRAPH])
 
 ])
 
 
 dnl ##### EvtGen #####
 AC_DEFUN([HERWIG_CHECK_EVTGEN],
 [
 AC_MSG_CHECKING([for evtgen])
 
 AC_ARG_WITH([evtgen],
     AS_HELP_STRING([--with-evtgen=DIR], [Installation path of EvtGen]),
     [],
     [with_evtgen=no]
 )
 
 AC_MSG_RESULT([$with_evtgen])
 
 AS_IF([test "x$with_evtgen" != "xno"],
       [AC_CHECK_FILES(
       ${with_evtgen}/lib/libEvtGenExternal.so,
       [have_evtgen=lib], [have_evtgen=no])],
       [have_evtgen=no])
 
 AS_IF([test "x$with_evtgen" != "xno" -a "x$have_evtgen" = "xno"],
       [AC_CHECK_FILES(
       ${with_evtgen}/lib64/libEvtGenExternal.so,
       [have_evtgen=lib64], [have_evtgen=no])])
 
 AS_IF([test "x$with_evtgen" != "xno" -a "x$have_evtgen" = "xno" ],
       [AC_CHECK_FILES(
       ${with_evtgen}/lib/libEvtGenExternal.dylib,
       [have_evtgen=lib], [have_evtgen=no])])
 
 AS_IF([test "x$have_evtgen" = "xlib" -o "x$have_evtgen" = "xlib64" ],
       [EVTGENPREFIX=${with_evtgen}
       AC_SUBST(EVTGENPREFIX)
       ])
 
 AS_IF([test "x$with_evtgen" != "xno"  -a "x$have_evtgen" = "xno"],
       [AC_MSG_ERROR([EvtGen requested but not found])])
 
 AC_SUBST([EVTGENINCLUDE],[-I$EVTGENPREFIX/include])
 
 AM_CONDITIONAL(HAVE_EVTGEN,[test "x$have_evtgen" = "xlib" ])
 
 if test "x$have_evtgen" = "xlib"  ; then
      	LOAD_EVTGEN_DECAYS="read EvtGenBDecays.in"
      	LOAD_EVTGEN_DECAYER="read EvtGenDecayer.in"
 	EVTGENLIBS="-L$with_evtgen/lib -lEvtGen -lEvtGenExternal"
 elif test "x$have_evtgen" = "xlib64"  ; then
       LOAD_EVTGEN_DECAYS="read EvtGenBDecays.in"
       LOAD_EVTGEN_DECAYER="read EvtGenDecayer.in"
   EVTGENLIBS="-L$with_evtgen/lib64 -lEvtGen -lEvtGenExternal"
 else
      	LOAD_EVTGEN_DECAYS="read HerwigBDecays.in"
      	LOAD_EVTGEN_DECAYER="#read EvtGenDecayer.in"
 	EVTGENLIBS=""
 fi
 
 AC_SUBST([LOAD_EVTGEN_DECAYS])
 AC_SUBST([LOAD_EVTGEN_DECAYER])
 AC_SUBST([EVTGENLIBS])
 
 
 ])
 
 AC_DEFUN([HERWIG_CHECK_PYTHIA],
 [
 dnl check if a directory is specified for Pythia
 AC_ARG_WITH(pythia,
             [AC_HELP_STRING([--with-pythia=dir], 
                             [Assume the given directory for Pythia])])
 
 dnl search for the pythia-config script
 if test "$with_pythia" = ""; then
    AC_PATH_PROG(pythiaconfig, pythia8-config, no)
 else
    AC_PATH_PROG(pythiaconfig, pythia8-config, no, ${with_pythia}/bin)
 fi
 
 if test "${pythiaconfig}" = "no"; then
    AC_MSG_CHECKING(Pythia)
    AC_MSG_RESULT(no);
 #   $2
 else
 
    PYTHIA8DATA=`${pythiaconfig} --datadir`/xmldoc
 
 fi
 
 AC_SUBST(PYTHIA8DATA)
 
 ])
 
 dnl CHECK PYTHIA END
 
 dnl ###### GSL ######
 AC_DEFUN([HERWIG_CHECK_GSL],
 [
 AC_MSG_CHECKING([for gsl location])
 GSLINCLUDE=""
 GSLLIBS=""
 
 AC_ARG_WITH(gsl,
         AC_HELP_STRING([--with-gsl=DIR],[location of gsl installation @<:@default=system libs@:>@]),
         [],
 	[with_gsl=system])
 
 if test "x$with_gsl" = "xno"; then
 AC_MSG_ERROR([libgsl is required. Please install the GNU scientific library and header files.])
 fi
 
 if test "x$with_gsl" = "xsystem"; then
 	AC_MSG_RESULT([in system libraries])
 	oldlibs="$LIBS"
 	AC_CHECK_LIB(m,main)
 	AC_CHECK_LIB(gslcblas,main)
 	AC_CHECK_LIB(gsl,main,[],
 			[
 			AC_MSG_ERROR([Cannot find libgsl. Please install the GNU scientific library and header files or use --with-gsl=.])
 			]
 		     )
 	GSLLIBS="$LIBS"
 	GSLPATH="$with_gsl"
 	LIBS=$oldlibs
 else
 	if test "`uname -m`" = "x86_64" -a -e "$with_gsl/lib64/libgsl.a" -a -d "$with_gsl/include/gsl"; then
 		AC_MSG_RESULT([found in $with_gsl])
 		GSLLIBS="-L$with_gsl/lib64 -R$with_gsl/lib64 -lgslcblas -lgsl"
 		GSLINCLUDE="-I$with_gsl/include"
 		GSLPATH="$with_gsl"
 	elif test -e "$with_gsl/lib/libgsl.a" -a -d "$with_gsl/include/gsl"; then
 		AC_MSG_RESULT([found in $with_gsl])
 		GSLLIBS="-L$with_gsl/lib -R$with_gsl/lib -lgslcblas -lgsl"
 		GSLINCLUDE="-I$with_gsl/include"
 		GSLPATH="$with_gsl"
 	else
 		AC_MSG_RESULT([not found])
 		AC_MSG_ERROR([Can't find $with_gsl/lib/libgsl.a or the headers in $with_gsl/include])
 	fi
 fi
 
 AC_SUBST(GSLINCLUDE)
 AC_SUBST(GSLLIBS)
 AC_SUBST(GSLPATH)
 ])
 
 dnl ##### COMPILERFLAGS #####
 AC_DEFUN([HERWIG_COMPILERFLAGS],
 [
 AC_REQUIRE([HERWIG_CHECK_GSL])
 AC_REQUIRE([HERWIG_CHECK_THEPEG])
 AC_REQUIRE([BOOST_REQUIRE])
 AC_REQUIRE([AX_COMPILER_VENDOR])
 
 AM_CPPFLAGS="-I\$(top_builddir)/include $THEPEGINCLUDE \$(GSLINCLUDE) \$(BOOST_CPPFLAGS)"
 
 AC_MSG_CHECKING([for debugging mode])
 AC_ARG_ENABLE(debug,
         AC_HELP_STRING([--enable-debug],[debug mode, use --enable-debug=slow for additional options that slow down the run.]),
         [],
         [enable_debug=no]
         )
 AC_MSG_RESULT([$enable_debug])
 
 if test "x$enable_debug" = "xno"; then
 	debugflags=""
 else
 	debugflags="-g"
 fi
 
 dnl -Wfloat-equal -fvisibility-inlines-hidden -Wctor-dtor-privacy -Weffc++
 if test -n "$GCC"; then
 	warnflags="-pedantic -Wall -Wextra -Wno-overloaded-virtual"
 
 	if test "x$enable_debug" = "xslow"; then
 		debugflags="$debugflags -fno-inline"
 		AM_CPPFLAGS="$AM_CPPFLAGS -D_GLIBCXX_DEBUG"
 	fi
 fi
 
 dnl do an actual capability check on ld instead of this workaround
 case "${host}" in
   *-darwin*)
      ;;
   *)
      AM_LDFLAGS="-Wl,--enable-new-dtags"
      ;;
 esac
 
 case "${ax_cv_cxx_compiler_vendor}" in
      gnu)
         AM_CXXFLAGS="-pedantic -Wall -W"
         ;;
      clang)
         AM_CXXFLAGS="-pedantic -Wall -Wno-overloaded-virtual -Wno-unused-function -Wno-unused-parameter"
 dnl  -Wno-unneeded-internal-declaration
         ;;
      intel)
         AM_CXXFLAGS="-strict-ansi -Wall -wd13000,1418,981,444,383,1599,1572,2259,980"
         ;;
 esac
 
 
 
 AC_SUBST(AM_CPPFLAGS)
 AC_SUBST(AM_CFLAGS,  ["$warnflags $debugflags"])
 AC_SUBST(AM_CXXFLAGS,["$AM_CXXFLAGS $warnflags $debugflags"])
 AC_SUBST(AM_FCFLAGS,  ["$debugflags"])
 AC_SUBST(AM_LDFLAGS)
 ])
 
 AC_DEFUN([HERWIG_ENABLE_MODELS],
 [
 AC_MSG_CHECKING([if BSM models should be built])
 
 AC_ARG_ENABLE(models,
         AC_HELP_STRING([--disable-models],[Turn off compilation of BSM models.]),
         [],
         [enable_models=yes]
         )
 AC_MSG_RESULT([$enable_models])
 
 LOAD_BSM=""
 if test "$enable_models" = "yes"; then
 LOAD_BSM="read BSMlibs.in"
 fi
 AC_SUBST(LOAD_BSM)
 
 AM_CONDITIONAL(WANT_BSM,[test "$enable_models" = "yes"])
 ])
 
 AC_DEFUN([HERWIG_OVERVIEW],
 [
 FCSTRING=`$FC --version | head -1`
 CXXSTRING=`$CXX --version | head -1`
 CCSTRING=`$CC --version | head -1`
 if test "x$PYTHON" != "x:"
 then
    python_was_found="yes, using Python $PYTHON_VERSION"
 else
    python_was_found="no, requires Python >= 2.6"
 fi
 cat << _HW_EOF_ > config.herwig
 *****************************************************
 *** $PACKAGE_STRING configuration summary
 *** Please include this information in bug reports!
 ***--------------------------------------------------
 *** Prefix:		$prefix
 ***
 *** BSM models:		$enable_models
 *** UFO converter:	${python_was_found}
 ***
 *** Herwig debug mode:	$enable_debug
 ***
 *** ThePEG:		$with_thepeg
 *** ThePEG headers:	$with_thepeg_headers
 ***
 *** GoSam:		$with_gosam
 *** GoSam-Contrib:      $with_gosam_contrib
 *** MadGraph:        	$with_madgraph
 *** njet:		$with_njet
 *** OpenLoops:		$with_openloops
 *** VBFNLO:		$with_vbfnlo
 ***
 *** EvtGen:		$with_evtgen
 *** GSL:		$with_gsl
 *** boost:              ${BOOST_CPPFLAGS:-system}
 *** Fastjet:		${fjconfig}
 ***
 *** Host:		$host
 *** CC:			$CCSTRING
 *** CXX:		$CXXSTRING
 *** FC:			$FCSTRING
 ***
 *** CXXFLAGS:		$CXXFLAGS
 *****************************************************
 _HW_EOF_
 ])
diff --git a/src/LHC-MB.in b/src/LHC-MB.in
--- a/src/LHC-MB.in
+++ b/src/LHC-MB.in
@@ -1,91 +1,62 @@
 # -*- ThePEG-repository -*-
 
 ################################################################################
 # This file contains our best tune to UE data from ATLAS at 7 TeV. More recent
 # tunes and tunes for other centre-of-mass energies as well as more usage
 # instructions can be obtained from this Herwig wiki page:
 # http://projects.hepforge.org/herwig/trac/wiki/MB_UE_tunes
 # The model for soft interactions and diffractions is explained in
 # [S. Gieseke, P. Kirchgaesser, F. Loshaj, arXiv:1612.04701]
 ################################################################################
 
 read snippets/PPCollider.in
 
 ##################################################
 # Technical parameters for this run
 ##################################################
 cd /Herwig/Generators
 ##################################################
 # LHC physics parameters (override defaults here) 
 ##################################################
 set EventGenerator:EventHandler:LuminosityFunction:Energy 7000.0
 
 # Intrinsic pT tune extrapolated to LHC energy
 set /Herwig/Shower/ShowerHandler:IntrinsicPtGaussian 2.2*GeV
 
 # Minimum Bias
 read snippets/MB.in
 
+# Read in parameters of the soft model recommended for MB/UE simulations
+read snippets/SoftTune.in
+
 # Diffraction model
 read snippets/Diffraction.in
 
+##################################################
 # Analyses
-cd /Herwig/Analysis
-create ThePEG::RivetAnalysis RivetAnalysis RivetAnalysis.so
+##################################################
 
-cd /Herwig/Generators
-insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
+# cd /Herwig/Analysis
+# create ThePEG::RivetAnalysis RivetAnalysis RivetAnalysis.so
 
-# ATLAS
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2012_I1084540
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2010_S8591806
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2010_S8894728
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2011_S8994773
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2010_S8918562
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2011_I894867
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2012_I1124167
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2014_I1298811
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2012_I1091481
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2016_I1426695
+# cd /Herwig/Generators
+# insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
-# ATLAS 13 TeV
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2016_I1467230
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2016_I1419652
+# insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_20XX_XXXXXXX
 
 
-# CMS
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 CMS_2015_I1356998
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 CMS_2010_S8656010
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 CMS_2011_S8884919
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 CMS_2011_S8978280
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 CMS_2012_I1193338
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 CMS_2013_I1218372
-
-
-# Alice
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ALICE_2010_S8624100
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ALICE_2010_S8625980
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ALICE_2010_S8706239
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ALICE_2011_S8909580
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ALICE_2011_S8945144
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ALICE_2012_I1181770
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ALICE_2014_I1300380
-
-# LHCb
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 LHCB_2014_I1281685
-
 #set /Herwig/Analysis/Plot:EventNumber 54
 #cd /Herwig/Generators
 #insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/Plot
 
 #insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/HepMCFile
 #set /Herwig/Analysis/HepMCFile:PrintEvent 1000000
 #set /Herwig/Analysis/HepMCFile:Format GenEvent
 #set /Herwig/Analysis/HepMCFile:Units GeV_mm
 #set /Herwig/Analysis/HepMCFile:Filename events.fifo
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 saverun LHC-MB EventGenerator
 
diff --git a/src/snippets/Makefile.am b/src/snippets/Makefile.am
--- a/src/snippets/Makefile.am
+++ b/src/snippets/Makefile.am
@@ -1,29 +1,30 @@
 BUILT_SOURCES = done-all-links
 
 snippetsdir = ${pkgdatadir}/snippets
 
 INPUTFILES = \
 DipoleShowerFiveFlavours.in \
 DipoleShowerFourFlavours.in \
 Particles-SetLonglivedParticlesStable.in \
 PDF-CT10.in \
 PDF-NNPDF30NLO.in \
 Matchbox.in \
 MonacoSampler.in \
 DipoleMerging.in \
 EECollider.in EPCollider.in PPCollider.in \
 MB.in \
 MB-DipoleShower.in \
 SoftModel.in \
-Diffraction.in
+Diffraction.in \
+SoftTune.in
 
 dist_snippets_DATA = $(INPUTFILES)
 
 CLEANFILES = done-all-links
 
 done-all-links: $(INPUTFILES)
 	@echo "Linking input files"
 	@for i in $(INPUTFILES); do \
 	if test -f $(srcdir)/$$i -a ! -e $$i; then \
 	$(LN_S) -f $(srcdir)/$$i; fi; done
 	@touch done-all-links
diff --git a/src/snippets/SoftTune.in b/src/snippets/SoftTune.in
new file mode 100644
--- /dev/null
+++ b/src/snippets/SoftTune.in
@@ -0,0 +1,8 @@
+# Recommended set of parameters for MB/UE runs
+
+set /Herwig/Hadronization/ColourReconnector:ReconnectionProbability 0.5
+set /Herwig/UnderlyingEvent/MPIHandler:pTmin0 3.502683
+set /Herwig/UnderlyingEvent/MPIHandler:InvRadius 1.402055
+set /Herwig/UnderlyingEvent/MPIHandler:Power 0.416852
+set /Herwig/Partons/RemnantDecayer:ladderPower -0.08
+set /Herwig/Partons/RemnantDecayer:ladderNorm 0.95