diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -1,38 +1,39 @@
 168ae2110e964d62fbc1331a1c2e095952a67748 release-2-5-2
 3abb4fa42e20e332796c2572334c2d77204cd0e0 release-2-4-2
 4796ca080aafd5daa3b7349b015cb1df944428a2 release-2-5-0
 76da042f056eb153981b4d005d5474ffb90a5e88 release-2-4-1
 81a684a558413c69df314365eabf09893ffd43d8 release-2-6-0
 bd75cd00d99f4bdbaed992daf98f0a73c0f91e9b release-2-4-0
 ff6ecc8d49ce10299303b050394bd5cb5837f1c3 release-2-5-1
 d0389f5453b2c210923e1adc7b872b18269de668 release-2-6-1
 f8998033021185942533b824607285feb3fbd2dc release-2-6-1a
 cead23e428b9aacaf2d709e722624e54f844498b release-2-6-1b
 191db4655439045f912cb21bd905e729d59ec7bc release-2-6-2
 edb538156e9c3d64bb842934b4cebf0126aeb9ea release-2-6-3
 eb4a104591859ecac18746b1ad54d6aa0c2a5d1a release-2-7-0
 568971ac5b3c1d044c9259f2280a8304fc5a62e9 trunk-before-QED
 6e3edb6cfeb4ee48687eb4eb3d016026fc59d602 trunk-after-QED
 633abb80b571aa23088957df60e9b0000bbb8a22 release-2-7-1
 1bdde095d2346c15ee548e5406a96f0fc6d6e0f1 beforeHQ
 a0f9fb821396092bdbeee532bcb0bd624f58335b before_MB_merge
 270c1e6b34aa7f758f1d9868c4d3e1ec4bf4e709 herwig-7-0-0
 6e0f198c1c2603ecd1a0b6cfe40105cda4bd58c5 herwig-7-0-1
 566c1de845a8070559cda45b1bdb40afa18cb2cc herwig-7-0-2
 f5c4aa956880f2def763ebd57de7b5bfa55cb1db herwig-7-0-3
 65282dedfc2e4bec184e68678dbf4c553c968f38 herwig-7-0-4
 541e7790b65ed423c86780bf66ec30e6b99b5a18 herwig-7-1-0
 dd35a1c12d57c047169e8c5fb18644972d49c6ac herwig-7-1-1
 0d651b079756b63713e32a1341d81e4dfc7eeb7b herwig-7-1-2
 4b97934bc41c861c4be04f563ffa68a94a982560 herwig-7-1-3
 97aca5398cfa1f3273804f03fa96fa0fa23eca61 herwig-7-1-4
 3d69fbe18c682c98891c5f9204947f2eb7a72686 herwig-7-1-5
 392e0bdc94f11d067dc24792a4b470b09eb8fdf7 herwig-7-2-0
 392e0bdc94f11d067dc24792a4b470b09eb8fdf7 herwig-7-2-0
 af22cb052ed5e3fd5323ec9a24693962efe8144d herwig-7-2-0
 f3047b8819217a3ea264adf423ab183c9ca9b3a1 herwig-7-1-6
 f3047b8819217a3ea264adf423ab183c9ca9b3a1 herwig-7-1-6
 c9519d355aeab14d43e4655faf78e2c7324b34a6 herwig-7-1-6
 af22cb052ed5e3fd5323ec9a24693962efe8144d herwig-7-2-0
 51f480cba67c56c2b6d5a65383254d6aafcd5cbd herwig-7-2-0
 b76dedb1f1f1bc42d676bca00019852b32003502 herwig-7-2-1
+474898bfc7f68305c654d6323f844c6cbd0921fc herwig-7.2.2
diff --git a/AUTHORS b/AUTHORS
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,58 +1,58 @@
 ================================================================================
-Herwig 7.2.0
+Herwig 7.2.2
 ================================================================================
 
 Please contact <herwig@projects.hepforge.org> for any queries.
 
 --------------------------------------------------------------------------------
 Herwig is actively developed by:
 --------------------------------------------------------------------------------
 
 Gavin Bewick
 Silvia Ferrario Ravasio
 Stefan Gieseke
 Patrick Kirchgaeßer
 Mohammad R. Masouminia
 Graeme Nail
 Andreas Papaefstathiou
 Simon Plätzer
 Christian Reuschle
 Peter Richardson
 Mike Seymour
 Andrzej Siödmok
 
 --------------------------------------------------------------------------------
 Former authors are:
 --------------------------------------------------------------------------------
 
 Ken Arnold
 Manuel Bähr
 Johannes Bellm
 Luca d'Errico
 Martyn Gigg
 David Grellscheid
 Nadine Fischer
 Keith Hamilton
 Marco A. Harrendorf
 Seyi Latunde-Dada
 Frashër Loshaj
 Radek Podskubka
 Daniel Rauch
 Michael Rauch
 Alberto Ribon
 Christian Röhr
 Pavel Růžička
 Peter Schichtel
 Alex Schofield
 Thomas Schuh
 Alexander Sherstnev
 Philip Stephens
 Martin Stoll
 Louise Suter
 Jon Tully
 Bryan Webber
 Stephen Webster
 Alix Wilcock
 David Winn
 Benedikt Zimmermann
 
diff --git a/Decay/EvtGen/Makefile.am b/Decay/EvtGen/Makefile.am
--- a/Decay/EvtGen/Makefile.am
+++ b/Decay/EvtGen/Makefile.am
@@ -1,12 +1,12 @@
 pkglib_LTLIBRARIES = HwEvtGenInterface.la
 
 HwEvtGenInterface_la_SOURCES = \
 EvtGenInterface.cc EvtGenInterface.h EvtGenInterface.fh \
 EvtGenRandom.h \
 EvtGenDecayer.cc EvtGenDecayer.h
 
 HwEvtGenInterface_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 2:0:0
-HwEvtGenInterface_la_LIBADD = $(EVTGENLIBS)
+HwEvtGenInterface_la_LIBADD = $(EVTGENLIBS) $(PYTHIA8LIB)
 HwEvtGenInterface_la_CPPFLAGS = $(AM_CPPFLAGS) $(EVTGENINCLUDE) \
 -DEVTGEN_PREFIX="\"$(EVTGENPREFIX)\"" \
 -DPYTHIA8DATA="\"$(PYTHIA8DATA)\""
diff --git a/Decay/Makefile.am b/Decay/Makefile.am
--- a/Decay/Makefile.am
+++ b/Decay/Makefile.am
@@ -1,256 +1,256 @@
 SUBDIRS = FormFactors Tau Baryon VectorMeson HeavyMeson Perturbative \
 	  WeakCurrents ScalarMeson TensorMeson Partonic General Radiation
 
 if HAVE_EVTGEN
 SUBDIRS += EvtGen
 endif
 
 noinst_LTLIBRARIES = libHwDecay.la
 
 libHwDecay_la_LIBADD = \
 $(top_builddir)/PDT/libHwPDT.la
 
 nodist_libHwDecay_la_SOURCES =  \
 hwdecay__all.cc
 
 BUILT_SOURCES  = hwdecay__all.cc
 CLEANFILES = hwdecay__all.cc
 
 hwdecay__all.cc : $(DIR_H_FILES) $(DIR_CC_FILES) Makefile
 	@echo "Concatenating .cc files into $@"
 	@$(top_srcdir)/cat_with_cpplines $(DIR_CC_FILES) > $@
 
 EXTRA_DIST = $(ALL_H_FILES) $(ALL_CC_FILES)
 
 DIR_H_FILES = $(addprefix $(srcdir)/,$(ALL_H_FILES))
 ALL_H_FILES = \
 DecayIntegrator.fh DecayIntegrator.h \
 PhaseSpaceMode.fh PhaseSpaceMode.h \
 HwDecayerBase.fh HwDecayerBase.h \
 HwDecayHandler.h \
 DecayVertex.fh DecayVertex.h \
 DecayMatrixElement.fh DecayMatrixElement.h \
 TwoBodyDecayMatrixElement.h \
 GeneralDecayMatrixElement.fh GeneralDecayMatrixElement.h \
 BranchingRatioReweighter.h\
 PerturbativeDecayer.h \
 ResonanceHelpers.h PhaseSpaceChannel.h IsoSpin.h
 
 DIR_CC_FILES = $(addprefix $(srcdir)/,$(ALL_CC_FILES))
 ALL_CC_FILES = \
 DecayIntegrator.cc \
 PhaseSpaceChannel.cc \
 PhaseSpaceMode.cc \
 HwDecayerBase.cc \
 HwDecayHandler.cc \
 DecayVertex.cc \
 DecayMatrixElement.cc \
 TwoBodyDecayMatrixElement.cc \
 GeneralDecayMatrixElement.cc \
 BranchingRatioReweighter.cc\
 PerturbativeDecayer.cc
 
 ##################
 
 pkglib_LTLIBRARIES = Hw64Decay.la
 
 Hw64Decay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 11:0:0
+$(AM_LDFLAGS) -module -version-info 12:0:0
 
 Hw64Decay_la_SOURCES = \
 Hw64Decayer.h Hw64Decayer.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwMamboDecay.la
 
 HwMamboDecay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 12:0:0
+$(AM_LDFLAGS) -module -version-info 13:0:0
 
 HwMamboDecay_la_SOURCES = \
 MamboDecayer.h MamboDecayer.cc
 
 ##################
 
 noinst_LTLIBRARIES += libHwFormFactor.la
 
 libHwFormFactor_la_SOURCES = \
 FormFactors/BaryonFormFactor.cc \
 FormFactors/ScalarFormFactor.cc \
 FormFactors/BtoSGammaHadronicMass.cc \
 FormFactors/KMatrix.cc \
 FormFactors/ScalarAmplitude.cc \
 FormFactors/BaryonFormFactor.fh \
 FormFactors/BaryonFormFactor.h \
 FormFactors/ScalarFormFactor.fh \
 FormFactors/ScalarFormFactor.h \
 FormFactors/BtoSGammaHadronicMass.h \
 FormFactors/BtoSGammaHadronicMass.fh \
 FormFactors/KMatrix.h \
 FormFactors/KMatrix.fh \
 FormFactors/ScalarAmplitude.h \
 FormFactors/ScalarAmplitude.fh
 
 pkglib_LTLIBRARIES += HwFormFactors.la
 
 HwFormFactors_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 12:0:0
+$(AM_LDFLAGS) -module -version-info 13:0:0
 
 HwFormFactors_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/FormFactors
 
 nodist_HwFormFactors_la_SOURCES = \
 FormFactors/Formfactor__all.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwTauDecay.la
 
 HwTauDecay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 12:0:0
+$(AM_LDFLAGS) -module -version-info 13:0:0
 
 HwTauDecay_la_SOURCES = \
 Tau/TauDecayer.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwBaryonDecay.la
 
 HwBaryonDecay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 11:0:0
+$(AM_LDFLAGS) -module -version-info 12:0:0
 
 HwBaryonDecay_la_LIBADD = \
 $(top_builddir)/PDT/libHwBaryonWidth.la
 
 HwBaryonDecay_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/Baryon
 
 nodist_HwBaryonDecay_la_SOURCES = \
 Baryon/BaryonDecayer__all.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwVMDecay.la
 
 HwVMDecay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 11:0:0
+$(AM_LDFLAGS) -module -version-info 12:0:0
 
 HwVMDecay_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/VectorMeson
 
 nodist_HwVMDecay_la_SOURCES = \
 VectorMeson/VMDecayer__all.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwPerturbativeDecay.la 
 
 HwPerturbativeDecay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 12:0:0
+$(AM_LDFLAGS) -module -version-info 13:0:0
 
 HwPerturbativeDecay_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/Perturbative
 
 nodist_HwPerturbativeDecay_la_SOURCES = \
 Perturbative/Perturbative__all.cc
 
 ##################
 
 noinst_LTLIBRARIES += libHwWeakCurrent.la
 libHwWeakCurrent_la_SOURCES = \
 WeakCurrents/WeakCurrent.cc \
 WeakCurrents/LeptonNeutrinoCurrent.cc \
 WeakCurrents/WeakCurrent.fh \
 WeakCurrents/WeakCurrent.h \
 WeakCurrents/LeptonNeutrinoCurrent.fh \
 WeakCurrents/LeptonNeutrinoCurrent.h \
 WeakCurrents/WeakBaryonCurrent.cc \
 WeakCurrents/WeakBaryonCurrent.h
 
 pkglib_LTLIBRARIES += HwWeakCurrents.la
 
 HwWeakCurrents_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 12:0:0
+$(AM_LDFLAGS) -module -version-info 13:0:0
 
 HwWeakCurrents_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/WeakCurrents
 
 nodist_HwWeakCurrents_la_SOURCES = \
 WeakCurrents/WeakCurrents__all.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwHMDecay.la
 
 HwHMDecay_la_LDFLAGS = \
 $(AM_LDFLAGS) -module -version-info 11:0:0
 
 HwHMDecay_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/HeavyMeson
 
 nodist_HwHMDecay_la_SOURCES = \
 HeavyMeson/HMDecayer__all.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwSMDecay.la
 
 HwSMDecay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 13:0:0
+$(AM_LDFLAGS) -module -version-info 14:0:0
 
 HwSMDecay_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/ScalarMeson
 
 nodist_HwSMDecay_la_SOURCES = \
 ScalarMeson/SMDecayer__all.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwTMDecay.la
 
 HwTMDecay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 11:0:0
+$(AM_LDFLAGS) -module -version-info 12:0:0
 
 HwTMDecay_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/TensorMeson
 
 nodist_HwTMDecay_la_SOURCES = \
 TensorMeson/TMDecayer__all.cc
 
 ##################
 
 pkglib_LTLIBRARIES += HwPartonicDecay.la
 
 HwPartonicDecay_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 12:0:0
+$(AM_LDFLAGS) -module -version-info 13:0:0
 
 HwPartonicDecay_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/Partonic
 
 nodist_HwPartonicDecay_la_SOURCES = \
 Partonic/Partonic__all.cc
 
 ##################
 
 noinst_LTLIBRARIES += libHwDecRad.la
 
 libHwDecRad_la_SOURCES = \
 Radiation/DecayRadiationGenerator.cc \
 Radiation/QEDRadiationHandler.cc \
 Radiation/DecayRadiationGenerator.h \
 Radiation/DecayRadiationGenerator.fh \
 Radiation/QEDRadiationHandler.fh \
 Radiation/QEDRadiationHandler.h
 
 
 pkglib_LTLIBRARIES += HwSOPHTY.la
 
 HwSOPHTY_la_LDFLAGS = \
-$(AM_LDFLAGS) -module -version-info 6:0:0
+$(AM_LDFLAGS) -module -version-info 7:0:0
 
 HwSOPHTY_la_CPPFLAGS = \
 $(AM_CPPFLAGS) -I$(srcdir)/Radiation
 
 nodist_HwSOPHTY_la_SOURCES = \
 Radiation/Sophty__all.cc
 ##################
diff --git a/Decay/WeakCurrents/OmegaPionSNDCurrent.cc b/Decay/WeakCurrents/OmegaPionSNDCurrent.cc
--- a/Decay/WeakCurrents/OmegaPionSNDCurrent.cc
+++ b/Decay/WeakCurrents/OmegaPionSNDCurrent.cc
@@ -1,365 +1,365 @@
 // -*- C++ -*-
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the OmegaPionSNDCurrent class.
 //
 
 #include "OmegaPionSNDCurrent.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/EventRecord/Particle.h"
 #include "ThePEG/Repository/UseRandom.h"
 #include "ThePEG/Repository/EventGenerator.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Helicity/epsilon.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "Herwig/Utilities/Kinematics.h"
 
 using namespace Herwig;
 
 OmegaPionSNDCurrent::OmegaPionSNDCurrent() {
   // modes handled
   addDecayMode(2,-1);
   addDecayMode(1,-1);
   addDecayMode(2,-2);
   setInitialModes(3);
   // amplitudes for the weights in the current
   amp_   = {1.,0.175,0.014};
   phase_ = {0.,124.,-63.};
   // rho masses and widths
   rhoMasses_ = {0.77526*GeV,1.510*GeV,1.720*GeV};
   rhoWidths_ = {0.1491 *GeV,0.44 *GeV,0.25 *GeV};
   // coupling
   gRhoOmegaPi_   = 15.9/GeV;
   //fRho_        = 4.9583;
   fRho_ = 5.06325;//evaluated with alphaEM in considered energy range
 }
 
 IBPtr OmegaPionSNDCurrent::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr OmegaPionSNDCurrent::fullclone() const {
   return new_ptr(*this);
 }
 
 void OmegaPionSNDCurrent::doinit() {
   WeakCurrent::doinit();
   assert(phase_.size()==amp_.size());
   wgts_.clear();
   Complex ii(0.,1.);
   for(unsigned int ix=0;ix<amp_.size();++ix) {
     double phi = phase_[ix]/180.*Constants::pi;
     wgts_.push_back(amp_[ix]*(cos(phi)+ii*sin(phi)));
   }
   mpi_ = getParticleData(ParticleID::piplus)->mass();
 }
 
 void OmegaPionSNDCurrent::persistentOutput(PersistentOStream & os) const {
   os << ounit(rhoMasses_,GeV) << ounit(rhoWidths_,GeV)
      << amp_ << phase_ << wgts_ << fRho_
      << ounit(gRhoOmegaPi_,1./GeV) << ounit(mpi_,GeV);
 }
 
 void OmegaPionSNDCurrent::persistentInput(PersistentIStream & is, int) {
   is >> iunit(rhoMasses_,GeV) >> iunit(rhoWidths_,GeV)
      >> amp_ >> phase_ >> wgts_ >> fRho_
      >> iunit(gRhoOmegaPi_,1./GeV) >> iunit(mpi_,GeV);
 }
 
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeClass<OmegaPionSNDCurrent,WeakCurrent>
 describeHerwigOmegaPionSNDCurrent("Herwig::OmegaPionSNDCurrent",
 				  "HwWeakCurrents.so");
 
 void OmegaPionSNDCurrent::Init() {
 
   static ClassDocumentation<OmegaPionSNDCurrent> documentation
     ("The OmegaPionSNDCurrent class provides a current for omega pi"
      " using the model of SND",
      "The current based on \\cite{Achasov:2016zvn} for $\\omega\\pi$ was used.\n",
      "\\bibitem{Achasov:2016zvn}"
      "M.~N.~Achasov {\\it et al.},\n"
      "%``Updated measurement of the $e^+e^- \\to \\omega \\pi^0 \\to \\pi^0\\pi^0\\gamma$ cross section with the SND detector,''\n"
      "Phys.\\ Rev.\\ D {\\bf 94} (2016) no.11,  112001\n"
      "doi:10.1103/PhysRevD.94.112001\n"
      "[arXiv:1610.00235 [hep-ex]].\n"
      "%%CITATION = doi:10.1103/PhysRevD.94.112001;%%\n"
      "%12 citations counted in INSPIRE as of 22 Aug 2018\n");
 
   static ParVector<OmegaPionSNDCurrent,Energy> interfaceRhoMasses
     ("RhoMasses",
      "The masses of the rho mesons",
      &OmegaPionSNDCurrent::rhoMasses_, GeV, -1, 775.26*MeV,
      0.5*GeV, 10.0*GeV,
      false, false, Interface::limited);
 
   static ParVector<OmegaPionSNDCurrent,Energy> interfaceRhoWidths
     ("RhoWidths",
      "The widths of the rho mesons",
      &OmegaPionSNDCurrent::rhoWidths_, GeV, -1, 0.1491*GeV,
      0.0*GeV, 10.0*GeV,
      false, false, Interface::limited);
 
   static ParVector<OmegaPionSNDCurrent,double> interfaceAmplitudes
     ("Amplitudes",
      "THe amplitudes for the different rho resonances",
      &OmegaPionSNDCurrent::amp_, -1, 1.0, 0.0, 10.0,
      false, false, Interface::limited);
 
   static ParVector<OmegaPionSNDCurrent,double> interfacePhase
     ("Phase",
      "The phases for the different rho resonances in degrees",
      &OmegaPionSNDCurrent::phase_, -1, 0., -360., 360.,
      false, false, Interface::limited);
 
   static Parameter<OmegaPionSNDCurrent,double> interfacefRho
     ("fRho",
      "The coupling of the photon and the rho meson",
      &OmegaPionSNDCurrent::fRho_, 4.9583, 0.0, 100.0,
      false, false, Interface::limited);
 
   static Parameter<OmegaPionSNDCurrent,InvEnergy> interfacegRhoOmegaPi
     ("gRhoOmegaPi",
      "The coupling rho-omega-pi",
      &OmegaPionSNDCurrent::gRhoOmegaPi_, 1./GeV,
      15.9/GeV, 0./GeV, 1000./GeV,
      false, false, Interface::limited);
 
 }
 
 // complete the construction of the decay mode for integration
 bool OmegaPionSNDCurrent::createMode(int icharge, tcPDPtr resonance,
 					 FlavourInfo flavour,
 					 unsigned int imode,PhaseSpaceModePtr mode,
 					 unsigned int iloc,int ires,
 					 PhaseSpaceChannel phase, Energy upp ) {
   // check the charge
   if((abs(icharge)!=3 && imode == 0) ||
      (   icharge!=0   && imode >= 1))
     return false;
   // check the total isospin
   if(flavour.I!=IsoSpin::IUnknown || flavour.I3!=IsoSpin::I3Unknown) {
     if(flavour.I!=IsoSpin::IOne) return false;
     // and check I_3
     switch(flavour.I3) {
     case IsoSpin::I3Zero:
       if(imode!=1) return false;
       break;
     case IsoSpin::I3One:
       if(imode>1 || icharge ==-3) return false;
       break;
     case IsoSpin::I3MinusOne:
       if(imode>1 || icharge ==3) return false;
       break;
     default:
       return false;
     }
   }
   // other flavour stuff
   if(flavour.strange != Strangeness::Unknown and flavour.strange != Strangeness::Zero) return false;
   if(flavour.charm   != Charm::Unknown       and flavour.charm   != Charm::Zero      ) return false;
   if(flavour.bottom  != Beauty::Unknown      and flavour.bottom  != Beauty::Zero     ) return false;
   // check that the mode is are kinematical allowed
   Energy min = getParticleData(ParticleID::omega)->massMin();
   if(imode==0)
     min += getParticleData(ParticleID::piplus)->mass();
   else
     min += getParticleData(ParticleID::pi0   )->mass();
   if(min>upp) return false;
   // set up the integration channels;
   vector<tPDPtr> rho;
   if(icharge==-3)
     rho = {getParticleData(-213),getParticleData(-100213),getParticleData(-30213)};
   else if(icharge==0)
     rho = {getParticleData( 113),getParticleData( 100113),getParticleData( 30113)};
   else if(icharge==3)
     rho = {getParticleData( 213),getParticleData( 100213),getParticleData( 30213)};
   for(unsigned int ix=0;ix<3;++ix) {
     if(resonance && resonance!=rho[ix]) continue;
     mode->addChannel((PhaseSpaceChannel(phase),ires,rho[ix],
 		      ires+1,iloc+1,ires+1,iloc+2));
   }
   // reset the masses and widths of the resonances if needed
   for(unsigned int ix=0;ix<3;++ix) {
     mode->resetIntermediate(rho[ix],rhoMasses_[ix],rhoWidths_[ix]);
   }
   return true;
 }
 
 // the particles produced by the current
 tPDVector OmegaPionSNDCurrent::particles(int icharge, unsigned int imode,int,int) {
   tPDVector extpart = {tPDPtr(),
 		       getParticleData(ParticleID::omega)};
   if(imode==0) {
     if(icharge==3)       extpart[0] = getParticleData(ParticleID::piplus );
     else if(icharge==-3) extpart[0] = getParticleData(ParticleID::piminus);
   }
   else {
     extpart[0] = getParticleData(ParticleID::pi0);
   }
   return extpart;
 }
 
 void OmegaPionSNDCurrent::constructSpinInfo(ParticleVector decay) const {
   vector<LorentzPolarizationVector> temp(3);
   for(unsigned int ix=0;ix<3;++ix) {
     temp[ix] = HelicityFunctions::polarizationVector(-decay[1]->momentum()
 						     ,ix,Helicity::outgoing);
   }
   ScalarWaveFunction::constructSpinInfo(decay[0],outgoing,true);
   VectorWaveFunction::constructSpinInfo(temp,decay[1],
 					outgoing,true,true);
 }
 
-// the hadronic currents    
-vector<LorentzPolarizationVectorE> 
+// the hadronic currents
+vector<LorentzPolarizationVectorE>
 OmegaPionSNDCurrent::current(tcPDPtr resonance,
 			      FlavourInfo flavour,
-			      const int imode, const int ichan, Energy & scale, 
+			      const int imode, const int ichan, Energy & scale,
 			      const tPDVector & outgoing,
 			      const vector<Lorentz5Momentum> & momenta,
 			      DecayIntegrator::MEOption) const {
   int icharge = outgoing[0]->iCharge()+outgoing[1]->iCharge();
   // check the charge
   if((abs(icharge)!=3 && imode == 0) ||
      (   icharge!=0   && imode == 1))
     return vector<LorentzPolarizationVectorE>();
   // check the total isospin
   if(flavour.I!=IsoSpin::IUnknown || flavour.I3!=IsoSpin::I3Unknown) {
     if(flavour.I!=IsoSpin::IOne) return vector<LorentzPolarizationVectorE>();
     // and check I_3
     switch(flavour.I3) {
     case IsoSpin::I3Zero:
       if(imode!=1) return vector<LorentzPolarizationVectorE>();
       break;
     case IsoSpin::I3One:
       if(imode>1 || icharge ==-3) return vector<LorentzPolarizationVectorE>();
       break;
     case IsoSpin::I3MinusOne:
       if(imode>1 || icharge ==3) return vector<LorentzPolarizationVectorE>();
       break;
     default:
       return vector<LorentzPolarizationVectorE>();
     }
   }
   // other flavour stuff
   if(flavour.strange != Strangeness::Unknown and flavour.strange != Strangeness::Zero) return vector<LorentzPolarizationVectorE>();
   if(flavour.charm   != Charm::Unknown       and flavour.charm   != Charm::Zero      ) return vector<LorentzPolarizationVectorE>();
   if(flavour.bottom  != Beauty::Unknown      and flavour.bottom  != Beauty::Zero     ) return vector<LorentzPolarizationVectorE>();
   useMe();
   vector<LorentzPolarizationVector> temp(3);
   for(unsigned int ix=0;ix<3;++ix)
     temp[ix] = HelicityFunctions::polarizationVector(-momenta[1],ix,Helicity::outgoing);
   // locate the particles
   Lorentz5Momentum q(momenta[0]+momenta[1]);
   // overall hadronic mass
   q.rescaleMass();
   scale=q.mass();
   Energy2 q2(q.m2());
   // compute the rho width
   Energy2 mr2(sqr(rhoMasses_[0]));
   Energy grho = rhoWidths_[0]*mr2/q2*pow((q2-4.*sqr(mpi_))/(mr2-4.*sqr(mpi_)),1.5);
   Energy qw = Kinematics::pstarTwoBodyDecay(q.mass(),momenta[0].mass(),momenta[1].mass());
   grho += pow<3,1>(qw)*sqr(gRhoOmegaPi_)/12./Constants::pi;
   unsigned int imin=0, imax = wgts_.size();
   if(ichan>0) {
     imin = ichan;
     imax = ichan+1;
   }
   if(resonance) {
     switch(resonance->id()/1000) {
     case 0:
       imin = 0;
       break;
     case 100:
       imin = 1;
       break;
     case 30 :
       imin = 2;
       break;
     default:
       assert(false);
     }
     imax=imin+1;
   }
   // compute the prefactor
   complex<InvEnergy> pre = gRhoOmegaPi_/fRho_;
   Complex bw(0.);
   for(unsigned int ix=imin;ix<imax;++ix) {
     Energy wid = ix==0 ? grho : rhoWidths_[ix];
     Energy2 mR2 = sqr(rhoMasses_[ix]);
     bw += mR2*wgts_[ix]/(mR2-q2-Complex(0.,1.)*q.mass()*wid);
   }
-  pre *=bw;
+  pre = pre * bw;
   vector<LorentzPolarizationVectorE> ret(3);
   for(unsigned int ix=0;ix<3;++ix) {
     ret[ix] = pre*Helicity::epsilon(q,temp[ix],momenta[1]);
   }
   if(imode==0) pre *=sqrt(2.);
   return ret;
 }
 
 bool OmegaPionSNDCurrent::accept(vector<int> id) {
   if(id.size()!=2){return false;}
   unsigned int npiplus(0),npi0(0),nomega(0);
   for(unsigned int ix=0;ix<id.size();++ix) {
     if(abs(id[ix])==ParticleID::piplus) ++npiplus;
     else if(id[ix]==ParticleID::omega)  ++nomega;
     else if(id[ix]==ParticleID::pi0)    ++npi0;
   }
   return nomega==1 && (npiplus==1||npi0==1);
 }
 
 unsigned int OmegaPionSNDCurrent::decayMode(vector<int> id) {
   int npip(0),npim(0),npi0(0),nomega(0);
   for(unsigned int ix=0;ix<id.size();++ix) {
     if(id[ix]==ParticleID::piplus)         ++npip;
     else if(id[ix]==ParticleID::piminus)   ++npim;
     else if(id[ix]==ParticleID::pi0)       ++npi0;
     else if(id[ix]==ParticleID::omega)   ++nomega;
   }
   if((npip==1 || npim == 1) && nomega==1)
     return 0;
   else
     return 1;
 }
 
 // output the information for the database
 void OmegaPionSNDCurrent::dataBaseOutput(ofstream & output,bool header,
 					  bool create) const {
   if(header) output << "update decayers set parameters=\"";
-  if(create) output << "create Herwig::OmegaPionSNDCurrent " << name() 
+  if(create) output << "create Herwig::OmegaPionSNDCurrent " << name()
 		    << " HwWeakCurrents.so\n";
   for(unsigned int ix=0;ix<rhoMasses_.size();++ix) {
-    if(ix<3) output << "newdef " << name() << ":RhoMasses " << ix 
+    if(ix<3) output << "newdef " << name() << ":RhoMasses " << ix
 		    << " " << rhoMasses_[ix]/GeV << "\n";
-    else     output << "insert " << name() << ":RhoMasses " << ix 
+    else     output << "insert " << name() << ":RhoMasses " << ix
 		    << " " << rhoMasses_[ix]/GeV << "\n";
   }
   for(unsigned int ix=0;ix<rhoWidths_.size();++ix) {
-    if(ix<3) output << "newdef " << name() << ":RhoWidths " << ix 
+    if(ix<3) output << "newdef " << name() << ":RhoWidths " << ix
 		    << " " << rhoWidths_[ix]/GeV << "\n";
-    else     output << "insert " << name() << ":RhoWidths " << ix 
+    else     output << "insert " << name() << ":RhoWidths " << ix
 		    << " " << rhoWidths_[ix]/GeV << "\n";
   }
   for(unsigned int ix=0;ix<amp_.size();++ix) {
-    if(ix<3) output << "newdef " << name() << ":Amplitudes " << ix 
+    if(ix<3) output << "newdef " << name() << ":Amplitudes " << ix
 		    << " " << amp_[ix] << "\n";
-    else     output << "insert " << name() << ":Amplitudes " << ix 
+    else     output << "insert " << name() << ":Amplitudes " << ix
 		    << " " << amp_[ix] << "\n";
   }
   for(unsigned int ix=0;ix<phase_.size();++ix) {
-    if(ix<3) output << "newdef " << name() << ":Phases " << ix 
+    if(ix<3) output << "newdef " << name() << ":Phases " << ix
 		    << " " << phase_[ix] << "\n";
-    else     output << "insert " << name() << ":Phases " << ix 
+    else     output << "insert " << name() << ":Phases " << ix
 		    << " " << phase_[ix] << "\n";
   }
   output << "newdef " << name() << ":fRho "    << fRho_ << "\n";
   output << "newdef " << name() << ":gRhoOmegaPi "    << gRhoOmegaPi_*GeV << "\n";
   WeakCurrent::dataBaseOutput(output,false,false);
-  if(header) output << "\n\" where BINARY ThePEGName=\"" 
+  if(header) output << "\n\" where BINARY ThePEGName=\""
 		    << fullName() << "\";" << endl;
 }
diff --git a/Decay/WeakCurrents/ThreePionCLEOCurrent.cc b/Decay/WeakCurrents/ThreePionCLEOCurrent.cc
--- a/Decay/WeakCurrents/ThreePionCLEOCurrent.cc
+++ b/Decay/WeakCurrents/ThreePionCLEOCurrent.cc
@@ -1,1284 +1,1283 @@
 // -*- C++ -*-
 //
 // ThreePionCLEOCurrent.cc is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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.
 //
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the ThreePionCLEOCurrent class.
 //
 
 #include "ThreePionCLEOCurrent.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/Interface/Parameter.h"
 #include "ThePEG/Interface/ParVector.h"
 #include "ThePEG/Interface/Switch.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "Herwig/PDT/ThreeBodyAllOnCalculator.h"
 #include "Herwig/Decay/ResonanceHelpers.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 
 using namespace Herwig;
 
 DescribeClass<ThreePionCLEOCurrent,WeakCurrent>
 describeHerwigThreePionCLEOCurrent("Herwig::ThreePionCLEOCurrent",
 				   "HwWeakCurrents.so");
 HERWIG_INTERPOLATOR_CLASSDESC(ThreePionCLEOCurrent,Energy,Energy2)
 
 ThreePionCLEOCurrent::ThreePionCLEOCurrent() {
   addDecayMode(1,-1);
   addDecayMode(2,-2);
   addDecayMode(2,-1);
   addDecayMode(1,-1);
   addDecayMode(2,-2);
   addDecayMode(2,-1);
   setInitialModes(6);
   // rho masses and widths
   _rhomass  = {0.7743*GeV,1.370*GeV};
   _rhowidth = {0.1491*GeV,0.386*GeV};
   // f_2 mass and width
   _f2mass  = 1.275*GeV;
   _f2width = 0.185*GeV;
   // f_0(1370) mass and width
   _f0mass  = 1.186*GeV;
   _f0width = 0.350*GeV;
   // sigma mass and width
   _sigmamass  = 0.860*GeV;
   _sigmawidth = 0.880*GeV;
   // a1 mass and width
   _a1mass  = 1.331*GeV;
   _a1width = 0.814*GeV;
   // parameters for the K K* contribution to the a_1 running width
   _mKstar = 894*MeV;
   _mK     = 496*MeV;
   _gammk  = 3.32;
   // pion decay constant
   _fpi = 130.7*MeV/sqrt(2.);
   // couplings and phases for the different channels
   // p-wave rho and rho prime
   using Constants::pi;
   _rhomagP   = {1.,0.12};
   _rhophaseP = {0.,0.99*pi};
   // d-wave rho and rho prime
   _rhomagD   = {0.37/GeV2,0.87/GeV2};
   _rhophaseD = {-0.15*pi, 0.53*pi};
   // f_2
   _f2mag   = 0.71/GeV2;
   _f2phase = 0.56*pi;
   _f2coup  = ZERO;
   // sigma
   _sigmamag   = 2.10;
   _sigmaphase = 0.23*pi;
   _sigmacoup  = 0.;
   // f_0
   _f0mag   = 0.77;
   _f0phase = -0.54*pi;
   _f0coup  = 0.;
   // initialize the a_1 width
   _initializea1=false;
   _a1opt=true;
   double  a1q2in[200]={0      ,15788.6,31577.3,47365.9,63154.6,78943.2,
 		       94731.9,110521 ,126309 ,142098 ,157886 ,173675 ,
-		       189464 ,205252 ,221041 ,236830 ,252618 ,268407 ,     
-		       284196 ,299984 ,315773 ,331562 ,347350 ,363139 ,     
-		       378927 ,394716 ,410505 ,426293 ,442082 ,457871 ,     
-		       473659 ,489448 ,505237 ,521025 ,536814 ,552603 ,      
-		       568391 ,584180 ,599969 ,615757 ,631546 ,647334 ,      
-		       663123 ,678912 ,694700 ,710489 ,726278 ,742066 ,      
-		       757855 ,773644 ,789432 ,805221 ,821010 ,836798 ,      
-		       852587 ,868375 ,884164 ,899953 ,915741 ,931530 ,     
-		       947319 ,963107 ,978896 ,994685 ,     
-		       1.01047e+06,1.02626e+06,1.04205e+06,1.05784e+06, 
-		       1.07363e+06,1.08942e+06,1.10521e+06,1.12099e+06, 
-		       1.13678e+06,1.15257e+06,1.16836e+06,1.18415e+06, 
-		       1.19994e+06,1.21573e+06,1.23151e+06,1.24730e+06, 
-		       1.26309e+06,1.27888e+06,1.29467e+06,1.31046e+06, 
-		       1.32625e+06,1.34203e+06,1.35782e+06,1.37361e+06, 
-		       1.38940e+06,1.40519e+06,1.42098e+06,1.43677e+06, 
-		       1.45256e+06,1.46834e+06,1.48413e+06,1.49992e+06, 
-		       1.51571e+06,1.53150e+06,1.54729e+06,1.56308e+06, 
-		       1.57886e+06,1.59465e+06,1.61044e+06,1.62623e+06, 
-		       1.64202e+06,1.65781e+06,1.67360e+06,1.68939e+06, 
-		       1.70517e+06,1.72096e+06,1.73675e+06,1.75254e+06, 
-		       1.76833e+06,1.78412e+06,1.79991e+06,1.81569e+06, 
-		       1.83148e+06,1.84727e+06,1.86306e+06,1.87885e+06, 
-		       1.89464e+06,1.91043e+06,1.92621e+06,1.94200e+06, 
-		       1.95779e+06,1.97358e+06,1.98937e+06,2.00516e+06, 
-		       2.02095e+06,2.03674e+06,2.05252e+06,2.06831e+06, 
-		       2.08410e+06,2.09989e+06,2.11568e+06,2.13147e+06, 
-		       2.14726e+06,2.16304e+06,2.17883e+06,2.19462e+06, 
-		       2.21041e+06,2.22620e+06,2.24199e+06,2.25778e+06, 
-		       2.27356e+06,2.28935e+06,2.30514e+06,2.32093e+06, 
-		       2.33672e+06,2.35251e+06,2.36830e+06,2.38409e+06, 
-		       2.39987e+06,2.41566e+06,2.43145e+06,2.44724e+06, 
-		       2.46303e+06,2.47882e+06,2.49461e+06,2.51039e+06, 
-		       2.52618e+06,2.54197e+06,2.55776e+06,2.57355e+06, 
-		       2.58934e+06,2.60513e+06,2.62092e+06,2.63670e+06, 
-		       2.65249e+06,2.66828e+06,2.68407e+06,2.69986e+06, 
-		       2.71565e+06,2.73144e+06,2.74722e+06,2.76301e+06, 
-		       2.77880e+06,2.79459e+06,2.81038e+06,2.82617e+06, 
-		       2.84196e+06,2.85774e+06,2.87353e+06,2.88932e+06, 
-		       2.90511e+06,2.92090e+06,2.93669e+06,2.95248e+06, 
-		       2.96827e+06,2.98405e+06,2.99984e+06,3.01563e+06, 
-		       3.03142e+06,3.04721e+06,3.06300e+06,3.07879e+06, 
+		       189464 ,205252 ,221041 ,236830 ,252618 ,268407 ,
+		       284196 ,299984 ,315773 ,331562 ,347350 ,363139 ,
+		       378927 ,394716 ,410505 ,426293 ,442082 ,457871 ,
+		       473659 ,489448 ,505237 ,521025 ,536814 ,552603 ,
+		       568391 ,584180 ,599969 ,615757 ,631546 ,647334 ,
+		       663123 ,678912 ,694700 ,710489 ,726278 ,742066 ,
+		       757855 ,773644 ,789432 ,805221 ,821010 ,836798 ,
+		       852587 ,868375 ,884164 ,899953 ,915741 ,931530 ,
+		       947319 ,963107 ,978896 ,994685 ,
+		       1.01047e+06,1.02626e+06,1.04205e+06,1.05784e+06,
+		       1.07363e+06,1.08942e+06,1.10521e+06,1.12099e+06,
+		       1.13678e+06,1.15257e+06,1.16836e+06,1.18415e+06,
+		       1.19994e+06,1.21573e+06,1.23151e+06,1.24730e+06,
+		       1.26309e+06,1.27888e+06,1.29467e+06,1.31046e+06,
+		       1.32625e+06,1.34203e+06,1.35782e+06,1.37361e+06,
+		       1.38940e+06,1.40519e+06,1.42098e+06,1.43677e+06,
+		       1.45256e+06,1.46834e+06,1.48413e+06,1.49992e+06,
+		       1.51571e+06,1.53150e+06,1.54729e+06,1.56308e+06,
+		       1.57886e+06,1.59465e+06,1.61044e+06,1.62623e+06,
+		       1.64202e+06,1.65781e+06,1.67360e+06,1.68939e+06,
+		       1.70517e+06,1.72096e+06,1.73675e+06,1.75254e+06,
+		       1.76833e+06,1.78412e+06,1.79991e+06,1.81569e+06,
+		       1.83148e+06,1.84727e+06,1.86306e+06,1.87885e+06,
+		       1.89464e+06,1.91043e+06,1.92621e+06,1.94200e+06,
+		       1.95779e+06,1.97358e+06,1.98937e+06,2.00516e+06,
+		       2.02095e+06,2.03674e+06,2.05252e+06,2.06831e+06,
+		       2.08410e+06,2.09989e+06,2.11568e+06,2.13147e+06,
+		       2.14726e+06,2.16304e+06,2.17883e+06,2.19462e+06,
+		       2.21041e+06,2.22620e+06,2.24199e+06,2.25778e+06,
+		       2.27356e+06,2.28935e+06,2.30514e+06,2.32093e+06,
+		       2.33672e+06,2.35251e+06,2.36830e+06,2.38409e+06,
+		       2.39987e+06,2.41566e+06,2.43145e+06,2.44724e+06,
+		       2.46303e+06,2.47882e+06,2.49461e+06,2.51039e+06,
+		       2.52618e+06,2.54197e+06,2.55776e+06,2.57355e+06,
+		       2.58934e+06,2.60513e+06,2.62092e+06,2.63670e+06,
+		       2.65249e+06,2.66828e+06,2.68407e+06,2.69986e+06,
+		       2.71565e+06,2.73144e+06,2.74722e+06,2.76301e+06,
+		       2.77880e+06,2.79459e+06,2.81038e+06,2.82617e+06,
+		       2.84196e+06,2.85774e+06,2.87353e+06,2.88932e+06,
+		       2.90511e+06,2.92090e+06,2.93669e+06,2.95248e+06,
+		       2.96827e+06,2.98405e+06,2.99984e+06,3.01563e+06,
+		       3.03142e+06,3.04721e+06,3.06300e+06,3.07879e+06,
 		       3.09457e+06,3.11036e+06,3.12615e+06,3.14194e+06};
   double a1widthin[200]={0,0,0,0,0,0,0,0,
 			 0,0,0,0.00021256,0.0107225,0.0554708,0.150142,0.303848,
 			 0.522655,0.81121,1.1736,1.61381,2.13606,2.74499,3.44583,4.24454,
 			 5.14795,6.16391,7.3014,8.57079,9.98398,11.5547,13.2987,15.2344,
 			 17.3827,19.7683,22.4195,25.3695,28.6568,32.3264,36.4311,41.0322,
 			 46.201,52.0203,58.5847,66.0011,74.3871,83.8666,94.5615,106.578,
 			 119.989,134.807,150.968,168.315,186.615,205.576,224.893,244.28,
 			 263.499,282.364,300.748,318.569,335.781,352.367,368.327,383.677,
 			 398.438,412.638,426.306,439.472,452.167,464.421,476.263,487.719,
 			 498.815,509.576,520.024,530.179,540.063,549.693,559.621,568.26,
 			 577.229,586.005,594.604,603.035,611.314,619.447,627.446,635.321,
 			 643.082,650.736,658.288,665.75,673.127,680.427,687.659,694.82,
 			 701.926,708.977,715.983,722.944,729.862,736.752,743.619,750.452,
 			 757.271,764.076,770.874,777.658,784.444,791.233,798.027,804.838,
 			 811.649,818.485,825.342,832.224,839.139,846.082,853.059,860.079,
 			 867.143,874.248,881.409,919.527,945.28,965.514,983.228,999.471,
 			 1014.69,1029.15,1043.05,1056.49,1069.57,1082.36,1094.88,1107.2,
 			 1120.89,1131.4,1143.33,1155.15,1166.92,1178.61,1190.27,1201.92,
 			 1213.55,1225.18,1236.81,1250.06,1260.16,1271.86,1283.64,1295.46,
 			 1307.36,1319.3,1331.34,1343.45,1355.64,1367.93,1380.31,1392.77,
 			 1405.35,1418.03,1430.83,1443.75,1457.17,1469.94,1483.22,1496.64,
 			 1510.18,1523.86,1537.67,1551.64,1565.72,1579.99,1594.38,1608.92,
 			 1623.63,1642.08,1653.51,1668.69,1684.03,1699.53,1715.21,1731.04,
 			 1747.05,1763.23,1779.59,1796.12,1812.83,1829.72,1846.79,1864.04,
 			 1881.49,1899.11,1916.93,1934.93,1953.13,1971.52,1990.12,2008.89};
   if(_a1runwidth.empty()) {
     vector<double> tmp1(a1widthin,a1widthin+200);
     std::transform(tmp1.begin(), tmp1.end(),
 		   back_inserter(_a1runwidth),
 		   [](double x){return x*GeV;});
-    
+
     vector<double> tmp2(a1q2in,a1q2in+200);
     _a1runq2.clear();
     std::transform(tmp2.begin(), tmp2.end(),
 		   back_inserter(_a1runq2),
 		   [](double x){return x*GeV2;});
   }
   // zero parameters which will be calculated later to avoid problems
   _mpi0=ZERO;
   _mpic=ZERO;
   _fact=ZERO;
   _maxmass=ZERO;
   _maxcalc=ZERO;
 }
 
 void ThreePionCLEOCurrent::doinit() {
   WeakCurrent::doinit();
   // parameters for the breit-wigners
   _mpic = getParticleData(ParticleID::piplus)->mass();
   _mpi0 = getParticleData(ParticleID::pi0)   ->mass();
   // couplings for the different modes
   Complex ii(0.,1.);
   _rhocoupP.resize(_rhomagP.size());
   for(unsigned int ix=0;ix<_rhomagP.size();++ix)
     _rhocoupP[ix]=_rhomagP[ix]*(cos(_rhophaseP[ix])+ii*sin(_rhophaseP[ix]));
   _rhocoupD.resize(_rhomagD.size());
   for(unsigned int ix=0;ix<_rhomagD.size();++ix)
     _rhocoupD[ix]=_rhomagD[ix]*(cos(_rhophaseD[ix])+ii*sin(_rhophaseD[ix]));
   _f0coup=_f0mag*(cos(_f0phase)+ii*sin(_f0phase));
   _f2coup=_f2mag*(cos(_f2phase)+ii*sin(_f2phase));
   _sigmacoup=_sigmamag*(cos(_sigmaphase)+ii*sin(_sigmaphase));
   // overall coupling
   _fact = 2.*sqrt(2.)/_fpi/3.;
   // initialise the a_1 running width calculation
   inita1Width(-1);
 }
 
 void ThreePionCLEOCurrent::persistentOutput(PersistentOStream & os) const {
   os << ounit(_rhomass,GeV) << ounit(_rhowidth,GeV)
      << ounit(_f2mass,GeV) << ounit(_f2width,GeV)
-     << ounit(_f0mass,GeV) << ounit(_f0width,GeV) 
+     << ounit(_f0mass,GeV) << ounit(_f0width,GeV)
      << ounit(_sigmamass,GeV) << ounit(_sigmawidth,GeV)
-     << ounit(_mpi0,GeV) << ounit(_mpic,GeV) 
-     << ounit(_fpi,GeV) << ounit(_fact,1/GeV) 
-     << _rhomagP << _rhophaseP 
-     << _rhocoupP << ounit(_rhomagD,1/GeV2) << _rhophaseD 
+     << ounit(_mpi0,GeV) << ounit(_mpic,GeV)
+     << ounit(_fpi,GeV) << ounit(_fact,1/GeV)
+     << _rhomagP << _rhophaseP
+     << _rhocoupP << ounit(_rhomagD,1/GeV2) << _rhophaseD
      << ounit(_rhocoupD,1/GeV2) <<ounit(_f2mag,1/GeV2) << _f2phase << ounit(_f2coup ,1/GeV2)
      << _f0mag << _f0phase << _f0coup << _sigmamag << _sigmaphase << _sigmacoup
-     << ounit(_a1mass,GeV) << ounit(_a1width,GeV) << ounit(_a1runwidth,GeV) 
+     << ounit(_a1mass,GeV) << ounit(_a1width,GeV) << ounit(_a1runwidth,GeV)
      << ounit(_a1runq2,GeV2) <<  _initializea1
-     << ounit(_mKstar,GeV) << ounit(_mK,GeV) << _gammk << _a1opt 
+     << ounit(_mKstar,GeV) << ounit(_mK,GeV) << _gammk << _a1opt
      << ounit(_maxmass,GeV) << ounit(_maxcalc,GeV) << _a1runinter;
 }
 
 void ThreePionCLEOCurrent::persistentInput(PersistentIStream & is, int) {
   is >> iunit(_rhomass,GeV) >> iunit(_rhowidth,GeV)
      >> iunit(_f2mass,GeV) >> iunit(_f2width,GeV)
      >> iunit(_f0mass,GeV) >> iunit(_f0width,GeV)
      >> iunit(_sigmamass,GeV) >> iunit(_sigmawidth,GeV)
-     >> iunit(_mpi0,GeV) >> iunit(_mpic,GeV) 
-     >> iunit(_fpi,GeV) >> iunit(_fact,1/GeV) 
-     >> _rhomagP >> _rhophaseP 
-     >> _rhocoupP >> iunit(_rhomagD,1/GeV2) >> _rhophaseD >> iunit(_rhocoupD,1/GeV2) 
-     >> iunit(_f2mag,1/GeV2) >> _f2phase >> iunit(_f2coup,1/GeV2) 
+     >> iunit(_mpi0,GeV) >> iunit(_mpic,GeV)
+     >> iunit(_fpi,GeV) >> iunit(_fact,1/GeV)
+     >> _rhomagP >> _rhophaseP
+     >> _rhocoupP >> iunit(_rhomagD,1/GeV2) >> _rhophaseD >> iunit(_rhocoupD,1/GeV2)
+     >> iunit(_f2mag,1/GeV2) >> _f2phase >> iunit(_f2coup,1/GeV2)
      >> _f0mag >> _f0phase >> _f0coup >> _sigmamag >> _sigmaphase >> _sigmacoup
-     >> iunit(_a1mass,GeV) >> iunit(_a1width,GeV) >>  iunit(_a1runwidth,GeV) 
+     >> iunit(_a1mass,GeV) >> iunit(_a1width,GeV) >>  iunit(_a1runwidth,GeV)
      >> iunit(_a1runq2,GeV2) >>  _initializea1
-     >> iunit(_mKstar,GeV) >> iunit(_mK,GeV) >> _gammk >> _a1opt 
+     >> iunit(_mKstar,GeV) >> iunit(_mK,GeV) >> _gammk >> _a1opt
      >> iunit(_maxmass,GeV) >> iunit(_maxcalc,GeV) >> _a1runinter;
 }
 
 void ThreePionCLEOCurrent::Init() {
 
   static ClassDocumentation<ThreePionCLEOCurrent> documentation
     ("The ThreePionCLEOCurrent class performs the decay of the"
      " tau to three pions using the currents from CLEO",
      "The decay of tau to three pions is modelled using the currents from "
      "\\cite{Asner:1999kj}.",
      "  %\\cite{Asner:1999kj}\n"
      "\\bibitem{Asner:1999kj}\n"
      "  D.~M.~Asner {\\it et al.}  [CLEO Collaboration],\n"
      "   ``Hadronic structure in the decay tau- --> nu/tau pi- pi0 pi0 and the  sign\n"
      "  %of the tau neutrino helicity,''\n"
      "  Phys.\\ Rev.\\  D {\\bf 61}, 012002 (2000)\n"
      "  [arXiv:hep-ex/9902022].\n"
      "  %%CITATION = PHRVA,D61,012002;%%\n"
      );
 
   static ParVector<ThreePionCLEOCurrent,Energy> interfacerhomass
     ("RhoMasses",
      "The masses of the different rho resonnaces",
      &ThreePionCLEOCurrent::_rhomass,
      MeV, 0, ZERO, -10000*MeV, 10000*MeV, false, false, true);
 
   static ParVector<ThreePionCLEOCurrent,Energy> interfacerhowidth
     ("RhoWidths",
      "The widths of the different rho resonnaces",
      &ThreePionCLEOCurrent::_rhowidth,
      MeV, 0, ZERO, -10000*MeV, 10000*MeV, false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfacef_2Mass
     ("f_2Mass",
      "The mass of the f_2 meson",
      &ThreePionCLEOCurrent::_f2mass, GeV, 1.275*GeV, ZERO, 10.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfacef_2Width
     ("f_2Width",
      "The width of the f_2 meson",
      &ThreePionCLEOCurrent::_f2width, GeV, 0.185*GeV, ZERO, 1.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfacef_0Mass
     ("f_0Mass",
      "The mass of the f_0 meson",
      &ThreePionCLEOCurrent::_f0mass, GeV, 1.186*GeV, ZERO, 10.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfacef_0Width
     ("f_0Width",
      "The width of the f_0 meson",
      &ThreePionCLEOCurrent::_f0width, GeV, 0.350*GeV, ZERO, 1.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfacesigmaMass
     ("sigmaMass",
      "The mass of the sigma meson",
      &ThreePionCLEOCurrent::_sigmamass, GeV, 0.860*GeV, ZERO, 10.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfacesigmaWidth
     ("sigmaWidth",
      "The width of the sigma meson",
      &ThreePionCLEOCurrent::_sigmawidth, GeV, 0.880*GeV, ZERO, 2.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfacea1Mass
     ("a1Mass",
      "The mass of the a_1 meson",
      &ThreePionCLEOCurrent::_a1mass, GeV, 1.331*GeV, ZERO, 10.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfacea1Width
     ("a1Width",
      "The width of the a_1 meson",
      &ThreePionCLEOCurrent::_a1width, GeV, 0.814*GeV, ZERO, 10.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfaceKaonMass
     ("KaonMass",
      "The mass of the kaon",
      &ThreePionCLEOCurrent::_mK, GeV, 0.496*GeV, ZERO, 10.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfaceKStarMass
     ("KStarMass",
      "The mass of the k* meson",
      &ThreePionCLEOCurrent::_mKstar, GeV, 0.894*GeV, ZERO, 10.0*GeV,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,double> interfaceKaonCoupling
     ("KaonCoupling",
      "The relative coupling for the kaon in the a_1 running width",
      &ThreePionCLEOCurrent::_gammk, 3.32, 0.0, 10.0,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,Energy> interfaceFpi
     ("Fpi",
      "The pion decay constant",
      &ThreePionCLEOCurrent::_fpi, MeV, 130.7*MeV/sqrt(2.), ZERO, 500.0*MeV,
      false, false, true);
 
   static ParVector<ThreePionCLEOCurrent,double> interfacerhomagP
     ("RhoPWaveMagnitude",
      "The magnitude of the couplings for the p-wave rho currents",
      &ThreePionCLEOCurrent::_rhomagP,
      0, 0, 0, 0, 10000, false, false, true);
 
   static ParVector<ThreePionCLEOCurrent,double> interfacerhophaseP
     ("RhoPWavePhase",
      "The phase of the couplings for the p-wave rho currents",
      &ThreePionCLEOCurrent::_rhophaseP,
      0, 0, 0, -Constants::twopi, Constants::twopi, false, false, true);
 
   static ParVector<ThreePionCLEOCurrent,InvEnergy2> interfacerhomagD
     ("RhoDWaveMagnitude",
      "The magnitude of the couplings for the d-wave rho currents",
      &ThreePionCLEOCurrent::_rhomagD,
      1/MeV2, 0, ZERO, ZERO, 10000/MeV2, false, false, true);
 
   static ParVector<ThreePionCLEOCurrent,double> interfacerhophaseD
     ("RhoDWavePhase",
      "The phase of the couplings for the d-wave rho currents",
      &ThreePionCLEOCurrent::_rhophaseD,
      0, 0, 0, -Constants::twopi, Constants::twopi, false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,double> interfacef0Phase
     ("f0Phase",
      "The phase of the f_0 scalar current",
      &ThreePionCLEOCurrent::_f0phase, 0.54*Constants::pi, -Constants::twopi, Constants::twopi,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,double> interfacef2Phase
     ("f2Phase",
      "The phase of the f_2 tensor current",
      &ThreePionCLEOCurrent::_f2phase, 0.56*Constants::pi,-Constants::twopi, Constants::twopi,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,double> interfacesigmaPhase
     ("sigmaPhase",
      "The phase of the sigma scalar current",
      &ThreePionCLEOCurrent::_sigmaphase, 0.23*Constants::pi, -Constants::twopi, Constants::twopi,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,double> interfacef0Magnitude
     ("f0Magnitude",
      "The magnitude of the f_0 scalar current",
      &ThreePionCLEOCurrent::_f0mag, 0.77, 0.0, 10,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,InvEnergy2> interfacef2Magnitude
     ("f2Magnitude",
      "The magnitude of the f_2 tensor current",
      &ThreePionCLEOCurrent::_f2mag, 1./GeV2, 0.71/GeV2, ZERO, 10./GeV2,
      false, false, true);
 
   static Parameter<ThreePionCLEOCurrent,double> interfacesigmaMagnitude
     ("sigmaMagnitude",
      "The magnitude of the sigma scalar current",
      &ThreePionCLEOCurrent::_sigmamag, 2.1, 0.0, 10,
      false, false, true);
 
   static ParVector<ThreePionCLEOCurrent,Energy> interfacea1RunningWidth
     ("a1RunningWidth",
      "The values of the a_1 width for interpolation to giving the running width.",
      &ThreePionCLEOCurrent::_a1runwidth,
      MeV, 0, ZERO, ZERO, 10000000*MeV, false, false, true);
-  
+
   static ParVector<ThreePionCLEOCurrent,Energy2> interfacea1RunningQ2
     ("a1RunningQ2",
      "The values of the q^2 for interpolation to giving the running width.",
      &ThreePionCLEOCurrent::_a1runq2,
      MeV2, 0, ZERO, ZERO, 10000000*MeV2, false, false, true);
 
   static Switch<ThreePionCLEOCurrent,bool> interfaceInitializea1
     ("Initializea1",
      "Initialise the calculation of the a_1 running width",
      &ThreePionCLEOCurrent::_initializea1, false, false, false);
   static SwitchOption interfaceInitializea1Initialization
     (interfaceInitializea1,
      "Yes",
      "Initialize the calculation",
      true);
   static SwitchOption interfaceInitializea1NoInitialization
     (interfaceInitializea1,
      "No",
      "Use the default values",
      false);
-  
+
   static Switch<ThreePionCLEOCurrent,bool> interfacea1WidthOption
     ("a1WidthOption",
      "Option for the treatment of the a1 width",
      &ThreePionCLEOCurrent::_a1opt, true, false, false);
   static SwitchOption interfacea1WidthOptionLocal
     (interfacea1WidthOption,
      "Local",
      "Use a calculation of the running width based on the parameters as"
      " interpolation table.",
      true);
   static SwitchOption interfacea1WidthOptionParam
     (interfacea1WidthOption,
      "Kuhn",
      "Use the parameterization of Kuhn and Santamaria for default parameters."
      " This should only be used for testing vs TAUOLA",
      false);
 }
 
 // initialisation of the a_1 width
 // (iopt=-1 initialises, iopt=0 starts the interpolation)
 void ThreePionCLEOCurrent::inita1Width(int iopt) {
   if(iopt==-1) {
     _maxcalc=_maxmass;
     if(!_initializea1||_maxmass==ZERO) return;
     // parameters for the table of values
     Energy2 step=sqr(_maxmass)/200.;
     // function to be integrated to give the matrix element
     // integrator to perform the integral
     vector<double> inweights;inweights.push_back(0.5);inweights.push_back(0.5);
     vector<int> intype;intype.push_back(2);intype.push_back(3);
     Energy mrho=getParticleData(ParticleID::rhoplus)->mass();
     Energy wrho=getParticleData(ParticleID::rhoplus)->width();
     vector<Energy> inmass;inmass.push_back(mrho);inmass.push_back(mrho);
     vector<Energy> inwidth;inwidth.push_back(wrho);inwidth.push_back(wrho);
     vector<double> inpow(2,0.0);
     ThreeBodyAllOnCalculator<ThreePionCLEOCurrent>
       widthgenN(inweights,intype,inmass,inwidth,inpow,*this,0,_mpi0,_mpi0,_mpic);
     ThreeBodyAllOnCalculator<ThreePionCLEOCurrent>
       widthgenC(inweights,intype,inmass,inwidth,inpow,*this,1,_mpic,_mpic,_mpic);
     // normalisation constant to give physical width if on shell
     double a1const = _a1width/(widthgenN.partialWidth(sqr(_a1mass))+
 			       widthgenC.partialWidth(sqr(_a1mass)));
     // loop to give the values
     _a1runq2.clear();_a1runwidth.clear();
     for(Energy2 moff2=ZERO; moff2<=sqr(_maxmass); moff2+=step) {
       Energy moff=sqrt(moff2);
       _a1runq2.push_back(moff2);
       Energy charged=a1const*widthgenC.partialWidth(moff2);
       Energy neutral=a1const*widthgenN.partialWidth(moff2);
       Energy kaon = moff<=_mK+_mKstar ? ZERO : 2.870*_gammk*_gammk/8./Constants::pi*
 	Kinematics::pstarTwoBodyDecay(moff,_mK,_mKstar)/moff2*GeV2;
       Energy total = charged + neutral + kaon;
       _a1runwidth.push_back(total);
     }
   }
   // set up the interpolator
   else if(iopt==0) {
     _a1runinter = make_InterpolatorPtr(_a1runwidth,_a1runq2,3);
   }
 }
 
 void ThreePionCLEOCurrent::CLEOFormFactor(int imode,int ichan,
 					  Energy2 q2,Energy2 s1, Energy2 s2, Energy2 s3,
-					  Complex & F1, Complex & F2, 
+					  Complex & F1, Complex & F2,
 					  Complex & F3) const {
   useMe();
   double fact=1.;
   if(imode<=1) {
     // identical particle factors
     fact = 1./sqrt(6.);
     // compute the breit wigners we need
     Complex sigbws1 = Resonance::BreitWignerSWave(s1,_sigmamass,_sigmawidth,_mpi0,_mpi0);
     Complex sigbws2 = Resonance::BreitWignerSWave(s2,_sigmamass,_sigmawidth,_mpi0,_mpi0);
     Complex sigbws3 = Resonance::BreitWignerSWave(s3,_sigmamass,_sigmawidth,_mpi0,_mpi0);
     Complex f0bws1  = Resonance::BreitWignerSWave(s1,   _f0mass,   _f0width,_mpi0,_mpi0);
     Complex f0bws2  = Resonance::BreitWignerSWave(s2,   _f0mass,   _f0width,_mpi0,_mpi0);
     Complex f0bws3  = Resonance::BreitWignerSWave(s3,   _f0mass,   _f0width,_mpi0,_mpi0);
     Complex f2bws1  = Resonance::BreitWignerDWave(s1,   _f2mass,   _f2width,_mpi0,_mpi0);
     Complex f2bws2  = Resonance::BreitWignerDWave(s2,   _f2mass,   _f2width,_mpi0,_mpi0);
     Complex f2bws3  = Resonance::BreitWignerDWave(s3,   _f2mass,   _f2width,_mpi0,_mpi0);
     if(ichan<0) {
       // the scalar terms
       F1=2./3.*(_sigmacoup*sigbws3+_f0coup*f0bws3)
 	-2./3.*(_sigmacoup*sigbws2+_f0coup*f0bws2);
       F2=2./3.*(_sigmacoup*sigbws3+_f0coup*f0bws3)
 	-2./3.*(_sigmacoup*sigbws1+_f0coup*f0bws1);
       F3=-2./3.*(_sigmacoup*sigbws1+_f0coup*f0bws1)
 	+2./3.*(_sigmacoup*sigbws2+_f0coup*f0bws2);
       // the tensor terms
       complex<Energy2> Dfact1 = 1./18.*(4.*_mpi0*_mpi0-s1)*(q2+s1-_mpi0*_mpi0)/s1*f2bws1;
       complex<Energy2> Dfact2 = 1./18.*(4.*_mpi0*_mpi0-s2)*(q2+s2-_mpi0*_mpi0)/s2*f2bws2;
       complex<Energy2> Dfact3 = 1./18.*(4.*_mpi0*_mpi0-s3)*(q2-_mpi0*_mpi0+s3)/s3*f2bws3;
       F1+=Complex(_f2coup*( 0.5*(s3-s2)*f2bws1-Dfact2+Dfact3));
       F2+=Complex(_f2coup*( 0.5*(s3-s1)*f2bws2-Dfact1+Dfact3));
       F3+=Complex(_f2coup*(-0.5*(s1-s2)*f2bws3-Dfact1+Dfact2));
     }
     else if(ichan==0) {
       F2=-2./3.*_sigmacoup*sigbws1;
       F3=-2./3.*_sigmacoup*sigbws1;
     }
     else if(ichan==1) {
       F1=-2./3.*_sigmacoup*sigbws2;
       F3=+2./3.*_sigmacoup*sigbws2;
     }
     else if(ichan==2) {
       F1= 2./3.*_sigmacoup*sigbws3;
       F2= 2./3.*_sigmacoup*sigbws3;
     }
     else if(ichan==3) {
       complex<Energy2> Dfact1 = 1./18.*(4.*_mpi0*_mpi0-s1)*(q2+s1-_mpi0*_mpi0)/s1*f2bws1;
       F1+=Complex(_f2coup*0.5*(s3-s2)*f2bws1);
-      F2-=Complex(_f2coup*Dfact1); 
+      F2-=Complex(_f2coup*Dfact1);
       F3-=Complex(_f2coup*Dfact1);
     }
     else if(ichan==4) {
       complex<Energy2> Dfact2 = 1./18.*(4.*_mpi0*_mpi0-s2)*(q2+s2-_mpi0*_mpi0)/s2*f2bws2;
       F2+=Complex(_f2coup*0.5*(s3-s1)*f2bws2);
       F1-=Complex(_f2coup*Dfact2);
       F3+=Complex(_f2coup*Dfact2);
     }
     else if(ichan==5) {
       complex<Energy2> Dfact3 = 1./18.*(4.*_mpi0*_mpi0-s3)*(q2-_mpi0*_mpi0+s3)/s3*f2bws3;
       F3+=Complex(-_f2coup*0.5*(s1-s2)*f2bws3);
       F1+=Complex(_f2coup*Dfact3);
       F2+=Complex(_f2coup*Dfact3);
     }
     else if(ichan==6) {
       F2=-2./3.*_f0coup*f0bws1;
       F3=-2./3.*_f0coup*f0bws1;
     }
     else if(ichan==7) {
       F1=-2./3.*_f0coup*f0bws2;
       F3=+2./3.*_f0coup*f0bws2;
     }
     else if(ichan==8) {
       F1= 2./3.*_f0coup*f0bws3;
       F2= 2./3.*_f0coup*f0bws3;
     }
   }
   // calculate the pi0 pi0 pi+ factor
   else if(imode==2) {
     // identical particle factors
     fact = 1./sqrt(2.);
     // compute the breit wigners we need
     Complex rhos1bw[3],rhos2bw[3];
     for(unsigned int ix=0,N=max(_rhocoupP.size(),_rhocoupD.size());ix<N;++ix) {
       rhos1bw[ix] = Resonance::BreitWignerPWave(s1,_rhomass[ix], _rhowidth[ix],_mpic,_mpi0);
       rhos2bw[ix] = Resonance::BreitWignerPWave(s2,_rhomass[ix], _rhowidth[ix],_mpic,_mpi0);
     }
     Complex f0bw  = Resonance::BreitWignerSWave(s3,   _f0mass,   _f0width,_mpi0,_mpi0);
     Complex sigbw = Resonance::BreitWignerSWave(s3,_sigmamass,_sigmawidth,_mpi0,_mpi0);
     Complex f2bw  = Resonance::BreitWignerDWave(s3,   _f2mass,   _f2width,_mpi0,_mpi0);
     if(ichan<0) {
       // the p-wave rho terms
       for(unsigned int ix=0;ix<_rhocoupP.size();++ix) {
 	F1+=_rhocoupP[ix]*rhos1bw[ix];
 	F2+=_rhocoupP[ix]*rhos2bw[ix];
       }
       // the D-wave rho terms
       Energy2 Dfact1=-1./3.*((s3-_mpic*_mpic)-(s1-_mpi0*_mpi0));
       Energy2 Dfact2=-1./3.*((s3-_mpic*_mpic)-(s2-_mpi0*_mpi0));
       for(unsigned int ix=0;ix<_rhocoupD.size();++ix) {
 	F1+=Complex(Dfact1*_rhocoupD[ix]*rhos2bw[ix]);
 	F2+=Complex(Dfact2*_rhocoupD[ix]*rhos1bw[ix]);
 	F3+=Complex(_rhocoupD[ix]*(Dfact2*rhos1bw[ix]-Dfact1*rhos2bw[ix]));
       }
       // the scalar terms
       Complex scalar=2./3.*(_sigmacoup*sigbw+_f0coup*f0bw);
       F1+=scalar;F2+=scalar;
       // the tensor terms
       Complex Dfact3=1./18./s3*_f2coup*(q2-_mpic*_mpic+s3)*(4.*_mpi0*_mpi0-s3)*f2bw;
       F1+=Dfact3;F2+=Dfact3;
       F3-=Complex(0.5*_f2coup*(s1-s2)*f2bw);
     }
     else if(ichan%2==0&&ichan<=4) {
       unsigned int ires=ichan/2;
       if(ires<_rhocoupP.size()){F1+=_rhocoupP[ires]*rhos1bw[ires];}
       Energy2 Dfact2=-1./3.*((s3-_mpic*_mpic)-(s2-_mpi0*_mpi0));
       if(ires<_rhocoupD.size()) {
 	F2+=Complex(Dfact2*_rhocoupD[ires]*rhos1bw[ires]);
 	F3+=Complex(_rhocoupD[ires]*Dfact2*rhos1bw[ires]);
       }
     }
     else if(ichan%2==1&&ichan<=5) {
       unsigned int ires=(ichan-1)/2;
       if(ires<_rhocoupP.size()){F2+=_rhocoupP[ires]*rhos2bw[ires];}
       Energy2 Dfact1=-1./3.*((s3-_mpic*_mpic)-(s1-_mpi0*_mpi0));
       if(ires<_rhocoupD.size()) {
 	F1+=Complex(Dfact1*_rhocoupD[ires]*rhos2bw[ires]);
 	F3-=Complex(_rhocoupD[ires]*Dfact1*rhos2bw[ires]);
       }
     }
     else if(ichan==6) {
       F1+=2./3.*_sigmacoup*sigbw;
       F2+=2./3.*_sigmacoup*sigbw;
     }
     else if(ichan==7) {
       Complex Dfact3=1./18./s3*_f2coup*(q2-_mpic*_mpic+s3)*(4.*_mpi0*_mpi0-s3)*f2bw;
       F1+=Dfact3;
       F2+=Dfact3;
       F3-=Complex(0.5*_f2coup*(s1-s2)*f2bw);
     }
     else if(ichan==8) {
       F1+=2./3.*_f0coup*f0bw;
       F2+=2./3.*_f0coup*f0bw;
     }
   }
   // a_1^0 ->pi+pi-pi0
   else if(imode==3||imode==4) {
     // compute the breit wigners we need
     Complex rhos1bw[3],rhos2bw[3];
     for(unsigned int ix=0,N=max(_rhocoupP.size(),_rhocoupD.size());ix<N;++ix) {
       rhos1bw[ix] = Resonance::BreitWignerPWave(s1,_rhomass[ix], _rhowidth[ix],_mpic,_mpi0);
       rhos2bw[ix] = Resonance::BreitWignerPWave(s2,_rhomass[ix], _rhowidth[ix],_mpic,_mpi0);
     }
     Complex f0bw  = Resonance::BreitWignerSWave(s3,   _f0mass,   _f0width,_mpic,_mpic);
     Complex sigbw = Resonance::BreitWignerSWave(s3,_sigmamass,_sigmawidth,_mpic,_mpic);
     Complex f2bw  = Resonance::BreitWignerDWave(s3,   _f2mass,   _f2width,_mpic,_mpic);
     if(ichan<0) {
       // the p-wave rho terms
       for(unsigned int ix=0;ix<_rhocoupP.size();++ix) {
 	F1+=_rhocoupP[ix]*rhos1bw[ix];
 	F2+=_rhocoupP[ix]*rhos2bw[ix];
       }
       // the D-wave rho terms
       Energy2 Dfact1=-1./3.*(s3-_mpi0*_mpi0-s1+_mpic*_mpic);
       Energy2 Dfact2=-1./3.*(s3-_mpi0*_mpi0-s2+_mpic*_mpic);
       for(unsigned int ix=0;ix<_rhocoupD.size();++ix) {
 	F1+=Complex(Dfact1*_rhocoupD[ix]*rhos2bw[ix]);
 	F2+=Complex(Dfact2*_rhocoupD[ix]*rhos1bw[ix]);
 	F3+=Complex(_rhocoupD[ix]*(Dfact2*rhos1bw[ix]-Dfact1*rhos2bw[ix]));
       }
       // the scalar terms
       Complex scalar=2./3.*(_sigmacoup*sigbw+_f0coup*f0bw);
       F1+=scalar;
       F2+=scalar;
       // the tensor terms
       Complex Dfact3=1./18./s3*_f2coup*(q2-_mpi0*_mpi0+s3)*(4.*_mpic*_mpic-s3)*f2bw;
       F1+=Dfact3;
       F2+=Dfact3;
       F3-=Complex(0.5*_f2coup*(s1-s2)*f2bw);
     }
     else if(ichan%2==0&&ichan<=4) {
       unsigned int ires=ichan/2;
       if(ires<_rhocoupP.size()) F1+=_rhocoupP[ires]*rhos1bw[ires];
       Energy2 Dfact2=-1./3.*(s3-_mpi0*_mpi0-s2+_mpic*_mpic);
       if(ires<_rhocoupD.size()) {
 	F2+=Complex(Dfact2*_rhocoupD[ires]*rhos1bw[ires]);
 	F3+=Complex(_rhocoupD[ires]*Dfact2*rhos1bw[ires]);
       }
     }
     else if(ichan%2==1&&ichan<=5) {
       unsigned int ires=(ichan-1)/2;
       if(ires<_rhocoupP.size()) F2+=_rhocoupP[ires]*rhos2bw[ires];
       Energy2 Dfact1=-1./3.*(s3-_mpi0*_mpi0-s1+_mpic*_mpic);
       if(ires<_rhocoupD.size()) {
 	F1+=Complex(Dfact1*_rhocoupD[ires]*rhos2bw[ires]);
 	F3-=Complex(_rhocoupD[ires]*-Dfact1*rhos2bw[ires]);
       }
     }
     else if(ichan==6) {
       F1+=2./3.*_sigmacoup*sigbw;
       F2+=2./3.*_sigmacoup*sigbw;
     }
     else if(ichan==7) {
       Complex Dfact3=1./18./s3*_f2coup*(q2-_mpi0*_mpi0+s3)*(4.*_mpic*_mpic-s3)*f2bw;
       F1+=Dfact3;
       F2+=Dfact3;
       F3-=Complex(0.5*_f2coup*(s1-s2)*f2bw);
     }
     else if(ichan==8) {
       F1+=2./3.*_f0coup*f0bw;
       F2+=2./3.*_f0coup*f0bw;
     }
   }
   else if(imode==5) {
     // identical particle factors
     fact = 1./sqrt(2.);
     // compute the breit wigners we need
     Complex rhos1bw[3],rhos2bw[3];
     for(unsigned int ix=0,N=max(_rhocoupP.size(),_rhocoupD.size());ix<N;++ix) {
       rhos1bw[ix] = Resonance::BreitWignerPWave(s1,_rhomass[ix], _rhowidth[ix],_mpic,_mpic);
       rhos2bw[ix] = Resonance::BreitWignerPWave(s2,_rhomass[ix], _rhowidth[ix],_mpic,_mpic);
     }
     Complex f0bws1  = Resonance::BreitWignerSWave(s1,   _f0mass,   _f0width,_mpic,_mpic);
     Complex sigbws1 = Resonance::BreitWignerSWave(s1,_sigmamass,_sigmawidth,_mpic,_mpic);
     Complex f2bws1  = Resonance::BreitWignerDWave(s1,   _f2mass,   _f2width,_mpic,_mpic);
     Complex f0bws2  = Resonance::BreitWignerSWave(s2,   _f0mass,   _f0width,_mpic,_mpic);
     Complex sigbws2 = Resonance::BreitWignerSWave(s2,_sigmamass,_sigmawidth,_mpic,_mpic);
     Complex f2bws2  = Resonance::BreitWignerDWave(s2,   _f2mass,   _f2width,_mpic,_mpic);
     if(ichan<0) {
       // the p-wave rho terms
       for(unsigned int ix=0;ix<_rhocoupP.size();++ix) {
 	F1-=_rhocoupP[ix]*rhos1bw[ix];
 	F2-=_rhocoupP[ix]*rhos2bw[ix];
       }
       // the D-wave rho terms
       Energy2 Dfact1=1./3.*(s1-s3);
       Energy2 Dfact2=1./3.*(s2-s3);
       for(unsigned int ix=0;ix<_rhocoupD.size();++ix) {
 	F1-=Complex(Dfact1*_rhocoupD[ix]*rhos2bw[ix]);
 	F2-=Complex(Dfact2*_rhocoupD[ix]*rhos1bw[ix]);
 	F3-=Complex(_rhocoupD[ix]*(Dfact2*rhos1bw[ix]-Dfact1*rhos2bw[ix]));
       }
       // the scalar terms
       F1-=2./3.*(_sigmacoup*sigbws2+_f0coup*f0bws2);
       F2-=2./3.*(_sigmacoup*sigbws1+_f0coup*f0bws1);
       F3+=-2./3.*(_sigmacoup*sigbws1+_f0coup*f0bws1)
 	  +2./3.*(_sigmacoup*sigbws2+_f0coup*f0bws2);
       // the tensor terms
       complex<Energy2> sfact1 = 1./18.*(4.*_mpic*_mpic-s1)*(q2+s1-_mpic*_mpic)/s1*f2bws1;
       complex<Energy2> sfact2 = 1./18.*(4.*_mpic*_mpic-s2)*(q2+s2-_mpic*_mpic)/s2*f2bws2;
       F1+=Complex(_f2coup*(0.5*(s3-s2)*f2bws1-sfact2));
       F2+=Complex(_f2coup*(0.5*(s3-s1)*f2bws2-sfact1));
       F3+=Complex(_f2coup*(-sfact1+sfact2));
     }
     else if(ichan%2==0&&ichan<=4) {
       unsigned int ires=ichan/2;
       Energy2 Dfact2=1./3.*(s2-s3);
       if(ires<_rhocoupP.size()) F1-=_rhocoupP[ires]*rhos1bw[ires];
       if(ires<_rhocoupD.size()) {
 	F2-=Complex(Dfact2*_rhocoupD[ires]*rhos1bw[ires]);
 	F3-=Complex(_rhocoupD[ires]*Dfact2*rhos1bw[ires]);
       }
     }
     else if(ichan%2==1&&ichan<=5) {
       unsigned int ires=(ichan-1)/2;
       Energy2 Dfact1=1./3.*(s1-s3);
       if(ires<_rhocoupP.size()) {
 	F2-=_rhocoupP[ires]*rhos2bw[ires];
       }
       if(ires<_rhocoupD.size()) {
 	F1-=Complex(Dfact1*_rhocoupD[ires]*rhos2bw[ires]);
 	F3+=Complex(_rhocoupD[ires]*Dfact1*rhos2bw[ires]);
       }
     }
     else if(ichan==6) {
       F2-=2./3.*_sigmacoup*sigbws1;
       F3-=2./3.*_sigmacoup*sigbws1;
     }
     else if(ichan==7) {
       F1-=2./3.*_sigmacoup*sigbws2;
       F3+=2./3.*_sigmacoup*sigbws2;
     }
     else if(ichan==8) {
       complex<Energy2> sfact1 = 1./18.*(4.*_mpic*_mpic-s1)*(q2+s1-_mpic*_mpic)/s1*f2bws1;
       F1+=Complex(_f2coup*0.5*(s3-s2)*f2bws1);
       F2-=Complex(_f2coup*sfact1);
       F3-=Complex(_f2coup*sfact1);
     }
     else if(ichan==9) {
       complex<Energy2> sfact2 = 1./18.*(4.*_mpic*_mpic-s2)*(q2+s2-_mpic*_mpic)/s2*f2bws2;
       F1-=Complex(_f2coup*sfact2);
       F2+=Complex(_f2coup*0.5*(s3-s1)*f2bws2);
       F3+=Complex(_f2coup*sfact2);
     }
     else if(ichan==10) {
       F2-=2./3.*_f0coup*f0bws1;
       F3-=2./3.*_f0coup*f0bws1;
     }
     else if(ichan==11) {
       F1-=2./3.*_f0coup*f0bws2;
       F3+=2./3.*_f0coup*f0bws2;
     }
   }
   else {
     throw Exception() << "ThreePionCLEOCurrent Unknown Decay" << imode
 				 << Exception::abortnow;
   }
   F1 *= fact;
   F2 *= fact;
   F3 *= fact;
 }
 
 // complete the construction of the decay mode for integration
 bool ThreePionCLEOCurrent::createMode(int icharge, tcPDPtr resonance,
 				      FlavourInfo flavour,
 				      unsigned int imode,PhaseSpaceModePtr mode,
 				      unsigned int iloc,int ires,
 				      PhaseSpaceChannel phase, Energy upp ) {
   // check the charge and resonance
   if(imode<=1||imode==3||imode==4) {
     if(icharge!=0) return false;
     if(resonance && resonance->id()!=ParticleID::a_10) return false;
   }
   else if(imode==2||imode==5) {
     if(abs(icharge)!=3) return false;
     if(resonance && abs(resonance->id())!=ParticleID::a_1plus) return false;
   }
   // check the total isospin
   if(flavour.I!=IsoSpin::IUnknown) {
     if(flavour.I!=IsoSpin::IOne) return false;
   }
   // check I_3
   if(flavour.I3!=IsoSpin::I3Unknown) {
     switch(flavour.I3) {
     case IsoSpin::I3Zero:
       if(imode==2||imode==5) return false;
       break;
     case IsoSpin::I3One:
       if((imode!=2&&imode!=5) || icharge ==-3) return false;
       break;
     case IsoSpin::I3MinusOne:
       if((imode!=2&&imode!=5) || icharge == 3) return false;
       break;
     default:
       return false;
     }
   }
   if(flavour.strange != Strangeness::Unknown and flavour.strange != Strangeness::Zero) return false;
   if(flavour.charm   != Charm::Unknown       and flavour.charm   != Charm::Zero      ) return false;
   if(flavour.bottom  != Beauty::Unknown      and flavour.bottom  !=Beauty::Zero      ) return false;
   // get the particles and check the masses
   int iq(0),ia(0);
   tPDVector extpart=particles(1,imode,iq,ia);
   Energy min(ZERO);
   for(unsigned int ix=0;ix<extpart.size();++ix) min+=extpart[ix]->massMin();
   if(min>upp) return false;
   _maxmass=max(_maxmass,upp);
   // pointers to the particles we need
   tPDPtr a1m = getParticleData(ParticleID::a_1minus);
   tPDPtr a10 = getParticleData(ParticleID::a_10);
   // the different rho resonances
   tPDPtr rhom[3] = {getParticleData(-213),getParticleData(-100213),getParticleData(-30213)};
   if(icharge==3) {
     for(unsigned int ix=0;ix<3;++ix) rhom[ix]=rhom[ix]->CC();
     a1m = a1m->CC();
   }
   tPDPtr rho0[3] = {getParticleData(113),getParticleData(100113),getParticleData(30113)};
   // the sigma
   tPDPtr sigma = getParticleData(9000221);
   // the f_2
   tPDPtr f2=getParticleData(225);
   // the f_0
   tPDPtr f0=getParticleData(10221);
   assert(f2 && f0 && sigma);
   // a0 -> pi0 pi0 pi0
   if(imode<=1) {
     for(unsigned int ix=0;ix<3;++ix) {
       tPDPtr temp;
       if(ix==0)      temp = sigma;
       else if(ix==1) temp = f2;
       else if(ix==2) temp = f0;
       mode->addChannel((PhaseSpaceChannel(phase),ires,a10,ires+1,temp,ires+1,iloc+1,
 			ires+2,iloc+2,ires+2,iloc+3));
       mode->addChannel((PhaseSpaceChannel(phase),ires,a10,ires+1,temp,ires+1,iloc+2,
 			ires+2,iloc+1,ires+2,iloc+3));
       mode->addChannel((PhaseSpaceChannel(phase),ires,a10,ires+1,temp,ires+1,iloc+3,
 			ires+2,iloc+1,ires+2,iloc+2));
     }
   }
   // decay mode a_1- -> pi0 pi0 pi-
   else if(imode==2) {
     for(unsigned int ix=0;ix<3;++ix) {
       // first rho+ channel
       mode->addChannel((PhaseSpaceChannel(phase),ires,a1m,ires+1,rhom[ix],ires+1,iloc+1,
 			ires+2,iloc+2,ires+2,iloc+3));
       // second rho+ channel
       mode->addChannel((PhaseSpaceChannel(phase),ires,a1m,ires+1,rhom[ix],ires+1,iloc+2,
 			ires+2,iloc+1,ires+2,iloc+3));
     }
     // I=0 channels
     for(unsigned int iy=0;iy<3;++iy) {
       tPDPtr temp;
       if(iy==0)      temp = sigma;
       else if(iy==1) temp = f2;
       else if(iy==2) temp = f0;
       mode->addChannel((PhaseSpaceChannel(phase),ires,a1m,ires+1,temp,ires+1,iloc+3,
 			ires+2,iloc+1,ires+2,iloc+2));
     }
   }
   // decay mode a_10 -> pi+ pi- pi0
   else if(imode==3||imode==4) {
     // rho modes
     for(unsigned int ix=0;ix<3;++ix) {
       // first rho channel
       mode->addChannel((PhaseSpaceChannel(phase),ires,a10,ires+1,rhom[ix],ires+1,iloc+1,
 			ires+2,iloc+2,ires+2,iloc+3));
       // second channel
       mode->addChannel((PhaseSpaceChannel(phase),ires,a10,ires+1,rhom[ix],ires+1,iloc+2,
 			ires+2,iloc+1,ires+2,iloc+3));
     }
     // I=0 channels
     for(unsigned int iy=0;iy<3;++iy) {
       tPDPtr temp;
       if(iy==0)      temp = sigma;
       else if(iy==1) temp = f2;
       else if(iy==2) temp = f0;
       mode->addChannel((PhaseSpaceChannel(phase),ires,a10,ires+1,temp,ires+1,iloc+3,
 			ires+2,iloc+1,ires+2,iloc+2));
     }
   }
   else if(imode==5) {
     for(unsigned int ix=0;ix<3;++ix) {
       // the neutral rho channels
       // first channel
       mode->addChannel((PhaseSpaceChannel(phase),ires,a1m,ires+1,rho0[ix],ires+1,iloc+1,
 			ires+2,iloc+2,ires+2,iloc+3));
       // interchanged channel
       mode->addChannel((PhaseSpaceChannel(phase),ires,a1m,ires+1,rho0[ix],ires+1,iloc+2,
 			ires+2,iloc+1,ires+2,iloc+3));
     }
     for(unsigned int iy=0;iy<3;++iy) {
       tPDPtr temp;
       if(iy==0)      temp = sigma;
       else if(iy==1) temp = f2;
       else if(iy==2) temp = f0;
       // first channel
       mode->addChannel((PhaseSpaceChannel(phase),ires,a1m,ires+1,temp,ires+1,iloc+1,
 			ires+2,iloc+2,ires+2,iloc+3));
       // interchanged channel
       mode->addChannel((PhaseSpaceChannel(phase),ires,a1m,ires+1,temp,ires+1,iloc+2,
 			ires+2,iloc+1,ires+2,iloc+3));
     }
   }
   // reset the integration parameters
   for(unsigned int iy=0;iy<_rhomass.size();++iy) {
     mode->resetIntermediate(rho0[iy],_rhomass[iy],_rhowidth[iy]);
     mode->resetIntermediate(rhom[iy],_rhomass[iy],_rhowidth[iy]);
   }
   mode->resetIntermediate(sigma,_sigmamass,_sigmawidth);
   mode->resetIntermediate(f2,_f2mass,_f2width);
   mode->resetIntermediate(f0,_f0mass,_f0width);
   mode->resetIntermediate(a10,_a1mass,_a1width);
   mode->resetIntermediate(a10,_a1mass,_a1width);
   return true;
 }
 
 void ThreePionCLEOCurrent::dataBaseOutput(ofstream & output,bool header,
 					  bool create) const {
   if(header){output << "update decayers set parameters=\"";}
   if(create) {
-    output << "create Herwig::ThreePionCLEOCurrent " << name() 
+    output << "create Herwig::ThreePionCLEOCurrent " << name()
 	   << " HwWeakCurrents.so\n";
   }
   for(unsigned int ix=0;ix<_rhomass.size();++ix) {
     if(ix<2) {
-      output << "newdef    " << name() << ":RhoMasses " << ix 
+      output << "newdef    " << name() << ":RhoMasses " << ix
 	     << " " << _rhomass[ix]/MeV << "\n";
     }
     else {
-      output << "insert " << name() << ":RhoMasses " << ix 
+      output << "insert " << name() << ":RhoMasses " << ix
 	     << " " << _rhomass[ix]/MeV << "\n";
     }
   }
   for(unsigned int ix=0;ix<_rhowidth.size();++ix) {
     if(ix<2) {
-      output << "newdef    " << name() << ":RhoWidths " << ix 
+      output << "newdef    " << name() << ":RhoWidths " << ix
 	     << " " << _rhowidth[ix]/MeV << "\n";
     }
     else {
-      output << "insert " << name() << ":RhoWidths " << ix 
+      output << "insert " << name() << ":RhoWidths " << ix
 	     << " " << _rhowidth[ix]/MeV << "\n";
     }
   }
   output << "newdef " << name() << ":f_2Mass " << _f2mass/GeV << "\n";
   output << "newdef " << name() << ":f_2Width " << _f2width/GeV << "\n";
   output << "newdef " << name() << ":f_0Mass " << _f0mass/GeV << "\n";
   output << "newdef " << name() << ":f_0Width " << _f0width/GeV << "\n";
   output << "newdef " << name() << ":sigmaMass " << _sigmamass/GeV << "\n";
   output << "newdef " << name() << ":sigmaWidth " << _sigmawidth/GeV << "\n";
   output << "newdef " << name() << ":a1Mass " << _a1mass/GeV << "\n";
   output << "newdef " << name() << ":a1Width " <<_a1width /GeV << "\n";
   output << "newdef " << name() << ":KaonMass " << _mK/GeV << "\n";
   output << "newdef " << name() << ":KStarMass " << _mKstar/GeV << "\n";
   output << "newdef " << name() << ":KaonCoupling " << _gammk << "\n";
   output << "newdef " << name() << ":Fpi " << _fpi/MeV << "\n";
   output << "newdef " << name() << ":a1WidthOption " << _a1opt << "\n";
   for(unsigned int ix=0;ix<_rhomagP.size();++ix) {
       if(ix<2) {
-	output << "newdef    " << name() << ":RhoPWaveMagnitude " << ix 
+	output << "newdef    " << name() << ":RhoPWaveMagnitude " << ix
 	       << " " << _rhomagP[ix] << "\n";
       }
       else {
-	output << "insert " << name() << ":RhoPWaveMagnitude " << ix 
+	output << "insert " << name() << ":RhoPWaveMagnitude " << ix
 	       << " " << _rhomagP[ix] << "\n";
       }
   }
   for(unsigned int ix=0;ix<_rhophaseP.size();++ix) {
     if(ix<2) {
-      output << "newdef    " << name() << ":RhoPWavePhase " << ix 
+      output << "newdef    " << name() << ":RhoPWavePhase " << ix
 	     << " " << _rhophaseP[ix] << "\n";
     }
     else {
-      output << "insert " << name() << ":RhoPWavePhase " << ix 
+      output << "insert " << name() << ":RhoPWavePhase " << ix
 	     << " " << _rhophaseP[ix] << "\n";
     }
   }
   for(unsigned int ix=0;ix<_rhomagD.size();++ix) {
     if(ix<2) {
-      output << "newdef    " << name() << ":RhoDWaveMagnitude " << ix 
+      output << "newdef    " << name() << ":RhoDWaveMagnitude " << ix
 	     << " " << _rhomagD[ix]*MeV2 << "\n";
     }
     else {
-      output << "insert " << name() << ":RhoDWaveMagnitude " << ix 
+      output << "insert " << name() << ":RhoDWaveMagnitude " << ix
 	     << " " << _rhomagD[ix]*MeV2 << "\n";
     }
   }
   for(unsigned int ix=0;ix<_rhophaseD.size();++ix) {
     if(ix<2) {
-      output << "newdef    " << name() << ":RhoDWavePhase " << ix 
+      output << "newdef    " << name() << ":RhoDWavePhase " << ix
 	     << " " << _rhophaseD[ix] << "\n";
     }
     else {
-      output << "insert " << name() << ":RhoDWavePhase " << ix 
+      output << "insert " << name() << ":RhoDWavePhase " << ix
 	     << " " << _rhophaseD[ix] << "\n";
     }
   }
   output << "newdef " << name() << ":f0Phase " << _f0phase << "\n";
   output << "newdef " << name() << ":f2Phase " <<_f2phase  << "\n";
   output << "newdef " << name() << ":sigmaPhase " <<_sigmaphase  << "\n";
   output << "newdef " << name() << ":f0Magnitude " << _f0mag << "\n";
   output << "newdef " << name() << ":f2Magnitude " << _f2mag*GeV2 << "\n";
   output << "newdef " << name() << ":sigmaMagnitude " <<_sigmamag  << "\n";
   output << "newdef " << name() << ":Initializea1 " <<_initializea1  << "\n";
   for(unsigned int ix=0;ix<_a1runwidth.size();++ix) {
     if(ix<200) {
-      output << "newdef    " << name() << ":a1RunningWidth " << ix 
+      output << "newdef    " << name() << ":a1RunningWidth " << ix
 	     << " " << _a1runwidth[ix]/MeV << "\n";
     }
     else {
-      output << "insert " << name() << ":a1RunningWidth " << ix 
+      output << "insert " << name() << ":a1RunningWidth " << ix
 	     << " " << _a1runwidth[ix]/MeV << "\n";
     }
   }
   for(unsigned int ix=0;ix<_a1runq2.size();++ix) {
     if(ix<200) {
-      output << "newdef    " << name() << ":a1RunningQ2 " << ix 
+      output << "newdef    " << name() << ":a1RunningQ2 " << ix
 	     << " " << _a1runq2[ix]/MeV2 << "\n";
     }
     else {
-      output << "insert " << name() << ":a1RunningQ2 " << ix 
+      output << "insert " << name() << ":a1RunningQ2 " << ix
 	     << " " << _a1runq2[ix]/MeV2 << "\n";
     }
   }
   WeakCurrent::dataBaseOutput(output,false,false);
-  if(header) output << "\n\" where BINARY ThePEGName=\"" 
+  if(header) output << "\n\" where BINARY ThePEGName=\""
 		    << fullName() << "\";" << endl;
 }
 
 void ThreePionCLEOCurrent::doinitrun() {
   // set up the running a_1 width
   inita1Width(0);
   WeakCurrent::doinitrun();
 }
 
 void ThreePionCLEOCurrent::doupdate() {
   WeakCurrent::doupdate();
   // update running width if needed
   if ( !touched() ) return;
   if(_maxmass!=_maxcalc) inita1Width(-1);
 }
 
 Energy ThreePionCLEOCurrent::a1width(Energy2 q2) const {
   Energy output;
   if(_a1opt) output=(*_a1runinter)(q2);
   else {
     double gam(0.);
     if(q2<0.1753*GeV2) {
       gam =0.;
     }
     else if(q2<0.823*GeV2) {
       double p=q2/GeV2-0.1753;
       gam = 5.80900*p*sqr(p)*(1.-3.00980*p+4.57920*sqr(p));
     }
     else {
       double p=q2/GeV2;
       gam = -13.91400+27.67900*p-13.39300*sqr(p)
 	+3.19240*sqr(p)*p-0.10487*sqr(sqr(p));
     }
     if(q2<0.1676*GeV2) {
       gam+=0.;
     }
     else if(q2<0.823*GeV2) {
       double p=q2/GeV2-0.1676;
       gam+= 6.28450*p*sqr(p)*(1.-2.95950*p+4.33550*sqr(p));
     }
     else {
       double p=q2/GeV2;
       gam+= -15.41100+32.08800*p-17.66600*sqr(p)
 	+4.93550*sqr(p)*p-0.37498*sqr(sqr(p));
     }
     Energy mkst=0.894*GeV,mk=0.496*GeV;
     Energy2 mk1sq=sqr(mkst+mk), mk2sq=sqr(mkst-mk);
     double c3pi=sqr(0.2384),ckst=sqr(4.7621)*c3pi;
     gam*=c3pi;
     if(q2>mk1sq) gam+=0.5*ckst*sqrt((q2-mk1sq)*(q2-mk2sq))/q2;
     gam = gam*_a1width*_a1mass/GeV2/1.331/0.814/1.0252088;
     output = gam*GeV2/sqrt(q2);
   }
   return output;
 }
 
-double 
+double
 ThreePionCLEOCurrent::threeBodyMatrixElement(const int iopt, const Energy2 q2,
-					     const Energy2 s3, const Energy2 s2, 
+					     const Energy2 s3, const Energy2 s2,
 					     const Energy2 s1, const Energy,
 					     const Energy, const Energy) const {
   Energy p1[5],p2[5],p3[5];
   Energy2 p1sq, p2sq, p3sq;
   Energy q=sqrt(q2);
   Energy2 mpi2c=_mpic*_mpic;
   Energy2 mpi20=_mpi0*_mpi0;
   // construct the momenta for the 2 neutral 1 charged mode
   Complex F1,F2,F3;
   if(iopt==0) {
     // construct the momenta of the decay products
     p1[0] = 0.5*(q2+mpi20-s1)/q; p1sq=p1[0]*p1[0]; p1[4]=sqrt(p1sq-mpi20);
     p2[0] = 0.5*(q2+mpi20-s2)/q; p2sq=p2[0]*p2[0]; p2[4]=sqrt(p2sq-mpi20);
     p3[0] = 0.5*(q2+mpi2c-s3)/q; p3sq=p3[0]*p3[0]; p3[4]=sqrt(p3sq-mpi2c);
     // take momentum of 1 parallel to z axis
     p1[1]=ZERO;p1[2]=ZERO;p1[3]=p1[4];
-    // construct 2 
+    // construct 2
     double cos2 = 0.5*(p1sq+p2sq-p3sq-2.*mpi20+mpi2c)/p1[4]/p2[4];
     p2[1] = p2[4]*sqrt(1.-cos2*cos2); p2[2]=ZERO; p2[3]=-p2[4]*cos2;
     // construct 3
     double cos3 = 0.5*(p1sq-p2sq+p3sq-mpi2c)/p1[4]/p3[4];
-    p3[1] =-p3[4]*sqrt(1.-cos3*cos3); p3[2]=ZERO; p3[3]=-p3[4]*cos3; 
+    p3[1] =-p3[4]*sqrt(1.-cos3*cos3); p3[2]=ZERO; p3[3]=-p3[4]*cos3;
     // calculate the form factors
     CLEOFormFactor(1,-1,q2,s1,s2,s3,F1,F2,F3);
   }
-  // construct the momenta for the 3 charged mode 
+  // construct the momenta for the 3 charged mode
   else {
     // construct the momenta of the decay products
     p1[0] = 0.5*(q2+mpi2c-s1)/q; p1sq=p1[0]*p1[0]; p1[4]=sqrt(p1sq-mpi2c);
     p2[0] = 0.5*(q2+mpi2c-s2)/q; p2sq=p2[0]*p2[0]; p2[4]=sqrt(p2sq-mpi2c);
     p3[0] = 0.5*(q2+mpi2c-s3)/q; p3sq=p3[0]*p3[0]; p3[4]=sqrt(p3sq-mpi2c);
     // take momentum of 1 parallel to z axis
     p1[1]=ZERO;p1[2]=ZERO;p1[3]=p1[4];
-    // construct 2 
+    // construct 2
     double cos2 = 0.5*(p1sq+p2sq-p3sq-mpi2c)/p1[4]/p2[4];
     p2[1] = p2[4]*sqrt(1.-cos2*cos2); p2[2]=ZERO; p2[3]=-p2[4]*cos2;
     // construct 3
     double cos3 = 0.5*(p1sq-p2sq+p3sq-mpi2c)/p1[4]/p3[4];
-    p3[1] =-p3[4]*sqrt(1.-cos3*cos3); p3[2]=ZERO; p3[3]=-p3[4]*cos3; 
+    p3[1] =-p3[4]*sqrt(1.-cos3*cos3); p3[2]=ZERO; p3[3]=-p3[4]*cos3;
     // calculate the form factors
     CLEOFormFactor(0,-1,q2,s1,s2,s3,F1,F2,F3);
   }
   // construct a vector with the current
   complex<Energy> current[4];
   for(unsigned int ix=0;ix<4;++ix)
     current[ix] = F1*(p2[ix]-p3[ix])-F2*(p3[ix]-p1[ix])+F3*(p1[ix]-p2[ix]);
   complex<Energy2> dot1=current[0]*conj(current[0]);
   for(unsigned int ix=1;ix<4;++ix) dot1-=current[ix]*conj(current[ix]);
   complex<Energy2> dot2=current[0]*q;
   return(-dot1+dot2*conj(dot2)/q2).real() / sqr(_rhomass[0]);
 }
 
-// the hadronic currents    
-vector<LorentzPolarizationVectorE> 
+// the hadronic currents
+vector<LorentzPolarizationVectorE>
 ThreePionCLEOCurrent::current(tcPDPtr resonance,
 			      FlavourInfo flavour,
-			      const int imode, const int ichan, Energy & scale, 
+			      const int imode, const int ichan, Energy & scale,
 			      const tPDVector & ,
 			      const vector<Lorentz5Momentum> & momenta,
 			      DecayIntegrator::MEOption) const {
   useMe();
   // check the isospin
   if(flavour.I!=IsoSpin::IUnknown && flavour.I!=IsoSpin::IOne)
     return vector<LorentzPolarizationVectorE>();
   // check I_3
   if(flavour.I3!=IsoSpin::I3Unknown) {
     switch(flavour.I3) {
     case IsoSpin::I3Zero:
       if(imode==2||imode==5) return vector<LorentzPolarizationVectorE>();
       break;
     case IsoSpin::I3One:
       if(imode!=2&&imode!=5) return vector<LorentzPolarizationVectorE>();
       break;
     case IsoSpin::I3MinusOne:
       if(imode!=2&&imode!=5) return vector<LorentzPolarizationVectorE>();
       break;
     default:
       return vector<LorentzPolarizationVectorE>();
     }
   }
   if(flavour.strange != Strangeness::Unknown and flavour.strange != Strangeness::Zero) return vector<LorentzPolarizationVectorE>();
   if(flavour.charm   != Charm::Unknown       and flavour.charm   != Charm::Zero      ) return vector<LorentzPolarizationVectorE>();
   if(flavour.bottom  != Beauty::Unknown      and flavour.bottom  !=Beauty::Zero      ) return vector<LorentzPolarizationVectorE>();
   // calculate q2,s1,s2,s3
   Lorentz5Momentum q;
   for(unsigned int ix=0;ix<momenta.size();++ix)
     q+=momenta[ix];
   q.rescaleMass();
   scale=q.mass();
   Energy2 q2=q.mass2();
   Energy2 s1 = (momenta[1]+momenta[2]).m2();
   Energy2 s2 = (momenta[0]+momenta[2]).m2();
   Energy2 s3 = (momenta[0]+momenta[1]).m2();
   // form factors
   Complex F1(0.), F2(0.), F3(0.);
   CLEOFormFactor(imode,ichan,q2,s1,s2,s3,F1,F2,F3);
   // change sign of the F2 term
   F2 =- F2;
   // prefactor
   complex<InvEnergy> a1fact = _fact;
-  if(!resonance) a1fact *= a1BreitWigner(q2);
+  if(!resonance) a1fact = a1fact * a1BreitWigner(q2);
   // current
   LorentzPolarizationVectorE vect = q.mass()*a1fact*
     ((F2-F1)*momenta[2] + (F1-F3)*momenta[1] + (F3-F2)*momenta[0]);
   // scalar piece
   Complex dot=(vect*q)/q2;
   vect -= dot*q;
   // return the answer
   return vector<LorentzPolarizationVectorE>(1,vect);
 }
 
 bool ThreePionCLEOCurrent::accept(vector<int> id) {
   if(id.size()!=3) return false;
   for(unsigned int ix=0;ix<id.size();++ix) {
-    if(id[ix]==ParticleID::piplus) continue; 
+    if(id[ix]==ParticleID::piplus) continue;
     else if(id[ix]==ParticleID::piminus) continue;
     else if(id[ix]==ParticleID::pi0)     continue;
     return false;
   }
   return true;
 }
 
 unsigned int ThreePionCLEOCurrent::decayMode(vector<int> id) {
   if(id.size()!=3) return -1;
   int npip(0),npim(0),npi0(0);
   for(unsigned int ix=0;ix<id.size();++ix) {
     if(id[ix]==ParticleID::piplus)       ++npip;
     else if(id[ix]==ParticleID::piminus) ++npim;
     else if(id[ix]==ParticleID::pi0)     ++npi0;
   }
   if       (npi0==3)                                  return 0;
   else if( (npip==1&&npi0==2) || (npim==1&&npi0==2) ) return 2;
-  else if( npi0==1 && npip==1 && npim==1 )            return 3; 
+  else if( npi0==1 && npip==1 && npim==1 )            return 3;
   else if( (npip==2&&npim==1) || (npim==2&&npip==1) ) return 5;
   else return -1;
 }
 
 tPDVector ThreePionCLEOCurrent::particles(int icharge, unsigned int imode,int,int) {
   tPDVector extpart(3);
   if(imode==0||imode==1) {
     extpart[0]=getParticleData(ParticleID::pi0);
     extpart[1]=getParticleData(ParticleID::pi0);
     extpart[2]=getParticleData(ParticleID::pi0);
   }
   else if(imode==2) {
     extpart[0]=getParticleData(ParticleID::pi0);
     extpart[1]=getParticleData(ParticleID::pi0);
     extpart[2]=getParticleData(ParticleID::piminus);
   }
   else if(imode==3||imode==4) {
     extpart[0]=getParticleData(ParticleID::piplus);
     extpart[1]=getParticleData(ParticleID::piminus);
     extpart[2]=getParticleData(ParticleID::pi0);
   }
   else if(imode==5) {
     extpart[0]=getParticleData(ParticleID::piminus);
     extpart[1]=getParticleData(ParticleID::piminus);
     extpart[2]=getParticleData(ParticleID::piplus);
   }
   else
     assert(false);
   // conjugate the particles if needed
   if(icharge==3) {
     for(unsigned int ix=0;ix<3;++ix) {
       if(extpart[ix]->CC()) extpart[ix]=extpart[ix]->CC();
     }
   }
   // return the answer
   return extpart;
 }
-
diff --git a/Decay/WeakCurrents/TwoPionPhotonSNDCurrent.cc b/Decay/WeakCurrents/TwoPionPhotonSNDCurrent.cc
--- a/Decay/WeakCurrents/TwoPionPhotonSNDCurrent.cc
+++ b/Decay/WeakCurrents/TwoPionPhotonSNDCurrent.cc
@@ -1,434 +1,434 @@
 // -*- C++ -*-
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the TwoPionPhotonSNDCurrent class.
 //
 
 #include "TwoPionPhotonSNDCurrent.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/EventRecord/Particle.h"
 #include "ThePEG/Repository/UseRandom.h"
 #include "ThePEG/Repository/EventGenerator.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Helicity/epsilon.h"
 
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "Herwig/Utilities/Kinematics.h"
 
 using namespace Herwig;
 
 TwoPionPhotonSNDCurrent::TwoPionPhotonSNDCurrent() {
   // modes handled
   addDecayMode(2,-1);
   addDecayMode(1,-1);
   addDecayMode(2,-2);
   setInitialModes(3);
   // amplitudes for the weights in the current
   amp_   = {1.,0.175,0.014};
   phase_ = {0.,124.,-63.};
   // rho masses and widths
   rhoMasses_ = {0.77526*GeV,1.510*GeV,1.720*GeV};
   rhoWidths_ = {0.1491 *GeV,0.44 *GeV,0.25 *GeV};
   // coupling
   gRhoOmegaPi_   = 15.9/GeV;
   fRho_        = 4.9583;
   gGammaOmegaPi_ = 0.695821538653/GeV;
   fRho_        = 4.9583;
   // omega parameters
   omegaMass_  = 782.65*MeV;
   omegaWidth_ = 8.49 *MeV;
 }
 
 IBPtr TwoPionPhotonSNDCurrent::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr TwoPionPhotonSNDCurrent::fullclone() const {
   return new_ptr(*this);
 }
 
 void TwoPionPhotonSNDCurrent::doinit() {
   WeakCurrent::doinit();
   assert(phase_.size()==amp_.size());
   wgts_.clear();
   Complex ii(0.,1.);
   for(unsigned int ix=0;ix<amp_.size();++ix) {
     double phi = phase_[ix]/180.*Constants::pi;
     wgts_.push_back(amp_[ix]*(cos(phi)+ii*sin(phi)));
   }
   mpi_ = getParticleData(ParticleID::piplus)->mass();
 }
 
 void TwoPionPhotonSNDCurrent::persistentOutput(PersistentOStream & os) const {
   os << ounit(rhoMasses_,GeV) << ounit(rhoWidths_,GeV)
      << amp_ << phase_ << wgts_ << fRho_
      << ounit(gRhoOmegaPi_,1./GeV) << ounit(gGammaOmegaPi_,1./GeV)
      << ounit(omegaMass_,GeV) << ounit(omegaWidth_,GeV) << ounit(mpi_,GeV);
 }
 
 void TwoPionPhotonSNDCurrent::persistentInput(PersistentIStream & is, int) {
   is >> iunit(rhoMasses_,GeV) >> iunit(rhoWidths_,GeV)
      >> amp_ >> phase_ >> wgts_ >> fRho_
      >> iunit(gRhoOmegaPi_,1./GeV) >> iunit(gGammaOmegaPi_,1./GeV)
      >> iunit(omegaMass_,GeV) >> iunit(omegaWidth_,GeV) >> iunit(mpi_,GeV);
 }
 
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeClass<TwoPionPhotonSNDCurrent,WeakCurrent>
 describeHerwigTwoPionPhotonSNDCurrent("Herwig::TwoPionPhotonSNDCurrent",
 				      "HwWeakCurrents.so");
 
 void TwoPionPhotonSNDCurrent::Init() {
 
   static ClassDocumentation<TwoPionPhotonSNDCurrent> documentation
     ("The TwoPionPhotonSNDCurrent class provides the weka current for"
      "pi pi gamma using the model of SND",
      "The current based on \\cite{Achasov:2016zvn} for $\\pi\\pi^0\\gamma$ was used.\n",
      "\\bibitem{Achasov:2016zvn}"
      "M.~N.~Achasov {\\it et al.},\n"
      "%``Updated measurement of the $e^+e^- \\to \\omega \\pi^0 \\to \\pi^0\\pi^0\\gamma$ cross section with the SND detector,''\n"
      "Phys.\\ Rev.\\ D {\\bf 94} (2016) no.11,  112001\n"
      "doi:10.1103/PhysRevD.94.112001\n"
      "[arXiv:1610.00235 [hep-ex]].\n"
      "%%CITATION = doi:10.1103/PhysRevD.94.112001;%%\n"
      "%12 citations counted in INSPIRE as of 22 Aug 2018\n");
 
   static ParVector<TwoPionPhotonSNDCurrent,Energy> interfaceRhoMasses
     ("RhoMasses",
      "The masses of the rho mesons",
      &TwoPionPhotonSNDCurrent::rhoMasses_, GeV, -1, 775.26*MeV,
      0.5*GeV, 10.0*GeV,
      false, false, Interface::limited);
 
   static ParVector<TwoPionPhotonSNDCurrent,Energy> interfaceRhoWidths
     ("RhoWidths",
      "The widths of the rho mesons",
      &TwoPionPhotonSNDCurrent::rhoWidths_, GeV, -1, 0.1491*GeV,
      0.5*GeV, 10.0*GeV,
      false, false, Interface::limited);
 
   static ParVector<TwoPionPhotonSNDCurrent,double> interfaceAmplitudes
     ("Amplitudes",
      "THe amplitudes for the different rho resonances",
      &TwoPionPhotonSNDCurrent::amp_, -1, 1.0, 0.0, 10.0,
      false, false, Interface::limited);
 
   static ParVector<TwoPionPhotonSNDCurrent,double> interfacePhase
     ("Phase",
      "The phases for the different rho resonances in degrees",
      &TwoPionPhotonSNDCurrent::phase_, -1, 0., 0.0, 360.,
      false, false, Interface::limited);
 
   static Parameter<TwoPionPhotonSNDCurrent,double> interfacefRho
     ("fRho",
      "The coupling of the photon and the rho meson",
      &TwoPionPhotonSNDCurrent::fRho_, 4.9583, 0.0, 100.0,
      false, false, Interface::limited);
 
   static Parameter<TwoPionPhotonSNDCurrent,InvEnergy> interfacegRhoOmegaPi
     ("gRhoOmegaPi",
      "The coupling rho-omega-pi",
      &TwoPionPhotonSNDCurrent::gRhoOmegaPi_, 1./GeV,
      15.9/GeV, 0./GeV, 1000./GeV,
      false, false, Interface::limited);
 
   static Parameter<TwoPionPhotonSNDCurrent,InvEnergy> interfacegGammaOmegaPi
     ("gGammaOmegaPi",
      "The coupling gamma-omega-pi",
      &TwoPionPhotonSNDCurrent::gGammaOmegaPi_, 1./GeV,
      0.695821538653/GeV, 0./GeV, 1000./GeV,
      false, false, Interface::limited);
 
   static Parameter<TwoPionPhotonSNDCurrent,Energy> interfaceOmegaMass
     ("OmegaMass",
      "The mass of the omega meson",
      &TwoPionPhotonSNDCurrent::omegaMass_, GeV, 0.78265*GeV, 0.0*GeV, 10.0*GeV,
      false, false, Interface::limited);
 
   static Parameter<TwoPionPhotonSNDCurrent,Energy> interfaceOmegaWidth
     ("OmegaWidth",
      "The width of the omega meson",
      &TwoPionPhotonSNDCurrent::omegaWidth_, GeV, 8.49*MeV, 0.0*GeV, 10.0*GeV,
      false, false, Interface::limited);
 }
 
 // complete the construction of the decay mode for integration
 bool TwoPionPhotonSNDCurrent::createMode(int icharge, tcPDPtr resonance,
 					 FlavourInfo flavour,
 					 unsigned int imode,PhaseSpaceModePtr mode,
 					 unsigned int iloc,int ires,
 					 PhaseSpaceChannel phase, Energy upp ) {
   // check the charge
   if((abs(icharge)!=3 && imode == 0) ||
      (   icharge!=0   && imode >= 1))
     return false;
   // check the total isospin
   if(flavour.I!=IsoSpin::IUnknown) {
     if(flavour.I!=IsoSpin::IOne) return false;
   }
   // check I_3
   if(flavour.I3!=IsoSpin::I3Unknown) {
     switch(flavour.I3) {
     case IsoSpin::I3Zero:
       if(imode!=1) return false;
       break;
     case IsoSpin::I3One:
       if(imode>1 || icharge ==-3) return false;
       break;
     case IsoSpin::I3MinusOne:
       if(imode>1 || icharge ==3) return false;
       break;
     default:
       return false;
     }
   }
   if(flavour.strange != Strangeness::Unknown and flavour.strange != Strangeness::Zero)
     return false;
   if(flavour.charm   != Charm::Unknown       and flavour.charm   != Charm::Zero       )
     return false;
   if(flavour.bottom  != Beauty::Unknown      and flavour.bottom  !=Beauty::Zero       )
     return false;
   // check that the mode is are kinematical allowed
   Energy min(getParticleData(ParticleID::piplus)->mass()+
   	     getParticleData(ParticleID::pi0   )->mass());
   if(min>upp) return false;
   // set up the integration channels;
   tPDPtr omega(getParticleData(ParticleID::omega));
   vector<tPDPtr> rho;
   if(icharge==-3)
     rho = {getParticleData(-213),getParticleData(-100213),getParticleData(-30213)};
   else if(icharge==0)
     rho = {getParticleData( 113),getParticleData( 100113),getParticleData( 30113)};
   else if(icharge==3)
     rho = {getParticleData( 213),getParticleData( 100213),getParticleData( 30213)};
   for(unsigned int ix=0;ix<3;++ix) {
     if(resonance && resonance!=rho[ix]) continue;
     mode->addChannel((PhaseSpaceChannel(phase),ires,rho[ix],
 		      ires+1,omega,ires+1,iloc+1,
 		      ires+2,iloc+2,ires+2,iloc+3));
     // channel with the pions exchanged
-    if(icharge==0) 
+    if(icharge==0)
       mode->addChannel((PhaseSpaceChannel(phase),ires,rho[ix],
 			ires+1,omega,ires+1,iloc+2,
 			ires+2,iloc+1,ires+2,iloc+3));
   }
   // reset the masses and widths of the resonances if needed
   for(unsigned int ix=0;ix<3;++ix) {
     mode->resetIntermediate(rho[ix],rhoMasses_[ix],rhoWidths_[ix]);
   }
   // set up the omega masses and widths
   mode->resetIntermediate(omega,omegaMass_,omegaWidth_);
   return true;
 }
 
 // the particles produced by the current
 tPDVector TwoPionPhotonSNDCurrent::particles(int icharge, unsigned int imode,int,int) {
   tPDVector extpart = {tPDPtr(),
 		       getParticleData(ParticleID::pi0),
 		       getParticleData(ParticleID::gamma)};
   if(imode==0) {
     if(icharge==3)       extpart[0] = getParticleData(ParticleID::piplus );
     else if(icharge==-3) extpart[0] = getParticleData(ParticleID::piminus);
   }
   else {
     extpart[0] = getParticleData(ParticleID::pi0);
   }
   return extpart;
 }
 
 void TwoPionPhotonSNDCurrent::constructSpinInfo(ParticleVector decay) const {
   vector<LorentzPolarizationVector> temp(3);
   for(unsigned int ix=0;ix<3;++ix) {
     if(ix==1) ++ix;
     temp[ix] = HelicityFunctions::polarizationVector(-decay[2]->momentum()
 						     ,ix,Helicity::outgoing);
   }
   for(unsigned int ix=0;ix<2;++ix)
     ScalarWaveFunction::constructSpinInfo(decay[ix],outgoing,true);
   VectorWaveFunction::constructSpinInfo(temp,decay[2],
 					outgoing,true,true);
 }
 
-// the hadronic currents    
-vector<LorentzPolarizationVectorE> 
+// the hadronic currents
+vector<LorentzPolarizationVectorE>
 TwoPionPhotonSNDCurrent::current(tcPDPtr resonance,
 			      FlavourInfo flavour,
-			      const int imode, const int ichan, Energy & scale, 
+			      const int imode, const int ichan, Energy & scale,
 			      const tPDVector & outgoing,
 			      const vector<Lorentz5Momentum> & momenta,
 			      DecayIntegrator::MEOption) const {
   int icharge = outgoing[0]->iCharge()+outgoing[1]->iCharge()+outgoing[2]->iCharge();
   // check the charge
   if((abs(icharge)!=3 && imode == 0) ||
      (   icharge!=0   && imode == 1))
     return vector<LorentzPolarizationVectorE>();
   // check the total isospin
   if(flavour.I!=IsoSpin::IUnknown) {
     if(flavour.I!=IsoSpin::IOne) return vector<LorentzPolarizationVectorE>();
   }
   // check I_3
   if(flavour.I3!=IsoSpin::I3Unknown) {
     switch(flavour.I3) {
     case IsoSpin::I3Zero:
       if(imode!=1) return vector<LorentzPolarizationVectorE>();
       break;
     case IsoSpin::I3One:
       if(imode>1 || icharge ==-3) return vector<LorentzPolarizationVectorE>();
       break;
     case IsoSpin::I3MinusOne:
       if(imode>1 || icharge ==3) return vector<LorentzPolarizationVectorE>();
       break;
     default:
       return vector<LorentzPolarizationVectorE>();
     }
   }
   if(flavour.strange != Strangeness::Unknown and flavour.strange != Strangeness::Zero)
     return vector<LorentzPolarizationVectorE>();
   if(flavour.charm   != Charm::Unknown       and flavour.charm   != Charm::Zero       )
     return vector<LorentzPolarizationVectorE>();
   if(flavour.bottom  != Beauty::Unknown      and flavour.bottom  !=Beauty::Zero       )
     return vector<LorentzPolarizationVectorE>();
   useMe();
   // polarization vectors of the photon
   vector<LorentzPolarizationVector> temp(3);
   for(unsigned int ix=0;ix<3;++ix) {
     if(ix==1) ++ix;
     temp[ix] = HelicityFunctions::polarizationVector(-momenta[2],ix,Helicity::outgoing);
   }
   // total momentum of the system
   Lorentz5Momentum q(momenta[0]+momenta[1]+momenta[2]);
   // overall hadronic mass
   q.rescaleMass();
   scale=q.mass();
   Energy2 q2(q.m2());
   unsigned int imin=0, imax = wgts_.size();
   if(ichan>0) {
     if(outgoing[0]!=outgoing[1])
       imin = ichan;
     else
       imin = ichan/2;
     imax = imin+1;
   }
   if(resonance) {
     switch(resonance->id()/1000) {
     case 0:
       imin = 0;
       break;
     case 100:
       imin = 1;
       break;
     case 30 :
       imin = 2;
       break;
     default:
       assert(false);
     }
     imax=imin+1;
   }
   vector<LorentzPolarizationVectorE> ret(3);
   // need to include exchange of identical particles for the I_3=0 case
   for(int iorder=0;iorder<2;++iorder) {
     Lorentz5Momentum pout(momenta[2]);
     if(outgoing[0]==outgoing[1]) {
       if(ichan>=0&& ichan%2!=iorder) continue;
     }
     else if(iorder==1) continue;
     // add pion momentum
     if(iorder==0) pout += momenta[1];
     else          pout += momenta[0];
     // mass of the omega
     pout.rescaleMass();
     Energy2 s2(pout.m2());
     // compute the rho width
     Energy2 mr2(sqr(rhoMasses_[0]));
     Energy grho = rhoWidths_[0]*mr2/q2*pow(max(double((q2-4.*sqr(mpi_))/(mr2-4.*sqr(mpi_))),0.),1.5);
     Energy qw = Kinematics::pstarTwoBodyDecay(q.mass(),pout.mass(),mpi_);
     grho += pow<3,1>(qw)*sqr(gRhoOmegaPi_)/12./Constants::pi;
     // compute the prefactor
     complex<InvEnergy4> pre = gRhoOmegaPi_*gGammaOmegaPi_/fRho_*
       Resonance::BreitWignerFW(s2,omegaMass_,omegaWidth_)/sqr(omegaMass_);
     if(imode==0) pre *=sqrt(2.);
     Complex bw(0.);
     for(unsigned int ix=imin;ix<imax;++ix) {
       Energy wid = ix==0 ? grho : rhoWidths_[ix];
       Energy2 mR2 = sqr(rhoMasses_[ix]);
       bw += mR2*wgts_[ix]/(mR2-q2-Complex(0.,1.)*q.mass()*wid);
     }
-    pre *=bw;
+    pre = pre * bw;
     for(unsigned int ix=0;ix<3;++ix) {
       if(ix==1) continue;
       LorentzVector<complex<Energy2> > v2 = Helicity::epsilon(pout,temp[ix],momenta[2]);
       ret[ix] += pre*scale*Helicity::epsilon(q,v2,pout);
     }
   }
   return ret;
 }
 
 bool TwoPionPhotonSNDCurrent::accept(vector<int> id) {
   if(id.size()!=3){return false;}
   unsigned int npiplus(0),npi0(0),ngamma(0);
   for(unsigned int ix=0;ix<id.size();++ix) {
     if(abs(id[ix])==ParticleID::piplus) ++npiplus;
     else if(id[ix]==ParticleID::gamma)  ++ngamma;
     else if(id[ix]==ParticleID::pi0)    ++npi0;
   }
   return (npiplus==1&&ngamma==1&&npi0==1) ||
     (npi0==2&&ngamma==1);
 }
 
 unsigned int TwoPionPhotonSNDCurrent::decayMode(vector<int> id) {
   int npip(0),npim(0),npi0(0),ngamma(0);
   for(unsigned int ix=0;ix<id.size();++ix) {
     if(id[ix]==ParticleID::piplus)         ++npip;
     else if(id[ix]==ParticleID::piminus)   ++npim;
     else if(id[ix]==ParticleID::pi0)       ++npi0;
     else if(id[ix]==ParticleID::gamma)   ++ngamma;
   }
   if((npip==1 || npim == 1) && npi0==1 && ngamma==1)
     return 0;
   else
     return 1;
 }
 
 // output the information for the database
 void TwoPionPhotonSNDCurrent::dataBaseOutput(ofstream & output,bool header,
 					  bool create) const {
   if(header) output << "update decayers set parameters=\"";
-  if(create) output << "create Herwig::TwoPionPhotonSNDCurrent " << name() 
+  if(create) output << "create Herwig::TwoPionPhotonSNDCurrent " << name()
 		    << " HwWeakCurrents.so\n";
   for(unsigned int ix=0;ix<rhoMasses_.size();++ix) {
-    if(ix<3) output << "newdef " << name() << ":RhoMasses " << ix 
+    if(ix<3) output << "newdef " << name() << ":RhoMasses " << ix
 		    << " " << rhoMasses_[ix]/GeV << "\n";
-    else     output << "insert " << name() << ":RhoMasses " << ix 
+    else     output << "insert " << name() << ":RhoMasses " << ix
 		    << " " << rhoMasses_[ix]/GeV << "\n";
   }
   for(unsigned int ix=0;ix<rhoWidths_.size();++ix) {
-    if(ix<3) output << "newdef " << name() << ":RhoWidths " << ix 
+    if(ix<3) output << "newdef " << name() << ":RhoWidths " << ix
 		    << " " << rhoWidths_[ix]/GeV << "\n";
-    else     output << "insert " << name() << ":RhoWidths " << ix 
+    else     output << "insert " << name() << ":RhoWidths " << ix
 		    << " " << rhoWidths_[ix]/GeV << "\n";
   }
   for(unsigned int ix=0;ix<amp_.size();++ix) {
-    if(ix<3) output << "newdef " << name() << ":Amplitudes " << ix 
+    if(ix<3) output << "newdef " << name() << ":Amplitudes " << ix
 		    << " " << amp_[ix] << "\n";
-    else     output << "insert " << name() << ":Amplitudes " << ix 
+    else     output << "insert " << name() << ":Amplitudes " << ix
 		    << " " << amp_[ix] << "\n";
   }
   for(unsigned int ix=0;ix<phase_.size();++ix) {
-    if(ix<3) output << "newdef " << name() << ":Phases " << ix 
+    if(ix<3) output << "newdef " << name() << ":Phases " << ix
 		    << " " << phase_[ix] << "\n";
-    else     output << "insert " << name() << ":Phases " << ix 
+    else     output << "insert " << name() << ":Phases " << ix
 		    << " " << phase_[ix] << "\n";
   }
   output << "newdef " << name() << ":fRho "    << fRho_ << "\n";
   output << "newdef " << name() << ":gRhoOmegaPi "    << gRhoOmegaPi_*GeV << "\n";
   output << "newdef " << name() << ":gGammaOmegaPi "    << gGammaOmegaPi_*GeV << "\n";
   output << "newdef " << name() << ":OmegaMass "    << omegaMass_/GeV << "\n";
   output << "newdef " << name() << ":OmegaWidth "    << omegaWidth_/GeV << "\n";
   WeakCurrent::dataBaseOutput(output,false,false);
-  if(header) output << "\n\" where BINARY ThePEGName=\"" 
+  if(header) output << "\n\" where BINARY ThePEGName=\""
 		    << fullName() << "\";" << endl;
 }
diff --git a/MatrixElement/FxFx/Makefile.am b/MatrixElement/FxFx/Makefile.am
--- a/MatrixElement/FxFx/Makefile.am
+++ b/MatrixElement/FxFx/Makefile.am
@@ -1,15 +1,15 @@
 pkglib_LTLIBRARIES = HwFxFx.la HwFxFxHandler.la
 HwFxFx_la_SOURCES = \
 FxFxFileReader.cc FxFxFileReader.fh FxFxFileReader.h\
 FxFxEventHandler.cc FxFxEventHandler.h FxFxEventHandler.fh\
 FxFxReader.cc FxFxReader.fh FxFxReader.h\
 FxFx.h
 HwFxFx_la_CPPFLAGS = $(AM_CPPFLAGS) $(FASTJETINCLUDE) -I$(FASTJETPATH)
 HwFxFx_la_LIBADD = $(FASTJETLIBS) 
-HwFxFx_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 1:0:0
+HwFxFx_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 2:0:0
 
 HwFxFxHandler_la_SOURCES = \
 FxFxHandler.cc FxFxHandler.h
 HwFxFxHandler_la_CPPFLAGS = $(AM_CPPFLAGS) $(FASTJETINCLUDE) -I$(FASTJETPATH)
 HwFxFxHandler_la_LIBADD = $(FASTJETLIBS) 
-HwFxFxHandler_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 1:0:0
+HwFxFxHandler_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 2:0:0
diff --git a/MatrixElement/Matchbox/External/Makefile.am b/MatrixElement/Matchbox/External/Makefile.am
--- a/MatrixElement/Matchbox/External/Makefile.am
+++ b/MatrixElement/Matchbox/External/Makefile.am
@@ -1,95 +1,96 @@
 SUBDIRS = BLHAGeneric VBFNLO NJet GoSam OpenLoops MadGraph
 
 
 pkglib_LTLIBRARIES =
 
 ##############
 
 if HAVE_GOSAM
 pkglib_LTLIBRARIES += HwMatchboxGoSam.la
 endif
 
 HwMatchboxGoSam_la_LDFLAGS = \
 $(AM_LDFLAGS) -module -version-info 15:0:0
 
 HwMatchboxGoSam_la_CPPFLAGS = $(AM_CPPFLAGS) \
 -DHERWIG_BINDIR="\"$(bindir)\"" \
 -DHERWIG_PKGDATADIR="\"$(pkgdatadir)\"" \
 -DGOSAM_PREFIX="\"$(GOSAMPREFIX)\""
 
 HwMatchboxGoSam_la_SOURCES = \
 GoSam/GoSamAmplitude.cc
 
 
 ###############
 
 if HAVE_VBFNLO
 pkglib_LTLIBRARIES += HwMatchboxVBFNLO.la
 endif
 
-HwMatchboxVBFNLO_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 4:0:0
+HwMatchboxVBFNLO_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 5:0:0
 HwMatchboxVBFNLO_la_CPPFLAGS = $(AM_CPPFLAGS)
 HwMatchboxVBFNLO_la_CPPFLAGS += -I$(VBFNLOINCLUDE)
 HwMatchboxVBFNLO_la_CPPFLAGS += -DVBFNLOLIB=$(VBFNLOLIB)
 
 HwMatchboxVBFNLO_la_SOURCES = \
 VBFNLO/VBFNLOAmplitude.cc \
 VBFNLO/VBFNLOPhasespace.cc
 
 
 ###############
 
 if HAVE_OPENLOOPS
 pkglib_LTLIBRARIES += HwMatchboxOpenLoops.la
 endif
 
 HwMatchboxOpenLoops_la_SOURCES = \
 OpenLoops/OpenLoopsAmplitude.cc
 
-HwMatchboxOpenLoops_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 14:0:0
+HwMatchboxOpenLoops_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 15:0:0
 
 HwMatchboxOpenLoops_la_CPPFLAGS = $(AM_CPPFLAGS) \
 -DOPENLOOPSLIBS="\"$(OPENLOOPSLIBS)\"" \
 -DOPENLOOPSPREFIX="\"$(OPENLOOPSPREFIX)\""
 
 ##############
 
 
 if HAVE_NJET
 pkglib_LTLIBRARIES += HwMatchboxNJet.la
 endif
 
-HwMatchboxNJet_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 14:0:0
+HwMatchboxNJet_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 15:0:0
 
 HwMatchboxNJet_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(NJETINCLUDEPATH) \
 -DNJET_PREFIX="\"$(NJETPREFIX)\"" \
--DNJET_LIBS="\"$(NJETLIBPATH)\""
+-DNJET_LIBS="\"$(NJETLIBPATH)\"" \
+-DNJET_VERSION="$(NJET_VERSION)"
 
 HwMatchboxNJet_la_SOURCES = \
 NJet/NJetsAmplitude.cc
 
 
 
 ##############
 
 if HAVE_MADGRAPH
 pkglib_LTLIBRARIES += HwMatchboxMadGraph.la
 endif
 
-HwMatchboxMadGraph_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 5:0:0
+HwMatchboxMadGraph_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 6:0:0
 
 HwMatchboxMadGraph_la_SOURCES = \
 MadGraph/MadGraphAmplitude.cc
 
 HwMatchboxMadGraph_la_CPPFLAGS = $(AM_CPPFLAGS) \
 -DHERWIG_BINDIR="\"$(bindir)\"" \
 -DHERWIG_INCLUDEDIR="\"$(includedir)\"" \
 -DHERWIG_PKGDATADIR="\"$(pkgdatadir)\"" \
 -DMADGRAPH_PREFIX="\"$(MADGRAPHPREFIX)\""
 
 
 
 
 
 
 
diff --git a/MatrixElement/Matchbox/External/NJet/NJetsAmplitude.cc b/MatrixElement/Matchbox/External/NJet/NJetsAmplitude.cc
--- a/MatrixElement/Matchbox/External/NJet/NJetsAmplitude.cc
+++ b/MatrixElement/Matchbox/External/NJet/NJetsAmplitude.cc
@@ -1,307 +1,310 @@
 // -*- C++ -*-
 //
 // NJetsAmplitude.cc is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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.
 //
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the NJetsAmplitude class.
 //
 
 #include "NJetsAmplitude.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/Interface/Parameter.h"
 #include "ThePEG/EventRecord/Particle.h"
 #include "ThePEG/Repository/UseRandom.h"
 #include "ThePEG/Repository/EventGenerator.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 
 #include "ThePEG/Utilities/DynamicLoader.h"
 
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 
 #include "Herwig/MatrixElement/Matchbox/MatchboxFactory.h"
 
 #include "njet.h"
 
 #include <cstdlib>
 
 #ifndef NJET_PREFIX
 #error Makefile.am needs to define NJET_PREFIX
 #endif
 #ifndef NJET_LIBS
 #error Makefile.am needs to define NJET_LIBS
 #endif
 
 using namespace Herwig;
 
 NJetsAmplitude::NJetsAmplitude() : NJetsPrefix_(NJET_PREFIX),
 				   NJetsLibs_(NJET_LIBS) {}
 
 NJetsAmplitude::~NJetsAmplitude() {}
 
 IBPtr NJetsAmplitude::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr NJetsAmplitude::fullclone() const {
   return new_ptr(*this);
 }
 
 void NJetsAmplitude::signOLP(const string& order, const string& contract) {
   string cmd = NJetsPrefix_+"/bin/njet.py -o " + contract + " " + order;
   std::system(cmd.c_str());
 }
 
 void NJetsAmplitude::startOLP(const string& contract, int& status) {
   NJet::LH_OLP::OLP_Start(contract.c_str(), &status);
 
   if ( status != 1 )
     return;
 
   status = 0;
 
   static double zero = 0.0;
   double param = 0.0;
 
   param = SM().alphaEMMZ();
   NJet::LH_OLP::OLP_SetParameter("alpha",&param,&zero,&status);
   if ( status != 1 )
     return;
 
   param = getParticleData(ParticleID::Z0)->hardProcessMass()/GeV;
   NJet::LH_OLP::OLP_SetParameter("mass(23)",&param,&zero,&status);
   if ( status != 1 )
     return;
 
   param = getParticleData(ParticleID::Wplus)->hardProcessMass()/GeV;
   NJet::LH_OLP::OLP_SetParameter("mass(24)",&param,&zero,&status);
   if ( status != 1 )
     return;
 
   param = getParticleData(ParticleID::Z0)->hardProcessWidth()/GeV;
   NJet::LH_OLP::OLP_SetParameter("width(23)",&param,&zero,&status);
   if ( status != 1 )
     return;
 
   param = getParticleData(ParticleID::Wplus)->hardProcessWidth()/GeV;
   NJet::LH_OLP::OLP_SetParameter("width(24)",&param,&zero,&status);
   if ( status != 1 )
     return;
 
   param = SM().sin2ThetaW();
   NJet::LH_OLP::OLP_SetParameter("sw2",&param,&zero,&status);
 
   didStartOLP() = true;
 
 }
 
 void NJetsAmplitude::loadNJET() {
   if ( ! (DynamicLoader::load(NJetsLibs_+"/libnjet2.so") ||
 	  DynamicLoader::load("libnjet2.so") ||
 	  DynamicLoader::load(NJetsLibs_+"/libnjet2.dylib") ||
 	  DynamicLoader::load("libnjet2.dylib") ) )
     throw Exception() << "NJetsAmplitude: Failed to load libnjet2.so\n"
 		      << DynamicLoader::lastErrorMessage
 		      << Exception::runerror;
 }
 
 bool NJetsAmplitude::startOLP(const map<pair<Process,int>,int>& procs) {
   loadNJET();
 
   // TODO throw exception on massive leptons in procs
 
   string orderFileName = factory()->buildStorage() + name() + ".OLPOrder.lh";
   ofstream orderFile(orderFileName.c_str());
 
   olpOrderFileHeader(orderFile);
 
   orderFile << "NJetReturnAccuracy        yes\n"
 	    << "NJetRenormalize           yes\n"
-	    << "NJetNf                    " << factory()->nLight() << "\n";
-
+#if NJET_VERSION > 1023
+	    << "SetParameter qcd(nf) " << factory()->nLight() << "\n"; // NJet >= 2.1.0: 
+#else
+            << "NJetNf                    " << factory()->nLight() << "\n"; // NJet <=2.0.0
+#endif
   olpOrderFileProcesses(orderFile,procs);
 
   orderFile << flush;
 
   orderFile.close();
 
   string contractFileName = factory()->buildStorage() + name() + ".OLPContract.lh";
 
   signOLP(orderFileName, contractFileName);
 
   int status = -1;
 
   startOLP(contractFileName,status);
 
   if ( status != 1 )
     return false;
 
   return true;
 
 }
 
 LorentzVector<Complex> NJetsAmplitude::plusPolarization(const Lorentz5Momentum& p,
 							const Lorentz5Momentum& n,
 							int inc) const {
 
   double pvec[4] = {p.t()/GeV,p.x()/GeV,p.y()/GeV,p.z()/GeV};
   double nvec[4] = {n.t()/GeV,n.x()/GeV,n.y()/GeV,n.z()/GeV};
   double out[8] ={ };
   NJet::LH_OLP::OLP_Polvec(pvec,nvec,out);
 
   LorentzVector<Complex> res;
   Complex a(out[0],out[1]);
   res.setT(a);
   Complex b(out[2],out[3]);
   res.setX(b);
   Complex c(out[4],out[5]);
   res.setY(c);
   Complex d(out[6],out[7]);
   res.setZ(d);
 	
   if (inc<2)
     return res.conjugate();
   else 
     return res;
 
 }
 
 void NJetsAmplitude::evalSubProcess() const {
 
   useMe();
 
   double units = pow(lastSHat()/GeV2,mePartonData().size()-4.);
   fillOLPMomenta(lastXComb().meMomenta(),mePartonData(),reshuffleMasses());
   double as;
   if (!hasRunningAlphaS()) as = SM().alphaS();
   else if (hasRunningAlphaS()) as = lastAlphaS();
   double scale = sqrt(mu2()/GeV2);
 
   double out[7]={};
 
   int id = 
     olpId()[ProcessType::oneLoopInterference] ?
     olpId()[ProcessType::oneLoopInterference] :
     olpId()[ProcessType::treeME2];
 
   NJet::LH_OLP::OLP_EvalSubProcess(id, olpMomenta(), scale, &as, out);
 
   if ( olpId()[ProcessType::oneLoopInterference] ) {
     if(calculateTreeME2())lastTreeME2(out[3]*units);
     lastOneLoopInterference(out[2]*units);
     lastOneLoopPoles(pair<double,double>(out[0]*units,out[1]*units));
   } else if ( olpId()[ProcessType::treeME2] ) {
     lastTreeME2(out[0]*units);
   } else assert(false);
 
 }
 
 void NJetsAmplitude::evalColourCorrelator(pair<int,int>) const {
 
   double units = pow(lastSHat()/GeV2,mePartonData().size()-4.);
   fillOLPMomenta(lastXComb().meMomenta(),mePartonData(),reshuffleMasses());
   double as;
   if (!hasRunningAlphaS()) as = SM().alphaS();
   else if (hasRunningAlphaS()) as = lastAlphaS();
   double scale = sqrt(mu2()/GeV2);
 
   int n = lastXComb().meMomenta().size();
   colourCorrelatorResults.resize(n*(n-1)/2);
 
   NJet::LH_OLP::OLP_EvalSubProcess(olpId()[ProcessType::colourCorrelatedME2], 
 				   olpMomenta(), scale, &as, &colourCorrelatorResults[0]);
 
   for ( int i = 0; i < n; ++i )
     for ( int j = i+1; j < n; ++j ) {
       lastColourCorrelator(make_pair(i,j),colourCorrelatorResults[i+j*(j-1)/2]*units);
     }
 
 }
 
 void NJetsAmplitude::evalSpinColourCorrelator(pair<int,int>) const {
 
   double units = pow(lastSHat()/GeV2,mePartonData().size()-4.);
   fillOLPMomenta(lastXComb().meMomenta(),mePartonData(),reshuffleMasses());
   double as;
   if (!hasRunningAlphaS()) as = SM().alphaS();
   else if (hasRunningAlphaS()) as = lastAlphaS();
   double scale = sqrt(mu2()/GeV2);
 
   int n = lastXComb().meMomenta().size();
   spinColourCorrelatorResults.resize(2*n*n);
 
   NJet::LH_OLP::OLP_EvalSubProcess(olpId()[ProcessType::spinColourCorrelatedME2], 
 				   olpMomenta(), scale, &as, &spinColourCorrelatorResults[0]);
 
   for ( int i = 0; i < n; ++i )
     for ( int j = 0; j < n; ++j ) {
       if ( i == j || mePartonData()[i]->id() != 21 )
 	continue;
       Complex scc(spinColourCorrelatorResults[2*i+2*n*j]*units,
 		  spinColourCorrelatorResults[2*i+2*n*j+1]*units);
       lastColourSpinCorrelator(make_pair(i,j),scc);
     }
 
 }
 
 void NJetsAmplitude::doinit() {
   loadNJET();
   MatchboxOLPME::doinit();
 }
 
 void NJetsAmplitude::doinitrun() {
   loadNJET();
   MatchboxOLPME::doinitrun();
 }
 
 // If needed, insert default implementations of virtual function defined
 // in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
 
 
 void NJetsAmplitude::persistentOutput(PersistentOStream & os) const {
   os << colourCorrelatorResults << spinColourCorrelatorResults
      << NJetsPrefix_ << NJetsLibs_;
 }
 
 void NJetsAmplitude::persistentInput(PersistentIStream & is, int) {
   is >> colourCorrelatorResults >> spinColourCorrelatorResults
      >> NJetsPrefix_ >> NJetsLibs_;
 }
 
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeClass<NJetsAmplitude,MatchboxOLPME>
 describeHerwigNJetsAmplitude("Herwig::NJetsAmplitude", "HwMatchboxNJet.so");
 
 void NJetsAmplitude::Init() {
 
   static ClassDocumentation<NJetsAmplitude> documentation
     ("NJetsAmplitude implements an interface to NJets.",
      "Matrix elements have been calculated using NJet \\cite{Badger:2012pg}",
      "%\\cite{Badger:2012pg}\n"
      "\\bibitem{Badger:2012pg}\n"
      "S.~Badger et al.,\n"
      "``Numerical evaluation of virtual corrections to multi-jet production in massless QCD,''\n"
      "arXiv:1209.0100 [hep-ph].\n"
      "%%CITATION = ARXIV:1209.0100;%%");
     
   static Parameter<NJetsAmplitude,string> interfaceNJetsPrefix
     ("NJetsPrefix",
      "The prefix for the location of NJets",
      &NJetsAmplitude::NJetsPrefix_, string(NJET_PREFIX),
      false, false);
     
   static Parameter<NJetsAmplitude,string> interfaceNJetsLibs
     ("NJetsLibs",
      "The location of the NJets library",
      &NJetsAmplitude::NJetsLibs_, string(NJET_LIBS),
      false, false);
 
 }
 
diff --git a/Models/Feynrules/python/slha2herwig b/Models/Feynrules/python/slha2herwig
--- a/Models/Feynrules/python/slha2herwig
+++ b/Models/Feynrules/python/slha2herwig
@@ -1,111 +1,112 @@
 #! /usr/bin/env python
 from __future__ import division
+from __future__ import print_function
 import os, sys, argparse, re, string
 
 comment_pat = re.compile('\s*#.*$')
 block_pat = re.compile('^\s*block\s+(\w+)',flags=re.I)
 decay_pat = re.compile('^\s*decay\s+(\w+)\s+([-+\.\w]+)',flags=re.I)
 
 data_pat = re.compile('^\s*((\d+\s+)+)(-?\d\S*)\s*$')
 whitespace = re.compile('\s+')
 
 
 PARAMS = {}
 
 # set up the option parser for command line input 
 parser = argparse.ArgumentParser(
 	description='Modify a ThePEG model file with parameters from a matching SLHA file.'
 )
 parser.add_argument(
 	'modelfile', 
 	metavar='ThePEG_model', 
 	help='ThePEG model file to use as template. Must have "# SLHA #"" annotations.'
 )
 parser.add_argument(
 	'slhafile', 
 	metavar='SLHA_file', 
 	help='SLHA spectrum file.'
 )
 parser.add_argument(
     '-o','--output',
     default="FRModel_slha.model",
     help="Name for the output file"
 )
 
 args = parser.parse_args()
 
 with open(args.slhafile) as f:
 	currentblock = None
 	for line in f:
 		line = comment_pat.sub('',line.rstrip())
 		if not line: continue
 		m = block_pat.match(line)
 		d = decay_pat.match(line)
 		if m:
 			currentblock = m.group(1).upper()
 		elif d:
 			currentblock = None
 			label = 'DECAY_%s' % d.group(1)
 			data = float(d.group(2))
 			PARAMS[label] = data
 		elif currentblock is not None:
 			d = data_pat.match(line)
 			if d:
 				index = whitespace.sub('_',d.group(1).rstrip())
 				try:
 					data  = float(d.group(3))
 				except ValueError:
 					continue
 				label = '%s_%s' % (currentblock, index)
 				#if label in PARAMS:
 				PARAMS[label] = data
 
 
 template = open(args.modelfile)
 output   = open(args.output,'w')
 
 line = template.readline()
 while line:
 	split = line.split("${")
 	if (len(split) == 1 ) :
 		output.write(line)
 	else :
 		outputLine = split[0]
 		for i in range(1,len(split)) :
 			split2 = split[i].split("}")
 			key = split2[0]
 			if key in PARAMS :
 				outputLine += str(PARAMS[key]) + split2[1]
 			else :
 				name, suffix = key.rsplit('_',1)
 				if suffix == 'ABS':
 					mass = PARAMS[name]
 					try:
 						mass = mass.real
 					except:
 						pass
 					outputLine += str(abs(mass)) + split2[1]
 				elif suffix == 'CTAU':
 					hbarc = 197.3269631e-15
 					if(name in PARAMS) :
 						width = PARAMS[name]
 						ctau = (hbarc / width) if width != 0 else 0
 					else :
 						ctau = 0
 					outputLine += str(ctau) + split2[1]
 				elif suffix == 'WCUT':
 					if(name in PARAMS) :
 						width = PARAMS[name]
 					else :
 						width = 0.
 					wcut = 10.0 * width
 					outputLine += str(wcut) + split2[1]
 				elif name == 'DECAY':
 					outputLine += str(0.) + split2[1]
 				else :
-					print 'Parameter ',key,'not set in SLHA file, keeping default'
+					print ('Parameter ',key,'not set in SLHA file, keeping default')
 					outputLine = '#' + outputLine + "${" + split2[0] + "}" + split2[1]
 		output.write(outputLine)
 	line = template.readline()
 output.write("\n")
-print "Output written as : ",args.output
+print ("Output written as : ",args.output)
diff --git a/Models/Feynrules/python/ufo2peg/check_lorentz.py b/Models/Feynrules/python/ufo2peg/check_lorentz.py
--- a/Models/Feynrules/python/ufo2peg/check_lorentz.py
+++ b/Models/Feynrules/python/ufo2peg/check_lorentz.py
@@ -1,871 +1,875 @@
 from __future__ import print_function
 import itertools,cmath,re
 from .helpers import SkipThisVertex,extractAntiSymmetricIndices
 from .converter import py2cpp
 from .lorentzparser import parse_lorentz
 import string,re
 
 def compare(a,b) :
     num=abs(a-b)
     den=abs(a+b)
     if(den == 0. and 1e-10) :
         return True
     return num/den<1e-10
 
 def evaluate(x,model,parmsubs):
     import cmath
     return eval(x, 
                 {'cmath':cmath,
                  'complexconjugate':model.function_library.complexconjugate}, 
                 parmsubs)
 
 # ordering for EW VVV vertices (ordering not an issue as all same spin)
 def VVVordering(vertex) :
     pattern = "if((p1->id()==%s&&p2->id()==%s&&p3->id()==%s)"+\
         "||(p1->id()==%s&&p2->id()==%s&&p3->id()==%s)||"+\
         "(p1->id()==%s&&p2->id()==%s&&p3->id()==%s)) {norm(-norm());}"
     ordering = pattern%(vertex.particles[1].pdg_code,
                         vertex.particles[0].pdg_code,
                         vertex.particles[2].pdg_code,
                         vertex.particles[0].pdg_code,
                         vertex.particles[2].pdg_code,
                         vertex.particles[1].pdg_code,
                         vertex.particles[2].pdg_code,
                         vertex.particles[1].pdg_code,
                         vertex.particles[0].pdg_code)
     return ordering
 
 def tensorCouplings(vertex,value,prefactors,L,lorentztag,pos,all_couplings,order) :
     # split the structure into its different terms for analysis
     ordering=""
     structures = extractStructures(L)
     if(lorentztag == 'SST') :
         terms=[['P(1003,2)','P(2003,1)'],
                ['P(1003,1)','P(2003,2)'],
                ['P(-1,1)','P(-1,2)','Metric(1003,2003)'],
                ['Metric(1003,2003)']]
         signs=[1.,1.,-1.,-1.]
         new_couplings=[False]*len(terms)
     elif(lorentztag == 'FFT' ) :
         terms=[['P(2003,1)','Gamma(1003,2,1)'],
                ['P(2003,2)','Gamma(1003,2,1)'],
                ['P(1003,1)','Gamma(2003,2,1)'],
                ['P(1003,2)','Gamma(2003,2,1)'],
                ['P(-1,1)','Gamma(-1,2,1)','Metric(1003,2003)'],
                ['P(-1,2)','Gamma(-1,2,1)','Metric(1003,2003)'],
                ['Metric(1003,2003)']]
         signs=[1.,-1.,1.,-1.,-0.5,0.5,1.]
         new_couplings=[False]*3*len(terms)
     elif(lorentztag == 'VVT' ) :
         terms=[['P(-1,1)','P(-1,2)','Metric(1,2003)','Metric(2,1003)'], # from C term
                ['P(-1,1)','P(-1,2)','Metric(1,1003)','Metric(2,2003)'], # from C term
                ['P(-1,1)','P(-1,2)','Metric(1,2)','Metric(1003,2003)'], # from C term
                ['P(1,2)','P(2,1)','Metric(1003,2003)'], # from D term (sym)
                ['P(1,2)','P(2003,1)','Metric(2,1003)'], # 1st term
                ['P(1,2)','P(1003,1)','Metric(2,2003)'], # 1st swap
                ['P(2,1)','P(2003,2)','Metric(1,1003)'], # 2nd term
                ['P(2,1)','P(1003,2)','Metric(1,2003)'], # 2nd swap
                ['P(1003,2)','P(2003,1)','Metric(1,2)'], # 3rd term 
                ['P(1003,1)','P(2003,2)','Metric(1,2)'], # 3rd swap
                ['Metric(1,2003)','Metric(2,1003)'], # from mass term
                ['Metric(1,1003)','Metric(2,2003)'], # from mass term
                ['Metric(1,2)','Metric(1003,2003)'], # from mass term
                ['P(1,1)','P(2,1)','Metric(1003,2003)'], # gauge terms
                ['P(1,2)','P(2,2)','Metric(1003,2003)'], # gauge terms
                ['P(1,1)','P(2,2)','Metric(1003,2003)'], # gauge terms
                ['P(1003,1)','P(1,1)','Metric(2,2003)'], # gauge terms
                ['P(1003,2)','P(2,2)','Metric(1,2003)'], # gauge terms
                ['P(2003,1)','P(1,1)','Metric(2,1003)'], # gauge terms
                ['P(2003,2)','P(2,2)','Metric(1,1003)'], # gauge terms
         ]
         signs=[1.,1.,-1.,1.,-1.,-1.,-1.,-1.,1.,1.,1.,1.,-1.,1.,1.,0.25,-1.,-1.,-1.,-1.]
         new_couplings=[False]*len(terms)
     elif(lorentztag == 'FFVT' ) :
         terms = [['Gamma(2004,2,1)','Metric(3,1004)'],
                  ['Gamma(1004,2,1)','Metric(3,2004)'],
                  ['Gamma(3,2,1)','Metric(1004,2004)'],
                  ['Gamma(2004,2,-1)','Metric(3,1004)'],
                  ['Gamma(1004,2,-1)','Metric(3,2004)'],
                  ['Gamma(3,2,-1)','Metric(1004,2004)']]
         signs=[1.,1.,-0.5,1.,1.,-0.5]
         new_couplings=[False]*3*len(terms)
     elif(lorentztag == 'VVVT' ) :
         # the F(mu nu,rho sigma lambda) terms first
         terms = [['P(2004,2)','Metric(1,1004)','Metric(2,3)'],['P(2004,3)','Metric(1,1004)','Metric(2,3)'],
                  ['P(1004,2)','Metric(1,2004)','Metric(2,3)'],['P(1004,3)','Metric(1,2004)','Metric(2,3)'],
                  ['P(2004,3)','Metric(1,3)','Metric(2,1004)'],['P(2004,1)','Metric(1,3)','Metric(2,1004)'],
                  ['P(1004,3)','Metric(1,3)','Metric(2,2004)'],['P(1004,1)','Metric(1,3)','Metric(2,2004)'],
                  ['P(2004,1)','Metric(1,2)','Metric(3,1004)'],['P(2004,2)','Metric(1,2)','Metric(3,1004)'],
                  ['P(1004,1)','Metric(1,2)','Metric(3,2004)'],['P(1004,2)','Metric(1,2)','Metric(3,2004)'],
                  ['P(3,1)','Metric(1,2004)','Metric(2,1004)'],['P(3,2)','Metric(1,2004)','Metric(2,1004)'], 
                  ['P(3,1)','Metric(1,1004)','Metric(2,2004)'],['P(3,2)','Metric(1,1004)','Metric(2,2004)'],
                  ['P(3,1)','Metric(1,2)','Metric(1004,2004)'],['P(3,2)','Metric(1,2)','Metric(1004,2004)'],
                  ['P(2,3)','Metric(1,2004)','Metric(3,1004)'],['P(2,1)','Metric(1,2004)','Metric(3,1004)'],
                  ['P(2,3)','Metric(1,1004)','Metric(3,2004)'],['P(2,1)','Metric(1,1004)','Metric(3,2004)'],
                  ['P(2,3)','Metric(1,3)','Metric(1004,2004)'],['P(2,1)','Metric(1,3)','Metric(1004,2004)'],
                  ['P(1,2)','Metric(2,2004)','Metric(3,1004)'],['P(1,3)','Metric(2,2004)','Metric(3,1004)'],
                  ['P(1,2)','Metric(2,1004)','Metric(3,2004)'],['P(1,3)','Metric(2,1004)','Metric(3,2004)'],
                  ['P(1,2)','Metric(2,3)','Metric(1004,2004)'],['P(1,3)','Metric(2,3)','Metric(1004,2004)']]
         signs = [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.,-1.,1.]
         new_couplings=[False]*len(terms)
         l = lambda c: len(pos[c])
         if l(8)!=3 :
             ordering = VVVordering(vertex)
     # unknown
     else :
         raise Exception('Unknown data type "%s".' % lorentztag)
     iterm=0
     try :
         for term in terms:
             for perm in itertools.permutations(term):
                 label = '*'.join(perm)
                 for istruct in range(0,len(structures)) :
                     if label in structures[istruct] :
                         reminder = structures[istruct].replace(label,'1.',1)
                         loc=iterm
                         if(reminder.find("ProjM")>=0) :
                             reminder=re.sub("\*ProjM\(.*,.\)","",reminder)
                             loc+=len(terms)
                         elif(reminder.find("ProjP")>=0) :
                             reminder=re.sub("\*ProjP\(.*,.\)","",reminder)
                             loc+=2*len(terms)
                         structures[istruct] = "Done"
                         val = eval(reminder, {'cmath':cmath} )*signs[iterm]
                         if(new_couplings[loc]) :
                             new_couplings[loc] += val
                         else :
                             new_couplings[loc] = val
             iterm+=1
     except :
         SkipThisVertex()
     # check we've handled all the terms
     for val in structures:
         if(val!="Done") :
             raise SkipThisVertex()
     # special for FFVT
     if(lorentztag=="FFVT") :
         t_couplings=new_couplings
         new_couplings=[False]*9
         for i in range(0,9) :
             j = i+3*(i//3)
             k = i+3+3*(i//3)
             if( not t_couplings[j]) :
                 new_couplings[i] = t_couplings[k]
             else :
                 new_couplings[i] = t_couplings[j]
     # set the couplings
     for icoup in range(0,len(new_couplings)) :
         if(new_couplings[icoup]) :
             new_couplings[icoup] = '(%s) * (%s) *(%s)' % (new_couplings[icoup],prefactors,value)
     if(len(all_couplings)==0) :
         all_couplings=new_couplings
     else :
         for icoup in range(0,len(new_couplings)) :
             if(new_couplings[icoup] and all_couplings[icoup]) :
                 all_couplings[icoup] = '(%s) + (%s) ' % (new_couplings[icoup],all_couplings[icoup])
             elif(new_couplings[icoup]) :
                 all_couplings[icoup] = new_couplings[icoup]
     # return the results
     return (ordering,all_couplings)
 
 def processTensorCouplings(lorentztag,vertex,model,parmsubs,all_couplings,order) :
     # check for fermion vertices (i.e. has L/R couplings)
     fermions = "FF" in lorentztag
     # test and process the values of the couplings
     tval  = ["Unknown"]*3
     value = ["Unknown"]*3
     # loop over the colours
     for icolor in range(0,len(all_couplings)) :
         lmax = len(all_couplings[icolor])
         if(fermions) : lmax //=3
         # loop over the different terms
         for ix in range(0,lmax) :
             test = [False]*3
             imax=3
             # normal case
             if( not fermions ) :
                 test[0] = all_couplings[icolor][ix]
                 imax=1
             else :
                 # first case vector but no L/R couplings
                 if( not all_couplings[icolor][lmax+ix]  and
                     not all_couplings[icolor][2*lmax+ix] ) :
                     test[0] = all_couplings[icolor][ix]
                     imax=1
                     # special for mass terms and massless particles
                     if(not all_couplings[icolor][ix]) :
                         code = abs(vertex.particles[order[0]-1].pdg_code)
                         if(ix==6 and (code ==12 or code ==14 or code==16) ) :
                             continue
                         else :
                             raise SkipThisVertex()
                 # second case L/R couplings
                 elif( not all_couplings[icolor][ix] ) :
                     # L=R, replace with vector
                     if(all_couplings[icolor][lmax+ix] ==
                        all_couplings[icolor][2*lmax+ix]) :
                         test[0]  = all_couplings[icolor][lmax+ix]
                         imax=1
                     else :
                         test[1] = all_couplings[icolor][lmax+ix]
                         test[2] = all_couplings[icolor][2*lmax+ix]
                 else :
                     raise SkipThisVertex()
             # special handling of mass terms
             # scalar divide by m**2
             if((ix==3 and lorentztag=="SST") or
                ( ix>=10 and ix<=12 and lorentztag=="VVT" )) :
                 for i in range(0,len(test)) :
                     if(test[i]) :
                         test[i] = '(%s)/%s**2' % (test[i],vertex.particles[order[0]-1].mass.value)
             # fermions divide by 4*m
             elif(ix==6 and lorentztag=="FFT" and
                  float(vertex.particles[order[0]-1].mass.value) != 0. ) :
                 for i in range(0,len(test)) :
                     if(test[i]) :
                         test[i] = '-(%s)/%s/4' % (test[i],vertex.particles[order[0]-1].mass.value)
             # set values on first pass
             if((tval[0]=="Unknown" and fermions ) or
                (not fermions and tval[0]=="Unknown" and tval[1]=="Unknown" and tval[2]=="Unknown")) :
                 value = test
                 for i in range(0,len(test)) :
                     if(test[i]) : tval[i] = evaluate(test[i],model,parmsubs)
             else :
                 for i in range(0,imax) :
                     if(not test[i] and not tval[i]) :
                         continue
                     # special for vector gauge terms
                     if(lorentztag=="VVT" and ix>=13) :
                         continue
                     if(not test[i] or tval[i]=="Unknown") :
                         # special for mass terms and vectors
                         if(lorentztag=="VVT" and ix >=10 and ix <=12 and
                            float(vertex.particles[order[0]-1].mass.value) == 0. ) :
                             continue
                         raise SkipThisVertex()
                     tval2 = evaluate(test[i],model,parmsubs)
                     if(abs(tval[i]-tval2)>1e-6) :
                         # special for fermion mass term if fermions massless
                         if(lorentztag=="FFT" and ix ==6 and tval2 == 0. and
                            float(vertex.particles[order[0]-1].mass.value) == 0. ) :
                             continue
                         raise SkipThisVertex()
     # simple clean up
     for i in range(0,len(value)):
         if(value[i]) :
             value[i] = value[i].replace("(1.0) * ","").replace(" * (1)","")
     # put everything together
     coup_left  = 0.
     coup_right = 0.
     coup_norm  = 0.
     if(lorentztag ==  "SST" or lorentztag == "VVT" or
        lorentztag == "VVVT" or lorentztag == "FFT" ) :
         coup_norm = value[0]
         if(value[1] or value[2]) :
             raise SkipThisVertex()
     elif(lorentztag=="FFVT") :
         if(not value[1] and not value[2]) :
             coup_norm  = value[0]
             coup_left  = "1."
             coup_right = "1."
         elif(not value[0]) :
             coup_norm = "1."
             if(value[1] and value[2]) :
                 coup_left  = value[1]
                 coup_right = value[2]
             elif(value[1]) :
                 coup_left  = value[1]
                 coup_right = "0."
             elif(value[2]) :
                 coup_left  = "0."
                 coup_right = value[2]
             else :
                 raise SkipThisVertex()
         else :
             raise SkipThisVertex()
     else :
         raise SkipThisVertex()
     # return the answer
     return (coup_left,coup_right,coup_norm)
 
 def extractStructures(L) :
     structure1 = L.structure.replace(")-P",") - P").replace(")+P",") + P")
     structure1 = structure1.split()
     structures =[]
     sign=''
     for struct in structure1 :
         if(struct=='+') :
             continue
         elif(struct=='-') :
             sign='-'
         else :
             structures.append(sign+struct.strip())
             sign=''
     return structures
 
 
 
 def changeSign(sign1,sign2) :
     if((sign1=="+" and sign2=="+") or\
        (sign1=="-" and sign2=="-")) :
         return "+"
     else :
         return "-"
     
 def epsilonOrder(eps) :
     terms,sign = extractAntiSymmetricIndices(eps,"Epsilon(")
     return (sign,"Epsilon(%s,%s,%s,%s)" % (terms[0],terms[1],terms[2],terms[3]))
 
     
 def VVSEpsilon(couplings,struct) :
     if(struct.find("Epsilon")<0) :
         return
     fact=""
     sign="+"
     if(struct[-1]==")") :
         fact=struct.split("(")[0]
         if(fact.find("Epsilon")>=0) :
             fact=""
         else :
             struct=struct.split("(",1)[1][:-1]
             if(fact[0]=="-") :
                 sign="-"
                 fact=fact[1:]
     split = struct.split("*")
     # find the epsilon
     eps=""
     for piece in split :
         if(piece.find("Epsilon")>=0) :
             eps=piece
             split.remove(piece)
             break
     # and any prefactors
     for piece in split :
         if(piece.find("P(")<0) :
             split.remove(piece)
             if(piece[0]=="+" or piece[0]=="-") :
                 sign=changeSign(sign,piece[0])
                 piece=piece[1:]
             if(fact=="") :
                 fact=piece
             else :
                 fact = "( %s ) * ( %s )" % (fact , piece) 
     # now sort out the momenta
     for piece in split :
         terms=piece.split(",")
         terms[0]=terms[0].strip("P(")
         terms[1]=terms[1].strip(")")
         eps=eps.replace(terms[0],"P%s"%terms[1])
     (nsign,eps)=epsilonOrder(eps)
     if(nsign>0) : sign=changeSign(sign,"-")
     if(fact=="") : fact="1."
     if(eps!="Epsilon(1,2,P1,P2)") :
         return
     if(couplings[6]==0.) :
         couplings[6] = "( %s%s )" % (sign,fact)
     else :
         couplings[6] = "( %s ) + ( %s%s )" % (couplings[6],sign,fact)
 
 
 def scalarVectorCouplings(value,prefactors,L,lorentztag,all_couplings,order) :
     # set up the types of term we are looking for
     if(lorentztag=="VVS") :
         couplings=[0.,0.,0.,0.,0.,0.,0.]
         terms=[['P(-1,%s)' % order[0],
                 'P(-1,%s)' % order[1],
                 'Metric(%s,%s)' %(order[0],order[1])],
                ['P(1,%s)' % order[0],
                 'P(2,%s)' % order[0]],
                ['P(1,%s)' % order[0],
                 'P(2,%s)' % order[1]],
                ['P(1,%s)' % order[1],
                 'P(2,%s)' % order[0]],
                ['P(1,%s)' % order[1],
                 'P(2,%s)' % order[1]],
                ['Metric(%s,%s)'%(order[0],order[1])]]
     elif(lorentztag=="VVSS") :
         couplings=[0.]
         terms=[['Metric(%s,%s)' % (order[0],order[1])]]
     elif(lorentztag=="VSS"):
          couplings=[0.,0.]
          terms=[['P(%s,%s)' % (order[0],order[2])],
                 ['P(%s,%s)' % (order[0],order[1])]]
     # extract the lorentz structures
     structures = extractStructures(L)
     # handle the scalar couplings
     itype=-1
     try :
         for term in terms:
             itype+=1
             for perm in itertools.permutations(term):
                 label = '*'.join(perm)
                 for istruct in range(0,len(structures)) :
                     if label in structures[istruct] :
                         reminder = structures[istruct].replace(label,'1.',1)
                         couplings[itype]+=eval(reminder, {'cmath':cmath} )
                         structures[istruct]='Done'
     except :
         raise SkipThisVertex()
     # special for VVS and epsilon
     # handle the pseudoscalar couplings
     for struct in structures :
         if(struct != "Done" ) :
             if(lorentztag=="VVS") :
                 VVSEpsilon(couplings,struct)
             else :
                 raise SkipThisVertex()
     # put it all together
     if(len(all_couplings)==0) :
         for ic in range(0,len(couplings)) :
             if(couplings[ic]!=0.) :
                 all_couplings.append('(%s) * (%s) * (%s)' % (prefactors,value,couplings[ic]))
             else :
                 all_couplings.append(False)
     else :
         for ic in range(0,len(couplings)) :
             if(couplings[ic]!=0. and all_couplings[ic]) :
                 all_couplings[ic] = '(%s) * (%s) * (%s) + (%s) ' % (prefactors,value,
                                                                     couplings[ic],all_couplings[ic])
             elif(couplings[ic]!=0) :
                 all_couplings[ic] = '(%s) * (%s) * (%s) ' % (prefactors,value,couplings[ic])
     return all_couplings
 
 def processScalarVectorCouplings(lorentztag,vertex,model,parmsubs,all_couplings,header,order) :
     # check the values
     tval = [False]*len(all_couplings[0])
     value =[False]*len(all_couplings[0])
     for icolor in range(0,len(all_couplings)) :
         for ix in range(0,len(all_couplings[icolor])) :
             if(not value[ix]) :
                 value[ix] = all_couplings[icolor][ix]
             if(value[ix] and not tval[ix]) :
                 tval[ix] = evaluate(value[ix],model,parmsubs)
             elif(value[ix]) :
                 tval2 = evaluate(all_couplings[icolor][0],model,parmsubs)
                 if(abs(tval[ix]-tval2)>1e-6) :
                     raise SkipThisVertex()
 
     append = ""
     symbols = set()
     coup_norm=0.
     if(lorentztag=="VVS") :
         if(not value[0] and not value[1] and not value[2] and \
            not value[3] and not value[4] and not value[6] and value[5]) :
             coup_norm=value[5]
         else :
             for ix in range(0,len(value)) :
                 if(value[ix]) :
                     value[ix], sym = py2cpp(value[ix])
                     symbols |= sym
                 else :
                     value[ix]=0.
             lorentztag = 'GeneralVVS'
             header="kinematics(true);"
             # g_mu,nv piece of coupling 
             if(value[5]!=0.) :
                 append +='a00( %s + Complex(( %s )* GeV2/invariant(1,2)));\n' % ( value[0],value[5])
             else :
                 append +='a00( %s );\n' % value[0]
             # other couplings
             append += 'a11( %s );\n    a12( %s );\n    a21( %s );\n    a22( %s );\n aEp( %s );\n' % \
                       ( value[1],value[2],value[3],value[4],value[6] )
             coup_norm="1."
     elif(lorentztag=="VVSS") :
         coup_norm = value[0]
     elif(lorentztag=="VSS") :
         if(abs(tval[0]+tval[1])>1e-6) :
             for ix in range(0,len(value)) :
                 if(value[ix]) :
                     value[ix], sym = py2cpp(value[ix])
                     symbols |= sym
                 else :
                     value[ix]=0.
             coup_norm = "1."
             append = 'if(p2->id()==%s) { a( %s ); b( %s);}\n else { a( %s ); b( %s);}' \
                      % (vertex.particles[order[1]-1].pdg_code,
                         value[0],value[1],value[1],value[0])
         else :
             coup_norm = value[1]
             append = 'if(p2->id()!=%s){norm(-norm());}' \
                      % vertex.particles[order[1]-1].pdg_code
     # return the answer
     return (coup_norm,append,lorentztag,header,symbols)
 
 def getIndices(term) :
     if(term[0:2]=="P(") :
         indices = term.strip(")").strip("P(").split(",")
         mom   = int(indices[1])
         index = int(indices[0])
         return (True,mom,index)
     else :
         return (False,0,0)
     
 
 def lorentzScalar(vertex,L) :
     dotProduct = """(invariant( i[{i1}], i[{i2}] )/GeV2)"""
     structures=L.structure.split()
     output="("
     for struct in structures:
         if(struct=="+" or struct=="-") :
             output+=struct
             continue
         structure = struct.split("*")
         worked = False
         mom=-1
         newTerm=""
         while True :
             term = structure[-1]
             structure.pop()
             (momentum,mom,index) = getIndices(term)
             if( not momentum) : break
             # look for the matching momenta
             for term in structure :
                 (momentum,mom2,index2) = getIndices(term)
                 if(index2==index) :
                     structure.remove(term)
                     dot = dotProduct.format(i1=mom-1,i2=mom2-1)
                     if(newTerm=="") :
                         newTerm = dot
                     else :
                         newTerm = " ( %s) * ( %s ) " % (newTerm,dot)
             if(len(structure)==0) :
                 worked = True
                 break
         if(not worked) :
             return False
         else :
             output+=newTerm
     output+=")"
     return output
 
 kinematicsline = """\
 long id [3]={{{id1},{id2},{id3}}};
     long id2[3]={{p1->id(),p2->id(),p3->id()}};
     unsigned int i[3];
     for(unsigned int ix=0;ix<3;++ix) {{
       for(unsigned int iy=0;iy<3;++iy) {{
 	if(id[ix]==id2[iy]) {{
 	  i[ix] = iy;
 	  id2[iy]=0;
 	  break;
 	}}
       }}
     }}
     double hw_kine1 = {kine};
 """
 
 kinematicsline2 = """\
 long id [4]={{{id1},{id2},{id3},{id4}}};
     long id2[4]={{p1->id(),p2->id(),p3->id(),p4->id()}};
     unsigned int i[4];
     for(unsigned int ix=0;ix<4;++ix) {{
       for(unsigned int iy=0;iy<4;++iy) {{
 	if(id[ix]==id2[iy]) {{
 	  i[ix] = iy;
 	  id2[iy]=0;
 	  break;
 	}}
       }}
     }}
     double hw_kine1 = {kine};
 """
 
 kinematicsline3 ="""\
     double hw_kine{i} = {kine};
 """
 
 def scalarCouplings(vertex,value,prefactors,L,lorentztag,
                     all_couplings,prepend,header) :
     try :
         val = int(L.structure)
     except :
         output = lorentzScalar(vertex,L)
         if( not output ) :
             raise SkipThisVertex()
         else :
             if(prepend=="") :
                 if(lorentztag=="SSS") :
                     # order doesn't matter here, all same spin
                     prepend = kinematicsline.format(id1=vertex.particles[0].pdg_code,
                                                     id2=vertex.particles[1].pdg_code,
                                                     id3=vertex.particles[2].pdg_code,
                                                     kine=output)
                 else :
                     # order doesn't matter here, all same spin
                     prepend = kinematicsline2.format(id1=vertex.particles[0].pdg_code,
                                                      id2=vertex.particles[1].pdg_code,
                                                      id3=vertex.particles[2].pdg_code,
                                                      id4=vertex.particles[3].pdg_code,
                                                      kine=output)
                 value = "(%s) *(hw_kine1)" % value
             else :
                 osplit=prepend.split("\n")
                 i=-1
                 while osplit[i]=="":
                     i=i-1
                 ikin=int(osplit[i].split("=")[0].replace("double hw_kine",""))+1
                 prepend +=kinematicsline3.format(kine=output,i=ikin)
                 value = "(%s) *(hw_kine%s)" % (value,ikin)
             header="kinematics(true);"
     if(len(all_couplings)==0) :
         all_couplings.append('(%s) * (%s)' % (prefactors,value))
     else :
         all_couplings[0] = '(%s) * (%s) + (%s)' % (prefactors,value,all_couplings[0])
     return (prepend, header,all_couplings)
 
 def processScalarCouplings(model,parmsubs,all_couplings) :
     tval = False
     value = False
     for icolor in range(0,len(all_couplings)) :
         if(len(all_couplings[icolor])!=1) :
             raise SkipThisVertex()
         if(not value) :
             value = all_couplings[icolor][0]
         m = re.findall('hw_kine[0-9]*',  all_couplings[icolor][0])
         if m:
             for kine in m:
                 # bizarre number for checks, must be a better option
                 parmsubs[kine] = 987654321.
         if(not tval) :
+            value = all_couplings[icolor][0]
             tval = evaluate(value,model,parmsubs)
         else :
             tval2 = evaluate(all_couplings[icolor][0],model,parmsubs)
             if(abs(tval[i]-tval2)>1e-6) :
                 raise SkipThisVertex()
     # cleanup and return the answer
     return value.replace("(1.0) * ","").replace(" * (1)","")
 
 def vectorCouplings(vertex,value,prefactors,L,lorentztag,pos,
                     all_couplings,append,qcd,order) :
     structures=extractStructures(L)
     terms=[]
     signs=[]
     if(lorentztag=="VVV") :
         terms=[['P(%s,%s)' % (order[2],order[0]),'Metric(%s,%s)' % (order[0],order[1])],
                ['P(%s,%s)' % (order[2],order[1]),'Metric(%s,%s)' % (order[0],order[1])],
                ['P(%s,%s)' % (order[1],order[0]),'Metric(%s,%s)' % (order[0],order[2])],
                ['P(%s,%s)' % (order[1],order[2]),'Metric(%s,%s)' % (order[0],order[2])],
                ['P(%s,%s)' % (order[0],order[1]),'Metric(%s,%s)' % (order[1],order[2])],
                ['P(%s,%s)' % (order[0],order[2]),'Metric(%s,%s)' % (order[1],order[2])]]
         signs=[1.,-1.,-1.,1.,1.,-1.]
     elif(lorentztag=="VVVV") :
         terms=[['Metric(%s,%s)' % (order[0],order[3]),'Metric(%s,%s)' % (order[1],order[2])],
                ['Metric(%s,%s)' % (order[0],order[2]),'Metric(%s,%s)' % (order[1],order[3])],
                ['Metric(%s,%s)' % (order[0],order[1]),'Metric(%s,%s)' % (order[2],order[3])]]
         signs=[1.,1.,1.]
     elif(lorentztag=="VVVS") :
         terms=[['P(%s,%s)' % (order[2],order[0]),'Metric(%s,%s)' % (order[0],order[1])],
                ['P(%s,%s)' % (order[2],order[1]),'Metric(%s,%s)' % (order[0],order[1])],
                ['P(%s,%s)' % (order[1],order[0]),'Metric(%s,%s)' % (order[0],order[2])],
                ['P(%s,%s)' % (order[1],order[2]),'Metric(%s,%s)' % (order[0],order[2])],
                ['P(%s,%s)' % (order[0],order[1]),'Metric(%s,%s)' % (order[1],order[2])],
                ['P(%s,%s)' % (order[0],order[2]),'Metric(%s,%s)' % (order[1],order[2])],
                ['Epsilon(1,2,3,-1)','P(-1,1)'],['Epsilon(1,2,3,-1)','P(-1,2)'],
                ['Epsilon(1,2,3,-1)','P(-1,3)']]
         signs=[1.,-1.,-1.,1.,1.,-1.,1.,1.,1.]
 
     # extract the couplings
     new_couplings  = [False]*len(terms)
     iterm=0
     try :
         for term in terms:
             for perm in itertools.permutations(term):
                 label = '*'.join(perm)
                 for istruct in range(0,len(structures)) :
                     if label in structures[istruct] :
                         reminder = structures[istruct].replace(label,'1.',1)
                         structures[istruct] = "Done"
                         val = eval(reminder, {'cmath':cmath} )*signs[iterm]
                         if(new_couplings[iterm]) :
                             new_couplings[iterm] += val
                         else :
                             new_couplings[iterm] = val
             iterm += 1
     except :
         raise SkipThisVertex()
     # check we've handled all the terms
     for val in structures:
         if(val!="Done") :
             raise SkipThisVertex()
     # set the couplings
     for icoup in range(0,len(new_couplings)) :
         if(new_couplings[icoup]) :
             new_couplings[icoup] = '(%s) * (%s) *(%s)' % (new_couplings[icoup],prefactors,value)
     if(len(all_couplings)==0) :
         all_couplings=new_couplings
     else :
         for icoup in range(0,len(new_couplings)) :
             if(new_couplings[icoup] and all_couplings[icoup]) :
                 all_couplings[icoup] = '(%s) * (%s) *(%s) + (%s) ' % (new_couplings[icoup],prefactors,value,all_couplings[icoup])
             elif(new_couplings[icoup]) :
                 all_couplings[icoup] = new_couplings[icoup]
     # ordering for VVV type vertices
     if(len(pos[8]) != 3 and (lorentztag=="VVV" or lorentztag=="VVVS")) :
         append = VVVordering(vertex)
     return all_couplings,append
 
 def processVectorCouplings(lorentztag,vertex,model,parmsubs,all_couplings,append,header) :
     value = False
     tval  = False
     if(lorentztag=="VVV") :
         for icolor in range(0,len(all_couplings)) :
             # loop over the different terms
             for ix in range(0,len(all_couplings[icolor])) :
                 if(not value) :
                     value = all_couplings[icolor][ix]
                     tval = evaluate(value,model,parmsubs)
                 else :
-                    tval2 = evaluate(all_couplings[icolor][ix],model,parmsubs)
+                    if all_couplings[icolor][ix] == False:
+                        raise SkipThisVertex()
+                    else:
+                        tval2 = evaluate(all_couplings[icolor][ix],model,parmsubs)
                     if(abs(tval-tval2)>1e-6) :
                         raise SkipThisVertex()
     elif(lorentztag=="VVVV") :
         order=[]
         colours = vertex.color
         if(len(colours)==1) :
             tval=[]
             for i in range(0,3) :
                 tval.append(evaluate(all_couplings[0][i],model,parmsubs))
             if(compare(tval[2],-2.*tval[1]) and
                compare(tval[2],-2.*tval[0]) ) :
                 order=[0,1,2,3]
                 value = "0.5*(%s)" % all_couplings[0][2]
             elif(compare(tval[1],-2.*tval[2]) and
                  compare(tval[1],-2.*tval[0]) ) :
                 order=[0,2,1,3]
                 value = "0.5*(%s)" % all_couplings[0][1]
             elif(compare(tval[0],-2.*tval[2]) and
                  compare(tval[0],-2.*tval[1]) ) :
                 order=[0,3,1,2]
                 value = "0.5*(%s)" % all_couplings[0][0]
             else:
                 raise SkipThisVertex()
             pattern = \
                       "bool done[4]={false,false,false,false};\n" + \
                     "    tcPDPtr part[4]={p1,p2,p3,p4};\n" + \
                     "    unsigned int iorder[4]={0,0,0,0};\n" + \
                     "    for(unsigned int ix=0;ix<4;++ix) {\n" + \
                     "       if(!done[0] && part[ix]->id()==%s) {done[0]=true; iorder[%s] = ix; continue;}\n" + \
                 "       if(!done[1] && part[ix]->id()==%s) {done[1]=true; iorder[%s] = ix; continue;}\n" + \
                 "       if(!done[2] && part[ix]->id()==%s) {done[2]=true; iorder[%s] = ix; continue;}\n" + \
                 "       if(!done[3] && part[ix]->id()==%s) {done[3]=true; iorder[%s] = ix; continue;}\n" + \
                 "    }\n" + \
                 "    setType(2);\n" + \
                 "    setOrder(iorder[0],iorder[1],iorder[2],iorder[3]);"
             # order doesn't matter here same spin
             append = pattern % ( vertex.particles[0].pdg_code,order[0],
                                  vertex.particles[1].pdg_code,order[1],
                                  vertex.particles[2].pdg_code,order[2],
                                  vertex.particles[3].pdg_code,order[3] )
         else :
             for icolor in range(0,len(all_couplings)) :
                 col=colours[icolor].split("*")
                 if(len(col)==2 and "f(" in col[0] and "f(" in col[1]) :
                     sign = 1
                     for i in range(0,2) :
                         col[i],stemp = extractAntiSymmetricIndices(col[i],"f(")
                         for ix in range(0,len(col[i])): col[i][ix]=int(col[i][ix])
                         sign *=stemp
                     if(col[0][0]>col[1][0]) : col[0],col[1] = col[1],col[0]
                     # first flow
                     if(col[0][0]==1 and col[0][1]==2 and col[1][0] ==3 and col[1][1] == 4) :
                         if(all_couplings[icolor][2] or not all_couplings[icolor][0] or
                            not all_couplings[icolor][1]) :
                             raise SkipThisVertex()
                         if(not value) :
                             value = all_couplings[icolor][1]
                             tval  = evaluate(value,model,parmsubs)
                         tval2 = -evaluate(all_couplings[icolor][0],model,parmsubs)
                         tval3 =  evaluate(all_couplings[icolor][1],model,parmsubs)
                     elif(col[0][0]==1 and col[0][1]==3 and col[1][0] ==2 and col[1][1] == 4) : 
                         if(all_couplings[icolor][1] or not all_couplings[icolor][0] or
                            not all_couplings[icolor][2]) :
                             raise SkipThisVertex()
                         if(not value) :
                             value = all_couplings[icolor][2]
                             tval  = evaluate(value,model,parmsubs)
                         tval2 = -evaluate(all_couplings[icolor][0],model,parmsubs)
                         tval3 =  evaluate(all_couplings[icolor][2],model,parmsubs)
                     elif(col[0][0]==1 and col[0][1]==4 and col[1][0] ==2 and col[1][1] == 3) : 
                         if(all_couplings[icolor][0] or not all_couplings[icolor][1] or
                            not all_couplings[icolor][2]) :
                             raise SkipThisVertex()
                         if(not value) :
                             value = all_couplings[icolor][2]
                             tval  = evaluate(value,model,parmsubs)
                         tval2 = -evaluate(all_couplings[icolor][1],model,parmsubs)
                         tval3 =  evaluate(all_couplings[icolor][2],model,parmsubs)
                     else :
                         raise SkipThisVertex()
                     if(abs(tval-tval2)>1e-6 or abs(tval-tval3)>1e-6 ) :
                         raise SkipThisVertex()
                     append = 'setType(1);\nsetOrder(0,1,2,3);'
                 else :
                     print('unknown colour structure for VVVV vertex')
                     raise SkipThisVertex()
     elif(lorentztag=="VVVS") :
         try :
             # two distinct cases 0-5 = , 6-8=
             if(all_couplings[0][0]) :
                 imin=0
                 imax=6
                 header="scalar(true);"
             else :
                 imin=6
                 imax=9
                 header="scalar(false);"
             for icolor in range(0,len(all_couplings)) :
                 # loop over the different terms
                 for ix in range(imin,imax) :
                     if(not value) :
                         value = all_couplings[icolor][ix]
                         tval = evaluate(value,model,parmsubs)
                     else :
                         tval2 = evaluate(value,model,parmsubs)
                         if(abs(tval-tval2)>1e-6) :
                             raise SkipThisVertex()
         except :
             SkipThisVertex()
     # cleanup and return the answer
     value = value.replace("(1.0) * ","").replace(" * (1)","")
     return (value,append,header)
 
 def fermionCouplings(value,prefactors,L,all_couplings,order) :
     new_couplings=[False,False]
     try :
         new_couplings[0],new_couplings[1] = parse_lorentz(L.structure)
     except :
         raise SkipThisVertex()
     for i in range(0,2) :
         if new_couplings[i]:
             new_couplings[i] = '(%s) * (%s) * (%s)' % (prefactors,new_couplings[i],value)
     if(len(all_couplings)==0) :
         all_couplings=new_couplings
     else :
         for i in range(0,len(new_couplings)) :
             if(new_couplings[i] and all_couplings[i]) :
                 all_couplings[i] = '(%s) + (%s) ' % (new_couplings[i],all_couplings[i])
             elif(new_couplings[i]) :
                 all_couplings[i] = new_couplings[i]
     return all_couplings
 
 def processFermionCouplings(lorentztag,vertex,model,parmsubs,all_couplings,order) :
     leftcontent  = all_couplings[0][0] if all_couplings[0][0] else "0."
     rightcontent = all_couplings[0][1] if all_couplings[0][1] else "0."
     tval=[evaluate( leftcontent,model,parmsubs),
           evaluate(rightcontent,model,parmsubs)]
     for icolor in range(0,len(all_couplings)) :
         # loop over the different terms
         for ix in range(0,len(all_couplings[icolor])) :
             tval2 = evaluate(all_couplings[icolor][ix],model,parmsubs) if all_couplings[icolor][ix] else 0.
             if(abs(tval[ix]-tval2)>1e-6) :
                 raise SkipThisVertex()
     normcontent  = "1."
     append=""
     if lorentztag == 'FFV':
         append = ('if(p1->id()!=%s) {Complex ltemp=left(), rtemp=right(); left(-rtemp); right(-ltemp);}' 
                   % vertex.particles[order[0]-1].pdg_code)
     return normcontent,leftcontent,rightcontent,append
 
 def RSCouplings(value,prefactors,L,all_couplings,order) :
     raise SkipThisVertex()
diff --git a/Models/General/DecayConstructor.cc b/Models/General/DecayConstructor.cc
--- a/Models/General/DecayConstructor.cc
+++ b/Models/General/DecayConstructor.cc
@@ -1,166 +1,166 @@
 // -*- C++ -*-
 //
 // DecayConstructor.cc is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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.
 //
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the DecayConstructor class.
 //
 
 #include "DecayConstructor.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/Interface/Reference.h"
 #include "ThePEG/Interface/RefVector.h"
 #include "ThePEG/Interface/ParVector.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "ThePEG/Repository/BaseRepository.h"
 #include <iterator>
 
 using namespace Herwig;
 using namespace ThePEG;
 
 IBPtr DecayConstructor::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr DecayConstructor::fullclone() const {
   return new_ptr(*this);
 }
   
 void DecayConstructor::persistentOutput(PersistentOStream & os) const {
   os << NBodyDecayConstructors_ << QEDGenerator_;
 }
 
 void DecayConstructor::persistentInput(PersistentIStream & is, int) {
   is >> NBodyDecayConstructors_ >> QEDGenerator_;
 }
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeClass<DecayConstructor,Interfaced>
 describeHerwigDecayConstructor("Herwig::DecayConstructor", "Herwig.so");
 
 void DecayConstructor::Init() {
 
   static ClassDocumentation<DecayConstructor> documentation
     ("There is no documentation for the TwoBodyDecayConstructor class");
 
   static RefVector<DecayConstructor,Herwig::NBodyDecayConstructorBase> 
     interfaceNBodyDecayConstructors
     ("NBodyDecayConstructors",
      "Vector of references to NBodyDecayConstructors",
      &DecayConstructor::NBodyDecayConstructors_, -1, false, false, true,
      false, false);
 
   static ParVector<DecayConstructor,string> interfaceDisableModes
     ("DisableModes",
      "A list of decay modes to disable",
      &DecayConstructor::_disableDMTags, -1, string(""), string(""), string(""),
      false, false, Interface::nolimits);
 
   static Reference<DecayConstructor,DecayRadiationGenerator> interfaceQEDGenerator
     ("QEDGenerator",
      "Object to generate QED radiation in particle decays",
      &DecayConstructor::QEDGenerator_, false, false, true, true, false);
 
 }
 
 /** A helper function for for_each to sort the decay mode tags into the 
  *  standard order.
  */
 namespace {
 
   void adjustFSOrder(string & tag) {
     string::size_type sep = tag.find(">");
     string head = tag.substr(0, sep + 1);
     string products = tag.substr(sep + 1);
     OrderedParticles finalstate;
     bool loopbreak(true);
     while ( loopbreak ) {
       sep = products.find(",");
       string child;
       if( sep != string::npos ) {
 	child = products.substr(0, sep);
 	products = products.substr(sep + 1);
       }
       else {
 	child = string(products.begin(), products.end() - 1);
 	loopbreak = false;
       }
       PDPtr p = BaseRepository::GetObject<PDPtr>
 	(string("/Herwig/Particles/" + child));
       if( p ) finalstate.insert(p);
     }
     if( finalstate.empty() ) return;
     tag = head;
     OrderedParticles::const_iterator iend = finalstate.end();
     OrderedParticles::size_type count(0), npr(finalstate.size());
     for( OrderedParticles::const_iterator it = finalstate.begin(); 
 	 it != iend;  ++it ) {
       tag += (**it).name();
       if( ++count != npr ) tag += string(",");
     }
     tag += string(";");
    }
 }
 
 namespace {
   /// Helper function for sorting by number of outgoing lines
   inline bool orderNBodyConstructors(tNBodyDecayConstructorBasePtr a,
 				     tNBodyDecayConstructorBasePtr b) {
     return a->numBodies() < b->numBodies();
   }
 }
 
 void DecayConstructor::doinit() {
   Interfaced::doinit();
   //Need to check that the stored decay mode tags have the
   //products in the standard order
   for_each( _disableDMTags.begin(), _disableDMTags.end(), adjustFSOrder );
   sort(NBodyDecayConstructors_.begin(), NBodyDecayConstructors_.end(),
        orderNBodyConstructors);
 }
 
 void DecayConstructor::createDecayers(const PDVector & particles,
 				      double minBR) {
   _minBR = minBR;
   if ( particles.empty() || NBodyDecayConstructors_.empty() ) return;
   // turn the vector into a set to avoid duplicates
-  set<PDPtr> particleSet(particles.begin(),particles.end());
+  set<PDPtr,NBodyDecayConstructorBase::MassOrdering> particleSet(particles.begin(),particles.end());
   // remove any antiparticles
   for(set<PDPtr>::iterator it=particleSet.begin();it!=particleSet.end();++it) {
     PDPtr cc = (**it).CC();
     if(!cc) continue;
     set<PDPtr>::iterator ic = particleSet.find(cc);
     if(ic!=particleSet.end()) particleSet.erase(ic);
   }
   // set the decay list in the NBodyDecayConstructors
   typedef vector<NBodyDecayConstructorBasePtr>::iterator NBDecayIterator;
   NBDecayIterator it =  NBodyDecayConstructors_.begin();
   NBDecayIterator iend = NBodyDecayConstructors_.end();
   for( ; it != iend; ++it ) {
     (**it).init();
     (**it).decayConstructor(this);
     (**it).DecayList(particleSet);
   }
 }
 
 bool DecayConstructor::disableDecayMode(string tag) const {
   if( _disableDMTags.empty() ) return false;
   vector<string>::const_iterator dit = _disableDMTags.begin();
   vector<string>::const_iterator dend = _disableDMTags.end();
   bool disable(false);
   for( ; dit != dend; ++dit ) {
     if( *dit == tag ) {
       disable = true;
       break;
     }
   }
   return disable;
 }
diff --git a/Models/General/FourBodyDecayConstructor.cc b/Models/General/FourBodyDecayConstructor.cc
--- a/Models/General/FourBodyDecayConstructor.cc
+++ b/Models/General/FourBodyDecayConstructor.cc
@@ -1,259 +1,259 @@
 // -*- C++ -*-
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the FourBodyDecayConstructor class.
 //
 
 #include "FourBodyDecayConstructor.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/Interface/Parameter.h"
 #include "ThePEG/Interface/Switch.h"
 #include "ThePEG/Interface/RefVector.h"
 #include "ThePEG/EventRecord/Particle.h"
 #include "ThePEG/Repository/UseRandom.h"
 #include "ThePEG/Repository/EventGenerator.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/PDT/DecayMode.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "Herwig/Models/StandardModel/StandardModel.h"
 #include "Herwig/Decay/General/GeneralFourBodyDecayer.h"
 #include "DecayConstructor.h"
 
 using namespace Herwig;
 
 FourBodyDecayConstructor::~FourBodyDecayConstructor() {}
 
 IBPtr FourBodyDecayConstructor::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr FourBodyDecayConstructor::fullclone() const {
   return new_ptr(*this);
 }
 
 void FourBodyDecayConstructor::persistentOutput(PersistentOStream & os) const {
   os << interOpt_ << widthOpt_ << particles_;
 }
 
 void FourBodyDecayConstructor::persistentInput(PersistentIStream & is, int) {
   is >> interOpt_ >> widthOpt_ >> particles_;
 }
 
 DescribeClass<FourBodyDecayConstructor,NBodyDecayConstructorBase>
 describeFourBodyDecayConstructor("Herwig::FourBodyDecayConstructor","Herwig.so");
 
 void FourBodyDecayConstructor::Init() {
 
   static ClassDocumentation<FourBodyDecayConstructor> documentation
     ("The FourBodyDecayConstructor class implements a small number"
      " of 4-body decays in general models");
 
   static Switch<FourBodyDecayConstructor,unsigned int> interfaceWidthOption
     ("WidthOption",
      "Option for the treatment of the widths of the intermediates",
      &FourBodyDecayConstructor::widthOpt_, 1, false, false);
   static SwitchOption interfaceWidthOptionFixed
     (interfaceWidthOption,
      "Fixed",
      "Use fixed widths",
      1);
   static SwitchOption interfaceWidthOptionRunning
     (interfaceWidthOption,
      "Running",
      "Use running widths",
      2);
   static SwitchOption interfaceWidthOptionZero
     (interfaceWidthOption,
      "Zero",
      "Set the widths to zero",
      3);
 
   static Switch<FourBodyDecayConstructor,unsigned int> interfaceIntermediateOption
     ("IntermediateOption",
      "Option for the inclusion of intermediates in the event",
      &FourBodyDecayConstructor::interOpt_, 0, false, false);
   static SwitchOption interfaceIntermediateOptionAlways
     (interfaceIntermediateOption,
      "Always",
      "Always include the intermediates",
      1);
   static SwitchOption interfaceIntermediateOptionNever
     (interfaceIntermediateOption,
      "Never",
      "Never include the intermediates",
      2);
   static SwitchOption interfaceIntermediateOptionOnlyIfOnShell
     (interfaceIntermediateOption,
      "OnlyIfOnShell",
      "Only if there are on-shell diagrams",
      0);
 
   static RefVector<FourBodyDecayConstructor,ParticleData> interfaceParticles
     ("Particles",
      "Particles to override the choice in the DecayConstructor for 4-body decays,"
      " if empty the defaults from the DecayConstructor are used.",
      &FourBodyDecayConstructor::particles_, -1, false, false, true, true, false);
 
   static Switch<FourBodyDecayConstructor,bool> interfaceParticleType
     ("ParticleType",
      "Which types of particles to calculate four body decay modes for",
      &FourBodyDecayConstructor::particleType_, false, false, false);
   static SwitchOption interfaceParticleTypeStable
     (interfaceParticleType,
      "Stable",
      "Only calculate four-body decays in no 2/3 body modes",
      false);
   static SwitchOption interfaceParticleTypeAll
     (interfaceParticleType,
      "All",
      "Calculate 4-body modes for all particles",
      true);
 
 }
 
-void FourBodyDecayConstructor::DecayList(const set<PDPtr> & particles) {
+void FourBodyDecayConstructor::DecayList(const set<PDPtr,MassOrdering> & particles) {
   if( particles.empty() ) return;
-  set<PDPtr> new_particles;
-  for(set<PDPtr>::const_iterator it=particles.begin();it!=particles.end();++it) {
+  set<PDPtr,MassOrdering> new_particles;
+  for(set<PDPtr,MassOrdering>::const_iterator it=particles.begin();it!=particles.end();++it) {
     if(!particles_.empty() && find(particles_.begin(),particles_.end(),*it)==particles_.end()) continue;
     if(!(**it).stable()&&!particleType_) continue;
     new_particles.insert(*it);
   }
   if(!new_particles.empty())
     NBodyDecayConstructorBase::DecayList(new_particles);
 }
 
 void FourBodyDecayConstructor::
 createDecayMode(vector<NBDiagram> & diagrams,
 		bool possibleOnShell, double symfac) {
   // some basic checks for the modes we are interested in
   // only looking at scalars
   if(diagrams[0].incoming->iSpin()!=PDT::Spin0) return;
   // which decay to 4 fermions
   unsigned int nferm=0;
   for(OrderedParticles::const_iterator it=diagrams[0].outgoing.begin();
       it!=diagrams[0].outgoing.end();++it) {
     if((**it).iSpin()==PDT::Spin1Half) ++nferm;
   }
   if(nferm!=4) return;
   // check for on-shell intermediates
   bool inter = interOpt_ == 1 || (interOpt_ == 0 && possibleOnShell);
   // incoming particle  
   tPDPtr inpart = diagrams[0].incoming;
   // outgoing particles
   OrderedParticles outgoing=diagrams[0].outgoing;
   // incoming particle is now unstable
   inpart->stable(false);
   // construct the tag for the decay mode
   string tag = inpart->name() + "->";
   for(OrderedParticles::const_iterator it = outgoing.begin();
       it != outgoing.end(); ++it) {
     if(it!=outgoing.begin()) tag += ",";
     tag += (**it).name();
   }
   tag += ";";
   tDMPtr dm = generator()->findDecayMode(tag);
   // create mode if needed
   if( createDecayModes() && (!dm || inpart->id() == ParticleID::h0) ) {
     // create the decayer
     GeneralFourBodyDecayerPtr decayer = createDecayer(diagrams,inter,symfac);
     if(!decayer) {
       if(Debug::level > 1 ) generator()->log() << "Can't create the decayer for " 
 					       << tag << " so mode not created\n";
       return;
     }
     // create the decay mode
     tDMPtr ndm = generator()->preinitCreateDecayMode(tag);
     if(ndm) {
       string test = generator()->preinitInterface(ndm, "Decayer", "set",
 						  decayer->fullName());
       generator()->preinitInterface(ndm, "Active", "set", "Yes");
       Energy width = 
 	decayer->partialWidth(inpart,outgoing);
       setBranchingRatio(ndm, width);
     }
     else 
       throw NBodyDecayConstructorError() 
 	<< "FourBodyDecayConstructor::createDecayMode - Needed to create "
 	<< "new decaymode but one could not be created for the tag " 
 	<< tag << Exception::warning;
   }
   // otherwise 
   else if (dm && (dm->decayer()->fullName()).find("Mambo") != string::npos) {
     // create the decayer
     GeneralFourBodyDecayerPtr decayer = createDecayer(diagrams,inter,symfac);
     if(!decayer) {
       if(Debug::level > 1 ) generator()->log() << "Can't create the decayer for " 
 					       << tag << " so mode not created\n";
       return;
     }
     generator()->preinitInterface(dm, "Decayer", "set", 
 				  decayer->fullName());
   }
   //update CC mode if it exists
   if( inpart->CC() )
     inpart->CC()->synchronize();
 }
 
 GeneralFourBodyDecayerPtr 
 FourBodyDecayConstructor::createDecayer(vector<NBDiagram> & diagrams, 
 					bool inter, double symfac) const {
   if(diagrams.empty()) return GeneralFourBodyDecayerPtr();
   // extract the external particles for the process
   PDPtr incoming = diagrams[0].incoming;
   // outgoing particles
   vector<PDPtr> outgoing(diagrams[0].outgoing.begin(),
 			 diagrams[0].outgoing.end());
   // get the name for the object
   string objectname ("/Herwig/Decays/");
   string classname = DecayerClassName(incoming, diagrams[0].outgoing, objectname);
   if(classname=="") return GeneralFourBodyDecayerPtr();
   // create the object
   GeneralFourBodyDecayerPtr decayer = 
     dynamic_ptr_cast<GeneralFourBodyDecayerPtr>
     (generator()->preinitCreate(classname, objectname));
   // set up the decayer and return if doesn't work
   if(!decayer->setDecayInfo(incoming,outgoing,diagrams,symfac))
     return GeneralFourBodyDecayerPtr();
   // set decayer options from base class
   setDecayerInterfaces(objectname);
   // set the width option
   ostringstream value;
   value << widthOpt_;
   generator()->preinitInterface(objectname, "WidthOption", "set", value.str());
   // set the intermediates option
   ostringstream value2;
   value2 << inter;
   generator()->preinitInterface(objectname, "GenerateIntermediates", "set", 
  				value2.str());
   // initialize the decayer
   decayer->init();
   // return the decayer
   return decayer;
 }
 
 string  FourBodyDecayConstructor::DecayerClassName(tcPDPtr incoming,
 						   const OrderedParticles & outgoing, 
 						   string & objname) const {
   string classname("Herwig::");
   // spins of the outgoing particles
   unsigned int ns(0),nf(0),nv(0);
   objname += incoming->PDGName() + "2";
   for(OrderedParticles::const_iterator it=outgoing.begin();
       it!=outgoing.end();++it) {
     if     ((**it).iSpin()==PDT::Spin0    ) ++ns;
     else if((**it).iSpin()==PDT::Spin1Half) ++nf;
     else if((**it).iSpin()==PDT::Spin1    ) ++nv;
     objname += (**it).PDGName();
   }
   objname   += "Decayer";
   if(incoming->iSpin()==PDT::Spin0) {
     if(nf==4) classname += "StoFFFFDecayer";
     else      classname  = "";
   }
   else {
     classname="";
   }
   return classname;
 }
diff --git a/Models/General/FourBodyDecayConstructor.h b/Models/General/FourBodyDecayConstructor.h
--- a/Models/General/FourBodyDecayConstructor.h
+++ b/Models/General/FourBodyDecayConstructor.h
@@ -1,150 +1,150 @@
 // -*- C++ -*-
 #ifndef THEPEG_FourBodyDecayConstructor_H
 #define THEPEG_FourBodyDecayConstructor_H
 //
 // This is the declaration of the FourBodyDecayConstructor class.
 //
 
 #include "NBodyDecayConstructorBase.h"
 #include "ThePEG/Helicity/Vertex/VertexBase.h"
 #include "Herwig/Decay/General/GeneralFourBodyDecayer.fh"
 #include "PrototypeVertex.h"
 
 namespace Herwig {
 
 using namespace ThePEG;
 using Helicity::VertexBasePtr;
 
 /**
  * Here is the documentation of the FourBodyDecayConstructor class.
  *
  * @see \ref FourBodyDecayConstructorInterfaces "The interfaces"
  * defined for FourBodyDecayConstructor.
  */
 class FourBodyDecayConstructor: public NBodyDecayConstructorBase {
 
 public:
 
   /**
    * The default constructor.
    */
   FourBodyDecayConstructor() :
     interOpt_(0), widthOpt_(1), particleType_(false) {}
 
   /**
    *  Destructor
    */
   ~FourBodyDecayConstructor();
 
   /**
    * Function used to determine allowed decaymodes, to be implemented
    * in derived class.
    * @param particles vector of ParticleData pointers containing 
    * particles in model
    */
-  virtual void DecayList(const set<PDPtr> & particles);
+  virtual void DecayList(const set<PDPtr,MassOrdering> & particles);
 
   /**
    * Number of outgoing lines. Required for correct ordering.
    */
   virtual unsigned int numBodies() const {return 4;}
 
   /**
    *  Create a decay mode
    */
   void createDecayMode(vector<NBDiagram> &,bool,double);
 
   /**
    * Create the decayer
    * @param diagrams The diagrams for the decay
    * @param inter Option for intermediates
    */
   GeneralFourBodyDecayerPtr createDecayer(vector<NBDiagram> & diagrams,
 					  bool inter, double symfac) const;
 
   /**
    * Contruct the classname and object name for the Decayer
    * @param incoming The incoming particle
    * @param outgoing The decay products
    * @param objname a string containing the default path of the Decayer object
    */  
   string DecayerClassName(tcPDPtr incoming, const OrderedParticles & outgoing, 
 			  string & objname) const;
 
 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;
   //@}
 
 private:
 
   /**
    * The assignment operator is private and must never be called.
    * In fact, it should not even be implemented.
    */
   FourBodyDecayConstructor & operator=(const FourBodyDecayConstructor &) = delete;
 
 private:
 
   /**
    *  Option for the inclusion of intermediates
    */
   unsigned int interOpt_;
 
   /**
    *  How to treat the widths of the intermediate particles
    */
   unsigned int widthOpt_;
 
   /**
    *  Particles to override the default list
    */
   vector<PDPtr> particles_;
 
   /**
    *  Types of particles
    */
   bool particleType_;
 };
 
 }
 
 #endif /* THEPEG_FourBodyDecayConstructor_H */
diff --git a/Models/General/ModelGenerator.cc b/Models/General/ModelGenerator.cc
--- a/Models/General/ModelGenerator.cc
+++ b/Models/General/ModelGenerator.cc
@@ -1,556 +1,557 @@
 // -*- C++ -*-
 //
 // ModelGenerator.cc is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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.
 //
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the ModelGenerator class.
 //
 
 #include "ModelGenerator.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Interface/Reference.h"
 #include "ThePEG/Interface/RefVector.h"
 #include "ThePEG/Interface/Switch.h"
 #include "ThePEG/Interface/Parameter.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "ThePEG/PDT/DecayMode.h"
 #include "ThePEG/Repository/CurrentGenerator.h"
 #include "BSMWidthGenerator.h"
 #include "Herwig/PDT/GenericMassGenerator.h"
 #include "Herwig/Decay/DecayIntegrator.h"
 #include "ThePEG/Repository/BaseRepository.h"
 
 using namespace Herwig;
 
 IBPtr ModelGenerator::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr ModelGenerator::fullclone() const {
   return new_ptr(*this);
 }
 
 void ModelGenerator::persistentOutput(PersistentOStream & os) const {
   os << hardProcessConstructors_ << _theDecayConstructor << particles_ 
      << offshell_ << Offsel_ << BRnorm_ << twoBodyOnly_ << howOffShell_
      << Npoints_ << Iorder_ << BWshape_ << brMin_ << decayOutput_;
 }
 
 void ModelGenerator::persistentInput(PersistentIStream & is, int) {
   is >> hardProcessConstructors_ >> _theDecayConstructor >> particles_
      >> offshell_ >> Offsel_ >> BRnorm_ >> twoBodyOnly_ >> howOffShell_
      >> Npoints_ >> Iorder_ >> BWshape_ >> brMin_ >> decayOutput_;
 }
 
 // Static variable needed for the type description system in ThePEG.
 DescribeClass<ModelGenerator,Interfaced>
 describeThePEGModelGenerator("Herwig::ModelGenerator", "Herwig.so");
 
 
 void ModelGenerator::Init() {
 
   static ClassDocumentation<ModelGenerator> documentation
     ("This class controls the the use of BSM physics.",
      "BSM physics was produced using the algorithm of "
      "\\cite{Gigg:2007cr,Gigg:2008yc}",
      "\\bibitem{Gigg:2007cr} M.~Gigg and P.~Richardson, \n"
      "Eur.\\ Phys.\\ J.\\  C {\\bf 51} (2007) 989.\n"
      "%%CITATION = EPHJA,C51,989;%%\n"
      " %\\cite{Gigg:2008yc}\n"
      "\\bibitem{Gigg:2008yc}\n"
      "  M.~A.~Gigg and P.~Richardson,\n"
      "  %``Simulation of Finite Width Effects in Physics Beyond the Standard Model,''\n"
      "  arXiv:0805.3037 [hep-ph].\n"
      "  %%CITATION = ARXIV:0805.3037;%%\n"
      );
  
   static RefVector<ModelGenerator,HardProcessConstructor> 
     interfaceHardProcessConstructors
     ("HardProcessConstructors",
      "The objects to construct hard processes",
      &ModelGenerator::hardProcessConstructors_, -1, 
      false, false, true, false, false);
 
   static Reference<ModelGenerator,Herwig::DecayConstructor> 
      interfaceDecayConstructor
      ("DecayConstructor",
       "Pointer to DecayConstructor helper class",
       &ModelGenerator::_theDecayConstructor, false, false, true, false);
   
   static RefVector<ModelGenerator,ThePEG::ParticleData> interfaceModelParticles
     ("DecayParticles",
      "ParticleData pointers to the particles requiring spin correlation "
      "decayers. If decay modes do not exist they will also be created.",
      &ModelGenerator::particles_, -1, false, false, true, false);
     
   static RefVector<ModelGenerator,ParticleData> interfaceOffshell
     ("Offshell",
      "The particles to treat as off-shell",
      &ModelGenerator::offshell_, -1, false, false, true, false);
 
   static Switch<ModelGenerator,int> interfaceWhichOffshell
     ("WhichOffshell",
      "A switch to determine which particles to create mass and width "
      "generators for.",
      &ModelGenerator::Offsel_, 0, false, false);
   static SwitchOption interfaceWhichOffshellSelected
     (interfaceWhichOffshell,
      "Selected",
      "Only create mass and width generators for the particles specified",
      0);
   static SwitchOption interfaceWhichOffshellAll
     (interfaceWhichOffshell,
      "All",
      "Treat all particles specified in the DecayParticles "
      "list as off-shell",
      1);
   
   static Switch<ModelGenerator,bool> interfaceBRNormalize
     ("BRNormalize",
      "Whether to normalize the partial widths to BR*total width for an "
      "on-shell particle",
      &ModelGenerator::BRnorm_, true, false, false);
   static SwitchOption interfaceBRNormalizeNormalize
     (interfaceBRNormalize,
      "Yes",
      "Normalize the partial widths",
      true);
   static SwitchOption interfaceBRNormalizeNoNormalize
     (interfaceBRNormalize,
      "No",
      "Do not normalize the partial widths",
      false);
 
   static Parameter<ModelGenerator,int> interfacePoints
     ("InterpolationPoints",
      "Number of points to use for interpolation tables when needed",
      &ModelGenerator::Npoints_, 10, 5, 1000,
      false, false, true);
   
   static Parameter<ModelGenerator,unsigned int> 
     interfaceInterpolationOrder
     ("InterpolationOrder", "The interpolation order for the tables",
      &ModelGenerator::Iorder_, 1, 1, 5,
      false, false, Interface::limited);
 
   static Switch<ModelGenerator,int> interfaceBreitWignerShape
     ("BreitWignerShape",
      "Controls the shape of the mass distribution generated",
      &ModelGenerator::BWshape_, 0, false, false);
   static SwitchOption interfaceBreitWignerShapeDefault
     (interfaceBreitWignerShape,
      "Default",
      "Running width with q in numerator and denominator width factor",
      0);
   static SwitchOption interfaceBreitWignerShapeFixedWidth
     (interfaceBreitWignerShape,
      "FixedWidth",
      "Use a fixed width",
      1);
   static SwitchOption interfaceBreitWignerShapeNoq
     (interfaceBreitWignerShape,
      "Noq",
      "Use M rather than q in the numerator and denominator width factor",
      2);
   static SwitchOption interfaceBreitWignerShapeNoNumerator
     (interfaceBreitWignerShape,
      "NoNumerator",
      "Neglect the numerator factors",
      3);
 
   static Switch<ModelGenerator,bool> interfaceTwoBodyOnly
     ("TwoBodyOnly",
      "Whether to use only two-body or all modes in the running width calculation",
      &ModelGenerator::twoBodyOnly_, false, false, false);
   static SwitchOption interfaceTwoBodyOnlyYes
     (interfaceTwoBodyOnly,
      "Yes",
      "Only use two-body modes",
      true);
   static SwitchOption interfaceTwoBodyOnlyNo
     (interfaceTwoBodyOnly,
      "No",
      "Use all modes",
      false);
   
   static Parameter<ModelGenerator,double> interfaceMinimumBR
     ("MinimumBR",
      "The minimum branching fraction to include",
      &ModelGenerator::brMin_, 1e-6, 0.0, 1.0,
      false, false, Interface::limited);
 
   static Switch<ModelGenerator,unsigned int> interfaceDecayOutput
     ("DecayOutput",
      "Option to control the output of the decay mode information",
      &ModelGenerator::decayOutput_, 1, false, false);
   static SwitchOption interfaceDecayOutputNone
     (interfaceDecayOutput,
      "None",
      "No output",
      0);
   static SwitchOption interfaceDecayOutputPlain
     (interfaceDecayOutput,
      "Plain",
      "Default plain text output",
      1);
   static SwitchOption interfaceDecayOutputSLHA
     (interfaceDecayOutput,
      "SLHA",
      "Output in the Susy Les Houches Accord format",
      2);
 
   static Parameter<ModelGenerator,double> interfaceMinimumWidthFraction
     ("MinimumWidthFraction",
      "Minimum fraction of the particle's mass the width can be"
      " for the off-shell treatment.",
      &ModelGenerator::minWidth_, 1e-6, 1e-15, 1.,
      false, false, Interface::limited);
 
   static Parameter<ModelGenerator,double> interfaceHowMuchOffShell
     ("HowMuchOffShell",
      "The multiple of the particle's width by which it is allowed to be off-shell",
      &ModelGenerator::howOffShell_, 5., 0.0, 100.,
      false, false, Interface::limited);
 
 }
 
 namespace {
+  
   /// Helper function for sorting by mass
   inline bool massIsLess(tcPDPtr a, tcPDPtr b) {
     return a->mass() < b->mass();
   }
 
   // Helper function to find minimum possible mass of a particle
   inline Energy minimumMass(tcPDPtr parent) {
     Energy output(Constants::MaxEnergy);
     for(set<tDMPtr>::const_iterator dit = parent->decayModes().begin();
 	dit != parent->decayModes().end(); ++dit) {
       Energy outMass(ZERO);
       for(unsigned int ix=0;ix<(**dit).orderedProducts().size();++ix) {
 	outMass += (**dit).orderedProducts()[ix]->massMin();
       }
       output = min(output,outMass);
     }
     return output;
   }
 }
 
 void ModelGenerator::doinit() {
   useMe();
   Interfaced::doinit();
   // make sure the model is initialized
   Ptr<Herwig::StandardModel>::pointer model 
     = dynamic_ptr_cast<Ptr<Herwig::StandardModel>::pointer>(generator()->standardModel());
   model->init();
   // and the vertices
   for(size_t iv = 0; iv < model->numberOfVertices(); ++iv)
     model->vertex(iv)->init();
   // uniq and sort DecayParticles list by mass
   set<PDPtr> tmp(particles_.begin(),particles_.end());
   particles_.assign(tmp.begin(),tmp.end());
   sort(particles_.begin(),particles_.end(),massIsLess);
   //create decayers and decaymodes (if necessary)
   if( _theDecayConstructor ) {
     _theDecayConstructor->init();
     _theDecayConstructor->createDecayers(particles_,brMin_);
   }
 
   // write out decays with spin correlations
   ostream & os = CurrentGenerator::current().misc();
   ofstream ofs;
   if ( decayOutput_ > 1 ) {
     string filename 
       = CurrentGenerator::current().filename() + "-BR.spc";
     ofs.open(filename.c_str());
   }
 
   if(decayOutput_!=0) {
     if(decayOutput_==1) {
       os << "# The decay modes listed below will have spin\n"
 	  << "# correlations included when they are generated.\n#\n#";
     }
     else {
       ofs << "#  Herwig decay tables in SUSY Les Houches accord format\n";
       ofs << "Block DCINFO                           # Program information\n";
       ofs << "1   Herwig          # Decay Calculator\n";
       ofs << "2   " << generator()->strategy()->versionstring() 
 	  << "     # Version number\n";
     }
   }
   //create mass and width generators for the requested particles
   set<PDPtr> offShell;
   if( Offsel_ == 0 ) offShell = set<PDPtr>(offshell_.begin() ,offshell_.end() );
   else               offShell = set<PDPtr>(particles_.begin(),particles_.end());
   
   for(PDVector::iterator pit = particles_.begin(); 
       pit != particles_.end(); ++pit) {
     tPDPtr parent = *pit;
     // Check decays for ones where quarks cannot be put on constituent
     // mass-shell
     checkDecays(parent);
     parent->reset();
     // Now switch off the modes if needed
     for(DecaySet::const_iterator it=parent->decayModes().begin();
 	it!=parent->decayModes().end();++it) {
       if( _theDecayConstructor->disableDecayMode((**it).tag()) ) {
 	DMPtr mode = *it;
 	generator()->preinitInterface(mode, "Active", "set", "No");
 	if(mode->CC()) {
 	  DMPtr CCmode = mode->CC();
 	  generator()->preinitInterface(CCmode, "Active", "set", "No");
 	}
       }
     }
     parent->update();
     if( parent->CC() ) parent->CC()->synchronize();
     if( parent->decaySelector().empty() ) {
       parent->stable(true);
       parent->width(ZERO);
       parent->widthCut(ZERO);
       parent->massGenerator(tGenericMassGeneratorPtr());
       parent->widthGenerator(tGenericWidthGeneratorPtr());
     }
     else {
       if(parent->mass()*minWidth_>parent->width()) {
 	parent->massGenerator(tGenericMassGeneratorPtr());
 	parent->widthGenerator(tGenericWidthGeneratorPtr());
       }
       else {
 	if( offShell.find(*pit) != offShell.end() ) {
 	  createWidthGenerator(*pit);
 	}
 	else {
 	  parent->massGenerator(tGenericMassGeneratorPtr());
 	  parent->widthGenerator(tGenericWidthGeneratorPtr());
 	}
       }
 
     }
     // set the offshellness 
     Energy minMass = minimumMass(parent);
     Energy offShellNess = howOffShell_*parent->width();
     if(minMass>parent->mass()-offShellNess) {
       offShellNess = parent->mass()-minMass;
     }
     parent->widthCut(offShellNess);
     
     if( parent->massGenerator() ) {
 
       parent->massGenerator()->reset();
       if(decayOutput_==1)
 	os << "# " <<parent->PDGName() << " will be considered off-shell.\n#\n";
     }
     if( parent->widthGenerator() ) parent->widthGenerator()->reset();
   }
   // loop again to initialise mass and width generators
   // switch off modes and write output
   for(PDVector::iterator pit = particles_.begin();
       pit != particles_.end(); ++pit) {
     tPDPtr parent = *pit;
     if(parent->widthGenerator())
       parent->widthGenerator()->init();
     if(parent->massGenerator())
       parent->massGenerator()->init();
     // output the modes if needed
     if( !parent->decaySelector().empty() ) {
       if ( decayOutput_ == 2 )
 	writeDecayModes(ofs, parent);
       else
 	writeDecayModes(os, parent);
     }
   }
 
   //Now construct hard processes given that we know which
   //objects have running widths
   for(unsigned int ix=0;ix<hardProcessConstructors_.size();++ix) {
     hardProcessConstructors_[ix]->init();
     hardProcessConstructors_[ix]->constructDiagrams();
   }
 }
 
 void ModelGenerator::checkDecays(PDPtr parent) {
   if( parent->stable() ) {
     if(parent->coloured())
       cerr << "Warning: No decays for coloured particle " << parent->PDGName() << "\n\n" 
 	   << "have been calcluated in BSM model.\n"
 	   << "This may cause problems in the hadronization phase.\n"
 	   << "You may have forgotten to switch on the decay mode calculation using\n"
 	   << "  set TwoBodyDC:CreateDecayModes Yes\n"
 	   << "  set ThreeBodyDC:CreateDecayModes Yes\n"
 	   << "  set WeakDecayConstructor:CreateDecayModes Yes\n"
 	   << "or the decays of this particle are missing from your\n"
 	   << "input spectrum and decay file in the SLHA format.\n\n";
     return;
   }
   DecaySet::iterator dit = parent->decayModes().begin();
   DecaySet::iterator dend = parent->decayModes().end();
   Energy oldwidth(parent->width()), newwidth(ZERO);
   bool rescalebrat(false);
   double brsum(0.);
   for(; dit != dend; ++dit ) {
     if( !(**dit).on() ) continue;
     Energy release((**dit).parent()->mass());
     tPDVector::const_iterator pit = (**dit).orderedProducts().begin();
     tPDVector::const_iterator pend =(**dit).orderedProducts().end();
     for( ; pit != pend; ++pit ) {
       release -= (**pit).constituentMass();
     }
     if( (**dit).brat() < brMin_ || release < ZERO ) {
       if( release < ZERO )
 	cerr << "Warning: The shower cannot be generated using this decay " 
 	     << (**dit).tag() << " because it is too close to threshold.\nIt "
 	     << "will be switched off and the branching fractions of the "
 	     << "remaining modes rescaled.\n";
       rescalebrat = true;
       generator()->preinitInterface(*dit, "Active", "set", "No");
       generator()->preinitInterface(*dit, "BranchingRatio", 
 				    "set", "0.0");
       DecayIntegratorPtr decayer = dynamic_ptr_cast<DecayIntegratorPtr>((**dit).decayer());
       if(decayer) {
       	generator()->preinitInterface(decayer->fullName(), "Initialize", "set","0");
       }
     }
     else {
       brsum += (**dit).brat();
       newwidth += (**dit).brat()*oldwidth;
     }
   }
   // if no modes left set stable
   if(newwidth==ZERO) {
     parent->stable(true);
     parent->width(ZERO);
     parent->widthCut(ZERO);
     parent->massGenerator(tGenericMassGeneratorPtr());
     parent->widthGenerator(tGenericWidthGeneratorPtr());
   }
   // otherwise rescale if needed
   else if( ( rescalebrat || abs(brsum - 1.) > 1e-12 ) && !parent->decayModes().empty()) {
     dit = parent->decayModes().begin();
     dend = parent->decayModes().end();
     double factor = oldwidth/newwidth;
     brsum = 0.;
     for( ; dit != dend; ++dit ) {
       if( !(**dit).on() ) continue;
       double newbrat = ((**dit).brat())*factor;
       brsum += newbrat;
       ostringstream brf;
       brf << setprecision(13) << newbrat;
       generator()->preinitInterface(*dit, "BranchingRatio",
 				    "set", brf.str());
     }
     parent->width(newwidth);
     if( newwidth > ZERO ) parent->cTau(hbarc/newwidth);
   }
 }
 
 namespace {
   struct DecayModeOrdering {
     bool operator()(tcDMPtr m1, tcDMPtr m2) const {
       if(m1->brat()!=m2->brat()) {
 	return m1->brat()>m2->brat();
       }
       else {
 	if(m1->products().size()==m2->products().size()) {
 	  ParticleMSet::const_iterator it1=m1->products().begin();
 	  ParticleMSet::const_iterator it2=m2->products().begin();
 	  do {
 	    if((**it1).id()!=(**it2).id()) {
 	      return (**it1).id()>(**it2).id();
 	    }
 	    ++it1;
 	    ++it2;
 	  }
 	  while(it1!=m1->products().end()&&
 		it2!=m2->products().end());
 	  assert(false);
 	}
 	else
 	  return m1->products().size()<m2->products().size();
       }
       return false;
     }
   };
 }
 
 void ModelGenerator::writeDecayModes(ostream & os, tcPDPtr parent) const {
   if(decayOutput_==0) return;
   set<tcDMPtr,DecayModeOrdering> modes(parent->decayModes().begin(),
 				       parent->decayModes().end());
   if(decayOutput_==1) {
     os << " Parent: " << parent->PDGName() << "  Mass (GeV): " 
        << parent->mass()/GeV << "  Total Width (GeV): " 
        << parent->width()/GeV << endl;
     os << std::left << std::setw(40) << '#' 
        << std::left << std::setw(20) << "Partial Width/GeV"
        << std::left << std::setw(20) << "BR" << "Yes/No\n";
     for(set<tcDMPtr,DecayModeOrdering>::iterator dit=modes.begin();
 	dit!=modes.end();++dit)
       os << std::left << std::setw(40) << (**dit).tag() 
 	 << std::left << std::setw(20) << (**dit).brat()*parent->width()/GeV 
 	 << std::left << std::setw(20)  << (**dit).brat()
 	 << ((**dit).on() ? "Yes" : "No" ) << '\n';
     os << "#\n#";
   }
   else if(decayOutput_==2) {
     os << "#    \t PDG \t Width\n";
     os << "DECAY\t" << parent->id() << "\t" << parent->width()/GeV << "\t # " << parent->PDGName() << "\n";
     for(set<tcDMPtr,DecayModeOrdering>::iterator dit=modes.begin();
 	dit!=modes.end();++dit) {
       os << "\t" << std::left << std::setw(10) 
 	 << (**dit).brat() << "\t" << (**dit).orderedProducts().size() 
 	 << "\t";
       for(unsigned int ix=0;ix<(**dit).orderedProducts().size();++ix)
 	os << std::right << std::setw(10)
 	   << (**dit).orderedProducts()[ix]->id() ;
       for(unsigned int ix=(**dit).orderedProducts().size();ix<4;++ix)
 	os << "\t";
       os << "# " << (**dit).tag() << "\n";
     }
   }
 }
 
 void ModelGenerator::createWidthGenerator(tPDPtr p) {
   string wn = p->fullName() + string("-WGen");
   string mn = p->fullName() + string("-MGen");
   GenericMassGeneratorPtr mgen = dynamic_ptr_cast<GenericMassGeneratorPtr>
     (generator()->preinitCreate("Herwig::GenericMassGenerator", mn));
   BSMWidthGeneratorPtr wgen = dynamic_ptr_cast<BSMWidthGeneratorPtr>
     (generator()->preinitCreate("Herwig::BSMWidthGenerator", wn));
 
   //set the particle interface
   mgen->particle(p);
   wgen->particle(p);
 
   //set the generator interfaces in the ParticleData object
   generator()->preinitInterface(p, "Mass_generator","set", mn);
   generator()->preinitInterface(p, "Width_generator","set", wn);
   //allow the branching fraction of this particle type to vary
   p->variableRatio(true);
   if( p->CC() ) p->CC()->variableRatio(true);
   
   //initialize the generators
   generator()->preinitInterface(mgen, "Initialize", "set", "Yes");
   generator()->preinitInterface(wgen, "Initialize", "set", "Yes");
 
   string norm = BRnorm_ ? "Yes" : "No";
   generator()->preinitInterface(wgen, "BRNormalize", "set", norm);
   string twob = twoBodyOnly_ ? "Yes" : "No";
   generator()->preinitInterface(wgen, "TwoBodyOnly", "set", twob);
   ostringstream os;
   os << Npoints_;
   generator()->preinitInterface(wgen, "Points", "set", os.str());
   os.str("");
   os << Iorder_;
   generator()->preinitInterface(wgen, "InterpolationOrder", "set",
 				  os.str());
   os.str("");
   os << BWshape_;
   generator()->preinitInterface(mgen, "BreitWignerShape", "set", 
 				  os.str());
 }
diff --git a/Models/General/NBodyDecayConstructorBase.cc b/Models/General/NBodyDecayConstructorBase.cc
--- a/Models/General/NBodyDecayConstructorBase.cc
+++ b/Models/General/NBodyDecayConstructorBase.cc
@@ -1,682 +1,684 @@
 // -*- C++ -*-
 //
 // NBodyDecayConstructorBase.cc is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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.
 //
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the NBodyDecayConstructorBase class.
 //
 
 #include "NBodyDecayConstructorBase.h"
 #include "ThePEG/Repository/EventGenerator.h"
 #include "ThePEG/Repository/Repository.h"
 #include "ThePEG/PDT/DecayMode.h"
 #include "ThePEG/Interface/Parameter.h"
 #include "ThePEG/Interface/Switch.h"
 #include "ThePEG/Interface/RefVector.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "DecayConstructor.h"
 #include "Herwig/Models/StandardModel/StandardModel.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 
 using namespace Herwig; 
 using namespace ThePEG;
 
 void NBodyDecayConstructorBase::persistentOutput(PersistentOStream & os ) const {
   os << init_ << iteration_ << points_ << info_ << decayConstructor_
      << createModes_ << minReleaseFraction_ << maxBoson_ << maxList_
      << removeOnShell_ << excludeEffective_ << includeTopOnShell_
      << excludedVerticesVector_ << excludedVerticesSet_ 
      << excludedParticlesVector_ << excludedParticlesSet_
      << removeFlavourChangingVertices_ << removeSmallVertices_
      << minVertexNorm_;
 }
 
 void NBodyDecayConstructorBase::persistentInput(PersistentIStream & is , int) {
   is >> init_ >> iteration_ >> points_ >> info_ >> decayConstructor_
      >> createModes_ >> minReleaseFraction_ >> maxBoson_ >> maxList_
      >> removeOnShell_ >> excludeEffective_ >> includeTopOnShell_
      >> excludedVerticesVector_ >> excludedVerticesSet_
      >> excludedParticlesVector_ >> excludedParticlesSet_
      >> removeFlavourChangingVertices_ >> removeSmallVertices_
      >> minVertexNorm_;
 }
 
 // Static variable needed for the type description system in ThePEG.
 DescribeAbstractClass<NBodyDecayConstructorBase,Interfaced>
 describeThePEGNBodyDecayConstructorBase("Herwig::NBodyDecayConstructorBase", "Herwig.so");
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeAbstractClass<NBodyDecayConstructorBase,Interfaced>
 describeHerwigNBodyDecayConstructorBase("Herwig::NBodyDecayConstructorBase", "Herwig.so");
 
 void NBodyDecayConstructorBase::Init() {
 
   static ClassDocumentation<NBodyDecayConstructorBase> documentation
     ("The NBodyDecayConstructorBase class is the base class for the automatic"
      "construction of the decay modes");
   
   static Switch<NBodyDecayConstructorBase,bool> interfaceInitializeDecayers
     ("InitializeDecayers",
      "Initialize new decayers",
      &NBodyDecayConstructorBase::init_, true, false, false);
   static SwitchOption interfaceInitializeDecayersInitializeDecayersYes
     (interfaceInitializeDecayers,
      "Yes",
      "Initialize new decayers to find max weights",
      true);
   static SwitchOption interfaceInitializeDecayersNo
     (interfaceInitializeDecayers,
      "No",
      "Use supplied weights for integration",
      false);
   
   static Parameter<NBodyDecayConstructorBase,int> interfaceInitIteration
     ("InitIteration",
      "Number of iterations to optimise integration weights",
      &NBodyDecayConstructorBase::iteration_, 1, 0, 10,
      false, false, true);
 
   static Parameter<NBodyDecayConstructorBase,int> interfaceInitPoints
     ("InitPoints",
      "Number of points to generate when optimising integration",
      &NBodyDecayConstructorBase::points_, 1000, 100, 100000000,
      false, false, true);
 
   static Switch<NBodyDecayConstructorBase,bool> interfaceOutputInfo
     ("OutputInfo",
      "Whether to output information about the decayers",
      &NBodyDecayConstructorBase::info_, false, false, false);
   static SwitchOption interfaceOutputInfoNo
     (interfaceOutputInfo,
      "No",
      "Do not output information regarding the created decayers",
      false);
   static SwitchOption interfaceOutputInfoYes
     (interfaceOutputInfo,
      "Yes",
      "Output information regarding the decayers",
      true);
 
   static Switch<NBodyDecayConstructorBase,bool> interfaceCreateDecayModes
     ("CreateDecayModes",
      "Whether to create the ThePEG::DecayMode objects as well as the decayers",
      &NBodyDecayConstructorBase::createModes_, true, false, false);
   static SwitchOption interfaceCreateDecayModesYes
     (interfaceCreateDecayModes,
      "Yes",
      "Create the ThePEG::DecayMode objects",
      true);
   static SwitchOption interfaceCreateDecayModesNo
     (interfaceCreateDecayModes,
      "No",
      "Only create the Decayer objects",
      false);
 
   static Switch<NBodyDecayConstructorBase,unsigned int> interfaceRemoveOnShell
     ("RemoveOnShell",
      "Remove on-shell diagrams as should be treated as a sequence of 1->2 decays",
      &NBodyDecayConstructorBase::removeOnShell_, 1, false, false);
   static SwitchOption interfaceRemoveOnShellYes
     (interfaceRemoveOnShell,
      "Yes",
      "Remove the diagrams if neither the production of decay or the intermediate"
      " can happen",
      1);
   static SwitchOption interfaceRemoveOnShellNo
     (interfaceRemoveOnShell,
      "No",
      "Never remove the intermediate",
      0);
   static SwitchOption interfaceRemoveOnShellProduction
     (interfaceRemoveOnShell,
      "Production",
      "Remove the diagram if the on-shell production of the intermediate is allowed",
      2);
 
   static RefVector<NBodyDecayConstructorBase,VertexBase> interfaceExcludedVertices
     ("ExcludedVertices",
      "Vertices which are not included in the three-body decayers",
      &NBodyDecayConstructorBase::excludedVerticesVector_,
      -1, false, false, true, true, false);
 
   static RefVector<NBodyDecayConstructorBase,ParticleData> interfaceExcludedIntermediates
     ("ExcludedIntermediates",
      "Excluded intermediate particles",
      &NBodyDecayConstructorBase::excludedParticlesVector_,
      -1, false, false, true, true, false);
 
   static Switch<NBodyDecayConstructorBase,bool> interfaceExcludeEffectiveVertices
     ("ExcludeEffectiveVertices",
      "Exclude effectice vertices",
      &NBodyDecayConstructorBase::excludeEffective_, true, false, false);
   static SwitchOption interfaceExcludeEffectiveVerticesYes
     (interfaceExcludeEffectiveVertices,
      "Yes",
      "Exclude the effective vertices",
      true);
   static SwitchOption interfaceExcludeEffectiveVerticesNo
     (interfaceExcludeEffectiveVertices,
      "No",
      "Don't exclude the effective vertices",
      false);
   
   static Parameter<NBodyDecayConstructorBase,double> interfaceMinReleaseFraction
     ("MinReleaseFraction",
      "The minimum energy release for a three-body decay, as a "
      "fraction of the parent mass.",
      &NBodyDecayConstructorBase::minReleaseFraction_, 1e-3, 0.0, 1.0,
      false, false, Interface::limited);
 
   static Switch<NBodyDecayConstructorBase,unsigned int> interfaceMaximumGaugeBosons
     ("MaximumGaugeBosons",
      "Maximum number of electroweak gauge bosons"
      " to be produced as decay products",
      &NBodyDecayConstructorBase::maxBoson_, 1, false, false);
   static SwitchOption interfaceMaximumGaugeBosonsNone
     (interfaceMaximumGaugeBosons,
      "None",
      "Produce no W/Zs",
      0);
   static SwitchOption interfaceMaximumGaugeBosonsSingle
     (interfaceMaximumGaugeBosons,
      "Single",
      "Produce at most one W/Zs",
      1);
   static SwitchOption interfaceMaximumGaugeBosonsDouble
     (interfaceMaximumGaugeBosons,
      "Double",
      "Produce at most two W/Zs",
      2);
   static SwitchOption interfaceMaximumGaugeBosonsTriple
     (interfaceMaximumGaugeBosons,
      "Triple",
      "Produce at most three W/Zs",
      3);
 
   static Switch<NBodyDecayConstructorBase,unsigned int> interfaceMaximumNewParticles
     ("MaximumNewParticles",
      "Maximum number of particles from the list of "
      "decaying particles to be allowed as decay products",
      &NBodyDecayConstructorBase::maxList_, 0, false, false);
   static SwitchOption interfaceMaximumNewParticlesNone
     (interfaceMaximumNewParticles,
      "None",
      "No particles from the list",
      0);
   static SwitchOption interfaceMaximumNewParticlesOne
     (interfaceMaximumNewParticles,
      "One",
      "A single particle from the list",
      1);
   static SwitchOption interfaceMaximumNewParticlesTwo
     (interfaceMaximumNewParticles,
      "Two",
      "Two particles from the list",
      2);
   static SwitchOption interfaceMaximumNewParticlesThree
     (interfaceMaximumNewParticles,
      "Three",
      "Three particles from the list",
      3);
   static SwitchOption interfaceMaximumNewParticlesFour
     (interfaceMaximumNewParticles,
      "Four",
      "Four particles from the list",
      4);
 
   static Switch<NBodyDecayConstructorBase,bool> interfaceIncludeOnShellTop
     ("IncludeOnShellTop",
      "Include the on-shell diagrams involving t -> bW",
      &NBodyDecayConstructorBase::includeTopOnShell_, false, false, false);
   static SwitchOption interfaceIncludeOnShellTopYes
     (interfaceIncludeOnShellTop,
      "Yes",
      "Inlude them",
      true);
   static SwitchOption interfaceIncludeOnShellTopNo
     (interfaceIncludeOnShellTop,
      "No",
      "Don't include them",
      true);
 
   static Switch<NBodyDecayConstructorBase,bool> interfaceRemoveSmallVertices
     ("RemoveSmallVertices",
      "Remove vertices with norm() below minVertexNorm",
      &NBodyDecayConstructorBase::removeSmallVertices_, false, false, false);
   static SwitchOption interfaceRemoveSmallVerticesYes
     (interfaceRemoveSmallVertices,
      "Yes",
      "Remove them",
      true);
   static SwitchOption interfaceRemoveSmallVerticesNo
     (interfaceRemoveSmallVertices,
      "No",
      "Don't remove them",
      false);
 
   static Parameter<NBodyDecayConstructorBase,double> interfaceMinVertexNorm
     ("MinVertexNorm",
      "Minimum allowed value of the notm() of the vertex if removing small vertices",
      &NBodyDecayConstructorBase::minVertexNorm_, 1e-8, 1e-300, 1.,
      false, false, Interface::limited);
 
   static Switch<NBodyDecayConstructorBase,bool> interfaceRemoveFlavourChangingVertices
     ("RemoveFlavourChangingVertices",
      "Remove flavour changing interactions with the photon and gluon",
      &NBodyDecayConstructorBase::removeFlavourChangingVertices_, false, false, false);
   static SwitchOption interfaceRemoveFlavourChangingVerticesYes
     (interfaceRemoveFlavourChangingVertices,
      "Yes",
      "Remove them",
      true);
   static SwitchOption interfaceRemoveFlavourChangingVerticesNo
     (interfaceRemoveFlavourChangingVertices,
      "No",
      "Don't remove them",
      false);
 
 }
 
 void NBodyDecayConstructorBase::setBranchingRatio(tDMPtr dm, Energy pwidth) {
   // if zero width just set BR to zero
   if(pwidth==ZERO) {
     generator()->preinitInterface(dm, "BranchingRatio","set", "0.");
     generator()->preinitInterface(dm, "OnOff","set", "Off");
     return;
   }
   // Need width and branching ratios for all currently created decay modes
   PDPtr parent = const_ptr_cast<PDPtr>(dm->parent());
   DecaySet modes = parent->decayModes();
   unsigned int nmodes=0;
   for( auto dm : modes ) {
     if(dm->on()) ++nmodes;
   }
   if( nmodes==0 ) return;
   double dmbrat(0.);
   if( nmodes == 1 ) {
     parent->width(pwidth);
     if( pwidth > ZERO ) parent->cTau(hbarc/pwidth);
     dmbrat = 1.;
   }
   else {
     Energy currentwidth(parent->width());
     Energy newWidth(currentwidth + pwidth);
     parent->width(newWidth);
     if( newWidth > ZERO ) parent->cTau(hbarc/newWidth);
     //need to reweight current branching fractions if there are any
     double factor = newWidth > ZERO ? double(currentwidth/newWidth) : 0.;
     for(DecaySet::const_iterator dit = modes.begin(); 
 	dit != modes.end(); ++dit) {
       if( **dit == *dm || !(**dit).on() ) continue; 
       double newbrat = (**dit).brat()*factor;
       ostringstream brf;
       brf << setprecision(13)<< newbrat;
       generator()->preinitInterface(*dit, "BranchingRatio",
 				    "set", brf.str());
     }
     //set brat for current mode
     dmbrat = newWidth > ZERO ? double(pwidth/newWidth) : 0.;
   }
   ostringstream br;
   br << setprecision(13) << dmbrat;
   generator()->preinitInterface(dm, "BranchingRatio",
 				"set", br.str());
 }
 
 void NBodyDecayConstructorBase::setDecayerInterfaces(string fullname) const {
   if( initialize() ) {
     ostringstream value;
     value << initialize();
     generator()->preinitInterface(fullname, "Initialize", "set",
 				  value.str());
     value.str("");
     value << iteration();
     generator()->preinitInterface(fullname, "Iteration", "set",
 				  value.str());
     value.str("");
     value << points();
     generator()->preinitInterface(fullname, "Points", "set",
 				  value.str());
   }
   // QED stuff if needed
   if(decayConstructor()->QEDGenerator())
     generator()->preinitInterface(fullname, "PhotonGenerator", "set",
 				  decayConstructor()->QEDGenerator()->fullName());
   string outputmodes;
   if( info() ) outputmodes = string("Output");
   else outputmodes = string("NoOutput");
   generator()->preinitInterface(fullname, "OutputModes", "set",
 				outputmodes);
 }
 
 void NBodyDecayConstructorBase::doinit() {
   Interfaced::doinit();
   excludedVerticesSet_ = set<VertexBasePtr>(excludedVerticesVector_.begin(),
 					    excludedVerticesVector_.end());
   excludedParticlesSet_ = set<PDPtr>(excludedParticlesVector_.begin(),
 				     excludedParticlesVector_.end());
   if(removeOnShell_==0&&numBodies()>2) 
     generator()->log() << "Warning: Including diagrams with on-shell "
 		       << "intermediates in " << numBodies() << "-body BSM decays, this"
 		       << " can lead to double counting and is not"
 		       << " recommended unless you really know what you are doing\n"
 		       << "This can be switched off using\n set "
 		       << fullName() << ":RemoveOnShell Yes\n"; 
 }
 
 namespace {
 
 void constructIdenticalSwaps(unsigned int depth,
 			     vector<vector<unsigned int> > identical,
 			     vector<unsigned int> channelType,
 			     list<vector<unsigned int> > & swaps) {
   if(depth==0) {
     unsigned int size = identical.size();
     for(unsigned ix=0;ix<size;++ix) {
       for(unsigned int iy=2;iy<identical[ix].size();++iy)
 	identical.push_back(identical[ix]);
     }
   }
   if(depth+1!=identical.size()) {
     constructIdenticalSwaps(depth+1,identical,channelType,swaps);
   }
   else {
     swaps.push_back(channelType);
   }
   for(unsigned int ix=0;ix<identical[depth].size();++ix) {
     for(unsigned int iy=ix+1;iy<identical[depth].size();++iy) {
       vector<unsigned int> newType=channelType;
       swap(newType[identical[depth][ix]],newType[identical[depth][iy]]);
       // at bottom of chain
       if(depth+1==identical.size()) {
 	swaps.push_back(newType);
       }
       else {
 	constructIdenticalSwaps(depth+1,identical,newType,swaps);
       }
     }
   }
 }
 
 void identicalFromSameDecay(unsigned int & loc, const NBVertex & vertex,
 			    vector<vector<unsigned int> > & sameDecay) {
   list<pair<PDPtr,NBVertex> >::const_iterator it = vertex.vertices.begin();
   while(it!=vertex.vertices.end()) {
     if(it->second.incoming) {
       identicalFromSameDecay(loc,it->second,sameDecay);
       ++it;
       continue;
     }
     ++loc;
     long id = it->first->id();
     ++it;
     if(it == vertex.vertices.end()) break;
     if(it->second.incoming) continue;
     if(it->first->id()!=id) continue;
     sameDecay.push_back(vector<unsigned int>());
     sameDecay.back().push_back(loc-1);
     while(it != vertex.vertices.end() 
 	  && !it->second.incoming
 	  && it->first->id()==id) {
       ++loc;
       ++it;
       sameDecay.back().push_back(loc-1);
     }
   };
 }
 
 }
 
-void NBodyDecayConstructorBase::DecayList(const set<PDPtr> & particles) {
+void NBodyDecayConstructorBase::DecayList(const set<PDPtr,MassOrdering> & particles) {
   if( particles.empty() ) return;
   // cast the StandardModel to the Hw++ one to get the vertices
   tHwSMPtr model = dynamic_ptr_cast<tHwSMPtr>(generator()->standardModel());
   unsigned int nv(model->numberOfVertices());
   // loop over the particles and create the modes
-  for(set<PDPtr>::const_iterator ip=particles.begin();
+  for(set<PDPtr,MassOrdering>::const_iterator ip=particles.begin();
       ip!=particles.end();++ip) {
     // get the decaying particle
     tPDPtr parent = *ip;
     if ( Debug::level > 0 )
       Repository::cout() << "Constructing N-body decays for " 
 			 << parent->PDGName() << '\n';
     // first create prototype 1->2 decays
     std::stack<PrototypeVertexPtr> prototypes;
     for(unsigned int iv = 0; iv < nv; ++iv) {
       VertexBasePtr vertex = model->vertex(iv);
       if(excluded(vertex)) continue;
       PrototypeVertex::createPrototypes(parent, vertex, prototypes,this);
     }
     // now expand them into potential decay modes
     list<vector<PrototypeVertexPtr> > modes;
     while(!prototypes.empty()) {
       // get the first prototype from the stack
       PrototypeVertexPtr proto = prototypes.top();
       prototypes.pop();
       // multiplcity too low
       if(proto->npart<numBodies()) {
 	// loop over all vertices and expand
 	for(unsigned int iv = 0; iv < nv; ++iv) {
 	  VertexBasePtr vertex = model->vertex(iv);
 	  if(excluded(vertex) ||
 	     proto->npart+vertex->getNpoint()>numBodies()+2) continue;
 	  PrototypeVertex::expandPrototypes(proto,vertex,prototypes,
 					    excludedParticlesSet_,this);
 	}
       }
       // multiplcity too high disgard
       else if(proto->npart>numBodies()) {
 	continue;
       }
       // right multiplicity
       else {
 	// check it's kinematical allowed for physical masses
 	if( proto->incomingMass() < proto->outgoingMass() ) continue;
 	// and for constituent masses
 	Energy outgoingMass = proto->outgoingConstituentMass();
 	if( proto->incomingMass() < proto->outgoingConstituentMass() ) continue;
 	// remove processes which aren't kinematically allowed within
 	// the release fraction
 	if( proto->incomingMass() - outgoingMass <=
 	    minReleaseFraction_ * proto->incomingMass() ) continue;
 	// check the external particles
 	if(!proto->checkExternal()) continue;
 	// check if first piece on-shell
 	bool onShell = proto->canBeOnShell(removeOnShell(),proto->incomingMass(),true);
 	// special treatment for three-body top decays
 	if(onShell) {
 	  if(includeTopOnShell_ &&
 	     abs(proto->incoming->id())==ParticleID::t && proto->npart==3) {
 	    unsigned int nprimary=0;
 	    bool foundW=false, foundQ=false;
 	    for(OrderedVertices::const_iterator it = proto->outgoing.begin();
 		it!=proto->outgoing.end();++it) {
 	      if(abs(it->first->id())==ParticleID::Wplus)
 		foundW = true;
 	      if(abs(it->first->id())==ParticleID::b ||
 		 abs(it->first->id())==ParticleID::s ||
 		 abs(it->first->id())==ParticleID::d)
 		foundQ = true;
 	      ++nprimary;
 	    }
 	    if(!(foundW&&foundQ&&nprimary==2)) continue;
 	  }
 	  else continue;
 	}
 	// check if should be added to an existing decaymode
 	bool added = false;
 	for(list<vector<PrototypeVertexPtr> >::iterator it=modes.begin();
 	    it!=modes.end();++it) {
 	  // is the same ?
  	  if(!(*it)[0]->sameDecay(*proto)) continue;
 	  // it is the same
 	  added = true;
 	  // check if it is a duplicate
 	  bool already = false;
 	  for(unsigned int iz = 0; iz < (*it).size(); ++iz) {
 	    if( *(*it)[iz] == *proto) {
 	      already = true;
 	      break;
 	    }
 	  }
 	  if(!already) (*it).push_back(proto);
 	  break;
 	}
 	if(!added) modes.push_back(vector<PrototypeVertexPtr>(1,proto));
       }
     }
     // now look at the decay modes
     for(list<vector<PrototypeVertexPtr> >::iterator mit = modes.begin();
 	mit!=modes.end();++mit) {
       // count the number of gauge bosons and particles from the list
       unsigned int nlist(0),nbos(0);
       for(OrderedParticles::const_iterator it=(*mit)[0]->outPart.begin();
 	  it!=(*mit)[0]->outPart.end();++it) {
 	if(abs((**it).id()) == ParticleID::Wplus ||
 	   abs((**it).id()) == ParticleID::Z0) ++nbos;
 	if(particles.find(*it)!=particles.end()) ++nlist;
 	if((**it).CC() && particles.find((**it).CC())!=particles.end()) ++nlist;
       }
       // if too many ignore the mode
       if(nbos > maxBoson_ || nlist > maxList_) continue;
       // translate the prototypes into diagrams
       vector<NBDiagram> newDiagrams;
       double symfac(1.);
       bool possibleOnShell=false;
       for(unsigned int ix=0;ix<(*mit).size();++ix) {
 	symfac = 1.;
 	possibleOnShell |= (*mit)[ix]->possibleOnShell;
 	NBDiagram templateDiagram = NBDiagram((*mit)[ix]);
 	// extract the ordering
 	vector<int> order(templateDiagram.channelType.size());
 	for(unsigned int iz=0;iz<order.size();++iz) {
 	  order[templateDiagram.channelType[iz]-1]=iz;
 	}
 	// find any identical particles
 	vector<vector<unsigned int> > identical;
 	OrderedParticles::const_iterator it=templateDiagram.outgoing.begin();
 	unsigned int iloc=0;
 	while(it!=templateDiagram.outgoing.end()) {
 	  OrderedParticles::const_iterator lt = templateDiagram.outgoing.lower_bound(*it);
 	  OrderedParticles::const_iterator ut = templateDiagram.outgoing.upper_bound(*it);
 	  unsigned int nx=0;
 	  for(OrderedParticles::const_iterator jt=lt;jt!=ut;++jt) {++nx;}
 	  if(nx==1) {
 	    ++it;
 	    ++iloc;
 	  }
 	  else {
 	    symfac *= factorial(nx);
 	    identical.push_back(vector<unsigned int>());
 	    for(OrderedParticles::const_iterator jt=lt;jt!=ut;++jt) {
 	      identical.back().push_back(order[iloc]);
 	      ++iloc;
 	    }
 	    it = ut;
 	  }
 	}
 	// that's it if there outgoing are unqiue
 	if(identical.empty()) {
 	  newDiagrams.push_back(templateDiagram);
 	  continue;
 	}
 	// find any identical particles which shouldn't be swapped
 	unsigned int loc=0;
 	vector<vector<unsigned int> > sameDecay;
 	identicalFromSameDecay(loc,templateDiagram,sameDecay);
 	// compute the swaps
 	list<vector<unsigned int> > swaps;
 	constructIdenticalSwaps(0,identical,templateDiagram.channelType,swaps);
 	// special if identical from same decay
 	if(!sameDecay.empty()) {
 	  for(vector<vector<unsigned int> >::const_iterator st=sameDecay.begin();
 	      st!=sameDecay.end();++st) {
 	    for(list<vector<unsigned int> >::iterator it=swaps.begin();
 		it!=swaps.end();++it) {
 	      for(unsigned int iy=0;iy<(*st).size();++iy) {
 		for(unsigned int iz=iy+1;iz<(*st).size();++iz) {
 		  if((*it)[(*st)[iy]]>(*it)[(*st)[iz]])
 		    swap((*it)[(*st)[iy]],(*it)[(*st)[iz]]);
 		}
 	      }
 	    }
 	  }
 	}
 	// remove any dupliciates
 	for(list<vector<unsigned int> >::iterator it=swaps.begin();
 	    it!=swaps.end();++it) {
 	  for(list<vector<unsigned int> >::iterator jt=it;
 	      jt!=swaps.end();++jt) {
 	    if(it==jt) continue;
 	    bool different=false;
 	    for(unsigned int iz=0;iz<(*it).size();++iz) {
 	      if((*it)[iz]!=(*jt)[iz]) {
 		different = true;
 		break;
 	      }
 	    }
 	    if(!different) {
 	      jt = swaps.erase(jt);
 	      --jt;
 	    }
 	  }
 	}
 	// special for identical decay products
 	if(templateDiagram.vertices.begin()->second.incoming) {
 	  if(   templateDiagram.vertices.begin() ->first ==
 		(++templateDiagram.vertices.begin())->first) {
 	    if(*(   (*mit)[ix]->outgoing.begin() ->second) ==
 	       *((++(*mit)[ix]->outgoing.begin())->second)) {
 	      for(list<vector<unsigned int> >::iterator it=swaps.begin();
 		  it!=swaps.end();++it) {
 		for(list<vector<unsigned int> >::iterator jt=it;
 		    jt!=swaps.end();++jt) {
 		  if(it==jt) continue;
 		  if((*it)[0]==(*jt)[2]&&(*it)[1]==(*jt)[3]) {
 		    jt = swaps.erase(jt);
 		    --jt;
 		  }
 		}
 	      }
 	    }
 	  }
 	}
 	for(list<vector<unsigned int> >::iterator it=swaps.begin();
 	    it!=swaps.end();++it) {
 	  newDiagrams.push_back(templateDiagram);
 	  newDiagrams.back().channelType = *it;
 	}
       }
       // create the decay
       if( Debug::level > 1 ) {
 	generator()->log() << "Mode: ";
 	generator()->log() << (*mit)[0]->incoming->PDGName() << " -> ";
 	for(OrderedParticles::const_iterator it=(*mit)[0]->outPart.begin();
 	    it!=(*mit)[0]->outPart.end();++it)
 	  generator()->log() << (**it).PDGName() << " ";
 	generator()->log() << "\n";
 	generator()->log() << "There are " << (*mit).size() << " diagrams\n";
 	for(unsigned int iy=0;iy<newDiagrams.size();++iy) {
 	  generator()->log() << "Diagram: " << iy << "\n";
 	  generator()->log() << newDiagrams[iy] << "\n";
 	}
       }
       createDecayMode(newDiagrams,possibleOnShell,symfac);
     }
   }
 }
 
 void NBodyDecayConstructorBase::createDecayMode(vector<NBDiagram> &,
 						bool, double) {
+  assert(false);
   throw Exception() << "In NBodyDecayConstructorBase::createDecayMode() which"
-		    << " should have be overridden in an inheriting class"
+		    << " should have be overridden in an inheriting class "
+		    << fullName()
 		    << Exception::abortnow; 
 }
diff --git a/Models/General/NBodyDecayConstructorBase.h b/Models/General/NBodyDecayConstructorBase.h
--- a/Models/General/NBodyDecayConstructorBase.h
+++ b/Models/General/NBodyDecayConstructorBase.h
@@ -1,340 +1,348 @@
 // -*- C++ -*-
 //
 // NBodyDecayConstructorBase.h is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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_NBodyDecayConstructorBase_H
 #define HERWIG_NBodyDecayConstructorBase_H
 //
 // This is the declaration of the NBodyDecayConstructorBase class.
 //
 
 #include "ThePEG/Interface/Interfaced.h"
 #include "ThePEG/Utilities/Exception.h"
 #include "ThePEG/PDT/ParticleData.h"
 #include "NBodyDecayConstructorBase.fh"
 #include "PrototypeVertex.h"
 #include "DecayConstructor.fh"
 
 namespace Herwig {
 
 using namespace ThePEG;
 
 /**
  * This is the base class for NBodyDecayConstructors. An N-body 
  * decay constructor should inherit from this and implement the 
  * DecayList virtual funtcion to create the decays and decayers.  
  *
  * @see \ref NBodyDecayConstructorBaseInterfaces "The interfaces"
  * defined for NBodyDecayConstructor. 
  */
 class NBodyDecayConstructorBase: public Interfaced {
 
 public:
 
+  struct MassOrdering {
+    bool operator()(PDPtr p1, PDPtr p2) const {
+      return p1->mass() < p2->mass() || (p1->mass()==p2->mass() && p1->id()>p2->id());
+    }
+  };
+  
+public:
+
   /**
    * The default constructor.
    */
   NBodyDecayConstructorBase() : 
     init_(true),iteration_(1), points_(1000), info_(false), 
     createModes_(true), removeOnShell_(1), excludeEffective_(true), 
     minReleaseFraction_(1e-3), maxBoson_(1), maxList_(1),
     includeTopOnShell_(false ), removeFlavourChangingVertices_(false),
     removeSmallVertices_(false), minVertexNorm_(1e-8) 
   {}
 
   /**
    * Function used to determine allowed decaymodes, to be implemented
    * in derived class.
    * @param particles vector of ParticleData pointers containing 
    * particles in model
    */
-  virtual void DecayList(const set<PDPtr> & particles);
+  virtual void DecayList(const set<PDPtr,MassOrdering> & particles);
 
   /**
    * Number of outgoing lines. Required for correct ordering.
    */
   virtual unsigned int numBodies() const = 0;
 
   /**
    * Set the pointer to the DecayConstrcutor
    */
   void decayConstructor(tDecayConstructorPtr d) { 
     decayConstructor_ = d;
   }
 
   /**
    *  Remove flavour changing vertices ?
    */
   bool removeFlavourChangingVertices() const {
     return removeFlavourChangingVertices_;
   }
 
   /**
    *  Remove small vertices ?
    */
   bool removeSmallVertices() const {
     return removeSmallVertices_;
   }
 
   /**
    *  Minimum norm for vertex removal
    */
   double minVertexNorm() const {
     return minVertexNorm_;
   }
 
 protected:
   
   /**
    *  Method to set up the decay mode, should be overidden in inheriting class
    */
   virtual void createDecayMode(vector<NBDiagram> & mode,
 			       bool possibleOnShell,
 			       double symfac);
   
 
   /**
    * Set the branching ratio of this mode. This requires 
    * calculating a new width for the decaying particle and reweighting
    * the current branching fractions.
    * @param dm The decaymode for which to set the branching ratio
    * @param pwidth The calculated width of the mode
    */
   void setBranchingRatio(tDMPtr dm, Energy pwidth);
 
   /**
    * Set the interfaces of the decayers depending on the flags stored.
    * @param name Fullname of the decayer in the EventGenerator
    * including the path
    */
   void setDecayerInterfaces(string name) const;
 
   /**
    * Whether to initialize decayers or not
    */
   bool initialize() const { return init_; }
   
   /**
    * Number of iterations if initializing (default 1)
    */
   int iteration() const { return iteration_; }
 
   /**
    * Number of points to do in initialization
    */
   int points() const { return points_; }
 
   /**
    * Whether to output information on the decayers 
    */
   bool info() const { return info_; }
 
   /**
    * Whether to create the DecayModes as well as the Decayer objects 
    */
   bool createDecayModes() const { return createModes_; }
 
   /**
    *  Maximum number of electroweak gauge bosons
    */
   unsigned int maximumGaugeBosons() const { return maxBoson_;}
 
   /**
    *  Maximum number of particles from the list whose decays we are calculating
    */
   unsigned int maximumList() const { return maxList_;}
 
   /**
    *  Minimum energy release fraction
    */ 
   double minimumReleaseFraction() const {return minReleaseFraction_;}
 
   /**
    * Get the pointer to the DecayConstructor object
    */
   tDecayConstructorPtr decayConstructor() const { 
     return decayConstructor_;
   }
 
   /**
    *  Option for on-shell particles
    */
   unsigned int removeOnShell() const { return removeOnShell_; }
 
   /**
    *  Check if a vertex is excluded
    */
   bool excluded(VertexBasePtr vertex) const {
     // skip an effective vertex
     if( excludeEffective_ &&
 	vertex->orderInAllCouplings() != int(vertex->getNpoint())-2)
       return true;
     // check if explicitly forbidden
     return excludedVerticesSet_.find(vertex)!=excludedVerticesSet_.end();
   }
 
 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 Standard Interfaced functions. */
   //@{
   /**
    * 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();
   //@}
 
 private:
 
   /**
    * The assignment operator is private and must never be called.
    * In fact, it should not even be implemented.
    */
   NBodyDecayConstructorBase & operator=(const NBodyDecayConstructorBase &) = delete;
 
 private:
 
   /**
    * Whether to initialize decayers or not
    */
   bool init_;
   
   /**
    * Number of iterations if initializing (default 1)
    */
   int iteration_;
 
   /**
    * Number of points to do in initialization
    */
   int points_;
 
   /**
    * Whether to output information on the decayers 
    */
   bool info_;
 
   /**
    * Whether to create the DecayModes as well as the Decayer objects 
    */
   bool createModes_;
 
   /**
    *  Whether or not to remove on-shell diagrams
    */
   unsigned int removeOnShell_;
 
   /**
    *  Excluded Vertices
    */
   vector<VertexBasePtr> excludedVerticesVector_;
 
   /**
    *  Excluded Vertices
    */
   set<VertexBasePtr> excludedVerticesSet_;
 
   /**
    *  Excluded Particles
    */
   vector<PDPtr> excludedParticlesVector_;
 
   /**
    *  Excluded Particles
    */
   set<PDPtr> excludedParticlesSet_;
 
   /**
    *  Whether or not to exclude effective vertices
    */
   bool excludeEffective_;
   
   /**
    * A pointer to the DecayConstructor object 
    */
   tDecayConstructorPtr decayConstructor_;
 
   /**
    * The minimum energy release for a three-body decay as a 
    * fraction of the parent mass
    */
   double minReleaseFraction_;
 
   /**
    *  Maximum number of EW gauge bosons
    */
   unsigned int maxBoson_;
 
   /**
    *  Maximum number of particles from the decaying particle list
    */
   unsigned int maxList_;
 
   /**
    *  Include on-shell for \f$t\to b W\f$
    */
   bool includeTopOnShell_;
 
   /**
    *  Remove flavour changing vertices ?
    */
   bool removeFlavourChangingVertices_;
 
   /**
    *  Remove small vertices ?
    */
   bool removeSmallVertices_;
 
   /**
    *  Minimum norm for vertex removal
    */
   double minVertexNorm_;
 };
 
   /** An Exception class that can be used by all inheriting classes to
    * indicate a setup problem. */
   class NBodyDecayConstructorError : public Exception {
 
   public:
 
     NBodyDecayConstructorError() : Exception() {}
     
     NBodyDecayConstructorError(const string & str,
 			       Severity sev) : Exception(str,sev)
     {}
   };
 
 }
 
 #endif /* HERWIG_NBodyDecayConstructorBase_H */
diff --git a/Models/General/ThreeBodyDecayConstructor.cc b/Models/General/ThreeBodyDecayConstructor.cc
--- a/Models/General/ThreeBodyDecayConstructor.cc
+++ b/Models/General/ThreeBodyDecayConstructor.cc
@@ -1,377 +1,377 @@
 // -*- C++ -*-
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the ThreeBodyDecayConstructor class.
 //
 
 #include "ThreeBodyDecayConstructor.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Utilities/Debug.h"
 #include "ThePEG/PDT/EnumParticles.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/Interface/RefVector.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "Herwig/Models/StandardModel/StandardModel.h"
 #include "Herwig/Decay/General/GeneralThreeBodyDecayer.h"
 #include "Herwig/PDT/ThreeBodyAllOnCalculator.h"
 #include "ThePEG/PDT/StandardMatchers.h"
 #include "ThePEG/Interface/Switch.h"
 #include "ThePEG/Utilities/Throw.h"
 #include "DecayConstructor.h"
 #include "WeakCurrentDecayConstructor.h"
 
 using namespace Herwig;
 
 IBPtr ThreeBodyDecayConstructor::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr ThreeBodyDecayConstructor::fullclone() const {
   return new_ptr(*this);
 }
 
 void ThreeBodyDecayConstructor::persistentOutput(PersistentOStream & os) const {
   os << interOpt_ << widthOpt_ << intOpt_ << relErr_
      << includeIntermediatePhotons_;
 }
 
 void ThreeBodyDecayConstructor::persistentInput(PersistentIStream & is, int) {
   is  >> interOpt_ >> widthOpt_ >> intOpt_ >> relErr_
       >> includeIntermediatePhotons_;
 }
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeClass<ThreeBodyDecayConstructor,NBodyDecayConstructorBase>
 describeHerwigThreeBodyDecayConstructor("Herwig::ThreeBodyDecayConstructor", "Herwig.so");
 
 void ThreeBodyDecayConstructor::Init() {
 
   static ClassDocumentation<ThreeBodyDecayConstructor> documentation
     ("The ThreeBodyDecayConstructor class constructs the three body decay modes");
 
   static Switch<ThreeBodyDecayConstructor,bool> interfaceIncludeIntermediatePhotons
     ("IncludeIntermediatePhotons",
      "Whether or not ot allow intermediate photons",
      &ThreeBodyDecayConstructor::includeIntermediatePhotons_, false, false, false);
   static SwitchOption interfaceIncludeIntermediatePhotonsYes
     (interfaceIncludeIntermediatePhotons,
      "Yes",
      "Include them",
      true);
   static SwitchOption interfaceIncludeIntermediatePhotonsNo
     (interfaceIncludeIntermediatePhotons,
      "No",
      "Don't include them",
      false);
 
   static Switch<ThreeBodyDecayConstructor,unsigned int> interfaceWidthOption
     ("WidthOption",
      "Option for the treatment of the widths of the intermediates",
      &ThreeBodyDecayConstructor::widthOpt_, 1, false, false);
   static SwitchOption interfaceWidthOptionFixed
     (interfaceWidthOption,
      "Fixed",
      "Use fixed widths",
      1);
   static SwitchOption interfaceWidthOptionRunning
     (interfaceWidthOption,
      "Running",
      "Use running widths",
      2);
   static SwitchOption interfaceWidthOptionZero
     (interfaceWidthOption,
      "Zero",
      "Set the widths to zero",
      3);
 
   static Switch<ThreeBodyDecayConstructor,unsigned int> interfaceIntermediateOption
     ("IntermediateOption",
      "Option for the inclusion of intermediates in the event",
      &ThreeBodyDecayConstructor::interOpt_, 0, false, false);
   static SwitchOption interfaceIntermediateOptionAlways
     (interfaceIntermediateOption,
      "Always",
      "Always include the intermediates",
      1);
   static SwitchOption interfaceIntermediateOptionNever
     (interfaceIntermediateOption,
      "Never",
      "Never include the intermediates",
      2);
   static SwitchOption interfaceIntermediateOptionOnlyIfOnShell
     (interfaceIntermediateOption,
      "OnlyIfOnShell",
      "Only if there are on-shell diagrams",
      0);
 
 
   static Switch<ThreeBodyDecayConstructor,unsigned int> interfaceIntegrationOption
     ("IntegrationOption",
      "Option for the integration of the partial width",
      &ThreeBodyDecayConstructor::intOpt_, 1, false, false);
   static SwitchOption interfaceIntegrationOptionAllPoles
     (interfaceIntegrationOption,
      "AllPoles",
      "Include all potential poles",
      0);
   static SwitchOption interfaceIntegrationOptionShallowestPole
     (interfaceIntegrationOption,
      "ShallowestPole",
      "Only include the  shallowest pole",
      1);
 
   static Parameter<ThreeBodyDecayConstructor,double> interfaceRelativeError
     ("RelativeError",
      "The relative error for the GQ integration",
      &ThreeBodyDecayConstructor::relErr_, 1e-2, 1e-10, 1.,
      false, false, Interface::limited);
 
 }
 
-void ThreeBodyDecayConstructor::DecayList(const set<PDPtr> & particles) {
+void ThreeBodyDecayConstructor::DecayList(const set<PDPtr,MassOrdering> & particles) {
   if( particles.empty() ) return;
   // special for weak decays
   for(unsigned int ix=0;ix<decayConstructor()->decayConstructors().size();++ix) {
     Ptr<Herwig::WeakCurrentDecayConstructor>::pointer 
       weak = dynamic_ptr_cast<Ptr<Herwig::WeakCurrentDecayConstructor>::pointer >
       (decayConstructor()->decayConstructors()[ix]);
     if(!weak) continue;
     weakMassCut_ = max(weakMassCut_,weak->massCut());
   }
   NBodyDecayConstructorBase::DecayList(particles);
 }
 
 GeneralThreeBodyDecayerPtr ThreeBodyDecayConstructor::
 createDecayer(vector<TBDiagram> & diagrams, bool inter,
 	      double symfac) const {
   if(diagrams.empty()) return GeneralThreeBodyDecayerPtr();
   // extract the external particles for the process
   PDPtr incoming = getParticleData(diagrams[0].incoming);
   // outgoing particles
   OrderedParticles outgoing;
   outgoing.insert(getParticleData(diagrams[0].outgoing           ));
   outgoing.insert(getParticleData(diagrams[0].outgoingPair.first ));
   outgoing.insert(getParticleData(diagrams[0].outgoingPair.second));
   // get the object name
   string objectname ("/Herwig/Decays/");
   string classname = DecayerClassName(incoming, outgoing, objectname);
   if(classname=="") return GeneralThreeBodyDecayerPtr();
   // create the object
   GeneralThreeBodyDecayerPtr decayer = 
     dynamic_ptr_cast<GeneralThreeBodyDecayerPtr>
     (generator()->preinitCreate(classname, objectname));
   // set up the decayer and return if doesn't work
   vector<PDPtr> outVector(outgoing.begin(),outgoing.end());
   if(!decayer->setDecayInfo(incoming,outVector,diagrams,symfac))
     return GeneralThreeBodyDecayerPtr();
   // set decayer options from base class
   setDecayerInterfaces(objectname);
   // options for partial width integration
   ostringstream value;
   value << intOpt_;
   generator()->preinitInterface(objectname, "PartialWidthIntegration", "set",
 				value.str());
   value.str("");
   value << relErr_;
   generator()->preinitInterface(objectname, "RelativeError", "set",
 				value.str());
   // set the width option
   value.str("");
   value << widthOpt_;
   generator()->preinitInterface(objectname, "WidthOption", "set", value.str());
   // set the intermediates option
   value.str("");
   value << inter;
   generator()->preinitInterface(objectname, "GenerateIntermediates", "set", 
 				value.str());
   // initialize the decayer
   decayer->init();
   // return the decayer
   return decayer;
 }
 
 string ThreeBodyDecayConstructor::
 DecayerClassName(tcPDPtr incoming, const OrderedParticles & outgoing, 
 		 string & objname) const {
   string classname("Herwig::");
   // spins of the outgoing particles
   unsigned int ns(0),nf(0),nv(0);
   objname += incoming->PDGName() + "2";
   for(OrderedParticles::const_iterator it=outgoing.begin();
       it!=outgoing.end();++it) {
     if     ((**it).iSpin()==PDT::Spin0    ) ++ns;
     else if((**it).iSpin()==PDT::Spin1Half) ++nf;
     else if((**it).iSpin()==PDT::Spin1    ) ++nv;
     objname += (**it).PDGName();
   }
   objname   += "Decayer";
   if(incoming->iSpin()==PDT::Spin0) {
     if(ns==1&&nf==2) classname += "StoSFFDecayer";
     else if(nf==2&&nv==1) classname += "StoFFVDecayer";
     else             classname  = "";
   }
   else if(incoming->iSpin()==PDT::Spin1Half) {
     if(nf==3) classname += "FtoFFFDecayer";
     else if(nf==1&&nv==2) classname += "FtoFVVDecayer";
     else      classname  = "";
   }
   else if(incoming->iSpin()==PDT::Spin1) {
     if(nf==2&&nv==1) classname += "VtoFFVDecayer";
     else classname = "";
   }
   else {
     classname="";
   }
   return classname;
 }
 
 void ThreeBodyDecayConstructor::
 createDecayMode(vector<NBDiagram> & mode,
 		bool possibleOnShell,
 		double symfac) {
   // convert the diagrams from the general to the three body structure
   vector<TBDiagram> diagrams;
   for(unsigned int iy=0;iy<mode.size();++iy) {
     diagrams.push_back(TBDiagram(mode[iy]));
     // determine the type
     diagrams.back().channelType = diagrams.back().intermediate ?
       TBDiagram::Channel(mode[iy].channelType[0]-1) : TBDiagram::fourPoint;
     // remove weak processes simulated using the weak current
     if(weakMassCut_>ZERO && diagrams.back().intermediate &&
        abs(diagrams.back().intermediate->id())==ParticleID::Wplus) {
       Energy deltaM = 
     	getParticleData(diagrams.back().incoming)->mass() - 
     	getParticleData(diagrams.back().outgoing)->mass();
       if(deltaM<weakMassCut_) diagrams.pop_back();
     }
     // remove intermediate photons
     else if(!includeIntermediatePhotons_ && 
 	    diagrams.back().intermediate &&
     	    abs(diagrams.back().intermediate->id())==ParticleID::gamma)
       diagrams.pop_back();
   }
   if(diagrams.empty()) return;
   // check if possible on-shell internal particles
   bool inter = interOpt_ == 1 || (interOpt_ == 0 && possibleOnShell);
   // incoming particle
   tPDPtr inpart = getParticleData(diagrams[0].incoming);
   // outgoing particles
   OrderedParticles outgoing;
   outgoing.insert(getParticleData(diagrams[0].outgoing));
   outgoing.insert(getParticleData(diagrams[0].outgoingPair.first ));
   outgoing.insert(getParticleData(diagrams[0].outgoingPair.second));
   // sort out ordering and labeling of diagrams
   vector<PDPtr> outVector(outgoing.begin(),outgoing.end());
   for(unsigned int ix=0;ix<diagrams.size();++ix) {
     if( ( diagrams[ix].channelType == TBDiagram::channel23 && 
 	  outVector[1]->id() != diagrams[ix].outgoingPair.first) ||
 	( diagrams[ix].channelType == TBDiagram::channel13 && 
 	  outVector[0]->id() != diagrams[ix].outgoingPair.first) || 
 	( diagrams[ix].channelType == TBDiagram::channel12 && 
 	  outVector[0]->id() != diagrams[ix].outgoingPair.first) ) 
       swap(diagrams[ix].outgoingPair.first, diagrams[ix].outgoingPair.second);
   }
   // construct the tag for the decay mode
   string tag = inpart->name() + "->";
   unsigned int iprod=0;
   for(OrderedParticles::const_iterator it = outgoing.begin();
       it != outgoing.end(); ++it) {
     ++iprod;
     tag += (**it).name();
     if(iprod != 3) tag += ",";
   }
   tag += ";";
   tDMPtr dm = generator()->findDecayMode(tag);
   // create mode if needed
   if( createDecayModes() && (!dm || inpart->id() == ParticleID::h0) ) {
     // create the decayer
     GeneralThreeBodyDecayerPtr decayer = createDecayer(diagrams,inter,symfac);
     if(!decayer) {
       if(Debug::level > 1 ) generator()->log() << "Can't create the decayer for " 
 					       << tag << " so mode not created\n";
       return;
     }
     OrderedParticles::const_iterator pit=outgoing.begin();
     tPDPtr pa = *pit; ++pit;
     tPDPtr pb = *pit; ++pit;
     tPDPtr pc = *pit;
     Energy width = 
       decayer->partialWidth(make_pair(inpart,inpart->mass()),
 			    make_pair(pa,pa->mass()) , 
 			    make_pair(pb,pb->mass()) , 
 			    make_pair(pc,pc->mass()));
     if ( Debug::level > 1 )
       generator()->log() << "Partial width is: " << width / GeV << " GeV\n";
     if(width==ZERO) {
       if ( Debug::level > 1 )
 	generator()->log() << "Partial width for " 
 			   << tag << " zero so mode not created \n";
       generator()->preinitRemove(decayer);
       return;
     }
     tDMPtr ndm = generator()->preinitCreateDecayMode(tag);
     if(!ndm)
       throw NBodyDecayConstructorError() 
 	<< "ThreeBodyDecayConstructor::createDecayMode - Needed to create "
 	<< "new decaymode but one could not be created for the tag " 
 	<< tag << Exception::warning;
     generator()->preinitInterface(ndm, "Decayer", "set",
 				  decayer->fullName());
     generator()->preinitInterface(ndm, "Active", "set", "Yes");
     if(!ndm->decayer()) {
       generator()->log() << "Can't set the decayer for " 
 			 << tag << " so mode not created \n";
       return;
     }
     setBranchingRatio(ndm, width);
     if(ndm->brat()<decayConstructor()->minimumBR()) {
       generator()->preinitInterface(decayer->fullName(),
 				    "Initialize", "set","0");
     }
     // incoming particle is now unstable
     inpart->stable(false);
     if(Debug::level > 1 ) {
       generator()->log() << "Calculated partial width for mode "
 			 << tag << " is " << width/GeV << "\n";
     }
   }
   else if( dm ) {
     if(dm->brat()<decayConstructor()->minimumBR()) {
       return;
     }
     if((dm->decayer()->fullName()).find("Mambo") != string::npos) {
       // create the decayer
       GeneralThreeBodyDecayerPtr decayer = createDecayer(diagrams,inter,symfac);
       if(decayer) {
 	generator()->preinitInterface(dm, "Decayer", "set", 
 				      decayer->fullName());
 	// check not zero
 	OrderedParticles::const_iterator pit=outgoing.begin();
 	tPDPtr pa = *pit; ++pit;
 	tPDPtr pb = *pit; ++pit;
 	tPDPtr pc = *pit;
 	Energy width = 
 	  decayer->partialWidth(make_pair(inpart,inpart->mass()),
 				make_pair(pa,pa->mass()) , 
 				make_pair(pb,pb->mass()) , 
 				make_pair(pc,pc->mass()));
 	if(width/(dm->brat()*inpart->width())<1e-10) {
 	  string message = "Herwig calculation of the partial width for the decay mode "
 	    + inpart->PDGName() + " -> " + pa->PDGName() + " " + pb->PDGName() + " " + pc->PDGName()
 	    + " is zero.\n This will cause problems with the calculation of"
 	    + " spin correlations.\n It is probably due to inconsistent parameters"
 	    + " and decay modes being passed to Herwig via the SLHA file.\n"
 	    + " Zeroing the branching ratio for this mode.";
 	  setBranchingRatio(dm,ZERO);
 	  generator()->logWarning(NBodyDecayConstructorError(message,Exception::warning));
 	}
       }
       // incoming particle is now unstable
       inpart->stable(false);
     }
   }
   //update CC mode if it exists
   if( inpart->CC() ) inpart->CC()->synchronize();
 }
diff --git a/Models/General/ThreeBodyDecayConstructor.h b/Models/General/ThreeBodyDecayConstructor.h
--- a/Models/General/ThreeBodyDecayConstructor.h
+++ b/Models/General/ThreeBodyDecayConstructor.h
@@ -1,167 +1,167 @@
 // -*- C++ -*-
 #ifndef HERWIG_ThreeBodyDecayConstructor_H
 #define HERWIG_ThreeBodyDecayConstructor_H
 //
 // This is the declaration of the ThreeBodyDecayConstructor class.
 //
 
 #include "NBodyDecayConstructorBase.h"
 #include "ThePEG/Helicity/Vertex/VertexBase.h"
 #include "TBDiagram.h"
 #include "PrototypeVertex.h"
 #include "Herwig/Decay/General/GeneralThreeBodyDecayer.fh"
 
 namespace Herwig {
 using namespace ThePEG;
 
 using Helicity::VertexBasePtr;
 
 /**
  * The ThreeBodyDecayConstructor class inherits from the dummy base class
  * NBodyDecayConstructorBase and implements the necessary functions in
  * order to create the 3 body decaymodes for a given set of vertices
  * stored in a Model class.
  *
  * @see \ref ThreeBodyDecayConstructorInterfaces "The interfaces"
  * defined for ThreeBodyDecayConstructor.
  * @see NBodyDecayConstructor
  */
 class ThreeBodyDecayConstructor: public NBodyDecayConstructorBase {
 
 public:
 
   /**
    * The default constructor.
    */
   ThreeBodyDecayConstructor() : 
     includeIntermediatePhotons_(false),
     interOpt_(0), widthOpt_(1), weakMassCut_(-GeV),
     intOpt_(1), relErr_(1e-2) {}
 
   /**
    * Function used to determine allowed decaymodes, to be implemented
    * in derived class.
    *@param part vector of ParticleData pointers containing particles in model
    */
-  virtual void DecayList(const set<PDPtr> & part);
+  virtual void DecayList(const set<PDPtr,MassOrdering> & part);
 
   /**
    * Number of outgoing lines. Required for correct ordering.
    */
   virtual unsigned int numBodies() const { return 3; }
 
 protected:
 
   /**
    * Create the decayer
    * @param diagrams The diagrams for the decay
    * @param inter Option for intermediates
    */
   GeneralThreeBodyDecayerPtr createDecayer(vector<TBDiagram> & diagrams, 
 					   bool inter,double symfac) const;
 
   /**
    * Contruct the classname and object name for the Decayer
    * @param incoming The incoming particle
    * @param outgoing The decay products
    * @param objname a string containing the default path of the Decayer object
    */  
   string DecayerClassName(tcPDPtr incoming, const OrderedParticles & outgoing, 
 			  string & objname) const;
 
   /**
    *  Create the DecayMode from the diagrams
    * @param diagrams The diagrams
    * @param inter Option for intermediates
    */
   virtual void createDecayMode(vector<NBDiagram> & mode,
 			       bool possibleOnShell,
 			       double symfac);
 
 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;
   //@}
 
 private:
 
   /**
    * The assignment operator is private and must never be called.
    * In fact, it should not even be implemented.
    */
   ThreeBodyDecayConstructor & operator=(const ThreeBodyDecayConstructor &) = delete;
 
 private:
 
   /**
    *  Option for intermediate photons
    */
   bool includeIntermediatePhotons_;
 
   /**
    *  Option for the inclusion of intermediates
    */
   unsigned int interOpt_;
 
   /**
    *  How to treat the widths of the intermediate particles
    */
   unsigned int widthOpt_;
 
   /**
    *  Cut off or decays via the weak current
    */
   Energy weakMassCut_;
 
   /**
    *  Option for the integration to get the partial width
    */
   unsigned int intOpt_;
 
   /**
    *  Relative error for partial width integration
    */
   double relErr_;
 };
 
 }
 
 #endif /* HERWIG_ThreeBodyDecayConstructor_H */
diff --git a/Models/General/TwoBodyDecayConstructor.cc b/Models/General/TwoBodyDecayConstructor.cc
--- a/Models/General/TwoBodyDecayConstructor.cc
+++ b/Models/General/TwoBodyDecayConstructor.cc
@@ -1,446 +1,446 @@
 // -*- C++ -*-
 //
 // TwoBodyDecayConstructor.cc is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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.
 //
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the TwoBodyDecayConstructor class.
 //
 
 #include "TwoBodyDecayConstructor.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/Interface/Reference.h"
 #include "ThePEG/Interface/Switch.h"
 #include "Herwig/Decay/General/GeneralTwoBodyDecayer.h"
 #include "Herwig/Models/StandardModel/StandardModel.h"
 #include "ThePEG/PDT/EnumParticles.h"
 #include "DecayConstructor.h"
 #include "ThePEG/Utilities/Throw.h"
 #include "ThePEG/Utilities/EnumIO.h"
 #include "ThePEG/Helicity/Vertex/AbstractFFVVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractFFSVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractVVSVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractVSSVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractVVTVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractFFTVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractSSTVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractSSSVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractVVVVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractRFSVertex.fh"
 #include "ThePEG/Helicity/Vertex/AbstractRFVVertex.fh"
 #include "VectorCurrentDecayConstructor.h"
 
 using namespace Herwig;
 using ThePEG::Helicity::VertexBasePtr;
 
 IBPtr TwoBodyDecayConstructor::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr TwoBodyDecayConstructor::fullclone() const {
   return new_ptr(*this);
 }
 
 void TwoBodyDecayConstructor::persistentOutput(PersistentOStream & os) const {
   os << alphaQCD_ << alphaQED_ << oenum(inter_);
 }
 
 void TwoBodyDecayConstructor::persistentInput(PersistentIStream & is, int) {
   is  >> alphaQCD_ >> alphaQED_>> ienum(inter_);
 }
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeClass<TwoBodyDecayConstructor,NBodyDecayConstructorBase>
 describeHerwigTwoBodyDecayConstructor("Herwig::TwoBodyDecayConstructor", "Herwig.so");
 
 void TwoBodyDecayConstructor::Init() {
 
   static ClassDocumentation<TwoBodyDecayConstructor> documentation
     ("The TwoBodyDecayConstructor implements to creation of 2 body decaymodes "
      "and decayers that do not already exist for the given set of vertices.");
   
   static Reference<TwoBodyDecayConstructor,ShowerAlpha> interfaceShowerAlphaQCD
     ("AlphaQCD",
      "The coupling for QCD corrections",
      &TwoBodyDecayConstructor::alphaQCD_, false, false, true, false, false);
   
   static Reference<TwoBodyDecayConstructor,ShowerAlpha> interfaceShowerAlphaQED
     ("AlphaQED",
      "The coupling for QED corrections",
      &TwoBodyDecayConstructor::alphaQED_, false, false, true, false, false);
   
   static Switch<TwoBodyDecayConstructor,ShowerInteraction> interfaceInteractions
     ("Interactions",
      "which interactions to include for the hard corrections",
      &TwoBodyDecayConstructor::inter_, ShowerInteraction::QCD, false, false);
   static SwitchOption interfaceInteractionsQCD
     (interfaceInteractions,
      "QCD",
      "QCD Only",
      ShowerInteraction::QCD);
   static SwitchOption interfaceInteractionsQED
     (interfaceInteractions,
      "QED",
      "QED only",
      ShowerInteraction::QED);
   static SwitchOption interfaceInteractionsQCDandQED
     (interfaceInteractions,
      "QCDandQED",
      "Both QCD and QED",
      ShowerInteraction::Both);
 
 }
 
-void TwoBodyDecayConstructor::DecayList(const set<PDPtr> & particles) {
+void TwoBodyDecayConstructor::DecayList(const set<PDPtr,MassOrdering> & particles) {
   // special for weak decays
   for(unsigned int ix=0;ix<decayConstructor()->decayConstructors().size();++ix) {
     Ptr<Herwig::VectorCurrentDecayConstructor>::pointer 
       weak = dynamic_ptr_cast<Ptr<Herwig::VectorCurrentDecayConstructor>::pointer >
       (decayConstructor()->decayConstructors()[ix]);
     if(!weak) continue;
     weakMassCut_ = max(weakMassCut_,weak->massCut());
   }
   if( particles.empty() ) return;
   tHwSMPtr model = dynamic_ptr_cast<tHwSMPtr>(generator()->standardModel());
   unsigned int nv(model->numberOfVertices());
   
-  for(set<PDPtr>::const_iterator ip=particles.begin();
+  for(set<PDPtr,MassOrdering>::const_iterator ip=particles.begin();
       ip!=particles.end();++ip) {
     tPDPtr parent = *ip;
     if ( Debug::level > 0 )
       Repository::cout() << "Constructing 2-body decays for " 
 			 << parent->PDGName() << '\n';
     multiset<TwoBodyDecay> decays;
     for(unsigned int iv = 0; iv < nv; ++iv) {
       if(excluded(model->vertex(iv)) || 
 	 model->vertex(iv)->getNpoint()>3) continue;
       for(unsigned int il = 0; il < 3; ++il) 
 	createModes(parent, model->vertex(iv), il,decays);
     }
     if( !decays.empty() ) createDecayMode(decays);
   }
 }
 
 void TwoBodyDecayConstructor::
 createModes(tPDPtr inpart, VertexBasePtr vertex,
 	    unsigned int list, multiset<TwoBodyDecay> & modes) {
   if( !vertex->isIncoming(inpart) || vertex->getNpoint() != 3 )
     return;
   Energy m1(inpart->mass());
   tPDPtr ccpart = inpart->CC() ? inpart->CC() : inpart;
   long id = ccpart->id();
   tPDVector decaylist = vertex->search(list, ccpart);
   tPDVector::size_type nd = decaylist.size();
   for( tPDVector::size_type i = 0; i < nd; i += 3 ) {
     tPDPtr pa(decaylist[i]), pb(decaylist[i + 1]), pc(decaylist[i + 2]);
     if( pb->id() == id ) swap(pa, pb);
     if( pc->id() == id ) swap(pa, pc);
     //allowed on-shell decay?
     if( m1 <= pb->mass() + pc->mass() ) continue;
     // double counting with current decays?
     if(inpart->iSpin()==PDT::Spin1 && inpart->iCharge()==0 &&
        pb->id()==-pc->id() && abs(pb->id())<=3 && inpart->mass() <= weakMassCut_ ) {
       continue;
     }
     //vertices are defined with all particles incoming
     modes.insert( TwoBodyDecay(inpart,pb, pc, vertex) );
   }
 } 
 
 GeneralTwoBodyDecayerPtr
 TwoBodyDecayConstructor::createDecayer(TwoBodyDecay decay,
 				       vector<VertexBasePtr> vertices) {
   string name;
   using namespace Helicity::VertexType;
   PDT::Spin in   = decay.parent_->iSpin();
   // PDT::Spin out1 = decay.children_.first ->iSpin();
   PDT::Spin out2 = decay.children_.second->iSpin();
   switch(decay.vertex_->getName()) {
   case FFV :
     if(in == PDT::Spin1Half) {
       name = "FFVDecayer";
       if(out2==PDT::Spin1Half)
 	swap(decay.children_.first,decay.children_.second);
     }
     else {
       name = "VFFDecayer";
     }
     break;
   case FFS :
     if(in == PDT::Spin1Half) {
       name = "FFSDecayer";
       if(out2==PDT::Spin1Half)
 	swap(decay.children_.first,decay.children_.second);
     }
     else {
       name = "SFFDecayer";
     }
     break;
   case VVS :
     if(in == PDT::Spin1) {
       name = "VVSDecayer";
       if(out2==PDT::Spin1)
 	swap(decay.children_.first,decay.children_.second);
     }
     else {
       name = "SVVDecayer";
     }
     break;
   case VSS :
     if(in == PDT::Spin1) {
       name = "VSSDecayer";
     }
     else {
       name = "SSVDecayer";
       if(out2==PDT::Spin0)
 	swap(decay.children_.first,decay.children_.second);
     }
     break;
   case VVT :
     name = in==PDT::Spin2 ? "TVVDecayer" : "Unknown";
     break;
   case FFT :
     name = in==PDT::Spin2 ? "TFFDecayer" : "Unknown";
     break;
   case SST :
     name = in==PDT::Spin2 ? "TSSDecayer" : "Unknown";
     break;
   case SSS :
     name = "SSSDecayer";
     break;
   case VVV :
     name = "VVVDecayer";
     break;
   case RFS :
     if(in==PDT::Spin1Half) {
       name = "FRSDecayer";
       if(out2==PDT::Spin3Half)
 	swap(decay.children_.first,decay.children_.second);
     }
     else if(in==PDT::Spin0) {
       name = "SRFDecayer";
       if(out2==PDT::Spin3Half)
 	swap(decay.children_.first,decay.children_.second);
     }
     else {
       name = "Unknown";
     }
     break;
   case RFV :
     if(in==PDT::Spin1Half) {
       name = "FRVDecayer";
       if(out2==PDT::Spin3Half)
 	swap(decay.children_.first,decay.children_.second);
     }
     else
       name = "Unknown";
     break;
   default : Throw<NBodyDecayConstructorError>() 
       << "Error: Cannot assign " << decay.vertex_->fullName() << " to a decayer. " 
       <<  "Decay is " << decay.parent_->PDGName() << " -> "
       << decay.children_.first ->PDGName() << " " 
       << decay.children_.second->PDGName() << Exception::runerror;
   }
   if(name=="Unknown") 
     Throw<NBodyDecayConstructorError>() 
       << "Error: Cannot assign " << decay.vertex_->fullName() << " to a decayer. " 
       <<  "Decay is " << decay.parent_->PDGName() << " -> "
       << decay.children_.first ->PDGName() << " " 
       << decay.children_.second->PDGName() << Exception::runerror;
   ostringstream fullname;
   fullname << "/Herwig/Decays/" << name << "_" << decay.parent_->PDGName() 
 	   << "_" << decay.children_.first ->PDGName() 
 	   << "_" << decay.children_.second->PDGName();
   string classname = "Herwig::" + name;
   GeneralTwoBodyDecayerPtr decayer;
   decayer = dynamic_ptr_cast<GeneralTwoBodyDecayerPtr>
     (generator()->preinitCreate(classname,fullname.str()));
   if(!decayer) 
     Throw<NBodyDecayConstructorError>() 
       << "Error: Cannot assign " << decay.vertex_->fullName() << " to a decayer. " 
       << "Decay is " << decay.parent_->PDGName() << " -> "
       << decay.children_.first ->PDGName() << " " 
       << decay.children_.second->PDGName() << Exception::runerror;
   // set the strong coupling for radiation
   generator()->preinitInterface(decayer, "AlphaS" , "set", alphaQCD_->fullName());
   // set the EM     coupling for radiation
   generator()->preinitInterface(decayer, "AlphaEM", "set", alphaQED_->fullName());
   // set the type of interactions for the correction
   if(inter_==ShowerInteraction::QCD)
     generator()->preinitInterface(decayer, "Interactions", "set", "QCD");
   else if(inter_==ShowerInteraction::QED)
     generator()->preinitInterface(decayer, "Interactions", "set", "QED");
   else
     generator()->preinitInterface(decayer, "Interactions", "set", "QCDandQED");
   // get the vertices for radiation from the external legs
   map<ShowerInteraction,VertexBasePtr> inRad,fourRad;
   vector<map<ShowerInteraction,VertexBasePtr> > outRad(2);
   vector<ShowerInteraction> itemp={ShowerInteraction::QCD,ShowerInteraction::QED};
   for(auto & inter : itemp) {
     inRad[inter] = radiationVertex(decay.parent_,inter);
     outRad[0][inter] = radiationVertex(decay.children_.first ,inter);
     outRad[1][inter] = radiationVertex(decay.children_.second,inter);
     // get any contributing 4 point vertices
     fourRad[inter]   = radiationVertex(decay.parent_,inter, decay.children_);
   }
 
   // set info on decay
   decayer->setDecayInfo(decay.parent_,decay.children_,vertices,
   			inRad,outRad,fourRad);
   // initialised the decayer
   setDecayerInterfaces(fullname.str());
   decayer->init();
   return decayer;
 }
 
 void TwoBodyDecayConstructor::
 createDecayMode(multiset<TwoBodyDecay> & decays) {
   tPDPtr inpart = decays.begin()->parent_;
   for( multiset<TwoBodyDecay>::iterator dit = decays.begin();
        dit != decays.end(); ) {
     TwoBodyDecay mode = *dit;
     // get all the moees with the same in and outgoing particles
     pair<multiset<TwoBodyDecay>::iterator,
 	 multiset<TwoBodyDecay>::iterator> range = decays.equal_range(mode);
     // construct the decay mode
     tPDPtr pb((mode).children_.first), pc((mode).children_.second);
     string tag = inpart->name() + "->" + pb->name() + "," + 
       pc->name() + ";";
     // Does it exist already ?
     tDMPtr dm = generator()->findDecayMode(tag);
     // find the vertices
     vector<VertexBasePtr> vertices;
     for ( multiset<TwoBodyDecay>::iterator dit2 = range.first;
 	  dit2 != range.second; ++dit2) {
       vertices.push_back(dit2->vertex_);
     }
     dit=range.second;
     // now create DecayMode objects that do not already exist      
     if( createDecayModes() && (!dm || inpart->id() == ParticleID::h0) ) {
       tDMPtr ndm = generator()->preinitCreateDecayMode(tag);
       if(ndm) {
 	inpart->stable(false);
 	GeneralTwoBodyDecayerPtr decayer=createDecayer(mode,vertices);
 	if(!decayer) continue;
 	generator()->preinitInterface(ndm, "Decayer", "set",
 				      decayer->fullName());
 	generator()->preinitInterface(ndm, "Active", "set", "Yes");
 	Energy width = 
 	  decayer->partialWidth(make_pair(inpart,inpart->mass()),
 				make_pair(pb,pb->mass()) , 
 				make_pair(pc,pc->mass()));
 	setBranchingRatio(ndm, width);
 	if(width==ZERO || ndm->brat()<decayConstructor()->minimumBR()) {
 	  generator()->preinitInterface(decayer->fullName(),
 					"Initialize", "set","0");
 	}
       }
       else
 	Throw<NBodyDecayConstructorError>() 
 	  << "TwoBodyDecayConstructor::createDecayMode - Needed to create "
 	  << "new decaymode but one could not be created for the tag " 
 	  << tag << Exception::warning;
     }
     else if( dm ) {
       if(dm->brat()<decayConstructor()->minimumBR()) {
 	continue;
       }
       if((dm->decayer()->fullName()).find("Mambo") != string::npos) {
 	inpart->stable(false);
 	GeneralTwoBodyDecayerPtr decayer=createDecayer(mode,vertices);
 	if(!decayer) continue;
 	generator()->preinitInterface(dm, "Decayer", "set", 
 				      decayer->fullName());
 	Energy width = 
 	  decayer->partialWidth(make_pair(inpart,inpart->mass()),
 				make_pair(pb,pb->mass()) , 
 				make_pair(pc,pc->mass()));
 	if(width/(dm->brat()*inpart->width())<1e-10) {
 	  string message = "Herwig calculation of the partial width for the decay mode "
 	    + inpart->PDGName() + " -> " + pb->PDGName() + " " + pc->PDGName()
 	    + " is zero.\n This will cause problems with the calculation of"
 	    + " spin correlations.\n It is probably due to inconsistent parameters"
 	    + " and decay modes being passed to Herwig via the SLHA file.\n"
 	    + " Zeroing the branching ratio for this mode.";
 	  setBranchingRatio(dm,ZERO);
 	  generator()->logWarning(NBodyDecayConstructorError(message,Exception::warning));
 	}
       }
     }
   }
   // update CC mode if it exists
   if( inpart->CC() ) inpart->CC()->synchronize();
 }
 
 VertexBasePtr TwoBodyDecayConstructor::radiationVertex(tPDPtr particle,
 						       ShowerInteraction inter,
 						       tPDPair children) {
   tHwSMPtr model = dynamic_ptr_cast<tHwSMPtr>(generator()->standardModel());
   map<tPDPtr,VertexBasePtr>::iterator rit = radiationVertices_[inter].find(particle);
   tPDPtr cc = particle->CC() ? particle->CC() : particle;
   if(children==tPDPair() && rit!=radiationVertices_[inter].end()) return rit->second;
   unsigned int nv(model->numberOfVertices());
   long bosonID = inter==ShowerInteraction::QCD ? ParticleID::g : ParticleID::gamma;
   tPDPtr gluon = getParticleData(bosonID);
   // look for radiation vertices for incoming and outgoing particles
   for(unsigned int iv=0;iv<nv;++iv) {
     VertexBasePtr vertex = model->vertex(iv);
     // look for 3 point vertices
     if (children==tPDPair()){
       if( !vertex->isIncoming(particle) ||  vertex->getNpoint() != 3 ||
 	  !vertex->isOutgoing(particle) || !vertex->isOutgoing(gluon)) continue;      
       for(unsigned int list=0;list<3;++list) {
 	tPDVector decaylist = vertex->search(list, particle);
 	for( tPDVector::size_type i = 0; i < decaylist.size(); i += 3 ) {
 	  tPDPtr pa(decaylist[i]), pb(decaylist[i + 1]), pc(decaylist[i + 2]);
 	  if( pb->id() == bosonID ) swap(pa, pb);
 	  if( pc->id() == bosonID ) swap(pa, pc);
 	  if( pb->id() != particle->id()) swap(pb, pc);
 	  if( pa->id() != bosonID) continue;
 	  if( pb       != particle)      continue;
 	  if( pc       != cc)            continue;
 	  radiationVertices_[inter][particle] = vertex; 
 	  return vertex;
 	}
       }
     }
     // look for 4 point vertex including a gluon
     else {           
       if( !vertex->isIncoming(particle)       ||  vertex->getNpoint()!=4              ||
       	  !vertex->isOutgoing(children.first) || !vertex->isOutgoing(children.second) || 
 	  !vertex->isOutgoing(gluon)) continue;
       
       for(unsigned int list=0;list<4;++list) {
 	tPDVector decaylist = vertex->search(list, particle);
 	for( tPDVector::size_type i = 0; i < decaylist.size(); i += 4 ) {
 	  tPDPtr pa(decaylist[i]), pb(decaylist[i+1]), pc(decaylist[i+2]), pd(decaylist[i+3]);
 	  // order so that a = g, b = parent
 	  if( pb->id() == bosonID ) swap(pa, pb);
 	  if( pc->id() == bosonID ) swap(pa, pc);
 	  if( pd->id() == bosonID ) swap(pa, pd);
 	  if( pc->id() == particle->id()) swap(pb, pc);
 	  if( pd->id() == particle->id()) swap(pb, pd);
 	  if( pa->id() != bosonID)  continue;
 	  if( pb->id() != particle->id()) continue;
 
 	  if( !((abs(pd->id()) == abs(children. first->id()) &&
 		 abs(pc->id()) == abs(children.second->id())) ||
 		(abs(pc->id()) == abs(children. first->id()) &&
 		 abs(pd->id()) == abs(children.second->id()))))
 	    continue;
 
 	  return vertex;
 	}
       }
     }
   }
   return VertexBasePtr();
 }
 
 
diff --git a/Models/General/TwoBodyDecayConstructor.h b/Models/General/TwoBodyDecayConstructor.h
--- a/Models/General/TwoBodyDecayConstructor.h
+++ b/Models/General/TwoBodyDecayConstructor.h
@@ -1,182 +1,182 @@
 // -*- C++ -*-
 //
 // TwoBodyDecayConstructor.h is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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_TwoBodyDecayConstructor_H
 #define HERWIG_TwoBodyDecayConstructor_H
 //
 // This is the declaration of the TwoBodyDecayConstructor class.
 //
 
 #include "NBodyDecayConstructorBase.h"
 #include "ThePEG/Helicity/Vertex/VertexBase.h"
 #include "Herwig/Decay/General/GeneralTwoBodyDecayer.fh"
 #include "Herwig/Shower/ShowerAlpha.h"
 #include "TwoBodyDecay.h"
 
 namespace Herwig {
 using namespace ThePEG;
 
 using Helicity::VertexBasePtr;
 using Helicity::tVertexBasePtr;
 
 /**
  * The TwoBodyDecayConstructor class inherits from the dummy base class
  * NBodyDecayConstructorBase and implements the necessary functions in
  * order to create the 2 body decay modes for a given set of vertices
  * stored in a Model class.
  *
  * @see \ref TwoBodyDecayConstructorInterfaces "The interfaces"
  * defined for TwoBodyDecayConstructor.
  * @see NBodyDecayConstructor
  **/
 class TwoBodyDecayConstructor: public NBodyDecayConstructorBase {
 
 public:
 
   /**
    * The default constructor.
    */
   TwoBodyDecayConstructor() : inter_(ShowerInteraction::Both), weakMassCut_(-GeV) {
     radiationVertices_[ShowerInteraction::QCD] = map<tPDPtr,VertexBasePtr>();
     radiationVertices_[ShowerInteraction::QED] = map<tPDPtr,VertexBasePtr>();
   }
 
   /**
    * Function used to determine allowed decaymodes
    *@param part vector of ParticleData pointers containing particles in model
    */
-  virtual void DecayList(const set<PDPtr> & part);
+  virtual void DecayList(const set<PDPtr,MassOrdering> & part);
 
   /**
    * Number of outgoing lines. Required for correct ordering.
    */
   virtual unsigned int numBodies() const { return 2; }
 
   
 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;
   //@}
 
 private:
 
   /**
    * The assignment operator is private and must never be called.
    * In fact, it should not even be implemented.
    */
   TwoBodyDecayConstructor & operator=(const TwoBodyDecayConstructor &) = delete;
 
 private:
   
   /** @name Functions to create decayers and decaymodes. */
   //@{
   /**
    * Function to create decays
    * @param inpart Incoming particle 
    * @param vert The vertex to create decays for
    * @param ilist Which list to search
    * @param iv Row number in _theExistingDecayers member
    * @return A vector a decay modes
    */
   void createModes(tPDPtr inpart, VertexBasePtr vert,
 		   unsigned int ilist,
 		   multiset<TwoBodyDecay> & modes);
 
   /**
    * Function to create decayer for specific vertex
    * @param decay decay mode for this decay
    * member variable
    */
   GeneralTwoBodyDecayerPtr createDecayer(TwoBodyDecay decay,
 					 vector<VertexBasePtr> );
 
   /**
    * Create decay mode(s) from given part and decay modes
    * @param decays The vector of decay modes
    * @param decayer The decayer responsible for this decay
    */
   void createDecayMode(multiset<TwoBodyDecay> & decays);
   //@}
 
   /**
    * Get the vertex for QED/QCD radiation
    */
   VertexBasePtr radiationVertex(tPDPtr particle,ShowerInteraction inter,
 				tPDPair children = tPDPair ());
 
 private:
 
   /**
    *  Map of particles and the vertices which generate their QCD
    *  radiation
    */
   map<ShowerInteraction,map<tPDPtr,VertexBasePtr> > radiationVertices_;
 
   /**
    *  Default choice for the strong coupling object for hard QCD radiation
    */
   ShowerAlphaPtr  alphaQCD_;
 
   /**
    *  Default choice for the strong coupling object for hard QED radiation
    */
   ShowerAlphaPtr  alphaQED_;
 
   /**
    *  Which type of corrections to the decays to include
    */
   ShowerInteraction inter_; 
 
   /**
    *  Cut off or decays via the weak current
    */
   Energy weakMassCut_;
   
 };
   
 }
 
 #endif /* HERWIG_TwoBodyDecayConstructor_H */
diff --git a/Models/General/VectorCurrentDecayConstructor.cc b/Models/General/VectorCurrentDecayConstructor.cc
--- a/Models/General/VectorCurrentDecayConstructor.cc
+++ b/Models/General/VectorCurrentDecayConstructor.cc
@@ -1,172 +1,172 @@
 // -*- C++ -*-
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the VectorCurrentDecayConstructor class.
 //
 
 #include "VectorCurrentDecayConstructor.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/EventRecord/Particle.h"
 #include "ThePEG/Repository/UseRandom.h"
 #include "ThePEG/Repository/EventGenerator.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "Herwig/Decay/General/VectorCurrentDecayer.h"
 
 
 namespace {
 struct ParticleOrdering {
   /**
    *  Operator for the ordering
    * @param p1 The first ParticleData object
    * @param p2 The second ParticleData object
    */
   bool operator() (tcPDPtr p1, tcPDPtr p2) const {
     return abs(p1->id()) > abs(p2->id()) ||
       ( abs(p1->id()) == abs(p2->id()) && p1->id() > p2->id() ) ||
       ( p1->id() == p2->id() && p1->fullName() > p2->fullName() );
   }
 };
 }
 
 using namespace Herwig;
 
 IBPtr VectorCurrentDecayConstructor::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr VectorCurrentDecayConstructor::fullclone() const {
   return new_ptr(*this);
 }
 
 void VectorCurrentDecayConstructor::persistentOutput(PersistentOStream & os) const {
   os << ounit(massCut_,GeV) << current_;
 }
 
 void VectorCurrentDecayConstructor::persistentInput(PersistentIStream & is, int) {
   is >> iunit(massCut_,GeV) >> current_;
 }
 
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeClass<VectorCurrentDecayConstructor,NBodyDecayConstructorBase>
   describeHerwigVectorCurrentDecayConstructor("Herwig::VectorCurrentDecayConstructor", "Herwig.so");
 
 void VectorCurrentDecayConstructor::Init() {
 
   static ClassDocumentation<VectorCurrentDecayConstructor> documentation
     ("The VectorCurrentDecayConstructor class constructs the decays of low mass vector bosons"
      " to hadrons via the weak current");
 
   static RefVector<VectorCurrentDecayConstructor,WeakCurrent> interfaceCurrent
     ("Current",
      "The current for the decay mode",
      &VectorCurrentDecayConstructor::current_, -1, false, false, true, false, false);
 
   static Parameter<VectorCurrentDecayConstructor,Energy> interfaceMassCut
     ("MassCut",
      "The maximum mass difference for the decay",
      &VectorCurrentDecayConstructor::massCut_, GeV, 2.0*GeV, 1.0*GeV, 10.0*GeV,
      false, false, Interface::limited);
 
 }
 
 void VectorCurrentDecayConstructor::doinit() {
   NBodyDecayConstructorBase::doinit();
   model_ = dynamic_ptr_cast<Ptr<Herwig::StandardModel>::pointer>(generator()->standardModel());
 }
 
-void VectorCurrentDecayConstructor::DecayList(const set<PDPtr> & particles) {
+void VectorCurrentDecayConstructor::DecayList(const set<PDPtr,MassOrdering> & particles) {
   if( particles.empty() ) return;
   unsigned int nv(model_->numberOfVertices());
   for(PDPtr part : particles) {
     if(part->iSpin()!=PDT::Spin1) continue;
     if(part->iCharge()!=0) continue;
     bool foundD(false),foundU(false),foundS(false);
     if(part->mass()>massCut_) continue;
     for(unsigned int iv = 0; iv < nv; ++iv) {
       VertexBasePtr vertex = model_->vertex(iv);
       if( !vertex->isIncoming(part) || vertex->getNpoint() != 3 ) continue;
       for(unsigned int iloc = 0;iloc < 3; ++iloc) {
 	vector<long> ext = vertex->search(iloc, part->id());
 	if(ext.empty()) continue;
 	for(unsigned int ioff=0;ioff<ext.size();ioff+=3) {
 	  if(iloc!=2) assert(false);
 	  if(abs(ext[ioff])==1 && abs(ext[ioff+1])==1 &&  ext[ioff]==-ext[ioff+1]) {
 	    foundD = true;
 	  }
 	  else if(abs(ext[ioff])==2 && abs(ext[ioff+1])==2 &&  ext[ioff]==-ext[ioff+1]) {
 	    foundU = true;
 	  }
 	  else if(abs(ext[ioff])==3 && abs(ext[ioff+1])==3 &&  ext[ioff]==-ext[ioff+1]) {
 	    foundS = true;
 	  }
 	}
       }
     }
     if(!foundD && !foundU && !foundS) continue;
     for(tWeakCurrentPtr current : current_) {
       current->init();
       for(unsigned int imode=0;imode<current->numberOfModes();++imode) {
 	// get the external particles for this mode
 	int iq(0),ia(0);
 	tPDVector out = current->particles(0,imode,iq,ia);
 	current->decayModeInfo(imode,iq,ia);
 	if(iq==2&&ia==-2) continue;
 	// order the particles
 	bool skip=false;
 	for(unsigned int ix=0;ix<out.size();++ix) {
 	  if(!out[ix]) {
 	    skip=true;
 	    break;
 	  }
 	}
 	if(skip) continue;
 	multiset<tcPDPtr,ParticleOrdering> outgoing(out.begin(),out.end());
 	Energy minMass(ZERO);
 	string tag = part->PDGName() + "->";
 	bool first=false;
 	int charge(0);
 	for(tcPDPtr part : outgoing) {
 	  if(!first)
 	    first=true;
 	  else
 	    tag+=",";
 	  tag+=part->PDGName();
 	  minMass+=part->mass();
 	  charge+=part->iCharge();
 	}
 	tag+=";";
 	if(minMass>part->mass()) continue;
 	if(charge!=0) continue;
 	// create the decayer
 	ostringstream fullname;
 	fullname << "/Herwig/Decays/DMMediator_" << part->PDGName();
 	for(tcPDPtr part : out)
 	  fullname  << "_" << part->PDGName();
 	string classname = "Herwig::VectorCurrentDecayer";
 	VectorCurrentDecayerPtr decayer = dynamic_ptr_cast<VectorCurrentDecayerPtr>
 	  (generator()->preinitCreate(classname,fullname.str()));
 	decayer->setDecayInfo(part,out,current);
 	// // set decayer options from base class
 	// setDecayerInterfaces(fullname.str());
 	// initialize the decayer
 	decayer->init();
 	// calculate the width
 	Energy pWidth = decayer->partialWidth(part,out);
 	if(pWidth<=ZERO) {
 	  generator()->preinitInterface(decayer->fullName(),
 					"Initialize", "set","0");
 	  continue;
 	}
 	tDMPtr ndm = generator()->preinitCreateDecayMode(tag);
 	generator()->preinitInterface(ndm, "Decayer", "set", decayer->fullName());
 	part->stable(false);
 	generator()->preinitInterface(ndm, "Active", "set", "Yes");
 	setBranchingRatio(ndm, pWidth);
       }
     }
   }
 }
diff --git a/Models/General/VectorCurrentDecayConstructor.h b/Models/General/VectorCurrentDecayConstructor.h
--- a/Models/General/VectorCurrentDecayConstructor.h
+++ b/Models/General/VectorCurrentDecayConstructor.h
@@ -1,131 +1,131 @@
 // -*- C++ -*-
 #ifndef Herwig_VectorCurrentDecayConstructor_H
 #define Herwig_VectorCurrentDecayConstructor_H
 //
 // This is the declaration of the VectorCurrentDecayConstructor class.
 //
 
 #include "NBodyDecayConstructorBase.h"
 #include "Herwig/Decay/WeakCurrents/WeakCurrent.h"
 
 namespace Herwig {
 
 using namespace ThePEG;
 
 /**
  * The VectorCurrentDecayConstructor class constructs the decay of low mass vector bosons via the weak currents.
  *
  * @see \ref VectorCurrentDecayConstructorInterfaces "The interfaces"
  * defined for VectorCurrentDecayConstructor.
  */
 class VectorCurrentDecayConstructor: public NBodyDecayConstructorBase {
 
 public:
 
   /**
    * The default constructor.
    */
   VectorCurrentDecayConstructor() : massCut_(2.*GeV)
   {}
   
   /**
    * Function used to determine allowed decaymodes, to be implemented
    * in derived class.
    *@param part vector of ParticleData pointers containing particles in model
    */
-  virtual void DecayList(const set<PDPtr> & part);
+  virtual void DecayList(const set<PDPtr,MassOrdering> & part);
 
   /**
    * Number of outgoing lines. Required for correct ordering (do this one next-to-last)
    */
   virtual unsigned int numBodies() const { return 999; }
 
   /**
    *  Cut off
    */
   Energy massCut() const { return massCut_;}
 
 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;
   //@}
 
 protected:
 
   /** @name Standard Interfaced functions. */
   //@{
   /**
    * 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();
   //@}
 
 private:
 
   /**
    * The assignment operator is private and must never be called.
    * In fact, it should not even be implemented.
    */
   VectorCurrentDecayConstructor & operator=(const VectorCurrentDecayConstructor &) = delete;
 
 private:
 
   /**
    * Model Pointer
    */
   Ptr<Herwig::StandardModel>::pointer model_;
 
   /**
    *  Cut-off on the mass difference
    */
   Energy massCut_;
 
   /**
    *  The current for the mode
    */
   vector<WeakCurrentPtr> current_;
 };
 
 }
 
 #endif /* Herwig_VectorCurrentDecayConstructor_H */
diff --git a/Models/General/WeakCurrentDecayConstructor.cc b/Models/General/WeakCurrentDecayConstructor.cc
--- a/Models/General/WeakCurrentDecayConstructor.cc
+++ b/Models/General/WeakCurrentDecayConstructor.cc
@@ -1,295 +1,295 @@
 // -*- C++ -*-
 //
 // WeakCurrentDecayConstructor.cc is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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.
 //
 //
 // This is the implementation of the non-inlined, non-templated member
 // functions of the WeakCurrentDecayConstructor class.
 //
 
 #include "WeakCurrentDecayConstructor.h"
 #include "ThePEG/Utilities/DescribeClass.h"
 #include "ThePEG/Interface/ClassDocumentation.h"
 #include "ThePEG/Interface/Parameter.h"
 #include "ThePEG/Interface/ParVector.h"
 #include "ThePEG/Interface/RefVector.h"
 #include "ThePEG/Interface/Switch.h"
 #include "ThePEG/Persistency/PersistentOStream.h"
 #include "ThePEG/Persistency/PersistentIStream.h"
 #include "ThePEG/Repository/EventGenerator.h"
 #include "ThePEG/PDT/DecayMode.h"
 #include "ThePEG/Helicity/Vertex/AbstractFFVVertex.fh"
 #include "DecayConstructor.h"
 
 using namespace Herwig;
 using ThePEG::Helicity::VertexBasePtr;
 
 IBPtr WeakCurrentDecayConstructor::clone() const {
   return new_ptr(*this);
 }
 
 IBPtr WeakCurrentDecayConstructor::fullclone() const {
   return new_ptr(*this);
 }
 
 void WeakCurrentDecayConstructor::doinit() {
   NBodyDecayConstructorBase::doinit();
   model_ = dynamic_ptr_cast<Ptr<Herwig::StandardModel>::pointer>(generator()->standardModel());
   unsigned int isize=decayTags_.size();
   if(isize!=_norm .size()||isize!=_current.size())
     throw InitException() << "Invalid sizes for the decay mode vectors in "
 			  << " WeakCurrentDecayConstructor " 
 			  << decayTags_.size() << " " << _norm.size() << " " 
 			  << _current.size() << Exception::runerror;
   // get the particles from the tags
   for(unsigned int ix=0;ix<decayTags_.size();++ix) {
     _current[ix]->init();
     particles_.push_back(vector<tPDPtr>());
     string tag=decayTags_[ix];
     do {
       string::size_type next = min(tag.find(','), tag.find(';'));
       particles_.back().push_back(generator()->findParticle(tag.substr(0,next)));
       if(!particles_.back().back()) 
 	throw Exception() << "Failed to find particle " << tag.substr(0,next)
 			  << " in DecayMode " << decayTags_[ix]
 			  << " in WeakCurrentDecayConstructor::doinit()"
 			  << Exception::runerror;
       if(tag[next]==';') break;
       tag = tag.substr(next+1);
     }
     while(true);
   }
 }
 
 void WeakCurrentDecayConstructor::persistentOutput(PersistentOStream & os) const {
   os << ounit(massCut_,GeV) << decayTags_ << particles_ << _norm << _current;
 }
 
 void WeakCurrentDecayConstructor::persistentInput(PersistentIStream & is, int) {
   is >> iunit(massCut_,GeV) >> decayTags_ >> particles_ >> _norm >> _current;
 }
 
 // The following static variable is needed for the type
 // description system in ThePEG.
 DescribeClass<WeakCurrentDecayConstructor,NBodyDecayConstructorBase>
 describeHerwigWeakCurrentDecayConstructor("Herwig::WeakCurrentDecayConstructor", "Herwig.so");
 
 void WeakCurrentDecayConstructor::Init() {
 
   static ClassDocumentation<WeakCurrentDecayConstructor> documentation
     ("The WeakCurrentDecayConstructor class implemets the decay of BSM particles "
      "to low mass hadronic states using the Weak current");
 
   static ParVector<WeakCurrentDecayConstructor,string> interfaceDecayModes
     ("DecayModes",
      "The decays of the weak current",
      &WeakCurrentDecayConstructor::decayTags_, -1, "", "", "",
      false, false, Interface::nolimits);
 
   static ParVector<WeakCurrentDecayConstructor,double> interfaceNormalisation
     ("Normalisation",
      "The normalisation of the different modes",
      &WeakCurrentDecayConstructor::_norm, -1, 1.0, 0.0, 10.0,
      false, false, Interface::limited);
 
   static RefVector<WeakCurrentDecayConstructor,WeakCurrent> interfaceCurrent
     ("Current",
      "The current for the decay mode",
      &WeakCurrentDecayConstructor::_current, -1, false, false, true, false, false);
 
   static Parameter<WeakCurrentDecayConstructor,Energy> interfaceMassCut
     ("MassCut",
      "The maximum mass difference for the decay",
      &WeakCurrentDecayConstructor::massCut_, GeV, 5.0*GeV, 1.0*GeV, 10.0*GeV,
      false, false, Interface::limited);
 
 }
 
-void WeakCurrentDecayConstructor::DecayList(const set<PDPtr> & part) {
+void WeakCurrentDecayConstructor::DecayList(const set<PDPtr,MassOrdering> & part) {
   if( part.empty() ) return;
   unsigned int nv(model_->numberOfVertices());
-  for(set<PDPtr>::const_iterator ip=part.begin();ip!=part.end();++ip) {
+  for(set<PDPtr,MassOrdering>::const_iterator ip=part.begin();ip!=part.end();++ip) {
     for(unsigned int iv = 0; iv < nv; ++iv) {
       for(unsigned int ilist = 0; ilist < 3; ++ilist) { 
 	vector<TwoBodyDecay> decays =
 	  createModes(*ip, model_->vertex(iv),ilist);
 	if(!decays.empty()) createDecayMode(decays);
       }
     }
   }
 }
   
 vector<TwoBodyDecay> WeakCurrentDecayConstructor::createModes(const PDPtr inpart,
 							      const VertexBasePtr vert,
 							      unsigned int ilist) {
   int id = inpart->id();
   if( !vert->isIncoming(inpart) || vert->getNpoint() != 3 )
     return vector<TwoBodyDecay>();
   Energy m1(inpart->mass());
   vector<tPDPtr> decaylist;
   decaylist = vert->search(ilist,inpart);
   tPDVector::size_type nd = decaylist.size();
   vector<TwoBodyDecay> decays;
   for( tPDVector::size_type i = 0; i < nd; i += 3 ) {
     tPDPtr pa(decaylist[i]), pb(decaylist.at(i + 1)), 
       pc(decaylist.at(i + 2));
     if( pb->id() == id ) swap(pa, pb);
     if( pc->id() == id ) swap(pa, pc);
     //One of the products must be a W
     Energy mp(ZERO);
     if( abs(pb->id()) == ParticleID::Wplus )
       mp = pc->mass();
     else if( abs(pc->id()) == ParticleID::Wplus )
       mp = pb->mass();
     else 
       continue;
     //allowed on-shell decay and passes mass cut
     if( m1 >= pb->mass() + pc->mass() ) continue;
     if( m1 < mp ) continue;
     if( m1 - mp >= massCut_ ) continue;
     //vertices are defined with all particles incoming
     if( pb->CC() ) pb = pb->CC();
     if( pc->CC() ) pc = pc->CC();
     decays.push_back( TwoBodyDecay(inpart,pb, pc, vert) );
     if(abs(decays.back().children_.second->id())!=ParticleID::Wplus)
       swap(decays.back().children_.first,decays.back().children_.second);
     assert(abs(decays.back().children_.second->id())==ParticleID::Wplus);
   }
   return decays;
 }
 
 GeneralCurrentDecayerPtr  WeakCurrentDecayConstructor::createDecayer(PDPtr in, PDPtr out1,
 								     vector<tPDPtr> outCurrent,
 								     VertexBasePtr vertex,
 								     WeakCurrentPtr current) {
   string name;
   using namespace ThePEG::Helicity::VertexType;
   switch(vertex->getName()) {
   case FFV : 
     name = "FFVCurrentDecayer";
     break;
   default :
     ostringstream message;
     message << "Invalid vertex for decays of " << in->PDGName() << " -> " << out1->PDGName() 
 	    << " via weak current " << vertex->fullName() << "\n";
     generator()->logWarning(NBodyDecayConstructorError(message.str(),
 						       Exception::warning));
     return GeneralCurrentDecayerPtr();
   }
   ostringstream fullname;
   fullname << "/Herwig/Decays/" << name << "_" << in->PDGName() << "_"
 	   << out1->PDGName();
   for(unsigned int ix=0;ix<outCurrent.size();++ix)
     fullname  << "_" << outCurrent[ix]->PDGName();
   string classname = "Herwig::" + name;
   GeneralCurrentDecayerPtr decayer = dynamic_ptr_cast<GeneralCurrentDecayerPtr>
     (generator()->preinitCreate(classname,fullname.str()));
   decayer->setDecayInfo(in,out1,outCurrent,vertex,current,massCut_);
   // set decayer options from base class
   setDecayerInterfaces(fullname.str());
   // initialize the decayer
   decayer->init();
   // return the decayer
   return decayer;
 }
 
 void WeakCurrentDecayConstructor::
 createDecayMode(vector<TwoBodyDecay> & decays) {
   assert(!decays.empty());
   for(unsigned int ix = 0; ix < decays.size(); ++ix) {
     PDVector particles(3);
     particles[0] = decays[ix].parent_;
     particles[1] = decays[ix].children_.first ;
     bool Wplus=decays[ix].children_.second->id()==ParticleID::Wplus;
     for(unsigned int iy=0;iy<_current.size();++iy) {
       particles.resize(2);
       vector<tPDPtr> wprod=particles_[iy];
       int icharge=0;
       Energy msum = particles[0]->mass()-particles[1]->mass();
       for(unsigned int iz=0;iz<wprod.size();++iz) {
 	icharge += wprod[iz]->iCharge();
 	msum -=wprod[iz]->mass();
       }
       if(msum<=ZERO) continue;
       bool cc = (Wplus&&icharge==-3)||(!Wplus&&icharge==3);
       OrderedParticles outgoing;
       outgoing.insert(particles[1]);
       for(unsigned int iz=0;iz<wprod.size();++iz) {
  	if(cc&&wprod[iz]->CC())  wprod[iz]=wprod[iz]->CC();
 	outgoing.insert(wprod[iz]);
       }
       // check outgoing particles initialised
       for(unsigned int iz=0;iz<wprod.size();++iz) wprod[iz]->init();
       // create the tag for the decay mode
       string tag = particles[0]->PDGName() + "->";
       OrderedParticles::const_iterator it = outgoing.begin();
       do {
 	tag += (**it).name();
 	++it;
 	if(it!=outgoing.end()) tag +=",";
 	else                   tag +=";";
       }
       while(it!=outgoing.end());
       // find the decay mode
       tDMPtr dm= generator()->findDecayMode(tag);
       if( !dm && createDecayModes() ) {
 	// create the decayer
 	GeneralCurrentDecayerPtr decayer = createDecayer(particles[0],particles[1],
 							 wprod,decays[ix].vertex_,
 							 _current[iy]);
 	if(!decayer) continue;
 	// calculate the width
 	Energy pWidth = _norm[iy]*decayer->partialWidth(particles[0],particles[1],wprod);
 	if(pWidth<=ZERO) {
 	  generator()->preinitInterface(decayer->fullName(),
 					"Initialize", "set","0");
 	  continue;
 	}
 	tDMPtr ndm = generator()->preinitCreateDecayMode(tag);
 	if(!ndm) throw NBodyDecayConstructorError() 
 		   << "WeakCurrentDecayConstructor::createDecayMode - Needed to create "
 		   << "new decaymode but one could not be created for the tag " 
 		   << tag
 		   << Exception::warning;
 	generator()->preinitInterface(ndm, "Decayer", "set",
 				      decayer->fullName());
 	generator()->preinitInterface(ndm, "Active", "set", "Yes");
 	setBranchingRatio(ndm, pWidth);
 	particles[0]->stable(false);
 	if(ndm->brat()<decayConstructor()->minimumBR()) {
 	  generator()->preinitInterface(decayer->fullName(),
 					"Initialize", "set","0");
 	}
       }
       else if (dm) {
 	// create the decayer
 	GeneralCurrentDecayerPtr decayer = createDecayer(particles[0],particles[1],
 							 wprod,decays[ix].vertex_,
 							 _current[iy]);
 	if(!decayer) continue;
 	generator()->preinitInterface(dm, "Decayer", "set", decayer->fullName());
 	particles[0]->stable(false);
 	if(createDecayModes()) {
 	  // calculate the width
 	  Energy pWidth = _norm[iy]*decayer->partialWidth(particles[0],particles[1],wprod);
 	  if(pWidth<=ZERO) {
 	    generator()->preinitInterface(decayer->fullName(),
 					  "Initialize", "set","0");
 	    continue;
 	  }
 	  generator()->preinitInterface(dm, "Active", "set", "Yes");
 	  particles[0]->width(particles[0]->width()*(1.-dm->brat()));
 	  setBranchingRatio(dm, pWidth);
 	}
 	if(dm->brat()<decayConstructor()->minimumBR()) {
 	  generator()->preinitInterface(decayer->fullName(),
 					"Initialize", "set","0");
 	}
       }
     }
   }
 }
diff --git a/Models/General/WeakCurrentDecayConstructor.h b/Models/General/WeakCurrentDecayConstructor.h
--- a/Models/General/WeakCurrentDecayConstructor.h
+++ b/Models/General/WeakCurrentDecayConstructor.h
@@ -1,194 +1,194 @@
 // -*- C++ -*-
 //
 // WeakCurrentDecayConstructor.h is a part of Herwig - A multi-purpose Monte Carlo event generator
 // Copyright (C) 2002-2019 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_WeakCurrentDecayConstructor_H
 #define HERWIG_WeakCurrentDecayConstructor_H
 //
 // This is the declaration of the WeakCurrentDecayConstructor class.
 //
 
 #include "NBodyDecayConstructorBase.h"
 #include "ThePEG/Helicity/Vertex/VertexBase.h"
 #include "Herwig/Decay/General/GeneralCurrentDecayer.fh"
 #include "Herwig/Models/StandardModel/StandardModel.h"
 #include "Herwig/Decay/WeakCurrents/WeakCurrent.h"
 #include "Herwig/Decay/General/GeneralCurrentDecayer.h"
 #include "TwoBodyDecay.h"
 
 namespace Herwig {
 
 using namespace ThePEG;
 
 /**
  * Here is the documentation of the WeakCurrentDecayConstructor class.
  *
  * @see \ref WeakCurrentDecayConstructorInterfaces "The interfaces"
  * defined for WeakCurrentDecayConstructor.
  */
 class WeakCurrentDecayConstructor: public NBodyDecayConstructorBase {
 
 public:
 
   /**
    * The default constructor.
    */
   WeakCurrentDecayConstructor() : massCut_(5.*GeV) {}
   
   /**
    * Function used to determine allowed decaymodes, to be implemented
    * in derived class.
    *@param part vector of ParticleData pointers containing particles in model
    */
-  virtual void DecayList(const set<PDPtr> & part);
+  virtual void DecayList(const set<PDPtr,MassOrdering> & part);
 
   /**
    * Number of outgoing lines. Required for correct ordering (do this one last)
    */
   virtual unsigned int numBodies() const { return 1000; }
 
   /**
    *  Cut off
    */
   Energy massCut() const { return massCut_;}
 
 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;
   //@}
 
 protected:
 
   /** @name Standard Interfaced functions. */
   //@{
   /**
    * 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();
   //@}
 
 private:
 
   /** @name Functions to create decayers and decaymodes. */
   //@{
   /**
    * Function to create decays
    * @param inpart Incoming particle 
    * @param vert The vertex to create decays for
    * @param ilist Which list to search
    * @param iv Row number in _theExistingDecayers member
    * @return vector of ParticleData ptrs
    */
   vector<TwoBodyDecay>
   createModes(const PDPtr inpart,const VertexBasePtr vert,
 	      unsigned int ilist);
 
   /**
    * Function to create decayer for specific vertex
    * @param vert Pointer to vertex 
    * @param icol Integer referring to the colmun in _theExistingDecayers
    * @param ivert Integer referring to the row in _theExistingDecayers
    * member variable
    */
   GeneralCurrentDecayerPtr createDecayer(PDPtr in, PDPtr out1,
 					 vector<tPDPtr> outCurrent,
 					 VertexBasePtr vertex,
 					 WeakCurrentPtr current);
 
   /**
    * Create decay mode(s) from given part and decay modes
    * @param inpart pointer to incoming particle
    * @param decays list of allowed interactions
    * @param decayer The decayer responsible for this decay
    */
   void createDecayMode(vector<TwoBodyDecay> & decays);
   //@}
 
 private:
 
   /**
    * The assignment operator is private and must never be called.
    * In fact, it should not even be implemented.
    */
   WeakCurrentDecayConstructor & operator=(const WeakCurrentDecayConstructor &) = delete;
 
 private:
 
   /**
    * Model Pointer
    */
   Ptr<Herwig::StandardModel>::pointer model_;
 
   /**
    *  Cut-off on the mass difference
    */
   Energy massCut_;
 
   /**
    *  Tags for the modes
    */
   vector<string> decayTags_;
 
   /**
    *  Particles for the mode
    */
   vector<vector<tPDPtr> > particles_;
 
   /**
    *  Normalisation
    */
   vector<double> _norm;
 
   /**
    *  The current for the mode
    */
   vector<WeakCurrentPtr> _current;
 };
 
 }
 
 #endif /* HERWIG_WeakCurrentDecayConstructor_H */
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -1,1753 +1,1759 @@
 Herwig News							 -*- outline -*-
 ================================================================================
 
+* Herwig 7.2.2 release: 2021-01-22
+
+** support for python 3 and gcc 10
+
+** ufo2herwig script is updated to be compatible with python 2 and 3, using --convert option 
+
 * Herwig 7.2.1 release: 2020-04-10
 
 ** vertex position fix for taus in dipole shower events
 
 * Herwig 7.2.0 release: 2019-12-09
 
 ** improvements to the simulation of multiple-parton interactions, including diffractive processes
 
 ** a new model for baryonic colour reconnection
 
 ** spin correlations in both the dipole and angular-ordered parton showers
 
 ** improvements to strangeness production
 
 ** an improved choice of evolution variable in the angular-ordered parton shower
 
 ** support for generic Lorentz structures in BSM models.
 
 * Herwig 7.1.7 release: 2020-04-10
 
 ** vertex position fix for taus in dipole shower events
 
 * Herwig 7.1.6 release: 2019-12-11
 
 ** fix if no W in top in external events
 
 ** vertex position fix for dipole shower events
 
 ** update boost m4
 
 ** add max,min, re, im to functions for ufo conversion
 
 ** comparision operators should be const, issues with C++17, thanks to Ivan Razumov (GENSER)
 
 * Herwig 7.1.5 release: 2019-04-04
 
 ** Add option of producing partons on physically mass shell after the parton shower
    to allow the string model to be used to hadronize events
 
 ** Fixes for template issues and compiler warnings for gcc8,9, icc and clang
 
 ** Fixes to the calculation of W, Z and h widths if decay modes removed
 
 ** Fix typo in FI g to gg dipole.
 
 ** Fix to allow 1 parameter to specify the mass of more than one particle in the UFO converter
 
 ** Fix to partial width calculation of VSS decays
 
 ** Fix the PDF assignment for DIS processes with Matchbox
 
 ** Fix for undecayed W bosons in internal POWHEG gauge boson pair code
 
 ** Update boost detection in configure script
 
 * Herwig 7.1.4 release: 2018-06-28
 
 ** More matrix elements and better handling of BSM physics
 
 ** Fix for spin correlations in angular-ordered shower, effects top decays
 
 ** Allow fixed target collisions
 
 ** various minor fixes
 
 * Herwig 7.1.3 release: 2018-04-05
 
 ** Dipole Shower
 *** Changed default phase space limits
 *** g -> gg splitting function asymmetrized
 *** Initial retune supplied, given the visible changes 
     to LEP observables
 
 ** Added new Baryonic colour reconnection model 
    (arXiv 1710:10906)
 
 ** Added Schuler-Sjostrand Photon PDFs
 
 ** Handling of massless taus from external sources
 
 ** various minor fixes
 
 ** use std::array<> where possible
 
 
 
 * Herwig 7.1.2 release: 2017-11-01
 
 ** Reduction of the default pt cut for QED radiation off leptons.
 
 ** Inputfile changes due to new read mode in ThePEG.
    ThePEG remains in current repo dir when reading input-file/snippet. 
 
 ** Fix for shower scale variations in qtilde shower. 
 
 ** All standard input files now use the tuned intrinsic pt.
 
 ** Remove obsolete input files for various tunes.
 
 ** Fix for Madgraph interface for NLO corrections with recent version.
 
 ** Run file size reduction for processes using madgraph/openloops.
 
 ** Fix in jacobian for massive dipole kinematics.
 
 ** General improvements for UFO model handling.
 
 
 
 * Herwig 7.1.1 release: 2017-07-14
 
 ** Snippets are now all installed
 
 ** Fixed broken ufo2herwig output and LHC-MB.in
 
 ** UFO improvements
 *** More robust SLHA file handling
 *** option of creating diagonal mixing matrices, needed for ATLAS simplfied models
 *** Improved warnings about resetting standard model particles
 *** Fixed certain cases where the wrong lorentz structure was picked in VVS vertices
 
 ** Improved error message for unhandled beam particles
 
 ** Fix for Dipole Shower chain selection
 
 ** Fixed crash in double diffractive delta resonances
 
 
 
 * Herwig 7.1.0 release: 2017-05-19
 
 ** Major new release
    For a more detailed overview and further references please see the 
    release note arXiv:1705.06919
 
 ** NLO multijet merging with the dipole shower
 
 ** A new soft model
 
 ** An interface to EvtGen
 
 ** Improved calculation of mass effects in the dipole shower
 
 ** Top decays in the dipole shower, and NLO corrections to the decay
 
 ** An implementation of the KrkNLO method for simple processes
 
 ** Major restructuring and cleanup of default input files
 
 ** C++11 is now mandatory and heavily used in the code
 
 ** Many smaller bugfixes and improvements
 
 
 
 * Herwig 7.0.4 release: 2016-10-24
 
 ** API
    The high level API is now properly available as a library, providing an
    alternative to the Herwig main program.
 
 ** Dipole shower
    Added nloops() function to the AlphaS classes to return the number of loops
    in the running coupling
 
 ** Matchbox
    Improved error handling and clearer messages
 
 ** BSM models
    Initialize W mass correctly from SLHA file. Improved reading in of decay
    modes if they already exist.
 
 ** Sampling
    Introduced option to reduce reference weight in AlmostUnweighted mode by
    Kappa factor. Useful for processes where full unweighting is infeasible.
 
 ** Qtilde shower
    Better control of scale in splitting functions using the
    SplittingFunction:ScaleChoice interface.
 
 ** Tests
    New NLO fixed-order input files for testing Matchbox in Tests/ExternNLO.
 
 ** Input files
    Set diagonal CKM options consistently. Added TauTauHVertex and MuMuHVertex
    to MatchboxDefaults.
 
 * Herwig 7.0.3 release: 2016-07-21
 
 ** subprocess generation filters
    A number of filters has been implemented to speed up process and diagram
    generation for the case of Standard Model like processes; this is
    particularly helpful for processes involving a large number of electroweak
    combinatorics. See the documentation for more details.
 
 ** fix to directory hierarchy
    A bug in the Herwig-scratch directory hierarchy when integrating with
    different seeds has been fixed.
 
 ** fix for relocating MadGraph generated amplitudes
    The directory and symbolic link structure for MadGraph-built amplitudes has
    been changed to allow for relocation of a run directory to a different file
    system hierarchy.
 
 ** z* variable added to LeptonsJetsAnalysis
    The builtin LeptonsJetsAnalysis has been extented to include the normalized
    relative rapidity z*
 
 ** detuning parameter for shower reweighting
    An efficiency tweak when using the shower reweighting facilities has been
    introduced for the veto algorithms in both the QTilde and the Dipole
    shower. See the documentation for more details.
 
 ** BaryonThreeQuarkModelFormFactor
    A scaling bug in the form factor series expansion was fixed.
 
 * Herwig 7.0.2 release: 2016-04-29
 
 ** Event reweighting
    New option of calculating the weights for the effect of varying the scale
    used in both the default and dipole showers. The method is described in
    arXiv:1605.08256
 
 ** mergegrids mode
    A main mode for the Herwig executable has been added which merges the
    integration grids from parallel runs.
 
 ** NLO Diphoton production
    The NLO matrix elements in the POWHEG approach for diphoton production as
    described in JHEP 1202 (2012) 130, arXiv:1106.3939 have been included as
    MEPP2GammaGammaPowheg.
 
 ** BSM Hard process constructor
    A missing Feynman diagram with a t-channel vector boson has been added to
    the matrix element for vv2ss
 
 ** BSM Decay Modes calculation
    The behaviour of the option to disable decay modes in BSM Models has been
    changed so that the partial width for the ignored modes is now calculated
    and included in the total width, but the branching ratio is set to
    zero. This is more physical than the previous option where the mode was
    t otally ignored and hence not included in the calculation of the width.
 
 ** Mass Generation
    The behaviour of the GenericMassGenerator has been changed so that modes
    which have been disabled are only included in the calculation of the total
    width and not in the partial width used in the numerator of the weight used
    to select the off-shell mass.
 
 ** Boost detection
    Boost could not detect the compiler version for gcc-5.3 and gcc-6.1
 
 * Herwig 7.0.1 release: 2016-01-17
 
 ** Version number written to log file
    The Herwig version number is now included in addition to ThePEG's version.
 
 ** Tau lifetimes
    A bug with lifetimes for hard process Taus is fixed. Thanks to ATLAS
    for the report!
 
 ** Shower FSR retries
    Rare events could take a long time due to an extremely large number
    of FSR retries. These are now capped at a configurable number.
 
 ** Dipole shower
    Reweighting for non-radiating events; fixes for shower profile
    handling; option to downgrade large-Q expansion for alphaS
 
 ** Matchbox builtins
    Added massive currents for q-qbar
 
 ** ShowerAlphaQCD
    can now use user-defined thresholds
 
 ** Input snippets
    W/Z/H on-shell now split into three files; 4-flavour scheme added
 
 ** UFO converter
    The converter now has experimental support for writing out param
    cards of its current settings.
 
 ** LEPJetAnalysis loading fixed
 
 ** Contrib
    HJets++ has moved to a stand-alone project, FxFx has been added
 
 * Herwig 7.0.0 (Herwig++ 3.0.0) release: 2015-12-04
 
 ** Major new release
    A major new release of the Monte Carlo event generator Herwig++ (version
    3.0) is now available. This release marks the end of distinguishing
    Herwig++ and HERWIG development and therefore constitutes the first major
    release of version 7 of the Herwig event generator family. The new version
    features a number of significant improvements to the event simulation,
    including: built-in NLO hard process calculation for all Standard Model
    processes, with matching to both angular ordered and dipole shower modules
    via variants of both subtractive (MC@NLO-type) and multiplicative
    (Powheg-type) algorithms; QED radiation and spin correlations in the
    angular ordered shower; a consistent treatment of perturbative
    uncertainties within the hard process and parton showering, as well as a
    vastly improved documentation. This version includes (for a more detailed
    overview and further references please see the release note
    arXiv:1512.01178):
 
 ** A long list of improvements and fixes for the Matchbox module
 *** includes MC@NLO and Powheg matching to both showers with truncated showering
 
 ** A long list of improvements and fixes for both of the shower modules
 *** includes improvements of numerics issues relevant to 100 TeV pp collisions
 
 ** NLO event simulation and Matchbox development
 *** Interfaces to a number of external libraries
 *** A new workflow for event generation
 *** Electroweak corrections to VV production
 
 ** Parton shower development
 *** QED radiation in the angular ordered shower
 *** Spin correlations in the angular ordered shower
 *** New scale choices in gluon branchings
 
 ** Improvements to event generation workflow
 *** Re-organized and streamlined input files for the new NLO development
 *** A unified treatment of shower and matching uncertainties
 *** New integrator modules featuring parallel integration
 
 ** New default tunes for both shower modules
 
 ** New contrib modules
 *** Electroweak Higgs plus jets production
 *** FxFx merging support
 *** Higgs boson pair production
 
 
 
 * Herwig++-2.7.1 release: 2014-07-07
 
 ** New shower switches to select schemes for momentum reconstruction
 *** QTildeReconstructor:FinalStateReconOption
     has the following options:
 *** Default
     All momenta are rescaled in the rest frame.
 *** MostOffShell
     Put all particles on the new-mass shell and the most off-shell and
     recoiling system are rescaled to ensure 4-momentum is conserved.
 *** Recursive
     Recursively put the most off-shell particle which hasn't yet been
     rescaled on-shell by rescaling the particles and the recoiling
     system.
 *** RestMostOffShell
     The most off-shell is put on shell by rescaling it and the
     recoiling system, the recoiling system is then put on-shell in its
     rest frame.
 *** RestRecursive
     As above, but recursively treat the currently most-off shell
     (only makes a difference for more than 3 partons)
 
 ** Ticket #378: Hadronization of baryon number violating clusters involving diquarks
    Fixed by only considering non-diquarks to be combined in the
    ClusterFinder.
 
 ** UFO converter can now parse SLHA files for parameter settings
    The UFO converter code can now use SLHA files for modifying
    parameters. The first pass "ufo2herwig" produces the model to be
    compiled. For each parameter card, run "slha2herwig" to get the
    matching input file.
 
 ** Fix for systems using lib64
    The repository is now initialized correctly on systems using lib64
    as the library location.
    
 ** Efficiency optimization
    Better allocation of internal vector variables for a noticeable
    speed increase of 10-20% with LHC events.
 
 
 
 * Herwig++-2.7.0 release: 2013-10-28
 
 ** UFO interface to Feynman rules generators
    Herwig++ now includes "ufo2herwig", a tool that automatically
    creates all required files to run a BSM model from a UFO
    directory. The conversion has been extensively tested against
    Feynrules models MSSM, NMSSM, RS, Technicolor,
    and less extensively with most of the
    other models in the Feynrules model database.
    We expect that following this release there will be no further
    hard-coded new physics models added to Herwig++ and that future
    models will be included using the UFO interface.
 
 ** Shower uncertainties
    A first set of scaling parameters to estimate shower uncertainties
    is provided for both the angular ordered as well as the dipole
    shower; they are Evolver:HardScaleFactor and ShowerAlphaQCD:
    RenormalizationScaleFactor. 
 
 ** Rewrite of Matchbox NLO matching
    The NLO matching implementation has been rewritten and is now more
    flexible and consistent. Profile scales are provided for the
    hardest emission both for the dipole shower and matrix element
    correction matching.
 
 ** BLHA2 Interface and new processes
    Matchbox now features a generic BLHA2 interface to one-loop
    amplitude codes and now also includes W and W+jet production as
    well as Higss production in gluon fusion as builtin processes.
 
 ** Impoved dipole shower kinematics parametrization
    The kinematics parametrization for emissions in the dipole shower
    has been made more efficient.
 
 ** W and Z Powheg decays
    Decays of W and Z bosons now use the Powheg decayers by default.
 
 ** Improved treatment of beam remnants
    The handling of beam remnants has been improved in multiple
    contexts, leading to a much lower error rate at p+/p- collisions.
    An additional value "VeryHard" for ClusterFissioner:RemnantOption
    can be used to disable any special treatment of beam remnant
    clusters.
 
 ** New underlying event tune
    Herwig++ now uses tune UE-EE-5-MRST by default. Other related tunes
    can be obtained from the Herwig++ tunes page
 
 ** Improvements in BSM code
    The UFO development identified many sign fixes in rarely used BSM
    vertices; many improvements were made to general decayers, allowing
    four-body decays in BSM for the first time; Powheg is enabled in
    General two-body decayers; and the handling of colour
    sextets has been improved.
 
 ** A new HiggsPair matrix element in Contrib.
 
 ** A new matrix element for single top production.
 
 ** The Higgs mass is now set to 125.9 GeV (from PDG 2013 update).
 
 ** C++-11 testing
    To help with the coming transition to C++-11, we provide the new
    --enable-stdcxx11 configure flag. Please try to test builds with
    this flag enabled and let us know any problems, but do not use this
    in production code yet. In future releases, this flag will be on by
    default.
 
 ** Other changes
 *** Many new Rivet analyses have been included in the Tests directory.
 *** Cleaned Shower header structure; grouped shower parameters into one struct.
 *** The boolean Powheg flag in HwMEBase changed to an enumeration.
 
 
 
 
 * Herwig++-2.6.3 release: 2013-02-22
 
 ** Decay vertex positioning in HepMC output
    Pseudo-vertices that Herwig++ inserts for technical reasons will
    now not contribute to the Lorentz positions of downstream vertices.
    Thanks to ATLAS for the bug report!
 
 ** Updated Rivet tests 
    Herwig's library of Rivet test runs has been brought up-to-date
    with new analyses that were recently published by the Rivet
    collaboration.
 
 
 
 * Herwig++-2.6.2 release: 2013-01-30
 
 ** Fixes for PDF and scale choices in POWHEG events
    Scale settings for MPI and the regular shower are now correct in
    POWHEG events. This should fix reported anomalies in POWHEG jet rates.
    NLO PDFs are now also set consistently in the example input files.
 
 ** Ticket #373: Branching ratio factors in cross-section
    If any decay modes are selectively disabled, setting the following
    post-handler will cause all reported cross-sections to include the
    branching ratio factor(s) from the previous stages correctly:
 
    create Herwig::BranchingRatioReweighter BRreweight
    insert LHCGenerator:EventHandler:PostDecayHandlers 0 BRreweight
 
 ** Anomalous vertices now possible in MEfftoVH
 
 ** Interactive shell does not quit on error
 
 ** Better warning messages for events from inconsistent LHEF files
 
 ** Possible division by zero error fixed in BSM branching ratio calculations
 
 ** Decayer and ME changes to improve checkpointing
    The checkpointing changes in ThePEG 1.8.2 are implemented here, too. Regular
    dump files are consistent now.
 
 
 
 * Herwig++-2.6.1 release: 2012-10-16
 
 ** Configure switches
    The various switches to turn off compilation of BSM models have
    been unified into a single '--disable-models'. A new flag
    '--disable-dipole' can be used to turn off the compilation of the
    Dipole and Matchbox codes.
 
 ** Ticket #348: Search path for repository 'read' command
    The search path for the 'read' command is configurable on the
    command line with the -i and -I switches. By default, the
    installation location is now included in the search path, so that
    'Herwig++ read LEP.in' will work in an empty directory. The current
    working directory will always be searched first. 
    The rarely used "Herwig++ init" command has been made consistent
    with 'read' and 'run' and should now be used without the '-i' flag.
 
 ** Width treatment in BSM
    The width treatment in BSM decay chains has been greatly improved
    and is now switched on by default in the .model files. To get the
    old behaviour, use 
      set /Herwig/NewPhysics/NewModel:WhichOffshell Selected
 
 ** New BSM models
    Little Higgs models with and without T-parity are now available.
 
 ** Resonance photon lifetime
    A lifetime bug affecting decays of pi0 to e+e-X was fixed. The
    virtual photon is not part of the event record anymore.
 
 ** Ticket #371: Hard diffraction FPE
    Herwig++ 2.6.0 introduced a bug into the diffraction code which
    would abort any runs. This is now fixed.
 
 ** O2AlphaS
    Support for setting quark masses different from the particle data
    objects as introduced in ThePEG 1.8.1 has been enabled.
 
 ** Matchbox
    Several improvements and bug fixes are included for
    Matchbox. Amplitudes relevant to pp -> Z+jet and crossed processes
    at NLO are now available, and various scale choices have been added
    in a more flexible way. All subtraction dipoles for massive quarks
    are now included.
 
 ** Dipole shower
    Parameters to perform scale variations in the shower have been
    added to estimate uncertainties. A bug in showering off gg -> h has
    been fixed.
 
 ** Minor fixes
 *** Two broken colour structures in GeneralHardME
 *** Susy Higgs mixing matrix
 *** BaryonFactorizedDecayer out-of-bounds access
 *** Mass values in SimpleLHCAnalysis
 
 
 
 * Herwig++-2.6.0 release: 2012-05-21 (tagged at SVN r7407)
 
 ** New NLO framework
    Matchbox, a flexible and very general framework for performing NLO
    calculations at fixed order or matched to parton showers is
    provided with this release.
 
 ** Dipole shower algorithm
    A first implementation of the coherent dipole shower algorithm by
    Plätzer and Gieseke (arXiv:0909.5593 and arXiv:1109.6256) is
    available.
 
 ** Alternative samplers and the ExSample library
    The ExSample library by Plätzer (arXiv:1108.6182) is shipped along
    with Herwig++ in an extended version. The extended version provides
    SamplerBase objects which can be used alternatively to the default
    ACDCSampler.
 
 ** New BSM models
 *** New colour sextet diquark model
     A colour sextet diquark model has been included, as described in
     Richardson and Winn (arXiv:1108.6154).
 
 *** Models reproducing the CDF t-tbar asymmetry
     Four models that can reproduce the reported t-tbar asymmetry have
     been included. 
     
 *** Zprime
     A simple standard model extension by one additional heavy neutral
     vector boson.
 
 ** Interface to AlpGen, with MLM merging
    The Contrib directory contains a new interface to the AlpGen matrix
    element generator. AlpGen events must be preprocessed with the
    provided AlpGenToLH.exe tool before they can be used. More
    information can be found in the Herwig++ 2.6 release note.
 
 ** HiggsVBF Powheg
    Higgs boson production by vector boson fusion is available at NLO
    in the POWHEG scheme, as described in d'Errico, Richardson
    (arXiv:1106.2983). The Powheg DIS processes were available in
    Herwig++-2.5.2 already.
    
 ** Statistical colour reconnection
    Alternative mechanisms to minimize the colour length Sum(m_clu)
    before the hadronization stage, based on Metropolis and annealing
    algorithms.
 
 ** Energy extrapolation of underlying-event tunes
    To describe underlying-event data at different c.m. energies, the
    energy-dependent parameter pT_min will now be adjusted
    automatically, following a power-law. The new tune parameters are
    the value at 7000 GeV "MPIHandler:pTmin0", and MPIHandler:Power.
 
 ** Ticket #239: Reporting of minimum-bias cross-section
    When simulating minimum-bias events using the MEMinBias matrix
    element, the correct unitarized cross section can now be reported
    via the standard facilities; it is no longer necessary to extract
    it from the .log file of the run. The corresponding functionality
    is enabled by inserting a MPIXSecReweighter object as a
    post-subprocess handler: 
    create Herwig::MPIXSecReweighter MPIXSecReweighter 
    insert LHCHandler:PostSubProcessHandlers 0 MPIXSecReweighter
 
 ** Dependency on 'boost'
    Herwig++ now requires the boost headers to build; if not detected
    in standard locations, specify with the --with-boost configure
    option.
 
 ** Tests directory
    The Tests directory now contains input cards for almost all Rivet
    analyses. A full comparison run can be initiated with 'make tests'.
 
 ** Minor changes
 *** Default LHC energy now 8 TeV
     All LHC-based defaults have now been updated to use 8 TeV as the
     center-of-mass energy.
 
 *** Herwig::ExtraParticleID -> ThePEG::ParticleID
     The namespace for additional particles has been unified into
     ThePEG::ParticleID
 
 *** MEee2VectorMeson
     The e+e- -> vector meson matrix element has moved from Contrib into
     HwMELepton.so
 
 *** SUSY numerics fixes
     Better handling of rare numerical instabilities.
 
 *** YODA output for Rivet
     The built-in histogramming handler can now output data in the YODA
     format used by Rivet.
 
 *** Consistency checks in SLHA file reader
     Better warnings for inconsistent SusyLHA files
 
 *** better colour flow checking for development
 
 ** Bug fixes
 *** Extremely offshell W from top decay
     Numerical improvements for very off-shell W bosons coming from top
     decays.
 
 *** Ticket #367: problems in using SUSY + LHE
     Susy events from Les Houches event files are now handled better.
 
 *** Infinite loop in remnant decayer
     The remnant decayer will now abort after 100 tries.
 
 *** Fix to HiggsVBF LO diagrams 
     The diagram structure of HiggsVBF LO matrix elements has been fixed.
 
 *** LEP thrust fix 
     The calculation of the transverse momentum of a branching from the
     evolution variable in final-state radiation can now be
     changed. While formally a sub-leading choice this enables a better
     description of the thrust distribution in e+e- collisions at
     small values of the thrust. Currently the default behaviour, where
     the cut-off masses are used in the calculation, remains the same
     as previous versions.
 
 
 
 
 * Herwig++-2.5.2 release: 2011-11-01 (tagged at SVN r6928)
 
 ** Optional new jet vetoing model
    The jet vetoing model by Schofield and Seymour (arXiv:1103.4811) is
    available via Evolver:ColourEvolutionMethod,
    PartnerFinder:PartnerMethod and SplittingFunction:SplittingColourMethod.
    The default behaviour is unchanged.
 
 ** MPI tune
    Version 3 of the MPI tunes is now the default. Please note that the
    pT parameter is energy-dependent and needs to be modified when an
    LHC run is not at 7 TeV.
    The latest tunes are always available at 
      http://projects.hepforge.org/herwig/trac/wiki/MB_UE_tunes
 
 ** MPI PDFs
    MPI PDFs can now be controlled independently.
 
 ** Initialization time speedup
    A new BSMModel base class was introduced between StandardModel and
    the BSM model classes. Together with a restructured decay mode
    initialization, this offers significantly faster startup times for
    BSM runs. ThreeBodyDecays can now always be switched on without a
    large speed penalty.
 
 ** Decay mode file
    Decay mode files in the SLHA format can now be read separately in
    any BSM model with 'set Model:DecayFileName filename'
 
 ** Powheg DIS
    Charged- and neutral-current DIS processes implementing the POWHEG
    method are now available.
 
 ** Diffraction models
    Xi cut implemented in PomeronFlux
 
 ** Ticket #352: Colour reconnection fixed in DIS
 
 ** Ticket #353: Improved numerical stability in chargino decays
 
 ** Ticket #358: Infinite loop in top events with pT cut in shower
 
 ** Ticket #361: Problem with duplicate 2-body modes in BSM
 
 ** Tickets #362 / #363: Crashes with baryon number violating models
    Particle decays in SUSY models with RPV now work correctly in the
    colour 8 -> 3,3,3 case. Colour reshuffling now works for RPV
    clusters.
 
 ** Improved Fastjet detection
    The configure step uses fastjet-config to make sure all header file
    paths are seen.
 
 ** Darwin 11 / OS X Lion
    A configure bug was fixed which prevented 'make check' from
    succeeding on OS X Lion.
 
 ** Vertex classes
    The specification of QED / QCD orders has been moved to the vertex
    constructors, to allow ThePEG consistency checks. WWHH vertices in
    MSSM and NMSSM were fixed. Some Leptoquark and UED vertices fixed.
 
 ** Hadronization
    Cleanup of obsolete code.
 
 
 
 * Herwig++-2.5.1 release: 2011-06-24 (tagged at SVN r6609)
 
 ** Example input files at 7 TeV
    All our example input files for LHC now have their beam energy set
    to 7 TeV instead of 14 TeV.
 
 ** Colour reconnection on by default
    The colour reconnection tunes are now the default setup. Version 2
    of the tunes replaces the *-1 tunes, which had a problem with LEP
    event shapes.
 
 ** Run name tags
    Aded possibility to add a tag to the run name when running with the
    '-t' option. One run file can thus be run with different seeds and
    results stored in different output files.
 
 ** Floating point exceptions
    The new command line option -D enables floating point error checking.
 
 ** General improvements to WeakCurrent decays
 
 ** Remnant decayer
    Hardwired gluon mass was removed.
 
 ** WeakCurrentDecayConstructor
    Instead of specifying separate Particle1...Particle5 vectors for
    the decay modes, the new interface DecayModes can be filled with
    decay tags in the standard syntax.
 
 ** BSM: improvements to handling of vertex and model initialisation
 
 ** Powheg Higgs
    Option to use pT or mT as the scale in alphaS and for the
    factorization scale in the PDFs
 
 ** Ticket #337: Tau polarization wrong in charged Higgs decay
 
 ** Ticket #339: Colour flows in GeneralThreeBody Decayers for 3bar -> 8 3bar 1
 
 ** Ticket #340: Crash for resonant zero-width particles
 
 ** Ticket #341: Varying scale for BSM processes
    The scale used is now ResonantProcessConstructor:ScaleFactor or
    TwoToTwoProcessConstructor:ScaleFactor multiplied by sHat.
 
 ** Ticket #346: Chargino decays
    Chargino decayers now automatically switch between the mesonic
    decays for mass differences less than 2 GeV and the normal partonic
    decays above 2 GeV.
 
 ** Ticket #349: Stop by default on input file errors
    The '--exitonerror' flag is now the default behaviour for the
    Herwig++ binary. To switch back to the old behaviour,
    '--noexitonerror' is required.
 
 ** Ticket #351: Four-body stop decays
 
 ** Tested with gcc-4.6
 
 
 
 * Herwig++-2.5.0 release: 2011-02-08 (tagged at SVN r6274)
 
 ** Uses ThePEG-1.7.0
    Herwig++ 2.5.0 requires ThePEG 1.7.0 to benefit from various
    improvements, particularly: handling of diffractive processes;
    respecting LD_LIBRARY_PATH when loading dynamic libraries,
    including LHAPDF; improvements to repository commands for decay
    modes. See ThePEG's NEWS file for more details.
 
 ** POWHEG improvements
 
 *** New POWHEG processes
     Simulation at NLO accuracy using the POWHEG method is now
     available for hadronic diboson production (pp to WW,WZ,ZZ), Higgs
     decays to heavy quarks, and e+e- to two jets or ttbar, including
     full mass dependence.
 
 *** Input file changes
     The input files for setting up POWHEG process simulation have been
     simplified.  See the example files LHC-Powheg.in and TVT-Powheg.in
     for the improved command list.
 
 *** Structural changes
     The POWHEG backend in the shower code has been restructured to
     make future additions easier: PowhegEvolver has merged with
     Evolver; both the matrix element corrections and real corrections
     in the POWHEG scheme are implemented directly in the ME or Decayer
     classes.
 
 ** New processes at leading order
 
 *** Photon initiated processes
     We have added a matrix element for dijet production in gamma
     hadron collisions.
     
 *** Bottom and charm in heavy quark ME
     The option of bottom and charm quarks is now supported for heavy
     quark production in MEHeavyQuark.
 
 ** Colour reconnection
    The cluster hadronization model has been extended by an option to
    reconnect coloured constituents between clusters with a given
    probability. This new model is different from the colour
    reconnection model used in FORTRAN HERWIG, and improves the
    description of minimum bias and underlying event data.
 
 ** Diffractive Processes
    Both single and double diffractive processes are now supported in
    Herwig++. The Pomeron PDF is implemented using a fit to HERA data,
    and a pion PDF can be used to model reggeon flux.
 
 ** BSM physics
 
 *** New models 
     We have added new BSM models, particularly ADD-type extra
     dimension models and the next-to-minimal supersymmetric standard
     model (NMSSM).  Effects of leptoquarks can as well be simulated.
 
 *** Vertex additions
     We have added flavour changing stop interactions (stop -
     neutralino - charm) and gravitino interactions with particular
     emphasis on numerical stability for very light gravitinos.
     Tri-linear Higgs and Higgs-Higgs/Vector-Vector four-vertices are
     available as well.
 
 *** Input file changes
     The SUSY model can now also extract the SLHA information from the
     header of a Les Houches event file: replace the SLHA file name
     in the example input files with the LH file name.
 
 *** Structure
     The backend structure of the HardProcessConstructor has changed,
     to allow easier inclusion of new process constructors. Some 2->3
     BSM scattering processes involving neutral higgs bosons are now
     included. The spin handling has been improved in the background. 
 
 ** Shower splitting code reorganized
    The selection of spin structures has been decoupled from the choice
    of colour structure. This gives more flexibility in implementing
    new splittings. Selected splittings can be disabled in the input
    files.
 
 ** B mixing
    B mixing, and indirect CP violation in the B meson system are
    included now.
    
 ** Looptools
    The Looptools directory has been updated to reflect T.Hahn's
    Looptools 2.6.
 
 ** Contrib changes
    The ROOT interface has been removed as deprecated. The MCPWNLO code
    has temporarily been removed from the Contrib directory as a major
    review of this code is required. Additionally, there are various
    fixes to all other codes shipped in Contrib.
 
 ** DIS improvements
    The momentum reshuffling in DIS events has been improved.
 
 ** mu and nu beams
    mu, nu_e and nu_mu and their antiparticles are now available as
    beam particles. They are all supported in the DIS matrix
    elements. mu+ mu- collisions are supported in the general
    matrix element code for BSM models, but not yet in the hard-coded
    matrix elements for lepton-lepton scattering.
 
 ** Structural changes
 
 *** Inline code
     Inline code has been merged into the header files, .icc files were
     removed.
 
 *** Silent build
     By default, Herwig++ now builds with silent build rules. To get
     the old behaviour, run 'make V=1'.
 
 *** Debug level
     The debug level on the command line will now always have priority.
 
 *** Event counter
     The event counter has been simplified.
 
 *** Interpolator persistency
     Interpolators can now be written persistently.
 
 ** Ticket #307: Momentum violation check in BasicConsistency
    Added parameters AbsoluteMomentumTolerance and
    RelativeMomentumTolerance
 
 ** Example POWHEG input files
    The example input files for Powheg processes now set the NLO
    alpha_S correctly, and are run as part of 'make check'.
 
 ** Truncated shower
    A problem which lead to the truncated shower not being applied in
    some cases has been fixed.
 
 ** Fixes to numerical problems
    Minor problems with values close to zero were fixed in several
    locations.
 
 ** Remove duplicated calculation of event shapes
    An accidental duplication in the calculation of event shapes was
    removed, they are now only calculated once per event. Several other
    minor issues in the event shape calculations have also been fixed.
 
 ** MRST PDFs fixed
    An initialization problem in the internal MRST PDFs was fixed.
 
 ** Vertex scale choice
    The scale in the Vertex classes can now be zero where
    possible.
 
 ** Treatment of -N flag
    The Herwig++ main program now correctly treats the -N flag
    as optional.
 
 ** Numerical stability improved
    The numerical stability in the 'RunningMass' and
    'QTildeReconstructor' classes has been improved.  The
    stability of the boosts in the SOPTHY code for the
    simulation of QED radiation has been improved.
    The accuracy of boosts in the z-direction has been improved to
    fix problems with extremely high p_T partons.
 
 ** Bugfix in initial state splittings
    A bug in the implementation of the PDF weight in initial-state
    qbar -> qbar g  splittings has been fixed.
 
 ** Bugfix in chargino neutralino vertices
    A bug in the 'chi+- chi0 W-+' and charged
    Higgs-sfermions vertices has been fixed.
 
 ** Remove uninitialized variables written to repository
    A number of uninitialised variables which were written to the
    repository have been initialised to zero to avoid problems on some
    systems.
 
 ** Fix to QED radiation in hadronic collisions
    The longitudinal boost of the centre-of-mass frame in hadronic
    collisions is correctly accounted for now in the generation of QED
    radiation.
 
 ** Fix to numerical problems in two-body decays
    Numerical problems have been fixed, which appeared in the rare case
    that the three-momenta of the decay products in two-body decays are
    zero in the rest frame of the decay particle.
 
 ** A problem with forced splittings in the Remnant was fixed.
 
 ** ME correction for W+- decays applied properly
    The matrix element correction for QCD radiation in W+- decays
    which was not being applied is now correctly used.
 
 ** Top quark decays from SLHA file
    The presence of top quark decay modes in SLHA files is now handled
    correctly.
 
 ** Exceptional shower reconstruction kinematics
    Additional protection against problems due to the shower
    reconstruction leading to partons with x>1 has been added.
 
 ** Ordering of particles in BSM processes
    Changes have been made to allow arbitrary ordering of the outgoing
    particles in BSM processes.
 
 ** Bugfixes in tau decays
    Two bugs involving tau decays have been fixed. The wrong masses
    were used in the 'KPiCurrent' class for the scalar form factors
    and a mistake in the selection of decay products lead to
    tau- --> pi0 K- being generated instead of tau- --> eta K-.
 
 ** Avoid crashes in baryon number violating processes.
    To avoid crashes, better protection has been introduced for the
    case where diquarks cannot be formed from the quarks in a
    baryon-number violating process. In addition, the parents of the
    baryon-number violating clusters have been changed to avoid
    problems with the conversion of the events to HepMC.
 
 ** QED radiation in W- decays
    A bug in the 'QEDRadiationHandler' class which resulted
    in no QED radiation being generated in W- decays has been fixed.
 
 ** A number of minor fixes to the SUSY models have been made.
 
 ** Partial width calculations in BSM models  
    A fix for the direction of the incoming particle in the calculation
    of two-body partial widths in BSM models has been made.
 
 ** LoopTools improvements   
    The LoopTools cache is now cleared more frequently to
    reduce the amount of memory used by the particle.
 
 ** Negative gluino masses are now correctly handled.
 
 ** A problem with mixing matrices which are not square has been fixed. 
 
 ** Removed duplicate diagram
    The 'MEee2gZ2ll' class has been fixed to only include the
    photon exchange diagram once rather than twice as previously.
 
 ** Fix for duplicate particles in DecayConstructor
    A problem has been fixed which occurred if the same particle was
    included in the list of DecayConstructor:DecayParticles.
 
 ** Fixes for UED model vertices
    A number of minor problems in the vertices for the UED model have
    been fixed.
 
 ** Include missing symmetry factor
    The missing identical-particle symmetry factor in
    'MEPP2GammaGamma' has been included.
 
 ** Fix floating point problem in top decays
    A floating point problem in the matrix element correction for top
    decays has been fixed.
 
 
 
 * Herwig++-2.4.2 release: 2009-12-11 (tagged at SVN r5022)
 
 ** Ticket #292: Tau decay numerical instability
    The momentum assignment in tau decays contained numerical
    instabilities which have been fixed by postponing the tau decay
    until after the parton shower. A new interface setting
    DecayHandler:Excluded is available to prevent decays in the shower
    step. This is enabled by default for tau only.
 
 ** Ticket #290: Missing MSSM colour structure
    The missing colour structure for gluino -> gluon neutralino was added.
 
 ** Ticket #294: Zero momentum in some decays
    Some rare phase space points lead to zero momentum in two-body
    decays. This has been fixed.
 
 ** Ticket #295: Stability of QED radiation for lepton collider processes
    The numerical stability of QED radiation momenta was improved
    further.
 
 ** Ticket #296: K0 oscillation vertex was wrong
    The oscillation from K0 to K0_L/S now takes place at the production
    vertex of K0.
 
 ** Ticket #289: Undefined variables in repository
    On some system configurations, undefined variables were written to
    the repository. These have been fixed.
 
 ** Fixed QED radiation for hadron processes
    The longitudinal boost of the centre-of-mass frame in hadronic
    collisions is correctly accounted for now.
 
 ** Numerical stability fixes 
    Small fixes in RunningMass and QTildeReconstructor.
 
 ** Powheg example input files
    The example input files for Powheg processes now set the NLO
    alpha_S correctly, and are run as part of 'make check'.
 
 ** OS X builds for Snow Leopard
    Snow Leopard machines will now be recognized as a 64bit
    architecture.
 
 
 
 
 * Herwig++-2.4.1 release: 2009-11-19 (tagged at SVN r4932)
 
 ** Uses ThePEG-1.6.0 
    Herwig++ now requires ThePEG-1.6.0 to benefit from the improved
    helicity code there. If you have self-written vertex classes, see
    ThePEG's NEWS file for conversion instructions.
 
 ** Vertex improvements
    ThePEG's new helicity code allowed major simplification of the vertex
    implementations for all Standard Model and BSM physics models.
 
 ** New Transplanckian scattering model
    An example configuration is in LHC-TRP.in
 
 ** BSM ModelGenerator as branching ratio calculator
    The BSM ModelGenerator has a new switch to output the branching
    ratios for a given SLHA file in SLHA format, which can then be used
    elsewhere.
 
 ** BSM debugging: HardProcessConstructor
    New interface 'Excluded' to exclude certain particles from
    intermediate lines.  
 
 ** Chargino-Neutralino-W vertex fixed
 
 ** Spin correlations
    are now switched on by default for all perturbative decays.
 
 ** Ticket #276: Scale choice in BSM models' HardProcessConstructor
    New interface 'ScaleChoice' to choose process scale between 
    - sHat (default for colour neutral intermediates) and 
    - transverse mass (default for all other processes).
 
 ** Ticket #287: Powheg process scale choice
    The default choice is now the mass of the colour-singlet system.
    
 ** Ticket #278: QED radiation for BSM
    Soft QED radiation is now enabled in BSM decays and all
    perturbative decays by default. 
 
 ** Ticket #279: Full 1-loop QED radiation for Z decays
    Soft QED radiation in Z decays is now fully 1-loop by default.
 
 ** Ticket #280: Redirect all files to stdout
    This is now implemented globally. The files previously ending in
    -UE.out and -BSMinfo.out are now appended to the log file. They now
    also obey the EventGenerator:UseStdout flag.
 
 ** Ticket #270: LaTeX output updated
    After each run, a LaTeX file is produced that contains the full
    list of citations. Please include the relevant ones in publications.
 
 ** Ticket #256: Mac OS X problems
    An initialization problem that affected only some configurations has
    been identified and fixed.
 
 ** Tests directory added
    This contains many .in files, to exercise most matrix
    elements. 
 
 ** Minor fixes
 *** Prevent rare x>1 partons in shower reconstruction.
 *** SUSY-LHA parameter EXTPAR can be used to set tan beta
 *** Improved Fastjet detection at configure time
 
 
 
 
 
 * Herwig++-2.4.0 release: 2009-09-01 (tagged at SVN r4616)
 
 ** New matrix elements
    We have added a built-in implementation of several new matrix elements:
    PP --> WW / WZ / ZZ
    PP --> W gamma / Z gamma
    PP --> VBF Higgs
    PP --> Higgs tt / Higgs bb
    e+e- --> WW / ZZ
    gamma gamma --> ff / WW 
 
 
 
 ** Base code improvements
 *** Ticket #257: Remnant handling
     A problem with forced splittings in the Remnant was fixed.
 
 *** Ticket #264: Soft matrix element correction
     A problem with emissions form antiquarks was fixed. 
 
 
 
 ** PDF sets
 *** New default set
     MRST LO** is the new default PDF set. LO* is also available built-in.
 
 *** Shower PDFs can be set separately from the hard process
     Use the 'ShowerHandler:PDF' interface.
 
 
 
 ** Parameter tunes
     Shower, hadronization and underlying event parameters were retuned
     against LEP and Tevatron data respectively.
 
 
 
 ** BSM module improvements
 *** Ticket #259: read error for some UED models
     Arbitrary ordering of outgoing lines in the process description is now
     possible.
 
 *** Ticket #266: branching ratio sums
     The warning threshold for branching ratios not summing to 1 has
     been relaxed. It is now a user interface parameter.
 
 *** Ticket #267: Top decay modes
     Top decay modes listed in SLHA files are now handled correctly.
 
 
 
 ** QED radiation 
 *** Ticket #241: Soft QED radiation is now enabled by default
 
 *** Ticket #265: Radiation off W+ and W- is now handled correctly
 
 
 
 ** Interfaces
 *** Ticket #243: Fastjet
     Fastjet is now the only supported jet finder code. All example
     analyses have been converted to use Fastjet.
 
 *** KtJet and CLHEP interfaces have been removed.
 
 *** New interfaces to AcerDet and PGS available in Contrib
 
 *** MCPWnlo distributed in Contrib
 
 *** HepMC and Rivet interfaces moved to ThePEG
 
 
 
 ** Ticket #239: Inelastic cross-section for MinBias
    This information is now available in the ...-UE.out files.
 
 
 
 ** Technical changes
 *** Ticket #186
     Configure now looks for ThePEG in the --prefix location first.
 
 *** Configure information
     Important configuration information is listed at the end of the
     'configure' run and in the file 'config.thepeg'. Please provide
     this file in any bug reports.
 
 *** New ZERO object
     The ZERO object can be used to set any dimensionful quantity to
     zero. This avoids explicit constructs like 0.0*GeV.
 
 *** Exception specifiers removed
     Client code changes are needed in doinit() etc., simply remove the
     exception specifier after the function name.
 
 *** Ticket #263: Tau polarizations can be forced in TauDecayer
 
 
 
 
 
 * Herwig++-2.3.2 release: 2009-05-08 (tagged at SVN r4249)
 
 ** SUSY enhancements
 
 *** Ticket #245: Select inclusive / exclusive production
     Using the new 'HardProcessConstructor:Processes' switch options
     'SingleParticleInclusive', 'TwoParticleInclusive' or 'Exclusive'
 *** Improved three-body decay generation
     Several problems were fixed, incl. tickets #249 #250 #251
     Thanks to J.Tattersall and K.Rolbiecki for the stress-testing!
 *** Looptools fix
     Release 2.3.1 had broken the Looptools initialization.
 *** Improved warning message texts
 
 ** Ticket #237:
    Values of q2last can now be zero where possible.
 
 ** Ticket #240:
    The Herwig++ main program now correctly treats the -N flag as optional.
 
 ** Ticket #246:
    Extreme pT partons fixed by improving accuracy of z boosts.
 
 ** DIS
    Improved parton shower momentum reshuffling.
 
 ** Minimum Bias events
    The zero-momentum interacting particle used for
    bookkeeping is now labelled as a pomeron. 
 
 ** User Makefile
    Makefile-UserModules does not enable -pedantic anymore. User's ROOT
    code will not compile otherwise.
 
 ** Build system
    Small fixes in the build system.
 
 
 
 * Herwig++-2.3.1 release: 2009-03-31 (tagged at SVN r4140)
 ** Initial state showers
    The PDF veto was wrongly applied to qbar->qbar g splittings.
 
 ** User interaction
    The Makefile-UserModules now includes the Herwig version number.
    The -N flag to 'Herwig++ run' is optional now, as was always intended.
 
 ** Contrib
    The contrib directory is now included in the tarball. The omission
    was accidental.
 
 ** Numerical accuracy
    Minor problems with values close to zero were fixed in several
    locations.
 
 ** LEP event shapes
    An accidental duplication was removed, they are now only calculated
    once per event.
 
 ** MRST PDF code
    Initialization problem fixed.
 
 ** Mac OS X
    The configure script was improved to detect libraries better.
 
 ** Libtool
    Updated to version 2.2.6
 
 
 * Herwig++-2.3.0 release: 2008-12-02 (tagged at SVN r3939)
 ** Major release, with many new features and bug fixes
 
 ** Extension to lepton-hadron collisions
 
 ** Inclusion of several processes accurate at next-to-leading order
    in the POsitive Weight Hardest Emission Generator (POWHEG) scheme
 
 ** Inclusion of three-body decays and finite-width effects
    in BSM processes
 
 ** New procedure for reconstructing kinematics of the parton shower
    based on the colour structure of the hard scattering process
 
 ** New model for baryon decays including excited baryon multiplets
 
 ** Addition of a soft component to the multiple scattering model
    of the underlying event and the option to choose more than one hard
    scattering explicitly
 
 ** New matrix elements for DIS and e+e- processes
 
 ** New /Contrib directory added
    containing external modules that will hopefully be of use to some
    users but are not expected to be needed by most users and are not
    supported at the same level as the main Herwig++ code
 
 ** Minor changes to improve the physics simulation:
 
 *** IncomingPhotonEvolver added
     to allow the simulation of partonic processes with incoming photons
     in hadron collisions
 
 *** KTRapidityCut added
     to allow cuts on the p_T and rapidity, rather than just the p_T and
     pseudorapidity used in SimpleKTCut. This is now used by default for
     cuts on massive particles such as the $W^\pm$, $Z^0$ and Higgs
     bosons and the top quark
 
 *** Several changes to the decayers of B mesons
     both to resolve problems with the modelling of partonic decays and
     improve agreement with $\Upsilon(4s)$ data
 
 *** Changes to allow values other than transverse mass of final-state particles as maximum transverse momentum for radiation in parton shower
     either SCALUP for Les Houches events or the scale of the hard
     process for internally generated hard processes
 
 *** Changed defaults for intrinsic transverse momentum in hadron collisions
     to 1.9GeV, 2.1GeV and 2.2GeV for the Tevatron and LHC at 10 TeV and
     14 TeV, respectively
 
 *** Pdfinfo object is now created in the HepMC interface
     However in order to support all versions of HepMC containing this
     feature the PDF set is not specified as not all versions contain
     this information
 
 *** New option of only decaying particles with lifetimes below user specified value
 
 *** New options for the cut-off in the shower
     and some obsolete parameters removed
 
 *** Added option of switching off certain decay modes in BSM models
 
 *** Added a Matcher for Higgs boson
     to allow cuts to be placed on it
 
 *** Diffractive particles deleted from default input files
     they were not previously used
 
 ** Technical changes:
 
 *** Some AnalysisHandler classes comparing to LEP data have been renamed
     e.g. MultiplicityCount becomes LEPMultiplicityCount to avoid
     confusion with those supplied in /Contrib for observables at the
     Upsilon(4s) resonance
 
 *** Reorganisation to remove the majority of the .icc files
     by moving inlined functions to headers in an effort to improve
     compile time
 
 *** Restructured the decay libraries to reduce the amount of memory allocation
     and de-allocation which improves run-time performance
 
 *** The switch to turn off LoopTools has been removed
     because LoopTools is now used by several core modules. As LoopTools
     does not work on 64-bit platforms with g77 this build option is not
     supported
 
 *** Removed support for obsolete version of HepMC supplied with CLHEP
     and improved the support for different units options with HepMC
 
 *** EvtGen interface has been removed until it is more stable
 
 *** Support for ROOT has been removed
     it was not previously used
 
 *** CKKW infrastructure has been removed from the release
     until a concrete implementation is available
 
 *** Default optimisation has been increased from -O2 to -O3
 
 *** Handling of the fortran compiler has been improved
     mainly due to improvements in the autotools
 
 *** Use of FixedAllocator for Particle objects in ThePEG has been removed
     as it had no performance benefits
 
 ** Bugs fixed:
 
 *** Problems with the mother/daughter relations in the hard process
     and diagram selection in W+- and Z0 production in association with a
     hard jet
 
 *** In general matrix element code for fermion-vector to fermion-scalar
     where the outgoing fermion is coloured and the scalar neutral
 
 *** In the selection of diagrams in some associated squark gaugino processes
 
 *** h0->mu+mu- was being generated when h0->tau+tau-
 
 *** Normalisation in the Histogram class for non unit-weight events
 
 *** Protection against negative PDF values has been improved
     these can occur when using NLO PDF sets
 
 *** Lifetime for BSM particles is now automatically calculated
     at the same time as the width
 
 *** Hadrons containing a top quark now treated like hadrons containing BSM particles
     in order to support this possibility
 
 *** Several ambiguous uses of unsigned int
 
 *** Several variables that may have been used undefined
 
 *** Several memory leaks at initialisation
 
 *** The configuration now aborts if no fortran compiler is found
     as this is required to compile Looptools
 
 *** Several minor floating point errors that did not affect results
 
 
 
 * Herwig++-2.2.1 release: 2008-07-09 (tagged at SVN r3434)
 ** Ticket #181: BSM shower with a decay close to threshold
    Now fixed.
 
 ** Ticket #191: Split SUSY crash
    Improved error message. 
 
 ** Ticket #192: using SCALUP as the pT veto in the shower
    Now implemented.
 
 ** Ticket #194: production processes of ~chi_1(2)-
    Fixed bug in the diagram creation.
 
 ** Removed unused particles
    DiffractiveParticles.in was removed, they were never produced.
 
 ** Hadronization
    Top quark clusters now possible, handled as 'exotic' clusters.
 
 ** Improved handling of decay modes
    See ThePEG-1.3.0. 'defaultparticle' command is now obsolete. 
 
 ** Multi-Parton interactions
    Increased phase space sampling to have less than 1% uncertainty on
    average multiplicity.
 
 ** New libtool version
    gfortran is now used as default if it is available. Set FC=g77 to
    override this. 
 
 ** Fixed several memory leaks
 
 ** Memory allocation
    Now using plain 'new' and 'delete'.
 
 
 * Herwig++-2.2.0 release: 2008-04-18 (tagged at SVN r3195)
 ** Major release: now as stand-alone library
    Herwig++ is now a stand-alone dlopen() plugin to ThePEG.
    No compile-time linking to Herwig code is required. The Herwig++
    binary is a simple executable steering ThePEG, which can
    be replaced by other frontends (such as setupThePEG / runThePEG).  
 
 ** New matrix elements
    p p   -> W + jet / Z + jet / W + higgs / Z + higgs
    e+ e- -> Z + higgs
 
 ** Looptools 
    Updated to version 2.2.
 
 ** Ticket #141: segfault from using 'run' command
    Fixed by using default allocators in Herwig++, and the
    Repository::cleanup() method in ThePEG 1.2.0. 
 
 ** Ticket #157: broken gsl library path on some 64bit systems
    Paths with lib64 are correctly identified now.
 
 ** Ticket #159: p_t spectrum of ttbar pair
    Fixed identical particle multiplier in Sudakov form factor.
 
 ** Ticket #161: glibc segfault
    Rare segfault in MPI handler fixed.
 
 ** Ticket #165: rare infinite loop in four-body decay
    All 4-body decays without dedicated decayers now use the Mambo algorithm.
    A loop guard has been introduced to 3-body decays to avoid infinite retries.
 
 ** Ticket #166: rare infinite loop in top ME correction
    These very rare events (O(1) in 10^7) close to mass threshold
    now are discarded.
 
 ** Higgs width fixes
 
 ** SatPDF
    Optionally, the PDF extrapolation behaviour outside a given range 
    can now be specified.
 
 ** gcc 4.3
    Herwig++-2.2 compiles cleanly with the new gcc 4.3 series.
 
 
 
 
 * Herwig++-2.1.4 release: 2008-03-03 (tagged at SVN r3024)
 ** Ticket #152: Vertex positions
    All vertex positions of unphysical particles are set to zero until
    a fix for the previous nonsensical values can be implemented.
 
 
 
 
 * Herwig++-2.1.3 release: 2008-02-25 (tagged at SVN r2957)
 ** Ticket #129: Baryon decays
    Fix for baryon decay modes.
 
 ** Ticket #131: HepMC
    Check if IO_GenEvent exists
 
 ** Ticket #134: Hadronization
    Smearing of hadron directions in cluster decay fixed.
 
 ** Ticket #137: HepMC
    HepMC conversion allows specification of energy and length units to
    be used. 
 
 ** Ticket #139: Neutral kaons
    Ratio K_L / K_S corrected.
 
 ** Ticket #140 / #141: Crash on shutdown
    Event generation from the 'read' stage or an interface now shuts
    down cleanly. Fixes a crash bug introduced in 2.1.1 which affected
    external APIs to ThePEG / Herwig.
 
 ** Ticket #146: BSM models can be disabled
    To save build time, some or all of the BSM models can be disabled
    using the '--enable-models' configure switch.
 
 ** Reorganised .model files
    The .model files now include the model-specific particles, too.
 
 ** Re-tune
    Re-tuned hadronization parameters to LEP data. 
 
 ** Other fixes in
    QSPAC implementation in Shower; Multi-parton interaction tuning;
    MRST initialization
 
 
 
 
 * Herwig++-2.1.2 release: 2008-01-05 (tagged at SVN r2694)
 ** Ticket #127
    Thanks to a patch submitted by Fred Stober, HepMCFile now can
    output event files in all supported formats. 
 
 ** Ticket #128
    Fixed incorrect value of pi in histogram limits.
 
 ** Other fixes in
    CKKW Qtilde clusterers, BSM width cut, SUSY mixing matrices.
 
 
 
 
 * Herwig++-2.1.1 release: 2007-12-08 (tagged at SVN r2589)
 ** Bug #123
    Fixed a bug with particle lifetimes which resulted in nan for some
    vertex positions.
 
 ** Secondary scatters
    Fixed bug which gave intrinsic pT to secondary scatters.
 
 ** gcc abs bug detection
    configure now checks for and works around
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34130
 
 ** CKKW reweighting
    Fixed wrong check for top quarks.
 
 ** MPIHandler
    Fixed call order ambiguity.
 
 
 
 
 * Herwig++-2.1.0 release: 2007-11-20 (tagged at SVN r2542)
 ** Major new release
    Herwig++-2.1 includes significant improvements, including
    multi-parton interactions, BSM physics and a new hadronic decay
    model, tuned to LEP data.
 
    For an overview of the changes, please see the release note
    arXiv:0711.3137
 
 
 
 
 * Herwig++-2.0.3 release: 2007-08-21 (tagged at SVN r2101)
 
 ** Bug #90
    nan in top decay ME corrections fixed.
 
 ** unlisted
    Colour flow fix in LightClusterDecayer
 
 ** unlisted
    Updated version of MultiplicityCount analysis handler.
 
 
 
 
 * Herwig++-2.0.2 release: 2007-07-06 (tagged at SVN r1716)
 
 ** Bug #80
    Separation of HepMC from CLHEP is handled properly now.
 
 ** Bug #83
    Workaround for OS X header problem
 
 ** unlisted
    Veto on very hard emissions from Shower.
 
 ** unlisted
    Detailed documentation in .in files
 
 
 
 
 * Herwig++-2.0.1 release: 2006-12-05 (tagged at SVN r1195)
 
 ** Bug #54
    ClusterFissioner vertex calculation fixed.
 
 ** Bug #57
    Crash when showering W+jet events supplied by Les Houches interface.
 
 ** Bug #59
    Fix for #57 applied to LHC events.
 
 ** Bug #60
    Segfault when PDF is set to NoPDF.
 
 ** Bug #61
    Missing weight factor for I=0 mesons
 
 ** Bug #62
    Spinor vertex calculations broken when spinor rep is not default rep.
 
 ** Bug #63
    Top decay never produces tau.
 
 ** Bug #69
    TTbar and HiggsJet analysis handlers fixed.
 
 ** unlisted 
    Reorganization of Hadronization module gives 30% speedup. 
    Thanks to Vincenzo Innocente at CMS for his profiling work!
 
 ** unlisted
    cleaner automake files in include/ and src/
 
 ** unlisted 
    Hw64 hadron selection algorithm 'abortnow' fixed.
 
 ** unlisted 
    Top/LeptonDalitzAnalysis removed (only worked with modified code).
 
 ** unlisted
    removed f'_0 from particle list, decays were not handled
 
 
 
 
 * Herwig++-2.0.0 release: 2006-09-28 (tagged at SVN r1066)
 
 ** Full simulation of hadron collisions
diff --git a/PDF/Makefile.am b/PDF/Makefile.am
--- a/PDF/Makefile.am
+++ b/PDF/Makefile.am
@@ -1,64 +1,64 @@
 EXTRA_DIST = diffraction
 
 pkglib_LTLIBRARIES = HwPomeronPDF.la
 HwPomeronPDF_la_SOURCES = \
 PomeronPDF.cc PomeronPDF.h
 ## add this to produce tests of the PDFs
 ## HwDIFFRACTIVEPDF_la_CPPFLAGS=$(AM_CPPFLAGS) -DDIFFRACTIVEPDF_TESTING
-HwPomeronPDF_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 4:0:0
+HwPomeronPDF_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 5:0:0
 
 pkglib_LTLIBRARIES += HwReggeonPDF.la
 HwReggeonPDF_la_SOURCES = \
 ReggeonPDF.cc ReggeonPDF.h
 ## add this to produce tests of the PDFs
 ## HwDIFFRACTIVEPDF_la_CPPFLAGS=$(AM_CPPFLAGS) -DDIFFRACTIVEPDF_TESTING
-HwReggeonPDF_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 4:0:0
+HwReggeonPDF_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 5:0:0
 
 pkglib_LTLIBRARIES += HwPomeronFlux.la
 HwPomeronFlux_la_SOURCES = \
 PomeronFlux.h PomeronFlux.cc
-HwPomeronFlux_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 5:0:0
+HwPomeronFlux_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 6:0:0
 
 ## bound into HwShower.la
 noinst_LTLIBRARIES = libHwRemDecayer.la
 libHwRemDecayer_la_SOURCES = \
 HwRemDecayer.h HwRemDecayer.cc HwRemDecayer.fh
 
 ## bound into HwShower.la
 noinst_LTLIBRARIES += libHwMPIPDF.la
 libHwMPIPDF_la_SOURCES = \
 MPIPDF.h MPIPDF.cc MPIPDF.fh \
 MinBiasPDF.h MinBiasPDF.cc MinBiasPDF.fh
 
 pkglib_LTLIBRARIES += HwSatPDF.la
 HwSatPDF_la_SOURCES = \
 SatPDF.h SatPDF.cc
 
-HwSatPDF_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 7:0:0
+HwSatPDF_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 8:0:0
 
 pkglib_LTLIBRARIES += HwPartonExtractor.la
 HwPartonExtractor_la_SOURCES = \
 MultiPartonExtractor.h MultiPartonExtractor.cc
 
-HwPartonExtractor_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 7:0:0
+HwPartonExtractor_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 8:0:0
 
 pkglib_LTLIBRARIES += HwIncomingPhotonEvolver.la
 HwIncomingPhotonEvolver_la_SOURCES = \
 IncomingPhotonEvolver.h IncomingPhotonEvolver.cc
 
-HwIncomingPhotonEvolver_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 7:0:0
+HwIncomingPhotonEvolver_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 8:0:0
 
 pkglib_LTLIBRARIES += HwSaSPhotonPDF.la
 HwSaSPhotonPDF_la_SOURCES = \
 SaSGamma.f SaSPhotonPDF.cc SaSPhotonPDF.h
 
-HwSaSPhotonPDF_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 2:0:0
+HwSaSPhotonPDF_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 3:0:0
 
 install-data-local:
 	for i in `find $(srcdir)/diffraction -name '*.data'`; \
 	do \
 	$(install_sh_DATA) $$i $(DESTDIR)$(pkgdatadir)/PDF/$${i#$(srcdir)/}; \
 	done
 
 uninstall-local:
 	rm -rf $(DESTDIR)$(pkgdatadir)/PDF
diff --git a/README b/README
--- a/README
+++ b/README
@@ -1,14 +1,14 @@
 ========
 Herwig 7
 ========
 
-This is the release of Herwig 7.2.0, a multi purpose event
+This is the release of Herwig 7.2.2, a multi purpose event
 generator for high energy physics.
 
 The Herwig++ distribution contains an adapted version of LoopTools 2.6
 <http://www.feynarts.de/looptools/>. 
 
 BUILD AND INSTALL
 =================
 Please refer to https://herwig.hepforge.org/tutorials/ for detailed 
 instructions.
diff --git a/Shower/Dipole/Makefile.am b/Shower/Dipole/Makefile.am
--- a/Shower/Dipole/Makefile.am
+++ b/Shower/Dipole/Makefile.am
@@ -1,23 +1,23 @@
 SUBDIRS = Base Kernels Kinematics Utility AlphaS Merging SpinCorrelations 
 
 pkglib_LTLIBRARIES = HwDipoleShower.la
 
-HwDipoleShower_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 11:0:0
+HwDipoleShower_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 12:0:0
 
 HwDipoleShower_la_LIBADD = \
 	Base/libHwDipoleShowerBase.la \
 	Kernels/libHwDipoleShowerKernels.la \
 	Kinematics/libHwDipoleShowerKinematics.la \
 	Utility/libHwDipoleShowerUtility.la \
 	Merging/libHwDipoleShowerMerging.la \
 	SpinCorrelations/libHwDipoleShowerSpinCorrelations.la 
 
 HwDipoleShower_la_SOURCES =  \
 	DipoleShowerHandler.h DipoleShowerHandler.fh DipoleShowerHandler.cc
 
 
 pkglib_LTLIBRARIES += HwKrknloEventReweight.la
 HwKrknloEventReweight_la_SOURCES = \
 	KrkNLO/KrknloEventReweight.h KrkNLO/KrknloEventReweight.cc
 
-HwKrknloEventReweight_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 3:0:0
+HwKrknloEventReweight_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 4:0:0
diff --git a/Shower/QTilde/Makefile.am b/Shower/QTilde/Makefile.am
--- a/Shower/QTilde/Makefile.am
+++ b/Shower/QTilde/Makefile.am
@@ -1,46 +1,46 @@
 SUBDIRS = Matching
 pkglib_LTLIBRARIES = HwShower.la
-HwShower_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 27:0:0
+HwShower_la_LDFLAGS = $(AM_LDFLAGS) -module -version-info 28:0:0
 HwShower_la_SOURCES =  \
 Couplings/ShowerAlphaQCD.h Couplings/ShowerAlphaQCD.cc \
 Couplings/ShowerAlphaQED.h Couplings/ShowerAlphaQED.cc\
 QTildeShowerHandler.h QTildeShowerHandler.fh QTildeShowerHandler.cc \
 SplittingFunctions/HalfHalfOneSplitFn.h SplittingFunctions/HalfHalfOneSplitFn.cc\
 SplittingFunctions/OneOneOneSplitFn.h SplittingFunctions/OneOneOneSplitFn.cc\
 SplittingFunctions/OneOneOneMassiveSplitFn.h SplittingFunctions/OneOneOneMassiveSplitFn.cc\
 SplittingFunctions/ZeroZeroOneSplitFn.h SplittingFunctions/ZeroZeroOneSplitFn.cc\
 SplittingFunctions/OneHalfHalfSplitFn.h SplittingFunctions/OneHalfHalfSplitFn.cc\
 SplittingFunctions/HalfOneHalfSplitFn.h SplittingFunctions/HalfOneHalfSplitFn.cc\
 SplittingFunctions/CMWOneOneOneSplitFn.h SplittingFunctions/CMWOneOneOneSplitFn.cc\
 SplittingFunctions/CMWHalfHalfOneSplitFn.h SplittingFunctions/CMWHalfHalfOneSplitFn.cc\
 Kinematics/Decay_QTildeShowerKinematics1to2.cc \
 Kinematics/Decay_QTildeShowerKinematics1to2.h  \
 Kinematics/IS_QTildeShowerKinematics1to2.cc    Kinematics/IS_QTildeShowerKinematics1to2.h  \
 Kinematics/FS_QTildeShowerKinematics1to2.cc    Kinematics/FS_QTildeShowerKinematics1to2.h  \
 Kinematics/KinematicHelpers.h \
 Kinematics/KinematicsReconstructor.cc \
 Kinematics/KinematicsReconstructor.tcc \
 Kinematics/KinematicsReconstructor.h \
 Kinematics/KinematicsReconstructor.fh \
 Base/HardTree.cc Base/HardTree.h Base/HardTree.fh \
 Base/HardBranching.h Base/HardBranching.fh Base/HardBranching.cc\
 Base/PartnerFinder.h Base/PartnerFinder.fh Base/PartnerFinder.cc \
 Base/ShowerVeto.h Base/ShowerVeto.fh Base/ShowerVeto.cc \
 Base/FullShowerVeto.h Base/FullShowerVeto.fh Base/FullShowerVeto.cc \
 SplittingFunctions/SplittingGenerator.cc SplittingFunctions/SplittingGenerator.h\
 SplittingFunctions/SplittingGenerator.fh \
 Base/ShowerTree.h Base/ShowerTree.fh Base/ShowerTree.cc \
 ShowerConfig.h ShowerConfig.cc \
 Base/Branching.h \
 Base/ShowerParticle.cc  Base/ShowerParticle.fh  Base/ShowerParticle.h \
 Kinematics/ShowerKinematics.fh  Kinematics/ShowerKinematics.h Kinematics/ShowerKinematics.cc \
 Kinematics/ShowerBasis.fh  Kinematics/ShowerBasis.h Kinematics/ShowerBasis.cc \
 Base/ShowerProgenitor.fh Base/ShowerProgenitor.h \
 SplittingFunctions/SudakovFormFactor.cc SplittingFunctions/SudakovFormFactor.h SplittingFunctions/SudakovFormFactor.fh \
 SplittingFunctions/SudakovCutOff.cc SplittingFunctions/SudakovCutOff.h SplittingFunctions/SudakovCutOff.fh \
 SplittingFunctions/PTCutOff.cc SplittingFunctions/PTCutOff.h \
 SplittingFunctions/MassCutOff.cc SplittingFunctions/MassCutOff.h \
 SplittingFunctions/VariableMassCutOff.cc SplittingFunctions/VariableMassCutOff.h \
 SplittingFunctions/SplittingFunction.h SplittingFunctions/SplittingFunction.fh \
 SplittingFunctions/SplittingFunction.cc  \
 Base/ShowerVertex.cc Base/ShowerVertex.fh Base/ShowerVertex.h
diff --git a/Tests/Makefile.am b/Tests/Makefile.am
--- a/Tests/Makefile.am
+++ b/Tests/Makefile.am
@@ -1,387 +1,387 @@
 AM_LDFLAGS += -module -avoid-version -rpath /dummy/path/not/used
 
-EXTRA_DIST = Inputs python Rivet 
+EXTRA_DIST = Inputs python Rivet
 
 EXTRA_LTLIBRARIES = LeptonTest.la GammaTest.la HadronTest.la DISTest.la
 
 if WANT_LIBFASTJET
 EXTRA_LTLIBRARIES += HadronJetTest.la LeptonJetTest.la
 HadronJetTest_la_SOURCES = \
 Hadron/VHTest.h Hadron/VHTest.cc\
 Hadron/VTest.h Hadron/VTest.cc\
 Hadron/HTest.h Hadron/HTest.cc
 HadronJetTest_la_CPPFLAGS = $(AM_CPPFLAGS) $(FASTJETINCLUDE) \
 -I$(FASTJETPATH)
-HadronJetTest_la_LIBADD = $(FASTJETLIBS) 
+HadronJetTest_la_LIBADD = $(FASTJETLIBS)
 LeptonJetTest_la_SOURCES = \
 Lepton/TopDecay.h Lepton/TopDecay.cc
 LeptonJetTest_la_CPPFLAGS = $(AM_CPPFLAGS) $(FASTJETINCLUDE) \
 -I$(FASTJETPATH)
-LeptonJetTest_la_LIBADD = $(FASTJETLIBS) 
+LeptonJetTest_la_LIBADD = $(FASTJETLIBS)
 endif
 
 LeptonTest_la_SOURCES = \
 Lepton/VVTest.h Lepton/VVTest.cc \
 Lepton/VBFTest.h Lepton/VBFTest.cc \
 Lepton/VHTest.h Lepton/VHTest.cc \
 Lepton/FermionTest.h Lepton/FermionTest.cc
 
 GammaTest_la_SOURCES = \
 Gamma/GammaMETest.h  Gamma/GammaMETest.cc \
 Gamma/GammaPMETest.h Gamma/GammaPMETest.cc
 
 DISTest_la_SOURCES = \
 DIS/DISTest.h  DIS/DISTest.cc
 
 HadronTest_la_SOURCES = \
 Hadron/HadronVVTest.h  Hadron/HadronVVTest.cc\
 Hadron/HadronVBFTest.h  Hadron/HadronVBFTest.cc\
 Hadron/WHTest.h  Hadron/WHTest.cc\
 Hadron/ZHTest.h  Hadron/ZHTest.cc\
 Hadron/VGammaTest.h  Hadron/VGammaTest.cc\
 Hadron/ZJetTest.h  Hadron/ZJetTest.cc\
 Hadron/WJetTest.h  Hadron/WJetTest.cc\
 Hadron/QQHTest.h  Hadron/QQHTest.cc
 
 
 REPO = $(top_builddir)/src/HerwigDefaults.rpo
 HERWIG = $(top_builddir)/src/Herwig
 HWREAD = $(HERWIG) read --repo $(REPO) -L $(builddir)/.libs -i $(top_builddir)/src
 HWBUILD = $(HERWIG) build --repo $(REPO) -L $(builddir)/.libs -i $(top_builddir)/src
 HWINTEGRATE = $(HERWIG) integrate
 HWRUN = $(HERWIG) run -N $${NUMEVENTS:-10000}
 
 
 tests : tests-LEP tests-DIS tests-LHC tests-Gamma
 
 
 LEPDEPS = \
 test-LEP-VV \
 test-LEP-VH \
 test-LEP-VBF \
 test-LEP-BB \
 test-LEP-Quarks \
 test-LEP-Leptons
 
 if WANT_LIBFASTJET
 LEPDEPS += test-LEP-TopDecay
 endif
 
 tests-LEP : $(LEPDEPS)
 
 tests-DIS : test-DIS-Charged test-DIS-Neutral
 
 
 LHCDEPS = \
 test-LHC-WW test-LHC-WZ test-LHC-ZZ \
 test-LHC-ZGamma test-LHC-WGamma \
 test-LHC-ZH test-LHC-WH \
 test-LHC-ZJet test-LHC-WJet \
 test-LHC-Z test-LHC-W \
 test-LHC-ZZVBF test-LHC-VBF \
 test-LHC-WWVBF \
 test-LHC-bbH test-LHC-ttH \
 test-LHC-GammaGamma test-LHC-GammaJet \
 test-LHC-Higgs test-LHC-HiggsJet \
 test-LHC-QCDFast test-LHC-QCD \
 test-LHC-Top
 
 
 if WANT_LIBFASTJET
 LHCDEPS += \
 test-LHC-Bottom \
 test-LHC-WHJet test-LHC-ZHJet test-LHC-HJet \
 test-LHC-ZShower test-LHC-WShower \
 test-LHC-WHJet-Powheg test-LHC-ZHJet-Powheg test-LHC-HJet-Powheg \
 test-LHC-ZShower-Powheg test-LHC-WShower-Powheg
 endif
 
-tests-LHC : $(LHCDEPS) 
+tests-LHC : $(LHCDEPS)
 
 tests-Gamma : test-Gamma-FF test-Gamma-WW test-Gamma-P
 
 
 
 LEPLIBS = LeptonTest.la
 HADLIBS = HadronTest.la
 
-if WANT_LIBFASTJET 
+if WANT_LIBFASTJET
 LEPLIBS += LeptonJetTest.la
 HADLIBS += HadronJetTest.la
 endif
 
 
 test-LEP-% : Inputs/LEP-%.in $(LEPLIBS)
 	$(HWREAD) $<
 	$(HWRUN) $(notdir $(subst .in,.run,$<))
 
 test-Gamma-% : Inputs/Gamma-%.in GammaTest.la
 	$(HWREAD) $<
 	$(HWRUN) $(notdir $(subst .in,.run,$<))
 
 test-DIS-% : Inputs/DIS-%.in DISTest.la
 	$(HWREAD) $<
 	$(HWRUN) $(notdir $(subst .in,.run,$<))
 
 test-LHC-% : Inputs/LHC-%.in GammaTest.la $(HADLIBS)
 	$(HWREAD) $<
 	$(HWRUN) $(notdir $(subst .in,.run,$<))
 
 
 
 tests-Rivet : Rivet-EE Rivet-DIS Rivet-Fixed \
 	      Rivet-TVT-WZ Rivet-TVT-Photon Rivet-TVT-Jets \
 	      Rivet-LHC-Jets Rivet-LHC-EW Rivet-LHC-Photon Rivet-LHC-Higgs
 
 Rivet-%-UE-Cent.yoda : Rivet-%-UE-Cent.run Rivet-%-Cent.run
 	rm -rf $(subst .yoda,,$@)
 	mkdir $(subst .yoda,,$@)
 	mv $(subst .yoda,.run,$@) $(subst UE-,,$(subst .yoda,.run,$@)) $(subst .yoda,,$@)
 	cd $(subst .yoda,,$@); ../$(HWRUN) $(subst UE-,,$(subst .yoda,.run,$@)); mv $(subst UE-,,$@) ALICE_2015_PPCentrality.yoda
 	cd $(subst .yoda,,$@); export RIVET_ANALYSIS_PATH=`pwd`; ../$(HWRUN)  $(subst .yoda,.run,$@)
 	mv $(subst .yoda,,$@)/$@ .
 	rm -rf $(subst .yoda,,$@)
 
 Rivet-%.run : Rivet/%.in
 	$(HWBUILD) -c .cache/$(subst .run,,$@) $<
 
 Rivet-Matchbox-%.yoda : Rivet-Matchbox-%.run
 	$(HWINTEGRATE) -c .cache/$(subst .run,,$<) $<
 	$(HWRUN)       -c .cache/$(subst .run,,$<) $<
 
 Rivet-%.yoda : Rivet-%.run
 	$(HWRUN) $<
 
 Rivet/%.in :
 	python/make_input_files.py $(notdir $(subst .in,,$@))
 
 Rivet-inputfiles: $(shell echo Rivet/EE{,-Powheg,-Matchbox,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox-Powheg,-Merging}-{7.7,9.4,12,13,17,27.6,27.7,29,30.2,30.7,30,31.3,31.6,34,34.8,41,42.1,42.6,43.6,45,50,52,53.3,55,56,57,58,59.5,60.8,60,61.4,66,76,82,85,10,12.8,21.5,22,25,26.8,34.5,35,36.2,44,48.0,91,93.0,130,133,136,161,172,177,183,189,192,196,197,200,202,205,206,207,91-nopi}.in) \
                   $(shell echo Rivet/EE{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Powheg,-Matchbox-Powheg}-{14,14.8}.in) \
 	          $(shell echo Rivet/EE{,-Dipole}-{10.5,11.96,12.8,13.96,16.86,21.84,26.8,28.48,35.44,48.0,97.0}-gg.in) \
                   $(shell echo Rivet/EE{,-Powheg,-Matchbox,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox-Powheg}-{2.2,2.6,3.0,3.2,4.17,4.3,4.41,5.0,5.2,4.6,4.8,5.8,6.2,6.6,7.0,7.4,3.63,4.03,4.5,8.8,9.27,9.46,9.51,10.52,10.52-sym,10.54,10.58,10.45,10.47,10.6}.in) \
                   $(shell echo Rivet/EE-{Upsilon,Upsilon2,Upsilon3,Upsilon4,Upsilon4-asym,JPsi,Psi2S,Psi2S-All,Psi3770,Tau,Phi,Lambdac,Omega-Meson,Omega-Baryon,Eta,Xi0,Xic0,Xicp,Omegac0,Xim}.in) \
                   $(shell echo Rivet/DIS{,-NoME,-Powheg,-Matchbox,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox-Powheg,-Merging}-{e--LowQ2,e+-LowQ2,e+-HighQ2}.in) \
                   $(shell echo Rivet/TVT{,-Powheg,-Matchbox,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox-Powheg,-Merging}-{Run-I-Z,Run-I-W,Run-I-WZ,Run-II-Z-e,Run-II-Z-{,LowMass-,HighMass-}mu,Run-II-W}.in) \
 	          $(shell echo Rivet/TVT{,-Dipole}-Run-II-{DiPhoton-GammaGamma,DiPhoton-GammaJet,PromptPhoton}.in) \
 	          $(shell echo Rivet/TVT-Powheg-Run-II-{DiPhoton-GammaGamma,DiPhoton-GammaJet}.in) \
                   $(shell echo Rivet/TVT{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-{Run-II-Jets-{0..11},Run-I-Jets-{1..8}}.in ) \
 	          $(shell echo Rivet/TVT{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-{630-Jets-{1..3},300-Jets-1,900-Jets-1}.in ) \
                   $(shell echo Rivet/TVT{,-Dipole}-{Run-I,Run-II,300,630,900}-UE.in) \
                   $(shell echo Rivet/LHC{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-7-DiJets-{1..7}-{A,B,C}.in ) \
                   $(shell echo Rivet/LHC{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-13-DiJets-{{1..11}-A,{6..11}-B}.in ) \
                   $(shell echo Rivet/LHC{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-{7,8,13}-Jets-{0..10}.in ) \
 	          $(shell echo Rivet/LHC{,-Dipole}-{900,2360,2760,7,8,13}-UE.in ) \
 	          $(shell echo Rivet/LHC{,-Dipole}-{7,13}{,-UE}-Cent.in ) \
 		  $(shell echo Rivet/LHC{,-Dipole}-2760-Jets-{1..3}.in ) \
 	          $(shell echo Rivet/LHC{,-Dipole}-{900,7,13}-UE-Long.in ) \
 		  $(shell echo Rivet/LHC{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-7-Charm-{1..5}.in) \
 		  $(shell echo Rivet/LHC{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-7-Bottom-{0..9}.in) \
 		  $(shell echo Rivet/LHC{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-7-Top-{L,SL}.in) \
 		  $(shell echo Rivet/LHC{,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Matchbox,-Matchbox-Powheg,-Merging}-{8,13}-Top-{All,L,SL}.in) \
                   $(shell echo Rivet/Star{,-Dipole}-{UE,Jets-{1..4}}.in ) \
 	          $(shell echo Rivet/SppS{,-Dipole}-{53,63,200,500,546,900}-UE.in ) \
                   $(shell echo Rivet/LHC{,-Matchbox,-Matchbox-Powheg,-Powheg,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Merging}-{{,8-}W-{e,mu},13-Z-{e,mu},Z-HighMass{1,2}-e,13-W-mu,{8,13}-Z-Mass{1..4}-{e,mu},Z-{e,mu,mu-SOPHTY},Z-LowMass-{e,mu},Z-MedMass-e,WZ,WW-{emu,ll},13-WW-emu,13-ZZ-ll,ZZ-{ll,lv},{8,13}-WZ,8-ZZ-lv,8-WW-ll,Z-mu-Short}.in) \
                   $(shell echo Rivet/LHC{,-Dipole}-7-{W,Z}Gamma-{e,mu}.in) \
                   $(shell echo Rivet/LHC{,-Dipole}-8-ZGamma-{e,mu}.in) \
 	          $(shell echo Rivet/LHC{,-Matchbox,-Matchbox-Powheg,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Merging}-{7-W-Jet-{1..3}-e,7-Z-Jet-{0..3}-e,7-Z-Jet-0-mu}.in) \
 	          $(shell echo Rivet/LHC{-Matchbox,-Matchbox-Powheg,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Merging}-{Z-b,Z-bb,8-Z-b,8-Z-bb,W-b,8-Z-jj}.in) \
 		  $(shell echo Rivet/LHC{,-Dipole}-{7,8,13}-PromptPhoton-{1..4}.in) Rivet/LHC-GammaGamma-7.in \
 	          $(shell echo Rivet/LHC{,-Powheg,-Dipole}-{7,8}-{DiPhoton-GammaGamma,DiPhoton-GammaJet}.in) \
 	          $(shell echo Rivet/LHC{,-Powheg,-Matchbox,-Matchbox-Powheg,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Merging}-{ggH,VBF,WH,ZH}.in) \
                   $(shell echo Rivet/LHC{,-Powheg,-Matchbox,-Matchbox-Powheg,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Merging}-8-{{ggH,VBF,WH,ZH}{,-GammaGamma},ggH-WW}.in) \
                   $(shell echo Rivet/LHC{,-Matchbox,-Matchbox-Powheg,-Dipole,-Dipole-MCatNLO,-Dipole-Matchbox-Powheg,-Merging}-ggHJet.in) \
                   $(shell echo Rivet/ISR{,-Dipole}-{{30,44,53,62}-UE,{44,62}-Z-mu}.in Rivet/EHS{,-Dipole}-UE.in) \
                   $(shell echo Rivet/SPS{,-Dipole}-{17.4-UE,200-Z-mu}.in ) \
                   $(shell echo Rivet/Fermilab{,-Dipole}-{27.4,38.8}-Z-mu.in )
 
 
 Rivet-GammaGamma: Rivet-GammaGamma/done
 	touch $@
 
 Rivet-GammaGamma/done: $(shell echo Rivet-GammaGamma-mumu-{3.5,4.5,5.5,6.5,7.5,9.0,12.5,17.5,30.0}.yoda )
 	rm -rf Rivet-GammaGamma
 	python/merge-GammaGamma GammaGamma
 	rivet-mkhtml -o Rivet-GammaGamma GammaGamma.yoda:Hw
 	touch $@
 
 Rivet-EE-Gamma: Rivet-EE-Gamma/done
 	touch $@
 
 Rivet-EE-Gamma/done: $(shell echo Rivet-EE-Gamma-Direct-mumu-{161,172,183,189,196,206}.yoda ) \
                       $(shell echo Rivet-EE-Gamma-Direct-tautau-{189,196,206}.yoda ) \
 	              $(shell echo Rivet-EE-Gamma-{Direct,Single-Resolved,Double-Resolved}-Jets-{198,206}.yoda )
 	rm -rf Rivet-EE-Gamma
 	python/merge-EE-Gamma EE-Gamma
 	rivet-mkhtml -o Rivet-EE-Gamma EE-Gamma.yoda:Hw
 	touch $@
 
 Rivet-EE : Rivet-EE/done
 	touch $@
 
 Rivet-EE/done : $(shell echo Rivet{,-Powheg}-EE-{7.7,9.4,12,13,14,14.8,17,27.6,27.7,29,30.2,30.7,30,31.3,31.6,34,34.8,43.6,45,50,52,53.3,55,56,57,58,59.5,60.8,60,61.4,66,76,10,12.8,21.5,22,25,26.8,34.5,35,36.2,41,42.1,42.6,44,48.0,82,85,91,93.0,130,133,136,161,172,177,183,189,192,196,197,200,202,205,206,207,91-nopi}.yoda) \
 	   $(shell echo Rivet-EE-{10.5,11.96,12.8,13.96,16.86,21.84,26.8,28.48,35.44,48.0,97.0}-gg.yoda) \
 	   $(shell echo Rivet-EE-{10.52,10.52-sym,10.6,2.2,2.6,3.0,3.2,4.6,4.8,5.8,6.2,6.6,7.0,7.4,3.63,4.03,4.17,4.3,4.41,5.0,5.2,4.5,8.8,9.27,9.46,9.51,10.54,10.58,10.45,10.47,Upsilon,Upsilon2,Upsilon3,Upsilon4,Upsilon4-asym,Tau,Phi,Lambdac,Omega-Meson,Omega-Baryon,Eta,Xi0,Xic0,Xicp,Omegac0,Xim,JPsi,Psi2S,Psi2S-All,Psi3770}.yoda)
 	rm -rf Rivet-EE
 	python/merge-EE --with-gg --with-decay EE
 	python/merge-EE Powheg-EE
 	rivet-mkhtml -o Rivet-EE EE.yoda:Hw Powheg-EE.yoda:Hw-Powheg
 	python/plot-EE Rivet-EE
 	touch $@
 
 Rivet-LowEnergy-%.yoda:
 	$(HWBUILD) -c .cache/$(subst .yoda,,$@) Rivet/$(subst .yoda,.in,$@)
 	$(HWRUN)  $(subst .yoda,.run,$@)
 
 Rivet-LowEnergy-EE-%:
 	args="--process "$(word 1,$(subst -, ,$(subst Rivet-LowEnergy-EE-,,$@))); if [ -n "$(strip $(word 2,$(subst -, ,$(subst Rivet-LowEnergy-EE-,,$@))))" ]; then args+=" --flavour "$(word 2,$(subst -, ,$(subst Rivet-LowEnergy-EE-,,$@))); fi; OUTPUT=`python/LowEnergy-EE.py $$args --non-perturbative --perturbative`; $(MAKE) $$OUTPUT NUMEVENTS=$${NUMEVENTS:-10000};
 	args="--process "$(word 1,$(subst -, ,$(subst Rivet-LowEnergy-EE-,,$@))); plots=`python/LowEnergy-EE.py $$args --plots`; python/mergeLowEnergy.py $(subst Rivet-LowEnergy-,,$@) $$plots; if [ -e LowEnergy-NonPerturbative-EE-$(subst Rivet-LowEnergy-EE-,,$@).yoda ] && [ -e LowEnergy-Perturbative-EE-$(subst Rivet-LowEnergy-EE-,,$@).yoda ]; then rivet-mkhtml -o Rivet-LowEnergy-EE-$(subst Rivet-LowEnergy-EE-,,$@) LowEnergy-NonPerturbative-EE-$(subst Rivet-LowEnergy-EE-,,$@).yoda:"Non-Pert" LowEnergy-Perturbative-EE-$(subst Rivet-LowEnergy-EE-,,$@).yoda:"Pert" $$plots; elif [ -e LowEnergy-NonPerturbative-EE-$(subst Rivet-LowEnergy-EE-,,$@).yoda ]; then rivet-mkhtml -o Rivet-LowEnergy-EE-$(subst Rivet-LowEnergy-EE-,,$@) LowEnergy-NonPerturbative-EE-$(subst Rivet-LowEnergy-EE-,,$@).yoda:"Non-Pert" $$plots; elif [ -e  LowEnergy-Perturbative-EE-$(subst Rivet-LowEnergy-EE-,,$@).yoda ]; then  rivet-mkhtml -o Rivet-LowEnergy-EE-$(subst Rivet-LowEnergy-EE-,,$@)  LowEnergy-Perturbative-EE-$(subst Rivet-LowEnergy-EE-,,$@).yoda:"Pert" $$plots; fi
 
 Rivet-LowEnergy-Photon-%:
 	args="--process "$(word 1,$(subst -, ,$(subst Rivet-LowEnergy-Photon-,,$@))); OUTPUT=`python/LowEnergy-Photon.py $$args --non-perturbative`; $(MAKE) $$OUTPUT NUMEVENTS=$${NUMEVENTS:-10000};
 	args="--process "$(word 1,$(subst -, ,$(subst Rivet-LowEnergy-Photon-,,$@))); plots=`python/LowEnergy-Photon.py $$args --plots`; python/mergeLowEnergy.py $(subst Rivet-LowEnergy-Photon-,GammaGamma-,$@) $$plots; if [ -e LowEnergy-NonPerturbative-GammaGamma-$(subst Rivet-LowEnergy-Photon-,,$@).yoda ] && [ -e LowEnergy-Perturbative-GammaGamma-$(subst Rivet-LowEnergy-Photon-,,$@).yoda ]; then rivet-mkhtml -o Rivet-LowEnergy-Photon-$(subst Rivet-LowEnergy-Photon-,,$@) LowEnergy-NonPerturbative-GammaGamma-$(subst Rivet-LowEnergy-Photon-,,$@).yoda:"Non-Pert" LowEnergy-Perturbative-GammaGamma-$(subst Rivet-LowEnergy-Photon-,,$@).yoda:"Pert" $$plots; elif [ -e LowEnergy-NonPerturbative-GammaGamma-$(subst Rivet-LowEnergy-Photon-,,$@).yoda ]; then rivet-mkhtml -o Rivet-LowEnergy-Photon-$(subst Rivet-LowEnergy-Photon-,,$@) LowEnergy-NonPerturbative-GammaGamma-$(subst Rivet-LowEnergy-Photon-,,$@).yoda:"Non-Pert" $$plots; elif [ -e  LowEnergy-Perturbative-GammaGamma-$(subst Rivet-LowEnergy-Photon-,,$@).yoda ]; then  rivet-mkhtml -o Rivet-LowEnergy-Photon-$(subst Rivet-LowEnergy-Photon-,,$@)  LowEnergy-Perturbative-GammaGamma-$(subst Rivet-LowEnergy-Photon-,,$@).yoda:"Pert" $$plots; fi
 
 Rivet-R:
 	OUTPUT=`python/R.py --perturbative --non-perturbative`; $(MAKE) $$OUTPUT NUMEVENTS=$${NUMEVENTS:-10000};
 	plots=`python/R.py --perturbative --non-perturbative --plots`; python/mergeLowEnergy.py R $$plots; rivet-mkhtml -o Rivet-R LowEnergy-EE-Perturbative-R.yoda:"Pert" LowEnergy-EE-NonPerturbative-R.yoda:"Non-Pert" $$plots
 
 Rivet-DIS : Rivet-DIS/done
 	touch $@
 
 Rivet-DIS/done: $(shell echo Rivet{-DIS,-DIS-NoME,-Powheg-DIS}-{e--LowQ2,e+-LowQ2,e+-HighQ2}.yoda)
 	rm -rf Rivet-DIS
-	python/merge-DIS DIS 
+	python/merge-DIS DIS
 	python/merge-DIS Powheg-DIS
 	python/merge-DIS DIS-NoME
 	rivet-mkhtml -o Rivet-DIS DIS.yoda:Hw Powheg-DIS.yoda:Hw-Powheg DIS-NoME.yoda:Hw-NoME
 	touch $@
 
 
 
 Rivet-TVT-EW : Rivet-TVT-EW/done
 	touch $@
 
 Rivet-TVT-EW/done:  $(shell echo Rivet{,-Powheg}-TVT-{Run-I-Z,Run-I-W,Run-I-WZ,Run-II-Z-{e,{,LowMass-,HighMass-}mu},Run-II-W}.yoda)
 	rm -rf Rivet-TVT-EW
 	python/merge-TVT-EW TVT
 	python/merge-TVT-EW Powheg-TVT
 	rivet-mkhtml -o Rivet-TVT-EW TVT-EW.yoda:Hw Powheg-TVT-EW.yoda:Hw-Powheg
 	touch $@
 
 Rivet-TVT-Photon : Rivet-TVT-Photon/done
 	touch $@
 
 Rivet-TVT-Photon/done: $(shell echo Rivet{,-Powheg}-TVT-Run-II-{DiPhoton-GammaGamma,DiPhoton-GammaJet}.yoda Rivet-TVT-Run-II-PromptPhoton.yoda)
 	rm -rf Rivet-TVT-Photon
 	python/merge-TVT-Photon TVT
 	python/merge-TVT-Photon Powheg-TVT
 	rivet-mkhtml -o Rivet-TVT-Photon TVT-Photon.yoda:Hw Powheg-TVT-Photon.yoda:Hw-Powheg
 	touch $@
 
 
 
 Rivet-TVT-Jets : Rivet-TVT-Jets/done
 	touch $@
 
 Rivet-TVT-Jets/done:  $(shell echo Rivet-TVT-{Run-II-Jets-{0..11},Run-I-Jets-{1..8}}.yoda ) \
 	         $(shell echo Rivet-TVT-{630-Jets-{1..3},300-Jets-1,900-Jets-1}.yoda ) \
                  $(shell echo Rivet-TVT-{Run-I,Run-II,300,630,900}-UE.yoda)
 	rm -rf Rivet-TVT-Jets
 	python/merge-TVT-Jets TVT
 	rivet-mkhtml -o Rivet-TVT-Jets TVT-Jets.yoda:Hw
 	touch $@
 
 Rivet-Fixed : Rivet-Fixed/done
 	touch $@
 
 
 Rivet-Fixed/done : $(shell echo Rivet-SppS-{53,63,200,500,546,900}-UE.yoda ) \
 	          $(shell echo Rivet-ISR-{{30,44,53,62}-UE,{44,62}-Z-mu}.yoda ) Rivet-EHS-UE.yoda \
                   $(shell echo Rivet-Star-{UE,Jets-{1..4}}.yoda ) \
                   $(shell echo Rivet-SPS-{17.4-UE,200-Z-mu}.yoda ) \
                   $(shell echo Rivet-Fermilab-{27.4,38.8}-Z-mu.yoda )
 	rm -rf Rivet-Fixed
 	python/merge-Fixed Fixed
 	rivet-mkhtml -o Rivet-Fixed Fixed.yoda:Hw
 	touch $@
 
 Rivet-LHC-Jets : Rivet-LHC-Jets/done
 	touch $@
 
 Rivet-LHC-Jets/done : \
 	        $(shell echo Rivet-LHC-7-DiJets-{1..7}-{A,B,C}.yoda   ) \
 	        $(shell echo Rivet-LHC-13-DiJets-{{1..11}-A,{6..11}-B}.yoda   ) \
 	        $(shell echo Rivet-LHC-{7,8,13}-Jets-{0..10}.yoda     ) \
 	        $(shell echo Rivet-LHC-2760-Jets-{1..3}.yoda     ) \
 	        $(shell echo Rivet-LHC-{900,2360,2760,7,8,13}-UE.yoda ) \
 	        $(shell echo Rivet-LHC-{7,13}-UE-Cent.yoda ) \
 	        $(shell echo Rivet-LHC-{900,7,13}-UE-Long.yoda        ) \
 		$(shell echo Rivet-LHC-7-Charm-{1..5}.yoda            ) \
 		$(shell echo Rivet-LHC-7-Bottom-{0..9}.yoda           ) \
 		$(shell echo Rivet-LHC-{7,8,13}-Top-{L,SL}.yoda ) \
 		$(shell echo Rivet-LHC-{8,13}-Top-All.yoda )
 	rm -rf Rivet-LHC-Jets
 	python/merge-LHC-Jets LHC
 	rivet-mkhtml -o Rivet-LHC-Jets LHC-Jets.yoda:Hw
 	touch $@
 
 
 Rivet-LHC-EW : Rivet-LHC-EW/done
 	touch $@
 
 Rivet-LHC-EW/done: \
 		$(shell echo Rivet{,-Powheg}-LHC-{13-Z-{e,mu},13-W-mu,Z-HighMass{1,2}-e,{8,13}-Z-Mass{1..4}-{e,mu},{,8-}W-{e,mu},Z-{e,mu,mu-SOPHTY},Z-LowMass-{e,mu},Z-MedMass-e,WZ,WW-{emu,ll},13-WW-emu,ZZ-{ll,lv},{8,13}-WZ,13-ZZ-ll,8-ZZ-lv,8-WW-ll,Z-mu-Short}.yoda) \
 		$(shell echo Rivet-LHC-{7-W-Jet-{1..3}-e,7-Z-Jet-{0..3}-e,7-Z-Jet-0-mu}.yoda) \
 		$(shell echo Rivet-LHC-7-{W,Z}Gamma-{e,mu}.yoda) \
-		$(shell echo Rivet-LHC-8-ZGamma-{e,mu}.yoda) 
+		$(shell echo Rivet-LHC-8-ZGamma-{e,mu}.yoda)
 	rm -rf Rivet-LHC-EW;
 	python/merge-LHC-EW LHC
 	python/merge-LHC-EW Powheg-LHC
 	rivet-mkhtml -o Rivet-LHC-EW LHC-EW.yoda:Hw Powheg-LHC-EW.yoda:Hw-Powheg \
                                      Rivet-LHC-Z-mu-SOPHTY.yoda:Hw Rivet-Powheg-LHC-Z-mu-SOPHTY.yoda:Hw-Powheg
 	touch $@
 
 
 
 
 Rivet-LHC-Photon : Rivet-LHC-Photon/done
 	touch $@
 
 Rivet-LHC-Photon/done: \
 		$(shell echo Rivet-LHC-{7,8,13}-PromptPhoton-{1..4}.yoda) \
 		Rivet-LHC-GammaGamma-7.yoda \
 	    $(shell echo Rivet{,-Powheg}-LHC-{7,8}-{DiPhoton-GammaGamma,DiPhoton-GammaJet}.yoda)
 	rm -rf Rivet-LHC-Photon
 	python/merge-LHC-Photon LHC
 	python/merge-LHC-Photon Powheg-LHC
 	rivet-mkhtml -o Rivet-LHC-Photon LHC-Photon.yoda:Hw Powheg-LHC-Photon.yoda:Hw-Powheg
 	touch $@
 
 
 
 
 Rivet-LHC-Higgs : Rivet-LHC-Higgs/done
 	touch $@
 
 Rivet-LHC-Higgs/done:  \
 		$(shell echo Rivet{,-Powheg}-LHC-{ggH,VBF,WH,ZH}.yoda) \
         $(shell echo Rivet{,-Powheg}-LHC-8-{{ggH,VBF,WH,ZH}{,-GammaGamma},ggH-WW}.yoda) \
         Rivet-LHC-ggHJet.yoda
 	yodamerge --add Rivet-Powheg-LHC-8-{ggH{-GammaGamma,-WW,},{VBF,ZH,WH}{,-GammaGamma}}.yoda -o Powheg-LHC-Higgs.yoda
 	yodamerge --add Rivet-LHC-8-{ggH{-GammaGamma,-WW,},{VBF,ZH,WH}{,-GammaGamma}}.yoda -o LHC-Higgs.yoda
 	rm -rf Rivet-LHC-Higgs
 	rivet-mkhtml -o Rivet-LHC-Higgs Powheg-LHC-Higgs.yoda:Hw-Powheg LHC-Higgs.yoda:Hw\
 	                Rivet-Powheg-LHC-ggH.yoda:gg-Powheg Rivet-LHC-ggH.yoda:gg Rivet-LHC-ggHJet.yoda:HJet \
                         Rivet-Powheg-LHC-VBF.yoda:VBF-Powheg Rivet-LHC-VBF.yoda:VBF Rivet-LHC-WH.yoda:WH Rivet-LHC-ZH.yoda:ZH \
                         Rivet-Powheg-LHC-WH.yoda:WH-Powheg Rivet-Powheg-LHC-ZH.yoda:ZH-Powheg
 	touch $@
 
 
 
 
 
 clean-local:
 	rm -f *.out *.log *.tex *.top *.run *.dump *.mult *.Bmult *.yoda Rivet/*.in anatohepmc.txt hepmctoana.txt
 	rm -rf Rivet-*
 
 distclean-local:
 	rm -rf .cache
diff --git a/Tests/Rivet/LHC/LHC-13-Top-L.in b/Tests/Rivet/LHC/LHC-13-Top-L.in
--- a/Tests/Rivet/LHC/LHC-13-Top-L.in
+++ b/Tests/Rivet/LHC/LHC-13-Top-L.in
@@ -1,9 +1,11 @@
 # -*- ThePEG-repository -*-
 ##################################################
 # select the analyses
 ##################################################
 # ATLAS top
 insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2016_I1468168
 insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2017_I1495243
 insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2018_I1705857
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2019_I1759875
\ No newline at end of file
+insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2019_I1759875
+insert /Herwig/Analysis/RivetAnalysis:Analyses 0 CMS_2018_I1620050
+insert /Herwig/Analysis/RivetAnalysis:Analyses 0 LHCB_2018_I1662483
\ No newline at end of file
diff --git a/Tests/Rivet/LHC/LHC-8-W-mu.in b/Tests/Rivet/LHC/LHC-8-W-mu.in
--- a/Tests/Rivet/LHC/LHC-8-W-mu.in
+++ b/Tests/Rivet/LHC/LHC-8-W-mu.in
@@ -1,6 +1,8 @@
 # -*- ThePEG-repository -*-
 ##################################################
 # select the analyses
 ##################################################
 # CMS W+jets
 insert /Herwig/Analysis/RivetAnalysis:Analyses 0 CMS_2016_I1491953
+# LHCb W/Z analysis
+insert /Herwig/Analysis/RivetAnalysis:Analyses 0 LHCB_2016_I1454404:MODE=WJET
diff --git a/Tests/Rivet/LHC/LHC-8-Z-Mass3-mu.in b/Tests/Rivet/LHC/LHC-8-Z-Mass3-mu.in
--- a/Tests/Rivet/LHC/LHC-8-Z-Mass3-mu.in
+++ b/Tests/Rivet/LHC/LHC-8-Z-Mass3-mu.in
@@ -1,12 +1,14 @@
 # -*- ThePEG-repository -*-
 ##################################################
 # select the analyses
 ##################################################
 # ATLAS Z + dijets
 insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2014_I1279489
 # ATLAS Z pT and phi*
 insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2015_I1408516:LMODE=MU
 # ATLAS high mass drell-yan
 insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2016_I1467454:LMODE=MU
 # ATLAS splittings rivet problem with this at the moment)
-#insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2017_I1589844:LMODE=MU
\ No newline at end of file
+insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ATLAS_2017_I1589844:LMODE=MU
+# LHCb W/Z analysis
+insert /Herwig/Analysis/RivetAnalysis:Analyses 0 LHCB_2016_I1454404:MODE=ZJET
diff --git a/Tests/Rivet/Templates/DIS-Matchbox.in b/Tests/Rivet/Templates/DIS-Matchbox.in
--- a/Tests/Rivet/Templates/DIS-Matchbox.in
+++ b/Tests/Rivet/Templates/DIS-Matchbox.in
@@ -1,55 +1,55 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 
 ##################################################
 ## Herwig/Matchbox example input file
 ##################################################
 
 ##################################################
 ## Collider type
 ##################################################
 
 read snippets/Matchbox.in
 read snippets/EPCollider.in
 
 ##################################################
 ## Process selection
 ##################################################
 
 ## Note that event generation may fail if no matching matrix element has
 ## been found.  Coupling orders are with respect to the Born process,
 ## i.e. NLO QCD does not require an additional power of alphas.
 
 ## Model assumptions
 read Matchbox/StandardModelLike.in
 read Matchbox/DiagonalCKM.in
 ## Set the order of the couplings
 cd /Herwig/MatrixElements/Matchbox
 set Factory:OrderInAlphaS 0
 set Factory:OrderInAlphaEW 2
 set Factory:ScaleChoice /Herwig/MatrixElements/Matchbox/Scales/LeptonQ2Scale
 ${shower}
 ${bscheme}
 read Matchbox/CT14.in
 
 do /Herwig/MatrixElements/Matchbox/Factory:ProductionMode
 
 # switch off initial state QED radiation
 set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
 set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
 
 # create the Rivet analysis
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert /Herwig/Generators/EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
-read ${parameterFile}
+${parameterFile}
 
 ## Select the process
 cd /Herwig/MatrixElements/Matchbox
 ${process}
 
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/DIS-Merging.in b/Tests/Rivet/Templates/DIS-Merging.in
--- a/Tests/Rivet/Templates/DIS-Merging.in
+++ b/Tests/Rivet/Templates/DIS-Merging.in
@@ -1,65 +1,65 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 
 ##################################################
 ## Herwig/Matchbox example input file
 ##################################################
 
 ##################################################
 ## Collider type
 ##################################################
 read snippets/DipoleMerging.in
 read snippets/EPCollider.in
 read snippets/MonacoSampler.in
 
 ##################################################
 ## Process selection
 ##################################################
 
 ## Note that event generation may fail if no matching matrix element has
 ## been found.  Coupling orders are with respect to the Born process,
 ## i.e. NLO QCD does not require an additional power of alphas.
 
 ## Model assumptions
 read Matchbox/StandardModelLike.in
 read Matchbox/DiagonalCKM.in
 ## Set the order of the couplings
 read Matchbox/MadGraph-OpenLoops.in
 
 set /Herwig/Merging/MergingFactory:OrderInAlphaS 0
 set /Herwig/Merging/MergingFactory:OrderInAlphaEW 2
 set /Herwig/Merging/MergingFactory:ScaleChoice /Herwig/MatrixElements/Matchbox/Scales/LeptonQ2Scale
 
 
 ##################################################
 ## PDF and AlphaS choice
 ##################################################
 read Matchbox/FiveFlavourNoBMassScheme.in
 read Matchbox/CT14.in
 set /Herwig/Couplings/NLOAlphaS:input_alpha_s  0.118
 read Merging/FactorCMWScheme.in
 
 
 
 # switch off initial state QED radiation
 set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
 set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
 
 # create the Rivet analysis
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert /Herwig/Generators/EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
-read ${parameterFile}
+${parameterFile}
 
 ## Select the process
 cd /Herwig/Merging/
 set Merger:MergingScale 10.*GeV
 ${process}
 
 do /Herwig/Merging/MergingFactory:ProductionMode
 
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/DIS-Powheg.in b/Tests/Rivet/Templates/DIS-Powheg.in
--- a/Tests/Rivet/Templates/DIS-Powheg.in
+++ b/Tests/Rivet/Templates/DIS-Powheg.in
@@ -1,48 +1,48 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # Example generator based on DIS parameters
 # usage: Herwig read DIS.in
 ##################################################
 read snippets/EPCollider.in
 
 set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
 set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
 ##################################################
 #  Need to use an NLO PDF
 ##################################################
 set /Herwig/Particles/p+:PDF    /Herwig/Partons/HardNLOPDF
 set /Herwig/Particles/pbar-:PDF /Herwig/Partons/HardNLOPDF
 set /Herwig/Shower/ShowerHandler:PDFB /Herwig/Partons/ShowerLOPDF
 set /Herwig/Partons/MPIExtractor:SecondPDF  /Herwig/Partons/MPIPDF
 set /Herwig/Partons/EPExtractor:SecondPDF  /Herwig/Partons/HardNLOPDF
 
 ##################################################
 #  Setup the POWHEG shower
 ##################################################
 cd /Herwig/Shower
 set ShowerHandler:IntrinsicPtGaussian 1.9*GeV
 set ShowerHandler:HardEmission POWHEG
 
 cd /Herwig/MatrixElements/
 # Neutral current DIS
 
 insert SubProcess:MatrixElements[0] /Herwig/MatrixElements/PowhegMEDISNC
 ${process}
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 set /Herwig/Shower/ShowerHandler:MPIHandler NULL
 cd /Herwig/Generators
 
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/DIS.in b/Tests/Rivet/Templates/DIS.in
--- a/Tests/Rivet/Templates/DIS.in
+++ b/Tests/Rivet/Templates/DIS.in
@@ -1,44 +1,44 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # Example generator based on DIS parameters
 # usage: Herwig read DIS.in
 ##################################################
 
 read snippets/EPCollider.in
 
 set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
 set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
 
 ##################################################
 ## Shower and flavour scheme selection.
 ## Should be empty unless using the Dipole Shower.
 ##################################################
 ${shower}
 ${bscheme}
 
 
 
 cd /Herwig/MatrixElements/
 # Neutral current DIS
 insert SubProcess:MatrixElements[0] MEDISNC
 ${process}
 
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 set /Herwig/Shower/ShowerHandler:MPIHandler NULL
 set /Herwig/DipoleShower/DipoleShowerHandler:MPIHandler NULL
 
 cd /Herwig/Generators
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/EE-Gamma-Direct.in b/Tests/Rivet/Templates/EE-Gamma-Direct.in
--- a/Tests/Rivet/Templates/EE-Gamma-Direct.in
+++ b/Tests/Rivet/Templates/EE-Gamma-Direct.in
@@ -1,46 +1,46 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # base parameters for LEP analyses
 ##################################################
 read snippets/EECollider.in
 ##################################################
 # Technical parameters for this run
 ##################################################
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 
 ##################################################
 #  Switch off ISR
 ##################################################
 set /Herwig/Particles/e+:PDF /Herwig/Partons/WWPDF
 set /Herwig/Particles/e-:PDF /Herwig/Partons/WWPDF
 ##################################################
 ## Shower and scheme selection.
 ## Should be empty unless using the Dipole Shower.
 ##################################################
 ${shower}
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 cd /Herwig/Generators
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
 ##################################################
 #  Use the q qbar matrix element
 ##################################################
 # default e+e- > q qbar (5 flavours d,u,s,c,b)
 ${process}
 set /Herwig/Shower/PartnerFinder:QEDPartner IIandFF
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/EE-Gamma-Double-Resolved.in b/Tests/Rivet/Templates/EE-Gamma-Double-Resolved.in
--- a/Tests/Rivet/Templates/EE-Gamma-Double-Resolved.in
+++ b/Tests/Rivet/Templates/EE-Gamma-Double-Resolved.in
@@ -1,47 +1,47 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # base parameters for LEP analyses
 ##################################################
 read snippets/EECollider.in
 ##################################################
 # Technical parameters for this run
 ##################################################
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 
 ##################################################
 #  Switch off ISR
 ##################################################
 set /Herwig/Particles/e+:PDF /Herwig/Partons/WWPDF
 set /Herwig/Particles/e-:PDF /Herwig/Partons/WWPDF
 set /Herwig/Particles/gamma:PDF  /Herwig/Partons/SaSPDF
 ##################################################
 ## Shower and scheme selection.
 ## Should be empty unless using the Dipole Shower.
 ##################################################
 ${shower}
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 cd /Herwig/Generators
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
 ##################################################
 #  Use the q qbar matrix element
 ##################################################
 # default e+e- > q qbar (5 flavours d,u,s,c,b)
 ${process}
 set /Herwig/Shower/PartnerFinder:QEDPartner All
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/EE-Gamma-Single-Resolved.in b/Tests/Rivet/Templates/EE-Gamma-Single-Resolved.in
--- a/Tests/Rivet/Templates/EE-Gamma-Single-Resolved.in
+++ b/Tests/Rivet/Templates/EE-Gamma-Single-Resolved.in
@@ -1,72 +1,72 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # base parameters for LEP analyses
 ##################################################
 read snippets/EECollider.in
 ##################################################
 # Technical parameters for this run
 ##################################################
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 
 ##################################################
 #  Select the PDFs
 ##################################################
 set /Herwig/Particles/e+:PDF /Herwig/Partons/WWPDF
 set /Herwig/Particles/e-:PDF /Herwig/Partons/WWPDF
 set /Herwig/Particles/gamma:PDF /Herwig/Partons/SaSPDF
 
 
 DISABLEREADONLY
 create Herwig::MultiPartonExtractor /Herwig/Partons/GGExtractor HwPartonExtractor.so
 newdef /Herwig/Partons/GGExtractor:NoPDF /Herwig/Partons/NoPDF
 insert /Herwig/Partons/GGExtractor:FirstPDFs 0 /Herwig/Partons/WWPDF
 insert /Herwig/Partons/GGExtractor:FirstPDFs 1 /Herwig/Partons/SaSPDF
 insert /Herwig/Partons/GGExtractor:SecondPDFs 0 /Herwig/Partons/WWPDF
 insert /Herwig/Partons/GGExtractor:SecondPDFs 1 /Herwig/Partons/NoPDF
 
 create Herwig::MultiPartonExtractor /Herwig/Partons/GG2Extractor HwPartonExtractor.so
 newdef /Herwig/Partons/GG2Extractor:NoPDF /Herwig/Partons/NoPDF
 insert /Herwig/Partons/GG2Extractor:FirstPDFs 0 /Herwig/Partons/WWPDF
 insert /Herwig/Partons/GG2Extractor:FirstPDFs 1 /Herwig/Partons/NoPDF
 insert /Herwig/Partons/GG2Extractor:SecondPDFs 0 /Herwig/Partons/WWPDF
 insert /Herwig/Partons/GG2Extractor:SecondPDFs 1 /Herwig/Partons/SaSPDF
 
 
 set /Herwig/MatrixElements/SubProcess:PartonExtractor /Herwig/Partons/GGExtractor
 cp /Herwig/MatrixElements/SubProcess /Herwig/MatrixElements/SubProcess2
 set /Herwig/MatrixElements/SubProcess2:PartonExtractor /Herwig/Partons/GG2Extractor
 
 insert /Herwig/Generators/EventGenerator:EventHandler:SubProcessHandlers 1 /Herwig/MatrixElements/SubProcess2
 
 
 ##################################################
 ## Shower and scheme selection.
 ## Should be empty unless using the Dipole Shower.
 ##################################################
 ${shower}
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 cd /Herwig/Generators
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
 ##################################################
 #  Use the q qbar matrix element
 ##################################################
 # default e+e- > q qbar (5 flavours d,u,s,c,b)
 ${process}
 set /Herwig/Shower/PartnerFinder:QEDPartner All
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/EE-Matchbox.in b/Tests/Rivet/Templates/EE-Matchbox.in
--- a/Tests/Rivet/Templates/EE-Matchbox.in
+++ b/Tests/Rivet/Templates/EE-Matchbox.in
@@ -1,61 +1,61 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 ## Collider type
 ##################################################
 read snippets/Matchbox.in
 
 read snippets/EECollider.in
 ##################################################
 ## Process selection
 ##################################################
 ## Model assumptions
 read Matchbox/StandardModelLike.in
 read Matchbox/DiagonalCKM.in
 ## Set the order of the couplings
 cd /Herwig/MatrixElements/Matchbox
 set Factory:OrderInAlphaS 0
 set Factory:OrderInAlphaEW 2
 
 ##################################################
 ## Scale choice
 ## See the documentation for more options
 ##################################################
 cd /Herwig/MatrixElements/Matchbox
 set Factory:ScaleChoice /Herwig/MatrixElements/Matchbox/Scales/SHatScale
 ##################################################
 ## Matching and shower selection
 ##################################################
 ${shower}
 ##################################################
 #  Switch off ISR
 ##################################################
 set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
 set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert /Herwig/Generators/EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 ##################################################
 ## Do not apply profile scales for LEP as hard
 ## scale coincides with kinematic limit
 ##################################################
 set /Herwig/Shower/ShowerHandler:HardScaleProfile NULL
 set /Herwig/DipoleShower/DipoleShowerHandler:HardScaleProfile NULL
 ##################################################
 ## Save the generator
 ##################################################
 do /Herwig/MatrixElements/Matchbox/Factory:ProductionMode
 
 ## Select the process
 cd /Herwig/MatrixElements/Matchbox
 ${process}
 
-read ${parameterFile}
+${parameterFile}
 
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/EE-Merging.in b/Tests/Rivet/Templates/EE-Merging.in
--- a/Tests/Rivet/Templates/EE-Merging.in
+++ b/Tests/Rivet/Templates/EE-Merging.in
@@ -1,67 +1,67 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 ## Collider type
 ##################################################
 read snippets/DipoleMerging.in
 read snippets/EECollider.in
 read snippets/MonacoSampler.in
 ##################################################
 ## Process selection
 ##################################################
 ## Model assumptions
 read Matchbox/StandardModelLike.in
 read Matchbox/DiagonalCKM.in
 ## Set the order of the couplings
 cd /Herwig/Merging/
 set MergingFactory:OrderInAlphaS 0
 set MergingFactory:OrderInAlphaEW 2
 ##################################################
 ## Matrix element library selection
 ##################################################
 read Matchbox/MadGraph-OpenLoops.in
 ##################################################
 ## Scale choice
 ## See the documentation for more options
 ##################################################
 cd /Herwig/Merging/
 set MergingFactory:ScaleChoice /Herwig/MatrixElements/Matchbox/Scales/SHatScale
 ##################################################
 ## PDF and AlphaS choice
 ##################################################
 set /Herwig/Couplings/NLOAlphaS:input_alpha_s  0.118
 read Merging/FactorCMWScheme.in
 ##################################################
 #  Switch off ISR
 ##################################################
 set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
 set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert /Herwig/Generators/EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 ##################################################
 ## Do not apply profile scales for LEP as hard
 ## scale coincides with kinematic limit
 ##################################################
 set /Herwig/DipoleShower/DipoleShowerHandler:HardScaleProfile NULL
 
 
 ## Select the process
 cd /Herwig/Merging/
 set Merger:MergingScale 5.*GeV
 ${process}
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 ## Save the generator
 ##################################################
 do /Herwig/Merging/MergingFactory:ProductionMode
 
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/EE-Powheg.in b/Tests/Rivet/Templates/EE-Powheg.in
--- a/Tests/Rivet/Templates/EE-Powheg.in
+++ b/Tests/Rivet/Templates/EE-Powheg.in
@@ -1,40 +1,40 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # base parameters for LEP analyses
 ##################################################
 read snippets/EECollider.in
 ##################################################
 # Technical parameters for this run
 ##################################################
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 
 ##################################################
 #  Switch off ISR
 ##################################################
 set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
 set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
 ##################################################
 #  Use the NLO q qbar matrix element
 ##################################################
 set /Herwig/Shower/ShowerHandler:HardEmission POWHEG
 insert /Herwig/MatrixElements/SubProcess:MatrixElements 0 /Herwig/MatrixElements/PowhegMEee2gZ2qq
 ${process}
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/EE.in b/Tests/Rivet/Templates/EE.in
--- a/Tests/Rivet/Templates/EE.in
+++ b/Tests/Rivet/Templates/EE.in
@@ -1,48 +1,48 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # base parameters for LEP analyses
 ##################################################
 read snippets/EECollider.in
 ##################################################
 # Technical parameters for this run
 ##################################################
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 
 ##################################################
 #  Switch off ISR
 ##################################################
 set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
 set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
 
 
 ##################################################
 ## Shower and scheme selection.
 ## Should be empty unless using the Dipole Shower.
 ##################################################
 ${shower}
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 cd /Herwig/Generators
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
 ##################################################
 #  Use the q qbar matrix element
 ##################################################
 # default e+e- > q qbar (5 flavours d,u,s,c,b)
 ${process}
 set /Herwig/Shower/PartnerFinder:QEDPartner IIandFF
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/GammaGamma.in b/Tests/Rivet/Templates/GammaGamma.in
--- a/Tests/Rivet/Templates/GammaGamma.in
+++ b/Tests/Rivet/Templates/GammaGamma.in
@@ -1,44 +1,44 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # base parameters for LEP analyses
 ##################################################
 read snippets/EECollider.in
 set /Herwig/EventHandlers/EventHandler:BeamA /Herwig/Particles/gamma
 set /Herwig/EventHandlers/EventHandler:BeamB /Herwig/Particles/gamma
 set /Herwig/Particles/gamma:PDF /Herwig/Partons/NoPDF
 ##################################################
 # Technical parameters for this run
 ##################################################
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 
 ##################################################
 ## Shower and scheme selection.
 ## Should be empty unless using the Dipole Shower.
 ##################################################
 ${shower}
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 cd /Herwig/Generators
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
 ##################################################
 #  Use the q qbar matrix element
 ##################################################
 # default e+e- > q qbar (5 flavours d,u,s,c,b)
 ${process}
 set /Herwig/Shower/PartnerFinder:QEDPartner IIandFF
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/Hadron-Gamma.in b/Tests/Rivet/Templates/Hadron-Gamma.in
--- a/Tests/Rivet/Templates/Hadron-Gamma.in
+++ b/Tests/Rivet/Templates/Hadron-Gamma.in
@@ -1,59 +1,59 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # Technical parameters for this run
 ##################################################
 read snippets/PPCollider.in
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 set EventGenerator:EventHandler:StatLevel Full
 set EventGenerator:EventHandler:Sampler:Ntry 10000
 set /Herwig/Partons/PPExtractor:FlatSHatY 0
 set /Herwig/Decays/DecayHandler:MaxLifeTime 10*mm
 ##################################################
 # Change the proton PDFs to those for photon radiation
 ##################################################
 set /Herwig/Particles/p+:PDF    /Herwig/Partons/BudnevPDF
 set /Herwig/Particles/pbar-:PDF /Herwig/Partons/BudnevPDF
 set /Herwig/Partons/PPExtractor:FirstPDF  /Herwig/Partons/BudnevPDF
 set /Herwig/Partons/PPExtractor:SecondPDF /Herwig/Partons/BudnevPDF
 set /Herwig/Shower/ShowerHandler:PDFA NULL
 set /Herwig/Shower/ShowerHandler:PDFB NULL
 set /Herwig/DipoleShower/DipoleShowerHandler:PDFA NULL
 set /Herwig/DipoleShower/DipoleShowerHandler:PDFB NULL
 # No MPI
 set EventGenerator:EventHandler:CascadeHandler:MPIHandler NULL
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 set /Herwig/Analysis/RivetAnalysis:Debug No
 
 ##################################################
 #  Cuts
 ##################################################
 cd /Herwig/Cuts
 set Cuts:ScaleMin 0.0
 set Cuts:X1Min 0
 set Cuts:X2Min 0
 set Cuts:X1Max 1.
 set Cuts:X2Max 1.
 set Cuts:MHatMin 1.*GeV
 erase Cuts:MultiCuts 0
 set LeptonKtCut:MinKT 3*GeV
 
 cd /Herwig/MatrixElements
 ${process}
 
 cd /Herwig/Generators
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/Hadron-Matchbox.in b/Tests/Rivet/Templates/Hadron-Matchbox.in
--- a/Tests/Rivet/Templates/Hadron-Matchbox.in
+++ b/Tests/Rivet/Templates/Hadron-Matchbox.in
@@ -1,50 +1,50 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 ## Collider type
 ##################################################
 read snippets/Matchbox.in
 read snippets/PPCollider.in
 
 ##################################################
 ## Matrix element library selection
 ##################################################
 ## Model assumptions
 read Matchbox/StandardModelLike.in
 read Matchbox/DiagonalCKM.in
 ${nlo}
 ##################################################
 ## Matching and shower selection
 ## Please also see flavour scheme settings
 ## towards the end of the input file.
 ##################################################
 ${shower}
 ##################################################
 ## PDF choice
 ##################################################
 ${bscheme}
 read Matchbox/CT14.in
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert /Herwig/Generators/EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 set /Herwig/Analysis/RivetAnalysis:Debug No
 set /Herwig/Decays/DecayHandler:MaxLifeTime 10*mm
 ##################################################
 ## Save the generator
 ##################################################
 do /Herwig/MatrixElements/Matchbox/Factory:ProductionMode
 
 ## Select the process
 cd /Herwig/MatrixElements/Matchbox
 
 ${process}
 
-read ${parameterFile}
+${parameterFile}
 
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/Hadron-Merging.in b/Tests/Rivet/Templates/Hadron-Merging.in
--- a/Tests/Rivet/Templates/Hadron-Merging.in
+++ b/Tests/Rivet/Templates/Hadron-Merging.in
@@ -1,50 +1,50 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 ## Collider type
 ##################################################
 read snippets/DipoleMerging.in
 read snippets/PPCollider.in
 read snippets/MonacoSampler.in
 ##################################################
 ## Matrix element library selection
 ##################################################
 ## Model assumptions
 read Matchbox/StandardModelLike.in
 read Matchbox/DiagonalCKM.in
 read Matchbox/MadGraph-OpenLoops.in
 
 ##################################################
 ## PDF and AlphaS choice
 ##################################################
 read Matchbox/FiveFlavourNoBMassScheme.in
 read Matchbox/CT14.in
 set /Herwig/Couplings/NLOAlphaS:input_alpha_s  0.118
 read Merging/FactorCMWScheme.in
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert /Herwig/Generators/EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 set /Herwig/Analysis/RivetAnalysis:Debug No
 set /Herwig/Decays/DecayHandler:MaxLifeTime 10*mm
 
 
 ## Select the process
 cd /Herwig/Merging/
 set Merger:MergingScale 15.*GeV
 
 ${process}
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 ## Save the generator
 ##################################################
 do /Herwig/Merging/MergingFactory:ProductionMode
 
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/Hadron-Powheg.in b/Tests/Rivet/Templates/Hadron-Powheg.in
--- a/Tests/Rivet/Templates/Hadron-Powheg.in
+++ b/Tests/Rivet/Templates/Hadron-Powheg.in
@@ -1,49 +1,49 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # Technical parameters for this run
 ##################################################
 read snippets/PPCollider.in
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 set /Herwig/Decays/DecayHandler:MaxLifeTime 10*mm
 ##################################################
 #  Need to use an NLO PDF
 ##################################################
 set /Herwig/Particles/p+:PDF    /Herwig/Partons/HardNLOPDF
 set /Herwig/Particles/pbar-:PDF /Herwig/Partons/HardNLOPDF
 set /Herwig/Shower/ShowerHandler:PDFA /Herwig/Partons/ShowerLOPDF
 set /Herwig/Shower/ShowerHandler:PDFB /Herwig/Partons/ShowerLOPDF
 set /Herwig/Partons/MPIExtractor:FirstPDF  /Herwig/Partons/MPIPDF
 set /Herwig/Partons/MPIExtractor:SecondPDF /Herwig/Partons/MPIPDF
 set /Herwig/Partons/PPExtractor:FirstPDF  /Herwig/Partons/HardNLOPDF
 set /Herwig/Partons/PPExtractor:SecondPDF /Herwig/Partons/HardNLOPDF
 
 ##################################################
 #  Setup the POWHEG shower
 ##################################################
 cd /Herwig/Shower
 set ShowerHandler:IntrinsicPtGaussian 1.9*GeV
 set ShowerHandler:HardEmission POWHEG
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 cd /Herwig/Generators
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 
 cd /Herwig/MatrixElements
 ${process}
 
 cd /Herwig/Generators
 
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/Rivet/Templates/Hadron.in b/Tests/Rivet/Templates/Hadron.in
--- a/Tests/Rivet/Templates/Hadron.in
+++ b/Tests/Rivet/Templates/Hadron.in
@@ -1,38 +1,38 @@
 # -*- ThePEG-repository -*-
 #
 # DO NOT EDIT - autogenerated by make_input_files.py 
 #
 ##################################################
 # Technical parameters for this run
 ##################################################
 read snippets/${collider}
 cd /Herwig/Generators
 set EventGenerator:MaxErrors 1000000
 set EventGenerator:EventHandler:StatLevel Full
 set /Herwig/Decays/DecayHandler:MaxLifeTime 10*mm
 
 ##################################################
 ## Shower and flavour scheme selection.
 ## Should be empty unless using the Dipole Shower.
 ##################################################
 ${shower}
 ${bscheme}
 
 ##################################################
 #  Create the Herwig analysis
 ##################################################
 cd /Herwig/Generators
 create ThePEG::RivetAnalysis /Herwig/Analysis/RivetAnalysis RivetAnalysis.so
 insert EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/RivetAnalysis
 set /Herwig/Analysis/RivetAnalysis:Debug No
 cd /Herwig/MatrixElements
 ${process}
 
 cd /Herwig/Generators
-read ${parameterFile}
+${parameterFile}
 
 ##################################################
 # Save run for later usage with 'Herwig run'
 ##################################################
 cd /Herwig/Generators
 saverun ${runname} EventGenerator
diff --git a/Tests/python/merge-LHC-EW.in b/Tests/python/merge-LHC-EW.in
--- a/Tests/python/merge-LHC-EW.in
+++ b/Tests/python/merge-LHC-EW.in
@@ -1,492 +1,509 @@
 #! @PYTHON@
 from __future__ import print_function
 import logging, sys, os, yoda
 
 """%prog
 
 Script for merging aida files
 
 """
 
 def fillAbove(scale,desthisto, sourcehistosbyptmin) :
     pthigh= 1e100
     ptlow =-1e100
     for pt, h in sorted(sourcehistosbyptmin.items(),reverse=True):
         ptlow=pt
         if(type(desthisto)==yoda.core.Scatter2D) :
             for i in range(0,h.numPoints()) :
                 xMin = h.points()[i].x()-h.points()[i].xErrs().minus
                 if( xMin*scale >= ptlow and 
                     xMin*scale <  pthigh ) :
                     desthisto.addPoint(h.points()[i])
         elif(type(desthisto)==yoda.core.Profile1D) :
             for i in range(0,h.numBins()) :
                 if(h.bins()[i].xMin()*scale  >= ptlow and 
                    h.bins()[i].xMin()*scale  <  pthigh ) :
                     desthisto.bins()[i] += h.bins()[i]
         elif(type(desthisto)==yoda.core.Histo1D) :
             for i in range(0,h.numBins()) :
                 if(h.bins()[i].xMin()*scale  >= ptlow and 
                    h.bins()[i].xMin()*scale  <  pthigh ) :
                     desthisto.bins()[i] += h.bins()[i]
         else :
             logging.error("Can't merge %s, unknown type" % desthisto.path())
             sys.exit(1)
         pthigh=pt
 
 def mergeByMass(hpath, sqrts, scale=1.):
     global inhistos_mass
     global outhistos
     try:
         fillAbove(scale,outhistos[hpath], inhistos_mass[hpath][float(sqrts)])
     except:
         pass
 
 def useOneMass(hpath, sqrts, ptmin):
     global inhistos_mass
     global outhistos
     try:
        ## Find best pT_min match
         ptmins = inhistos_mass[hpath][float(sqrts)].keys()
         closest_ptmin = None
         for ptm in ptmins:
             if closest_ptmin is None or \
                     abs(ptm-float(ptmin)) < abs(closest_ptmin-float(ptmin)):
                 closest_ptmin = ptm
         if closest_ptmin != float(ptmin):
             logging.warning("Inexact match for requested pTmin=%s: " % ptmin + \
                                 "using pTmin=%e instead" % closest_ptmin)
         outhistos[hpath] =  inhistos_mass[hpath][float(sqrts)][closest_ptmin]
     except:
         pass
 
 import sys
 if sys.version_info[:3] < (2,4,0):
     print ("rivet scripts require Python version >= 2.4.0... exiting")
     sys.exit(1)
 
 if __name__ == "__main__":
     import logging
     from optparse import OptionParser, OptionGroup
     parser = OptionParser(usage="%prog base")
     verbgroup = OptionGroup(parser, "Verbosity control")
     verbgroup.add_option("-v", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
                          default=logging.INFO, help="print debug (very verbose) messages")
     verbgroup.add_option("-q", "--quiet", action="store_const", const=logging.WARNING, dest="LOGLEVEL",
                          default=logging.INFO, help="be very quiet")
     parser.add_option_group(verbgroup)
     (opts, args) = parser.parse_args()
     logging.basicConfig(level=opts.LOGLEVEL, format="%(message)s")
 
     ## Check args
     if len(args) < 1:
         logging.error("Must specify at least the name of the files")
         sys.exit(1)
 
     yodafiles=["-13-Z-e","-13-Z-mu","-Z-HighMass1-e","-Z-HighMass2-e",
                "-8-Z-Mass1-e" ,"-8-Z-Mass1-mu" ,"-8-Z-Mass2-e" ,"-8-Z-Mass2-mu" ,"-8-Z-Mass3-e" ,"-8-Z-Mass3-mu" ,"-8-Z-Mass4-e" ,"-8-Z-Mass4-mu" ,
                "-13-Z-Mass1-e","-13-Z-Mass1-mu","-13-Z-Mass2-e","-13-Z-Mass2-mu","-13-Z-Mass3-e","-13-Z-Mass3-mu","-13-Z-Mass4-e","-13-Z-Mass4-mu",
                "-W-e","-W-mu","-Z-e","-Z-mu","-Z-mu-Short","-Z-LowMass-e","-Z-LowMass-mu",
-               "-Z-MedMass-e","8-W-e","8-W-mu",
+               "-Z-MedMass-e","-8-W-e","-8-W-mu",
                "-WW-emu","-WW-ll","13-W-emu","-WZ","-ZZ-ll","-ZZ-lv","-13-ZZ-ll",
                "-8-WZ","-13-WZ","-8-ZZ-lv","-8-WW-ll",
                "-7-W-Jet-1-e","-7-W-Jet-2-e","-7-W-Jet-3-e","-7-Z-Jet-1-e","-7-Z-Jet-2-e","-7-Z-Jet-3-e",
                "-7-WGamma-e","-7-WGamma-mu","-7-ZGamma-e","-7-ZGamma-mu"]
     ## Get histos
     outhistos={}
 
     inhistos_mass = {}
     for f in yodafiles:
         file='Rivet-'+args[0]+f+".yoda"
         if not os.access(file, os.R_OK):
             logging.error("%s can not be read" % file)
             continue
         try:
             aos = yoda.read(file)
         except:
             logging.error("%s can not be parsed as yoda" % file)
             continue
         mass=66
         if(file.find("HighMass1")>=0) :
             mass = 116
         elif(file.find("HighMass2")>=0) :
             mass = 400
         elif(file.find("Mass1")>=0) :
             mass = 12
         elif(file.find("Mass2")>=0) :
             mass = 30
         elif(file.find("Mass3")>=0) :
             mass = 66
         elif(file.find("Mass4")>=0) :
             mass = 116
         ## Get histos from this YODA file
         for aopath, ao in aos.items() :
             if("RAW" in aopath) :continue
             if(aopath.find("ATLAS_2010_S8919674")>0) :
                 if((aopath.find("d01")>0 or aopath.find("d05")>0 or 
                     aopath.find("d07")>0) and file.find("-e")>0) : 
                     outhistos[aopath] = ao
                 elif((aopath.find("d02")>0 or aopath.find("d06")>0 or 
                       aopath.find("d08")>0) and file.find("-mu")>0) : 
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2011_S9131140")>0) :
                 if(aopath.find("d01")>0 and file.find("-e")>0) : 
                     outhistos[aopath] = ao
                 elif(aopath.find("d02")>0 and file.find("-mu")>0) : 
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2011_I925932")>0) :
                 if(aopath.find("d01")>0 and file.find("-e")>0) : 
                     outhistos[aopath] = ao
                 elif(aopath.find("d02")>0 and file.find("-mu")>0) : 
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2011_I945498")>0) :
                 if(aopath.find("y01")>0 and file.find("-e")>0) : 
                     outhistos[aopath] = ao
                 elif(aopath.find("y02")>0 and file.find("-mu")>0) : 
                     outhistos[aopath] = ao
                 elif(aopath.find("y03")>0 and file.find("-mu")>0) : 
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2013_I1217867")>0) :
                 if(aopath.find("y01")>0 and file.find("-e")>0) : 
                     outhistos[aopath] = ao
                 elif(aopath.find("y02")>0 and file.find("-mu")>0) : 
                     outhistos[aopath] = ao
             elif (aopath.find("CMS_2012_I941555")>0) :
                 if((aopath.find("y01")>0 or aopath.find("y03")>0 ) and file.find("-mu")>0) : 
                     outhistos[aopath] = ao
                 elif(aopath.find("y02")>0 and file.find("-e")>0) : 
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2014_I1300647" )>0) :
                 if(aopath.find("y01")>0 and file.find("-e")>0) : 
                     outhistos[aopath] = ao
                 elif((not aopath.find("y01")>0) and file.find("-mu")>0) :
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2014_I1288706" )>0) :
                 if(aopath.find("y02")>0 and file.find("-e")>0) : 
                     outhistos[aopath] = ao
                 elif(aopath.find("y01")>0 and file.find("-mu")>0) :
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2012_I1204784" )>0) :
                 if( file.find("-e")>0 and
                     ( aopath.find("d03")>0 or 
                       ((aopath.find("d01")>0 or aopath.find("d02")>0) and aopath.find("y01")>0))) : 
                     outhistos[aopath] = ao
                 elif(file.find("-mu")>0 and
                      ( aopath.find("d04")>0 or 
                        ((aopath.find("d01")>0 or aopath.find("d02")>0) and aopath.find("y02")>0))) : 
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2014_I1312627")>0) :
                 if("EL" in aopath) :
                     if(file.find("W")>0 and aopath.find("x02")>0) :
                         outhistos[aopath] = ao
                     elif(file.find("Z")>0 and aopath.find("x03")>0) :
                         outhistos[aopath] = ao
                 elif ("MU" in aopath) :
                     if(file.find("W")>0 and aopath.find("x02")>0) :
                         outhistos[aopath] = ao
                     elif(file.find("Z")>0 and aopath.find("x03")>0) :
                         outhistos[aopath] = ao
                 else :
                     if(file.find("W")>0 and aopath.find("x02")>0) :
                         outhistos[aopath] = ao
                     elif(file.find("Z")>0 and aopath.find("x03")>0) :
                         outhistos[aopath] = ao
             elif (aopath.find("CMS_2018_I1711625")>0) :
                 if( file.find("-e")>0 and aopath.find("d06-x01-y01") > 0 ):
                     if aopath in outhistos :
                         outhistos[aopath] += ao
                     else :
                         outhistos[aopath]  = ao
                 elif( file.find("-mu")>0 and (aopath.find("d03-x01-y01") > 0 or aopath.find("d05-x01-y01") > 0) ):
                     if aopath in outhistos :
                         outhistos[aopath] += ao
                     else :
                         outhistos[aopath]  = ao
             elif (aopath.find("CMS_2013_I1224539_WJET" )>0) :
                 if(file.find("-1-e")>0 and (aopath.find("d52")>0 or aopath.find("d53")>0 or aopath.find("d56")>0 or aopath.find("d57")>0 or aopath.find("d60")>0 or aopath.find("d61")>0 or aopath.find("d64")>0 or aopath.find("d65")>0 or aopath.find("d68")>0 or aopath.find("d69")>0 or aopath.find("d72")>0)) :
                     outhistos[aopath] = ao
                 elif(file.find("-2-e")>0 and (aopath.find("d54")>0 or aopath.find("d58")>0 or aopath.find("d62")>0 or aopath.find("d66")>0 or aopath.find("d70")>0 or aopath.find("d73")>0)) :
                     outhistos[aopath] = ao
                 elif(file.find("-3-e")>0 and (aopath.find("d55")>0 or aopath.find("d59")>0 or aopath.find("d63")>0 or aopath.find("d67")>0 or aopath.find("d71")>0 or aopath.find("d74")>0)) :
                     outhistos[aopath] = ao
             elif (aopath.find("CMS_2013_I1224539_ZJET" )>0) :
                 if(file.find("-1-e")>0 and (aopath.find("d29")>0 or aopath.find("d30")>0 or aopath.find("d33")>0 or aopath.find("d34")>0 or aopath.find("d37")>0 or aopath.find("d38")>0 or aopath.find("d41")>0 or aopath.find("d42")>0 or aopath.find("d45")>0 or aopath.find("d46")>0 or aopath.find("d49")>0)) :
                     outhistos[aopath] = ao
                 elif(file.find("-2-e")>0 and (aopath.find("d31")>0 or aopath.find("d35")>0 or aopath.find("d39")>0 or aopath.find("d43")>0 or aopath.find("d47")>0 or aopath.find("d50")>0)) :
                     outhistos[aopath] = ao
                 elif(file.find("-3-e")>0 and (aopath.find("d32")>0 or aopath.find("d36")>0 or aopath.find("d40")>0 or aopath.find("d44")>0 or aopath.find("d48")>0 or aopath.find("d51")>0)) :
                     outhistos[aopath] = ao
             elif (aopath.find("CMS_2013_I1258128")>0) :
                 if(aopath.find("d01")>0 or aopath.find("d02")>0 or
                    aopath.find("d03")>0 or aopath.find("d04")>0) :
                     outhistos[aopath] = ao
             elif (aopath.find("CMS_2013_I1209721" )>0 and file.find("-0")>0 ) :
                 outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2011_I928289")>0) :
                 if(file.find("-e")>=0 and (aopath.find("y01")>=0 or aopath.find("y02")>=0)) :
                     outhistos[aopath] = ao
                 elif(file.find("-mu")>=0 and (aopath.find("y03")>=0 or aopath.find("y04")>=0)) :
                     outhistos[aopath] = ao
             elif (aopath.find("CMS_2013_I1122847")>0) :
                 if(file.find("-mu")>=0 and aopath.find("d01")>=0 ) :
                     outhistos[aopath] = ao
                 elif(file.find("-e")>=0 and (aopath.find("d02")>=0 or aopath.find("d03")>=0)) :
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2016_I1424838")>0) :
                 ihist = int(aopath.split("/")[2].split("-")[0].replace("d",""))
                 if(file.find("-mu")>=0 and ihist>30 ) :
                     outhistos[aopath] = ao
                 elif(file.find("-e")>=0 and ihist<=30) :
                     outhistos[aopath] = ao
 
             elif "ATLAS_2016_I1502620" in aopath :
                 newPath = aopath.split(":")[0]+"/"+aopath.split("/")[-1]
                 if newPath in outhistos :
                     continue
                 else :                
                     outhistos[newPath] = ao
                     ao.setPath(newPath)
             elif ("CMS_2015_I1310737" in aopath or "ATLAS_2013_I1219109" in aopath or
                   ("ATLAS_2014_I1319490" in aopath and "y01" in aopath )) :
                 if aopath in outhistos :
                     outhistos[aopath] += ao
                 else :
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2015_I1351916")>=0) :
                 if(aopath.find("-y02")>=0) :
                     pathBase = "/%s/" % aopath.split("/")[1]
                     if("d03" in aopath) :
                         hp = aos[pathBase+"_ncf_pos"]
                         hm = aos[pathBase+"_ncf_neg"]
                     else :
                         hp = aos[pathBase+"_ncc_pos"]
                         hm = aos[pathBase+"_ncc_neg"]
                     ratio = (hp-hm)/(hp+hm)
                     title=""
                     if hasattr(ao, 'title'):
                         title=ao.title()
                     hnew = yoda.core.Scatter2D(aopath,title)
                     hnew.combineWith(ratio)
                     outhistos[aopath] = hnew
                 else :
                     continue
             elif (aopath.find("ATLAS_2014_I1282447")>=0) :
                 if((aopath.find("/ATLAS_2014_I1282447/d02-x01-y01")>=0 or
                     aopath.find("/ATLAS_2014_I1282447/d08-x01-y01")>=0 or 
                     aopath.find("/ATLAS_2014_I1282447/d02-x01-y02")>=0 or 
                     aopath.find("/ATLAS_2014_I1282447/d02-x01-y01")>=0 or
                     aopath.find("/ATLAS_2014_I1282447/d05-x01-y02")>=0 or 
                     aopath.find("/ATLAS_2014_I1282447/d05-x01-y03")>=0 or 
                     aopath.find("/ATLAS_2014_I1282447/d06-x01-y01")>=0 or
                     aopath.find("/ATLAS_2014_I1282447/d06-x01-y02")>=0 or 
                     aopath.find("/ATLAS_2014_I1282447/d06-x01-y03")>=0 or 
                     aopath.find("/ATLAS_2014_I1282447/d06-x01-y04")>=0) and 
                    not (aopath.find("plus")>=0 or aopath.find("minus")>=0 or
                         aopath.find("inc")>=0)) :
                     continue
                 if aopath in outhistos :
                     outhistos[aopath] += ao
                 else :
                     outhistos[aopath] = ao
             elif (aopath.find("ATLAS_2015_I1408516")>=0) :
                 if aopath not in inhistos_mass:
                     inhistos_mass[aopath] = {}
                 tmpE = inhistos_mass[aopath]
                 sqrts=8000
                 if sqrts not in tmpE:
                     tmpE[sqrts] = {}
                 tmpP = tmpE[sqrts]
                 if mass not in tmpP:
                     tmpP[mass] = ao
                 else:
                     raise Exception("A set with mass = %s already exists" % ( mass))
             elif (aopath.find("ATLAS_2013_I1234228")>=0) :
                 if aopath not in inhistos_mass:
                     inhistos_mass[aopath] = {}
                 tmpE = inhistos_mass[aopath]
                 sqrts=7000
                 if sqrts not in tmpE:
                     tmpE[sqrts] = {}
                 tmpP = tmpE[sqrts]
                 if mass not in tmpP:
                     tmpP[mass] = ao
                 else:
                     raise Exception("A set with mass = %s already exists" % ( mass))
             elif (aopath.find("ATLAS_2017_I1514251")>=0) :
                 outhistos[aopath] = ao
                 if(type(ao)==yoda.core.Scatter2D) :
                     ao.scaleY(2.)
                 elif(type(ao)==yoda.core.Histo1D) :
                     ao.scaleW(2.)
             elif ( "2015_041_" in aopath) :
                 aopath=aopath.replace("_EL","").replace("_MU","")
                 ao.setPath(aopath)
                 outhistos[aopath] = ao
             elif "CMS_2019_I1753680" in aopath :
                 if("d26" in aopath or "d27" in aopath or "d28" in aopath) :
                     if ("y01" in aopath and "=MU" in aopath) or ("y02" in aopath and "=EL" in aopath) :
                         outhistos[aopath] = ao
                     elif ("y03" in aopath and "=EMU" in aopath) :
                         if aopath in outhistos :
                             outhistos[aopath] += ao
                         else :
                             outhistos[aopath] = ao
                 elif  "=EMU" in aopath:
                     if aopath in outhistos :
                         outhistos[aopath] += ao
                         if "d29" not in aopath :
                             outhistos[aopath].scaleW(0.5)
                     else :
                         outhistos[aopath]  = ao
             elif "CMS_2018_I1667854" in aopath :
                 if "=EMU" in aopath:
                     if aopath in outhistos :
                         outhistos[aopath] += ao
                     else :
                         outhistos[aopath]  = ao
             else :
                 outhistos[aopath] = ao
     for hpath,hsets in inhistos_mass.items():
         if(hpath!="/ATLAS_2015_I1408516:LMODE=EL/d41-x01-y01" and
            hpath!="/ATLAS_2015_I1408516:LMODE=MU/d41-x01-y02" and
            hpath!="/ATLAS_2013_I1234228/d01-x01-y02" ) :
             continue
         title=""
         path=""
         histo = list(list(hsets.values())[0].values())[0]
         if hasattr(histo, 'title'):
             title=histo.title()
         if hasattr(histo, 'path'):
             path=histo.path()
         if(type(histo)==yoda.core.Scatter2D) :
             outhistos[hpath] = yoda.core.Scatter2D(path,title)
         elif(type(histo)==yoda.core.Profile1D) :
             outhistos[hpath] = yoda.core.Profile1D(path,title)
             for i in range(0,histo.numBins()) :
                 outhistos[hpath].addBin(histo.bins()[i].xMin(),
                                         histo.bins()[i].xMax())
         elif(type(histo)==yoda.core.Histo1D) :
             outhistos[hpath] = yoda.core.Histo1D(path,title)
             for i in range(0,histo.numBins()) :
                 outhistos[hpath].addBin(histo.bins()[i].xMin(),
                                         histo.bins()[i].xMax())
         else :
             logging.error("Histogram %s is of unknown type" % hpath)
             sys.exit(1)
     # sort out mass bins for ATLAS Z-> e,mu at 8 TeV
     for ltype in ["EL","MU"] :
         if(ltype=="EL") :
             y = "y01"
             mergeByMass("/ATLAS_2015_I1408516:LMODE=EL/d41-x01-y01", "8000")
         else :
             y = "y04"
             mergeByMass("/ATLAS_2015_I1408516:LMODE=MU/d41-x01-y02", "8000")
         for d in [2,3,4,14,26,38]:
             useOneMass("/ATLAS_2015_I1408516:LMODE=%s/d%02d-x01-%s" % (ltype,d,y), "8000", "30" )
         for d in [5,6,7,8,9,10,15,17,18,19,20,21,22,27,29,30,31,32,33,34,39]:
             useOneMass("/ATLAS_2015_I1408516:LMODE=%s/d%02d-x01-%s" % (ltype,d,y), "8000", "66" )
         for d in [11,12,13,16,28,40]:
             useOneMass("/ATLAS_2015_I1408516:LMODE=%s/d%02d-x01-%s" % (ltype,d,y), "8000", "116" )
         for d in [23,35]:
             useOneMass("/ATLAS_2015_I1408516:LMODE=%s/d%02d-x01-%s" % (ltype,d,y), "8000", "12" )
         for d in [24,36]:
             useOneMass("/ATLAS_2015_I1408516:LMODE=%s/d%02d-x01-%s" % (ltype,d,y), "8000", "12" )
         for d in [25,37]:
             useOneMass("/ATLAS_2015_I1408516:LMODE=%s/d%02d-x01-%s" % (ltype,d,y), "8000", "30" )
     # sort out ratios for ATLAS W+c
     if("/ATLAS_2014_I1282447/d02-x01-y01_plus" in outhistos and 
        "/ATLAS_2014_I1282447/d02-x01-y01_minus" in outhistos) :
         d02y01_plus  = outhistos["/ATLAS_2014_I1282447/d02-x01-y01_plus"]
         d02y01_minus = outhistos["/ATLAS_2014_I1282447/d02-x01-y01_minus"]
         ratio_d02y01 = d02y01_plus/d02y01_minus
         ratio_d02y01.setPath("/ATLAS_2014_I1282447/d02-x01-y01")
         del outhistos["/ATLAS_2014_I1282447/d02-x01-y01_plus"]
         del outhistos["/ATLAS_2014_I1282447/d02-x01-y01_minus"]
         outhistos["/ATLAS_2014_I1282447/d02-x01-y01"] = ratio_d02y01
     if("/ATLAS_2014_I1282447/d02-x01-y02_plus" in outhistos and 
        "/ATLAS_2014_I1282447/d02-x01-y02_minus" in outhistos) :
         d02y02_plus  = outhistos["/ATLAS_2014_I1282447/d02-x01-y02_plus"]
         d02y02_minus = outhistos["/ATLAS_2014_I1282447/d02-x01-y02_minus"]
         ratio_d02y02 = d02y02_plus/d02y02_minus
         ratio_d02y02.setPath("/ATLAS_2014_I1282447/d02-x01-y02")
         del outhistos["/ATLAS_2014_I1282447/d02-x01-y02_plus"]
         del outhistos["/ATLAS_2014_I1282447/d02-x01-y02_minus"]
         outhistos["/ATLAS_2014_I1282447/d02-x01-y02"] = ratio_d02y02
     if("/ATLAS_2014_I1282447/d08-x01-y01_plus" in outhistos and 
        "/ATLAS_2014_I1282447/d08-x01-y01_minus" in outhistos) :
         d08y01_plus  = outhistos["/ATLAS_2014_I1282447/d08-x01-y01_plus"]
         d08y01_minus = outhistos["/ATLAS_2014_I1282447/d08-x01-y01_minus"]
         ratio_d08y01 = d08y01_plus/d08y01_minus
         ratio_d08y01.setPath("/ATLAS_2014_I1282447/d08-x01-y01")
         del outhistos["/ATLAS_2014_I1282447/d08-x01-y01_plus"]
         del outhistos["/ATLAS_2014_I1282447/d08-x01-y01_minus"]
         outhistos["/ATLAS_2014_I1282447/d08-x01-y01"] = ratio_d08y01
     if ("/ATLAS_2014_I1282447/d05-x01-y01" in outhistos and
         "/ATLAS_2014_I1282447/d01-x01-y02" in outhistos) :
         h_winc = outhistos["/ATLAS_2014_I1282447/d05-x01-y01"]
         h_d    = outhistos["/ATLAS_2014_I1282447/d01-x01-y02"]
         ratio_wd      =  h_d/h_winc
         ratio_wd.setPath("/ATLAS_2014_I1282447/d05-x01-y02")
         outhistos["/ATLAS_2014_I1282447/d05-x01-y02"] = ratio_wd
     if ("/ATLAS_2014_I1282447/d05-x01-y01" in outhistos and
         "/ATLAS_2014_I1282447/d01-x01-y03" in outhistos) :
         h_winc = outhistos["/ATLAS_2014_I1282447/d05-x01-y01"]
         h_dstar= outhistos["/ATLAS_2014_I1282447/d01-x01-y03"]
         ratio_wdstar      =  h_dstar/h_winc
         ratio_wdstar.setPath("/ATLAS_2014_I1282447/d05-x01-y03")
         outhistos["/ATLAS_2014_I1282447/d05-x01-y03"] = ratio_wdstar
     if("/ATLAS_2014_I1282447/d06-x01-y01_winc" in outhistos and
        "/ATLAS_2014_I1282447/d06-x01-y02_winc" in outhistos) :
         h_winc_plus  = outhistos["/ATLAS_2014_I1282447/d06-x01-y01_winc"]
         h_winc_minus = outhistos["/ATLAS_2014_I1282447/d06-x01-y02_winc"]
         if( "/ATLAS_2014_I1282447/d06-x01-y01_wplus" in outhistos ) :
             h_wd_plus      = outhistos["/ATLAS_2014_I1282447/d06-x01-y01_wplus"]
             ratio_wd_plus       =  h_wd_plus/h_winc_plus
             ratio_wd_plus.setPath("/ATLAS_2014_I1282447/d06-x01-y01")
             outhistos["/ATLAS_2014_I1282447/d06-x01-y01"] = ratio_wd_plus
             del outhistos["/ATLAS_2014_I1282447/d06-x01-y01_wplus"]
         if( "/ATLAS_2014_I1282447/d06-x01-y02_wminus" in outhistos ) :
             h_wd_minus     = outhistos["/ATLAS_2014_I1282447/d06-x01-y02_wminus"]
             ratio_wd_minus      =  h_wd_minus/h_winc_minus
             ratio_wd_minus.setPath("/ATLAS_2014_I1282447/d06-x01-y02")
             outhistos["/ATLAS_2014_I1282447/d06-x01-y02"] = ratio_wd_minus
             del outhistos["/ATLAS_2014_I1282447/d06-x01-y02_wminus"]
         if ( "/ATLAS_2014_I1282447/d06-x01-y03_wplus" in outhistos) : 
             h_wdstar_plus  = outhistos["/ATLAS_2014_I1282447/d06-x01-y03_wplus"]
             ratio_wdstar_plus       =  h_wdstar_plus/h_winc_plus
             ratio_wdstar_plus.setPath("/ATLAS_2014_I1282447/d06-x01-y03")
             outhistos["/ATLAS_2014_I1282447/d06-x01-y03"] = ratio_wdstar_plus 
             del outhistos["/ATLAS_2014_I1282447/d06-x01-y03_wplus"]
         if ( "/ATLAS_2014_I1282447/d06-x01-y04_wminus" in outhistos) :
             h_wdstar_minus = outhistos["/ATLAS_2014_I1282447/d06-x01-y04_wminus"]
             ratio_wdstar_minus      =  h_wdstar_minus/h_winc_minus
             ratio_wdstar_minus.setPath("/ATLAS_2014_I1282447/d06-x01-y04")
             outhistos["/ATLAS_2014_I1282447/d06-x01-y04"] = ratio_wdstar_minus
             del outhistos["/ATLAS_2014_I1282447/d06-x01-y04_wminus"]
         del outhistos["/ATLAS_2014_I1282447/d06-x01-y01_winc"]
         del outhistos["/ATLAS_2014_I1282447/d06-x01-y02_winc"]
 
         
     mergeByMass("/ATLAS_2013_I1234228/d01-x01-y02", "7000")
     # ATLAS W/Z ratios
     iy=0
     for suffix in ["",":LMODE=EL",":LMODE=MU"] :
         iy+=1
         basePath = "/ATLAS_2014_I1312627%s/" % suffix
         for ihist in range(1,21) :
             num = "%sd%02d-x02-y%02d" % (basePath,ihist,iy) 
             den = "%sd%02d-x03-y%02d" % (basePath,ihist,iy)
             if(den in outhistos and num in outhistos) :
                 ratio = outhistos[num]/outhistos[den]
                 ratio.setPath("%sd%02d-x01-y%02d" % (basePath,ihist,iy))
                 del outhistos[num]
                 del outhistos[den]
                 outhistos[ "%sd%02d-x01-y%02d" % (basePath,ihist,iy)]=ratio
             elif den in outhistos :
                 del outhistos[den]
             elif num in outhistos :
                 del outhistos[num]
+    # LHCB W/Z + jets
+    if("/LHCB_2016_I1454404:MODE=WJET/d01-x01-y01" in outhistos and
+       "/LHCB_2016_I1454404:MODE=WJET/d01-x01-y02" in outhistos and
+       "/LHCB_2016_I1454404:MODE=ZJET/d01-x01-y03" in outhistos) :
+        hZ = outhistos["/LHCB_2016_I1454404:MODE=ZJET/d01-x01-y03"]
+        hWp= outhistos["/LHCB_2016_I1454404:MODE=WJET/d01-x01-y01"]
+        hWm= outhistos["/LHCB_2016_I1454404:MODE=WJET/d01-x01-y02"]
+        hsum=hWp+hWm
+        r1=hsum/hZ
+        r1.setPath("/LHCB_2016_I1454404/d02-x01-y01")
+        outhistos["/LHCB_2016_I1454404/d02-x01-y01"]=r1
+        r1=hWp/hZ
+        r1.setPath("/LHCB_2016_I1454404/d02-x01-y02")
+        outhistos["/LHCB_2016_I1454404/d02-x01-y02"]=r1
+        r1=hWm/hZ
+        r1.setPath("/LHCB_2016_I1454404/d02-x01-y03")
+        outhistos["/LHCB_2016_I1454404/d02-x01-y03"]=r1
     # Choose output file
     name = args[0]+"-EW.yoda"
     yoda.writeYODA(outhistos,name)
     sys.exit(0)
diff --git a/Tests/python/merge-Star.in b/Tests/python/merge-Star.in
new file mode 100644
--- /dev/null
+++ b/Tests/python/merge-Star.in
@@ -0,0 +1,172 @@
+#! @PYTHON@
+from __future__ import print_function
+import logging
+import sys
+
+if sys.version_info[:3] < (2,4,0):
+    print ("rivet scripts require Python version >= 2.4.0... exiting")
+    sys.exit(1)
+
+import os, yoda
+
+# #############################################
+
+def fillAbove(desthisto, sourcehistosbyptmin):
+    pthigh= 1e100
+    ptlow =-1e100
+    for pt, h in sorted(sourcehistosbyptmin.items(),reverse=True):
+        ptlow=pt
+        if(type(desthisto)==yoda.core.Scatter2D) :
+            for i in range(0,h.numPoints()) :
+                xMin = h.points()[i].x-h.points()[i].xErrs().minus
+                if( xMin >= ptlow and 
+                    xMin <  pthigh ) :
+                    desthisto.addPoint(h.points()[i])
+        elif(type(desthisto)==yoda.core.Profile1D) :
+            for i in range(0,h.numBins()) :
+                if(h.bins()[i].xMin()  >= ptlow and 
+                   h.bins()[i].xMin()  <  pthigh ) :
+                    desthisto.bins()[i] += h.bins()[i]
+        elif(type(desthisto)==yoda.core.Histo1D) :
+            for i in range(0,h.numBins()) :
+                if(h.bins()[i].xMin()  >= ptlow and 
+                   h.bins()[i].xMin()  <  pthigh ) :
+                    desthisto.bins()[i] += h.bins()[i]
+        else :
+            logging.error("Can't merge %s, unknown type" % desthisto.path)
+            sys.exit(1)
+        pthigh=pt
+
+def mergeByPt(hpath, sqrts):
+    global inhistos
+    global outhistos
+    try:
+        fillAbove(outhistos[hpath], inhistos[hpath][float(sqrts)])
+    except:
+        pass
+
+def useOnePt(hpath, sqrts, ptmin):
+    global inhistos
+    global outhistos
+    try:
+       ## Find best pT_min match
+        ptmins = inhistos[hpath][float(sqrts)].keys()
+        closest_ptmin = None
+        for ptm in ptmins:
+            if closest_ptmin is None or \
+                    abs(ptm-float(ptmin)) < abs(closest_ptmin-float(ptmin)):
+                closest_ptmin = ptm
+        if closest_ptmin != float(ptmin):
+            logging.warning("Inexact match for requested pTmin=%s: " % ptmin + \
+                                "using pTmin=%e instead" % closest_ptmin)
+        outhistos[hpath] =  inhistos[hpath][float(sqrts)][closest_ptmin]
+    except:
+        pass
+
+# #######################################
+
+if __name__ == "__main__":
+    import logging
+    from optparse import OptionParser, OptionGroup
+    parser = OptionParser(usage="%prog name")
+    verbgroup = OptionGroup(parser, "Verbosity control")
+    verbgroup.add_option("-v", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
+                         default=logging.INFO, help="print debug (very verbose) messages")
+    verbgroup.add_option("-q", "--quiet", action="store_const", const=logging.WARNING, dest="LOGLEVEL",
+                         default=logging.INFO, help="be very quiet")
+    parser.add_option_group(verbgroup)
+    (opts, args) = parser.parse_args()
+    logging.basicConfig(level=opts.LOGLEVEL, format="%(message)s")
+
+    ## Check args
+    if len(args) < 1:
+        logging.error("Must specify at least the name of the files")
+        sys.exit(1)
+
+yodafiles=["-UE.yoda","-Jets-1.yoda","-Jets-2.yoda","-Jets-3.yoda","-Jets-4.yoda"]
+
+## Get histos
+inhistos = {}
+outhistos={}
+weights = {}
+for f in yodafiles:
+    file='Rivet-'+args[0]+f
+    if(file.find("-UE")>0) :
+        sqrts=200
+        ptmin=0.
+    elif(file.find("-Jets-1")>0) :
+        sqrts=200
+        ptmin=2.
+    elif(file.find("-Jets-2")>0) :
+        sqrts=200
+        ptmin=5.
+    elif(file.find("-Jets-3")>0) :
+        sqrts=200
+        ptmin=26.
+    elif(file.find("-Jets-4")>0) :
+        sqrts=200
+        ptmin=15.
+
+    if not os.access(file, os.R_OK):
+        logging.error("%s can not be read" % file)
+        continue
+    try:
+        aos = yoda.read(file)
+    except:
+        logging.error("%s can not be parsed as YODA" % file)
+        continue
+    ## Get histos from this YODA file
+    for aopath, ao in aos.items() :
+        if("RAW" in aopath) :continue
+        if(aopath.find("6870392")>0 or aopath.find("HELEN")>0) :
+            if aopath not in inhistos:
+                inhistos[aopath] = {}
+            tmpE = inhistos[aopath]
+            if sqrts not in tmpE:
+                tmpE[sqrts] = {}
+            tmpP = tmpE[sqrts]
+            if ptmin not in tmpP:
+                tmpP[ptmin] = ao
+            else:
+                raise Exception("A set with ptmin = %s already exists" % ( ptmin))
+        else :
+            outhistos[aopath] = ao
+
+## Make empty output histos if needed
+for hpath,hsets in inhistos.items():
+    if( (hpath.find("6870392")>0 and hpath.find("d02-x01-y01" )>0 ) or
+        hpath.find("HELEN")>0 ) :
+        title=""
+        path=""
+        histo = list(list(hsets.values())[0].values())[0]
+        if hasattr(histo, 'title'):
+            title=histo.title()
+        if hasattr(histo, 'path'):
+            path=histo.path()
+        if(type(histo)==yoda.core.Scatter2D) :
+            outhistos[hpath] = yoda.core.Scatter2D(path,title)
+        elif(type(histo)==yoda.core.Profile1D) :
+            outhistos[hpath] = yoda.core.Profile1D(path,title)
+            for i in range(0,histo.numBins()) :
+                outhistos[hpath].addBin(histo.bins()[i].xMin(),
+                                        histo.bins()[i].xMax())
+        elif(type(histo)==yoda.core.Histo1D) :
+            outhistos[hpath] = yoda.core.Histo1D(path,title)
+            for i in range(0,histo.numBins()) :
+                outhistos[hpath].addBin(histo.bins()[i].xMin(),
+                                        histo.bins()[i].xMax())
+        else :
+            logging.error("Histogram %s is of unknown type" % hpath)
+            print (hpath,type(histo))
+            sys.exit(1)
+
+useOnePt("/STAR_2006_S6870392/d01-x01-y01","200","2")
+mergeByPt("/STAR_2006_S6870392/d02-x01-y01","200")
+mergeByPt("/STAR_2009_UE_HELEN/d01-x01-y01","200")
+mergeByPt("/STAR_2009_UE_HELEN/d02-x01-y01","200")
+mergeByPt("/STAR_2009_UE_HELEN/d03-x01-y01","200")
+
+# Choose output file
+name = args[0]+".yoda"
+yoda.writeYODA(outhistos,name)
+sys.exit(0)
diff --git a/m4/herwig.m4 b/m4/herwig.m4
--- a/m4/herwig.m4
+++ b/m4/herwig.m4
@@ -1,973 +1,983 @@
 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
 
 AM_CONDITIONAL(HAVE_RIVET,[test x$THEPEGHASRIVET = xyes])
 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_LANG_PUSH([Fortran])
 AC_MSG_CHECKING([checking if fortran compiler compiles argument mismatches])
 AC_COMPILE_IFELSE(AC_LANG_SOURCE([[
       program temp
       call a(1.0D0)
       end program
       subroutine a(b)
       double complex b
       end]]),
       [AC_MSG_RESULT([yes])],
       [oldFCFLAGS="$FCFLAGS"
       FCFLAGS="-std=legacy"
       AC_MSG_CHECKING([checking if fortran compiler compiles argument mismatches with -std=legacy])
       AC_COMPILE_IFELSE(AC_LANG_SOURCE([[
       program temp
       double precision b
       double complex c
       b = 1.0D0
       c  =1.0D0
       call a(b)
       call a(c)
       end program
       subroutine a(b)
       double complex b
       end]]),
       [AC_MSG_RESULT([yes])
        AM_FCFLAGS="$AM_FCFLAGS -std=legacy"],
       [AC_MSG_RESULT([no])
       AC_MSG_ERROR([fortran compiler won't compile LoopTools])])
      FCFLAGS="$oldFCFLAGS -std=legacy"]
 )
 
 AC_MSG_CHECKING([checking if fortran compiler compiles long lines])
 AC_COMPILE_IFELSE(AC_LANG_SOURCE([[
        program temp
        write (*,*) 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        end program]]),
        [AC_MSG_RESULT([yes])],
        [AC_MSG_RESULT([no])
        oldFCFLAGS="$FCFLAGS"
        FCFLAGS="-ffixed-line-length-none"
        AC_MSG_CHECKING([checking if fortran compiler compiles long lines with -ffixed-line-length-none])
        AC_COMPILE_IFELSE(AC_LANG_SOURCE([[
        program temp
        write (*,*) 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        end program]]),
        [AC_MSG_RESULT([yes])
        AM_FCFLAGS="$AM_FCFLAGS -ffixed-line-length-none"
        FCFLAGS="$oldFCFLAGS -ffixed-line-length-none"],
        [FCFLAGS="-132"
        AC_MSG_CHECKING([checking if fortran compiler compiles long lines with -132])
        AC_COMPILE_IFELSE(AC_LANG_SOURCE([[
        program temp
        write (*,*) 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        end program]]),
        [AC_MSG_RESULT([yes])
        AM_FCFLAGS="$AM_FCFLAGS -132"
        FCFLAGS="$oldFCFLAGS -132"],
        [AC_MSG_RESULT([no])
        AC_MSG_ERROR([fortran compiler won't compile LoopTools])])])
       ]
 )
 
 
 
 
 
 AC_LANG_POP([Fortran])
 
 
 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"])
 
+AS_IF([test "x$with_njet" != "xno"],[AC_MSG_CHECKING([for Njet version])
+tmp_njetversion=[$(${with_njet}/bin/njet.py --version 2>&1 | grep -oE '[0-9]{4}$')]
+AS_IF([test -z "$tmp_njetversion"],
+      [tmp_njetversion=1023])
+      AC_MSG_RESULT([${tmp_njetversion}])
+      NJET_VERSION=${tmp_njetversion}
+      AC_SUBST(NJET_VERSION)
+])
+
 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"
+      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_ARG_WITH([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])
 
 ])
 
 
+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);
+   PYTHIA8LIB=
+#   $2
+else
+   PYTHIA8DATA=`${pythiaconfig} --datadir`/xmldoc
+   PYTHIA8LIB="-L`${pythiaconfig} --libdir` -lpythia8"
+fi
+
+AC_SUBST(PYTHIA8DATA)
+AC_SUBST(PYTHIA8LIB)
+
+])
+
+dnl CHECK PYTHIA END
+
 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" -o "x$have_evtgen" = "xlib64"])
 
 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"
+      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
+*** njet:		$with_njet ${NJET_VERSION}
 *** 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
 *** FCFLAGS:            $FCFLAGS
 *****************************************************
 _HW_EOF_
 ])
diff --git a/src/Makefile.am b/src/Makefile.am
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,233 +1,237 @@
 SUBDIRS = defaults snippets Matchbox Merging
 
 defaultsdir = ${pkgdatadir}/defaults
 
 bin_PROGRAMS = Herwig
 
 Herwig_SOURCES = \
 HerwigMain.cc HerwigCLI.cc HerwigCLI.h \
 herwigopts.c herwigopts.h
 
 BUILT_SOURCES = herwigopts.c herwigopts.h
 
 Herwig_LDFLAGS = $(AM_LDFLAGS) -export-dynamic $(THEPEGLDFLAGS)
 Herwig_LDADD = $(THEPEGLIB) -ldl \
 $(top_builddir)/API/libHerwigAPI.la
 
 bin_SCRIPTS = herwig-config
 
 HELPERFILES = \
 CMSSM40.1.1.slha \
 NMSSM.spc \
 ADD.model \
 Leptoquark.model \
 LH.model \
 LHTP.model \
 MSSM.model \
 MUED.model \
 NMSSM.model \
 RPV-Bi.model \
 RPV-Tri.model \
 RS.model \
 DM.model \
 Sextet.model \
 TTBA.model \
 Zprime.model \
 RPV-BI.slha \
 RPV-TRI.slha \
 RPV-UDD.slha
 
 INPUTFILES = \
 DIS.in \
 DIS-Matchbox.in \
 GammaGamma.in \
 ILC.in \
 ILC-MSSM.in \
 ILC-MUED.in \
 ILC-RS.in \
 LEP.in \
 LEP-Matchbox.in \
 LHC-ADD.in \
 LHC-CEX.in \
 LHC-GammaGamma.in \
 LHC-ResolvedGammaGamma.in \
 LHC.in \
 LHC-Matchbox.in \
 LHC-LQ.in \
 LHC-MSSM.in \
 LHC-MUED.in \
 LHC-NMSSM.in \
 LHC-Powheg.in \
 LHC-RPV.in \
 LHC-RS.in \
 LHC-Sextet.in \
 LHC-TRP.in \
 LHC-TTBA.in \
 LHC-MB.in \
 LHC-ZP.in \
 TVT.in \
 TVT-Powheg.in \
 TVT-TTBA.in \
 LHC-LH.in \
 LHC-LHTP.in \
 LHE.in \
 LHE-POWHEG.in \
 LHE-MCatNLO.in \
 LHE-FxFx.in \
 LHE-MGMerging.in \
 DM.in
 
 dist_pkgdata_DATA = $(INPUTFILES) $(HELPERFILES)
 pkgdata_DATA = Makefile-UserModules
 
 CLEANFILES = HerwigDefaults.rpo \
   *.run *.log *.out *.tex \
   multi.test *.output probs.test chisq.value \
   LHC-RS-BR.spc LHC-MSSM-BR.spc LHC-RPV-BR.spc
 
 clean-local:
 	-rm -rf Herwig
 
 ## checking targets ##
 
 HerwigDefaults.rpo: Herwig $(srcdir)/defaults/*.in defaults/PDF.in defaults/Analysis.in $(top_builddir)/lib/*.so
 	./Herwig init -L$(top_builddir)/lib defaults/HerwigDefaults.in -D
 
 check_BSM_Full=
 check_BSM=
 
 if WANT_BSM
 
 check_BSM += check-LHC-RPV check-LHC-RS
 
 check_BSM_Full += \
 check-LHC-RPV check-LHC-MSSM check-ILC-MSSM \
 check-LHC-NMSSM \
 check-LHC-MUED check-ILC-MUED \
 check-LHC-RS check-ILC-RS check-LHC-ADD \
 check-LHC-LH check-LHC-LHTP \
 check-LHC-TRP \
 check-LHC-TTBA check-TVT-TTBA \
 check-LHC-ZP \
 check-LHC-LQ \
 check-LHC-Sextet \
 check-DM
 
 endif
 check_BSM_Full_valgrind = $(subst check,check-valgrind,$(check_BSM_Full))
 check_BSM_valgrind = $(subst check,check-valgrind,$(check_BSM))
 
 check-local: check-LEP check-LHC $(check_BSM) check-DIS check-ILC check-GammaGamma check-LHC-Powheg
 
 check-valgrind-local: check-valgrind-LEP check-valgrind-LHC $(check_BSM_valgrind) check-valgrind-DIS check-valgrind-ILC check-valgrind-GammaGamma check-valgrind-LHC-Powheg
 
 check-Powheg: check-LHC-Powheg check-TVT-Powheg
 
 check-valgrind-Powheg: check-valgrind-LHC-Powheg check-valgrind-TVT-Powheg
 
 check-BSM: $(check_BSM_Full)
 
 check-valgrind-BSM: $(check_BSM_Full_valgrind)
 
 check_Matchbox= \
 check-LEP-Matchbox check-DIS-Matchbox check-LHC-Matchbox
 check_Matchbox_valgrind = $(subst check,check-valgrind,$(check_Matchbox))
 
 check-Matchbox: $(check_Matchbox)
 
 check-valgrind-Matchbox: $(check_Matchbox_valgrind)
 
 check-extra: check-LHC-CEX check-LHC-GammaGamma check-LHC-ResolvedGammaGamma check-LHC-MB check-TVT
 
 check-valgrind-extra: check-valgrind-LHC-CEX check-valgrind-LHC-GammaGamma check-valgrind-LHC-MB check-valgrind-TVT
 
 check-all: check-local check-Powheg check-BSM check-Matchbox check-extra
 
 check-valgrind-all: check-valgrind-local check-valgrind-Powheg check-valgrind-BSM check-valgrind-Matchbox check-valgrind-extra
 
 link-helper-files:
 	@for i in $(HELPERFILES); do \
 	if test -f $(srcdir)/$$i -a ! -e $$i; then \
 	$(LN_S) -f $(srcdir)/$$i; fi; done
 
 ## valgrind targets ##
 
 VALGRIND=valgrind --leak-check=full --num-callers=25 --freelist-vol=100000000 --leak-resolution=med --trace-children=yes
 
 check-valgrind-%: $(srcdir)/%.in HerwigDefaults.rpo link-helper-files
 	$(VALGRIND) ./Herwig read -d1 -D $< &> valgrind-$(notdir $(subst .in,,$<))-read.log
 	$(VALGRIND) ./Herwig run $(notdir $(subst .in,.run,$<)) -N 500 -d1 -D &> valgrind-$(notdir $(subst .in,,$<))-run.log
 
 valgrind: valgrind-init valgrind-read valgrind-run
 
 valgrind-init:
 	$(VALGRIND) ./Herwig init -d1 -D -L$(top_builddir)/lib defaults/HerwigDefaults.in \
 &> /tmp/valgrind-init.log
 valgrind-read:
 	$(VALGRIND) ./Herwig read -d1 -D LHC.in &> /tmp/valgrind-read.log
 valgrind-run:
 	$(VALGRIND) ./Herwig run -d1 -D -N5 LHC.run &> /tmp/valgrind-run.log
 
 CHECKCOMMAND = ./Herwig run  $(notdir $(subst .in,.run,$<)) -N500 -d1 -D
 
 check-%: $(srcdir)/%.in HerwigDefaults.rpo link-helper-files
 	./Herwig read -i . $< -D
 	@echo $(CHECKCOMMAND)
 	@$(CHECKCOMMAND) && echo "# $@ OK #" \
 			 || (echo "###### $@ BAD ######"; false)
 SETUPTHEPEG=$(THEPEGPATH)/bin/setupThePEG
 THEPEGREPO=$(THEPEGLIBPATH)/ThePEGDefaults.rpo
 
 install-data-hook:
 	@echo Creating repository
+
+	@if [ "$(PYTHON_PLATFORM)" = "darwin" ]; then\
+				install_name_tool -add_rpath $(DESTDIR)$(libdir) $(DESTDIR)$(pkglibdir)/HwEvtGenInterface.so;\
+	fi
+
 	@./Herwig init -L$(DESTDIR)$(pkglibdir) -i$(DESTDIR)$(pkgdatadir) -i$(DESTDIR)$(pkgdatadir)/snippets $(DESTDIR)$(defaultsdir)/HerwigDefaults.in --repo=$(DESTDIR)$(pkgdatadir)/HerwigDefaults.rpo
 	@if test -n "$(DESTDIR)"; \
         then sed -i.bak -e "s@$(DESTDIR)@@g" $(DESTDIR)$(pkgdatadir)/HerwigDefaults.rpo; \
 	rm -f $(DESTDIR)$(pkgdatadir)/HerwigDefaults.rpo.bak; \
         fi
 
 uninstall-hook:
 	rm -f $(DESTDIR)$(pkgdatadir)/HerwigDefaults.rpo
 
 
 register: register-with-thepeg-repo
 register-with-thepeg-repo:
 	@if test -x "$(SETUPTHEPEG)" -a -w "$(THEPEGREPO)"; \
 		then echo Registering with ThePEG; \
 		"$(SETUPTHEPEG)" --init \
 		$(DESTDIR)$(defaultsdir)/HerwigDefaults.in \
 		-r "$(THEPEGREPO)" -o "$(THEPEGREPO)" \
 		-i $(DESTDIR)$(pkgdatadir) \
 		-l$(DESTDIR)$(pkglibdir) ; \
 		if test -n "$(DESTDIR)"; \
 		then sed -i -e "s@$(DESTDIR)@@g" "$(THEPEGREPO)" ; fi ; \
 	fi
 
 
 unregister : unregister-from-thepeg-repo
 unregister-from-thepeg-repo:
 	@if test -x "$(SETUPTHEPEG)" -a -w "$(THEPEGREPO)"; \
 		then echo Unregistering with ThePEG; \
 		"$(SETUPTHEPEG)" --init defaults/HerwigCleanup.in \
 		-r "$(THEPEGREPO)" -o "$(THEPEGREPO)" \
 		-l$(DESTDIR)$(pkglibdir) ; \
 	fi
 
 EXTRA_DIST = herwigopts.ggo
 
 nodist_Herwig_SOURCES = hgstamp.inc
 BUILT_SOURCES += hgstamp.inc
 CLEANFILES += hgstamp.inc
 
 HGVERSION := $(shell hg -R $(top_srcdir) parents --template '"Herwig {node|short} ({branch})"' 2> /dev/null || echo \"$(PACKAGE_STRING)\" || true )
 
 .PHONY: update_hgstamp
 hgstamp.inc: update_hgstamp
 	@[ -f $@ ] || touch $@
 	@echo '$(HGVERSION)' | cmp -s $@ - || echo '$(HGVERSION)' > $@
 
 GENGETOPT = gengetopt
 
 %opts.h %opts.c : %opts.ggo
 	$(GENGETOPT) < $<
-
diff --git a/src/snippets/EPCollider.in b/src/snippets/EPCollider.in
--- a/src/snippets/EPCollider.in
+++ b/src/snippets/EPCollider.in
@@ -1,49 +1,52 @@
 # -*- ThePEG-repository -*-
 cd /Herwig/EventHandlers
 create ThePEG::LuminosityFunction Luminosity
 set EventHandler:BeamA /Herwig/Particles/e-
 set Luminosity:BeamEMaxA 30.*GeV
 set EventHandler:BeamB /Herwig/Particles/p+
 set Luminosity:BeamEMaxB 920.*GeV
 set EventHandler:LuminosityFunction Luminosity
 set /Herwig/Shower/ShowerHandler:MPIHandler NULL
 set /Herwig/Shower/PowhegShowerHandler:MPIHandler NULL
 set /Herwig/DipoleShower/DipoleShowerHandler:MPIHandler NULL
 
 # cuts for DIS
 set EventHandler:Cuts:ScaleMin 1.0*GeV2
 set EventHandler:Cuts:X1Min 1.0e-5
 set EventHandler:Cuts:X2Min 1.0e-5
 set EventHandler:Cuts:MHatMin 0.0*GeV
 set /Herwig/Cuts/NeutralCurrentCut:MinW2 0
 set /Herwig/Cuts/NeutralCurrentCut:MaxW2 1e10
 set /Herwig/Cuts/ChargedCurrentCut:MinW2 0
 set /Herwig/Cuts/ChargedCurrentCut:MaxW2 1e10
 clear EventHandler:Cuts:OneCuts
 clear EventHandler:Cuts:TwoCuts
 clear EventHandler:Cuts:MultiCuts
 insert EventHandler:Cuts:TwoCuts[0] /Herwig/Cuts/NeutralCurrentCut
 insert EventHandler:Cuts:TwoCuts[1] /Herwig/Cuts/ChargedCurrentCut
 
 # switch off final-state electron/muon FSR
 do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting e-->e-,gamma; /Herwig/Shower/LtoLGammaSudakov
 do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting mu-->mu-,gamma; /Herwig/Shower/LtoLGammaSudakov
 do /Herwig/Shower/SplittingGenerator:DeleteFinalSplitting tau-->tau-,gamma; /Herwig/Shower/LtoLGammaSudakov
+do /Herwig/Shower/SplittingGenerator:DeleteInitialSplitting gamma->e-,e+; /Herwig/Shower/GammatoQQbarSudakov
+do /Herwig/Shower/SplittingGenerator:DeleteInitialSplitting gamma->mu-,mu+; /Herwig/Shower/GammatoQQbarSudakov
+do /Herwig/Shower/SplittingGenerator:DeleteInitialSplitting gamma->tau-,tau+; /Herwig/Shower/GammatoQQbarSudakov
 set /Herwig/Shower/KinematicsReconstructor:ReconstructionOption Colour
 # Matchbox settings
 cd /Herwig/MatrixElements/Matchbox
 set Factory:FirstPerturbativePDF No
 set Factory:SecondPerturbativePDF Yes
 set Factory:PartonExtractor /Herwig/Partons/EPExtractor
 
 set /Herwig/Merging/MergingFactory:FirstPerturbativePDF No
 set /Herwig/Merging/MergingFactory:SecondPerturbativePDF Yes
 set /Herwig/Merging/MergingFactory:PartonExtractor /Herwig/Partons/EPExtractor
 
 #  Erase the PDF for the lepton side (the one from Particle Data object is used)
 set /Herwig/Shower/ShowerHandler:PDFA NULL
 set /Herwig/DipoleShower/DipoleShowerHandler:PDFA NULL
 
 cd /Herwig/Generators/
 set /Herwig/MatrixElements/SubProcess:PartonExtractor /Herwig/Partons/EPExtractor