diff --git a/config/FrameProcessor.xml b/config/FrameProcessor.xml
index 91c3466779fc01c8d430647f83078928d477a6e1..d510afee74e184043b51fd312b2fba2f52d4ada9 100644
--- a/config/FrameProcessor.xml
+++ b/config/FrameProcessor.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <opencv_storage>
 <tictoc>""</tictoc>
-<enablePreProcessor>1</enablePreProcessor>
+<enablePreProcessor>0</enablePreProcessor>
 <enableForegroundMaskAnalysis>0</enableForegroundMaskAnalysis>
 <enableFrameDifference>1</enableFrameDifference>
 <enableStaticFrameDifference>0</enableStaticFrameDifference>
diff --git a/src/FrameProcessor.cpp b/src/FrameProcessor.cpp
index 83f94c95ef9e2ba44b799215e1b12d9e1a0a2da0..91ebafd4b78a501d05644b381d530a36babdab6e 100644
--- a/src/FrameProcessor.cpp
+++ b/src/FrameProcessor.cpp
@@ -20,164 +20,166 @@ namespace bgslibrary
   void FrameProcessor::init()
   {
     if (enablePreProcessor)
-      preProcessor = new PreProcessor;
+      preProcessor = std::make_unique<PreProcessor>();
 
     if (enableFrameDifference)
-      frameDifference = new FrameDifference;
+      frameDifference = std::make_shared<FrameDifference>();
 
     if (enableStaticFrameDifference)
-      staticFrameDifference = new StaticFrameDifference;
+      staticFrameDifference = std::make_shared<StaticFrameDifference>();
 
     if (enableWeightedMovingMean)
-      weightedMovingMean = new WeightedMovingMean;
+      weightedMovingMean = std::make_shared<WeightedMovingMean>();
 
     if (enableWeightedMovingVariance)
-      weightedMovingVariance = new WeightedMovingVariance;
+      weightedMovingVariance = std::make_shared<WeightedMovingVariance>();
 
     if (enableAdaptiveBackgroundLearning)
-      adaptiveBackgroundLearning = new AdaptiveBackgroundLearning;
+      adaptiveBackgroundLearning = std::make_shared<AdaptiveBackgroundLearning>();
 
     if (enableMixtureOfGaussianV2)
-      mixtureOfGaussianV2 = new MixtureOfGaussianV2;
+      mixtureOfGaussianV2 = std::make_shared<MixtureOfGaussianV2>();
 
 #if CV_MAJOR_VERSION == 2
     if (enableMixtureOfGaussianV1)
-      mixtureOfGaussianV1 = new MixtureOfGaussianV1;
+      mixtureOfGaussianV1 = std::make_shared<MixtureOfGaussianV1>();
 #endif
 
 #if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
     if (enableGMG)
-      gmg = new GMG;
+      gmg = std::make_shared<GMG>();
 #endif
 
 #if CV_MAJOR_VERSION >= 3
     if (enableKNN)
-      knn = new KNN;
+      knn = std::make_shared<KNN>();
 #endif
 
 #if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
     if (enableDPAdaptiveMedian)
-      dpAdaptiveMedian = new DPAdaptiveMedian;
+      dpAdaptiveMedian = std::make_shared<DPAdaptiveMedian>();
 
     if (enableDPGrimsonGMM)
-      dpGrimsonGMM = new DPGrimsonGMM;
+      dpGrimsonGMM = std::make_shared<DPGrimsonGMM>();
 
     if (enableDPZivkovicAGMM)
-      dpZivkovicAGMM = new DPZivkovicAGMM;
+      dpZivkovicAGMM = std::make_shared<DPZivkovicAGMM>();
 
     if (enableDPMean)
-      dpTemporalMean = new DPMean;
+      dpTemporalMean = std::make_shared<DPMean>();
 
     if (enableDPWrenGA)
-      dpWrenGA = new DPWrenGA;
+      dpWrenGA = std::make_shared<DPWrenGA>();
 
     if (enableDPPratiMediod)
-      dpPratiMediod = new DPPratiMediod;
+      dpPratiMediod = std::make_shared<DPPratiMediod>();
 
     if (enableDPEigenbackground)
-      dpEigenBackground = new DPEigenbackground;
+      dpEigenBackground = std::make_shared<DPEigenbackground>();
 
     if (enableDPTexture)
-      dpTexture = new DPTexture;
+      dpTexture = std::make_shared<DPTexture>();
 
     if (enableT2FGMM_UM)
-      type2FuzzyGMM_UM = new T2FGMM_UM;
+      type2FuzzyGMM_UM = std::make_shared<T2FGMM_UM>();
 
     if (enableT2FGMM_UV)
-      type2FuzzyGMM_UV = new T2FGMM_UV;
+      type2FuzzyGMM_UV = std::make_shared<T2FGMM_UV>();
 
     if (enableT2FMRF_UM)
-      type2FuzzyMRF_UM = new T2FMRF_UM;
+      type2FuzzyMRF_UM = std::make_shared<T2FMRF_UM>();
 
     if (enableT2FMRF_UV)
-      type2FuzzyMRF_UV = new T2FMRF_UV;
+      type2FuzzyMRF_UV = std::make_shared<T2FMRF_UV>();
 
     if (enableFuzzySugenoIntegral)
-      fuzzySugenoIntegral = new FuzzySugenoIntegral;
+      fuzzySugenoIntegral = std::make_shared<FuzzySugenoIntegral>();
 
     if (enableFuzzyChoquetIntegral)
-      fuzzyChoquetIntegral = new FuzzyChoquetIntegral;
+      fuzzyChoquetIntegral = std::make_shared<FuzzyChoquetIntegral>();
 
     if (enableLBSimpleGaussian)
-      lbSimpleGaussian = new LBSimpleGaussian;
+      lbSimpleGaussian = std::make_shared<LBSimpleGaussian>();
 
     if (enableLBFuzzyGaussian)
-      lbFuzzyGaussian = new LBFuzzyGaussian;
+      lbFuzzyGaussian = std::make_shared<LBFuzzyGaussian>();
 
     if (enableLBMixtureOfGaussians)
-      lbMixtureOfGaussians = new LBMixtureOfGaussians;
+      lbMixtureOfGaussians = std::make_shared<LBMixtureOfGaussians>();
 
     if (enableLBAdaptiveSOM)
-      lbAdaptiveSOM = new LBAdaptiveSOM;
+      lbAdaptiveSOM = std::make_shared<LBAdaptiveSOM>();
 
     if (enableLBFuzzyAdaptiveSOM)
-      lbFuzzyAdaptiveSOM = new LBFuzzyAdaptiveSOM;
+      lbFuzzyAdaptiveSOM = std::make_shared<LBFuzzyAdaptiveSOM>();
 
     if (enableLbpMrf)
-      lbpMrf = new LBP_MRF;
+      lbpMrf = std::make_shared<LBP_MRF>();
 
     if (enableMultiLayer)
-      multiLayer = new MultiLayer;
+      multiLayer = std::make_shared<MultiLayer>();
 
     if (enablePBAS)
-      pixelBasedAdaptiveSegmenter = new PixelBasedAdaptiveSegmenter;
+      pixelBasedAdaptiveSegmenter = std::make_shared<PixelBasedAdaptiveSegmenter>();
 
     if (enableVuMeter)
-      vuMeter = new VuMeter;
+      vuMeter = std::make_shared<VuMeter>();
 
     if (enableKDE)
-      kde = new KDE;
+      kde = std::make_shared<KDE>();
 
     if (enableIMBS)
-      imbs = new IndependentMultimodal;
+      imbs = std::make_shared<IndependentMultimodal>();
 
     if (enableMultiCue)
-      multiCue = new MultiCue;
+      multiCue = std::make_shared<MultiCue>();
 #endif
 
     if (enableSigmaDelta)
-      sigmaDelta = new SigmaDelta;
+      sigmaDelta = std::make_shared<SigmaDelta>();
 
     if (enableSuBSENSE)
-      subSENSE = new SuBSENSE;
+      subSENSE = std::make_shared<SuBSENSE>();
 
     if (enableLOBSTER)
-      lobster = new LOBSTER;
+      lobster = std::make_shared<LOBSTER>();
 
     if (enablePAWCS)
-      pawcs = new PAWCS;
+      pawcs = std::make_shared<PAWCS>();
 
     if (enableTwoPoints)
-      twoPoints = new TwoPoints;
+      twoPoints = std::make_shared<TwoPoints>();
 
     if (enableViBe)
-      vibe = new ViBe;
+      vibe = std::make_shared<ViBe>();
 
     if (enableCodeBook)
-      codeBook = new CodeBook;
+      codeBook = std::make_shared<CodeBook>();
 
     if (enableForegroundMaskAnalysis)
-      foregroundMaskAnalysis = new ForegroundMaskAnalysis;
+      foregroundMaskAnalysis = std::make_shared<ForegroundMaskAnalysis>();
   }
-
-  void FrameProcessor::process(std::string name, IBGS *bgs, const cv::Mat &img_input, cv::Mat &img_bgs)
+  
+  void FrameProcessor::process(const std::string name, const std::shared_ptr<IBGS> &bgs, const cv::Mat &img_input, cv::Mat &img_bgs)
   {
     if (tictoc == name)
       tic(name);
-
+    
     cv::Mat img_bkgmodel;
     bgs->process(img_input, img_bgs, img_bkgmodel);
-
+    
     if (tictoc == name)
       toc();
   }
-
+  
   void FrameProcessor::process(const cv::Mat &img_input)
   {
     frameNumber++;
 
     if (enablePreProcessor)
       preProcessor->process(img_input, img_preProcessor);
+    else
+      img_input.copyTo(img_preProcessor);
 
     if (enableFrameDifference)
       process("FrameDifference", frameDifference, img_preProcessor, img_frameDifference);
@@ -382,166 +384,7 @@ namespace bgslibrary
     firstTime = false;
   }
 
-  void FrameProcessor::finish(void)
-  {
-    /*if(enableMultiLayer)
-    multiLayer->finish();
-
-    if(enableLBSimpleGaussian)
-    lbSimpleGaussian->finish();
-
-    if(enableLBFuzzyGaussian)
-    lbFuzzyGaussian->finish();
-
-    if(enableLBMixtureOfGaussians)
-    lbMixtureOfGaussians->finish();
-
-    if(enableLBAdaptiveSOM)
-    lbAdaptiveSOM->finish();
-
-    if(enableLBFuzzyAdaptiveSOM)
-    lbFuzzyAdaptiveSOM->finish();*/
-
-    if (enableForegroundMaskAnalysis)
-      delete foregroundMaskAnalysis;
-
-    if (enableCodeBook)
-      delete codeBook;
-
-    if (enableViBe)
-      delete vibe;
-
-    if (enableTwoPoints)
-      delete twoPoints;
-
-    if (enablePAWCS)
-      delete pawcs;
-
-    if (enableLOBSTER)
-      delete lobster;
-
-    if (enableSuBSENSE)
-      delete subSENSE;
-
-    if (enableSigmaDelta)
-      delete sigmaDelta;
-
-#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
-    if (enableMultiCue)
-      delete multiCue;
-
-    if (enableIMBS)
-      delete imbs;
-
-    if (enableKDE)
-      delete kde;
-
-    if (enableVuMeter)
-      delete vuMeter;
-
-    if (enablePBAS)
-      delete pixelBasedAdaptiveSegmenter;
-
-    if (enableMultiLayer)
-      delete multiLayer;
-
-    if (enableLBFuzzyAdaptiveSOM)
-      delete lbFuzzyAdaptiveSOM;
-
-    if (enableLBAdaptiveSOM)
-      delete lbAdaptiveSOM;
-
-    if (enableLBMixtureOfGaussians)
-      delete lbMixtureOfGaussians;
-
-    if (enableLBFuzzyGaussian)
-      delete lbFuzzyGaussian;
-
-    if (enableLBSimpleGaussian)
-      delete lbSimpleGaussian;
-
-    if (enableLbpMrf)
-      delete lbpMrf;
-
-    if (enableFuzzyChoquetIntegral)
-      delete fuzzyChoquetIntegral;
-
-    if (enableFuzzySugenoIntegral)
-      delete fuzzySugenoIntegral;
-
-    if (enableT2FMRF_UV)
-      delete type2FuzzyMRF_UV;
-
-    if (enableT2FMRF_UM)
-      delete type2FuzzyMRF_UM;
-
-    if (enableT2FGMM_UV)
-      delete type2FuzzyGMM_UV;
-
-    if (enableT2FGMM_UM)
-      delete type2FuzzyGMM_UM;
-
-    if (enableDPTexture)
-      delete dpTexture;
-
-    if (enableDPEigenbackground)
-      delete dpEigenBackground;
-
-    if (enableDPPratiMediod)
-      delete dpPratiMediod;
-
-    if (enableDPWrenGA)
-      delete dpWrenGA;
-
-    if (enableDPMean)
-      delete dpTemporalMean;
-
-    if (enableDPZivkovicAGMM)
-      delete dpZivkovicAGMM;
-
-    if (enableDPGrimsonGMM)
-      delete dpGrimsonGMM;
-
-    if (enableDPAdaptiveMedian)
-      delete dpAdaptiveMedian;
-#endif
-
-#if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
-    if (enableGMG)
-      delete gmg;
-#endif
-
-#if CV_MAJOR_VERSION >= 3
-    if (enableKNN)
-      delete knn;
-#endif
-
-#if CV_MAJOR_VERSION == 2
-    if (enableMixtureOfGaussianV1)
-      delete mixtureOfGaussianV1;
-#endif
-    
-    if (enableMixtureOfGaussianV2)
-      delete mixtureOfGaussianV2;
-    
-    if (enableAdaptiveBackgroundLearning)
-      delete adaptiveBackgroundLearning;
-
-    if (enableWeightedMovingVariance)
-      delete weightedMovingVariance;
-
-    if (enableWeightedMovingMean)
-      delete weightedMovingMean;
-
-    if (enableStaticFrameDifference)
-      delete staticFrameDifference;
-
-    if (enableFrameDifference)
-      delete frameDifference;
-
-    if (enablePreProcessor)
-      delete preProcessor;
-  }
+  void FrameProcessor::finish(void){}
 
   void FrameProcessor::tic(std::string value)
   {
diff --git a/src/FrameProcessor.h b/src/FrameProcessor.h
index 4b40f24d7852c3bfff63caad85ac4d986f500224..63a9f42c1588c8dd5dd009cee5549729ea62e890 100644
--- a/src/FrameProcessor.h
+++ b/src/FrameProcessor.h
@@ -19,187 +19,187 @@ namespace bgslibrary
     std::string tictoc;
 
     cv::Mat img_preProcessor;
-    PreProcessor* preProcessor;
-    bool enablePreProcessor;
+    std::unique_ptr<PreProcessor> preProcessor;
+    bool enablePreProcessor = false;
 
     cv::Mat img_frameDifference;
-    FrameDifference* frameDifference;
-    bool enableFrameDifference;
+    std::shared_ptr<FrameDifference> frameDifference;
+    bool enableFrameDifference = false;
 
     cv::Mat img_staticFrameDifference;
-    StaticFrameDifference* staticFrameDifference;
-    bool enableStaticFrameDifference;
+    std::shared_ptr<StaticFrameDifference> staticFrameDifference;
+    bool enableStaticFrameDifference = false;
 
     cv::Mat img_weightedMovingMean;
-    WeightedMovingMean* weightedMovingMean;
-    bool enableWeightedMovingMean;
+    std::shared_ptr<WeightedMovingMean> weightedMovingMean;
+    bool enableWeightedMovingMean = false;
 
     cv::Mat img_weightedMovingVariance;
-    WeightedMovingVariance* weightedMovingVariance;
-    bool enableWeightedMovingVariance;
+    std::shared_ptr<WeightedMovingVariance> weightedMovingVariance;
+    bool enableWeightedMovingVariance = false;
 
 #if CV_MAJOR_VERSION == 2
     cv::Mat img_mixtureOfGaussianV1;
-    MixtureOfGaussianV1* mixtureOfGaussianV1;
-    bool enableMixtureOfGaussianV1;
+    std::shared_ptr<MixtureOfGaussianV1> mixtureOfGaussianV1;
+    bool enableMixtureOfGaussianV1 = false;
 #endif
 
     cv::Mat img_mixtureOfGaussianV2;
-    MixtureOfGaussianV2* mixtureOfGaussianV2;
-    bool enableMixtureOfGaussianV2;
+    std::shared_ptr<MixtureOfGaussianV2> mixtureOfGaussianV2;
+    bool enableMixtureOfGaussianV2 = false;
 
     cv::Mat img_adaptiveBackgroundLearning;
-    AdaptiveBackgroundLearning* adaptiveBackgroundLearning;
-    bool enableAdaptiveBackgroundLearning;
+    std::shared_ptr<AdaptiveBackgroundLearning> adaptiveBackgroundLearning;
+    bool enableAdaptiveBackgroundLearning = false;
 
 #if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3
     cv::Mat img_gmg;
-    GMG* gmg;
-    bool enableGMG;
+    std::shared_ptr<GMG> gmg;
+    bool enableGMG = false;
 #endif
 
 #if CV_MAJOR_VERSION >= 3
     cv::Mat img_knn;
-    KNN* knn;
-    bool enableKNN;
+    std::shared_ptr<KNN> knn;
+    bool enableKNN = false;
 #endif
 
 #if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
     cv::Mat img_dpAdaptiveMedian;
-    DPAdaptiveMedian* dpAdaptiveMedian;
-    bool enableDPAdaptiveMedian;
+    std::shared_ptr<DPAdaptiveMedian> dpAdaptiveMedian;
+    bool enableDPAdaptiveMedian = false;
 
     cv::Mat img_dpGrimsonGMM;
-    DPGrimsonGMM* dpGrimsonGMM;
-    bool enableDPGrimsonGMM;
+    std::shared_ptr<DPGrimsonGMM> dpGrimsonGMM;
+    bool enableDPGrimsonGMM = false;
 
     cv::Mat img_dpZivkovicAGMM;
-    DPZivkovicAGMM* dpZivkovicAGMM;
-    bool enableDPZivkovicAGMM;
+    std::shared_ptr<DPZivkovicAGMM> dpZivkovicAGMM;
+    bool enableDPZivkovicAGMM = false;
 
     cv::Mat img_dpTemporalMean;
-    DPMean* dpTemporalMean;
-    bool enableDPMean;
+    std::shared_ptr<DPMean> dpTemporalMean;
+    bool enableDPMean = false;
 
     cv::Mat img_dpWrenGA;
-    DPWrenGA* dpWrenGA;
-    bool enableDPWrenGA;
+    std::shared_ptr<DPWrenGA> dpWrenGA;
+    bool enableDPWrenGA = false;
 
     cv::Mat img_dpPratiMediod;
-    DPPratiMediod* dpPratiMediod;
-    bool enableDPPratiMediod;
+    std::shared_ptr<DPPratiMediod> dpPratiMediod;
+    bool enableDPPratiMediod = false;
 
     cv::Mat img_dpEigenBackground;
-    DPEigenbackground* dpEigenBackground;
-    bool enableDPEigenbackground;
+    std::shared_ptr<DPEigenbackground> dpEigenBackground;
+    bool enableDPEigenbackground = false;
 
     cv::Mat img_dpTexture;
-    DPTexture* dpTexture;
-    bool enableDPTexture;
+    std::shared_ptr<DPTexture> dpTexture;
+    bool enableDPTexture = false;
 
     cv::Mat img_type2FuzzyGMM_UM;
-    T2FGMM_UM* type2FuzzyGMM_UM;
-    bool enableT2FGMM_UM;
+    std::shared_ptr<T2FGMM_UM> type2FuzzyGMM_UM;
+    bool enableT2FGMM_UM = false;
 
     cv::Mat img_type2FuzzyGMM_UV;
-    T2FGMM_UV* type2FuzzyGMM_UV;
-    bool enableT2FGMM_UV;
+    std::shared_ptr<T2FGMM_UV> type2FuzzyGMM_UV;
+    bool enableT2FGMM_UV = false;
 
     cv::Mat img_type2FuzzyMRF_UM;
-    T2FMRF_UM* type2FuzzyMRF_UM;
-    bool enableT2FMRF_UM;
+    std::shared_ptr<T2FMRF_UM> type2FuzzyMRF_UM;
+    bool enableT2FMRF_UM = false;
 
     cv::Mat img_type2FuzzyMRF_UV;
-    T2FMRF_UV* type2FuzzyMRF_UV;
-    bool enableT2FMRF_UV;
+    std::shared_ptr<T2FMRF_UV> type2FuzzyMRF_UV;
+    bool enableT2FMRF_UV = false;
 
     cv::Mat img_fuzzySugenoIntegral;
-    FuzzySugenoIntegral* fuzzySugenoIntegral;
-    bool enableFuzzySugenoIntegral;
+    std::shared_ptr<FuzzySugenoIntegral> fuzzySugenoIntegral;
+    bool enableFuzzySugenoIntegral = false;
 
     cv::Mat img_fuzzyChoquetIntegral;
-    FuzzyChoquetIntegral* fuzzyChoquetIntegral;
-    bool enableFuzzyChoquetIntegral;
+    std::shared_ptr<FuzzyChoquetIntegral> fuzzyChoquetIntegral;
+    bool enableFuzzyChoquetIntegral = false;
 
     cv::Mat img_lbSimpleGaussian;
-    LBSimpleGaussian* lbSimpleGaussian;
-    bool enableLBSimpleGaussian;
+    std::shared_ptr<LBSimpleGaussian> lbSimpleGaussian;
+    bool enableLBSimpleGaussian = false;
 
     cv::Mat img_lbFuzzyGaussian;
-    LBFuzzyGaussian* lbFuzzyGaussian;
-    bool enableLBFuzzyGaussian;
+    std::shared_ptr<LBFuzzyGaussian> lbFuzzyGaussian;
+    bool enableLBFuzzyGaussian = false;
 
     cv::Mat img_lbMixtureOfGaussians;
-    LBMixtureOfGaussians* lbMixtureOfGaussians;
-    bool enableLBMixtureOfGaussians;
+    std::shared_ptr<LBMixtureOfGaussians> lbMixtureOfGaussians;
+    bool enableLBMixtureOfGaussians = false;
 
     cv::Mat img_lbAdaptiveSOM;
-    LBAdaptiveSOM* lbAdaptiveSOM;
-    bool enableLBAdaptiveSOM;
+    std::shared_ptr<LBAdaptiveSOM> lbAdaptiveSOM;
+    bool enableLBAdaptiveSOM = false;
 
     cv::Mat img_lbFuzzyAdaptiveSOM;
-    LBFuzzyAdaptiveSOM* lbFuzzyAdaptiveSOM;
-    bool enableLBFuzzyAdaptiveSOM;
+    std::shared_ptr<LBFuzzyAdaptiveSOM> lbFuzzyAdaptiveSOM;
+    bool enableLBFuzzyAdaptiveSOM = false;
     
     cv::Mat img_lbpMrf;
-    LBP_MRF* lbpMrf;
-    bool enableLbpMrf;
+    std::shared_ptr<LBP_MRF> lbpMrf;
+    bool enableLbpMrf = false;
 
     cv::Mat img_multiLayer;
-    MultiLayer* multiLayer;
-    bool enableMultiLayer;
+    std::shared_ptr<MultiLayer> multiLayer;
+    bool enableMultiLayer = false;
 
     cv::Mat img_pixelBasedAdaptiveSegmenter;
-    PixelBasedAdaptiveSegmenter* pixelBasedAdaptiveSegmenter;
-    bool enablePBAS;
+    std::shared_ptr<PixelBasedAdaptiveSegmenter> pixelBasedAdaptiveSegmenter;
+    bool enablePBAS = false;
 
     cv::Mat img_vumeter;
-    VuMeter* vuMeter;
-    bool enableVuMeter;
+    std::shared_ptr<VuMeter> vuMeter;
+    bool enableVuMeter = false;
 
     cv::Mat img_kde;
-    KDE* kde;
-    bool enableKDE;
+    std::shared_ptr<KDE> kde;
+    bool enableKDE = false;
 
     cv::Mat img_imbs;
-    IndependentMultimodal* imbs;
-    bool enableIMBS;
+    std::shared_ptr<IndependentMultimodal> imbs;
+    bool enableIMBS = false;
 
     cv::Mat img_multiCue;
-    MultiCue* multiCue;
-    bool enableMultiCue;
+    std::shared_ptr<MultiCue> multiCue;
+    bool enableMultiCue = false;
 #endif
 
     cv::Mat img_sigmaDelta;
-    SigmaDelta* sigmaDelta;
-    bool enableSigmaDelta;
+    std::shared_ptr<SigmaDelta> sigmaDelta;
+    bool enableSigmaDelta = false;
 
     cv::Mat img_subSENSE;
-    SuBSENSE* subSENSE;
-    bool enableSuBSENSE;
+    std::shared_ptr<SuBSENSE> subSENSE;
+    bool enableSuBSENSE = false;
 
     cv::Mat img_lobster;
-    LOBSTER* lobster;
-    bool enableLOBSTER;
+    std::shared_ptr<LOBSTER> lobster;
+    bool enableLOBSTER = false;
 
     cv::Mat img_pawcs;
-    PAWCS* pawcs;
-    bool enablePAWCS;
+    std::shared_ptr<PAWCS> pawcs;
+    bool enablePAWCS = false;
 
     cv::Mat img_twoPoints;
-    TwoPoints* twoPoints;
-    bool enableTwoPoints;
+    std::shared_ptr<TwoPoints> twoPoints;
+    bool enableTwoPoints = false;
 
     cv::Mat img_vibe;
-    ViBe* vibe;
-    bool enableViBe;
+    std::shared_ptr<ViBe> vibe;
+    bool enableViBe = false;
 
     cv::Mat img_codeBook;
-    CodeBook* codeBook;
-    bool enableCodeBook;
-
-    ForegroundMaskAnalysis* foregroundMaskAnalysis;
-    bool enableForegroundMaskAnalysis;
+    std::shared_ptr<CodeBook> codeBook;
+    bool enableCodeBook = false;
+    
+    std::shared_ptr<ForegroundMaskAnalysis> foregroundMaskAnalysis;
+    bool enableForegroundMaskAnalysis = false;
 
   public:
     FrameProcessor();
@@ -213,7 +213,7 @@ namespace bgslibrary
     void finish(void);
 
   private:
-    void process(std::string name, IBGS *bgs, const cv::Mat &img_input, cv::Mat &img_bgs);
+    void process(const std::string name, const std::shared_ptr<IBGS> &bgs, const cv::Mat &img_input, cv::Mat &img_bgs);
     void tic(std::string value);
     void toc();
 
diff --git a/src/VideoCapture.cpp b/src/VideoCapture.cpp
index 9fb004b904f9e35b2e6821ae3b308a7060ddaf3b..bcf44e4d2e28b756af80573bcc117e7d57ced38d 100644
--- a/src/VideoCapture.cpp
+++ b/src/VideoCapture.cpp
@@ -82,9 +82,9 @@ namespace bgslibrary
     std::cout << "~VideoCapture()" << std::endl;
   }
 
-  void VideoCapture::setFrameProcessor(std::shared_ptr<IFrameProcessor> frameProcessorPtr)
+  void VideoCapture::setFrameProcessor(const std::shared_ptr<IFrameProcessor> &_frameProcessor)
   {
-    frameProcessor = frameProcessorPtr;
+    frameProcessor = _frameProcessor;
   }
 
   void VideoCapture::setCamera(int _index)
diff --git a/src/VideoCapture.h b/src/VideoCapture.h
index 9a3bf823b6abb79137becec90f5b663258a1cd56..1f6abc2f30ba3f4fc9ba1ab5a8fe0886d8e54014 100644
--- a/src/VideoCapture.h
+++ b/src/VideoCapture.h
@@ -43,9 +43,9 @@ namespace bgslibrary
     VideoCapture();
     ~VideoCapture();
 
-    void setFrameProcessor(std::shared_ptr<IFrameProcessor> frameProcessorPtr);
-    void setCamera(int cameraIndex);
-    void setVideo(std::string filename);
+    void setFrameProcessor(const std::shared_ptr<IFrameProcessor> &_frameProcessor);
+    void setCamera(int _index);
+    void setVideo(std::string _filename);
     void start();
 
   private: