diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index 77d4387..14b6fb6 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -14,36 +14,37 @@
 // limitations under the License.
 */
 
-#include <Utils.hpp>
+#include "filesystem.hpp"
+
 #include <Overlay.hpp>
-#include <nlohmann/json.hpp>
-#include <fstream>
-#include <regex>
-#include <iostream>
-#include <sdbusplus/asio/connection.hpp>
-#include <sdbusplus/asio/object_server.hpp>
+#include <Utils.hpp>
+#include <VariantVisitors.hpp>
 #include <boost/algorithm/string/case_conv.hpp>
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/algorithm/string/replace.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/container/flat_map.hpp>
 #include <boost/container/flat_set.hpp>
-#include <VariantVisitors.hpp>
-#include "filesystem.hpp"
+#include <boost/lexical_cast.hpp>
+#include <fstream>
+#include <iostream>
+#include <nlohmann/json.hpp>
+#include <regex>
+#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/asio/object_server.hpp>
+#include <variant>
 
-constexpr const char *OUTPUT_DIR = "/var/configuration/";
-constexpr const char *configurationDirectory = PACKAGE_DIR "configurations";
-constexpr const char *schemaDirectory = PACKAGE_DIR "configurations/schemas";
-constexpr const char *globalSchema = "global.json";
-constexpr const char *TEMPLATE_CHAR = "$";
+constexpr const char* OUTPUT_DIR = "/var/configuration/";
+constexpr const char* configurationDirectory = PACKAGE_DIR "configurations";
+constexpr const char* schemaDirectory = PACKAGE_DIR "configurations/schemas";
+constexpr const char* globalSchema = "global.json";
+constexpr const char* TEMPLATE_CHAR = "$";
 constexpr const size_t PROPERTIES_CHANGED_UNTIL_FLUSH_COUNT = 20;
 constexpr const int32_t MAX_MAPPER_DEPTH = 0;
 constexpr const size_t SLEEP_AFTER_PROPERTIES_CHANGE_SECONDS = 5;
 
-namespace variant_ns = sdbusplus::message::variant_ns;
 struct cmp_str
 {
-    bool operator()(const char *a, const char *b) const
+    bool operator()(const char* a, const char* b) const
     {
         return std::strcmp(a, b) < 0;
     }
@@ -61,7 +62,7 @@
     FOUND,
     MATCH_ONE
 };
-const static boost::container::flat_map<const char *, probe_type_codes, cmp_str>
+const static boost::container::flat_map<const char*, probe_type_codes, cmp_str>
     PROBE_TYPES{{{"FALSE", probe_type_codes::FALSE_T},
                  {"TRUE", probe_type_codes::TRUE_T},
                  {"AND", probe_type_codes::AND},
@@ -69,15 +70,14 @@
                  {"FOUND", probe_type_codes::FOUND},
                  {"MATCH_ONE", probe_type_codes::MATCH_ONE}}};
 
-static constexpr std::array<const char *, 4> settableInterfaces = {
+static constexpr std::array<const char*, 4> settableInterfaces = {
     "Thresholds", "Pid", "Pid.Zone", "Stepwise"};
 using JsonVariantType =
-    sdbusplus::message::variant<std::vector<std::string>, std::string, int64_t,
-                                uint64_t, double, int32_t, uint32_t, int16_t,
-                                uint16_t, uint8_t, bool>;
+    std::variant<std::vector<std::string>, std::string, int64_t, uint64_t,
+                 double, int32_t, uint32_t, int16_t, uint16_t, uint8_t, bool>;
 using BasicVariantType =
-    sdbusplus::message::variant<std::string, int64_t, uint64_t, double, int32_t,
-                                uint32_t, int16_t, uint16_t, uint8_t, bool>;
+    std::variant<std::string, int64_t, uint64_t, double, int32_t, uint32_t,
+                 int16_t, uint16_t, uint8_t, bool>;
 
 using GetSubTreeType = std::vector<
     std::pair<std::string,
@@ -100,17 +100,17 @@
 
 const std::regex ILLEGAL_DBUS_REGEX("[^A-Za-z0-9_.]");
 
-void registerCallbacks(boost::asio::io_service &io,
-                       std::vector<sdbusplus::bus::match::match> &dbusMatches,
-                       nlohmann::json &systemConfiguration,
-                       sdbusplus::asio::object_server &objServer);
+void registerCallbacks(boost::asio::io_service& io,
+                       std::vector<sdbusplus::bus::match::match>& dbusMatches,
+                       nlohmann::json& systemConfiguration,
+                       sdbusplus::asio::object_server& objServer);
 
 // calls the mapper to find all exposed objects of an interface type
 // and creates a vector<flat_map> that contains all the key value pairs
 // getManagedObjects
 void findDbusObjects(std::shared_ptr<PerformProbe> probe,
                      std::shared_ptr<sdbusplus::asio::connection> connection,
-                     std::string &interface)
+                     std::string& interface)
 {
 
     // store reference to pending callbacks so we don't overwhelm services
@@ -125,8 +125,8 @@
 
     // add shared_ptr to vector of Probes waiting for callback from a specific
     // interface to keep alive while waiting for response
-    std::array<const char *, 1> objects = {interface.c_str()};
-    std::vector<std::shared_ptr<PerformProbe>> &pending =
+    std::array<const char*, 1> objects = {interface.c_str()};
+    std::vector<std::shared_ptr<PerformProbe>>& pending =
         pendingProbes[interface];
     auto iter = pending.emplace(pending.end(), probe);
     // only allow first call to run to not overwhelm processes
@@ -137,8 +137,8 @@
 
     // find all connections in the mapper that expose a specific type
     connection->async_method_call(
-        [connection, interface, probe](boost::system::error_code &ec,
-                                       const GetSubTreeType &interfaceSubtree) {
+        [connection, interface, probe](boost::system::error_code& ec,
+                                       const GetSubTreeType& interfaceSubtree) {
             boost::container::flat_set<std::string> interfaceConnections;
             if (ec)
             {
@@ -154,9 +154,9 @@
             }
             else
             {
-                for (auto &object : interfaceSubtree)
+                for (auto& object : interfaceSubtree)
                 {
-                    for (auto &connPair : object.second)
+                    for (auto& connPair : object.second)
                     {
                         auto insertPair =
                             interfaceConnections.insert(connPair.first);
@@ -169,12 +169,12 @@
                 return;
             }
             // get managed objects for all interfaces
-            for (const auto &conn : interfaceConnections)
+            for (const auto& conn : interfaceConnections)
             {
                 connection->async_method_call(
                     [conn,
-                     interface](boost::system::error_code &ec,
-                                const ManagedObjectType &managedInterface) {
+                     interface](boost::system::error_code& ec,
+                                const ManagedObjectType& managedInterface) {
                         if (ec)
                         {
                             std::cerr
@@ -183,7 +183,7 @@
                             pendingProbes[interface].clear();
                             return;
                         }
-                        for (auto &interfaceManagedObj : managedInterface)
+                        for (auto& interfaceManagedObj : managedInterface)
                         {
                             auto ifaceObjFind =
                                 interfaceManagedObj.second.find(interface);
@@ -191,8 +191,8 @@
                                 interfaceManagedObj.second.end())
                             {
                                 std::vector<boost::container::flat_map<
-                                    std::string, BasicVariantType>>
-                                    &dbusObject = DBUS_PROBE_OBJECTS[interface];
+                                    std::string, BasicVariantType>>&
+                                    dbusObject = DBUS_PROBE_OBJECTS[interface];
                                 dbusObject.emplace_back(ifaceObjFind->second);
                             }
                         }
@@ -209,14 +209,14 @@
 }
 // probes dbus interface dictionary for a key with a value that matches a regex
 bool probeDbus(
-    const std::string &interface,
-    const std::map<std::string, nlohmann::json> &matches,
-    std::vector<boost::container::flat_map<std::string, BasicVariantType>>
-        &devices,
-    bool &foundProbe)
+    const std::string& interface,
+    const std::map<std::string, nlohmann::json>& matches,
+    std::vector<boost::container::flat_map<std::string, BasicVariantType>>&
+        devices,
+    bool& foundProbe)
 {
-    std::vector<boost::container::flat_map<std::string, BasicVariantType>>
-        &dbusObject = DBUS_PROBE_OBJECTS[interface];
+    std::vector<boost::container::flat_map<std::string, BasicVariantType>>&
+        dbusObject = DBUS_PROBE_OBJECTS[interface];
     if (dbusObject.empty())
     {
         foundProbe = false;
@@ -225,10 +225,10 @@
     foundProbe = true;
 
     bool foundMatch = false;
-    for (auto &device : dbusObject)
+    for (auto& device : dbusObject)
     {
         bool deviceMatches = true;
-        for (auto &match : matches)
+        for (auto& match : matches)
         {
             auto deviceValue = device.find(match.first);
             if (deviceValue != device.end())
@@ -241,7 +241,7 @@
                         std::smatch match;
 
                         // convert value to string respresentation
-                        std::string probeValue = variant_ns::visit(
+                        std::string probeValue = std::visit(
                             VariantToStringVisitor(), deviceValue->second);
                         if (!std::regex_search(probeValue, match, search))
                         {
@@ -253,7 +253,7 @@
                     case nlohmann::json::value_t::boolean:
                     case nlohmann::json::value_t::number_unsigned:
                     {
-                        unsigned int probeValue = variant_ns::visit(
+                        unsigned int probeValue = std::visit(
                             VariantToUnsignedIntVisitor(), deviceValue->second);
 
                         if (probeValue != match.second.get<unsigned int>())
@@ -264,8 +264,8 @@
                     }
                     case nlohmann::json::value_t::number_integer:
                     {
-                        int probeValue = variant_ns::visit(
-                            VariantToIntVisitor(), deviceValue->second);
+                        int probeValue = std::visit(VariantToIntVisitor(),
+                                                    deviceValue->second);
 
                         if (probeValue != match.second.get<int>())
                         {
@@ -275,8 +275,8 @@
                     }
                     case nlohmann::json::value_t::number_float:
                     {
-                        float probeValue = variant_ns::visit(
-                            VariantToFloatVisitor(), deviceValue->second);
+                        float probeValue = std::visit(VariantToFloatVisitor(),
+                                                      deviceValue->second);
 
                         if (probeValue != match.second.get<float>())
                         {
@@ -307,9 +307,9 @@
 // default probe entry point, iterates a list looking for specific types to
 // call specific probe functions
 bool probe(
-    const std::vector<std::string> &probeCommand,
-    std::vector<boost::container::flat_map<std::string, BasicVariantType>>
-        &foundDevs)
+    const std::vector<std::string>& probeCommand,
+    std::vector<boost::container::flat_map<std::string, BasicVariantType>>&
+        foundDevs)
 {
     const static std::regex command(R"(\((.*)\))");
     std::smatch match;
@@ -318,10 +318,10 @@
     bool cur = true;
     probe_type_codes lastCommand = probe_type_codes::FALSE_T;
 
-    for (auto &probe : probeCommand)
+    for (auto& probe : probeCommand)
     {
         bool foundProbe = false;
-        boost::container::flat_map<const char *, probe_type_codes,
+        boost::container::flat_map<const char*, probe_type_codes,
                                    cmp_str>::const_iterator probeType;
 
         for (probeType = PROBE_TYPES.begin(); probeType != PROBE_TYPES.end();
@@ -445,9 +445,9 @@
 {
 
     PerformProbe(
-        const std::vector<std::string> &probeCommand,
+        const std::vector<std::string>& probeCommand,
         std::function<void(std::vector<boost::container::flat_map<
-                               std::string, BasicVariantType>> &)> &&callback) :
+                               std::string, BasicVariantType>>&)>&& callback) :
         _probeCommand(probeCommand),
         _callback(std::move(callback))
     {
@@ -462,14 +462,14 @@
     void run()
     {
         // parse out dbus probes by discarding other probe types
-        boost::container::flat_map<const char *, probe_type_codes,
+        boost::container::flat_map<const char*, probe_type_codes,
                                    cmp_str>::const_iterator probeType;
 
         std::vector<std::string> dbusProbes;
-        for (std::string &probe : _probeCommand)
+        for (std::string& probe : _probeCommand)
         {
             bool found = false;
-            boost::container::flat_map<const char *, probe_type_codes,
+            boost::container::flat_map<const char*, probe_type_codes,
                                        cmp_str>::const_iterator probeType;
             for (probeType = PROBE_TYPES.begin();
                  probeType != PROBE_TYPES.end(); probeType++)
@@ -492,16 +492,15 @@
         }
     }
     std::vector<std::string> _probeCommand;
-    std::function<void(
-        std::vector<boost::container::flat_map<std::string, BasicVariantType>>
-            &)>
+    std::function<void(std::vector<boost::container::flat_map<
+                           std::string, BasicVariantType>>&)>
         _callback;
     std::vector<boost::container::flat_map<std::string, BasicVariantType>>
         _foundDevs;
 };
 
 // writes output files to persist data
-bool writeJsonFiles(const nlohmann::json &systemConfiguration)
+bool writeJsonFiles(const nlohmann::json& systemConfiguration)
 {
     std::filesystem::create_directory(OUTPUT_DIR);
     std::ofstream output(std::string(OUTPUT_DIR) + "system.json");
@@ -516,14 +515,14 @@
 
 // template function to add array as dbus property
 template <typename PropertyType>
-void addArrayToDbus(const std::string &name, const nlohmann::json &array,
-                    sdbusplus::asio::dbus_interface *iface,
+void addArrayToDbus(const std::string& name, const nlohmann::json& array,
+                    sdbusplus::asio::dbus_interface* iface,
                     sdbusplus::asio::PropertyPermission permission)
 {
     std::vector<PropertyType> values;
-    for (const auto &property : array)
+    for (const auto& property : array)
     {
-        auto ptr = property.get_ptr<const PropertyType *>();
+        auto ptr = property.get_ptr<const PropertyType*>();
         if (ptr != nullptr)
         {
             values.emplace_back(*ptr);
@@ -536,13 +535,13 @@
 }
 
 template <typename JsonType>
-bool setJsonFromPointer(const std::string &ptrStr, const JsonType &value,
-                        nlohmann::json &systemConfiguration)
+bool setJsonFromPointer(const std::string& ptrStr, const JsonType& value,
+                        nlohmann::json& systemConfiguration)
 {
     try
     {
         nlohmann::json::json_pointer ptr(ptrStr);
-        nlohmann::json &ref = systemConfiguration[ptr];
+        nlohmann::json& ref = systemConfiguration[ptr];
         ref = value;
         return true;
     }
@@ -553,10 +552,10 @@
 }
 
 template <typename PropertyType>
-void addProperty(const std::string &propertyName, const PropertyType &value,
-                 sdbusplus::asio::dbus_interface *iface,
-                 nlohmann::json &systemConfiguration,
-                 const std::string &jsonPointerString,
+void addProperty(const std::string& propertyName, const PropertyType& value,
+                 sdbusplus::asio::dbus_interface* iface,
+                 nlohmann::json& systemConfiguration,
+                 const std::string& jsonPointerString,
                  sdbusplus::asio::PropertyPermission permission)
 {
     if (permission == sdbusplus::asio::PropertyPermission::readOnly)
@@ -568,7 +567,7 @@
         propertyName, value,
         [&systemConfiguration,
          jsonPointerString{std::string(jsonPointerString)}](
-            const PropertyType &newVal, PropertyType &val) {
+            const PropertyType& newVal, PropertyType& val) {
             val = newVal;
             if (!setJsonFromPointer(jsonPointerString, val,
                                     systemConfiguration))
@@ -586,10 +585,10 @@
 }
 
 void createDeleteObjectMethod(
-    const std::string &jsonPointerPath,
-    const std::shared_ptr<sdbusplus::asio::dbus_interface> &iface,
-    sdbusplus::asio::object_server &objServer,
-    nlohmann::json &systemConfiguration)
+    const std::string& jsonPointerPath,
+    const std::shared_ptr<sdbusplus::asio::dbus_interface>& iface,
+    sdbusplus::asio::object_server& objServer,
+    nlohmann::json& systemConfiguration)
 {
     std::weak_ptr<sdbusplus::asio::dbus_interface> interface = iface;
     iface->register_method(
@@ -623,13 +622,13 @@
 
 // adds simple json types to interface's properties
 void populateInterfaceFromJson(
-    nlohmann::json &systemConfiguration, const std::string &jsonPointerPath,
-    std::shared_ptr<sdbusplus::asio::dbus_interface> &iface,
-    nlohmann::json &dict, sdbusplus::asio::object_server &objServer,
+    nlohmann::json& systemConfiguration, const std::string& jsonPointerPath,
+    std::shared_ptr<sdbusplus::asio::dbus_interface>& iface,
+    nlohmann::json& dict, sdbusplus::asio::object_server& objServer,
     sdbusplus::asio::PropertyPermission permission =
         sdbusplus::asio::PropertyPermission::readOnly)
 {
-    for (auto &dictPair : dict.items())
+    for (auto& dictPair : dict.items())
     {
         auto type = dictPair.value().type();
         bool array = false;
@@ -642,7 +641,7 @@
             }
             type = dictPair.value()[0].type();
             bool isLegal = true;
-            for (const auto &arrayItem : dictPair.value())
+            for (const auto& arrayItem : dictPair.value())
             {
                 if (arrayItem.type() != type)
                 {
@@ -765,7 +764,7 @@
     iface->initialize();
 }
 
-sdbusplus::asio::PropertyPermission getPermission(const std::string &interface)
+sdbusplus::asio::PropertyPermission getPermission(const std::string& interface)
 {
     return std::find(settableInterfaces.begin(), settableInterfaces.end(),
                      interface) != settableInterfaces.end()
@@ -773,10 +772,10 @@
                : sdbusplus::asio::PropertyPermission::readOnly;
 }
 
-void createAddObjectMethod(const std::string &jsonPointerPath,
-                           const std::string &path,
-                           nlohmann::json &systemConfiguration,
-                           sdbusplus::asio::object_server &objServer)
+void createAddObjectMethod(const std::string& jsonPointerPath,
+                           const std::string& path,
+                           nlohmann::json& systemConfiguration,
+                           sdbusplus::asio::object_server& objServer)
 {
     auto iface = objServer.add_interface(path, "xyz.openbmc_project.AddObject");
 
@@ -785,10 +784,10 @@
         [&systemConfiguration, &objServer,
          jsonPointerPath{std::string(jsonPointerPath)},
          path{std::string(path)}](
-            const boost::container::flat_map<std::string, JsonVariantType>
-                &data) {
+            const boost::container::flat_map<std::string, JsonVariantType>&
+                data) {
             nlohmann::json::json_pointer ptr(jsonPointerPath);
-            nlohmann::json &base = systemConfiguration[ptr];
+            nlohmann::json& base = systemConfiguration[ptr];
             auto findExposes = base.find("Exposes");
 
             if (findExposes == base.end())
@@ -798,12 +797,11 @@
 
             // this will throw invalid-argument to sdbusplus if invalid json
             nlohmann::json newData{};
-            for (const auto &item : data)
+            for (const auto& item : data)
             {
-                nlohmann::json &newJson = newData[item.first];
-                variant_ns::visit(
-                    [&newJson](auto &&val) { newJson = std::move(val); },
-                    item.second);
+                nlohmann::json& newJson = newData[item.first];
+                std::visit([&newJson](auto&& val) { newJson = std::move(val); },
+                           item.second);
             }
 
             auto findName = newData.find("Name");
@@ -812,8 +810,8 @@
             {
                 throw std::invalid_argument("AddObject missing Name or Type");
             }
-            const std::string *type = findType->get_ptr<const std::string *>();
-            const std::string *name = findName->get_ptr<const std::string *>();
+            const std::string* type = findType->get_ptr<const std::string*>();
+            const std::string* name = findName->get_ptr<const std::string*>();
             if (type == nullptr || name == nullptr)
             {
                 throw std::invalid_argument("Type and Name must be a string.");
@@ -879,13 +877,13 @@
     iface->initialize();
 }
 
-void postToDbus(const nlohmann::json &newConfiguration,
-                nlohmann::json &systemConfiguration,
-                sdbusplus::asio::object_server &objServer)
+void postToDbus(const nlohmann::json& newConfiguration,
+                nlohmann::json& systemConfiguration,
+                sdbusplus::asio::object_server& objServer)
 
 {
     // iterate through boards
-    for (auto &boardPair : newConfiguration.items())
+    for (auto& boardPair : newConfiguration.items())
     {
         std::string boardKey = boardPair.key();
         std::vector<std::string> path;
@@ -928,7 +926,7 @@
                                   boardIface, boardValues, objServer);
         jsonPointerPath += "/";
         // iterate through board properties
-        for (auto &boardField : boardValues.items())
+        for (auto& boardField : boardValues.items())
         {
             if (boardField.value().type() == nlohmann::json::value_t::object)
             {
@@ -951,7 +949,7 @@
         // store the board level pointer so we can modify it on the way down
         std::string jsonPointerPathBoard = jsonPointerPath;
         size_t exposesIndex = -1;
-        for (auto &item : *exposes)
+        for (auto& item : *exposes)
         {
             exposesIndex++;
             jsonPointerPath = jsonPointerPathBoard;
@@ -996,7 +994,7 @@
                                       itemIface, item, objServer,
                                       getPermission(itemType));
 
-            for (auto &objectPair : item.items())
+            for (auto& objectPair : item.items())
             {
                 jsonPointerPath = jsonPointerPathBoard +
                                   std::to_string(exposesIndex) + "/" +
@@ -1029,7 +1027,7 @@
                     }
 
                     // verify legal json
-                    for (const auto &arrayItem : objectPair.value())
+                    for (const auto& arrayItem : objectPair.value())
                     {
                         if (arrayItem.type() != type)
                         {
@@ -1044,7 +1042,7 @@
                         break;
                     }
 
-                    for (auto &arrayItem : objectPair.value())
+                    for (auto& arrayItem : objectPair.value())
                     {
 
                         auto objectIface = objServer.add_interface(
@@ -1068,10 +1066,10 @@
 // the field found in a dbus object i.e. $ADDRESS would get populated with the
 // ADDRESS field from a object on dbus
 void templateCharReplace(
-    nlohmann::json::iterator &keyPair,
-    const boost::container::flat_map<std::string, BasicVariantType>
-        &foundDevice,
-    size_t &foundDeviceIdx)
+    nlohmann::json::iterator& keyPair,
+    const boost::container::flat_map<std::string, BasicVariantType>&
+        foundDevice,
+    size_t& foundDeviceIdx)
 {
     if (keyPair.value().type() == nlohmann::json::value_t::object)
     {
@@ -1102,13 +1100,12 @@
         else
         {
             bool found = false;
-            for (auto &foundDevicePair : foundDevice)
+            for (auto& foundDevicePair : foundDevice)
             {
                 if (boost::iequals(foundDevicePair.first, templateValue))
                 {
-                    variant_ns::visit(
-                        [&](auto &&val) { keyPair.value() = val; },
-                        foundDevicePair.second);
+                    std::visit([&](auto&& val) { keyPair.value() = val; },
+                               foundDevicePair.second);
                     found = true;
                     break;
                 }
@@ -1142,7 +1139,7 @@
 }
 
 // reads json files out of the filesystem
-bool findJsonFiles(std::list<nlohmann::json> &configurations)
+bool findJsonFiles(std::list<nlohmann::json>& configurations)
 {
     // find configuration files
     std::vector<std::filesystem::path> jsonPaths;
@@ -1172,7 +1169,7 @@
         return false;
     }
 
-    for (auto &jsonPath : jsonPaths)
+    for (auto& jsonPath : jsonPaths)
     {
         std::ifstream jsonStream(jsonPath.c_str());
         if (!jsonStream.good())
@@ -1198,7 +1195,7 @@
 
         if (data.type() == nlohmann::json::value_t::array)
         {
-            for (auto &d : data)
+            for (auto& d : data)
             {
                 configurations.emplace_back(d);
             }
@@ -1214,9 +1211,9 @@
 struct PerformScan : std::enable_shared_from_this<PerformScan>
 {
 
-    PerformScan(nlohmann::json &systemConfiguration,
-                std::list<nlohmann::json> &configurations,
-                std::function<void(void)> &&callback) :
+    PerformScan(nlohmann::json& systemConfiguration,
+                std::list<nlohmann::json>& configurations,
+                std::function<void(void)>&& callback) :
         _systemConfiguration(systemConfiguration),
         _configurations(configurations), _callback(std::move(callback))
     {
@@ -1262,7 +1259,7 @@
                 it = _configurations.erase(it);
                 continue;
             }
-            nlohmann::json *record = &(*it);
+            nlohmann::json* record = &(*it);
 
             // store reference to this to children to makes sure we don't get
             // destroyed too early
@@ -1271,7 +1268,7 @@
                 probeCommand,
                 [&, record, name,
                  thisRef](std::vector<boost::container::flat_map<
-                              std::string, BasicVariantType>> &foundDevices) {
+                              std::string, BasicVariantType>>& foundDevices) {
                     _passed = true;
 
                     PASSED_PROBES.push_back(name);
@@ -1281,7 +1278,7 @@
                     // reference ourselves
                     _systemConfiguration[name] = *record;
 
-                    for (auto &foundDevice : foundDevices)
+                    for (auto& foundDevice : foundDevices)
                     {
                         for (auto keyPair = record->begin();
                              keyPair != record->end(); keyPair++)
@@ -1294,7 +1291,7 @@
                         {
                             continue;
                         }
-                        for (auto &expose : *findExpose)
+                        for (auto& expose : *findExpose)
                         {
                             for (auto keyPair = expose.begin();
                                  keyPair != expose.end(); keyPair++)
@@ -1319,7 +1316,7 @@
                                     std::string bind = keyPair.key().substr(
                                         sizeof("Bind") - 1);
 
-                                    for (auto &configurationPair :
+                                    for (auto& configurationPair :
                                          _systemConfiguration.items())
                                     {
 
@@ -1335,7 +1332,7 @@
                                         {
                                             continue;
                                         }
-                                        for (auto &exposedObject :
+                                        for (auto& exposedObject :
                                              *configListFind)
                                         {
                                             std::string foundObjectName =
@@ -1390,7 +1387,7 @@
             _callback();
         }
     }
-    nlohmann::json &_systemConfiguration;
+    nlohmann::json& _systemConfiguration;
     std::list<nlohmann::json> _configurations;
     std::function<void(void)> _callback;
     std::vector<std::shared_ptr<PerformProbe>> _probes;
@@ -1399,16 +1396,16 @@
 
 // main properties changed entry
 void propertiesChangedCallback(
-    boost::asio::io_service &io,
-    std::vector<sdbusplus::bus::match::match> &dbusMatches,
-    nlohmann::json &systemConfiguration,
-    sdbusplus::asio::object_server &objServer)
+    boost::asio::io_service& io,
+    std::vector<sdbusplus::bus::match::match>& dbusMatches,
+    nlohmann::json& systemConfiguration,
+    sdbusplus::asio::object_server& objServer)
 {
     static boost::asio::deadline_timer timer(io);
     timer.expires_from_now(boost::posix_time::seconds(1));
 
     // setup an async wait as we normally get flooded with new requests
-    timer.async_wait([&](const boost::system::error_code &ec) {
+    timer.async_wait([&](const boost::system::error_code& ec) {
         if (ec == boost::asio::error::operation_aborted)
         {
             // we were cancelled
@@ -1467,14 +1464,14 @@
     });
 }
 
-void registerCallbacks(boost::asio::io_service &io,
-                       std::vector<sdbusplus::bus::match::match> &dbusMatches,
-                       nlohmann::json &systemConfiguration,
-                       sdbusplus::asio::object_server &objServer)
+void registerCallbacks(boost::asio::io_service& io,
+                       std::vector<sdbusplus::bus::match::match>& dbusMatches,
+                       nlohmann::json& systemConfiguration,
+                       sdbusplus::asio::object_server& objServer)
 {
     static boost::container::flat_set<std::string> watchedObjects;
 
-    for (const auto &objectMap : DBUS_PROBE_OBJECTS)
+    for (const auto& objectMap : DBUS_PROBE_OBJECTS)
     {
         auto findObject = watchedObjects.find(objectMap.first);
         if (findObject != watchedObjects.end())
@@ -1484,13 +1481,13 @@
         std::function<void(sdbusplus::message::message & message)>
             eventHandler =
 
-                [&](sdbusplus::message::message &) {
+                [&](sdbusplus::message::message&) {
                     propertiesChangedCallback(io, dbusMatches,
                                               systemConfiguration, objServer);
                 };
 
         sdbusplus::bus::match::match match(
-            static_cast<sdbusplus::bus::bus &>(*SYSTEM_BUS),
+            static_cast<sdbusplus::bus::bus&>(*SYSTEM_BUS),
             "type='signal',member='PropertiesChanged',arg0='" +
                 objectMap.first + "'",
             eventHandler);
@@ -1498,7 +1495,7 @@
     }
 }
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
     // setup connection to dbus
     boost::asio::io_service io;
@@ -1522,10 +1519,11 @@
     nlohmann::json systemConfiguration = nlohmann::json::object();
 
     inventoryIface->register_method(
-        "Notify", [](const boost::container::flat_map<
-                      std::string,
-                      boost::container::flat_map<std::string, BasicVariantType>>
-                         &object) { return; });
+        "Notify",
+        [](const boost::container::flat_map<
+            std::string,
+            boost::container::flat_map<std::string, BasicVariantType>>&
+               object) { return; });
     inventoryIface->initialize();
 
     io.post([&]() {
