diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49449bafde75d8d608a67972f29aa75d48d24b3f..a3a0e8592aa4e328e9b792e54ca3d9486c0d8e6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,4 @@
+#camtron
 cmake_minimum_required(VERSION 3.1)
 
 project(bgslibrary)
@@ -25,13 +26,14 @@ endfunction()
 #endif()
 
 if(UNIX)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a")
-  #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
+  # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
+#   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a")
   #set(CMAKE_MACOSX_RPATH 1)
 endif(UNIX)
 
 # Avoid cmake warnings about changes in behavior of some Mac OS X path
-# variable we don't care about.
+# variable we dont care about.
 if (POLICY CMP0042)
   cmake_policy(SET CMP0042 NEW)
 endif()
@@ -70,12 +72,13 @@ endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
 
 if(UNIX)
   # add some standard warnings
-  ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas)
+  # ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas)
+  ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Wno-unknown-pragmas)
 
   # -ansi does not compile with sjn module
   #ADD_DEFINITIONS(-ansi)
 
-  # if you like to have warinings about conversions, e.g. double->int or double->float etc., or float compare
+  # if you like to have warnings about conversions, e.g. double->int or double->float etc., or float compare
   #ADD_DEFINITIONS(-Wconversion -Wfloat-equal)
 endif(UNIX)
 
@@ -150,8 +153,8 @@ if(BGS_PYTHON_SUPPORT)
   #  find_package(Boost REQUIRED COMPONENTS python3)
   #endif()
 
-  # Pybind11's cmake scripts enable link time optimization by default.  However,
-  # it makes linking take a really long time and doesn't seem to substantively
+  # Pybind11s cmake scripts enable link time optimization by default.  However,
+  # it makes linking take a really long time and doesnt seem to substantively
   # improve runtime performance.  So we disable LTO here to make building bgslibrary
   # faster.
   set(PYBIND11_LTO_CXX_FLAGS "")
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 335c9d86c071d258cd840cff496c394edb8e29f4..b3575735c96a25e2ce1f83fe20388d7bf642d507 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,5 +1,5 @@
-#examples
-cmake_minimum_required(VERSION 2.8)
+#camtron examples
+cmake_minimum_required(VERSION 3.10)
 
 project(bgslibrary)
 
@@ -12,9 +12,9 @@ endif()
 message(STATUS "BGSLIBRARY WITH PYTHON SUPPORT: ${BGS_PYTHON_SUPPORT}")
 
 if(UNIX)
+# 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
-	#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a") #seems to be TOOO modern??
-	#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
+# 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a")
 endif(UNIX)
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
@@ -45,7 +45,7 @@ endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
 if(UNIX)
 	# add some standard warnings
 	#-Woverloaded-virtual #removed temporarily to increase readability of compiler output
-	ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas)
+	ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Wsign-promo -Wno-unused-parameter -pedantic -Wno-unknown-pragmas)
 
 	# -ansi does not compile with sjn module
 	#ADD_DEFINITIONS(-ansi)
@@ -62,9 +62,9 @@ message(STATUS "    version: ${OpenCV_VERSION}")
 message(STATUS "    libraries: ${OpenCV_LIBS}")
 message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")
 
-if(${OpenCV_VERSION} VERSION_EQUAL 3 OR ${OpenCV_VERSION} VERSION_GREATER 3)
-	message(STATUS "WOW! Found OpenCV Version ${OpenCV_VERSION}. SO PROGRESSIVE ;) 		<-- might not be compatible yet\n")
-endif()
+# if(${OpenCV_VERSION} VERSION_EQUAL 4 OR ${OpenCV_VERSION} VERSION_GREATER 3)
+# 	message(STATUS "WOW! Found OpenCV Version ${OpenCV_VERSION}. SO PROGRESSIVE ;) 		<-- might not be compatible yet\n")
+# endif()
 
 if(${OpenCV_VERSION} VERSION_LESS 2.3.1)
 	message(FATAL_ERROR "OpenCV version is not compatible: ${OpenCV_VERSION}")
@@ -97,64 +97,83 @@ if(BGS_PYTHON_SUPPORT)
 	message(STATUS "    include path: ${PYTHON_INCLUDE_DIRS}")
 endif()
 
-#file(GLOB sources FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp)
-file(GLOB main Main.cpp FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp)
+
+file(GLOB main ../src/*.cpp) #Main.cpp FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp
+# set(src "../src")
+# file(GLOB main "${src}/Main.cpp" "${src}/FrameProcessor.cpp" "${src}/PreProcessor.cpp" "${src}/VideoAnalysis.cpp" "${src}/VideoCapture.cpp")
 file(GLOB demo Demo.cpp)
 file(GLOB demo2 Demo2.cpp)
+file(GLOB_RECURSE tools_src ../src/tools/*.cpp)
 
+#file(GLOB sources FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp)
 # list(REMOVE_ITEM sources ${demo} ${demo2})
 
-file(GLOB_RECURSE analysis_src package_analysis/*.cpp)
 if(BGS_PYTHON_SUPPORT)
-	file(GLOB_RECURSE bgs_src package_bgs/*.cpp package_bgs/*.c wrapper_python/*.cpp)
-	file(GLOB_RECURSE bgs_include package_bgs/*.h wrapper_python/*.h)
+	file(GLOB_RECURSE bgs_src ../algorithms/*.cpp ../algorithms/*.c wrapper_python/*.cpp)
+	file(GLOB_RECURSE bgs_include ../algorithms/*.h wrapper_python/*.h)
 	include_directories(${CMAKE_SOURCE_DIR} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
 else()
-	file(GLOB_RECURSE bgs_src package_bgs/*.cpp package_bgs/*.c)
-	file(GLOB_RECURSE bgs_include package_bgs/*.h)
+	# file(GLOB_RECURSE bgs_src ../algorithms/*.cpp ../algorithms/*.c)
+	# file(GLOB_RECURSE bgs_include ../algorithms/*.h)
+
+	#stolen from bgs main cmake
+	file(GLOB_RECURSE bgs_src ../src/algorithms/*.cpp ../src/algorithms/*.c)
+	file(GLOB_RECURSE bgs_inc ../src/algorithms/*.h ../src/algorithms/*.hpp)
+
 	include_directories(${CMAKE_SOURCE_DIR} ${OpenCV_INCLUDE_DIRS} ${LibArchive_INCLUDE_DIRS})
 endif()
 
 # GMG is not available in older OpenCV versions
 if(${OpenCV_VERSION} VERSION_LESS 2.4.3)
 	message(WARNING "WTF???????")
-	file(GLOB gmg package_bgs/GMG.cpp)
+	file(GLOB gmg ../algorithms/GMG.cpp)
 	list(REMOVE_ITEM bgs_src ${gmg})
 endif()
 
 if(BGS_PYTHON_SUPPORT)
-	#add_library(libbgs SHARED ${sources} ${bgs_src} ${analysis_src})
-	add_library(libbgs SHARED ${bgs_src} ${analysis_src})
+	#add_library(libbgs SHARED ${sources} ${bgs_src} ${tools_src})
+	add_library(libbgs SHARED ${bgs_src} ${tools_src})
 	target_link_libraries(libbgs ${OpenCV_LIBS} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
 	target_compile_definitions(libbgs PRIVATE BGS_PYTHON_SUPPORT=1)
 else()
-	message(STATUS "HAHA ${bgs_src}\n\n")
-	#add_library(libbgs STATIC ${sources} ${bgs_src} ${analysis_src})
-	add_library(libbgs STATIC ${bgs_src} ${analysis_src}) # <<<<<< TODO
-	target_link_libraries(libbgs ${OpenCV_LIBS})
-endif()
-set_property(TARGET libbgs PROPERTY PUBLIC_HEADER ${bgs_include})
-if(WIN32)
-	# set_property(TARGET libbgs PROPERTY SUFFIX ".lib")
-else()
-	set_property(TARGET libbgs PROPERTY OUTPUT_NAME "bgs")
+	#add_library(libbgs STATIC ${sources} ${bgs_src} ${tools_src})
+	add_library(libbgs STATIC ${bgs_src} ${tools_src}) # <<<<<< TODO - STATIC,,,  .a ??
+# 	target_link_libraries(libbgs ${OpenCV_LIBS})
 endif()
+set_property(TARGET libbgs PROPERTY PUBLIC_HEADER ${bgs_include}) #macos framework bundle??
+set_property(TARGET libbgs PROPERTY OUTPUT_NAME "bgs") #linux
+
+message("")
+message(STATUS "bgs_src: '${bgs_src}'")
+message(STATUS "tools_src: '${tools_src}'")
+message(STATUS "main: '${main}'")
+message(STATUS "demo: '${demo}'")
+message(STATUS "demo2: '${demo2}'")
+message(STATUS "CMAKE_SOURCE_DIR: '${CMAKE_SOURCE_DIR}'")
+message(STATUS "CMAKE_BINARY_DIR: '${CMAKE_BINARY_DIR}'")
+message(STATUS "CMAKE_INCLUDE_PATH: '${CMAKE_INCLUDE_PATH}'")
+message(STATUS "bgs_include: '${bgs_include}'")
+message(STATUS "INCLUDE_DIRECTORIES: '${INCLUDE_DIRECTORIES}'")
 
-add_executable(bgslibrary ${main}) # <<<<<< TODO
+message("")
+
+
+add_executable(bgslibrary ${main})
 target_link_libraries(bgslibrary ${OpenCV_LIBS} libbgs)
-# set_target_properties(bgslibrary PROPERTIES OUTPUT_NAME bgs)
+set_target_properties(bgslibrary PROPERTIES OUTPUT_NAME bgs)
 
-add_executable(bgs_demo ${demo})
+add_executable(bgs_demo ${demo}) # <<<<<< TODO
 target_link_libraries(bgs_demo ${OpenCV_LIBS} ${LibArchive_LIBRARIES} libbgs)
 
 add_executable(bgs_demo2 ${demo2})
 target_link_libraries(bgs_demo2 ${OpenCV_LIBS} ${LibArchive_LIBRARIES} libbgs)
 
-install(TARGETS libbgs
-	bgslibrary
+install(TARGETS libbgs bgslibrary
 	RUNTIME DESTINATION bin COMPONENT app
 	LIBRARY DESTINATION lib COMPONENT runtime
 	ARCHIVE DESTINATION lib COMPONENT runtime
-	PUBLIC_HEADER DESTINATION include/package_bgs COMPONENT dev
+	PUBLIC_HEADER DESTINATION include/../algorithms COMPONENT dev
 	FRAMEWORK DESTINATION "/Library/Frameworks"
 )
+
+#15:34 last sudo
diff --git a/examples/Demo.cpp b/examples/Demo.cpp
index 67ac83ec0d3ace39be9fdeacc809589167885cb2..1db0e7dcac599f159057ffa16f0490600accff99 100644
--- a/examples/Demo.cpp
+++ b/examples/Demo.cpp
@@ -1,5 +1,6 @@
 /*
 ./bgs_demo -i test45/ -a 100 -o test45/results
+// -c center?
 */
 
 //cpp c
@@ -19,22 +20,16 @@
 #include <string.h>
 #include <unistd.h>
 
-//cpp 11X
-#include <regex>
-
+#include <regex> //cpp 11X
 
 #define PROCESS_CENTER_VERSION_MAJOR 2
 #define PROCESS_CENTER_VERSION_MINOR 0
 #define PROCESS_CENTER_VERSION_MINOR_FIXES 1
 
-//opencv
-#include <opencv2/opencv.hpp>
-//bgslibrary
-#include "package_bgs/bgslibrary.h"
-//my class
-#include "package_bgs/Tapter.h"
-#include "package_bgs/ttoolbox.h"
+#include <opencv2/opencv.hpp> //opencv
+#include "../src/algorithms/algorithms.h" //bgs
 
+using namespace bgslibrary::algorithms;
 using namespace cv;
 using namespace std;
 
@@ -55,7 +50,7 @@ int main(int argc, char * argv[])
 {
 	signal(SIGUSR1, my_handler);
 
-	std::cout << "using processcenter  " <<PROCESS_CENTER_VERSION_MAJOR <<"."<< PROCESS_CENTER_VERSION_MINOR<<"."<<PROCESS_CENTER_VERSION_MINOR_FIXES<< endl;
+	std::cout << "using processcenter  " << PROCESS_CENTER_VERSION_MAJOR <<"."<< PROCESS_CENTER_VERSION_MINOR<<"."<<PROCESS_CENTER_VERSION_MINOR_FIXES<< endl;
 	std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl;
 	//!** parse programm input****************/
 	if(cmdOptionExists(argv, argv+argc, "-h"))
@@ -140,54 +135,23 @@ int main(int argc, char * argv[])
 		exit(1);
 	}
 
+	/*
+  Codebook is new!
+  Tapter is TBoy!
+   List of all algorithms:
+   (Note that some of these algorithms are available only for a specific version of OpenCV, see algorithms.h)
+   AdaptiveBackgroundLearning,AdaptiveSelectiveBackgroundLearning,CodeBook,DPAdaptiveMedian,DPEigenbackground,
+   DPGrimsonGMM,DPMean,DPPratiMediod,DPTexture,DPWrenGA,DPZivkovicAGMM,FrameDifference,FuzzyChoquetIntegral,
+   FuzzySugenoIntegral,GMG,IndependentMultimodal,KDE,KNN,LBAdaptiveSOM,LBFuzzyAdaptiveSOM,LBFuzzyGaussian,
+   LBMixtureOfGaussians,LBP_MRF,LBSimpleGaussian,LOBSTER,MixtureOfGaussianV2,MixtureOfGaussianV1,MultiCue,
+   MultiLayer,PAWCS,PixelBasedAdaptiveSegmenter,SigmaDelta,StaticFrameDifference,SuBSENSE,T2FGMM_UM,T2FGMM_UV,
+   T2FMRF_UM,T2FMRF_UV,TwoPoints,ViBe,VuMeter,WeightedMovingMean,WeightedMovingVariance
+  */
 	/* Background Subtraction Methods */
 	IBGS *bgs;
 
-	//bgs = new FrameDifference;
-	//bgs = new StaticFrameDifference;
-	//bgs = new WeightedMovingMean;
-	//bgs = new WeightedMovingVariance;
-	//bgs = new MixtureOfGaussianV1; // only on OpenCV 2.x
-	//bgs = new MixtureOfGaussianV2;
-	//bgs = new AdaptiveBackgroundLearning;
-	//bgs = new AdaptiveSelectiveBackgroundLearning;
-	//bgs = new GMG; // only on OpenCV 2.x
-	//bgs = new KNN; // only on OpenCV 3.x
-	//bgs = new DPAdaptiveMedian;
-	//bgs = new DPGrimsonGMM;
-	//bgs = new DPZivkovicAGMM;
-	//bgs = new DPMean;
-	//bgs = new DPWrenGA;
-	//bgs = new DPPratiMediod;
-	//bgs = new DPEigenbackground;
-	//bgs = new DPTexture;
-	//bgs = new T2FGMM_UM;
-	//bgs = new T2FGMM_UV;
-	//bgs = new T2FMRF_UM;
-	//bgs = new T2FMRF_UV;
-	//bgs = new FuzzySugenoIntegral;
-	//bgs = new FuzzyChoquetIntegral;
-	//bgs = new MultiLayer;
 	bgs = new PixelBasedAdaptiveSegmenter;
-	//bgs = new LBSimpleGaussian;
-	//bgs = new LBFuzzyGaussian;
-	//bgs = new LBMixtureOfGaussians;
-	//bgs = new LBAdaptiveSOM;
-	//bgs = new LBFuzzyAdaptiveSOM;
-	//bgs = new LBP_MRF;
-	//bgs = new VuMeter;
-	//bgs = new KDE;
-	//bgs = new IndependentMultimodal;
-	//bgs = new MultiCue;
-	//bgs = new SigmaDelta;
-	//bgs = new SuBSENSE;
-	//bgs = new LOBSTER;
-	//bgs = new PAWCS;
-	//bgs = new TwoPoints;
-	//bgs = new ViBe;
-	//bgs = new Tapter;
-
-	//Tapter *bgs = new Tapter;
+
 
 	//see paper https://dl.acm.org/citation.cfm?id=2321600
 	//https://ieeexplore.ieee.org/document/4527178/
diff --git a/examples/Demo2.cpp b/examples/Demo2.cpp
index eef22d47c9fcc7ae707e4e0313c65b497db5fa48..7e3105c4622a10a180b40dc3953fcf1528dca34a 100644
--- a/examples/Demo2.cpp
+++ b/examples/Demo2.cpp
@@ -25,14 +25,10 @@ based  on original demo.cpp
 #define PROCESS_CENTER_VERSION_MAJOR 0
 #define PROCESS_CENTER_VERSION_MINOR 2
 
-//opencv
-#include <opencv2/opencv.hpp>
-//bgslibrary
-#include "package_bgs/bgslibrary.h"
-//my class
-#include "package_bgs/Tapter.h"
-#include "package_bgs/ttoolbox.h"
+#include <opencv2/opencv.hpp> //opencv
+#include "../src/algorithms/algorithms.h" //bgs
 
+using namespace bgslibrary::algorithms;
 using namespace cv;
 using namespace std;
 
diff --git a/examples/Demo3.cpp b/examples/Demo3.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..908e809663e20728d3513f7d7dd0bd169a65a9ae
--- /dev/null
+++ b/examples/Demo3.cpp
@@ -0,0 +1,87 @@
+#include <iostream>
+#include <algorithm>
+#include <iterator>
+#include <string>
+#include <vector>
+#include <opencv2/opencv.hpp>
+
+#include "../src/algorithms/algorithms.h"
+
+using namespace bgslibrary::algorithms;
+
+/* Background Subtraction Methods */
+auto algorithmsName = BGS_Factory::Instance()->GetRegisteredAlgorithmsName();
+
+int main(int argc, char** argv)
+{
+  std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl;
+
+  std::cout << "Number of available algorithms: " << algorithmsName.size() << std::endl;
+  std::cout << "List of available algorithms:" << std::endl;
+  std::copy(algorithmsName.begin(), algorithmsName.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
+
+  /*
+  Codebook is new!
+  Tapter is TBoy!
+   List of all algorithms:
+   (Note that some of these algorithms are available only for a specific version of OpenCV, see algorithms.h)
+   AdaptiveBackgroundLearning,AdaptiveSelectiveBackgroundLearning,CodeBook,DPAdaptiveMedian,DPEigenbackground,
+   DPGrimsonGMM,DPMean,DPPratiMediod,DPTexture,DPWrenGA,DPZivkovicAGMM,FrameDifference,FuzzyChoquetIntegral,
+   FuzzySugenoIntegral,GMG,IndependentMultimodal,KDE,KNN,LBAdaptiveSOM,LBFuzzyAdaptiveSOM,LBFuzzyGaussian,
+   LBMixtureOfGaussians,LBP_MRF,LBSimpleGaussian,LOBSTER,MixtureOfGaussianV2,MixtureOfGaussianV1,MultiCue,
+   MultiLayer,PAWCS,PixelBasedAdaptiveSegmenter,SigmaDelta,StaticFrameDifference,SuBSENSE,T2FGMM_UM,T2FGMM_UV,
+   T2FMRF_UM,T2FMRF_UV,TwoPoints,ViBe,VuMeter,WeightedMovingMean,WeightedMovingVariance
+  */
+  std::string algorithmName = "FrameDifference";
+  int cameraIndex = 0;
+  if (argc > 1) algorithmName = argv[1];
+  if (argc > 2) cameraIndex = std::stoi(argv[2]);
+
+  cv::VideoCapture capture;
+  capture.open(cameraIndex);
+
+  if (!capture.isOpened()) {
+    std::cerr << "Cannot initialize web camera!" << std::endl;
+    return -1;
+  }
+
+  std::cout << "Running " << algorithmName << std::endl;
+  auto bgs = BGS_Factory::Instance()->Create(algorithmName);
+
+  cv::Mat img_input;
+  auto key = 0;
+  std::cout << "Press 's' to stop:" << std::endl;
+  while (key != 's') {
+    // Capture frame-by-frame
+    capture >> img_input;
+
+    if (img_input.empty()) break;
+
+    // Resize input frame for better visualization
+    cv::resize(img_input, img_input, cv::Size(380, 240), 0, 0, CV_INTER_LINEAR);
+    cv::imshow("input", img_input);
+
+    cv::Mat img_mask;
+    cv::Mat img_bkgmodel;
+    try {
+      // by default, bgs->process(...) shows automatically the foreground mask image
+      // or you can disable it by: bgs->setShowOutput(false);
+      bgs->process(img_input, img_mask, img_bkgmodel);
+
+      //if(!img_mask.empty())
+      //  cv::imshow("Foreground", img_mask);
+      //  ....do something else...
+    }
+    catch (std::exception& e) {
+      std::cout << "Exception occurred" << std::endl;
+      std::cout << e.what() << std::endl;
+    }
+
+    key = cv::waitKey(33);
+  }
+
+  cv::destroyAllWindows();
+  capture.release();
+
+  return 0;
+}
diff --git a/src/algorithms/Tapter.cpp b/src/algorithms/Tapter.cpp
index b0ce1936e94b76f1e85bd6aafb279038ecf41e0c..f98230d57b61dcd0971cc880ecea5b64ade820bc 100644
--- a/src/algorithms/Tapter.cpp
+++ b/src/algorithms/Tapter.cpp
@@ -1,91 +1,59 @@
-/*
-This file is part of BGSLibrary.
-
-BGSLibrary is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-BGSLibrary is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
-*/
 #include "Tapter.h"
 
+#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
+
+//IPLIMAGE?
+// #include <opencv2/core/types_c.h>
+// #include <opencv2/core/mat.hpp>
+// #include <opencv2/imgproc.hpp>
+// #include "lb/BGModelSom.h"
+// #include "lb/Types.h"
+
 using namespace bgslibrary::algorithms;
 
 Tapter::Tapter() :
-    sensitivity(75), trainingSensitivity(245), learningRate(62), trainingLearningRate(255), trainingSteps(55)
+    IBGS(quote(Tapter)),
+    sensitivity(75),
+    trainingSensitivity(245),
+    learningRate(62),
+    trainingLearningRate(255),
+    trainingSteps(55)
 {
-    std::cout << "Tapter()" << std::endl;
-    setup("./config/Tapter.xml");
-//    frameCounter = 0;
-//    //inputPath = ".";
-//    //centerFile = ".";
-//    outputPath = ".";
-//    flagWrite = -1;
-//    writeDbgPic = -1;
-
+    // load_config("./config/Tapter.xml")
+    debug_construction(Tapter);
+    initLoadSaveConfig(algorithmName);
 }
 
 Tapter::~Tapter()
 {
+    debug_destruction(Tapter);
     delete m_pBGModel;
-    std::cout << "~Tapter()" << std::endl;
 }
 
-//void Tapter::setFlagWrite(short flag)
-//{
-//    flagWrite = flag;
-//}
-
-//void Tapter::setFlagWriteDBGpic(short flag)
-//{
-//    writeDbgPic = flag;
-//}
-
-//void Tapter::setPathOut(std::string outPath)
-//{
-//    outputPath = outPath;
-//}
-
-
-//void Tapter::setLearningRate(int rate)
-//{
-//    learningRate = rate;
-
-//}
-//void Tapter::setInitialFrameCounter(int counter)
-//{
-//    frameCounter = counter;
-//}
-
 void Tapter::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel)
 {
-
     //!  continue the normal
     init(img_input, img_output, img_bgmodel);
 
-    IplImage *frame = new IplImage(img_input);
+    IplImage *frame = new cvIplImage(img_input);
+    // IplImage *frame = new cv::cvarrToMat(img_input);
 
-    if (firstTime) // XXX where is this ever set?
+    if (firstTime)
     {
         int w = cvGetSize(frame).width;
         int h = cvGetSize(frame).height;
 
-        m_pBGModel = new BGModelSom(w, h);
+        m_pBGModel = new lb::BGModelSom(w, h);
         m_pBGModel->InitModel(frame);
+        m_pBGModel->setBGModelParameter(0, sensitivity);
+        m_pBGModel->setBGModelParameter(1, trainingSensitivity);
+        m_pBGModel->setBGModelParameter(2, learningRate);
+        m_pBGModel->setBGModelParameter(3, trainingLearningRate);
+        m_pBGModel->setBGModelParameter(5, trainingSteps); //xxx Y 5? what happened to 4?
+
+        firstTime = false;
     }
 
-    m_pBGModel->setBGModelParameter(0, sensitivity);
-    m_pBGModel->setBGModelParameter(1, trainingSensitivity);
-    m_pBGModel->setBGModelParameter(2, learningRate);
-    m_pBGModel->setBGModelParameter(3, trainingLearningRate);
-    m_pBGModel->setBGModelParameter(5, trainingSteps); //xxx Y 5? what happened to 4?
 
     m_pBGModel->UpdateModel(frame);
 
@@ -104,14 +72,10 @@ void Tapter::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img
     img_background.copyTo(img_bgmodel);
 
     delete frame;
-
-    firstTime = false;
 }
 
 void Tapter::save_config(cv::FileStorage &fs)
 {
-    //TODO
-    // CvFileStorage* fs = cvOpenFileStorage(config_xml.c_str(), nullptr, CV_STORAGE_WRITE);
     fs << "sensitivity"         << sensitivity;
     fs << "trainingSensitivity" << trainingSensitivity;
     fs << "learningRate"        << learningRate;
@@ -122,18 +86,12 @@ void Tapter::save_config(cv::FileStorage &fs)
 
 void Tapter::load_config(cv::FileStorage &fs)
 {
-    //TODO
-    //test defaults...
-    // CvFileStorage* fs = cvOpenFileStorage(config_xml.c_str(), nullptr, CV_STORAGE_READ);
-
-    fs["sensitivity"]           >> sensitivity;         //def: 75
-    fs["trainingSensitivity"]   >> trainingSensitivity; //def: 245
-    fs["learningRate"]          >> learningRate;        //def: 62
-    fs["trainingLearningRate"]  >> trainingLearningRate;//def: 255
-    fs["trainingSteps"]         >> trainingSteps;       //def: 55
-    fs["showOutput"]            >> showOutput;          //def: true
-
-    cvReleaseFileStorage(&fs);
+    fs["sensitivity"]           >> sensitivity;
+    fs["trainingSensitivity"]   >> trainingSensitivity;
+    fs["learningRate"]          >> learningRate;
+    fs["trainingLearningRate"]  >> trainingLearningRate;
+    fs["trainingSteps"]         >> trainingSteps;
+    fs["showOutput"]            >> showOutput;
 }
 
-
+#endif
diff --git a/src/algorithms/Tapter.h b/src/algorithms/Tapter.h
index 3e3bfaab9cc92cbbd9cc29b222dd9677f22cb9c5..25df4598b972b9af2df5136b9255ba12f2cc74e6 100644
--- a/src/algorithms/Tapter.h
+++ b/src/algorithms/Tapter.h
@@ -1,39 +1,21 @@
-/*
-This file is part of BGSLibrary.
-
-BGSLibrary is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-BGSLibrary is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
-*/
 #pragma once
 
 //std lib
-#include <sstream>
-#include <vector>
+// #include <sstream>
+// #include <vector>
 //opencv
-#include "opencv2/opencv.hpp"
-#include "opencv2/imgproc/imgproc.hpp"
+// #include "opencv2/opencv.hpp"
+// #include "opencv2/imgproc/imgproc.hpp"
 //bgslib
-#include "lb/BGModelSom.h"
 #include "IBGS.h"
 
-#include "ttoolbox.h"
+#include "opencv2/core/version.hpp"
+#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
 
-//#define MC_SHOW_STEP_ANALYSE
+#include "ttoolbox.h"
+#include "lb/BGModel.h"
+// #include "lb/BGModel.h"
 
-using namespace bgslibrary::algorithms::lb;
-// using namespace bgslibrary::algorithms::lb::AdaptiveSOM;
-using namespace cv;
-using namespace std;
 
 namespace bgslibrary
 {
@@ -42,40 +24,17 @@ namespace bgslibrary
     class Tapter : public IBGS
     {
     private:
-      BGModel* m_pBGModel;
+      lb::BGModel* m_pBGModel; //TODO put in some kind of smartpointer.
       int sensitivity;
       int trainingSensitivity;
       int learningRate;
       int trainingLearningRate;
       int trainingSteps;
 
-//      int frameCounter; //
-//      std::string inputPath;
-////      std::string centerFile;
-//      short flagWrite;
-//      short writeDbgPic;
-//      std::string outputPath;
-
     public:
       Tapter();
       ~Tapter();
 
-      void setInitialFrameCounter(int counter);
-
-//      void setPaths(std::string inPath,std::string outPath);
-      // void setPathOut(std::string outPath);
-
-//      //! 1 is on
-//      //! other no write
-//      void setFlagWrite(short flag);
-
-//      //! set learning rate
-//      void setLearningRate(int rate);
-
-//      //! 1 is on
-//      //! other no write
-//      void setFlagWriteDBGpic(short flag);
-
       void process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel);
 
     private:
@@ -86,3 +45,5 @@ namespace bgslibrary
     bgs_register(Tapter);
   }
 }
+
+#endif
diff --git a/src/algorithms/algorithms.h b/src/algorithms/algorithms.h
index 0db7953baeb2624b1ad48b86c3065dbe97b03a6a..b03dc1387c078c6d8c3fd671741d4aead79db382 100644
--- a/src/algorithms/algorithms.h
+++ b/src/algorithms/algorithms.h
@@ -44,6 +44,9 @@
 #include "ViBe.h"
 #include "CodeBook.h"
 
+#include "Tapter.h"
+#include "ttoolbox.h"
+
 //#include "_template_/MyBGS.h"
 
 using namespace bgslibrary::algorithms;
diff --git a/src/algorithms/ttoolbox.cpp b/src/algorithms/ttoolbox.cpp
index d1734221196f4b002065fff5d46f0b3a76d4fb30..e5005a3d1267ce358322aa4a95850bba375409f5 100644
--- a/src/algorithms/ttoolbox.cpp
+++ b/src/algorithms/ttoolbox.cpp
@@ -41,7 +41,7 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv:
     cv::Canny( imgSmoothed, imgCannyEdge, threshholdMin, threshholdMax, apertureSize );
 
     // Find contours, use RETR_EXTERNAL ignore inner child structures, TREE more usefull ?
-    cv::findContours( imgCannyEdge, contours, hierarchy, cv::RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0) );
+    cv::findContours( imgCannyEdge, contours, hierarchy, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE, cv::Point(0, 0) );
 
 #define MC_SHOW_STEP_ANALYSE
 #ifdef  MC_SHOW_STEP_ANALYSE
@@ -77,7 +77,7 @@ cv::Mat TToolBox::cropImageCircle(cv::Mat image, int x, int y, int r)
 
     // Draw the mask: white circle on black background
     cv::Mat1b mask(image.size(), uchar(0));
-    cv::circle(mask, cv::Point(circ[0], circ[1]), circ[2], cv::Scalar(255), CV_FILLED);
+    cv::circle(mask, cv::Point(circ[0], circ[1]), circ[2], cv::Scalar(255), cv::FILLED);
 
     //NO CROP NEEDED
 
@@ -145,7 +145,6 @@ std::string TToolBox::execCMD(const char* cmd) {
         if (fgets(buffer.data(), 128, pipe.get()) != nullptr)
             result += buffer.data();
         //std::cout<<result<<std::endl;
-
     }
     //std::cout<<"call:       " <<result<<std::endl;
     return result;
diff --git a/src/utils/ILoadSaveConfig.h b/src/utils/ILoadSaveConfig.h
index 33c896b0d80c7594976cfdfcd5997c4b0284e902..bc0c76dc5b80b35e66eae4a85c386d6b66237ea9 100644
--- a/src/utils/ILoadSaveConfig.h
+++ b/src/utils/ILoadSaveConfig.h
@@ -44,14 +44,14 @@ namespace bgslibrary
     
   private:
     void _save_config() {
-      //std::cout << "_save_config: " << config_file_path << std::endl;
+      std::cout << "_save_config: " << config_file_path << std::endl;
       cv::FileStorage fs(config_file_path, cv::FileStorage::WRITE);
       if (_is_valid(fs))
         save_config(fs);
       fs.release();
     }
     void _load_config() {
-      //std::cout << "_load_config: " << config_file_path << std::endl;
+      std::cout << "_load_config: " << config_file_path << std::endl;
       cv::FileStorage fs;
       fs.open(config_file_path, cv::FileStorage::READ);
       if (_is_valid(fs))