Remove use of deprecated code

Change-Id: I721e9d0f9b41e7a53d75b1fde4a718c349273eeb
Refs: #3988
diff --git a/examples/data-producer.cpp b/examples/data-producer.cpp
index 73f731a..20692c5 100644
--- a/examples/data-producer.cpp
+++ b/examples/data-producer.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -14,15 +14,15 @@
  * PURPOSE.  See the GNU General Public License for more details.
  *
  * 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/>.
+ * repo-ng, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 /**
  * This file demonstrates how to generate data to be stored in repo with repo watch
  * protocol and repo insert protocol.
  * The details of the protocols can be find here
- *  <http://redmine.named-data.net/projects/repo-ng/wiki/Watched_Prefix_Insertion_Protocol>
- *  <http://redmine.named-data.net/projects/repo-ng/wiki/Basic_Repo_Insertion_Protocol>
+ *  <https://redmine.named-data.net/projects/repo-ng/wiki/Watched_Prefix_Insertion_Protocol>
+ *  <https://redmine.named-data.net/projects/repo-ng/wiki/Basic_Repo_Insertion_Protocol>
  *
  * This file is used for debugging purpose. There are two modes for users to assign
  * names for the data.
@@ -87,7 +87,7 @@
   void
   generateFromFile();
 
-  ndn::shared_ptr<ndn::Data>
+  std::shared_ptr<ndn::Data>
   createData(const ndn::Name& name);
 public:
   std::ifstream insertStream;
@@ -109,11 +109,11 @@
 
   if (mode == AUTO) {
     m_scheduler.scheduleEvent(timeInterval,
-                            ndn::bind(&Publisher::autoGenerate, this));
+                            bind(&Publisher::autoGenerate, this));
   }
   else {
     m_scheduler.scheduleEvent(timeInterval,
-                              ndn::bind(&Publisher::generateFromFile, this));
+                              bind(&Publisher::generateFromFile, this));
   }
   m_face.processEvents(duration);
 }
@@ -123,11 +123,11 @@
 {
   Name name = dataPrefix;
   name.appendNumber(m_range());
-  ndn::shared_ptr<Data> data = createData(name);
+  std::shared_ptr<Data> data = createData(name);
   // std::cout<<"data name = "<<data->getName()<<std::endl;
   m_face.put(*data);
   m_scheduler.scheduleEvent(timeInterval,
-                            ndn::bind(&Publisher::autoGenerate, this));
+                            bind(&Publisher::autoGenerate, this));
 }
 
 void
@@ -139,19 +139,19 @@
    }
   std::string name;
   getline(insertStream, name);
-  ndn::shared_ptr<Data> data = createData(Name(name));
+  std::shared_ptr<Data> data = createData(Name(name));
   m_face.put(*data);
   m_scheduler.scheduleEvent(timeInterval,
-                            ndn::bind(&Publisher::generateFromFile, this));
+                            bind(&Publisher::generateFromFile, this));
 }
 
-ndn::shared_ptr<Data>
+std::shared_ptr<Data>
 Publisher::createData(const Name& name)
 {
   static ndn::KeyChain keyChain;
   static std::vector<uint8_t> content(1500, '-');
 
-  ndn::shared_ptr<ndn::Data> data = ndn::make_shared<Data>();
+  std::shared_ptr<ndn::Data> data = std::make_shared<Data>();
   data->setName(name);
   data->setContent(&content[0], content.size());
   keyChain.sign(*data);
@@ -203,7 +203,7 @@
       try {
         generator.duration = milliseconds(boost::lexical_cast<uint64_t>(optarg));
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-s option should be an integer.";
         return 1;
       }
@@ -212,7 +212,7 @@
       try {
         generator.timeInterval = milliseconds(boost::lexical_cast<uint64_t>(optarg));
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-t option should be an integer.";
         return 1;
       }
@@ -244,7 +244,7 @@
   try {
     return repo::main(argc, argv);
   }
-  catch (std::exception& e) {
+  catch (const std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
     return 2;
   }
diff --git a/src/handles/base-handle.hpp b/src/handles/base-handle.hpp
index 95b8caa..a598883 100644
--- a/src/handles/base-handle.hpp
+++ b/src/handles/base-handle.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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,7 +31,7 @@
 class BaseHandle : noncopyable
 {
 public:
-  class Error : std::runtime_error
+  class Error : public std::runtime_error
   {
   public:
     explicit
diff --git a/src/handles/delete-handle.cpp b/src/handles/delete-handle.cpp
index 5cd0506..5cfbea2 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,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -40,7 +40,7 @@
 void
 DeleteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
 {
-  throw Error("Delete prefix registration failed");
+  BOOST_THROW_EXCEPTION(Error("Delete prefix registration failed"));
 }
 
 
@@ -54,7 +54,7 @@
 void
 DeleteHandle::onCheckRegisterFailed(const Name& prefix, const std::string& reason)
 {
-  throw Error("Delete check prefix registration failed");
+  BOOST_THROW_EXCEPTION(Error("Delete check prefix registration failed"));
 }
 
 
@@ -194,4 +194,4 @@
   }
 }
 
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/tcp-bulk-insert-handle.cpp b/src/handles/tcp-bulk-insert-handle.cpp
index a445110..1d81b17 100644
--- a/src/handles/tcp-bulk-insert-handle.cpp
+++ b/src/handles/tcp-bulk-insert-handle.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2015,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -84,7 +84,7 @@
   ip::tcp::resolver::iterator end;
 
   if (endpoint == end)
-    throw Error("Cannot listen on [" + host + ":" + port + "]");
+    BOOST_THROW_EXCEPTION(Error("Cannot listen on [" + host + ":" + port + "]"));
 
   m_localEndpoint = *endpoint;
   std::cerr << "Start listening on " << m_localEndpoint  << std::endl;
@@ -179,7 +179,7 @@
         else
           std::cerr << "FAILED to inject " << data.getName() << std::endl;
       }
-      catch (std::runtime_error& error) {
+      catch (const std::runtime_error& error) {
         /// \todo Catch specific error after determining what wireDecode() can throw
         std::cerr << "Error decoding received Data packet" << std::endl;
       }
diff --git a/src/handles/watch-handle.cpp b/src/handles/watch-handle.cpp
index 9e80212..25ce278 100644
--- a/src/handles/watch-handle.cpp
+++ b/src/handles/watch-handle.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -68,7 +68,7 @@
 WatchHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
 {
   std::cerr << reason << std::endl;
-  throw Error("watch prefix registration failed");
+  BOOST_THROW_EXCEPTION(Error("watch prefix registration failed"));
 }
 
 void
@@ -106,7 +106,7 @@
 }
 
 void
-WatchHandle::onData(const Interest& interest, ndn::Data& data, const Name& name)
+WatchHandle::onData(const Interest& interest, const ndn::Data& data, const Name& name)
 {
   m_validator.validate(data,
                        bind(&WatchHandle::onDataValidated, this, interest, _1, name),
@@ -148,10 +148,11 @@
     ++m_interestNum;
     getFace().expressInterest(fetchInterest,
                               bind(&WatchHandle::onData, this, _1, _2, name),
+                              bind(&WatchHandle::onTimeout, this, _1, name), // Nack
                               bind(&WatchHandle::onTimeout, this, _1, name));
   }
   else {
-    throw Error("Insert into Repo Failed");
+    BOOST_THROW_EXCEPTION(Error("Insert into Repo Failed"));
   }
   m_processes[name].first.setInsertNum(m_size);
 }
@@ -190,6 +191,7 @@
   ++m_interestNum;
   getFace().expressInterest(fetchInterest,
                             bind(&WatchHandle::onData, this, _1, _2, name),
+                            bind(&WatchHandle::onTimeout, this, _1, name), // Nack
                             bind(&WatchHandle::onTimeout, this, _1, name));
 }
 
@@ -211,6 +213,7 @@
   ++m_interestNum;
   getFace().expressInterest(fetchInterest,
                             bind(&WatchHandle::onData, this, _1, _2, name),
+                            bind(&WatchHandle::onTimeout, this, _1, name), // Nack
                             bind(&WatchHandle::onTimeout, this, _1, name));
 
 }
@@ -310,7 +313,7 @@
 WatchHandle::deferredDeleteProcess(const Name& name)
 {
   getScheduler().scheduleEvent(PROCESS_DELETE_TIME,
-                               ndn::bind(&WatchHandle::deleteProcess, this, name));
+                               bind(&WatchHandle::deleteProcess, this, name));
 }
 
 void
@@ -351,6 +354,7 @@
   m_interestNum++;
   getFace().expressInterest(fetchInterest,
                             bind(&WatchHandle::onData, this, _1, _2, parameter.getName()),
+                            bind(&WatchHandle::onTimeout, this, _1, parameter.getName()), // Nack
                             bind(&WatchHandle::onTimeout, this, _1, parameter.getName()));
 }
 
@@ -377,4 +381,4 @@
   return true;
 }
 
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/watch-handle.hpp b/src/handles/watch-handle.hpp
index 2fde3cf..f34b1fb 100644
--- a/src/handles/watch-handle.hpp
+++ b/src/handles/watch-handle.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -87,7 +87,7 @@
    * @brief fetch data and send next interest
    */
   void
-  onData(const Interest& interest, Data& data, const Name& name);
+  onData(const Interest& interest, const Data& data, const Name& name);
 
   /**
    * @brief handle when fetching one data timeout
@@ -169,4 +169,4 @@
 
 } // namespace repo
 
-#endif // REPO_HANDLES_Watch_HANDLE_HPP
+#endif // REPO_HANDLES_WATCH_HANDLE_HPP
diff --git a/src/handles/write-handle.cpp b/src/handles/write-handle.cpp
index 08e951b..16c622e 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,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -59,7 +59,7 @@
 WriteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
 {
   std::cerr << reason << std::endl;
-  throw Error("Insert prefix registration failed");
+  BOOST_THROW_EXCEPTION(Error("Insert prefix registration failed"));
 }
 
 // onRegisterFailed for insert.
@@ -67,7 +67,7 @@
 WriteHandle::onCheckRegisterFailed(const Name& prefix, const std::string& reason)
 {
   std::cerr << reason << std::endl;
-  throw Error("Insert check prefix registration failed");
+  BOOST_THROW_EXCEPTION(Error("Insert check prefix registration failed"));
 }
 
 void
@@ -106,7 +106,7 @@
 }
 
 void
-WriteHandle::onData(const Interest& interest, Data& data, ProcessId processId)
+WriteHandle::onData(const Interest& interest, const Data& data, ProcessId processId)
 {
   m_validator.validate(data,
                        bind(&WriteHandle::onDataValidated, this, interest, _1, processId),
@@ -143,7 +143,7 @@
 }
 
 void
-WriteHandle::onSegmentData(const Interest& interest, Data& data, ProcessId processId)
+WriteHandle::onSegmentData(const Interest& interest, const Data& data, ProcessId processId)
 {
   m_validator.validate(data,
                        bind(&WriteHandle::onSegmentDataValidated, this, interest, _1, processId),
@@ -247,6 +247,7 @@
     interest.setInterestLifetime(m_interestLifetime);
     getFace().expressInterest(interest,
                               bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+                              bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
                               bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
     process.credit--;
     processRetry[segment] = 0;
@@ -341,6 +342,7 @@
   fetchInterest.setInterestLifetime(m_interestLifetime);
   getFace().expressInterest(fetchInterest,
                             bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+                            bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
                             bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
   //When an interest is expressed, processCredit--
   processCredit--;
@@ -392,6 +394,7 @@
     retryInterest.setInterestLifetime(m_interestLifetime);
     getFace().expressInterest(retryInterest,
                               bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+                              bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
                               bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
   }
 
@@ -464,7 +467,7 @@
 WriteHandle::deferredDeleteProcess(ProcessId processId)
 {
   getScheduler().scheduleEvent(PROCESS_DELETE_TIME,
-                               ndn::bind(&WriteHandle::deleteProcess, this, processId));
+                               bind(&WriteHandle::deleteProcess, this, processId));
 }
 
 void
@@ -491,6 +494,7 @@
   }
   getFace().expressInterest(fetchInterest,
                             bind(&WriteHandle::onData, this, _1, _2, processId),
+                            bind(&WriteHandle::onTimeout, this, _1, processId), // Nack
                             bind(&WriteHandle::onTimeout, this, _1, processId));
 }
 
@@ -569,4 +573,4 @@
   reply(interest, response);
 }
 
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/write-handle.hpp b/src/handles/write-handle.hpp
index 1c64437..a02f675 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,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -125,7 +125,7 @@
    * @brief fetch one data
    */
   void
-  onData(const Interest& interest, Data& data, ProcessId processId);
+  onData(const Interest& interest, const Data& data, ProcessId processId);
 
   void
   onDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,
@@ -145,7 +145,7 @@
    * @brief fetch segmented data
    */
   void
-  onSegmentData(const Interest& interest, Data& data, ProcessId processId);
+  onSegmentData(const Interest& interest, const Data& data, ProcessId processId);
 
   void
   onSegmentDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,
diff --git a/src/repo-command-parameter.hpp b/src/repo-command-parameter.hpp
index 22a8bcd..3648679 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,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -38,7 +38,7 @@
 
 /**
 * @brief Class defining abstraction of parameter of command for NDN Repo Protocol
-* @sa link http://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#RepoCommandParameter
+* @sa link https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#RepoCommandParameter
 **/
 
 class RepoCommandParameter
@@ -370,7 +370,7 @@
   m_wire.parse();
 
   if (m_wire.type() != tlv::RepoCommandParameter)
-    throw Error("Requested decoding of RepoCommandParameter, but Block is of different type");
+    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);
diff --git a/src/repo-command-response.hpp b/src/repo-command-response.hpp
index 79dc027..d8f1fe8 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,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -35,7 +35,7 @@
 
 /**
 * @brief Class defining abstraction of Response for NDN Repo Protocol
-* @sa link http://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#Repo-Command-Response
+* @sa link https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#Repo-Command-Response
 */
 class RepoCommandResponse
 {
@@ -262,8 +262,9 @@
     totalLength += variableLength;
     totalLength += encoder.prependVarNumber(variableLength);
     totalLength += encoder.prependVarNumber(tlv::StatusCode);
-  } else {
-    throw Error("required field StatusCode is missing");
+  }
+  else {
+    BOOST_THROW_EXCEPTION(Error("required field StatusCode is missing"));
   }
 
   if (m_hasProcessId) {
@@ -311,7 +312,7 @@
   Block::element_const_iterator val;
 
   if (m_wire.type() != tlv::RepoCommandResponse)
-    throw Error("RepoCommandResponse malformed");
+    BOOST_THROW_EXCEPTION(Error("RepoCommandResponse malformed"));
 
   // StartBlockId
   val = m_wire.find(tlv::StartBlockId);
@@ -344,8 +345,9 @@
     m_hasStatusCode = true;
     m_statusCode = readNonNegativeInteger(*val);
 
-  } else {
-    throw Error("required field StatusCode is missing");
+  }
+  else {
+    BOOST_THROW_EXCEPTION(Error("required field StatusCode is missing"));
   }
 
   // InsertNum
diff --git a/src/repo.cpp b/src/repo.cpp
index 0ec3837..dcf7007 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,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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,15 +31,15 @@
 
   std::ifstream fin(configPath.c_str());
   if (!fin.is_open())
-    throw Repo::Error("failed to open configuration file '"+ configPath +"'");
+    BOOST_THROW_EXCEPTION(Repo::Error("failed to open configuration file '"+ configPath +"'"));
 
   using namespace boost::property_tree;
   ptree propertyTree;
   try {
     read_info(fin, propertyTree);
   }
-  catch (ptree_error& e) {
-    throw Repo::Error("failed to read configuration file '"+ configPath +"'");
+  catch (const ptree_error& e) {
+    BOOST_THROW_EXCEPTION(Repo::Error("failed to read configuration file '"+ configPath +"'"));
   }
 
   ptree repoConf = propertyTree.get_child("repo");
@@ -55,8 +55,8 @@
     if (it->first == "prefix")
       repoConfig.dataPrefixes.push_back(Name(it->second.get_value<std::string>()));
     else
-      throw Repo::Error("Unrecognized '" + it->first + "' option in 'data' section in "
-                        "configuration file '"+ configPath +"'");
+      BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'data' section in "
+                                        "configuration file '"+ configPath +"'"));
   }
 
   ptree commandConf = repoConf.get_child("command");
@@ -67,8 +67,8 @@
     if (it->first == "prefix")
       repoConfig.repoPrefixes.push_back(Name(it->second.get_value<std::string>()));
     else
-      throw Repo::Error("Unrecognized '" + it->first + "' option in 'command' section in "
-                        "configuration file '"+ configPath +"'");
+      BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'command' section in "
+                                        "configuration file '"+ configPath +"'"));
   }
 
   ptree tcpBulkInsert = repoConf.get_child("tcp_bulk_insert");
@@ -92,15 +92,16 @@
       port = it->second.get_value<std::string>();
     }
     else
-      throw Repo::Error("Unrecognized '" + it->first + "' option in 'tcp_bulk_insert' section in "
-                        "configuration file '"+ configPath +"'");
+      BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'tcp_bulk_insert' section in "
+                                        "configuration file '"+ configPath +"'"));
   }
   if (isTcpBulkEnabled) {
     repoConfig.tcpBulkInsertEndpoints.push_back(std::make_pair(host, port));
   }
 
-  if (repoConf.get<std::string>("storage.method") != "sqlite")
-    throw Repo::Error("Only 'sqlite' storage method is supported");
+  if (repoConf.get<std::string>("storage.method") != "sqlite") {
+    BOOST_THROW_EXCEPTION(Repo::Error("Only 'sqlite' storage method is supported"));
+  }
 
   repoConfig.dbPath = repoConf.get<std::string>("storage.path");
 
diff --git a/src/storage/index.cpp b/src/storage/index.cpp
index 572dc97..3197a70 100644
--- a/src/storage/index.cpp
+++ b/src/storage/index.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -67,7 +67,7 @@
 Index::insert(const Data& data, int64_t id)
 {
   if (isFull())
-    throw Error("The Index is Full. Cannot Insert Any Data!");
+    BOOST_THROW_EXCEPTION(Error("The Index is Full. Cannot Insert Any Data!"));
   Entry entry(data, id);
   bool isInserted = m_indexContainer.insert(entry).second;
   if (isInserted)
@@ -80,7 +80,7 @@
               const ndn::ConstBufferPtr& keyLocatorHash)
 {
   if (isFull())
-    throw Error("The Index is Full. Cannot Insert Any Data!");
+    BOOST_THROW_EXCEPTION(Error("The Index is Full. Cannot Insert Any Data!"));
   Entry entry(fullName, keyLocatorHash, id);
   bool isInserted = m_indexContainer.insert(entry).second;
   if (isInserted)
@@ -160,7 +160,7 @@
 Index::computeKeyLocatorHash(const KeyLocator& keyLocator)
 {
   const Block& block = keyLocator.wireEncode();
-  ndn::ConstBufferPtr keyLocatorHash = ndn::crypto::sha256(block.wire(), block.size());
+  ndn::ConstBufferPtr keyLocatorHash = ndn::crypto::computeSha256Digest(block.wire(), block.size());
   return keyLocatorHash;
 }
 
@@ -175,7 +175,7 @@
     {
       KeyLocator keyLocator = interest.getPublisherPublicKeyLocator();
       const Block& block = keyLocator.wireEncode();
-      hash = ndn::crypto::sha256(block.wire(), block.size());
+      hash = ndn::crypto::computeSha256Digest(block.wire(), block.size());
     }
 
   if (isLeftmost)
diff --git a/src/storage/repo-storage.cpp b/src/storage/repo-storage.cpp
index 381ccaa..49873d7 100644
--- a/src/storage/repo-storage.cpp
+++ b/src/storage/repo-storage.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -46,7 +46,7 @@
 {
    bool isExist = m_index.hasData(data);
    if (isExist)
-     throw Error("The Entry Has Already In the Skiplist. Cannot be Inserted!");
+     BOOST_THROW_EXCEPTION(Error("The Entry Has Already In the Skiplist. Cannot be Inserted!"));
    int64_t id = m_storage.insert(data);
    if (id == -1)
      return false;
diff --git a/src/storage/sqlite-storage.cpp b/src/storage/sqlite-storage.cpp
index 7edcda7..ae380ea 100644
--- a/src/storage/sqlite-storage.cpp
+++ b/src/storage/sqlite-storage.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -40,7 +40,7 @@
     boost::filesystem::file_status fsPathStatus = boost::filesystem::status(fsPath);
     if (!boost::filesystem::is_directory(fsPathStatus)) {
       if (!boost::filesystem::create_directory(boost::filesystem::path(fsPath))) {
-        throw Error("Folder '" + dbPath + "' does not exists and cannot be created");
+        BOOST_THROW_EXCEPTION(Error("Folder '" + dbPath + "' does not exists and cannot be created"));
       }
     }
 
@@ -75,7 +75,7 @@
   }
   else {
     std::cerr << "Database file open failure rc:" << rc << std::endl;
-    throw Error("Database file open failure");
+    BOOST_THROW_EXCEPTION(Error("Database file open failure"));
   }
   sqlite3_exec(m_db, "PRAGMA synchronous = OFF", 0, 0, &errMsg);
   sqlite3_exec(m_db, "PRAGMA journal_mode = WAL", 0, 0, &errMsg);
@@ -87,15 +87,14 @@
 }
 
 void
-SqliteStorage::fullEnumerate(const ndn::function
-                             <void(const Storage::ItemMeta)>& f)
+SqliteStorage::fullEnumerate(const std::function<void(const Storage::ItemMeta)>& f)
 {
   sqlite3_stmt* m_stmt = 0;
   int rc = SQLITE_DONE;
   string sql = string("SELECT id, name, keylocatorHash FROM NDN_REPO;");
   rc = sqlite3_prepare_v2(m_db, sql.c_str(), -1, &m_stmt, 0);
   if (rc != SQLITE_OK)
-    throw Error("Initiation Read Entries from Database Prepare error");
+    BOOST_THROW_EXCEPTION(Error("Initiation Read Entries from Database Prepare error"));
   int entryNumber = 0;
   while (true) {
     rc = sqlite3_step(m_stmt);
@@ -124,7 +123,7 @@
     else {
       std::cerr << "Initiation Read Entries rc:" << rc << std::endl;
       sqlite3_finalize(m_stmt);
-      throw Error("Initiation Read Entries error");
+      BOOST_THROW_EXCEPTION(Error("Initiation Read Entries error"));
     }
   }
   m_size = entryNumber;
@@ -168,14 +167,14 @@
     if (rc == SQLITE_CONSTRAINT) {
       std::cerr << "Insert  failed" << std::endl;
       sqlite3_finalize(insertStmt);
-      throw Error("Insert failed");
+      BOOST_THROW_EXCEPTION(Error("Insert failed"));
      }
     sqlite3_reset(insertStmt);
      m_size++;
      id = sqlite3_last_insert_rowid(m_db);
   }
   else {
-    throw Error("Some error with insert");
+    BOOST_THROW_EXCEPTION(Error("Some error with insert"));
   }
 
   sqlite3_finalize(insertStmt);
@@ -193,7 +192,7 @@
   if (sqlite3_prepare_v2(m_db, deleteSql.c_str(), -1, &deleteStmt, 0) != SQLITE_OK) {
     sqlite3_finalize(deleteStmt);
     std::cerr << "delete statement prepared failed" << std::endl;
-    throw Error("delete statement prepared failed");
+    BOOST_THROW_EXCEPTION(Error("delete statement prepared failed"));
   }
 
   if (sqlite3_bind_int64(deleteStmt, 1, id) == SQLITE_OK) {
@@ -201,7 +200,7 @@
     if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
       std::cerr << " node delete error rc:" << rc << std::endl;
       sqlite3_finalize(deleteStmt);
-      throw Error(" node delete error");
+      BOOST_THROW_EXCEPTION(Error(" node delete error"));
     }
     if (sqlite3_changes(m_db) != 1)
       return false;
@@ -210,7 +209,7 @@
   else {
     std::cerr << "delete bind error" << std::endl;
     sqlite3_finalize(deleteStmt);
-    throw Error("delete bind error");
+    BOOST_THROW_EXCEPTION(Error("delete bind error"));
   }
   sqlite3_finalize(deleteStmt);
   return true;
@@ -239,20 +238,20 @@
       else {
         std::cerr << "Database query failure rc:" << rc << std::endl;
         sqlite3_finalize(queryStmt);
-        throw Error("Database query failure");
+        BOOST_THROW_EXCEPTION(Error("Database query failure"));
       }
     }
     else {
       std::cerr << "select bind error" << std::endl;
       sqlite3_finalize(queryStmt);
-      throw Error("select bind error");
+      BOOST_THROW_EXCEPTION(Error("select bind error"));
     }
     sqlite3_finalize(queryStmt);
   }
   else {
     sqlite3_finalize(queryStmt);
     std::cerr << "select statement prepared failed" << std::endl;
-    throw Error("select statement prepared failed");
+    BOOST_THROW_EXCEPTION(Error("select statement prepared failed"));
   }
   return shared_ptr<Data>();
 }
@@ -267,7 +266,7 @@
     {
       std::cerr << "Database query failure rc:" << rc << std::endl;
       sqlite3_finalize(queryStmt);
-      throw Error("Database query failure");
+      BOOST_THROW_EXCEPTION(Error("Database query failure"));
     }
 
   rc = sqlite3_step(queryStmt);
@@ -275,7 +274,7 @@
     {
       std::cerr << "Database query failure rc:" << rc << std::endl;
       sqlite3_finalize(queryStmt);
-      throw Error("Database query failure");
+      BOOST_THROW_EXCEPTION(Error("Database query failure"));
     }
 
   int64_t nDatas = sqlite3_column_int64(queryStmt, 0);
@@ -285,4 +284,4 @@
   return nDatas;
 }
 
-} //namespace repo
+} // namespace repo
diff --git a/tests/dataset-fixtures.hpp b/tests/dataset-fixtures.hpp
index 9321c9f..f60526b 100644
--- a/tests/dataset-fixtures.hpp
+++ b/tests/dataset-fixtures.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -41,17 +41,17 @@
     }
   };
 
-  typedef std::list<ndn::shared_ptr<ndn::Data> > DataContainer;
+  typedef std::list<std::shared_ptr<ndn::Data> > DataContainer;
   DataContainer data;
 
-  typedef std::list<std::pair<ndn::Interest, ndn::shared_ptr<ndn::Data> > > InterestContainer;
+  typedef std::list<std::pair<ndn::Interest, std::shared_ptr<ndn::Data> > > InterestContainer;
   InterestContainer interests;
 
   typedef std::list<std::pair<ndn::Interest, size_t > > RemovalsContainer;
   RemovalsContainer removals;
 
 protected:
-  ndn::shared_ptr<ndn::Data>
+  std::shared_ptr<ndn::Data>
   createData(const ndn::Name& name)
   {
     if (map.count(name) > 0)
@@ -60,7 +60,7 @@
     static ndn::KeyChain keyChain;
     static std::vector<uint8_t> content(1500, '-');
 
-    ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
+    std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
     data->setName(name);
     data->setContent(&content[0], content.size());
     keyChain.sign(*data);
@@ -69,13 +69,13 @@
     return data;
   }
 
-  ndn::shared_ptr<ndn::Data>
+  std::shared_ptr<ndn::Data>
   getData(const ndn::Name& name)
   {
     if (map.count(name) > 0)
       return map[name];
     else
-      throw Error("Data with name " + name.toUri() + " is not found");
+      BOOST_THROW_EXCEPTION(Error("Data with name " + name.toUri() + " is not found"));
   }
 
 private:
@@ -100,7 +100,7 @@
     for (size_t i = 0; i < N; i++) {
       ndn::Name name(baseName);
       name.appendSegment(i);
-      ndn::shared_ptr<Data> data = createData(name);
+      std::shared_ptr<Data> data = createData(name);
       this->data.push_back(data);
 
       this->interests.push_back(std::make_pair(Interest(name), data));
diff --git a/tests/integrated/test-basic-command-insert-delete.cpp b/tests/integrated/test-basic-command-insert-delete.cpp
index 10775f7..f9e58e3 100644
--- a/tests/integrated/test-basic-command-insert-delete.cpp
+++ b/tests/integrated/test-basic-command-insert-delete.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -89,10 +89,10 @@
 
 
   void
-  onInsertData(const Interest& interest, Data& data);
+  onInsertData(const Interest& interest, const Data& data);
 
   void
-  onDeleteData(const Interest& interest, Data& data);
+  onDeleteData(const Interest& interest, const Data& data);
 
   void
   onInsertTimeout(const Interest& interest);
@@ -179,7 +179,7 @@
 }
 
 template<class T> void
-Fixture<T>::onInsertData(const Interest& interest, Data& data)
+Fixture<T>::onInsertData(const Interest& interest, const Data& data)
 {
   RepoCommandResponse response;
   response.wireDecode(data.getContent().blockFromValue());
@@ -189,7 +189,7 @@
 }
 
 template<class T> void
-Fixture<T>::onDeleteData(const Interest& interest, Data& data)
+Fixture<T>::onDeleteData(const Interest& interest, const Data& data)
 {
   RepoCommandResponse response;
   response.wireDecode(data.getContent().blockFromValue());
@@ -218,6 +218,7 @@
 {
   insertFace.expressInterest(insertInterest,
                              bind(&Fixture<T>::onInsertData, this, _1, _2),
+                             bind(&Fixture<T>::onInsertTimeout, this, _1), // Nack
                              bind(&Fixture<T>::onInsertTimeout, this, _1));
 }
 
@@ -226,6 +227,7 @@
 {
   deleteFace.expressInterest(deleteInterest,
                              bind(&Fixture<T>::onDeleteData, this, _1, _2),
+                             bind(&Fixture<T>::onDeleteTimeout, this, _1), // Nack
                              bind(&Fixture<T>::onDeleteTimeout, this, _1));
 }
 
@@ -328,5 +330,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
-} //namespace tests
-} //namespace repo
+} // namespace tests
+} // namespace repo
diff --git a/tests/integrated/test-basic-command-watch.cpp b/tests/integrated/test-basic-command-watch.cpp
index ae06eb1..8c4c13e 100644
--- a/tests/integrated/test-basic-command-watch.cpp
+++ b/tests/integrated/test-basic-command-watch.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -36,7 +36,7 @@
 using ndn::time::milliseconds;
 using ndn::time::seconds;
 using ndn::EventId;
-namespace random=ndn::random;
+namespace random = ndn::random;
 
 //All the test cases in this test suite should be run at once.
 BOOST_AUTO_TEST_SUITE(TestBasicCommandWatchDelete)
@@ -80,10 +80,10 @@
   stopFaceProcess();
 
   void
-  onWatchData(const Interest& interest, Data& data);
+  onWatchData(const Interest& interest, const Data& data);
 
   void
-  onWatchStopData(const Interest& interest, Data& data);
+  onWatchStopData(const Interest& interest, const Data& data);
 
   void
   onWatchTimeout(const Interest& interest);
@@ -158,7 +158,7 @@
 }
 
 template<class T> void
-Fixture<T>::onWatchData(const Interest& interest, Data& data)
+Fixture<T>::onWatchData(const Interest& interest, const Data& data)
 {
   RepoCommandResponse response;
   response.wireDecode(data.getContent().blockFromValue());
@@ -168,7 +168,7 @@
 }
 
 template<class T> void
-Fixture<T>::onWatchStopData(const Interest& interest, Data& data)
+Fixture<T>::onWatchStopData(const Interest& interest, const Data& data)
 {
   RepoCommandResponse response;
   response.wireDecode(data.getContent().blockFromValue());
@@ -188,6 +188,7 @@
 {
   watchFace.expressInterest(watchInterest,
                             bind(&Fixture<T>::onWatchData, this, _1, _2),
+                            bind(&Fixture<T>::onWatchTimeout, this, _1), // Nack
                             bind(&Fixture<T>::onWatchTimeout, this, _1));
 }
 
@@ -196,6 +197,7 @@
 {
   watchFace.expressInterest(watchInterest,
                             bind(&Fixture<T>::onWatchStopData, this, _1, _2),
+                            bind(&Fixture<T>::onWatchTimeout, this, _1), // Nack
                             bind(&Fixture<T>::onWatchTimeout, this, _1));
 }
 
@@ -263,5 +265,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
-} //namespace tests
-} //namespace repo
+} // namespace tests
+} // namespace repo
diff --git a/tests/integrated/test-basic-interest-read.cpp b/tests/integrated/test-basic-interest-read.cpp
index d4eba2e..79a7e8f 100644
--- a/tests/integrated/test-basic-interest-read.cpp
+++ b/tests/integrated/test-basic-interest-read.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -74,7 +74,7 @@
       Interest readInterest((*i)->getName());
       readInterest.setMustBeFresh(true);
       scheduler.scheduleEvent(ndn::time::milliseconds(timeCount * 50),
-                              ndn::bind(&BasicInterestReadFixture<Dataset>::sendInterest, this,
+                              bind(&BasicInterestReadFixture<Dataset>::sendInterest, this,
                                         readInterest));
       timeCount++;
     }
@@ -87,7 +87,7 @@
   }
 
   void
-  onReadData(const ndn::Interest& interest, ndn::Data& data)
+  onReadData(const ndn::Interest& interest, const ndn::Data& data)
   {
     int rc = memcmp(data.getContent().value(), content, sizeof(content));
     BOOST_CHECK_EQUAL(rc, 0);
@@ -104,6 +104,7 @@
   {
     readFace.expressInterest(interest,
                              bind(&BasicInterestReadFixture::onReadData, this, _1, _2),
+                             bind(&BasicInterestReadFixture::onReadTimeout, this, _1), // Nack
                              bind(&BasicInterestReadFixture::onReadTimeout, this, _1));
   }
 
@@ -134,16 +135,16 @@
 
   this->startListen();
   this->scheduler.scheduleEvent(ndn::time::seconds(0),
-                                ndn::bind(&BasicInterestReadFixture<T>::scheduleReadEvent, this));
+                                bind(&BasicInterestReadFixture<T>::scheduleReadEvent, this));
 
   // schedule an event to terminate IO
   this->scheduler.scheduleEvent(ndn::time::seconds(20),
-                                ndn::bind(&BasicInterestReadFixture<T>::stopFaceProcess, this));
+                                bind(&BasicInterestReadFixture<T>::stopFaceProcess, this));
   this->repoFace.getIoService().run();
 
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
-} //namespace tests
-} //namespace repo
+} // namespace tests
+} // namespace repo
diff --git a/tools/ndngetfile.cpp b/tools/ndngetfile.cpp
index 99f54ca..1f59a36 100644
--- a/tools/ndngetfile.cpp
+++ b/tools/ndngetfile.cpp
@@ -1,6 +1,6 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -55,6 +55,7 @@
                          bind(&Consumer::onVersionedData, this, _1, _2)
                          :
                          bind(&Consumer::onUnversionedData, this, _1, _2),
+                         bind(&Consumer::onTimeout, this, _1), // Nack
                          bind(&Consumer::onTimeout, this, _1));
 }
 
@@ -72,7 +73,7 @@
 }
 
 void
-Consumer::onVersionedData(const Interest& interest, Data& data)
+Consumer::onVersionedData(const Interest& interest, const Data& data)
 {
   const Name& name = data.getName();
 
@@ -110,7 +111,7 @@
 }
 
 void
-Consumer::onUnversionedData(const Interest& interest, Data& data)
+Consumer::onUnversionedData(const Interest& interest, const Data& data)
 {
   const Name& name = data.getName();
   //std::cout<<"recevied data name = "<<name<<std::endl;
@@ -248,7 +249,7 @@
           {
             interestLifetime = boost::lexical_cast<int>(optarg);
           }
-        catch (boost::bad_lexical_cast&)
+        catch (const boost::bad_lexical_cast&)
           {
             std::cerr << "ERROR: -l option should be an integer." << std::endl;
             return 1;
@@ -260,7 +261,7 @@
           {
             timeout = boost::lexical_cast<int>(optarg);
           }
-        catch (boost::bad_lexical_cast&)
+        catch (const boost::bad_lexical_cast&)
           {
             std::cerr << "ERROR: -w option should be an integer." << std::endl;
             return 1;
diff --git a/tools/ndngetfile.hpp b/tools/ndngetfile.hpp
index 8e84440..e7e851b 100644
--- a/tools/ndngetfile.hpp
+++ b/tools/ndngetfile.hpp
@@ -1,6 +1,6 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -55,14 +55,14 @@
   fetchData(const ndn::Name& name);
 
   void
-  onVersionedData(const ndn::Interest& interest, ndn::Data& data);
+  onVersionedData(const ndn::Interest& interest, const ndn::Data& data);
 
   void
-  onUnversionedData(const ndn::Interest& interest, ndn::Data& data);
+  onUnversionedData(const ndn::Interest& interest, const ndn::Data& data);
 
   void
   onTimeout(const ndn::Interest& interest);
-  
+
   void
   readData(const ndn::Data& data);
 
diff --git a/tools/ndnputfile.cpp b/tools/ndnputfile.cpp
index 7dd92e5..f08a7a3 100644
--- a/tools/ndnputfile.cpp
+++ b/tools/ndnputfile.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2016,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -14,7 +14,7 @@
  * PURPOSE.  See the GNU General Public License for more details.
  *
  * 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/>.
+ * repo-ng, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "../src/repo-command-parameter.hpp"
@@ -50,7 +50,7 @@
 static const uint64_t DEFAULT_CHECK_PERIOD = 1000;
 static const size_t PRE_SIGN_DATA_COUNT = 11;
 
-class NdnPutFile : ndn::noncopyable
+class NdnPutFile : boost::noncopyable
 {
 public:
   class Error : public std::runtime_error
@@ -93,7 +93,7 @@
   startInsertCommand();
 
   void
-  onInsertCommandResponse(const ndn::Interest& interest, ndn::Data& data);
+  onInsertCommandResponse(const ndn::Interest& interest, const ndn::Data& data);
 
   void
   onInsertCommandTimeout(const ndn::Interest& interest);
@@ -120,7 +120,7 @@
   startCheckCommand();
 
   void
-  onCheckCommandResponse(const ndn::Interest& interest, ndn::Data& data);
+  onCheckCommandResponse(const ndn::Interest& interest, const ndn::Data& data);
 
   void
   onCheckCommandTimeout(const ndn::Interest& interest);
@@ -186,7 +186,7 @@
       boost::iostreams::read(*insertStream, reinterpret_cast<char*>(buffer), DEFAULT_BLOCK_SIZE);
 
     if (readSize <= 0) {
-      throw Error("Error reading from the input stream");
+      BOOST_THROW_EXCEPTION(Error("Error reading from the input stream"));
     }
 
     shared_ptr<ndn::Data> data =
@@ -250,17 +250,18 @@
   ndn::Interest commandInterest = generateCommandInterest(repoPrefix, "insert", parameters);
   m_face.expressInterest(commandInterest,
                          bind(&NdnPutFile::onInsertCommandResponse, this, _1, _2),
+                         bind(&NdnPutFile::onInsertCommandTimeout, this, _1), // Nack
                          bind(&NdnPutFile::onInsertCommandTimeout, this, _1));
 }
 
 void
-NdnPutFile::onInsertCommandResponse(const ndn::Interest& interest, ndn::Data& data)
+NdnPutFile::onInsertCommandResponse(const ndn::Interest& interest, const ndn::Data& data)
 {
   RepoCommandResponse response(data.getContent().blockFromValue());
   int statusCode = response.getStatusCode();
   if (statusCode >= 400) {
-    throw Error("insert command failed with code " +
-                boost::lexical_cast<std::string>(statusCode));
+    BOOST_THROW_EXCEPTION(Error("insert command failed with code " +
+                                boost::lexical_cast<std::string>(statusCode)));
   }
   m_processId = response.getProcessId();
 
@@ -271,7 +272,7 @@
 void
 NdnPutFile::onInsertCommandTimeout(const ndn::Interest& interest)
 {
-  throw Error("command response timeout");
+  BOOST_THROW_EXCEPTION(Error("command response timeout"));
 }
 
 void
@@ -290,7 +291,7 @@
     ndn::Name::Component segmentComponent = interest.getName().get(prefix.size());
     segmentNo = segmentComponent.toSegment();
   }
-  catch (tlv::Error& e) {
+  catch (const tlv::Error& e) {
     if (isVerbose) {
       std::cerr << "Error processing incoming interest " << interest << ": "
                 << e.what() << std::endl;
@@ -333,11 +334,11 @@
     boost::iostreams::read(*insertStream, reinterpret_cast<char*>(buffer), DEFAULT_BLOCK_SIZE);
 
   if (readSize <= 0) {
-    throw Error("Error reading from the input stream");
+    BOOST_THROW_EXCEPTION(Error("Error reading from the input stream"));
   }
 
   if (insertStream->peek() != std::istream::traits_type::eof()) {
-    throw Error("Input data does not fit into one Data packet");
+    BOOST_THROW_EXCEPTION(Error("Input data does not fit into one Data packet"));
   }
 
   shared_ptr<ndn::Data> data = make_shared<ndn::Data>(m_dataPrefix);
@@ -352,7 +353,7 @@
 void
 NdnPutFile::onRegisterFailed(const ndn::Name& prefix, const std::string& reason)
 {
-  throw Error("onRegisterFailed: " + reason);
+  BOOST_THROW_EXCEPTION(Error("onRegisterFailed: " + reason));
 }
 
 void
@@ -386,17 +387,18 @@
                                                           .setProcessId(m_processId));
   m_face.expressInterest(checkInterest,
                          bind(&NdnPutFile::onCheckCommandResponse, this, _1, _2),
+                         bind(&NdnPutFile::onCheckCommandTimeout, this, _1), // Nack
                          bind(&NdnPutFile::onCheckCommandTimeout, this, _1));
 }
 
 void
-NdnPutFile::onCheckCommandResponse(const ndn::Interest& interest, ndn::Data& data)
+NdnPutFile::onCheckCommandResponse(const ndn::Interest& interest, const ndn::Data& data)
 {
   RepoCommandResponse response(data.getContent().blockFromValue());
   int statusCode = response.getStatusCode();
   if (statusCode >= 400) {
-    throw Error("Insert check command failed with code: " +
-                boost::lexical_cast<std::string>(statusCode));
+    BOOST_THROW_EXCEPTION(Error("Insert check command failed with code: " +
+                                boost::lexical_cast<std::string>(statusCode)));
   }
 
   if (m_isFinished) {
@@ -424,7 +426,7 @@
 void
 NdnPutFile::onCheckCommandTimeout(const ndn::Interest& interest)
 {
-  throw Error("check response timeout");
+  BOOST_THROW_EXCEPTION(Error("check response timeout"));
 }
 
 ndn::Interest
@@ -495,7 +497,7 @@
       try {
         ndnPutFile.freshnessPeriod = milliseconds(boost::lexical_cast<uint64_t>(optarg));
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-x option should be an integer.";
         return 1;
       }
@@ -504,7 +506,7 @@
       try {
         ndnPutFile.interestLifetime = milliseconds(boost::lexical_cast<uint64_t>(optarg));
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-l option should be an integer.";
         return 1;
       }
@@ -514,7 +516,7 @@
       try {
         ndnPutFile.timeout = milliseconds(boost::lexical_cast<uint64_t>(optarg));
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-w option should be an integer.";
         return 1;
       }
@@ -567,7 +569,7 @@
   try {
     return repo::main(argc, argv);
   }
-  catch (std::exception& e) {
+  catch (const std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
     return 2;
   }
diff --git a/tools/ndnrepowatch.cpp b/tools/ndnrepowatch.cpp
index c5128f3..4172d79 100644
--- a/tools/ndnrepowatch.cpp
+++ b/tools/ndnrepowatch.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -14,7 +14,7 @@
  * PURPOSE.  See the GNU General Public License for more details.
  *
  * 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/>.
+ * repo-ng, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "../src/repo-command-parameter.hpp"
@@ -50,7 +50,7 @@
   STOP
 };
 
-class NdnRepoWatch : ndn::noncopyable
+class NdnRepoWatch : boost::noncopyable
 {
 public:
   class Error : public std::runtime_error
@@ -87,7 +87,7 @@
   startWatchCommand();
 
   void
-  onWatchCommandResponse(const ndn::Interest& interest, ndn::Data& data);
+  onWatchCommandResponse(const ndn::Interest& interest, const ndn::Data& data);
 
   void
   onWatchCommandTimeout(const ndn::Interest& interest);
@@ -168,6 +168,7 @@
     m_face.expressInterest(commandInterest,
                            bind(&NdnRepoWatch::onWatchCommandResponse, this,
                                      _1, _2),
+                           bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1), // Nack
                            bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
   }
   else if (status == STOP){
@@ -175,6 +176,7 @@
     m_face.expressInterest(commandInterest,
                            bind(&NdnRepoWatch::onWatchCommandResponse, this,
                                      _1, _2),
+                           bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1), // Nack
                            bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
   }
   else if (status == CHECK){
@@ -182,19 +184,20 @@
     m_face.expressInterest(commandInterest,
                            bind(&NdnRepoWatch::onWatchCommandResponse, this,
                                      _1, _2),
+                           bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1), // Nack
                            bind(&NdnRepoWatch::onWatchCommandTimeout, this, _1));
   }
 
 }
 
 void
-NdnRepoWatch::onWatchCommandResponse(const ndn::Interest& interest, ndn::Data& data)
+NdnRepoWatch::onWatchCommandResponse(const ndn::Interest& interest, const ndn::Data& data)
 {
   RepoCommandResponse response(data.getContent().blockFromValue());
   int statusCode = response.getStatusCode();
   if (statusCode >= 400) {
-    throw Error("Watch command failed with code " +
-                boost::lexical_cast<std::string>(statusCode));
+    BOOST_THROW_EXCEPTION(Error("Watch command failed with code " +
+                                boost::lexical_cast<std::string>(statusCode)));
   }
   else if (statusCode == 101) {
     std::cerr << "Watching prefix is stopped!" <<std::endl;
@@ -214,15 +217,15 @@
     return;
   }
   else {
-    throw Error("Unrecognized Status Code " +
-                boost::lexical_cast<std::string>(statusCode));
+    BOOST_THROW_EXCEPTION(Error("Unrecognized Status Code " +
+                                boost::lexical_cast<std::string>(statusCode)));
   }
 }
 
 void
 NdnRepoWatch::onWatchCommandTimeout(const ndn::Interest& interest)
 {
-  throw Error("command response timeout");
+  BOOST_THROW_EXCEPTION(Error("command response timeout"));
 }
 
 void
@@ -240,13 +243,14 @@
                                                           .setName(m_dataPrefix));
   m_face.expressInterest(checkInterest,
                          bind(&NdnRepoWatch::onWatchCommandResponse, this, _1, _2),
+                         bind(&NdnRepoWatch::onCheckCommandTimeout, this, _1), // Nack
                          bind(&NdnRepoWatch::onCheckCommandTimeout, this, _1));
 }
 
 void
 NdnRepoWatch::onCheckCommandTimeout(const ndn::Interest& interest)
 {
-  throw Error("check response timeout");
+  BOOST_THROW_EXCEPTION(Error("check response timeout"));
 }
 
 void
@@ -255,8 +259,8 @@
   RepoCommandResponse response(data.getContent().blockFromValue());
   int statusCode = response.getStatusCode();
   if (statusCode != 101) {
-    throw Error("Watch stop command failed with code: " +
-                boost::lexical_cast<std::string>(statusCode));
+    BOOST_THROW_EXCEPTION(Error("Watch stop command failed with code: " +
+                                boost::lexical_cast<std::string>(statusCode)));
   }
   else {
     std::cerr << "Status code is 101. Watching prefix is stopped successfully!" << std::endl;
@@ -268,7 +272,7 @@
 void
 NdnRepoWatch::onStopCommandTimeout(const ndn::Interest& interest)
 {
-  throw Error("stop response timeout");
+  BOOST_THROW_EXCEPTION(Error("stop response timeout"));
 }
 
 ndn::Interest
@@ -322,7 +326,7 @@
       try {
         app.freshnessPeriod = milliseconds(boost::lexical_cast<uint64_t>(optarg));
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-x option should be an integer.";
         return 1;
       }
@@ -331,7 +335,7 @@
       try {
         app.interestLifetime = milliseconds(boost::lexical_cast<uint64_t>(optarg));
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-l option should be an integer.";
         return 1;
       }
@@ -341,7 +345,7 @@
       try {
         app.watchTimeout = milliseconds(boost::lexical_cast<int64_t>(optarg));
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-w option should be an integer.";
         return 1;
       }
@@ -351,7 +355,7 @@
       try {
         app.maxInterestNum = boost::lexical_cast<int64_t>(optarg);
       }
-      catch (boost::bad_lexical_cast&) {
+      catch (const boost::bad_lexical_cast&) {
         std::cerr << "-n option should be an integer.";
         return 1;
       }
@@ -398,7 +402,7 @@
   try {
     return repo::main(argc, argv);
   }
-  catch (std::exception& e) {
+  catch (const std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
     return 2;
   }
diff --git a/tools/repo-ng-ls.cpp b/tools/repo-ng-ls.cpp
index 862f133..3a916a3 100644
--- a/tools/repo-ng-ls.cpp
+++ b/tools/repo-ng-ls.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -14,7 +14,7 @@
  * PURPOSE.  See the GNU General Public License for more details.
  *
  * 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/>.
+ * repo-ng, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "../src/common.hpp"
@@ -88,7 +88,7 @@
    #endif
                           );
   if (rc != SQLITE_OK) {
-    throw Error("Database file open failure");
+    BOOST_THROW_EXCEPTION(Error("Database file open failure"));
   }
   sqlite3_exec(m_db, "PRAGMA synchronous = OFF", 0, 0, &errMsg);
   sqlite3_exec(m_db, "PRAGMA journal_mode = WAL", 0, 0, &errMsg);
@@ -98,20 +98,20 @@
 RepoEnumerator::readConfig(const std::string& configFile)
 {
   if (configFile.empty()) {
-    throw Error("Invalid configuration file name");
+    BOOST_THROW_EXCEPTION(Error("Invalid configuration file name"));
   }
 
   std::ifstream fin(configFile.c_str());
   if (!fin.is_open())
-    throw Error("failed to open configuration file '" + configFile + "'");
+    BOOST_THROW_EXCEPTION(Error("failed to open configuration file '" + configFile + "'"));
 
   using namespace boost::property_tree;
   ptree propertyTree;
   try {
     read_info(fin, propertyTree);
   }
-  catch (ptree_error& e) {
-    throw Error("failed to read configuration file '" + configFile + "'");
+  catch (const ptree_error& e) {
+    BOOST_THROW_EXCEPTION(Error("failed to read configuration file '" + configFile + "'"));
   }
   ptree repoConf = propertyTree.get_child("repo");
   m_dbPath = repoConf.get<std::string>("storage.path");
@@ -126,7 +126,7 @@
   string sql = string("SELECT id, name, keylocatorHash FROM NDN_REPO;");
   rc = sqlite3_prepare_v2(m_db, sql.c_str(), -1, &m_stmt, 0);
   if (rc != SQLITE_OK)
-    throw Error("Initiation Read Entries from Database Prepare error");
+    BOOST_THROW_EXCEPTION(Error("Initiation Read Entries from Database Prepare error"));
   uint64_t entryNumber = 0;
   while (true) {
     rc = sqlite3_step(m_stmt);
@@ -154,7 +154,7 @@
     }
     else {
       sqlite3_finalize(m_stmt);
-      throw Error("Initiation Read Entries error");
+      BOOST_THROW_EXCEPTION(Error("Initiation Read Entries error"));
     }
   }
   return entryNumber;
@@ -197,7 +197,7 @@
   try {
     return repo::main(argc, argv);
   }
-  catch (std::exception& e) {
+  catch (const std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
     return 2;
   }