diff --git a/CMakeLists.txt b/CMakeLists.txt
index f68f7a9..ccb01c3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,392 +1,396 @@
 cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
 
 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
 project("HEJ" VERSION 2.0.5 LANGUAGES C CXX)
 
 # Set a default build type if none was specified
 set(default_build_type "RelWithDebInfo")
 
 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
   message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
   set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
       STRING "Choose the type of build." FORCE)
   # Set the possible values of build type for cmake-gui
   set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
     "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
 endif()
 
 ## Flags for the compiler. No warning allowed.
 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
 elseif (MSVC)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc")
 endif()
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 set(CMAKE_CXX_STANDARD 14)
 
 ## Create Version
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
 
 # Get the latest abbreviated commit hash of the working branch
 execute_process(
   COMMAND git rev-parse HEAD
   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
   OUTPUT_VARIABLE PROJECT_GIT_REVISION
   OUTPUT_STRIP_TRAILING_WHITESPACE
 )
 # Get the current working branch
 execute_process(
   COMMAND git rev-parse --abbrev-ref HEAD
   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
   OUTPUT_VARIABLE PROJECT_GIT_BRANCH
   OUTPUT_STRIP_TRAILING_WHITESPACE
   )
 
 ## target directories for install
 set(INSTALL_INCLUDE_DIR_BASE include)
 set(INSTALL_INCLUDE_DIR ${INSTALL_INCLUDE_DIR_BASE}/HEJ)
 set(INSTALL_BIN_DIR bin)
 set(INSTALL_LIB_DIR lib)
 set(INSTALL_CONFIG_DIR lib/cmake/HEJ)
 
 ## Template files
 configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/Version.hh.in
                 ${PROJECT_BINARY_DIR}/include/HEJ/Version.hh  @ONLY )
 
 configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/HEJ-config.cc.in
                 ${PROJECT_BINARY_DIR}/src/bin/HEJ-config.cc  @ONLY )
 
 # Generate CMake config file
 include(CMakePackageConfigHelpers)
 configure_package_config_file(
   cmake/Templates/hej-config.cmake.in
   ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config.cmake
   INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}
   PATH_VARS INSTALL_INCLUDE_DIR_BASE INSTALL_LIB_DIR
   )
 write_basic_package_version_file(
   ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config-version.cmake
   COMPATIBILITY SameMajorVersion
   )
 install(
   FILES ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config.cmake
     ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config-version.cmake
   DESTINATION ${INSTALL_CONFIG_DIR})
 
 ## Add directories and find dependences
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include)
 
 find_package(fastjet REQUIRED)
 include_directories(${fastjet_INCLUDE_DIRS})
 find_package(CLHEP 2.3 REQUIRED)
 include_directories(${CLHEP_INCLUDE_DIRS})
 find_package(LHAPDF REQUIRED)
 include_directories(${LHAPDF_INCLUDE_DIRS})
 ## Amend unintuitive behaviour of FindBoost.cmake
 ## Priority of BOOST_ROOT over BOOSTROOT matches FindBoost.cmake
 ## at least for cmake 3.12
 if(DEFINED BOOST_ROOT)
   message("BOOST_ROOT set - only looking for Boost in ${BOOST_ROOT}")
   set(Boost_NO_BOOST_CMAKE ON)
   elseif(DEFINED BOOSTROOT)
   message("BOOSTROOT set - only looking for Boost in ${BOOSTROOT}")
   set(Boost_NO_BOOST_CMAKE ON)
 endif()
 find_package(Boost REQUIRED COMPONENTS iostreams)
 include_directories(${Boost_INCLUDE_DIRS})
 find_package(yaml-cpp) # requiring yaml does not work with fedora
 include_directories(${YAML_CPP_INCLUDE_DIR})
 if(${EXCLUDE_HepMC})
   message(STATUS "Skipping HepMC")
   # avoid "unused variable" warning if EXCLUDE_rivet is set by user
   set(EXCLUDE_rivet TRUE)
 else()
   find_package(HepMC 2)
 endif()
 if(${HepMC_FOUND})
   set(
     CMAKE_CXX_FLAGS
     "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_HepMC_VERSION=${HepMC_VERSION_MAJOR}"
     )
   include_directories(${HepMC_INCLUDE_DIRS})
   if(${EXCLUDE_rivet})
     message(STATUS "Skipping rivet")
   else()
     find_package(rivet)
   endif()
   if(${rivet_FOUND})
     include_directories(${rivet_INCLUDE_DIRS})
     set(
       CMAKE_CXX_FLAGS
       "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_RIVET"
       )
   endif()
 endif()
 if(${EXCLUDE_QCDloop})
   message(STATUS "Skipping QCDloop")
 else()
   find_package(QCDloop 2)
 endif()
 if(${QCDloop_FOUND})
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_QCDLOOP")
   include_directories(SYSTEM ${QCDloop_INCLUDE_DIRS})
 endif()
 if(${EXCLUDE_HighFive})
   message(STATUS "Skipping HighFive")
 else()
   find_package(HighFive QUIET)
   find_package_handle_standard_args( HighFive CONFIG_MODE )
 endif()
 if(${HighFive_FOUND})
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_HDF5")
   include_directories($<TARGET_PROPERTY:HighFive,INTERFACE_INCLUDE_DIRECTORIES>)
 endif()
 
 add_subdirectory(src)
 
 ## define executable
 add_executable(HEJ src/bin/HEJ.cc)
 
 ## link libraries
 target_link_libraries(HEJ hejlib)
 
 add_executable(HEJ-config src/bin/HEJ-config.cc)
 
 file(GLOB hej_headers
   ${CMAKE_CURRENT_SOURCE_DIR}/include/HEJ/*.hh
   ${PROJECT_BINARY_DIR}/include/HEJ/*.hh
 )
 file(GLOB hej_detail_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/HEJ/detail/*.hh)
 file(GLOB lhef_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/LHEF/*.h)
 install(FILES ${hej_headers} DESTINATION ${INSTALL_INCLUDE_DIR})
 install(FILES ${hej_detail_headers} DESTINATION ${INSTALL_INCLUDE_DIR}/detail/)
 install(FILES ${lhef_headers} DESTINATION ${INSTALL_INCLUDE_DIR_BASE}/LHEF/)
 install(TARGETS HEJ HEJ-config DESTINATION ${INSTALL_BIN_DIR})
 
 ## tests
 enable_testing()
 set(tst_dir "${CMAKE_CURRENT_SOURCE_DIR}/t")
 set(tst_ME_data_dir "${tst_dir}/ME_data")
 
 # test event classification
+add_executable(test_classify_new ${tst_dir}/test_classify_new.cc)
+target_link_libraries(test_classify_new hejlib)
+add_test(
+  NAME t_classify_new
+  COMMAND test_classify_new
+  )
 add_executable(test_classify ${tst_dir}/test_classify.cc)
 target_link_libraries(test_classify hejlib)
 add_test(
   NAME t_classify
-  COMMAND test_classify ${tst_dir}/classify.lhe.gz
+  COMMAND test_classify ${tst_dir}/classify_ref ${tst_dir}/classify.lhe.gz
   )
-add_executable(test_classify_new ${tst_dir}/test_classify_new.cc)
-target_link_libraries(test_classify_new hejlib)
 add_test(
-  NAME t_classify_new
-  COMMAND test_classify_new
+  NAME t_classify_4j
+  COMMAND test_classify ${tst_dir}/classify_ref_4j ${tst_dir}/4j.lhe.gz
   )
 
 # test phase space point
 add_executable(test_psp ${tst_dir}/test_psp.cc)
 target_link_libraries(test_psp hejlib)
 add_test(
   NAME t_psp
   COMMAND test_psp ${tst_dir}/psp_gen.lhe.gz
   )
 
 # test importing scales
 add_library(scales SHARED ${tst_dir}/scales.cc)
 add_executable(test_scale_import ${tst_dir}/test_scale_import)
 target_link_libraries(test_scale_import hejlib)
 add_test(
   NAME t_scale_import
   COMMAND test_scale_import ${tst_dir}/jet_config_with_import.yml
   )
 
 # test scale arithmetic (e.g. 2*H_T/4)
 add_executable(test_scale_arithmetics ${tst_dir}/test_scale_arithmetics)
 target_link_libraries(test_scale_arithmetics hejlib)
 add_test(
   NAME t_scale_arithmetics
   COMMAND test_scale_arithmetics ${tst_dir}/jet_config.yml ${tst_dir}/2j.lhe.gz
   )
 
 # test "ParameterDescription"
 add_executable(test_descriptions ${tst_dir}/test_descriptions)
 target_link_libraries(test_descriptions hejlib)
 add_test(
   NAME t_descriptions
   COMMAND test_descriptions
   )
 
 # test "EventParameters*Weight"
 add_executable(test_parameters ${tst_dir}/test_parameters)
 target_link_libraries(test_parameters hejlib)
 add_test(
   NAME test_parameters
   COMMAND test_parameters
   )
 
 # test colour generation
 add_executable(test_colours ${tst_dir}/test_colours)
 target_link_libraries(test_colours hejlib)
 add_test(
   NAME t_colour_flow
   COMMAND test_colours
   )
 
 # test matrix elements
 add_executable(test_ME_generic ${tst_dir}/test_ME_generic.cc)
 target_link_libraries(test_ME_generic hejlib)
 add_test(
   NAME t_ME_j
   COMMAND test_ME_generic ${tst_ME_data_dir}/config_mtinf.yml ${tst_ME_data_dir}/ME_jets.dat ${tst_ME_data_dir}/PSP_jets.lhe.gz
   )
 add_test(
   NAME t_ME_h
   COMMAND test_ME_generic ${tst_ME_data_dir}/config_mtinf.yml ${tst_ME_data_dir}/ME_h_mtinf.dat ${tst_ME_data_dir}/PSP_h.lhe.gz
   )
 if(${QCDloop_FOUND})
   add_test(
     NAME t_ME_h_mt
     COMMAND test_ME_generic ${tst_ME_data_dir}/config_mt.yml ${tst_ME_data_dir}/ME_h_mt_tree.dat ${tst_ME_data_dir}/PSP_h.lhe.gz
     )
   add_test(
     NAME t_ME_h_mtmb
     COMMAND test_ME_generic ${tst_ME_data_dir}/config_mtmb.yml ${tst_ME_data_dir}/ME_h_mtmb_tree.dat ${tst_ME_data_dir}/PSP_h.lhe.gz
     )
 endif()
 add_test(
   NAME t_ME_w_FKL
   COMMAND test_ME_generic ${tst_ME_data_dir}/config_w_ME.yml ${tst_ME_data_dir}/ME_w_FKL_tree.dat ${tst_ME_data_dir}/PSP_w_FKL.lhe.gz
   )
 add_test(
   NAME t_ME_w_FKL_virt
   COMMAND test_ME_generic ${tst_ME_data_dir}/config_w_ME.yml ${tst_ME_data_dir}/ME_w_FKL_virt.dat ${tst_ME_data_dir}/PSP_w_FKL.lhe.gz
   )
 add_test(
   NAME t_ME_Wp
   COMMAND test_ME_generic ${tst_ME_data_dir}/config_w_ME.yml ${tst_ME_data_dir}/ME_Wp.dat ${tst_ME_data_dir}/PSP_Wp.lhe.gz
   )
 add_test(
   NAME t_ME_Wm
   COMMAND test_ME_generic ${tst_ME_data_dir}/config_w_ME.yml ${tst_ME_data_dir}/ME_Wm.dat ${tst_ME_data_dir}/PSP_Wm.lhe.gz
   )
 
 # test main executable
 if(${HepMC_FOUND})
   file(READ "${tst_dir}/jet_config.yml" config)
   file(WRITE "${tst_dir}/jet_config_withHepMC.yml" "${config}  - tst.hepmc")
   if(${rivet_FOUND})
     file(READ "${tst_dir}/jet_config_withHepMC.yml" config)
     file(WRITE "${tst_dir}/jet_config_withRivet.yml" "${config}\n\nanalysis:\n  rivet: MC_XS\n  output: tst")
     add_test(
       NAME t_main
       COMMAND HEJ ${tst_dir}/jet_config_withRivet.yml ${tst_dir}/2j.lhe.gz
       )
   else() # no rivet
     add_test(
       NAME t_main
       COMMAND HEJ ${tst_dir}/jet_config_withHepMC.yml ${tst_dir}/2j.lhe.gz
       )
   endif()
   if(${HepMC_VERSION_MAJOR} GREATER 2)
     add_executable(check_hepmc ${tst_dir}/check_hepmc.cc)
     target_link_libraries(check_hepmc hejlib)
     # check that HepMC output is correct
     add_test(
       NAME t_hepmc
       COMMAND check_hepmc tst.hepmc
       )
   endif()
 else() # no HepMC
   add_test(
     NAME t_main
     COMMAND HEJ ${tst_dir}/jet_config.yml ${tst_dir}/2j.lhe.gz
     )
 endif()
 # check that LHEF output is correct
 add_executable(check_lhe ${tst_dir}/check_lhe.cc)
 target_link_libraries(check_lhe hejlib)
 add_test(
   NAME t_lhe
   COMMAND check_lhe tst.lhe
   )
 # check HDF5 reader
 if(${HighFive_FOUND})
   add_executable(test_hdf5 ${tst_dir}/test_hdf5.cc)
   target_link_libraries(test_hdf5 hejlib)
   add_test(
     NAME t_hdf5
     COMMAND test_hdf5 ${tst_dir}/Wm9-g4-repack.hdf5
     )
 endif()
 
 # test boson reconstruction
 add_executable(cmp_events ${tst_dir}/cmp_events.cc)
 target_link_libraries(cmp_events hejlib)
 add_test(
   NAME t_epnu_2j_noW
   COMMAND cmp_events ${tst_dir}/epnu2jLOFKL_unweight.lhe.tar.gz ${tst_dir}/epnu2jLOFKL_unweight_noW.lhe.gz
   )
 
 # test resummed result
 add_executable(check_res ${tst_dir}/check_res.cc)
 target_link_libraries(check_res hejlib)
 
 if(${TEST_ALL}) # deactivate long tests by default
   add_test(
     NAME t_2j
     COMMAND check_res ${tst_dir}/2j.lhe.gz 3.49391e+07 419684
     )
   add_test(
     NAME t_3j
     COMMAND check_res ${tst_dir}/3j.lhe.gz  2.37902e+06 25746.6
     )
   add_test(
     NAME t_4j
     COMMAND check_res ${tst_dir}/4j.lhe.gz  603713 72822.6
     )
   add_test(
     NAME t_h_3j
     COMMAND check_res ${tst_dir}/h_3j.lhe.gz 0.821622 0.0220334
     )
   add_test(
     NAME t_h_3j_unof
     COMMAND check_res ${tst_dir}/h_3j_uno.lhe.gz 0.0127362 0.000271555 unof
     )
   add_test(
     NAME t_h_3j_unob
     COMMAND check_res ${tst_dir}/h_3j_uno.lhe.gz 0.0130615 0.000224793 unob
     )
   add_test(
     NAME t_epnu_2j
     COMMAND check_res ${tst_dir}/epnu2jLOFKL_unweight.lhe.tar.gz 262.7 3
     )
   add_test(
     NAME t_MGepnu_3j
     COMMAND check_res ${tst_dir}/MGepnu3j_unweighted.tar.gz 38.9512 1
     )
   add_test(
     NAME t_MGemnubar_3j
     COMMAND check_res ${tst_dir}/MGemnubar3j_unweighted.tar.gz 24.1575 1
     )
   add_test(
     NAME t_MGepnu_3j_splitf
     COMMAND check_res ${tst_dir}/MGepnu3j_unweighted.tar.gz 2.91995 0.0463182 splitf
     )
   add_test(
     NAME t_MGepnu_3j_splitb
     COMMAND check_res ${tst_dir}/MGepnu3j_unweighted.tar.gz 3.40708 0.0550975 splitb
     )
   add_test(
     NAME t_MGepnu_4j
     COMMAND check_res ${tst_dir}/MGepnu4j_unweighted.tar.gz 10.2542 0.135106
     )
   add_test(
     NAME t_MGemnubar_4j
     COMMAND check_res ${tst_dir}/MGemnubar4j_unweighted.tar.gz 5.57909 0.0300496
     )
   add_test(
     NAME t_MGepnu_4j_qqxmid
     COMMAND check_res ${tst_dir}/MGepnu4j_unweighted.tar.gz 0.732084 0.005 qqxmid
     )
 endif()
diff --git a/t/classify_ref b/t/classify_ref
new file mode 100644
index 0000000..cae2ad5
--- /dev/null
+++ b/t/classify_ref
@@ -0,0 +1,125 @@
+8
+4
+4
+4
+4
+4
+4
+8
+4
+8
+4
+4
+4
+16
+4
+8
+4
+4
+8
+8
+4
+4
+8
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+16
+4
+4
+16
+4
+4
+4
+4
+4
+16
+4
+4
+4
+16
+4
+4
+8
+16
+4
+16
+4
+8
+4
+4
+8
+4
+8
+16
+8
+16
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+8
+4
+4
+4
+4
+4
+4
+4
+4
+8
+4
+4
+4
+4
+16
+4
+8
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+8
+4
+4
+4
+4
+4
+8
+4
+8
+8
+4
+4
+4
+4
+4
+4
+4
+4
+4
+16
+8
+4
diff --git a/t/classify_ref_4j b/t/classify_ref_4j
new file mode 100644
index 0000000..65f92f7
--- /dev/null
+++ b/t/classify_ref_4j
@@ -0,0 +1,3255 @@
+4
+4
+2
+4
+4
+8
+4
+4
+4
+16
+4
+32
+2
+4
+4
+2
+4
+4
+128
+4
+4
+4
+4
+4
+4
+4
+2
+4
+64
+4
+4
+8
+4
+64
+4
+4
+1
+8
+4
+1
+4
+4
+4
+4
+4
+4
+4
+8
+4
+4
+4
+4
+4
+1
+4
+4
+4
+16
+128
+4
+4
+4
+4
+4
+4
+64
+4
+4
+64
+4
+4
+4
+4
+4
+4
+2
+8
+32
+2
+4
+4
+64
+1
+4
+4
+4
+64
+4
+2
+4
+4
+4
+128
+4
+4
+2
+16
+8
+4
+4
+4
+4
+4
+4
+4
+4
+1
+1
+4
+32
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+64
+4
+4
+4
+32
+4
+4
+4
+1
+4
+4
+4
+4
+2
+4
+8
+4
+16
+4
+4
+32
+8
+4
+4
+1
+4
+1
+4
+4
+64
+4
+64
+4
+4
+4
+4
+4
+8
+4
+128
+4
+128
+4
+4
+1
+4
+64
+1
+1
+8
+4
+4
+128
+4
+4
+8
+4
+4
+16
+8
+2
+4
+128
+4
+4
+4
+4
+2
+4
+4
+4
+4
+2
+4
+4
+4
+1
+2
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+1
+8
+4
+4
+4
+4
+4
+4
+4
+128
+4
+64
+4
+8
+4
+4
+64
+2
+128
+4
+16
+4
+4
+4
+4
+32
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+32
+4
+4
+128
+4
+64
+4
+8
+4
+4
+4
+4
+2
+4
+8
+4
+8
+4
+4
+4
+4
+4
+4
+4
+4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4
+2
+16
+4
+4
+4
+4
+4
+4
+1
+4
+4
+16
+4
+4
+64
+64
+1
+4
+4
+16
+4
+128
+4
+4
+4
+4
+4
+128
+1
+4
+4
+4
+4
+4
+128
+4
+4
+8
+4
+32
+128
+4
+16
+1
+4
+4
+4
+1
+4
+4
+32
+4
+1
+4
+4
+4
+4
+16
+4
+4
+4
+4
+8
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+128
+16
+32
+4
+8
+1
+4
+4
+4
+4
+4
+4
+32
+128
+4
+2
+32
+4
+4
+4
+4
+2
+4
+128
+4
+4
+4
+128
+4
+4
+4
+1
+4
+4
+4
+4
+4
+128
+4
+2
+4
+4
+4
+64
+2
+1
+2
+4
+32
+16
+4
+4
+4
+4
+1
+4
+64
+4
+64
+4
+4
+32
+128
+4
+2
+4
+4
+32
+4
+4
+4
+4
+128
+2
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+16
+8
+4
+4
+16
+4
+4
+4
+4
+4
+4
+4
+4
+1
+4
+4
+128
+16
+4
+4
+16
+4
+4
+4
+4
+4
+4
+4
+4
+4
+2
+4
+4
+8
+4
+4
+1
+4
+4
+4
+4
+128
+4
+2
+1
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+64
+8
+4
+2
+4
+1
+4
+4
+4
+4
+8
+4
diff --git a/t/test_classify.cc b/t/test_classify.cc
index 38d8399..e9b0067 100644
--- a/t/test_classify.cc
+++ b/t/test_classify.cc
@@ -1,67 +1,75 @@
 /**
  *  \authors   The HEJ collaboration (see AUTHORS for details)
  *  \date      2019
  *  \copyright GPLv2 or later
  */
+#include <fstream>
 #include <random>
 #include <algorithm>
 
 #include "LHEF/LHEF.h"
-#include "HEJ/stream.hh"
+
+#include "HEJ/YAMLreader.hh"
 #include "HEJ/event_types.hh"
 #include "HEJ/Event.hh"
+#include "HEJ/EventReader.hh"
 
 namespace{
-  constexpr double min_jet_pt = 30.;
+  // this is deliberately chosen bigger than in the generation,
+  // to cluster multiple partons in one jet
+  constexpr double min_jet_pt = 40.;
   const fastjet::JetDefinition jet_def{fastjet::kt_algorithm, 0.4};
-  using namespace HEJ::event_type;
-  static const std::vector<EventType> results{
-    unob,FKL,FKL,FKL,FKL,FKL,FKL,unob,FKL,unob,FKL,FKL,FKL,unof,FKL,unob,FKL,
-    FKL,unob,unob,FKL,FKL,unob,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,unof,
-    FKL,FKL,unof,FKL,FKL,FKL,FKL,FKL,unof,FKL,FKL,FKL,unof,FKL,FKL,unob,unof,
-    FKL,unof,FKL,unob,FKL,FKL,unob,FKL,unob,unof,unob,unof,FKL,FKL,FKL,FKL,FKL,
-    FKL,FKL,FKL,FKL,FKL,FKL,FKL,unob,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,unob,FKL,
-    FKL,FKL,FKL,unof,FKL,unob,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,unob,FKL,
-    FKL,FKL,FKL,FKL,unob,FKL,unob,unob,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,FKL,unof,unob,FKL
-  };
 
   void shuffle_particles(HEJ::Event::EventData & ev) {
     static std::mt19937_64 ran{0};
     std::shuffle(begin(ev.incoming), end(ev.incoming), ran);
     std::shuffle(begin(ev.outgoing), end(ev.outgoing), ran);
   }
 }
 
 int main(int argn, char** argv) {
-  if(argn != 2){
-    std::cerr << "Usage: test_classify eventfile";
+  if(argn != 3 && argn != 4){
+    std::cerr << "Usage: " << argv[0]
+      << " reference_classification input_file.lhe\n";
     return EXIT_FAILURE;
   }
+  bool OUTPUT_MODE = false;
+  if(argn == 4 && std::string("OUTPUT")==std::string(argv[3]))
+      OUTPUT_MODE = true;
+
+  std::fstream ref_file;
+  if ( OUTPUT_MODE ) {
+    std::cout << "_______________________USING OUTPUT MODE!_______________________" << std::endl;
+    ref_file.open(argv[1], std::fstream::out);
+  } else {
+    ref_file.open(argv[1], std::fstream::in);
+  }
 
-  HEJ::istream in{argv[1]};
-  LHEF::Reader reader{in};
-  LHEF::Writer writer{std::cerr};
-  writer.heprup = reader.heprup;
+  auto reader{ HEJ::make_reader(argv[2]) };
 
-  for(auto const & expected: results){
-    reader.readEvent();
-    HEJ::Event::EventData data{reader.hepeup};
+  while(reader->read_event()){
+    HEJ::Event::EventData data{ reader->hepeup() };
     shuffle_particles(data);
     const HEJ::Event ev{
       data.cluster(
         jet_def, min_jet_pt
       )
     };
+    if ( OUTPUT_MODE ) {
+      ref_file << ev.type() << std::endl;
+    } else {
+      std::string line;
+      if(!std::getline(ref_file,line)) break;
+      const auto expected{static_cast<HEJ::event_type::EventType>(std::stoi(line))};
 
-    if(ev.type() != expected){
-      using HEJ::event_type::name;
-      writer.hepeup = reader.hepeup;
-      std::cerr << "wrong classification of event:\n";
-      writer.writeEvent();
-      std::cerr << "classified as " << name(ev.type())
-                << ", is " << name(expected) << '\n';
-      return EXIT_FAILURE;
+      if(ev.type() != expected){
+        using HEJ::event_type::name;
+        std::cerr << "wrong classification of event:\n" << ev
+                  << "classified as " << name(ev.type())
+                  << ", is " << name(expected) << '\n';
+        return EXIT_FAILURE;
+      }
     }
   }
 
 }