diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
 IndentWrappedFunctionNames: true
 InsertNewlineAtEOF: true
 KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
 LineEnding: LF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
@@ -98,13 +98,14 @@
 ObjCSpaceBeforeProtocolList: true
 PackConstructorInitializers: BinPack
 PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
 PointerAlignment: Left
 QualifierAlignment: Left
 ReferenceAlignment: Left
diff --git a/src/main.cpp b/src/main.cpp
index 84c15e4..ff72874 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -89,8 +89,8 @@
         auto instancePos = fullUnitName.rfind("@");
         if (instancePos != std::string::npos)
         {
-            instanceName = fullUnitName.substr(instancePos + 1,
-                                               typePos - instancePos - 1);
+            instanceName =
+                fullUnitName.substr(instancePos + 1, typePos - instancePos - 1);
             unitName = fullUnitName.substr(0, instancePos);
         }
         else
@@ -101,11 +101,11 @@
     return std::make_tuple(unitName, type, instanceName);
 }
 
-static inline void
-    handleListUnitsResponse(sdbusplus::asio::object_server& server,
-                            std::shared_ptr<sdbusplus::asio::connection>& conn,
-                            boost::system::error_code /*ec*/,
-                            const std::vector<ListUnitsType>& listUnits)
+static inline void handleListUnitsResponse(
+    sdbusplus::asio::object_server& server,
+    std::shared_ptr<sdbusplus::asio::connection>& conn,
+    boost::system::error_code /*ec*/,
+    const std::vector<ListUnitsType>& listUnits)
 {
     // Loop through all units, and mark all units, which has to be
     // managed, irrespective of instance name.
@@ -261,14 +261,14 @@
     conn->async_method_call(
         [&server, &conn](boost::system::error_code ec,
                          const std::vector<ListUnitsType>& listUnits) {
-        if (ec)
-        {
-            lg2::error("async_method_call error: ListUnits failed: {EC}", "EC",
-                       ec.value());
-            return;
-        }
-        handleListUnitsResponse(server, conn, ec, listUnits);
-    },
+            if (ec)
+            {
+                lg2::error("async_method_call error: ListUnits failed: {EC}",
+                           "EC", ec.value());
+                return;
+            }
+            handleListUnitsResponse(server, conn, ec, listUnits);
+        },
         sysdService, sysdObjPath, sysdMgrIntf, "ListUnits");
 }
 
@@ -279,46 +279,46 @@
     conn->async_method_call(
         [&server, &conn](boost::system::error_code ec,
                          const std::variant<uint64_t>& value) {
-        if (ec)
-        {
-            lg2::error("async_method_call error: ListUnits failed: {EC}", "EC",
-                       ec.value());
-            return;
-        }
-        if (std::get<uint64_t>(value))
-        {
-            if (!unitQueryStarted)
+            if (ec)
             {
-                unitQueryStarted = true;
-                init(server, conn);
+                lg2::error("async_method_call error: ListUnits failed: {EC}",
+                           "EC", ec.value());
+                return;
             }
-        }
-        else
-        {
-            // FIX-ME: Latest up-stream sync caused issue in receiving
-            // StartupFinished signal. Unable to get StartupFinished signal
-            // from systemd1 hence using poll method too, to trigger it
-            // properly.
-            constexpr size_t pollTimeout = 10; // seconds
-            initTimer->expires_after(std::chrono::seconds(pollTimeout));
-            initTimer->async_wait(
-                [&server, &conn](const boost::system::error_code& ec) {
-                if (ec == boost::asio::error::operation_aborted)
+            if (std::get<uint64_t>(value))
+            {
+                if (!unitQueryStarted)
                 {
-                    // Timer reset.
-                    return;
+                    unitQueryStarted = true;
+                    init(server, conn);
                 }
-                if (ec)
-                {
-                    lg2::error(
-                        "service config mgr - init - async wait error: {EC}",
-                        "EC", ec.value());
-                    return;
-                }
-                checkAndInit(server, conn);
-            });
-        }
-    },
+            }
+            else
+            {
+                // FIX-ME: Latest up-stream sync caused issue in receiving
+                // StartupFinished signal. Unable to get StartupFinished signal
+                // from systemd1 hence using poll method too, to trigger it
+                // properly.
+                constexpr size_t pollTimeout = 10; // seconds
+                initTimer->expires_after(std::chrono::seconds(pollTimeout));
+                initTimer->async_wait([&server, &conn](
+                                          const boost::system::error_code& ec) {
+                    if (ec == boost::asio::error::operation_aborted)
+                    {
+                        // Timer reset.
+                        return;
+                    }
+                    if (ec)
+                    {
+                        lg2::error(
+                            "service config mgr - init - async wait error: {EC}",
+                            "EC", ec.value());
+                        return;
+                    }
+                    checkAndInit(server, conn);
+                });
+            }
+        },
         sysdService, sysdObjPath, dBusPropIntf, dBusGetMethod, sysdMgrIntf,
         "FinishTimestamp");
 }
@@ -339,12 +339,12 @@
         "member='StartupFinished',path='/org/freedesktop/systemd1',"
         "interface='org.freedesktop.systemd1.Manager'",
         [&server, &conn](sdbusplus::message_t& /*msg*/) {
-        if (!unitQueryStarted)
-        {
-            unitQueryStarted = true;
-            init(server, conn);
-        }
-    });
+            if (!unitQueryStarted)
+            {
+                unitQueryStarted = true;
+                init(server, conn);
+            }
+        });
     // this will make sure to initialize the objects, when daemon is
     // restarted.
     checkAndInit(server, conn);
diff --git a/src/srvcfg_manager.cpp b/src/srvcfg_manager.cpp
index 3a771d9..69f639d 100644
--- a/src/srvcfg_manager.cpp
+++ b/src/srvcfg_manager.cpp
@@ -224,8 +224,8 @@
 
 void ServiceConfig::queryAndUpdateProperties()
 {
-    std::string objectPath = isSocketActivatedService ? socketObjectPath
-                                                      : serviceObjectPath;
+    std::string objectPath =
+        isSocketActivatedService ? socketObjectPath : serviceObjectPath;
     if (objectPath.empty())
     {
         return;
@@ -235,60 +235,60 @@
         [this](boost::system::error_code ec,
                const boost::container::flat_map<std::string, VariantType>&
                    propertyMap) {
-        if (ec)
-        {
-            lg2::error(
-                "async_method_call error: Failed to service unit properties: {EC}",
-                "EC", ec.value());
-            return;
-        }
-        try
-        {
-            updateServiceProperties(propertyMap);
-            if (!socketObjectPath.empty())
+            if (ec)
             {
-                conn->async_method_call(
-                    [this](boost::system::error_code ec,
-                           const boost::container::flat_map<
-                               std::string, VariantType>& propertyMap) {
-                    if (ec)
-                    {
-                        lg2::error(
-                            "async_method_call error: Failed to get all property: {EC}",
-                            "EC", ec.value());
-                        return;
-                    }
-                    try
-                    {
-                        updateSocketProperties(propertyMap);
-                        if (!srvCfgIface)
-                        {
-                            registerProperties();
-                        }
-                    }
-                    catch (const std::exception& e)
-                    {
-                        lg2::error(
-                            "Exception in getting socket properties: {ERROR}",
-                            "ERROR", e);
-                        return;
-                    }
-                },
-                    sysdService, socketObjectPath, dBusPropIntf,
-                    dBusGetAllMethod, sysdSocketIntf);
+                lg2::error(
+                    "async_method_call error: Failed to service unit properties: {EC}",
+                    "EC", ec.value());
+                return;
             }
-            else if (!srvCfgIface)
+            try
             {
-                registerProperties();
+                updateServiceProperties(propertyMap);
+                if (!socketObjectPath.empty())
+                {
+                    conn->async_method_call(
+                        [this](boost::system::error_code ec,
+                               const boost::container::flat_map<
+                                   std::string, VariantType>& propertyMap) {
+                            if (ec)
+                            {
+                                lg2::error(
+                                    "async_method_call error: Failed to get all property: {EC}",
+                                    "EC", ec.value());
+                                return;
+                            }
+                            try
+                            {
+                                updateSocketProperties(propertyMap);
+                                if (!srvCfgIface)
+                                {
+                                    registerProperties();
+                                }
+                            }
+                            catch (const std::exception& e)
+                            {
+                                lg2::error(
+                                    "Exception in getting socket properties: {ERROR}",
+                                    "ERROR", e);
+                                return;
+                            }
+                        },
+                        sysdService, socketObjectPath, dBusPropIntf,
+                        dBusGetAllMethod, sysdSocketIntf);
+                }
+                else if (!srvCfgIface)
+                {
+                    registerProperties();
+                }
             }
-        }
-        catch (const std::exception& e)
-        {
-            lg2::error("Exception in getting socket properties: {ERROR}",
-                       "ERROR", e);
-            return;
-        }
-    },
+            catch (const std::exception& e)
+            {
+                lg2::error("Exception in getting socket properties: {ERROR}",
+                           "ERROR", e);
+                return;
+            }
+        },
         sysdService, objectPath, dBusPropIntf, dBusGetAllMethod, sysdUnitIntf);
     return;
 }
@@ -322,8 +322,7 @@
     const std::string& objPath_, const std::string& baseUnitName_,
     const std::string& instanceName_, const std::string& serviceObjPath_,
     const std::string& socketObjPath_) :
-    conn(conn_),
-    server(srv_), objPath(objPath_), baseUnitName(baseUnitName_),
+    conn(conn_), server(srv_), objPath(objPath_), baseUnitName(baseUnitName_),
     instanceName(instanceName_), serviceObjectPath(serviceObjPath_),
     socketObjectPath(socketObjPath_)
 {
@@ -504,28 +503,28 @@
         updateInProgress = true;
         boost::asio::spawn(conn->get_io_context(),
                            [this](boost::asio::yield_context yield) {
-            // Stop and apply configuration for all objects
-            for (auto& srvMgrObj : srvMgrObjects)
-            {
-                auto& srvObj = srvMgrObj.second;
-                if (srvObj->updatedFlag)
-                {
-                    srvObj->stopAndApplyUnitConfig(yield);
-                }
-            }
-            // Do system reload
-            systemdDaemonReload(conn, yield);
-            // restart unit config.
-            for (auto& srvMgrObj : srvMgrObjects)
-            {
-                auto& srvObj = srvMgrObj.second;
-                if (srvObj->updatedFlag)
-                {
-                    srvObj->restartUnitConfig(yield);
-                }
-            }
-            updateInProgress = false;
-        });
+                               // Stop and apply configuration for all objects
+                               for (auto& srvMgrObj : srvMgrObjects)
+                               {
+                                   auto& srvObj = srvMgrObj.second;
+                                   if (srvObj->updatedFlag)
+                                   {
+                                       srvObj->stopAndApplyUnitConfig(yield);
+                                   }
+                               }
+                               // Do system reload
+                               systemdDaemonReload(conn, yield);
+                               // restart unit config.
+                               for (auto& srvMgrObj : srvMgrObjects)
+                               {
+                                   auto& srvObj = srvMgrObj.second;
+                                   if (srvObj->updatedFlag)
+                                   {
+                                       srvObj->restartUnitConfig(yield);
+                                   }
+                               }
+                               updateInProgress = false;
+                           });
     });
 }
 
@@ -539,8 +538,50 @@
         sockAttrIface->register_property(
             sockAttrPropPort, portNum,
             [this](const uint16_t& req, uint16_t& res) {
+                if (!internalSet)
+                {
+                    if (req == res)
+                    {
+                        return 1;
+                    }
+                    if (updateInProgress)
+                    {
+                        return 0;
+                    }
+                    portNum = req;
+                    updatedFlag |=
+                        (1 << static_cast<uint8_t>(UpdatedProp::port));
+                    startServiceRestartTimer();
+                }
+                res = req;
+                return 1;
+            });
+    }
+
+    srvCfgIface->register_property(
+        srvCfgPropMasked, unitMaskedState, [this](const bool& req, bool& res) {
             if (!internalSet)
             {
+#ifdef USB_CODE_UPDATE
+                if (baseUnitName == usbCodeUpdateUnitName)
+                {
+                    unitMaskedState = req;
+                    unitEnabledState = !unitMaskedState;
+                    unitRunningState = !unitMaskedState;
+                    internalSet = true;
+                    srvCfgIface->set_property(srvCfgPropEnabled,
+                                              unitEnabledState);
+                    srvCfgIface->set_property(srvCfgPropRunning,
+                                              unitRunningState);
+                    srvCfgIface->set_property(srvCfgPropMasked,
+                                              unitMaskedState);
+                    internalSet = false;
+                    setUSBCodeUpdateState(unitEnabledState);
+                    saveUSBCodeUpdateStateToFile(unitMaskedState,
+                                                 unitEnabledState);
+                    return 1;
+                }
+#endif
                 if (req == res)
                 {
                     return 1;
@@ -549,151 +590,122 @@
                 {
                     return 0;
                 }
-                portNum = req;
-                updatedFlag |= (1 << static_cast<uint8_t>(UpdatedProp::port));
+                unitMaskedState = req;
+                unitEnabledState = !unitMaskedState;
+                unitRunningState = !unitMaskedState;
+                updatedFlag |=
+                    (1 << static_cast<uint8_t>(UpdatedProp::maskedState)) |
+                    (1 << static_cast<uint8_t>(UpdatedProp::enabledState)) |
+                    (1 << static_cast<uint8_t>(UpdatedProp::runningState));
+                internalSet = true;
+                srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
+                srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
+                internalSet = false;
                 startServiceRestartTimer();
             }
             res = req;
             return 1;
         });
-    }
 
-    srvCfgIface->register_property(srvCfgPropMasked, unitMaskedState,
-                                   [this](const bool& req, bool& res) {
-        if (!internalSet)
-        {
-#ifdef USB_CODE_UPDATE
-            if (baseUnitName == usbCodeUpdateUnitName)
+    srvCfgIface->register_property(
+        srvCfgPropEnabled, unitEnabledState,
+        [this](const bool& req, bool& res) {
+            if (!internalSet)
             {
-                unitMaskedState = req;
-                unitEnabledState = !unitMaskedState;
-                unitRunningState = !unitMaskedState;
-                internalSet = true;
-                srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
-                srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
-                srvCfgIface->set_property(srvCfgPropMasked, unitMaskedState);
-                internalSet = false;
-                setUSBCodeUpdateState(unitEnabledState);
-                saveUSBCodeUpdateStateToFile(unitMaskedState, unitEnabledState);
-                return 1;
-            }
+#ifdef USB_CODE_UPDATE
+                if (baseUnitName == usbCodeUpdateUnitName)
+                {
+                    if (unitMaskedState)
+                    { // block updating if masked
+                        lg2::error("Invalid value specified");
+                        return -EINVAL;
+                    }
+                    unitEnabledState = req;
+                    unitRunningState = req;
+                    internalSet = true;
+                    srvCfgIface->set_property(srvCfgPropEnabled,
+                                              unitEnabledState);
+                    srvCfgIface->set_property(srvCfgPropRunning,
+                                              unitRunningState);
+                    internalSet = false;
+                    setUSBCodeUpdateState(unitEnabledState);
+                    saveUSBCodeUpdateStateToFile(unitMaskedState,
+                                                 unitEnabledState);
+                    res = req;
+                    return 1;
+                }
 #endif
-            if (req == res)
-            {
-                return 1;
-            }
-            if (updateInProgress)
-            {
-                return 0;
-            }
-            unitMaskedState = req;
-            unitEnabledState = !unitMaskedState;
-            unitRunningState = !unitMaskedState;
-            updatedFlag |=
-                (1 << static_cast<uint8_t>(UpdatedProp::maskedState)) |
-                (1 << static_cast<uint8_t>(UpdatedProp::enabledState)) |
-                (1 << static_cast<uint8_t>(UpdatedProp::runningState));
-            internalSet = true;
-            srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
-            srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
-            internalSet = false;
-            startServiceRestartTimer();
-        }
-        res = req;
-        return 1;
-    });
-
-    srvCfgIface->register_property(srvCfgPropEnabled, unitEnabledState,
-                                   [this](const bool& req, bool& res) {
-        if (!internalSet)
-        {
-#ifdef USB_CODE_UPDATE
-            if (baseUnitName == usbCodeUpdateUnitName)
-            {
+                if (req == res)
+                {
+                    return 1;
+                }
+                if (updateInProgress)
+                {
+                    return 0;
+                }
                 if (unitMaskedState)
                 { // block updating if masked
                     lg2::error("Invalid value specified");
                     return -EINVAL;
                 }
                 unitEnabledState = req;
-                unitRunningState = req;
-                internalSet = true;
-                srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
-                srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
-                internalSet = false;
-                setUSBCodeUpdateState(unitEnabledState);
-                saveUSBCodeUpdateStateToFile(unitMaskedState, unitEnabledState);
-                res = req;
-                return 1;
+                updatedFlag |=
+                    (1 << static_cast<uint8_t>(UpdatedProp::enabledState));
+                startServiceRestartTimer();
             }
-#endif
-            if (req == res)
-            {
-                return 1;
-            }
-            if (updateInProgress)
-            {
-                return 0;
-            }
-            if (unitMaskedState)
-            { // block updating if masked
-                lg2::error("Invalid value specified");
-                return -EINVAL;
-            }
-            unitEnabledState = req;
-            updatedFlag |= (1
-                            << static_cast<uint8_t>(UpdatedProp::enabledState));
-            startServiceRestartTimer();
-        }
-        res = req;
-        return 1;
-    });
+            res = req;
+            return 1;
+        });
 
-    srvCfgIface->register_property(srvCfgPropRunning, unitRunningState,
-                                   [this](const bool& req, bool& res) {
-        if (!internalSet)
-        {
-#ifdef USB_CODE_UPDATE
-            if (baseUnitName == usbCodeUpdateUnitName)
+    srvCfgIface->register_property(
+        srvCfgPropRunning, unitRunningState,
+        [this](const bool& req, bool& res) {
+            if (!internalSet)
             {
+#ifdef USB_CODE_UPDATE
+                if (baseUnitName == usbCodeUpdateUnitName)
+                {
+                    if (unitMaskedState)
+                    { // block updating if masked
+                        lg2::error("Invalid value specified");
+                        return -EINVAL;
+                    }
+                    unitEnabledState = req;
+                    unitRunningState = req;
+                    internalSet = true;
+                    srvCfgIface->set_property(srvCfgPropEnabled,
+                                              unitEnabledState);
+                    srvCfgIface->set_property(srvCfgPropRunning,
+                                              unitRunningState);
+                    internalSet = false;
+                    setUSBCodeUpdateState(unitEnabledState);
+                    saveUSBCodeUpdateStateToFile(unitMaskedState,
+                                                 unitEnabledState);
+                    res = req;
+                    return 1;
+                }
+#endif
+                if (req == res)
+                {
+                    return 1;
+                }
+                if (updateInProgress)
+                {
+                    return 0;
+                }
                 if (unitMaskedState)
                 { // block updating if masked
                     lg2::error("Invalid value specified");
                     return -EINVAL;
                 }
-                unitEnabledState = req;
                 unitRunningState = req;
-                internalSet = true;
-                srvCfgIface->set_property(srvCfgPropEnabled, unitEnabledState);
-                srvCfgIface->set_property(srvCfgPropRunning, unitRunningState);
-                internalSet = false;
-                setUSBCodeUpdateState(unitEnabledState);
-                saveUSBCodeUpdateStateToFile(unitMaskedState, unitEnabledState);
-                res = req;
-                return 1;
+                updatedFlag |=
+                    (1 << static_cast<uint8_t>(UpdatedProp::runningState));
+                startServiceRestartTimer();
             }
-#endif
-            if (req == res)
-            {
-                return 1;
-            }
-            if (updateInProgress)
-            {
-                return 0;
-            }
-            if (unitMaskedState)
-            { // block updating if masked
-                lg2::error("Invalid value specified");
-                return -EINVAL;
-            }
-            unitRunningState = req;
-            updatedFlag |= (1
-                            << static_cast<uint8_t>(UpdatedProp::runningState));
-            startServiceRestartTimer();
-        }
-        res = req;
-        return 1;
-    });
+            res = req;
+            return 1;
+        });
 
     srvCfgIface->initialize();
     if (!socketObjectPath.empty())
