Migrate to C++17 and misc code cleanups

Change-Id: I6b63385c92361a7ef5803d2bfd00f39c77e88d34
diff --git a/src/common.hpp b/src/common.hpp
index 4b36208..2fa27b9 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -25,22 +25,19 @@
 #include <ndn-cxx/data.hpp>
 #include <ndn-cxx/face.hpp>
 #include <ndn-cxx/interest.hpp>
-#include <ndn-cxx/key-locator.hpp>
 #include <ndn-cxx/name.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/security/validator.hpp>
-#include <ndn-cxx/security/validator-config.hpp>
-#include <ndn-cxx/util/time.hpp>
 #include <ndn-cxx/util/scheduler.hpp>
+#include <ndn-cxx/util/time.hpp>
 
-#include <boost/utility.hpp>
+#include <boost/core/noncopyable.hpp>
 
 #include <algorithm>
 #include <functional>
-#include <iostream>
+#include <iosfwd>
 #include <list>
 #include <map>
 #include <memory>
+#include <stdexcept>
 #include <string>
 #include <vector>
 
@@ -52,24 +49,21 @@
 
 namespace repo {
 
-using ndn::Face;
-using ndn::Block;
-using ndn::operator ""_block;
-using ndn::Name;
-namespace name = ndn::name;
-using ndn::Interest;
-using ndn::Data;
-using ndn::KeyLocator;
-using ndn::Scheduler;
-using ndn::security::KeyChain;
-using ndn::security::Validator;
-using ndn::security::ValidationError;
-using ndn::security::ValidatorConfig;
-
 using boost::noncopyable;
 
-typedef uint64_t ProcessId;
-typedef uint64_t SegmentNo;
+using ndn::Face;
+using ndn::Block;
+using ndn::Name;
+using ndn::Interest;
+using ndn::Data;
+using ndn::Scheduler;
+
+using ndn::operator""_block;
+namespace time = ndn::time;
+using namespace ndn::time_literals;
+
+using ProcessId = uint64_t;
+using SegmentNo = uint64_t;
 
 } // namespace repo
 
diff --git a/src/handles/command-base-handle.cpp b/src/handles/command-base-handle.cpp
index a820e3b..ba126c0 100644
--- a/src/handles/command-base-handle.cpp
+++ b/src/handles/command-base-handle.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -19,7 +19,7 @@
 
 #include "command-base-handle.hpp"
 
-#include <ndn-cxx/util/random.hpp>
+#include <optional>
 
 namespace repo {
 
@@ -29,23 +29,23 @@
 
 /** \brief obtain signer from SignerTag attached to Interest, if available
  */
-static ndn::optional<std::string>
+static std::optional<std::string>
 getSignerFromTag(const ndn::Interest& interest)
 {
-  std::shared_ptr<SignerTag> signerTag = interest.getTag<SignerTag>();
+  auto signerTag = interest.getTag<SignerTag>();
   if (signerTag == nullptr) {
-    return ndn::nullopt;
+    return std::nullopt;
   }
   else {
     return signerTag->get().toUri();
   }
 }
 
-CommandBaseHandle::CommandBaseHandle(Face& face, RepoStorage& storageHandle,
-                  Scheduler& scheduler, Validator& validator)
+CommandBaseHandle::CommandBaseHandle(Face& face, RepoStorage& storage,
+                                     Scheduler& sched, ndn::security::Validator& validator)
   : face(face)
-  , storageHandle(storageHandle)
-  , scheduler(scheduler)
+  , storageHandle(storage)
+  , scheduler(sched)
   , m_validator(validator)
 {
 }
@@ -53,19 +53,16 @@
 ndn::mgmt::Authorization
 CommandBaseHandle::makeAuthorization()
 {
-  return [=] (const ndn::Name& prefix, const ndn::Interest& interest,
-            const ndn::mgmt::ControlParameters* params,
-            const ndn::mgmt::AcceptContinuation& accept,
-            const ndn::mgmt::RejectContinuation& reject) {
+  return [=] (const ndn::Name&, const auto& interest,
+              const ndn::mgmt::ControlParameters*,
+              const ndn::mgmt::AcceptContinuation& accept,
+              const ndn::mgmt::RejectContinuation& reject) {
   m_validator.validate(interest,
-    [accept] (const ndn::Interest& request) {
-
-      auto signer1 = getSignerFromTag(request);
-      std::string signer = signer1.value_or("*");
+    [accept] (const auto& request) {
+      auto signer = getSignerFromTag(request).value_or("*");
       accept(signer);
     },
-    [reject] (const ndn::Interest& request,
-              const ndn::security::ValidationError& error) {
+    [reject] (auto&&...) {
       reject(ndn::mgmt::RejectReply::STATUS403);
     });
   };
diff --git a/src/handles/command-base-handle.hpp b/src/handles/command-base-handle.hpp
index 205b884..520b7d0 100644
--- a/src/handles/command-base-handle.hpp
+++ b/src/handles/command-base-handle.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -28,6 +28,7 @@
 #include "repo-command.hpp"
 
 #include <ndn-cxx/mgmt/dispatcher.hpp>
+#include <ndn-cxx/security/validator.hpp>
 
 namespace repo {
 
@@ -37,16 +38,12 @@
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
 public:
   CommandBaseHandle(Face& face, RepoStorage& storageHandle,
-                    Scheduler& scheduler, Validator& validator);
+                    Scheduler& scheduler, ndn::security::Validator& validator);
 
   virtual
   ~CommandBaseHandle() = default;
@@ -58,14 +55,14 @@
   bool
   validateParameters(const ndn::mgmt::ControlParameters& parameters)
   {
-    const RepoCommandParameter* castParams =
-      dynamic_cast<const RepoCommandParameter*>(&parameters);
+    const auto* castParams = dynamic_cast<const RepoCommandParameter*>(&parameters);
     BOOST_ASSERT(castParams != nullptr);
+
     T command;
     try {
       command.validateRequest(*castParams);
     }
-    catch (const RepoCommand::ArgumentError& ae) {
+    catch (const RepoCommand::ArgumentError&) {
       return false;
     }
     return true;
@@ -77,8 +74,9 @@
   Scheduler& scheduler;
 
 private:
-  Validator& m_validator;
+  ndn::security::Validator& m_validator;
 };
+
 } // namespace repo
 
-#endif // REPO_HANDLES_COMMAND_BASE_HANDLE_HPP
\ No newline at end of file
+#endif // REPO_HANDLES_COMMAND_BASE_HANDLE_HPP
diff --git a/src/handles/delete-handle.cpp b/src/handles/delete-handle.cpp
index c892583..d9efe76 100644
--- a/src/handles/delete-handle.cpp
+++ b/src/handles/delete-handle.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -27,7 +27,7 @@
 
 DeleteHandle::DeleteHandle(Face& face, RepoStorage& storageHandle,
                            ndn::mgmt::Dispatcher& dispatcher, Scheduler& scheduler,
-                           Validator& validator)
+                           ndn::security::Validator& validator)
   : CommandBaseHandle(face, storageHandle, scheduler, validator)
 {
   dispatcher.addControlCommand<RepoCommandParameter>(ndn::PartialName("delete"),
@@ -72,7 +72,8 @@
 }
 
 RepoCommandResponse
-DeleteHandle::negativeReply(const Interest& interest, uint64_t statusCode, std::string text) const
+DeleteHandle::negativeReply(const Interest& interest, uint64_t statusCode,
+                            const std::string& text) const
 {
   RepoCommandResponse response(statusCode, text);
   response.setBody(response.wireEncode());
@@ -108,9 +109,9 @@
       nDeletedData++;
     }
   }
+
   //All the data deleted, return 200
   done(positiveReply(interest, parameter, 200, nDeletedData));
-
 }
 
 } // namespace repo
diff --git a/src/handles/delete-handle.hpp b/src/handles/delete-handle.hpp
index ca32709..6bce2c1 100644
--- a/src/handles/delete-handle.hpp
+++ b/src/handles/delete-handle.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -22,27 +22,20 @@
 
 #include "command-base-handle.hpp"
 
-#include <ndn-cxx/mgmt/dispatcher.hpp>
-
 namespace repo {
 
 class DeleteHandle : public CommandBaseHandle
 {
-
 public:
   class Error : public CommandBaseHandle::Error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : CommandBaseHandle::Error(what)
-    {
-    }
+    using CommandBaseHandle::Error::Error;
   };
 
-public:
   DeleteHandle(Face& face, RepoStorage& storageHandle,
-               ndn::mgmt::Dispatcher& dispatcher, Scheduler& scheduler, Validator& validator);
+               ndn::mgmt::Dispatcher& dispatcher, Scheduler& scheduler,
+               ndn::security::Validator& validator);
 
 private:
   void
@@ -55,7 +48,7 @@
                 uint64_t statusCode, uint64_t nDeletedData) const;
 
   RepoCommandResponse
-  negativeReply(const Interest& interest, uint64_t statusCode, const std::string text) const;
+  negativeReply(const Interest& interest, uint64_t statusCode, const std::string& text) const;
 
   void
   processSingleDeleteCommand(const Interest& interest, const RepoCommandParameter& parameter,
diff --git a/src/handles/tcp-bulk-insert-handle.hpp b/src/handles/tcp-bulk-insert-handle.hpp
index 49ee8e0..2930985 100644
--- a/src/handles/tcp-bulk-insert-handle.hpp
+++ b/src/handles/tcp-bulk-insert-handle.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -33,11 +33,7 @@
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
 public:
diff --git a/src/handles/write-handle.cpp b/src/handles/write-handle.cpp
index d971878..1e30b5e 100644
--- a/src/handles/write-handle.cpp
+++ b/src/handles/write-handle.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -26,22 +26,14 @@
 
 NDN_LOG_INIT(repo.WriteHandle);
 
-static const int DEFAULT_CREDIT = 12;
-static const bool DEFAULT_CANBE_PREFIX = false;
-static const milliseconds MAX_TIMEOUT(60_s);
-static const milliseconds NOEND_TIMEOUT(10000_ms);
-static const milliseconds PROCESS_DELETE_TIME(10000_ms);
-static const milliseconds DEFAULT_INTEREST_LIFETIME(4000_ms);
+const int DEFAULT_CREDIT = 12;
+const time::milliseconds NOEND_TIMEOUT = 10_s;
+const time::milliseconds PROCESS_DELETE_TIME = 10_s;
 
 WriteHandle::WriteHandle(Face& face, RepoStorage& storageHandle, ndn::mgmt::Dispatcher& dispatcher,
-                         Scheduler& scheduler, Validator& validator)
+                         Scheduler& scheduler, ndn::security::Validator& validator)
   : CommandBaseHandle(face, storageHandle, scheduler, validator)
   , m_validator(validator)
-  , m_credit(DEFAULT_CREDIT)
-  , m_canBePrefix(DEFAULT_CANBE_PREFIX)
-  , m_maxTimeout(MAX_TIMEOUT)
-  , m_noEndTimeout(NOEND_TIMEOUT)
-  , m_interestLifetime(DEFAULT_INTEREST_LIFETIME)
 {
   dispatcher.addControlCommand<RepoCommandParameter>(ndn::PartialName("insert"),
     makeAuthorization(),
@@ -62,20 +54,20 @@
 
 void
 WriteHandle::handleInsertCommand(const Name& prefix, const Interest& interest,
-                                 const ndn::mgmt::ControlParameters& parameter,
+                                 const ndn::mgmt::ControlParameters& params,
                                  const ndn::mgmt::CommandContinuation& done)
 {
-  RepoCommandParameter* repoParameter =
-    dynamic_cast<RepoCommandParameter*>(const_cast<ndn::mgmt::ControlParameters*>(&parameter));
+  auto& repoParam = dynamic_cast<RepoCommandParameter&>(const_cast<ndn::mgmt::ControlParameters&>(params));
 
-  if (repoParameter->hasStartBlockId() || repoParameter->hasEndBlockId()) {
-    processSegmentedInsertCommand(interest, *repoParameter, done);
+  if (repoParam.hasStartBlockId() || repoParam.hasEndBlockId()) {
+    processSegmentedInsertCommand(interest, repoParam, done);
   }
   else {
-    processSingleInsertCommand(interest, *repoParameter, done);
+    processSingleInsertCommand(interest, repoParam, done);
   }
-  if (repoParameter->hasInterestLifetime())
-    m_interestLifetime = repoParameter->getInterestLifetime();
+  if (repoParam.hasInterestLifetime()) {
+    m_interestLifetime = repoParam.getInterestLifetime();
+  }
 }
 
 void
@@ -83,7 +75,7 @@
 {
   m_validator.validate(data,
                        std::bind(&WriteHandle::onDataValidated, this, interest, _1, processId),
-                       [](const Data& data, const ValidationError& error){NDN_LOG_ERROR("Error: " << error);});
+                       [] (auto&&, const auto& error) { NDN_LOG_ERROR("Error: " << error); });
 }
 
 void
@@ -128,7 +120,6 @@
 
   response.setCode(300);
   Interest fetchInterest(parameter.getName());
-  fetchInterest.setCanBePrefix(m_canBePrefix);
   fetchInterest.setInterestLifetime(m_interestLifetime);
   face.expressInterest(fetchInterest,
                        std::bind(&WriteHandle::onData, this, _1, _2, processId),
@@ -144,34 +135,32 @@
   Name name = parameter.getName();
   SegmentNo startBlockId = parameter.getStartBlockId();
 
-  uint64_t initialCredit = m_credit;
-
+  int initialCredit = DEFAULT_CREDIT;
   if (parameter.hasEndBlockId()) {
-    initialCredit =
-      std::min(initialCredit, parameter.getEndBlockId() - parameter.getStartBlockId() + 1);
+    initialCredit = std::min<int>(initialCredit, parameter.getEndBlockId() - parameter.getStartBlockId() + 1);
   }
   else {
     // set noEndTimeout timer
-    process.noEndTime = ndn::time::steady_clock::now() +
-                        m_noEndTimeout;
+    process.noEndTime = time::steady_clock::now() + NOEND_TIMEOUT;
   }
 
   Name fetchName = name;
-  SegmentNo segment = startBlockId;
-  fetchName.appendSegment(segment);
+  fetchName.appendSegment(startBlockId);
   Interest interest(fetchName);
 
   ndn::util::SegmentFetcher::Options options;
   options.initCwnd = initialCredit;
   options.interestLifetime = m_interestLifetime;
-  options.maxTimeout = m_maxTimeout;
   auto fetcher = ndn::util::SegmentFetcher::start(face, interest, m_validator, options);
-  fetcher->onError.connect([] (uint32_t errorCode, const std::string& errorMsg)
-                           {NDN_LOG_ERROR("Error: " << errorMsg);});
-  fetcher->afterSegmentValidated.connect([this, &fetcher, &processId] (const Data& data)
-                                         {onSegmentData(*fetcher, data, processId);});
-  fetcher->afterSegmentTimedOut.connect([this, &fetcher, &processId] ()
-                                        {onSegmentTimeout(*fetcher, processId);});
+  fetcher->onError.connect([] (uint32_t, const auto& errorMsg) {
+    NDN_LOG_ERROR("Error: " << errorMsg);
+  });
+  fetcher->afterSegmentValidated.connect([this, &fetcher, &processId] (const Data& data) {
+    onSegmentData(*fetcher, data, processId);
+  });
+  fetcher->afterSegmentTimedOut.connect([this, &fetcher, &processId] {
+    onSegmentTimeout(*fetcher, processId);
+  });
 }
 
 void
@@ -193,9 +182,8 @@
   ProcessInfo& process = m_processes[processId];
   //read whether notime timeout
   if (!response.hasEndBlockId()) {
-
-    ndn::time::steady_clock::TimePoint& noEndTime = process.noEndTime;
-    ndn::time::steady_clock::TimePoint now = ndn::time::steady_clock::now();
+    auto noEndTime = process.noEndTime;
+    auto now = time::steady_clock::now();
 
     if (now > noEndTime) {
       NDN_LOG_DEBUG("noEndtimeout: " << processId);
@@ -281,10 +269,10 @@
 
 void
 WriteHandle::handleCheckCommand(const Name& prefix, const Interest& interest,
-                                const ndn::mgmt::ControlParameters& parameter,
+                                const ndn::mgmt::ControlParameters& params,
                                 const ndn::mgmt::CommandContinuation& done)
 {
-  const RepoCommandParameter& repoParameter = dynamic_cast<const RepoCommandParameter&>(parameter);
+  const auto& repoParameter = dynamic_cast<const RepoCommandParameter&>(params);
 
   //check whether this process exists
   ProcessId processId = repoParameter.getProcessId();
@@ -324,8 +312,8 @@
 void
 WriteHandle::extendNoEndTime(ProcessInfo& process)
 {
-  auto& noEndTime = process.noEndTime;
-  auto now = ndn::time::steady_clock::now();
+  auto noEndTime = process.noEndTime;
+  auto now = time::steady_clock::now();
   RepoCommandResponse& response = process.response;
   if (now > noEndTime) {
     response.setCode(405);
@@ -333,7 +321,7 @@
   }
 
   //extends noEndTime
-  process.noEndTime = ndn::time::steady_clock::now() + m_noEndTimeout;
+  process.noEndTime = time::steady_clock::now() + NOEND_TIMEOUT;
 }
 
 RepoCommandResponse
@@ -341,7 +329,6 @@
 {
   RepoCommandResponse response(statusCode, text);
   response.setBody(response.wireEncode());
-
   return response;
 }
 
diff --git a/src/handles/write-handle.hpp b/src/handles/write-handle.hpp
index 115801e..04ed3f5 100644
--- a/src/handles/write-handle.hpp
+++ b/src/handles/write-handle.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -22,7 +22,6 @@
 
 #include "command-base-handle.hpp"
 
-#include <ndn-cxx/mgmt/dispatcher.hpp>
 #include <ndn-cxx/util/segment-fetcher.hpp>
 
 #include <queue>
@@ -52,23 +51,16 @@
  */
 class WriteHandle : public CommandBaseHandle
 {
-
 public:
   class Error : public CommandBaseHandle::Error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : CommandBaseHandle::Error(what)
-    {
-    }
+    using CommandBaseHandle::Error::Error;
   };
 
-
-public:
   WriteHandle(Face& face, RepoStorage& storageHandle,
               ndn::mgmt::Dispatcher& dispatcher, Scheduler& scheduler,
-              Validator& validator);
+              ndn::security::Validator& validator);
 
 private:
   /**
@@ -92,7 +84,7 @@
      * It is initialized to now()+noEndTimeout when segmented fetch process begins,
      * and reset to now()+noEndTimeout each time an insert status check command is processed.
      */
-    ndn::time::steady_clock::TimePoint noEndTime;
+    time::steady_clock::time_point noEndTime;
   };
 
 private: // insert command
@@ -105,7 +97,7 @@
                       const ndn::mgmt::CommandContinuation& done);
 
   void
-  onValidationFailed(const Interest& interest, const ValidationError& error);
+  onValidationFailed(const Interest& interest, const ndn::security::ValidationError& error);
 
 private: // single data fetching
   /**
@@ -171,7 +163,7 @@
                      const ndn::mgmt::CommandContinuation& done);
 
   void
-  onCheckValidationFailed(const Interest& interest, const ValidationError& error);
+  onCheckValidationFailed(const Interest& interest, const ndn::security::ValidationError& error);
 
 private:
   void
@@ -187,15 +179,9 @@
   negativeReply(std::string text, int statusCode);
 
 private:
-  Validator& m_validator;
-
+  ndn::security::Validator& m_validator;
   std::map<ProcessId, ProcessInfo> m_processes;
-
-  int m_credit;
-  bool m_canBePrefix;
-  ndn::time::milliseconds m_maxTimeout;
-  ndn::time::milliseconds m_noEndTimeout;
-  ndn::time::milliseconds m_interestLifetime;
+  time::milliseconds m_interestLifetime = ndn::DEFAULT_INTEREST_LIFETIME;
 };
 
 } // namespace repo
diff --git a/src/main.cpp b/src/main.cpp
index 6229759..767dc8f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2018-2019, Regents of the University of California.
+ * Copyright (c) 2018-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -21,6 +21,7 @@
 #include "extended-error-message.hpp"
 #include "repo.hpp"
 
+#include <iostream>
 #include <string.h> // for strsignal()
 
 #include <boost/asio/io_service.hpp>
diff --git a/src/repo-command-parameter.cpp b/src/repo-command-parameter.cpp
index 2f4de5c..4494eca 100644
--- a/src/repo-command-parameter.cpp
+++ b/src/repo-command-parameter.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -19,10 +19,7 @@
 
 #include "repo-command-parameter.hpp"
 
-#include <ndn-cxx/encoding/encoding-buffer.hpp>
 #include <ndn-cxx/encoding/block-helpers.hpp>
-#include <ndn-cxx/mgmt/control-parameters.hpp>
-#include <ndn-cxx/name.hpp>
 
 namespace repo {
 
@@ -63,7 +60,7 @@
 }
 
 RepoCommandParameter&
-RepoCommandParameter::setInterestLifetime(milliseconds interestLifetime)
+RepoCommandParameter::setInterestLifetime(time::milliseconds interestLifetime)
 {
   m_interestLifetime = interestLifetime;
   m_hasFields[REPO_PARAMETER_INTEREST_LIFETIME] = true;
@@ -73,7 +70,7 @@
 
 template<ndn::encoding::Tag T>
 size_t
-RepoCommandParameter::wireEncode(EncodingImpl<T>& encoder) const
+RepoCommandParameter::wireEncode(ndn::EncodingImpl<T>& encoder) const
 {
   size_t totalLength = 0;
   size_t variableLength = 0;
@@ -123,10 +120,10 @@
   if (m_wire.hasWire())
     return m_wire;
 
-  EncodingEstimator estimator;
+  ndn::EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
 
-  EncodingBuffer buffer(estimatedSize, 0);
+  ndn::EncodingBuffer buffer(estimatedSize, 0);
   wireEncode(buffer);
 
   m_wire = buffer.block();
@@ -136,15 +133,15 @@
 void
 RepoCommandParameter::wireDecode(const Block& wire)
 {
-  m_wire = wire;
+  if (wire.type() != tlv::RepoCommandParameter) {
+    NDN_THROW(Error("RepoCommandParameter", wire.type()));
+  }
 
+  m_wire = wire;
   m_wire.parse();
 
-  if (m_wire.type() != tlv::RepoCommandParameter)
-    BOOST_THROW_EXCEPTION(Error("Requested decoding of RepoCommandParameter, but Block is of different type"));
-
   // Name
-  Block::element_const_iterator val = m_wire.find(tlv::Name);
+  auto val = m_wire.find(tlv::Name);
   if (val != m_wire.elements_end())
   {
     m_hasFields[REPO_PARAMETER_NAME] = true;
@@ -175,42 +172,13 @@
     m_processId = readNonNegativeInteger(*val);
   }
 
-  // InterestLifeTime
+  // InterestLifetime
   val = m_wire.find(tlv::InterestLifetime);
   if (val != m_wire.elements_end())
   {
     m_hasFields[REPO_PARAMETER_INTEREST_LIFETIME] = true;
-    m_interestLifetime = milliseconds(readNonNegativeInteger(*val));
+    m_interestLifetime = time::milliseconds(readNonNegativeInteger(*val));
   }
 }
 
-std::ostream&
-operator<<(std::ostream& os, const RepoCommandParameter& repoCommandParameter)
-{
-  os << "RepoCommandParameter(";
-
-  // Name
-  if (repoCommandParameter.hasName()) {
-    os << " Name: " << repoCommandParameter.getName();
-  }
-  if (repoCommandParameter.hasStartBlockId()) {
-  // StartBlockId
-    os << " StartBlockId: " << repoCommandParameter.getStartBlockId();
-  }
-  // EndBlockId
-  if (repoCommandParameter.hasEndBlockId()) {
-    os << " EndBlockId: " << repoCommandParameter.getEndBlockId();
-  }
-  // ProcessId
-  if (repoCommandParameter.hasProcessId()) {
-    os << " ProcessId: " << repoCommandParameter.getProcessId();
-  }
-  // InterestLifetime
-  if (repoCommandParameter.hasProcessId()) {
-    os << " InterestLifetime: " << repoCommandParameter.getInterestLifetime();
-  }
-  os << " )";
-  return os;
-}
-
-} // namespace repo
\ No newline at end of file
+} // namespace repo
diff --git a/src/repo-command-parameter.hpp b/src/repo-command-parameter.hpp
index 6ce45f0..2885e10 100644
--- a/src/repo-command-parameter.hpp
+++ b/src/repo-command-parameter.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -20,22 +20,14 @@
 #ifndef REPO_REPO_COMMAND_PARAMETER_HPP
 #define REPO_REPO_COMMAND_PARAMETER_HPP
 
+#include "common.hpp"
 #include "repo-tlv.hpp"
 
 #include <ndn-cxx/encoding/encoding-buffer.hpp>
-#include <ndn-cxx/encoding/block-helpers.hpp>
 #include <ndn-cxx/mgmt/control-parameters.hpp>
-#include <ndn-cxx/name.hpp>
 
 namespace repo {
 
-using ndn::Name;
-using ndn::Block;
-using ndn::EncodingImpl;
-using ndn::EncodingEstimator;
-using ndn::EncodingBuffer;
-using namespace ndn::time;
-
 enum RepoParameterField {
   REPO_PARAMETER_NAME,
   REPO_PARAMETER_START_BLOCK_ID,
@@ -54,21 +46,16 @@
 };
 
 /**
-* @brief Class defining abstraction of parameter of command for NDN Repo Protocol
-* @sa link https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#RepoCommandParameter
-**/
-
+ * @brief Class defining abstraction of parameter of command for NDN Repo Protocol
+ * @sa link https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#RepoCommandParameter
+ */
 class RepoCommandParameter : public ndn::mgmt::ControlParameters
 {
 public:
-  class Error : public ndn::tlv::Error
+  class Error : public tlv::Error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : ndn::tlv::Error(what)
-    {
-    }
+    using tlv::Error::Error;
   };
 
   RepoCommandParameter()
@@ -102,7 +89,7 @@
   uint64_t
   getStartBlockId() const
   {
-    assert(hasStartBlockId());
+    BOOST_ASSERT(hasStartBlockId());
     return m_startBlockId;
   }
 
@@ -118,7 +105,7 @@
   uint64_t
   getEndBlockId() const
   {
-    assert(hasEndBlockId());
+    BOOST_ASSERT(hasEndBlockId());
     return m_endBlockId;
   }
 
@@ -134,7 +121,7 @@
   uint64_t
   getProcessId() const
   {
-    assert(hasProcessId());
+    BOOST_ASSERT(hasProcessId());
     return m_processId;
   }
 
@@ -147,15 +134,15 @@
     return m_hasFields[REPO_PARAMETER_PROCESS_ID];
   }
 
-  milliseconds
+  time::milliseconds
   getInterestLifetime() const
   {
-    assert(hasInterestLifetime());
+    BOOST_ASSERT(hasInterestLifetime());
     return m_interestLifetime;
   }
 
   RepoCommandParameter&
-  setInterestLifetime(milliseconds interestLifetime);
+  setInterestLifetime(time::milliseconds interestLifetime);
 
   bool
   hasInterestLifetime() const
@@ -164,19 +151,20 @@
   }
 
   const std::vector<bool>&
-  getPresentFields() const {
+  getPresentFields() const
+  {
     return m_hasFields;
   }
 
   template<ndn::encoding::Tag T>
   size_t
-  wireEncode(EncodingImpl<T>& block) const;
+  wireEncode(ndn::EncodingImpl<T>& block) const;
 
   Block
-  wireEncode() const;
+  wireEncode() const override;
 
   void
-  wireDecode(const Block& wire);
+  wireDecode(const Block& wire) override;
 
 private:
   std::vector<bool> m_hasFields;
@@ -184,7 +172,7 @@
   uint64_t m_startBlockId;
   uint64_t m_endBlockId;
   uint64_t m_processId;
-  milliseconds m_interestLifetime;
+  time::milliseconds m_interestLifetime;
 
   mutable Block m_wire;
 };
diff --git a/src/repo-command-response.cpp b/src/repo-command-response.cpp
index d00a1d0..15398e1 100644
--- a/src/repo-command-response.cpp
+++ b/src/repo-command-response.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -19,6 +19,8 @@
 
 #include "repo-command-response.hpp"
 
+#include <ndn-cxx/encoding/block-helpers.hpp>
+
 namespace repo {
 
 RepoCommandResponse&
@@ -70,9 +72,7 @@
 RepoCommandResponse::setCode(uint32_t statusCode)
 {
   m_hasStatusCode = true;
-
-  RepoCommandResponse* response =
-    static_cast<RepoCommandResponse *> (&ndn::mgmt::ControlResponse::setCode(statusCode));
+  auto* response = static_cast<RepoCommandResponse*>(&ndn::mgmt::ControlResponse::setCode(statusCode));
   return *response;
 }
 
@@ -118,20 +118,19 @@
   if (m_wire.hasWire())
     return m_wire;
 
-  EncodingEstimator estimator;
+  ndn::EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
 
-  EncodingBuffer buffer(estimatedSize, 0);
+  ndn::EncodingBuffer buffer(estimatedSize, 0);
   wireEncode(buffer);
 
   m_wire = buffer.block();
   return m_wire;
 }
 
-
 template<ndn::encoding::Tag T>
 size_t
-RepoCommandResponse::wireEncode(EncodingImpl<T>& encoder) const
+RepoCommandResponse::wireEncode(ndn::EncodingImpl<T>& encoder) const
 {
   size_t totalLength = 0;
   size_t variableLength = 0;
@@ -171,7 +170,7 @@
     totalLength += encoder.prependVarNumber(tlv::StatusCode);
   }
   else {
-    BOOST_THROW_EXCEPTION(Error("required field StatusCode is missing"));
+    NDN_THROW(Error("Required field StatusCode is missing"));
   }
 
   if (m_hasProcessId) {
@@ -189,6 +188,10 @@
 void
 RepoCommandResponse::wireDecode(const Block& wire)
 {
+  if (wire.type() != tlv::RepoCommandResponse) {
+    NDN_THROW(Error("RepoCommandResponse", wire.type()));
+  }
+
   m_hasStartBlockId = false;
   m_hasEndBlockId = false;
   m_hasProcessId = false;
@@ -197,16 +200,10 @@
   m_hasDeleteNum = false;
 
   m_wire = wire;
-
   m_wire.parse();
 
-  Block::element_const_iterator val;
-
-  if (m_wire.type() != tlv::RepoCommandResponse)
-    BOOST_THROW_EXCEPTION(Error("RepoCommandResponse malformed"));
-
   // StartBlockId
-  val = m_wire.find(tlv::StartBlockId);
+  auto val = m_wire.find(tlv::StartBlockId);
   if (val != m_wire.elements_end()) {
     m_hasStartBlockId = true;
     m_startBlockId = readNonNegativeInteger(*val);
@@ -226,13 +223,13 @@
     m_processId = readNonNegativeInteger(*val);
   }
 
-  //StatusCode
+  // StatusCode
   val = m_wire.find(tlv::StatusCode);
   if (val != m_wire.elements_end()) {
     setCode(readNonNegativeInteger(*val));
   }
   else {
-    BOOST_THROW_EXCEPTION(Error("required field StatusCode is missing"));
+    NDN_THROW(Error("Required field StatusCode is missing"));
   }
 
   // InsertNum
@@ -252,32 +249,4 @@
 
 NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(RepoCommandResponse);
 
-std::ostream&
-operator<<(std::ostream& os, const RepoCommandResponse& repoCommandResponse)
-{
-  os << "RepoCommandResponse(";
-
-  if (repoCommandResponse.hasProcessId()) {
-    os << " ProcessId: " << repoCommandResponse.getProcessId();
-  }
-  // if (repoCommandResponse.hasStatusCode()) {
-  //   os << " StatusCode: " << repoCommandResponse.getStatusCode();
-  // }
-  if (repoCommandResponse.hasStartBlockId()) {
-    os << " StartBlockId: " << repoCommandResponse.getStartBlockId();
-  }
-  if (repoCommandResponse.hasEndBlockId()) {
-    os << " EndBlockId: " << repoCommandResponse.getEndBlockId();
-  }
-  if (repoCommandResponse.hasInsertNum()) {
-    os << " InsertNum: " << repoCommandResponse.getInsertNum();
-  }
-  if (repoCommandResponse.hasDeleteNum()) {
-    os << " DeleteNum: " << repoCommandResponse.getDeleteNum();
-
-  }
-  os << " )";
-  return os;
-}
-
 } // namespace repo
diff --git a/src/repo-command-response.hpp b/src/repo-command-response.hpp
index 4f30ca5..cff12a6 100644
--- a/src/repo-command-response.hpp
+++ b/src/repo-command-response.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -20,38 +20,29 @@
 #ifndef REPO_REPO_COMMAND_RESPONSE_HPP
 #define REPO_REPO_COMMAND_RESPONSE_HPP
 
+#include "common.hpp"
 #include "repo-tlv.hpp"
 
-#include <ndn-cxx/mgmt/control-response.hpp>
-#include <ndn-cxx/encoding/block.hpp>
-#include <ndn-cxx/encoding/block-helpers.hpp>
 #include <ndn-cxx/encoding/encoding-buffer.hpp>
-#include <ndn-cxx/encoding/tlv-nfd.hpp>
+#include <ndn-cxx/mgmt/control-response.hpp>
 
 namespace repo {
 
-using ndn::Block;
-using ndn::EncodingImpl;
-using ndn::EncodingEstimator;
-using ndn::EncodingBuffer;
-
 /**
-* @brief Class defining abstraction of Response for NDN Repo Protocol
-* @sa link https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#Repo-Command-Response
-*/
+ * @brief Class defining abstraction of Response for NDN Repo Protocol
+ * @sa link https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#Repo-Command-Response
+ */
 class RepoCommandResponse : public ndn::mgmt::ControlResponse
 {
 public:
-  class Error : public ndn::tlv::Error
+  class Error : public tlv::Error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : ndn::tlv::Error(what)
-    {
-    }
+    using tlv::Error::Error;
   };
 
+  RepoCommandResponse() = default;
+
   RepoCommandResponse(uint32_t code, const std::string& text)
     : ndn::mgmt::ControlResponse(code, text)
     , m_hasStartBlockId(false)
@@ -63,9 +54,6 @@
   {
   }
 
-  RepoCommandResponse(){
-  }
-
   explicit
   RepoCommandResponse(const Block& block)
   {
@@ -87,7 +75,7 @@
   uint64_t
   getEndBlockId() const
   {
-    assert(hasEndBlockId());
+    BOOST_ASSERT(hasEndBlockId());
     return m_endBlockId;
   }
 
@@ -141,7 +129,7 @@
 
   template<ndn::encoding::Tag T>
   size_t
-  wireEncode(EncodingImpl<T>& block) const;
+  wireEncode(ndn::EncodingImpl<T>& block) const;
 
   const Block&
   wireEncode() const;
diff --git a/src/repo-command.cpp b/src/repo-command.cpp
index 0c1cc21..69d3c9e 100644
--- a/src/repo-command.cpp
+++ b/src/repo-command.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -22,7 +22,8 @@
 namespace repo {
 
 void
-RepoCommand::validateRequest(const RepoCommandParameter& parameters) {
+RepoCommand::validateRequest(const RepoCommandParameter& parameters)
+{
   m_requestValidator.validate(parameters);
   check(parameters);
 }
@@ -36,11 +37,11 @@
     bool isPresent = presentFields[i];
     if (m_required[i]) {
       if (!isPresent) {
-        BOOST_THROW_EXCEPTION(ArgumentError(REPO_PARAMETER_FIELD[i] + " is required but missing"));
+        NDN_THROW(ArgumentError(REPO_PARAMETER_FIELD[i] + " is required but missing"));
       }
     }
     else if (isPresent && !m_optional[i]) {
-      BOOST_THROW_EXCEPTION(ArgumentError(REPO_PARAMETER_FIELD[i] + " is forbidden but present"));
+      NDN_THROW(ArgumentError(REPO_PARAMETER_FIELD[i] + " is forbidden but present"));
     }
   }
 }
@@ -52,7 +53,7 @@
 }
 
 InsertCommand::InsertCommand()
-: RepoCommand()
+  : RepoCommand()
 {
   m_requestValidator
     .required(REPO_PARAMETER_NAME)
@@ -83,14 +84,14 @@
     if (parameters.hasEndBlockId()) {
       SegmentNo startBlockId = parameters.getStartBlockId();
       SegmentNo endBlockId = parameters.getEndBlockId();
-
       if (startBlockId > endBlockId) {
-        BOOST_THROW_EXCEPTION(ArgumentError("start block Id is bigger than end block Id"));
+        NDN_THROW(ArgumentError("Start block Id is bigger than end block Id"));
       }
     }
     else {
-      BOOST_THROW_EXCEPTION(ArgumentError("Segmented deletion without EndBlockId, not implemented"));
+      NDN_THROW(ArgumentError("Segmented deletion without EndBlockId, not implemented"));
     }
   }
 }
-} // namespace repo
\ No newline at end of file
+
+} // namespace repo
diff --git a/src/repo-command.hpp b/src/repo-command.hpp
index 28c2999..b985cbf 100644
--- a/src/repo-command.hpp
+++ b/src/repo-command.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -16,29 +16,25 @@
  * You should have received a copy of the GNU General Public License along with
  * repo-ng, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
+
 #ifndef REPO_REPO_COMMAND_HPP
 #define REPO_REPO_COMMAND_HPP
 
 #include "common.hpp"
 #include "repo-command-parameter.hpp"
 
-#include <stdexcept>
-
 namespace repo {
 
 class RepoCommand : boost::noncopyable
 {
 public:
-  /** \brief represents an error in RepoCommandParameters
+  /**
+   * \brief Represents an error in RepoCommandParameters
    */
   class ArgumentError : public std::invalid_argument
   {
   public:
-    explicit
-    ArgumentError(const std::string& what)
-      : std::invalid_argument(what)
-    {
-    }
+    using std::invalid_argument::invalid_argument;
   };
 
   virtual
@@ -116,4 +112,4 @@
 
 } // namespace repo
 
-#endif // REPO_REPO_COMMAND_HPP
\ No newline at end of file
+#endif // REPO_REPO_COMMAND_HPP
diff --git a/src/repo-tlv.hpp b/src/repo-tlv.hpp
index b8b9f15..5ce38cf 100644
--- a/src/repo-tlv.hpp
+++ b/src/repo-tlv.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2018,  Regents of the University of California.
+/*
+ * Copyright (c) 2018-2022,  Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -22,8 +22,7 @@
 
 #include <ndn-cxx/encoding/tlv.hpp>
 
-namespace repo {
-namespace tlv {
+namespace repo::tlv {
 
 using namespace ndn::tlv;
 
@@ -38,7 +37,6 @@
   DeleteNum            = 210,
 };
 
-} // namespace tlv
-} // namespace repo
+} // namespace repo::tlv
 
 #endif // REPO_REPO_TLV_HPP
diff --git a/src/repo.cpp b/src/repo.cpp
index 4a4a8b5..8ee393f 100644
--- a/src/repo.cpp
+++ b/src/repo.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -34,16 +34,16 @@
   }
 
   std::ifstream fin(configPath.c_str());
- if (!fin.is_open())
-    BOOST_THROW_EXCEPTION(Repo::Error("failed to open configuration file '" + configPath + "'"));
+  if (!fin.is_open())
+    NDN_THROW(Repo::Error("failed to open configuration file '" + configPath + "'"));
 
   using namespace boost::property_tree;
   ptree propertyTree;
   try {
     read_info(fin, propertyTree);
   }
-  catch (const ptree_error& e) {
-    BOOST_THROW_EXCEPTION(Repo::Error("failed to read configuration file '" + configPath + "'"));
+  catch (const ptree_error&) {
+    NDN_THROW_NESTED(Repo::Error("failed to read configuration file '" + configPath + "'"));
   }
 
   ptree repoConf = propertyTree.get_child("repo");
@@ -58,8 +58,8 @@
     else if (section.first == "registration-subset")
       repoConfig.registrationSubset = section.second.get_value<int>();
     else
-      BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + section.first + "' option in 'data' section in "
-                                        "configuration file '"+ configPath +"'"));
+      NDN_THROW(Repo::Error("Unrecognized '" + section.first + "' option in 'data' section in "
+                            "configuration file '"+ configPath +"'"));
   }
 
   ptree commandConf = repoConf.get_child("command");
@@ -67,8 +67,8 @@
     if (section.first == "prefix")
       repoConfig.repoPrefixes.push_back(Name(section.second.get_value<std::string>()));
     else
-      BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + section.first + "' option in 'command' section in "
-                                        "configuration file '"+ configPath +"'"));
+      NDN_THROW(Repo::Error("Unrecognized '" + section.first + "' option in 'command' section in "
+                            "configuration file '"+ configPath +"'"));
   }
 
   auto tcpBulkInsert = repoConf.get_child_optional("tcp_bulk_insert");
@@ -85,8 +85,8 @@
         port = section.second.get_value<std::string>();
       }
       else
-        BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + section.first + "' option in 'tcp_bulk_insert' section in "
-                                          "configuration file '"+ configPath +"'"));
+        NDN_THROW(Repo::Error("Unrecognized '" + section.first + "' option in 'tcp_bulk_insert' section in "
+                              "configuration file '" + configPath + "'"));
     }
   }
   if (isTcpBulkEnabled) {
@@ -94,7 +94,7 @@
   }
 
   if (repoConf.get<std::string>("storage.method") != "sqlite") {
-    BOOST_THROW_EXCEPTION(Repo::Error("Only 'sqlite' storage method is supported"));
+    NDN_THROW(Repo::Error("Only 'sqlite' storage method is supported"));
   }
 
   repoConfig.dbPath = repoConf.get<std::string>("storage.path");
@@ -127,10 +127,10 @@
 Repo::initializeStorage()
 {
   // Rebuild storage if storage checkpoin exists
-  ndn::time::steady_clock::TimePoint start = ndn::time::steady_clock::now();
-  ndn::time::steady_clock::TimePoint end = ndn::time::steady_clock::now();
-  ndn::time::milliseconds cost = ndn::time::duration_cast<ndn::time::milliseconds>(end - start);
-  NDN_LOG_DEBUG("initialize storage cost: " << cost << "ms");
+  auto start = time::steady_clock::now();
+  auto end = time::steady_clock::now();
+  auto cost = time::duration_cast<time::milliseconds>(end - start);
+  NDN_LOG_DEBUG("initialize storage cost: " << cost);
 }
 
 void
@@ -144,7 +144,7 @@
     m_face.registerPrefix(cmdPrefix, nullptr,
       [] (const Name& cmdPrefix, const std::string& reason) {
         NDN_LOG_DEBUG("Command prefix " << cmdPrefix << " registration error: " << reason);
-        BOOST_THROW_EXCEPTION(Error("Command prefix registration failed"));
+        NDN_THROW(Error("Command prefix registration failed"));
       });
 
     m_dispatcher.addTopPrefix(cmdPrefix);
diff --git a/src/repo.hpp b/src/repo.hpp
index 07e8945..9b7630e 100644
--- a/src/repo.hpp
+++ b/src/repo.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -31,6 +31,7 @@
 #include "common.hpp"
 
 #include <ndn-cxx/mgmt/dispatcher.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
 #include <ndn-cxx/security/validator-config.hpp>
 
 #include <boost/property_tree/info_parser.hpp>
@@ -40,7 +41,7 @@
 
 struct RepoConfig
 {
-  static const size_t DISABLED_SUBSET_LENGTH = -1;
+  static constexpr size_t DISABLED_SUBSET_LENGTH = -1;
 
   std::string repoConfigPath;
   std::string dbPath;
@@ -61,11 +62,7 @@
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
 public:
@@ -88,8 +85,8 @@
   ndn::mgmt::Dispatcher m_dispatcher;
   std::shared_ptr<Storage> m_store;
   RepoStorage m_storageHandle;
-  KeyChain m_keyChain;
-  ValidatorConfig m_validator;
+  ndn::KeyChain m_keyChain;
+  ndn::security::ValidatorConfig m_validator;
 
   ReadHandle m_readHandle;
   WriteHandle m_writeHandle;
diff --git a/src/storage/repo-storage.hpp b/src/storage/repo-storage.hpp
index fe355ad..62d8fa4 100644
--- a/src/storage/repo-storage.hpp
+++ b/src/storage/repo-storage.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -25,8 +25,6 @@
 
 #include <ndn-cxx/util/signal.hpp>
 
-#include <queue>
-
 namespace repo {
 
 /**
@@ -39,14 +37,9 @@
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
-public:
   explicit
   RepoStorage(Storage& store);
 
@@ -96,7 +89,7 @@
 
 private:
   Storage& m_storage;
-  const int NOTFOUND = -1;
+  static constexpr int NOTFOUND = -1;
 };
 
 } // namespace repo
diff --git a/src/storage/sqlite-storage.hpp b/src/storage/sqlite-storage.hpp
index 217f9d0..6c6006d 100644
--- a/src/storage/sqlite-storage.hpp
+++ b/src/storage/sqlite-storage.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -22,33 +22,17 @@
 
 #include "storage.hpp"
 
-#include <algorithm>
-#include <iostream>
-#include <queue>
-#include <stdlib.h>
-#include <string>
 #include <sqlite3.h>
-#include <vector>
 
 namespace repo {
 
 class SqliteStorage : public Storage
 {
 public:
-  class Error : public std::runtime_error
-  {
-  public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
-  };
-
   explicit
   SqliteStorage(const std::string& dbPath);
 
-  ~SqliteStorage();
+  ~SqliteStorage() override;
 
   /**
    *  @brief  put the data into database
@@ -92,7 +76,6 @@
   std::string m_dbPath;
 };
 
-
 } // namespace repo
 
 #endif // REPO_STORAGE_SQLITE_STORAGE_HPP
diff --git a/src/storage/storage.hpp b/src/storage/storage.hpp
index d724eb1..abda77c 100644
--- a/src/storage/storage.hpp
+++ b/src/storage/storage.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -21,26 +21,19 @@
 #define REPO_STORAGE_STORAGE_HPP
 
 #include "../common.hpp"
-#include <string>
-#include <iostream>
-#include <stdlib.h>
 
 namespace repo {
 
 /**
-  * @brief Storage is a virtual abstract class which will be called by SqliteStorage
-  */
+ * @brief Storage is a virtual abstract class which will be called by SqliteStorage
+ */
 class Storage : noncopyable
 {
 public:
   class Error : public std::runtime_error
   {
   public:
-    explicit
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
+    using std::runtime_error::runtime_error;
   };
 
 public: