From 3a552f97702613d4d08f6c9c486d4427df9512d9 Mon Sep 17 00:00:00 2001
From: jvallve <jvallve@iri.upc.edu>
Date: Tue, 12 Apr 2022 16:22:38 +0200
Subject: [PATCH] removing const auto& of returned lists and more

---
 demos/solver/test_iQR_wolf2.cpp               | 14 +--
 include/core/capture/capture_base.h           |  1 +
 include/core/feature/feature_base.h           |  1 +
 include/core/frame/frame_base.h               |  1 +
 include/core/hardware/hardware_base.h         |  6 ++
 include/core/state_block/has_state_blocks.h   |  4 +-
 include/core/trajectory/trajectory_base.h     | 18 ++++
 src/capture/capture_base.cpp                  | 27 +++---
 src/ceres_wrapper/solver_ceres.cpp            |  6 +-
 src/factor/factor_base.cpp                    | 24 ++---
 src/feature/feature_base.cpp                  |  9 +-
 src/frame/frame_base.cpp                      | 17 ++--
 src/hardware/hardware_base.cpp                | 30 +++++++
 src/landmark/landmark_base.cpp                | 14 +--
 src/problem/problem.cpp                       | 89 ++++++++-----------
 src/processor/processor_loop_closure.cpp      |  2 +-
 src/processor/processor_motion.cpp            | 18 ++--
 src/sensor/sensor_base.cpp                    | 14 +--
 src/solver/solver_manager.cpp                 |  6 +-
 src/solver_suitesparse/solver_manager.cpp     | 14 +--
 src/state_block/has_state_blocks.cpp          |  6 +-
 src/state_block/state_composite.cpp           | 12 +--
 src/utils/graph_search.cpp                    |  4 +-
 test/gtest_problem.cpp                        | 12 +--
 .../gtest_processor_tracker_feature_dummy.cpp |  8 +-
 ...gtest_processor_tracker_landmark_dummy.cpp |  9 +-
 26 files changed, 207 insertions(+), 159 deletions(-)

diff --git a/demos/solver/test_iQR_wolf2.cpp b/demos/solver/test_iQR_wolf2.cpp
index 2e8ee85c2..e634dac6f 100644
--- a/demos/solver/test_iQR_wolf2.cpp
+++ b/demos/solver/test_iQR_wolf2.cpp
@@ -309,9 +309,9 @@ int main(int argc, char *argv[])
 
         // draw landmarks
         std::vector<double> landmark_vector;
-        for (auto landmark_it = wolf_manager_QR->getProblem()->getMap()->getLandmarkList().begin(); landmark_it != wolf_manager_QR->getProblem()->getMap()->getLandmarkList().end(); landmark_it++)
+        for (auto landmark : wolf_manager_QR->getProblem()->getMap()->getLandmarkList())
         {
-            double* position_ptr = (*landmark_it)->getP()->get();
+            double* position_ptr = landmark->getP()->get();
             landmark_vector.push_back(*position_ptr); //x
             landmark_vector.push_back(*(position_ptr + 1)); //y
             landmark_vector.push_back(0.2); //z
@@ -364,9 +364,9 @@ int main(int argc, char *argv[])
     // Draw Final result -------------------------
     std::cout << "Drawing final results..." << std::endl;
     std::vector<double> landmark_vector;
-    for (auto landmark_it = wolf_manager_QR->getProblem()->getMap()->getLandmarkList().begin(); landmark_it != wolf_manager_QR->getProblem()->getMap()->getLandmarkList().end(); landmark_it++)
+    for (auto landmark : wolf_manager_QR->getProblem()->getMap()->getLandmarkList())
     {
-        double* position_ptr = (*landmark_it)->getP()->get();
+        double* position_ptr = landmark->getP()->get();
         landmark_vector.push_back(*position_ptr); //x
         landmark_vector.push_back(*(position_ptr + 1)); //y
         landmark_vector.push_back(0.2); //z
@@ -398,10 +398,10 @@ int main(int argc, char *argv[])
     std::cout << "Landmarks..." << std::endl;
     i = 0;
     Eigen::VectorXd landmarks(wolf_manager_QR->getProblem()->getMap()->getLandmarkList().size() * 2);
-    for (auto landmark_it = wolf_manager_QR->getProblem()->getMap()->getLandmarkList().begin(); landmark_it != wolf_manager_QR->getProblem()->getMap()->getLandmarkList().end(); landmark_it++)
+    for (auto landmark : wolf_manager_QR->getProblem()->getMap()->getLandmarkList())
     {
-        Eigen::Map<Eigen::Vector2d> landmark((*landmark_it)->getP()->get());
-        landmarks.segment(i, 2) = landmark;
+        Eigen::Map<Eigen::Vector2d> landmark_p(landmark->getP()->get());
+        landmarks.segment(i, 2) = landmark_p;
         i += 2;
     }
 
diff --git a/include/core/capture/capture_base.h b/include/core/capture/capture_base.h
index 1c2f80ab6..87fffa2d3 100644
--- a/include/core/capture/capture_base.h
+++ b/include/core/capture/capture_base.h
@@ -90,6 +90,7 @@ class CaptureBase : public NodeBase, public HasStateBlocks, public std::enable_s
     public:
         FeatureBaseConstPtrList getFeatureList() const;
         FeatureBasePtrList getFeatureList();
+        bool hasFeature(const FeatureBaseConstPtr &_feature) const;
         
         FactorBaseConstPtrList getFactorList() const;
         FactorBasePtrList getFactorList();
diff --git a/include/core/feature/feature_base.h b/include/core/feature/feature_base.h
index 3e7d29310..235a3dc70 100644
--- a/include/core/feature/feature_base.h
+++ b/include/core/feature/feature_base.h
@@ -128,6 +128,7 @@ class FeatureBase : public NodeBase, public std::enable_shared_from_this<Feature
         FactorBasePtrList getFactorList();
         void getFactorList(FactorBaseConstPtrList & _fac_list) const;
         void getFactorList(FactorBasePtrList & _fac_list);
+        bool hasFactor(FactorBaseConstPtr _fac) const;
 
         unsigned int getHits() const;
         FactorBaseConstPtrList getConstrainedByList() const;
diff --git a/include/core/frame/frame_base.h b/include/core/frame/frame_base.h
index fbdac3eb8..86ab564e3 100644
--- a/include/core/frame/frame_base.h
+++ b/include/core/frame/frame_base.h
@@ -129,6 +129,7 @@ class FrameBase : public NodeBase, public HasStateBlocks, public std::enable_sha
 
         CaptureBaseConstPtrList getCaptureList() const;
         CaptureBasePtrList getCaptureList();
+        bool hasCapture(const CaptureBaseConstPtr& _capture) const;
 
         FactorBaseConstPtrList getFactorList() const;
         FactorBasePtrList getFactorList();
diff --git a/include/core/hardware/hardware_base.h b/include/core/hardware/hardware_base.h
index 88d72e221..ea0a977a3 100644
--- a/include/core/hardware/hardware_base.h
+++ b/include/core/hardware/hardware_base.h
@@ -50,6 +50,12 @@ class HardwareBase : public NodeBase, public std::enable_shared_from_this<Hardwa
         SensorBaseConstPtrList getSensorList() const;
         SensorBasePtrList getSensorList();
 
+        /** \brief get a sensor pointer by its name
+         * \param _sensor_name The sensor name, as it was installed with installSensor()
+         */
+        SensorBaseConstPtr getSensor(const std::string& _sensor_name) const;
+        SensorBasePtr getSensor(const std::string& _sensor_name);
+
         virtual void printHeader(int depth, //
                                  bool constr_by, //
                                  bool metric, //
diff --git a/include/core/state_block/has_state_blocks.h b/include/core/state_block/has_state_blocks.h
index ccfbc5148..ac82297f5 100644
--- a/include/core/state_block/has_state_blocks.h
+++ b/include/core/state_block/has_state_blocks.h
@@ -425,9 +425,7 @@ inline std::unordered_map<char, StateBlockPtr>::const_iterator HasStateBlocks::f
 
 inline bool HasStateBlocks::hasStateBlock(const StateBlockConstPtr &_sb) const
 {
-    const auto& it = this->find(_sb);
-
-    return it != state_block_const_map_.end();
+    return this->find(_sb) != state_block_const_map_.end();
 }
 
 inline bool HasStateBlocks::stateBlockKey(const StateBlockConstPtr &_sb, char& _key) const
diff --git a/include/core/trajectory/trajectory_base.h b/include/core/trajectory/trajectory_base.h
index becf854fa..228798693 100644
--- a/include/core/trajectory/trajectory_base.h
+++ b/include/core/trajectory/trajectory_base.h
@@ -67,6 +67,8 @@ class TrajectoryBase : public NodeBase, public std::enable_shared_from_this<Traj
         TimeStamp closestTimeStampToTimeStamp(const TimeStamp& _ts) const;
         FrameBaseConstPtr closestFrameToTimeStamp(const TimeStamp& _ts) const;
         FrameBasePtr closestFrameToTimeStamp(const TimeStamp& _ts);
+        bool hasTimeStamp(const TimeStamp& _ts) const;
+        bool hasFrame(FrameBaseConstPtr _frame) const;
 
         virtual void printHeader(int depth, //
                                  bool constr_by, //
@@ -136,6 +138,22 @@ inline SizeEigen TrajectoryBase::size() const
     return frame_const_map_.size();
 }
 
+inline bool TrajectoryBase::hasTimeStamp(const TimeStamp& _ts) const
+{
+    return frame_const_map_.count(_ts) != 0;
+}
+
+inline bool TrajectoryBase::hasFrame(FrameBaseConstPtr _frame) const
+{
+    return std::find_if(frame_const_map_.begin(), 
+                        frame_const_map_.end(), 
+                        [&_frame](std::pair<TimeStamp,FrameBaseConstPtr> frm_it)
+                        { 
+                            return frm_it.second == _frame;
+                        }) != frame_const_map_.end();
+}
+
+
 } // namespace wolf
 
 #endif
diff --git a/src/capture/capture_base.cpp b/src/capture/capture_base.cpp
index 656a43398..011a93484 100644
--- a/src/capture/capture_base.cpp
+++ b/src/capture/capture_base.cpp
@@ -46,6 +46,7 @@ CaptureBase::CaptureBase(const std::string& _type,
     {
         if (_sensor_ptr->getP() != nullptr and _sensor_ptr->isStateBlockDynamic('P'))
         {
+            WOLF_ERROR_COND(not _p_ptr, "In CaptureBase constructor of type ", _type, " the sensor ", _sensor_ptr->getType(), " ", _sensor_ptr->getName(), " has state P dynamic but provided _p_ptr is nullptr")
             assert(_p_ptr && "Pointer to dynamic position params is null!");
             addStateBlock('P', _p_ptr, nullptr);
         }
@@ -54,6 +55,7 @@ CaptureBase::CaptureBase(const std::string& _type,
 
         if (_sensor_ptr->getO() != nullptr and _sensor_ptr->isStateBlockDynamic('O'))
         {
+            WOLF_ERROR_COND(not _o_ptr, "In CaptureBase constructor of type ", _type, " the sensor ", _sensor_ptr->getType(), " ", _sensor_ptr->getName(), " has state O dynamic but provided _o_ptr is nullptr")
             assert(_o_ptr && "Pointer to dynamic orientation params is null!");
             addStateBlock('O', _o_ptr, nullptr);
         }
@@ -62,6 +64,7 @@ CaptureBase::CaptureBase(const std::string& _type,
 
         if (_sensor_ptr->getIntrinsic() != nullptr and _sensor_ptr->isStateBlockDynamic('I'))
         {
+            WOLF_ERROR_COND(not _intr_ptr, "In CaptureBase constructor of type ", _type, " the sensor ", _sensor_ptr->getType(), " ", _sensor_ptr->getName(), " has state I dynamic but provided _i_ptr is nullptr")
             assert(_intr_ptr && "Pointer to dynamic intrinsic params is null!");
             addStateBlock('I', _intr_ptr, nullptr);
         }
@@ -179,22 +182,18 @@ void CaptureBase::removeConstrainedBy(FactorBasePtr _fac_ptr)
     constrained_by_const_list_.remove(_fac_ptr);
 }
 
+bool CaptureBase::hasFeature(const FeatureBaseConstPtr &_feature) const
+{
+    return std::find(feature_const_list_.begin(),
+                     feature_const_list_.end(),
+                     _feature) != feature_const_list_.end();
+}
+
 bool CaptureBase::isConstrainedBy(const FactorBaseConstPtr &_factor) const
 {
     return std::find(constrained_by_const_list_.begin(),
                      constrained_by_const_list_.end(),
                      _factor) != constrained_by_const_list_.end();
-    // FactorBaseConstPtrConstIter cby_it = std::find_if(constrained_by_const_list_.begin(),
-    //                                                   constrained_by_const_list_.end(),
-    //                                                   [_factor](const FactorBaseConstPtr & cby)
-    //                                                   {
-    //                                                       return cby == _factor;
-    //                                                   }
-    //                                                   );
-    // if (cby_it != constrained_by_const_list_.end())
-    //     return true;
-    // else
-    //     return false;
 }
 
 StateBlockConstPtr CaptureBase::getStateBlock(const char& _key) const
@@ -376,12 +375,12 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBaseConstPtr _cap_ptr, st
 
 
     // check contrained_by
-    for (const auto& cby : getConstrainedByList())
+    for (auto cby : getConstrainedByList())
     {
         if (_verbose)
         {
             _stream << _tabs << "    " << "<- Fac" << cby->id() << " -> ";
-            for (const auto& Cow : cby->getCaptureOtherList())
+            for (auto Cow : cby->getCaptureOtherList())
                 _stream << " Cap" << Cow.lock()->id();
             _stream << std::endl;
         }
@@ -441,7 +440,7 @@ CheckLog CaptureBase::localCheck(bool _verbose, CaptureBaseConstPtr _cap_ptr, st
     if(getSensor() != nullptr )
     {
         match_any_prc_timetolerance = getSensor()->getProcessorList().empty();
-        for(auto const& prc : getSensor()->getProcessorList())
+        for(auto prc : getSensor()->getProcessorList())
         {
             match_any_prc_timetolerance = match_any_prc_timetolerance or (time_diff <= prc->getTimeTolerance());
         }
diff --git a/src/ceres_wrapper/solver_ceres.cpp b/src/ceres_wrapper/solver_ceres.cpp
index da38aa736..b9fa97ae6 100644
--- a/src/ceres_wrapper/solver_ceres.cpp
+++ b/src/ceres_wrapper/solver_ceres.cpp
@@ -119,7 +119,7 @@ bool SolverCeres::computeCovariancesDerived(const CovarianceBlocksToBeComputed _
             std::vector<StateBlockPtr> all_state_blocks, landmark_state_blocks;
             //frame state blocks
             for(auto fr_pair : wolf_problem_->getTrajectory()->getFrameMap())
-                for (const auto& key : fr_pair.second->getStructure())
+                for (auto key : fr_pair.second->getStructure())
                 {
                     const auto& sb = fr_pair.second->getStateBlock(key);
                     all_state_blocks.push_back(sb);
@@ -150,12 +150,12 @@ bool SolverCeres::computeCovariancesDerived(const CovarianceBlocksToBeComputed _
         {
             // first create a vector containing all state blocks
             for(auto fr_pair : wolf_problem_->getTrajectory()->getFrameMap())
-                for (const auto& key1 : wolf_problem_->getFrameStructure())
+                for (auto key1 : wolf_problem_->getFrameStructure())
                 {
                     const auto& sb1 = fr_pair.second->getStateBlock(key1);
                     assert(isStateBlockRegisteredDerived(sb1));
 
-                    for (const auto& key2 : wolf_problem_->getFrameStructure())
+                    for (auto key2 : wolf_problem_->getFrameStructure())
                     {
                         const auto& sb2 = fr_pair.second->getStateBlock(key2);
                         assert(isStateBlockRegisteredDerived(sb2));
diff --git a/src/factor/factor_base.cpp b/src/factor/factor_base.cpp
index 37e1bcdaa..faecad96a 100644
--- a/src/factor/factor_base.cpp
+++ b/src/factor/factor_base.cpp
@@ -332,16 +332,16 @@ void FactorBase::printHeader(int _depth, bool _constr_by, bool _metric, bool _st
                && getLandmarkOtherList().empty())
         _stream << " Abs";
 
-    for (const auto& Fow : getFrameOtherList())
+    for (auto Fow : getFrameOtherList())
         if (!Fow.expired())
             _stream << " Frm" << Fow.lock()->id();
-    for (const auto& Cow : getCaptureOtherList())
+    for (auto Cow : getCaptureOtherList())
         if (!Cow.expired())
             _stream << " Cap" << Cow.lock()->id();
-    for (const auto& fow : getFeatureOtherList())
+    for (auto fow : getFeatureOtherList())
         if (!fow.expired())
             _stream << " Ftr" << fow.lock()->id();
-    for (const auto& Low : getLandmarkOtherList())
+    for (auto Low : getLandmarkOtherList())
         if (!Low.expired())
             _stream << " Lmk" << Low.lock()->id();
     _stream << std::endl;
@@ -370,7 +370,7 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBaseConstPtr _fac_ptr, std:
     }
 
     // find constrained_by pointer in constrained frame
-    for (const auto& Fow : getFrameOtherList())
+    for (auto Fow : getFrameOtherList())
     {
         if (!Fow.expired())
         {
@@ -393,7 +393,7 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBaseConstPtr _fac_ptr, std:
     if (_verbose && !getFrameOtherList().empty())
         _stream << ")";
     // find constrained_by pointer in constrained capture
-    for (const auto& Cow : getCaptureOtherList())
+    for (auto Cow : getCaptureOtherList())
     {
         if (!Cow.expired())
         {
@@ -417,7 +417,7 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBaseConstPtr _fac_ptr, std:
     if (_verbose && !getCaptureOtherList().empty())
         _stream << ")";
     // find constrained_by pointer in constrained feature
-    for (const auto& fow : getFeatureOtherList())
+    for (auto fow : getFeatureOtherList())
     {
         if (!fow.expired())
         {
@@ -440,7 +440,7 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBaseConstPtr _fac_ptr, std:
         _stream << ")";
 
     // find constrained_by pointer in constrained landmark
-    for (const auto& Low : getLandmarkOtherList())
+    for (auto Low : getLandmarkOtherList())
     {
         if (Low.expired())
         {
@@ -546,7 +546,7 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBaseConstPtr _fac_ptr, std:
 
 
         // find in constrained Frame
-        for (const auto& Fow : getFrameOtherList())
+        for (auto Fow : getFrameOtherList())
         {
             if (!Fow.expired())
             {
@@ -567,7 +567,7 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBaseConstPtr _fac_ptr, std:
         }
 
         // find in constrained Capture
-        for (const auto& Cow : getCaptureOtherList())
+        for (auto Cow : getCaptureOtherList())
         {
             if (!Cow.expired())
             {
@@ -579,7 +579,7 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBaseConstPtr _fac_ptr, std:
         }
 
         // find in constrained Feature
-        for (const auto& fow : getFeatureOtherList())
+        for (auto fow : getFeatureOtherList())
         {
             if (!fow.expired())
             {
@@ -605,7 +605,7 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBaseConstPtr _fac_ptr, std:
         }
 
         // find in constrained landmark
-        for (const auto& Low : getLandmarkOtherList())
+        for (auto Low : getLandmarkOtherList())
         {
             if (!Low.expired())
             {
diff --git a/src/feature/feature_base.cpp b/src/feature/feature_base.cpp
index 09971a9f9..7fdf1bfa0 100644
--- a/src/feature/feature_base.cpp
+++ b/src/feature/feature_base.cpp
@@ -134,6 +134,13 @@ bool FeatureBase::isConstrainedBy(const FactorBaseConstPtr &_factor) const
                      _factor) != constrained_by_const_list_.end();
 }
 
+bool FeatureBase::hasFactor(FactorBaseConstPtr _factor) const
+{
+    return std::find(factor_const_list_.begin(),
+                     factor_const_list_.end(),
+                     _factor) != factor_const_list_.end();
+}
+
 void FeatureBase::getFactorList(FactorBaseConstPtrList & _fac_list) const
 {
     _fac_list.insert(_fac_list.end(), factor_const_list_.begin(), factor_const_list_.end());
@@ -249,7 +256,7 @@ CheckLog FeatureBase::localCheck(bool _verbose, FeatureBaseConstPtr _ftr_ptr, st
         if (_verbose)
         {
             _stream << _tabs << "    " << "<- Fac" << cby->id() << " -> ";
-            for (const auto& fow : cby->getFeatureOtherList())
+            for (auto fow : cby->getFeatureOtherList())
                 _stream << " Ftr" << fow.lock()->id();
             _stream << std::endl;
         }
diff --git a/src/frame/frame_base.cpp b/src/frame/frame_base.cpp
index c76d30896..9490b58a3 100644
--- a/src/frame/frame_base.cpp
+++ b/src/frame/frame_base.cpp
@@ -362,6 +362,13 @@ void FrameBase::getFactorList(FactorBasePtrList& _fac_list)
         c_ptr->getFactorList(_fac_list);
 }
 
+bool FrameBase::hasCapture(const CaptureBaseConstPtr& _capture) const
+{
+    return std::find(capture_const_list_.begin(),
+                     capture_const_list_.end(),
+                     _capture) != capture_const_list_.end();
+}
+
 FactorBasePtr FrameBase::addConstrainedBy(FactorBasePtr _fac_ptr)
 {
     constrained_by_list_.push_back(_fac_ptr);
@@ -484,7 +491,7 @@ CheckLog FrameBase::localCheck(bool _verbose, FrameBaseConstPtr _frm_ptr, std::o
         if (_verbose)
         {
             _stream << _tabs << "    " << "<- Fac" << cby->id() << " -> ";
-            for (const auto& Fow : cby->getFrameOtherList())
+            for (auto Fow : cby->getFrameOtherList())
                 _stream << " Frm" << Fow.lock()->id() << std::endl;
 
 
@@ -515,13 +522,7 @@ CheckLog FrameBase::localCheck(bool _verbose, FrameBaseConstPtr _frm_ptr, std::o
     inconsistency_explanation << "Frm" << id() << " @ " << _frm_ptr
                               << " ---> Trj" << " @ " << trj_ptr
                               << " -X-> Frm" << id();
-    auto trj_has_frm = std::find_if(trj_ptr->getFrameMap().begin(), 
-                                    trj_ptr->getFrameMap().end(), 
-                                    [&_frm_ptr](std::pair<TimeStamp,FrameBaseConstPtr> frm_it)
-                                    { 
-                                        return frm_it.second == _frm_ptr;
-                                    });
-    log.assertTrue(trj_has_frm != trj_ptr->getFrameMap().end(), inconsistency_explanation);
+    log.assertTrue(trj_ptr->hasFrame(_frm_ptr), inconsistency_explanation);
 
     // Captures
     for(auto C : getCaptureList())
diff --git a/src/hardware/hardware_base.cpp b/src/hardware/hardware_base.cpp
index 3f9de63e6..428fb5825 100644
--- a/src/hardware/hardware_base.cpp
+++ b/src/hardware/hardware_base.cpp
@@ -42,6 +42,36 @@ SensorBasePtr HardwareBase::addSensor(SensorBasePtr _sensor_ptr)
     return _sensor_ptr;
 }
 
+SensorBaseConstPtr HardwareBase::getSensor(const std::string& _sensor_name) const
+{
+    auto sen_it = std::find_if(sensor_const_list_.begin(),
+                               sensor_const_list_.end(),
+                               [&](SensorBaseConstPtr sb)
+                               {
+                                   return sb->getName() == _sensor_name;
+                               }); // lambda function for the find_if
+
+    if (sen_it == sensor_const_list_.end())
+        return nullptr;
+
+    return (*sen_it);
+}
+
+SensorBasePtr HardwareBase::getSensor(const std::string& _sensor_name)
+{
+    auto sen_it = std::find_if(sensor_list_.begin(),
+                               sensor_list_.end(),
+                               [&](SensorBasePtr sb)
+                               {
+                                   return sb->getName() == _sensor_name;
+                               }); // lambda function for the find_if
+
+    if (sen_it == sensor_list_.end())
+        return nullptr;
+
+    return (*sen_it);
+}
+
 void HardwareBase::printHeader(int _depth, bool _constr_by, bool _metric, bool _state_blocks, std::ostream& _stream, std::string _tabs) const
 {
     _stream << _tabs << "Hardware" << ((_depth < 1) ? ("   -- " + std::to_string(getSensorList().size()) + "S") : "")  << std::endl;
diff --git a/src/landmark/landmark_base.cpp b/src/landmark/landmark_base.cpp
index 8a72934b9..20bea02c2 100644
--- a/src/landmark/landmark_base.cpp
+++ b/src/landmark/landmark_base.cpp
@@ -89,9 +89,9 @@ std::vector<StateBlockConstPtr> LandmarkBase::getUsedStateBlockVec() const
     std::vector<StateBlockConstPtr> used_state_block_vec(0);
 
     // normal state blocks in {P,O,V,W}
-    for (const auto& key : getStructure())
+    for (auto key : getStructure())
     {
-        const auto& sbp = getStateBlock(key);
+        const auto sbp = getStateBlock(key);
         if (sbp)
             used_state_block_vec.push_back(sbp);
     }
@@ -109,9 +109,9 @@ std::vector<StateBlockPtr> LandmarkBase::getUsedStateBlockVec()
     std::vector<StateBlockPtr> used_state_block_vec(0);
 
     // normal state blocks in {P,O,V,W}
-    for (const auto& key : getStructure())
+    for (auto key : getStructure())
     {
-        const auto& sbp = getStateBlock(key);
+        auto sbp = getStateBlock(key);
         if (sbp)
             used_state_block_vec.push_back(sbp);
     }
@@ -248,7 +248,7 @@ CheckLog LandmarkBase::localCheck(bool _verbose, LandmarkBaseConstPtr _lmk_ptr,
         _stream << _tabs << "Lmk" << id() << " @ " << _lmk_ptr.get() << std::endl;
         _stream << _tabs << "  -> Prb @ " << getProblem().get() << std::endl;
         _stream << _tabs << "  -> Map @ " << getMap().get() << std::endl;
-        for (const auto& pair : getStateBlockMap())
+        for (auto pair : getStateBlockMap())
         {
             auto sb = pair.second;
             _stream << _tabs << "  " << pair.first << " sb @ " << sb.get();
@@ -277,11 +277,11 @@ CheckLog LandmarkBase::localCheck(bool _verbose, LandmarkBaseConstPtr _lmk_ptr,
         {
             _stream << _tabs << "    " << "<- Fac" << cby->id() << " ->";
 
-            for (const auto& Low : cby->getLandmarkOtherList())
+            for (auto Low : cby->getLandmarkOtherList())
             {
                 if (!Low.expired())
                 {
-                    const auto& Lo = Low.lock();
+                    auto Lo = Low.lock();
                     _stream << " Lmk" << Lo->id();
                 }
             }
diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp
index 04854fba6..cc51fa680 100644
--- a/src/problem/problem.cpp
+++ b/src/problem/problem.cpp
@@ -299,6 +299,7 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, //
                                            const std::string& _params_filename)
 {
     SensorBasePtr sen_ptr = getSensor(_corresponding_sensor_name);
+    WOLF_INFO("installProcessor _corresponding_sensor_name", _corresponding_sensor_name, " found sensor name ", sen_ptr->getName())
     if (sen_ptr == nullptr)
         throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!");
     if (_params_filename == "")
@@ -335,32 +336,12 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, //
 
 SensorBaseConstPtr Problem::getSensor(const std::string& _sensor_name) const
 {
-    auto sen_it = std::find_if(getHardware()->getSensorList().begin(),
-                               getHardware()->getSensorList().end(),
-                               [&](SensorBaseConstPtr sb)
-                               {
-                                   return sb->getName() == _sensor_name;
-                               }); // lambda function for the find_if
-
-    if (sen_it == getHardware()->getSensorList().end())
-        return nullptr;
-
-    return (*sen_it);
+    return getHardware()->getSensor(_sensor_name);
 }
 
 SensorBasePtr Problem::getSensor(const std::string& _sensor_name)
 {
-    auto sen_it = std::find_if(getHardware()->getSensorList().begin(),
-                               getHardware()->getSensorList().end(),
-                               [&](SensorBasePtr sb)
-                               {
-                                   return sb->getName() == _sensor_name;
-                               }); // lambda function for the find_if
-
-    if (sen_it == getHardware()->getSensorList().end())
-        return nullptr;
-
-    return (*sen_it);
+    return getHardware()->getSensor(_sensor_name);
 }
 
 FrameBasePtr Problem::emplaceFrame(const TimeStamp& _time_stamp, //
@@ -371,7 +352,7 @@ FrameBasePtr Problem::emplaceFrame(const TimeStamp& _time_stamp, //
     VectorComposite state;
     SizeEigen index = 0;
     SizeEigen size = 0;
-    for (const auto& key : _frame_structure)
+    for (auto key : _frame_structure)
     {
         if (key == 'O')
         {
@@ -425,9 +406,9 @@ FrameBasePtr Problem::emplaceFrame (const TimeStamp& _time_stamp, //
                                        const VectorComposite& _frame_state)
 {
     // append new keys to frame structure
-    for (const auto& pair_key_vec : _frame_state)
+    for (auto pair_key_vec : _frame_state)
     {
-        const auto& key = pair_key_vec.first;
+        auto key = pair_key_vec.first;
         if (frame_structure_.find(key) == std::string::npos) // not found
             frame_structure_ += std::string(1,key);
     }
@@ -458,7 +439,7 @@ TimeStamp Problem::getTimeStamp ( ) const
 {
     TimeStamp  ts = TimeStamp::Invalid();
 
-    for (const auto& prc_pair : motion_provider_map_)
+    for (auto prc_pair : motion_provider_map_)
         if (prc_pair.second->getTimeStamp().ok())
             if ( (not ts.ok() ) or prc_pair.second->getTimeStamp() > ts)
                 ts = prc_pair.second->getTimeStamp();
@@ -466,7 +447,7 @@ TimeStamp Problem::getTimeStamp ( ) const
 
     if (not ts.ok())
     {
-        const auto& last_kf = trajectory_ptr_->getLastFrame();
+        auto last_kf = trajectory_ptr_->getLastFrame();
 
         if (last_kf)
             ts = last_kf->getTimeStamp(); // Use last estimated frame's state
@@ -486,12 +467,12 @@ VectorComposite Problem::getState(const StateStructure& _structure) const
     VectorComposite state;
 
     // compose the states of all MotionProvider processors (ordered by user-defined priority) into one only state
-    for (const auto& prc_pair : motion_provider_map_)
+    for (auto prc_pair : motion_provider_map_)
     {
-        const auto& prc_state = prc_pair.second->getState(structure);
+        auto prc_state = prc_pair.second->getState(structure);
 
         // transfer processor vector blocks to problem state
-        for (const auto& pair_key_vec : prc_state)
+        for (auto pair_key_vec : prc_state)
         {
             if (state.count(pair_key_vec.first) == 0) // Only write once. This gives priority to processors with more priority
             {  
@@ -510,7 +491,7 @@ VectorComposite Problem::getState(const StateStructure& _structure) const
 
     VectorComposite state_last;
 
-    const auto& last_kf = trajectory_ptr_->getLastFrame();
+    auto last_kf = trajectory_ptr_->getLastFrame();
 
     if (last_kf)
         state_last = last_kf->getState(structure);
@@ -518,7 +499,7 @@ VectorComposite Problem::getState(const StateStructure& _structure) const
     else if (prior_options_ and prior_options_->mode != "nothing")
         state_last = prior_options_->state;
 
-    for (const auto& key : structure)
+    for (auto key : structure)
     {
         if (state.count(key) == 0)
         {
@@ -542,12 +523,12 @@ VectorComposite Problem::getState (const TimeStamp& _ts, const StateStructure& _
     VectorComposite state;
 
     // compose the states of all MotionProvider processors (ordered by user-defined priority) into one only state
-    for (const auto& prc_pair : motion_provider_map_)
+    for (auto prc_pair : motion_provider_map_)
     {
-        const auto& prc_state = prc_pair.second->getState(_ts, structure);
+        auto prc_state = prc_pair.second->getState(_ts, structure);
 
         // transfer processor vector blocks to problem state
-        for (const auto& pair_key_vec : prc_state)
+        for (auto pair_key_vec : prc_state)
         {
             if (state.count(pair_key_vec.first) == 0) // Only write once. This gives priority to processors with more priority
                 state.insert(pair_key_vec);
@@ -564,7 +545,7 @@ VectorComposite Problem::getState (const TimeStamp& _ts, const StateStructure& _
 
     VectorComposite state_last;
 
-    const auto& last_kf = trajectory_ptr_->closestFrameToTimeStamp(_ts);
+    auto last_kf = trajectory_ptr_->closestFrameToTimeStamp(_ts);
 
     if (last_kf)
         state_last = last_kf->getState(structure);
@@ -572,7 +553,7 @@ VectorComposite Problem::getState (const TimeStamp& _ts, const StateStructure& _
     else if (prior_options_ and prior_options_->mode != "nothing")
         state_last = prior_options_->state;
 
-    for (const auto& key : structure)
+    for (auto key : structure)
     {
         if (state.count(key) == 0)
         {
@@ -596,12 +577,12 @@ VectorComposite Problem::getOdometry(const StateStructure& _structure) const
     VectorComposite odom_state;
 
     // compose the states of all MotionProvider processors (ordered by user-defined priority) into one only state
-    for (const auto& prc_pair : motion_provider_map_)
+    for (auto prc_pair : motion_provider_map_)
     {
-        const auto& prc_state = prc_pair.second->getOdometry();
+        auto prc_state = prc_pair.second->getOdometry();
 
         // transfer processor vector blocks to problem state
-        for (const auto& pair_key_vec : prc_state)
+        for (auto pair_key_vec : prc_state)
         {
             if (odom_state.count(pair_key_vec.first) == 0) // Only write once. This gives priority to processors with more priority
                 odom_state.insert(pair_key_vec);
@@ -615,7 +596,7 @@ VectorComposite Problem::getOdometry(const StateStructure& _structure) const
     if (prior_options_ and prior_options_->mode != "nothing")
         state_last = prior_options_->state;
 
-    for (const auto& key : structure)
+    for (auto key : structure)
     {
         if (odom_state.count(key) == 0)
         {
@@ -644,7 +625,7 @@ const StateStructure& Problem::getFrameStructure() const
 
 void Problem::appendToStructure(const StateStructure& _structure)
 {
-    for (const auto& key : _structure)
+    for (auto key : _structure)
         if (frame_structure_.find(key) == std::string::npos) // now key not found in problem structure -> append!
             frame_structure_ += key;
 }
@@ -691,7 +672,7 @@ void Problem::removeMotionProvider(MotionProviderPtr proc)
 
     // rebuild frame structure with remaining motion processors
     frame_structure_.clear();
-    for (const auto& pm : motion_provider_map_)
+    for (auto pm : motion_provider_map_)
         appendToStructure(pm.second->getStateStructure());
 }
 
@@ -700,7 +681,7 @@ VectorComposite Problem::stateZero ( const StateStructure& _structure ) const
     StateStructure structure = (_structure == "" ? getFrameStructure() : _structure);
 
     VectorComposite state;
-    for (const auto& key : structure)
+    for (auto key : structure)
     {
         VectorXd vec;
         if (key == 'O')
@@ -958,10 +939,10 @@ bool Problem::getFrameCovariance(FrameBaseConstPtr _frame_ptr, Eigen::MatrixXd&
 
     // filling covariance
     int i = 0, j = 0;
-    for (const auto& sb_i : _frame_ptr->getStateBlockVec())
+    for (auto sb_i : _frame_ptr->getStateBlockVec())
     {
         j = 0;
-        for (const auto& sb_j : _frame_ptr->getStateBlockVec())
+        for (auto sb_j : _frame_ptr->getStateBlockVec())
         {
             success = success && getCovarianceBlock(sb_i, sb_j, _covariance, i, j);
             j += sb_j->getLocalSize();
@@ -988,10 +969,10 @@ bool Problem::getLandmarkCovariance(LandmarkBaseConstPtr _landmark_ptr, Eigen::M
 
     // filling covariance
     int i = 0, j = 0;
-    for (const auto& sb_i : _landmark_ptr->getStateBlockVec())
+    for (auto sb_i : _landmark_ptr->getStateBlockVec())
     {
         j = 0;
-        for (const auto& sb_j : _landmark_ptr->getStateBlockVec())
+        for (auto sb_j : _landmark_ptr->getStateBlockVec())
         {
             success = success && getCovarianceBlock(sb_i, sb_j, _covariance, i, j);
             j += sb_j->getLocalSize();
@@ -1127,10 +1108,10 @@ FrameBasePtr Problem::applyPriorOptions(const TimeStamp& _ts)
             auto prior_cap = CaptureBase::emplace<CaptureVoid>(prior_keyframe, _ts, nullptr);
 
             // Emplace a feature and a factor for each state block
-            for (const auto& pair_key_sb : prior_keyframe->getStateBlockMap())
+            for (auto pair_key_sb : prior_keyframe->getStateBlockMap())
             {
-                const auto& key = pair_key_sb.first;
-                const auto& sb  = pair_key_sb.second;
+                auto key = pair_key_sb.first;
+                auto sb  = pair_key_sb.second;
 
                 const auto& state_blk = prior_options_->state.at(key);
                 const auto& covar_blk = prior_options_->cov.at(key,key);
@@ -1268,11 +1249,11 @@ bool Problem::check(int _verbose_level) const
 void Problem::perturb(double amplitude)
 {
     // Sensors
-    for (auto& S : getHardware()->getSensorList())
+    for (auto S : getHardware()->getSensorList())
         S->perturb(amplitude);
 
     // Frames and Captures
-    for (auto& F : getTrajectory()->getFrameMap())
+    for (auto F : getTrajectory()->getFrameMap())
     {
         F.second->perturb(amplitude);
         for (auto& C : F.second->getCaptureList())
@@ -1280,7 +1261,7 @@ void Problem::perturb(double amplitude)
     }
 
     // Landmarks
-    for (auto& L : getMap()->getLandmarkList())
+    for (auto L : getMap()->getLandmarkList())
         L->perturb(amplitude);
 }
 
diff --git a/src/processor/processor_loop_closure.cpp b/src/processor/processor_loop_closure.cpp
index 2c8e16ce6..288fbcfd2 100644
--- a/src/processor/processor_loop_closure.cpp
+++ b/src/processor/processor_loop_closure.cpp
@@ -159,7 +159,7 @@ void ProcessorLoopClosure::process(CaptureBasePtr _capture)
 
         // Emplace factors for each LC if validated
         auto n_loops = 0;
-        for (const auto& match_pair : match_lc_map)
+        for (auto match_pair : match_lc_map)
             if (validateLoopClosure(match_pair.second))
             {
                 emplaceFactors(match_pair.second);
diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp
index ef4b1ea19..0ad4a754d 100644
--- a/src/processor/processor_motion.cpp
+++ b/src/processor/processor_motion.cpp
@@ -418,7 +418,7 @@ void ProcessorMotion::processCapture(CaptureBasePtr _incoming_ptr)
 
 
     // Update state and time stamps
-    const auto& ts = getTimeStamp();
+    auto ts = getTimeStamp();
     last_ptr_->setTimeStamp( ts );
     last_ptr_->getFrame()->setTimeStamp( ts );
     VectorComposite state_propa = getState( ts );
@@ -552,7 +552,7 @@ VectorComposite ProcessorMotion::getState(const StateStructure& _structure) cons
      */
 
     // Get state of origin
-    const auto& x_origin = getOrigin()->getFrame()->getState(state_structure_);
+    auto x_origin = getOrigin()->getFrame()->getState(state_structure_);
 
     // Get most recent motion
     const auto& motion = last_ptr_->getBuffer().back();
@@ -561,7 +561,7 @@ VectorComposite ProcessorMotion::getState(const StateStructure& _structure) cons
     const auto& delta_preint = motion.delta_integr_;
 
     // Get calibration preint -- stored in last capture
-    const auto& calib_preint = last_ptr_->getCalibrationPreint();
+    auto calib_preint = last_ptr_->getCalibrationPreint();
 
     VectorComposite state;
     //WOLF_INFO("processorMotion last timestamp: ", last_ptr_->getTimeStamp());
@@ -569,7 +569,7 @@ VectorComposite ProcessorMotion::getState(const StateStructure& _structure) cons
     if ( hasCalibration())
     {
         // Get current calibration -- from origin capture
-        const auto& calib = getCalibration(origin_ptr_);
+        auto calib = getCalibration(origin_ptr_);
 
         // get Jacobian of delta wrt calibration
         const auto& J_delta_calib = motion.jacobian_calib_;
@@ -578,7 +578,7 @@ VectorComposite ProcessorMotion::getState(const StateStructure& _structure) cons
         const auto& delta_step = J_delta_calib * (calib - calib_preint);
 
         // correct delta // this is (+)
-        const auto& delta_corrected = correctDelta(delta_preint, delta_step);
+        auto delta_corrected = correctDelta(delta_preint, delta_step);
 
         // compute current state // this is [+]
         statePlusDelta(x_origin, delta_corrected, last_ptr_->getTimeStamp() - origin_ptr_->getTimeStamp(), state);
@@ -651,7 +651,7 @@ VectorComposite ProcessorMotion::getState(const TimeStamp& _ts, const StateStruc
 
         // Get state of origin
         auto cap_orig   = capture_motion->getOriginCapture();
-        const auto& x_origin = cap_orig->getFrame()->getState(state_structure_);
+        auto x_origin = cap_orig->getFrame()->getState(state_structure_);
 
         // Get motion at time stamp
         const auto& motion = capture_motion->getBuffer().getMotion(_ts);
@@ -660,14 +660,14 @@ VectorComposite ProcessorMotion::getState(const TimeStamp& _ts, const StateStruc
         const auto& delta_preint = motion.delta_integr_;
 
         // Get calibration preint -- stored in last capture
-        const auto& calib_preint = capture_motion->getCalibrationPreint();
+        auto calib_preint = capture_motion->getCalibrationPreint();
 
         VectorComposite state;
 
         if ( hasCalibration() )
         {
             // Get current calibration -- from origin capture
-            const auto& calib = getCalibration(cap_orig);
+            auto calib = getCalibration(cap_orig);
 
             // get Jacobian of delta wrt calibration
             const auto& J_delta_calib = motion.jacobian_calib_;
@@ -676,7 +676,7 @@ VectorComposite ProcessorMotion::getState(const TimeStamp& _ts, const StateStruc
             const auto& delta_step = J_delta_calib * (calib - calib_preint);
 
             // correct delta // this is (+)
-            const auto& delta_corrected = correctDelta(delta_preint, delta_step);
+            auto delta_corrected = correctDelta(delta_preint, delta_step);
 
             // compute current state // this is [+]
             statePlusDelta(x_origin, delta_corrected, _ts - cap_orig->getTimeStamp(), state);
diff --git a/src/sensor/sensor_base.cpp b/src/sensor/sensor_base.cpp
index 1958a8615..93abd7bfc 100644
--- a/src/sensor/sensor_base.cpp
+++ b/src/sensor/sensor_base.cpp
@@ -104,7 +104,7 @@ SensorBase::~SensorBase()
 
 void SensorBase::fixExtrinsics()
 {
-    for (const auto& key : std::string("PO"))
+    for (auto key : std::string("PO"))
     {
         auto sbp = getStateBlockDynamic(key);
         if (sbp != nullptr)
@@ -114,7 +114,7 @@ void SensorBase::fixExtrinsics()
 
 void SensorBase::unfixExtrinsics()
 {
-    for (const auto& key : std::string("PO"))
+    for (auto key : std::string("PO"))
     {
         auto sbp = getStateBlockDynamic(key);
         if (sbp != nullptr)
@@ -124,7 +124,7 @@ void SensorBase::unfixExtrinsics()
 
 void SensorBase::fixIntrinsics()
 {
-    for (const auto& key : getStructure())
+    for (auto key : getStructure())
     {
         if (key != 'P' and key != 'O') // exclude extrinsics
         {
@@ -137,7 +137,7 @@ void SensorBase::fixIntrinsics()
 
 void SensorBase::unfixIntrinsics()
 {
-    for (const auto& key : getStructure())
+    for (auto key : getStructure())
     {
         if (key != 'P' and key != 'O') // exclude extrinsics
         {
@@ -539,7 +539,7 @@ void SensorBase::printState (bool _metric, bool _state_blocks, std::ostream& _st
 {
     if (_metric && _state_blocks)
     {
-        for (const auto &key : getStructure())
+        for (auto key : getStructure())
         {
             auto sb = getStateBlockDynamic(key);
             if (sb)
@@ -555,9 +555,9 @@ void SensorBase::printState (bool _metric, bool _state_blocks, std::ostream& _st
     else if (_state_blocks)
     {
         _stream << _tabs << "  " << "sb:";
-        for (const auto &key : getStructure())
+        for (auto key : getStructure())
         {
-            const auto &sb = getStateBlockDynamic(key);
+            auto sb = getStateBlockDynamic(key);
             if (sb)
                 _stream << "    " << key << " [" << (sb->isFixed() ? "Fix" : "Est") << "] @ " << sb;
         }
diff --git a/src/solver/solver_manager.cpp b/src/solver/solver_manager.cpp
index e0168dd1b..c9d192a53 100644
--- a/src/solver/solver_manager.cpp
+++ b/src/solver/solver_manager.cpp
@@ -250,7 +250,7 @@ void SolverManager::addFactor(const FactorBasePtr& fac_ptr)
      *
      * Notification is put back on problem notifications, it will be added next update() call.
      */
-    for (const auto& st : fac_ptr->getStateBlockPtrVector())
+    for (auto st : fac_ptr->getStateBlockPtrVector())
         if (state_blocks_.count(st) == 0)
         {
             // Check if it was stored as a 'floating' state block
@@ -273,7 +273,7 @@ void SolverManager::addFactor(const FactorBasePtr& fac_ptr)
     factors_.insert(fac_ptr);
 
     // state-factor map
-    for (const auto& st : fac_ptr->getStateBlockPtrVector())
+    for (auto st : fac_ptr->getStateBlockPtrVector())
     {
         assert(state_blocks_.count(st) != 0 && "SolverManager::addFactor before adding any involved state block");
         assert(state_blocks_2_factors_.count(st) != 0 && "SolverManager::addFactor before adding any involved state block");
@@ -300,7 +300,7 @@ void SolverManager::removeFactor(const FactorBasePtr& fac_ptr)
     factors_.erase(fac_ptr);
 
     // state-factor map
-    for (const auto& st : fac_ptr->getStateBlockPtrVector())
+    for (auto st : fac_ptr->getStateBlockPtrVector())
     {
         assert(state_blocks_.count(st) != 0 && "SolverManager::removeFactor missing any involved state block");
         assert(state_blocks_2_factors_.count(st) != 0 && "SolverManager::removeFactor missing any involved state block");
diff --git a/src/solver_suitesparse/solver_manager.cpp b/src/solver_suitesparse/solver_manager.cpp
index 0f4d82837..84f6f7468 100644
--- a/src/solver_suitesparse/solver_manager.cpp
+++ b/src/solver_suitesparse/solver_manager.cpp
@@ -19,7 +19,7 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 //--------LICENSE_END--------
-#include "../../include/core/ceres_wrapper/solver_ceres.h"
+#include "core/ceres_wrapper/solver_ceres.h"
 
 SolverManager::SolverManager()
 {
@@ -49,14 +49,14 @@ void SolverManager::update(const WolfProblemPtr _problem_ptr)
 	}
 	else
 	{
-		// ADD/UPDATE STATE UNITS
-		for(auto state_unit_it = _problem_ptr->getStateList().begin(); state_unit_it!=_problem_ptr->getStateList().end(); state_unit_it++)
+		// ADD/UPDATE STATE BLOKS
+		for(auto state_block : _problem_ptr->getStateList())
 		{
-			if ((*state_unit_it)->getPendingStatus() == ADD_PENDING)
-				addStateUnit(*state_unit_it);
+			if (state_block->getPendingStatus() == ADD_PENDING)
+				addStateUnit(state_block);
 
-			else if((*state_unit_it)->getPendingStatus() == UPDATE_PENDING)
-				updateStateUnitStatus(*state_unit_it);
+			else if(state_block->getPendingStatus() == UPDATE_PENDING)
+				updateStateUnitStatus(state_block);
 		}
 		//std::cout << "state units updated!" << std::endl;
 
diff --git a/src/state_block/has_state_blocks.cpp b/src/state_block/has_state_blocks.cpp
index 350479924..047469dc8 100644
--- a/src/state_block/has_state_blocks.cpp
+++ b/src/state_block/has_state_blocks.cpp
@@ -80,7 +80,7 @@ void HasStateBlocks::printState (bool _metric, bool _state_blocks, std::ostream&
 {
     if (_metric && _state_blocks)
     {
-        for (const auto &key : getStructure())
+        for (auto key : getStructure())
         {
             auto sb = getStateBlock(key);
             if (sb)
@@ -99,9 +99,9 @@ void HasStateBlocks::printState (bool _metric, bool _state_blocks, std::ostream&
     else if (_state_blocks)
     {
         _stream << _tabs << "  " << "sb:";
-        for (const auto &key : getStructure())
+        for (auto key : getStructure())
         {
-            const auto &sb = getStateBlock(key);
+            auto sb = getStateBlock(key);
             if (sb)
                 _stream << "    " << key
                         << " [" << (sb->isFixed() ? "Fix" : "Est")
diff --git a/src/state_block/state_composite.cpp b/src/state_block/state_composite.cpp
index 9f3e729ea..ff1888db0 100644
--- a/src/state_block/state_composite.cpp
+++ b/src/state_block/state_composite.cpp
@@ -200,11 +200,11 @@ bool MatrixComposite::emplace(const char &_row, const char &_col, const Eigen::M
 
 bool MatrixComposite::at(const char &_row, const char &_col, Eigen::MatrixXd &_mat_blk) const
 {
-    const auto &row_it = this->find(_row);
+    auto row_it = this->find(_row);
     if(row_it != this->end())
         return false;
 
-    const auto &col_it = row_it->second.find(_col);
+    auto col_it = row_it->second.find(_col);
     if(col_it != row_it->second.end())
         return false;
 
@@ -215,10 +215,10 @@ bool MatrixComposite::at(const char &_row, const char &_col, Eigen::MatrixXd &_m
 
 Eigen::MatrixXd& MatrixComposite::at(const char &_row, const char &_col)
 {
-    const auto &row_it = this->find(_row);
+    auto row_it = this->find(_row);
     assert(row_it != this->end() && "Requested matrix block does not exist in matrix composite.");
 
-    const auto &col_it = row_it->second.find(_col);
+    auto col_it = row_it->second.find(_col);
     assert(col_it != row_it->second.end() && "Requested matrix block does not exist in matrix composite.");
 
     return col_it->second;
@@ -226,10 +226,10 @@ Eigen::MatrixXd& MatrixComposite::at(const char &_row, const char &_col)
 
 const Eigen::MatrixXd& MatrixComposite::at(const char &_row, const char &_col) const
 {
-    const auto &row_it = this->find(_row);
+    auto row_it = this->find(_row);
     assert(row_it != this->end() && "Requested matrix block does not exist in matrix composite.");
 
-    const auto &col_it = row_it->second.find(_col);
+    auto col_it = row_it->second.find(_col);
     assert(col_it != row_it->second.end() && "Requested matrix block does not exist in matrix composite.");
 
     return col_it->second;
diff --git a/src/utils/graph_search.cpp b/src/utils/graph_search.cpp
index 20dc65e0e..85d1b3f52 100644
--- a/src/utils/graph_search.cpp
+++ b/src/utils/graph_search.cpp
@@ -96,7 +96,7 @@ std::set<FrameBasePtr> GraphSearch::getNeighborFrames(const std::set<FrameBasePt
         FactorBasePtrList facs_by = frm->getConstrainedByList();
 
         // Iterate over all factors_by
-        for (auto && fac_by : facs_by)
+        for (auto fac_by : facs_by)
         {
             //WOLF_INFO_COND(fac_by, "fac_by: ", fac_by->id());
             //WOLF_INFO_COND(fac_by->getFrame(), "fac_by->getFrame(): ", fac_by->getFrame()->id());
@@ -115,7 +115,7 @@ std::set<FrameBasePtr> GraphSearch::getNeighborFrames(const std::set<FrameBasePt
         frm->getFactorList(facs_own);
 
         // Iterate over all factors_own
-        for (auto && fac_own : facs_own)
+        for (auto fac_own : facs_own)
         {
             //WOLF_INFO_COND(fac_own, "fac_own: ", fac_own->id());
             //WOLF_INFO_COND(fac_own->getFrameOtherList().empty(), "fac_own->getFrameOtherList() is empty");
diff --git a/test/gtest_problem.cpp b/test/gtest_problem.cpp
index ffecd322b..fa4c1807c 100644
--- a/test/gtest_problem.cpp
+++ b/test/gtest_problem.cpp
@@ -144,8 +144,9 @@ TEST(Problem, SetOrigin_PO_2d)
     TrajectoryBasePtr T = P->getTrajectory();
     FrameBasePtr F = P->getLastFrame();
     CaptureBasePtr C = F->getCaptureList().front();
-    FeatureBasePtr fo = (*std::find_if(C->getFeatureList().begin(), C->getFeatureList().end(), [](FeatureBasePtr ftr){ return ftr->getType() == "Prior O";}));
-    FeatureBasePtr fp = (*std::find_if(C->getFeatureList().begin(), C->getFeatureList().end(), [](FeatureBasePtr ftr){ return ftr->getType() == "Prior P";}));
+    auto feature_list = C->getFeatureList();
+    FeatureBasePtr fo = (*std::find_if(feature_list.begin(), feature_list.end(), [](FeatureBasePtr ftr){ return ftr->getType() == "Prior O";}));
+    FeatureBasePtr fp = (*std::find_if(feature_list.begin(), feature_list.end(), [](FeatureBasePtr ftr){ return ftr->getType() == "Prior P";}));
     FactorBasePtrList fac_list;
     F->getFactorList(fac_list);
 
@@ -201,10 +202,9 @@ TEST(Problem, SetOrigin_PO_3d)
     TrajectoryBasePtr T = P->getTrajectory();
     FrameBasePtr F = P->getLastFrame();
     CaptureBasePtr C = F->getCaptureList().front();
-    // FeatureBasePtr fo = C->getFeatureList().front();
-    // FeatureBasePtr fp = C->getFeatureList().back();
-    FeatureBasePtr fo = (*std::find_if(C->getFeatureList().begin(), C->getFeatureList().end(), [](FeatureBasePtr ftr){ return ftr->getType() == "Prior O";}));
-    FeatureBasePtr fp = (*std::find_if(C->getFeatureList().begin(), C->getFeatureList().end(), [](FeatureBasePtr ftr){ return ftr->getType() == "Prior P";}));
+    auto feature_list = C->getFeatureList();
+    FeatureBasePtr fo = (*std::find_if(feature_list.begin(), feature_list.end(), [](FeatureBasePtr ftr){ return ftr->getType() == "Prior O";}));
+    FeatureBasePtr fp = (*std::find_if(feature_list.begin(), feature_list.end(), [](FeatureBasePtr ftr){ return ftr->getType() == "Prior P";}));
     FactorBasePtrList fac_list;
     F->getFactorList(fac_list);
 
diff --git a/test/gtest_processor_tracker_feature_dummy.cpp b/test/gtest_processor_tracker_feature_dummy.cpp
index 7a142212a..b1dbdfee8 100644
--- a/test/gtest_processor_tracker_feature_dummy.cpp
+++ b/test/gtest_processor_tracker_feature_dummy.cpp
@@ -74,15 +74,17 @@ class ProcessorTrackerFeatureDummyDummy : public ProcessorTrackerFeatureDummy
 
 bool isFeatureLinked(FeatureBasePtr ftr, CaptureBasePtr cap)
 {
+    auto feature_list = cap->getFeatureList();
     return ftr->getCapture() == cap &&
-           std::find(cap->getFeatureList().begin(), cap->getFeatureList().end(), ftr) != cap->getFeatureList().end();
+           std::find(feature_list.begin(), feature_list.end(), ftr) != feature_list.end();
 
 }
 
 bool isFactorLinked(FactorBasePtr fac, FeatureBasePtr ftr)
 {
+    auto factor_list = ftr->getFactorList();
     return fac->getFeature() == ftr &&
-           std::find(ftr->getFactorList().begin(), ftr->getFactorList().end(), fac) != ftr->getFactorList().end();
+           std::find(factor_list.begin(), factor_list.end(), fac) != factor_list.end();
 
 }
 
@@ -249,7 +251,7 @@ TEST_F(ProcessorTrackerFeatureDummyTest, emplaceFactor)
     ASSERT_EQ(fac->getCaptureOther(),nullptr);
     ASSERT_EQ(fac->getFeatureOther(),ftr_other);
     ASSERT_EQ(fac->getLandmarkOther(),nullptr);
-    ASSERT_TRUE(std::find(ftr_other->getConstrainedByList().begin(),ftr_other->getConstrainedByList().end(), fac) != ftr_other->getConstrainedByList().end());
+    ASSERT_TRUE(ftr_other->isConstrainedBy(fac));
 }
 
 TEST_F(ProcessorTrackerFeatureDummyTest, establishFactors)
diff --git a/test/gtest_processor_tracker_landmark_dummy.cpp b/test/gtest_processor_tracker_landmark_dummy.cpp
index 8017ad604..4ed3c0846 100644
--- a/test/gtest_processor_tracker_landmark_dummy.cpp
+++ b/test/gtest_processor_tracker_landmark_dummy.cpp
@@ -85,22 +85,25 @@ class ProcessorTrackerLandmarkDummyDummy : public ProcessorTrackerLandmarkDummy
 
 bool isFeatureLinked(FeatureBasePtr ftr, CaptureBasePtr cap)
 {
+    auto feature_list = cap->getFeatureList();
     return ftr->getCapture() == cap &&
-           std::find(cap->getFeatureList().begin(), cap->getFeatureList().end(), ftr) != cap->getFeatureList().end();
+           std::find(feature_list.begin(), feature_list.end(), ftr) != feature_list.end();
 
 }
 
 bool isFactorLinked(FactorBasePtr fac, FeatureBasePtr ftr)
 {
+    auto factor_list = ftr->getFactorList();
     return fac->getFeature() == ftr &&
-           std::find(ftr->getFactorList().begin(), ftr->getFactorList().end(), fac) != ftr->getFactorList().end();
+           std::find(factor_list.begin(), factor_list.end(), fac) != factor_list.end();
 
 }
 
 bool isLandmarkLinked(LandmarkBasePtr lmk, MapBasePtr map)
 {
+    auto landmark_list = map->getLandmarkList();
     return lmk->getMap() == map &&
-           std::find(map->getLandmarkList().begin(), map->getLandmarkList().end(), lmk) != map->getLandmarkList().end();
+           std::find(landmark_list.begin(), landmark_list.end(), lmk) != landmark_list.end();
 
 }
 
-- 
GitLab