diff --git a/tools/ndncatchunks3.cpp b/tools/ndncatchunks3.cpp
index c912f26..cb4750a 100644
--- a/tools/ndncatchunks3.cpp
+++ b/tools/ndncatchunks3.cpp
@@ -18,36 +18,39 @@
  * Author: Wentao Shang <wentao@cs.ucla.edu>
  */
 
-
 #include "face.hpp"
 
 class Consumer
 {
 public:
-  Consumer (const std::string &data_name, int pipe_size, int total_seg, int scope = -1, bool mustBeFresh = true)
-    : m_data_name (data_name), m_pipe_size (pipe_size), m_total_seg (total_seg),
-      m_next_seg (0), m_total_size (0), m_output (false)
-	  , m_scope(scope)
-      , m_mustBeFresh(mustBeFresh)
+  Consumer(const std::string& data_name, int pipe_size, int total_seg, int scope = -1, bool mustBeFresh = true)
+    : m_data_name (data_name)
+    , m_pipe_size (pipe_size)
+    , m_total_seg (total_seg)
+    , m_next_seg (0)
+    , m_total_size (0)
+    , m_output (false)
+    , m_scope(scope)
+    , m_mustBeFresh(mustBeFresh)
   {
   }
 
   inline void
-  enable_output ()
+  enable_output()
   {
     m_output = true;
   }
 
   void
-  run ();
-  
+  run();
+
 private:
   void
-  on_data (const ndn::Interest& interest, ndn::Data& data);
+  on_data(const ndn::Interest& interest, ndn::Data& data);
 
   void
-  on_timeout (const ndn::Interest& interest);
-  
+  on_timeout(const ndn::Interest& interest);
+
   ndn::Face m_face;
   ndn::Name m_data_name;
   int m_pipe_size;
@@ -61,25 +64,25 @@
 };
 
 void
-Consumer::run ()
+Consumer::run()
 {
   try
     {
       for (int i = 0; i < m_pipe_size; i++)
 	{
-	  ndn::Interest inst (ndn::Name(m_data_name).appendSegment (m_next_seg++));
-	  inst.setInterestLifetime (4000);
+	  ndn::Interest interest(ndn::Name(m_data_name).appendSegment (m_next_seg++));
+	  interest.setInterestLifetime(ndn::time::milliseconds(4000));
 	  if (m_scope >= 0)
-		  inst.setScope (m_scope);
-	  inst.setMustBeFresh (m_mustBeFresh);
-	  
-	  m_face.expressInterest (inst,
-				  ndn::bind (&Consumer::on_data, this, _1, _2),
-				  ndn::bind (&Consumer::on_timeout, this, _1));
+            interest.setScope(m_scope);
+	  interest.setMustBeFresh(m_mustBeFresh);
+
+	  m_face.expressInterest (interest,
+				  ndn::bind(&Consumer::on_data, this, _1, _2),
+				  ndn::bind(&Consumer::on_timeout, this, _1));
 	}
-      
+
       // processEvents will block until the requested data received or timeout occurs
-      m_face.processEvents ();
+      m_face.processEvents();
     }
   catch (std::exception& e)
     {
@@ -88,10 +91,10 @@
 }
 
 void
-Consumer::on_data (const ndn::Interest& interest, ndn::Data& data)
+Consumer::on_data(const ndn::Interest& interest, ndn::Data& data)
 {
-  const ndn::Block& content = data.getContent ();
-  const ndn::Name& name = data.getName ();
+  const ndn::Block& content = data.getContent();
+  const ndn::Name& name = data.getName();
 
   if (m_output)
     {
@@ -99,8 +102,8 @@
     }
 
   m_total_size += content.value_size ();
-  
-  if ((int) (name.rbegin ()->toSegment ()) + 1 == m_total_seg)
+
+  if ((int)(name.rbegin ()->toSegment ()) + 1 == m_total_seg)
     {
       std::cerr << "Last segment received." << std::endl;
       std::cerr << "Total # bytes of content received: " << m_total_size << std::endl;
@@ -108,21 +111,21 @@
   else
     {
       // Send interest for next segment
-      ndn::Interest inst (ndn::Name(m_data_name).appendSegment (m_next_seg++));
-	  if (m_scope >= 0)
-	      inst.setScope (m_scope);
-      inst.setInterestLifetime (4000);
-      inst.setMustBeFresh (m_mustBeFresh);
-      
-      m_face.expressInterest (inst,
-			      ndn::bind (&Consumer::on_data, this, _1, _2),
-			      ndn::bind (&Consumer::on_timeout, this, _1));  
+      ndn::Interest interest(ndn::Name(m_data_name).appendSegment (m_next_seg++));
+      if (m_scope >= 0)
+        interest.setScope(m_scope);
+      interest.setInterestLifetime(ndn::time::milliseconds(4000));
+      interest.setMustBeFresh(m_mustBeFresh);
+
+      m_face.expressInterest (interest,
+			      ndn::bind(&Consumer::on_data, this, _1, _2),
+			      ndn::bind(&Consumer::on_timeout, this, _1));
     }
 }
 
 
 void
-Consumer::on_timeout (const ndn::Interest& interest)
+Consumer::on_timeout(const ndn::Interest& interest)
 {
   //XXX: currently no retrans
   std::cerr << "TIMEOUT: last interest sent for segment #" << (m_next_seg - 1) << std::endl;
@@ -138,7 +141,7 @@
 
 
 int
-main (int argc, char **argv)
+main(int argc, char **argv)
 {
   std::string name;
   int pipe_size = 1;
@@ -165,7 +168,7 @@
 	case 'o':
 	  output = true;
 	  break;
-        default: 
+        default:
 	  return usage(argv[0]);
         }
     }
@@ -174,17 +177,17 @@
     {
       name = argv[optind];
     }
-  
+
   if (name.empty())
     {
       return usage(argv[0]);
     }
-  
+
   Consumer consumer (name, pipe_size, total_seg);
 
   if (output)
     consumer.enable_output ();
-  
+
   consumer.run ();
 
   return 0;
diff --git a/tools/ndnputchunks3.cpp b/tools/ndnputchunks3.cpp
index be03453..d631798 100644
--- a/tools/ndnputchunks3.cpp
+++ b/tools/ndnputchunks3.cpp
@@ -26,23 +26,23 @@
 class Producer
 {
 public:
-  Producer (const char* name)
-  : m_name (name)
-  , m_verbose (false)
+  Producer(const char* name)
+    : m_name(name)
+    , m_verbose(false)
   {
     int segnum = 0;
     char* buf = new char[MAX_SEG_SIZE];
     do
       {
-        std::cin.read (buf, MAX_SEG_SIZE);
+        std::cin.read(buf, MAX_SEG_SIZE);
         int got = std::cin.gcount ();
 
         if (got > 0)
           {
             ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data> (ndn::Name(m_name).appendSegment (segnum));
-            data->setFreshnessPeriod (10000); // 10 sec
-            data->setContent (reinterpret_cast<const uint8_t*>(buf), got);
-            
+            data->setFreshnessPeriod(ndn::time::milliseconds(10000)); // 10 sec
+            data->setContent(reinterpret_cast<const uint8_t*>(buf), got);
+
             m_keychain.sign(*data);
             m_store.push_back(data);
             segnum++;
@@ -55,76 +55,77 @@
   }
 
   void
-  onInterest (const ndn::Name& name, const ndn::Interest& interest)
+  onInterest(const ndn::Name& name, const ndn::Interest& interest)
   {
     if (m_verbose)
       std::cerr << "<< I: " << interest << std::endl;
-    
-    size_t segnum = static_cast<size_t>(interest.getName ().rbegin ()->toSegment ());
+
+    size_t segnum = static_cast<size_t>(interest.getName().rbegin()->toSegment());
 
     if (segnum < m_store.size())
       {
-        m_face.put (*m_store[segnum]);
+        m_face.put(*m_store[segnum]);
       }
   }
 
   void
-  onRegisterFailed (const ndn::Name& prefix, const std::string& reason)
+  onRegisterFailed(const ndn::Name& prefix, const std::string& reason)
   {
     std::cerr << "ERROR: Failed to register prefix in local hub's daemon (" << reason << ")" << std::endl;
-    m_face.shutdown ();
+    m_face.shutdown();
   }
-  
+
   void
-  run ()
+  run()
   {
     if (m_store.empty())
       {
         std::cerr << "Nothing to serve. Exiting." << std::endl;
         return;
       }
-    
-    m_face.setInterestFilter (m_name,
-                              ndn::bind (&Producer::onInterest, this, _1, _2),
-                              ndn::bind (&Producer::onRegisterFailed, this, _1, _2));
-    m_face.processEvents ();
+
+    m_face.setInterestFilter(m_name,
+                             ndn::bind(&Producer::onInterest, this, _1, _2),
+                             ndn::bind(&Producer::onRegisterFailed, this, _1, _2));
+    m_face.processEvents();
   }
 
 private:
   ndn::Name m_name;
   ndn::Face m_face;
   ndn::KeyChain m_keychain;
-  
+
   std::vector< ndn::shared_ptr<ndn::Data> > m_store;
 
   bool m_verbose;
 };
 
 int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
 {
   if (argc < 2)
     {
       std::cerr << "Usage: ./ndnputchunks [data_prefix]\n";
       return -1;
     }
-  
+
   try
     {
-      ndn::MillisecondsSince1970 time = ndn::getNow();
-      
+      ndn::time::steady_clock::TimePoint startTime = ndn::time::steady_clock::now();
+
       std::cerr << "Preparing the input..." << std::endl;
-      Producer producer (argv[1]);
-      std::cerr << "Ready... (took " << ((ndn::getNow() - time)/1000) << " seconds)" << std::endl;
-      while(true)
+      Producer producer(argv[1]);
+      std::cerr << "Ready... (took " << (ndn::time::steady_clock::now() - startTime) << std::endl;
+
+      while (true)
         {
           try
             {
-              producer.run (); // this will exit when daemon dies... so try to connect again if possible
+              producer.run(); // this will exit when daemon dies... so try to connect again if possible
             }
           catch (std::exception& e)
             {
-              std::cerr << "ERROR: " << e.what () << std::endl;
+              std::cerr << "ERROR: " << e.what() << std::endl;
               // and keep going
               sleep (1);
             }
@@ -132,7 +133,7 @@
     }
   catch (std::exception& e)
     {
-      std::cerr << "ERROR: " << e.what () << std::endl;
+      std::cerr << "ERROR: " << e.what() << std::endl;
     }
   return 0;
 }
diff --git a/tools/ndnsec-cert-gen.hpp b/tools/ndnsec-cert-gen.hpp
index 023df7e..8b6e460 100644
--- a/tools/ndnsec-cert-gen.hpp
+++ b/tools/ndnsec-cert-gen.hpp
@@ -103,26 +103,26 @@
       return 1;
     }
 
-  Time notBefore;
-  Time notAfter;
+  time::system_clock::TimePoint notBefore;
+  time::system_clock::TimePoint notAfter;
   try{
     if (0 == vm.count("not-before"))
       {
-        notBefore = boost::posix_time::second_clock::universal_time();
+        notBefore = time::system_clock::now();
       }
     else
       {
-        notBefore = boost::posix_time::from_iso_string(notBeforeStr.substr(0, 8) + "T" + notBeforeStr.substr(8, 6));
+        notBefore = time::fromIsoString(notBeforeStr.substr(0, 8) + "T" + notBeforeStr.substr(8, 6));
       }
 
 
     if (0 == vm.count("not-after"))
       {
-        notAfter = notBefore + boost::posix_time::hours(24*365);
+        notAfter = notBefore + time::days(365);
       }
     else
       {
-        notAfter = boost::posix_time::from_iso_string(notAfterStr.substr(0, 8) + "T" + notAfterStr.substr(8, 6));
+        notAfter = time::fromIsoString(notAfterStr.substr(0, 8) + "T" + notAfterStr.substr(8, 6));
         if(notAfter < notBefore)
           {
             std::cerr << "not-before is later than not-after" << std::endl;
@@ -195,8 +195,8 @@
           CertificateSubjectDescription subDescryptName("2.5.4.41", sName);
           IdentityCertificate certificate;
           certificate.setName(certName);
-          certificate.setNotBefore((notBefore-ndn::UNIX_EPOCH_TIME).total_milliseconds());
-          certificate.setNotAfter((notAfter-ndn::UNIX_EPOCH_TIME).total_milliseconds());
+          certificate.setNotBefore(notBefore);
+          certificate.setNotAfter(notAfter);
           certificate.setPublicKeyInfo(selfSignedCertificate->getPublicKeyInfo());
           certificate.addSubjectDescription(subDescryptName);
           for(int i = 0; i < otherSubDescrypt.size(); i++)
