diff --git a/src/sec-policy-sync.cc b/src/sec-policy-sync.cc
deleted file mode 100644
index 0f4db3e..0000000
--- a/src/sec-policy-sync.cc
+++ /dev/null
@@ -1,440 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Yingdi Yu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Yingdi Yu <yingdi@cs.ucla.edu>
- */
-
-#include "sync-intro-certificate.h"
-#include "sync-logging.h"
-#include <ndn-cpp-dev/security/verifier.hpp>
-#include <ndn-cpp-dev/security/signature-sha256-with-rsa.hpp>
-
-#include "sec-policy-sync.h"
-
-using namespace ndn;
-using namespace ndn::ptr_lib;
-using namespace std;
-
-INIT_LOGGER("SecPolicySync");
-
-SecPolicySync::SecPolicySync(const Name& signingIdentity,
-                             const Name& signingCertificateName,
-                             const Name& syncPrefix,
-                             shared_ptr<Face> face,
-                             int stepLimit)
-  : m_signingIdentity(signingIdentity)
-  , m_signingCertificateName(signingCertificateName.getPrefix(signingCertificateName.size()-1))
-  , m_syncPrefix(syncPrefix)
-  , m_stepLimit(stepLimit)
-  , m_keyChain(new KeyChain())
-{  
-  m_introCertPrefix = syncPrefix;
-  m_introCertPrefix.append("WOT");
-
-  m_syncDataPolicy = make_shared<SecRuleRelative>("^[^<%F0\\.>]*<%F0\\.>([^<chronos>]*)<chronos><>",
-                                                  "^([^<KEY>]*)<KEY>(<>*)[<dsk-.*><ksk-.*>]<ID-CERT>$",
-                                                  "==", "\\1", "\\1", true);  
-}
-  
-SecPolicySync::~SecPolicySync()
-{}
-
-bool 
-SecPolicySync::skipVerifyAndTrust (const Data& data)
-{ return false; }
-
-bool
-SecPolicySync::requireVerify (const Data& data)
-{ return true; }
-
-shared_ptr<ValidationRequest>
-SecPolicySync::checkVerificationPolicy(const shared_ptr<Data>& data, 
-                                       int stepCount, 
-                                       const OnVerified& onVerified,
-                                       const OnVerifyFailed& onVerifyFailed)
-{
-  if(stepCount > m_stepLimit)
-    {
-      onVerifyFailed(data);
-      return shared_ptr<ValidationRequest>();
-    }
-
-  try{
-    SignatureSha256WithRsa sig(data->getSignature());
-    const Name& keyLocatorName = sig.getKeyLocator().getName();
-
-    // if data is intro cert
-    if(m_introCertPrefix.isPrefixOf(data->getName()))
-      {
-        Name keyName = IdentityCertificate::certificateNameToPublicKeyName(keyLocatorName);
-        map<Name, PublicKey>::const_iterator it = m_trustedIntroducers.find(keyName);
-        if(m_trustedIntroducers.end() != it)
-          {
-            if(Verifier::verifySignature(*data, sig, it->second))
-              onVerified(data);
-            else
-              onVerifyFailed(data);
-            return shared_ptr<ValidationRequest>();
-          }
-        else
-          return prepareRequest(keyName, true, data, stepCount, onVerified, onVerifyFailed);
-      }
-  
-    // if data is diff data or sync data
-    if(m_syncPrefix.isPrefixOf(data->getName()) || m_syncDataPolicy->satisfy(*data))
-      {
-        Name keyName = IdentityCertificate::certificateNameToPublicKeyName(keyLocatorName);
-
-        map<Name, PublicKey>::const_iterator it = m_trustedIntroducers.find(keyName);
-        if(m_trustedIntroducers.end() != it)
-          {
-            if(Verifier::verifySignature(*data, sig, it->second))
-              onVerified(data);
-            else
-              onVerifyFailed(data);
-            return shared_ptr<ValidationRequest>();
-          }
-
-        it = m_trustedProducers.find(keyName);
-        if(m_trustedProducers.end() != it)
-          {
-            if(Verifier::verifySignature(*data, sig, it->second))
-              onVerified(data);
-            else
-              onVerifyFailed(data);
-            return shared_ptr<ValidationRequest>();
-          }
-
-        return prepareRequest(keyName, false, data, stepCount, onVerified, onVerifyFailed);
-      }
-
-  }catch(SignatureSha256WithRsa::Error &e){
-    _LOG_DEBUG("SecPolicySync Error: " << e.what());
-    onVerifyFailed(data);
-    return shared_ptr<ValidationRequest>();
-  }catch(KeyLocator::Error &e){
-    _LOG_DEBUG("SecPolicySync Error: " << e.what());
-    onVerifyFailed(data);
-    return shared_ptr<ValidationRequest>();
-  }
-    
-  onVerifyFailed(data);
-  return shared_ptr<ValidationRequest>();
-}
-
-bool 
-SecPolicySync::checkSigningPolicy(const Name& dataName, 
-                                  const Name& certificateName)
-{ 
-  return true;
-}
-    
-Name 
-SecPolicySync::inferSigningIdentity(const ndn::Name& dataName)
-{ return m_signingIdentity; }
-
-void
-SecPolicySync::addTrustAnchor(const IdentityCertificate& identityCertificate, bool isIntroducer)
-{
-  Name publicKeyName = identityCertificate.getPublicKeyName();
-
-  _LOG_DEBUG("Add intro/producer: " << publicKeyName);
-
-  if(isIntroducer)
-    m_trustedIntroducers[publicKeyName] = identityCertificate.getPublicKeyInfo();
-  else
-    m_trustedProducers[publicKeyName] = identityCertificate.getPublicKeyInfo();
-}
-
-void
-SecPolicySync::addSyncDataRule(const Name& prefix, 
-                               const IdentityCertificate& identityCertificate,
-                               bool isIntroducer)
-{ addTrustAnchor(identityCertificate, isIntroducer); }
-
-
-shared_ptr<const vector<Name> >
-SecPolicySync::getAllIntroducerName()
-{
-  shared_ptr<vector<Name> > nameList = make_shared<vector<Name> >();
-  
-  map<Name, PublicKey>::iterator it =  m_trustedIntroducers.begin();
-  for(; it != m_trustedIntroducers.end(); it++)
-    nameList->push_back(it->first);
-  
-  return nameList;
-}
-
-shared_ptr<ValidationRequest>
-SecPolicySync::prepareRequest(const Name& keyName, 
-                              bool forIntroducer,
-                              shared_ptr<Data> data,
-                              const int & stepCount, 
-                              const OnVerified& onVerified,
-                              const OnVerifyFailed& onVerifyFailed)
-{
-  Name interestPrefix = m_syncPrefix;
-  interestPrefix.append("WOT").append(keyName.wireEncode()).append("INTRO-CERT");
-
-  shared_ptr<const vector<Name> > nameList = getAllIntroducerName();
-  if(0 == nameList->size())
-    {
-      onVerifyFailed(data);
-      return shared_ptr<ValidationRequest>();
-    }
-
-  Name interestName = interestPrefix;
-  interestName.append(nameList->at(0).wireEncode());
-
-  if(forIntroducer)
-    interestName.append("INTRODUCER");
-
-  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(interestName);
-
-  OnVerified introCertVerified = func_lib::bind(&SecPolicySync::onIntroCertVerified, 
-                                                this, 
-                                                _1,
-                                                forIntroducer,
-                                                data,
-                                                onVerified,
-                                                onVerifyFailed);
-                                                             
-  OnVerifyFailed introCertVerifyFailed = func_lib::bind(&SecPolicySync::onIntroCertVerifyFailed, 
-                                                        this, 
-                                                        _1, 
-                                                        interestPrefix,
-                                                        forIntroducer,
-                                                        nameList,
-                                                        1,
-                                                        data,
-                                                        onVerified,
-                                                        onVerifyFailed);
-
-    
-  shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(interest, 
-                                                                          introCertVerified,
-                                                                          introCertVerifyFailed,
-                                                                          1,
-                                                                          m_stepLimit-1);
-  return nextStep;
-}
-
-void
-SecPolicySync::OnIntroCertInterest(const shared_ptr<const Name>& prefix, 
-                                   const shared_ptr<const ndn::Interest>& interest, 
-                                   Transport& transport, 
-                                   uint64_t registeredPrefixId)
-{
-  map<Name, Data>::const_iterator it = m_introCert.find(*prefix);
-
-  if(m_introCert.end() != it)
-    m_face->put(it->second);
-}
-
-void
-SecPolicySync::OnIntroCertRegisterFailed(const shared_ptr<const Name>& prefix)
-{
-}
-
-void
-SecPolicySync::onIntroCertVerified(const shared_ptr<Data>& introCertificateData,
-                                   bool forIntroducer,
-                                   shared_ptr<Data> originalData,
-                                   const OnVerified& onVerified,
-                                   const OnVerifyFailed& onVerifyFailed)
-{
-  shared_ptr<SyncIntroCertificate> introCertificate = make_shared<SyncIntroCertificate>(*introCertificateData);
-  Name subjectKeyName = introCertificate->getPublicKeyName();
-
-  if(forIntroducer)
-    {
-      //Add the intro cert subject as trusted introducer.
-      m_trustedIntroducers[subjectKeyName] = introCertificate->getPublicKeyInfo();
-
-      //Generate another intro cert for the cert subject.
-      SyncIntroCertificate syncIntroCertificate(m_syncPrefix,
-                                                subjectKeyName,
-                                                m_keyChain->getDefaultKeyNameForIdentity(m_signingIdentity),
-                                                introCertificate->getNotBefore(),
-                                                introCertificate->getNotAfter(),
-                                                introCertificate->getPublicKeyInfo(),
-                                                SyncIntroCertificate::INTRODUCER);
-      m_keyChain->signByIdentity(syncIntroCertificate, m_signingIdentity);
-      m_face->put(syncIntroCertificate);
-
-      // Name prefix = syncIntroCertificate.getName().getPrefix(syncIntroCertificate.getName().size()-1);
-
-      // map<string, Data>::const_iterator it = m_introCert.find(prefix);
-      // if(m_introCert.end() != it)
-      //   {
-      //     it->second = syncIntroCertificate;
-      //   }
-      // else
-      //   {         
-      //     m_introCert.insert(pair <Name, Data> (prefix, syncIntroCertificate));
-      //     m_face->registerPrefix(prefix, 
-      //                           boost::bind(&SecPolicySync::onIntroCertInterest, this, _1, _2, _3, _4), 
-      //                           boost::bind(&SecPolicySync::onIntroCertRegisterFailed, this, _1));
-      //   }
-    }
-  else
-    {
-      //Add the intro cert subject as trusted producer.
-      m_trustedProducers[subjectKeyName] = introCertificate->getPublicKeyInfo();
-
-      //Generate another intro cert for the cert subject.
-      SyncIntroCertificate syncIntroCertificate(m_syncPrefix,
-                                                subjectKeyName,
-                                                m_keyChain->getDefaultKeyNameForIdentity(m_signingIdentity),
-                                                introCertificate->getNotBefore(),
-                                                introCertificate->getNotAfter(),
-                                                introCertificate->getPublicKeyInfo(),
-                                                SyncIntroCertificate::PRODUCER);
-      m_keyChain->signByIdentity(syncIntroCertificate, m_signingIdentity);
-      m_face->put(syncIntroCertificate);
-
-      // Name prefix = syncIntroCertificate.getName().getPrefix(syncIntroCertificate.getName().size()-1);
-
-      // map<string, Data>::const_iterator it = m_introCert.find(prefix);
-      // if(m_introCert.end() != it)
-      //   {
-      //     it->second = syncIntroCertificate;
-      //   }
-      // else
-      //   {
-      //     m_introCert.insert(pair <Name, Data> (prefix, syncIntroCertificate));
-      //     m_face->registerPrefix(prefix, 
-      //                           boost::bind(&SecPolicySync::onIntroCertInterest, this, _1, _2, _3, _4), 
-      //                           boost::bind(&SecPolicySync::onIntroCertRegisterFailed, this, _1));
-      //   }
-    }
-
-  try{
-    SignatureSha256WithRsa sig(originalData->getSignature());
-    if(Verifier::verifySignature(*originalData, sig, introCertificate->getPublicKeyInfo()))      
-      onVerified(originalData);    
-    else
-      onVerifyFailed(originalData);
-  }catch(SignatureSha256WithRsa::Error &e){
-    onVerifyFailed(originalData);
-  }catch(KeyLocator::Error &e){
-    onVerifyFailed(originalData);
-  }
-}
-
-void 
-SecPolicySync::onIntroCertVerifyFailed(const shared_ptr<Data>& introCertificateData,
-                                       Name interestPrefix,
-                                       bool forIntroducer,
-                                       shared_ptr<const vector<Name> > introNameList,
-                                       int nextIntroducerIndex,
-                                       shared_ptr<Data> originalData,
-                                       const OnVerified& onVerified,
-                                       const OnVerifyFailed& onVerifyFailed)
-{
-  Name interestName = interestPrefix;
-  if(nextIntroducerIndex < introNameList->size())
-    interestName.append(introNameList->at(nextIntroducerIndex).wireEncode());
-  else
-    onVerifyFailed(originalData);
-
-  if(forIntroducer)
-    interestName.append("INTRODUCER");
-  
-  ndn::Interest interest(interestName);
-
-  OnVerified introCertVerified = func_lib::bind(&SecPolicySync::onIntroCertVerified, 
-                                                this, 
-                                                _1,
-                                                forIntroducer, 
-                                                originalData,
-                                                onVerified,
-                                                onVerifyFailed);
-
-  OnVerifyFailed introCertVerifyFailed = func_lib::bind(&SecPolicySync::onIntroCertVerifyFailed, 
-                                                        this, 
-                                                        _1,
-                                                        interestPrefix,
-                                                        forIntroducer,
-                                                        introNameList,
-                                                        nextIntroducerIndex + 1,
-                                                        originalData, 
-                                                        onVerified,
-                                                        onVerifyFailed);
-        
-  m_face->expressInterest(interest, 
-                          func_lib::bind(&SecPolicySync::onIntroCertData,
-                                         this,
-                                         _1,
-                                         _2,     
-                                         m_stepLimit-1,
-                                         introCertVerified,
-                                         introCertVerifyFailed),
-                          func_lib::bind(&SecPolicySync::onIntroCertTimeout, 
-                                         this,
-                                         _1,
-                                         1,
-                                         m_stepLimit-1,
-                                         introCertVerified,
-                                         introCertVerifyFailed)
-                          );
-}
-
-void
-SecPolicySync::onIntroCertData(const shared_ptr<const ndn::Interest> &interest,
-                               const shared_ptr<Data>& introCertificateData,
-                               int stepCount,
-                               const OnVerified& introCertVerified,
-                               const OnVerifyFailed& introCertVerifyFailed)
-{
-  shared_ptr<ValidationRequest> nextStep = checkVerificationPolicy(introCertificateData, stepCount, introCertVerified, introCertVerifyFailed);
-  if (nextStep)
-    m_face->expressInterest(*nextStep->interest_, 
-                            func_lib::bind(&SecPolicySync::onIntroCertData, 
-                                           this, 
-                                           _1, 
-                                           _2,
-                                           nextStep->stepCount_,
-                                           nextStep->onVerified_, 
-                                           nextStep->onVerifyFailed_), 
-                            func_lib::bind(&SecPolicySync::onIntroCertTimeout, 
-                                           this, 
-                                           _1, 
-                                           nextStep->retry_, 
-                                           nextStep->stepCount_, 
-                                           nextStep->onVerified_, 
-                                           nextStep->onVerifyFailed_)
-                            );
-}
-
-void
-SecPolicySync::onIntroCertTimeout(const shared_ptr<const ndn::Interest>& interest, 
-                                  int retry, 
-                                  int stepCount,
-                                  const OnVerified& introCertVerified,
-                                  const OnVerifyFailed& introCertVerifyFailed)
-{
-  if(retry > 0)
-    m_face->expressInterest(*interest, 
-                            func_lib::bind(&SecPolicySync::onIntroCertData, 
-                                           this,
-                                           _1,
-                                           _2,
-                                           stepCount,
-                                           introCertVerified,
-                                           introCertVerifyFailed),
-                            func_lib::bind(&SecPolicySync::onIntroCertTimeout, 
-                                           this,
-                                           _1,
-                                           retry - 1,
-                                           stepCount,
-                                           introCertVerified,
-                                           introCertVerifyFailed)
-                            );
-  else
-    introCertVerifyFailed(shared_ptr<Data>());
-}
diff --git a/src/sec-policy-sync.h b/src/sec-policy-sync.h
deleted file mode 100644
index 2ecac0f..0000000
--- a/src/sec-policy-sync.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Yingdi Yu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Yingdi Yu <yingdi@cs.ucla.edu>
- */
-
-#ifndef SEC_POLICY_SYNC_H
-#define SEC_POLICY_SYNC_H
-
-#include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/security/key-chain.hpp>
-#include <ndn-cpp-dev/security/verifier.hpp>
-#include <ndn-cpp-dev/security/sec-policy.hpp>
-#include <ndn-cpp-dev/security/identity-certificate.hpp>
-#include <ndn-cpp-et/policy/sec-rule-relative.hpp>
-// #include <ndn-cpp-et/policy/sec-rule-specific.hpp>
-#include <map>
-
-class SecPolicySync : public ndn::SecPolicy
-{
-public:
-  SecPolicySync(const ndn::Name& signingIdentity,
-                const ndn::Name& signingCertificateName,
-                const ndn::Name& syncPrefix,
-                ndn::ptr_lib::shared_ptr<ndn::Face> face,
-                int m_stepLimit = 3);
-  
-  virtual
-  ~SecPolicySync();
-
-  bool 
-  skipVerifyAndTrust (const ndn::Data& data);
-
-  bool
-  requireVerify (const ndn::Data& data);
-
-  ndn::ptr_lib::shared_ptr<ndn::ValidationRequest>
-  checkVerificationPolicy(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, 
-                          int stepCount, 
-                          const ndn::OnVerified& onVerified,
-                          const ndn::OnVerifyFailed& onVerifyFailed);
-
-  bool 
-  checkSigningPolicy(const ndn::Name& dataName, 
-                     const ndn::Name& certificateName);
-    
-  ndn::Name 
-  inferSigningIdentity(const ndn::Name& dataName);
-
-  void
-  addTrustAnchor(const ndn::IdentityCertificate& identityCertificate, bool isIntroducer);
-
-  void
-  addSyncDataRule(const ndn::Name& prefix, 
-                  const ndn::IdentityCertificate& identityCertificate,
-                  bool isIntroducer);
-
-private:
-
-  ndn::ptr_lib::shared_ptr<ndn::ValidationRequest>
-  prepareIntroducerRequest(const ndn::Name& keyName,
-                           ndn::ptr_lib::shared_ptr<ndn::Data> data, 
-                           const int & stepCount, 
-                           const ndn::OnVerified& onVerified,
-                           const ndn::OnVerifyFailed& onVerifyFailed);
-  
-  ndn::ptr_lib::shared_ptr<const std::vector<ndn::Name> >
-  getAllIntroducerName();
-
-  ndn::ptr_lib::shared_ptr<ndn::ValidationRequest>
-  prepareRequest(const ndn::Name& keyName, 
-                 bool forIntroducer,
-                 ndn::ptr_lib::shared_ptr<ndn::Data> data,
-                 const int & stepCount, 
-                 const ndn::OnVerified& onVerified,
-                 const ndn::OnVerifyFailed& onVerifyFailed);
-
-  void
-  OnIntroCertInterest(const ndn::ptr_lib::shared_ptr<const ndn::Name>& prefix, 
-                      const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
-                      ndn::Transport& transport, 
-                      uint64_t registeredPrefixId);
-
-  void
-  OnIntroCertRegisterFailed(const ndn::ptr_lib::shared_ptr<const ndn::Name>& prefix);
-
-  void
-  onIntroCertVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& introCertificateData,
-                      bool forIntroducer,
-                      ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
-                      const ndn::OnVerified& onVerified,
-                      const ndn::OnVerifyFailed& onVerifyFailed);
-
-  void 
-  onIntroCertVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& introCertificateData,
-                          ndn::Name interestPrefix,
-                          bool forIntroducer,
-                          ndn::ptr_lib::shared_ptr<const std::vector<ndn::Name> > introNameList,
-                          int nextIntroducerIndex,
-                          ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
-                          const ndn::OnVerified& onVerified,
-                          const ndn::OnVerifyFailed& onVerifyFailed);
-
-  void 
-  onIntroCertData(const ndn::ptr_lib::shared_ptr<const ndn::Interest> &interest,
-                  const ndn::ptr_lib::shared_ptr<ndn::Data>& introCertificateData,                  
-                  int stepCount,
-                  const ndn::OnVerified& introCertVerified,
-                  const ndn::OnVerifyFailed& introCertVerifyFailed);
-
-  void
-  onIntroCertTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
-                     int retry,                      
-                     int stepCount,
-                     const ndn::OnVerified& introCertVerified,
-                     const ndn::OnVerifyFailed& introCertVerifyFailed);
-
-
-
-private:
-  ndn::Name m_signingIdentity;
-  ndn::Name m_signingCertificateName;
-  ndn::Name m_syncPrefix;
-  ndn::Name m_introCertPrefix;
-  int m_stepLimit;
-  ndn::ptr_lib::shared_ptr<ndn::SecRuleRelative> m_syncDataPolicy; 
-  std::map<ndn::Name, ndn::PublicKey> m_trustedIntroducers;
-  std::map<ndn::Name, ndn::PublicKey> m_trustedProducers;
-  // std::map<ndn::Name, SecRuleSyncSpecific> m_chatDataRules;
-  std::map<ndn::Name, ndn::Data> m_introCert;
-
-  ndn::ptr_lib::shared_ptr<ndn::KeyChain> m_keyChain;
-  ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
-
-};
-
-#endif
diff --git a/src/sync-digest.h b/src/sync-digest.h
index 7cef28f..ecc8522 100644
--- a/src/sync-digest.h
+++ b/src/sync-digest.h
@@ -103,11 +103,11 @@
   operator << (const std::string &str);
 
   /**
-   * @brief Add uint32_t value to digest calculation
-   * @param value uint32_t value to put into digest
+   * @brief Add uint64_t value to digest calculation
+   * @param value uint64_t value to put into digest
    */
   inline Digest &
-  operator << (uint32_t value);
+  operator << (uint64_t value);
 
   /**
    * @brief Checks if the stored hash is zero-root hash
@@ -153,9 +153,9 @@
 }
 
 inline Digest &
-Digest::operator << (uint32_t value)
+Digest::operator << (uint64_t value)
 {
-  update (reinterpret_cast<const uint8_t*> (&value), sizeof (uint32_t));
+  update (reinterpret_cast<const uint8_t*> (&value), sizeof (uint64_t));
   return *this;
 }
 
diff --git a/src/sync-intro-certificate.cc b/src/sync-intro-certificate.cc
deleted file mode 100644
index f335933..0000000
--- a/src/sync-intro-certificate.cc
+++ /dev/null
@@ -1,146 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Yingdi Yu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Yingdi Yu <yingdi@cs.ucla.edu>
- */
-
-#include "sync-intro-certificate.h"
-
-using namespace ndn;
-using namespace std;
-using namespace boost;
-
-SyncIntroCertificate::SyncIntroCertificate ()
-  : Certificate()
-{}
-
-SyncIntroCertificate::SyncIntroCertificate (const Name& nameSpace,
-					    const Name& keyName,
-					    const Name& signerName,
-					    const MillisecondsSince1970& notBefore,
-					    const MillisecondsSince1970& notAfter,
-					    const PublicKey& key,
-					    const IntroType& introType)
-  : m_nameSpace(nameSpace)
-  , m_keyName(keyName)
-  , m_introType(introType)
-{
-  Name certificateName = nameSpace;
-  certificateName.append("WOT").append(keyName.wireEncode()).append("INTRO-CERT").append(signerName.wireEncode());
-  switch(introType)
-    {
-    case PRODUCER:
-      certificateName.append("PRODUCER");
-      break;
-    case INTRODUCER:
-      certificateName.append("INTRODUCER");
-      break;
-    default:
-      throw Error("Wrong Introduction Type!");
-    }
-  certificateName.appendVersion();
- 
-  Data::setName(certificateName);
-  setNotBefore(notBefore);
-  setNotAfter(notAfter);
-  setPublicKeyInfo(key);
-  addSubjectDescription(CertificateSubjectDescription("2.5.4.41", keyName.toUri()));
-  encode();
-}
-
-SyncIntroCertificate::SyncIntroCertificate (const Name& nameSpace,
-					    const IdentityCertificate& identityCertificate,
-					    const Name& signerName,
-					    const IntroType& introType)
-  : m_nameSpace(nameSpace)
-  , m_introType(introType)
-{
-  m_keyName = identityCertificate.getPublicKeyName();
-
-  Name certificateName = nameSpace;
-  certificateName.append("WOT").append(m_keyName.wireEncode()).append("INTRO-CERT").append(signerName.wireEncode());
-  switch(introType)
-    {
-    case PRODUCER:
-      certificateName.append("PRODUCER");
-      break;
-    case INTRODUCER:
-      certificateName.append("INTRODUCER");
-      break;
-    default:
-      throw Error("Wrong Introduction Type!");
-    }
-  certificateName.appendVersion();
- 
-  Data::setName(certificateName);
-  setNotBefore(identityCertificate.getNotBefore());
-  setNotAfter(identityCertificate.getNotAfter());
-  setPublicKeyInfo(identityCertificate.getPublicKeyInfo());
-  addSubjectDescription(CertificateSubjectDescription("2.5.4.41", m_keyName.toUri()));
-}
-  
-SyncIntroCertificate::SyncIntroCertificate (const Data& data)
-  : Certificate(data)
-{ setName(getName()); }
-
-SyncIntroCertificate::SyncIntroCertificate (const SyncIntroCertificate& chronosIntroCertificate)
-  : Certificate(chronosIntroCertificate)
-  , m_nameSpace(chronosIntroCertificate.m_nameSpace)
-  , m_keyName(chronosIntroCertificate.m_keyName)
-  , m_introType(chronosIntroCertificate.m_introType)
-{}
-
-Data &
-SyncIntroCertificate::setName (const Name& certificateName)
-{
-  int nameLength = certificateName.size();
-
-  if(nameLength < 6)
-    throw Error("Wrong SyncIntroCertificate Name!");
-
-  m_nameSpace = certificateName.getPrefix(-6);
-
-  if(!certificateName.get(-6).equals("WOT"))
-    throw Error("Wrong SyncIntroCertificate Name!");
-
-  m_keyName.wireDecode(Block(certificateName.get(-5).getValue().buf(), 
-                             certificateName.get(-5).getValue().size()));
-
-  if(!certificateName.get(-4).equals("INTRO-CERT"))
-    throw Error("Wrong SyncIntroCertificate Name!");
-
-  if(certificateName.get(-2).equals("PRODUCER"))
-    m_introType = PRODUCER;
-  else if(certificateName.get(-2).equals("INTRODUCER"))
-    m_introType = INTRODUCER;
-  else
-    throw Error("Wrong SyncIntroCertificate Name!");
-
-  return *this;
-}
-
-bool
-SyncIntroCertificate::isSyncIntroCertificate(const Certificate& certificate)
-{
-  const Name& certificateName = certificate.getName();
-
-  int nameLength = certificateName.size();
-
-  if(nameLength < 6)
-    return false;
-
-  if(!certificateName.get(-6).equals("WOT"))
-    return false;
-
-  if(!certificateName.get(-4).equals("INTRO-CERT"))
-    return false;
-
-  if(!certificateName.get(-2).equals("PRODUCER") && !certificateName.get(-2).equals("INTRODUCER"))
-    return false;
-
-  return true;
-}
diff --git a/src/sync-intro-certificate.h b/src/sync-intro-certificate.h
deleted file mode 100644
index c9560ec..0000000
--- a/src/sync-intro-certificate.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Yingdi Yu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Yingdi Yu <yingdi@cs.ucla.edu>
- */
-
-#ifndef SYNC_INTRO_CERTIFICATE_H
-#define SYNC_INTRO_CERTIFICATE_H
-
-#include <ndn-cpp-dev/security/certificate.hpp>
-#include <ndn-cpp-dev/security/identity-certificate.hpp>
-
-class SyncIntroCertificate : public ndn::Certificate
-{
-public:
-  struct Error : public ndn::Certificate::Error { Error(const std::string &what) : ndn::Certificate::Error(what) {} };
-
-  enum IntroType{
-    PRODUCER,
-    INTRODUCER
-  };
-  
-public:
-  SyncIntroCertificate ();
-  
-  SyncIntroCertificate (const ndn::Name& nameSpace,
-                        const ndn::Name& keyName,
-                        const ndn::Name& signerName,
-                        const ndn::MillisecondsSince1970& notBefore,
-                        const ndn::MillisecondsSince1970& notAfter,
-                        const ndn::PublicKey& key,
-                        const IntroType& introType = PRODUCER);
-  
-  SyncIntroCertificate (const ndn::Name& nameSpace,
-                        const ndn::IdentityCertificate& identityCertificate,
-                        const ndn::Name& signerName,
-                        const IntroType& introType);
-  
-  SyncIntroCertificate (const ndn::Data& data);
-  
-  SyncIntroCertificate (const SyncIntroCertificate& chronosIntroCertificate);
-  
-  
-  virtual 
-  ~SyncIntroCertificate ()
-  {}
-  
-  ndn::Data&
-  setName (const ndn::Name& name);
-  
-  inline const ndn::Name &
-  getPublicKeyName() const;
-  
-  inline IntroType
-  getIntroType();
-
-  inline const ndn::Name &
-  getNameSpace() const;
-  
-  static bool
-  isSyncIntroCertificate(const ndn::Certificate& certificate);
-
-protected:
-  ndn::Name m_nameSpace;
-  ndn::Name m_keyName;
-  IntroType m_introType;
-};
-
-SyncIntroCertificate::IntroType
-SyncIntroCertificate::getIntroType()
-{ return m_introType; }
-
-const ndn::Name &
-SyncIntroCertificate::getPublicKeyName () const
-{ return m_keyName; }
-
-const ndn::Name &
-SyncIntroCertificate::getNameSpace() const
-{ return m_nameSpace; }
-
-#endif
diff --git a/src/sync-logic.cc b/src/sync-logic.cc
index 67fb342..293d90c 100644
--- a/src/sync-logic.cc
+++ b/src/sync-logic.cc
@@ -39,8 +39,6 @@
 
 using namespace std;
 using namespace ndn;
-using namespace ndn::ptr_lib;
-using namespace ndn::func_lib;
 
 INIT_LOGGER ("SyncLogic");
 
@@ -61,7 +59,7 @@
 {
 
   SyncLogic::SyncLogic (const Name& syncPrefix,
-                        shared_ptr<SecPolicySync> policy, 
+                        shared_ptr<Validator> validator, 
                         shared_ptr<Face> face,
                         LogicUpdateCallback onUpdate,
                         LogicRemoveCallback onRemove)
@@ -71,14 +69,14 @@
     , m_onUpdate (onUpdate)
     , m_onRemove (onRemove)
     , m_perBranch (false)
-    , m_policy(policy)
-    , m_verifier(new Verifier(policy))
+    , m_validator(validator)
     , m_keyChain(new KeyChain())
     , m_face(face)
+    , m_scheduler(*face->ioService())
 #ifndef NS3_MODULE
     , m_randomGenerator (static_cast<unsigned int> (std::time (0)))
-    , m_rangeUniformRandom (m_randomGenerator, uniform_int<> (200,1000))
-    , m_reexpressionJitter (m_randomGenerator, uniform_int<> (100,500))
+    , m_rangeUniformRandom (m_randomGenerator, boost::uniform_int<> (200,1000))
+    , m_reexpressionJitter (m_randomGenerator, boost::uniform_int<> (100,500))
 #else
     , m_rangeUniformRandom (200,1000)
     , m_reexpressionJitter (10,500)
@@ -88,19 +86,18 @@
 #ifndef NS3_MODULE
   // In NS3 module these functions are moved to StartApplication method
 
-  m_syncRegisteredPrefixId = m_face->setInterestFilter(m_syncPrefix, 
-                                                       func_lib::bind(&SyncLogic::onSyncInterest, this, _1, _2, _3, _4), 
-                                                       func_lib::bind(&SyncLogic::onSyncRegisterFailed, this, _1));
+  m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix, 
+                                                        bind(&SyncLogic::onSyncInterest, this, _1, _2), 
+                                                        bind(&SyncLogic::onSyncRegisterFailed, this, _1));
+  
 
-
-  m_scheduler.schedule (TIME_SECONDS (0), // no need to add jitter
-                        func_lib::bind (&SyncLogic::sendSyncInterest, this),
-                        REEXPRESSING_INTEREST);
+  m_reexpressingInterestId = m_scheduler.scheduleEvent (time::seconds (0), // no need to add jitter
+                                                        bind (&SyncLogic::sendSyncInterest, this));
 #endif
 }
 
 SyncLogic::SyncLogic (const Name& syncPrefix,
-                      shared_ptr<SecPolicySync> policy,
+                      shared_ptr<Validator> validator,
                       shared_ptr<Face> face,
                       LogicPerBranchCallback onUpdateBranch)
   : m_state (new FullState)
@@ -108,14 +105,14 @@
   , m_syncPrefix (syncPrefix)
   , m_onUpdateBranch (onUpdateBranch)
   , m_perBranch(true)
-  , m_policy(policy)
-  , m_verifier(new Verifier(policy))
+  , m_validator(validator)
   , m_keyChain(new KeyChain())
   , m_face(face)
+  , m_scheduler(*face->ioService())
 #ifndef NS3_MODULE
   , m_randomGenerator (static_cast<unsigned int> (std::time (0)))
-  , m_rangeUniformRandom (m_randomGenerator, uniform_int<> (200,1000))
-  , m_reexpressionJitter (m_randomGenerator, uniform_int<> (100,500))
+  , m_rangeUniformRandom (m_randomGenerator, boost::uniform_int<> (200,1000))
+  , m_reexpressionJitter (m_randomGenerator, boost::uniform_int<> (100,500))
 #else
   , m_rangeUniformRandom (200,1000)
   , m_reexpressionJitter (10,500)
@@ -125,19 +122,18 @@
 #ifndef NS3_MODULE
   // In NS3 module these functions are moved to StartApplication method
   
-  m_syncRegisteredPrefixId = m_face->setInterestFilter(m_syncPrefix, 
-                                                       func_lib::bind(&SyncLogic::onSyncInterest, this, _1, _2, _3, _4), 
-                                                       func_lib::bind(&SyncLogic::onSyncRegisterFailed, this, _1));
+  m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix, 
+                                                        bind(&SyncLogic::onSyncInterest, this, _1, _2), 
+                                                        bind(&SyncLogic::onSyncRegisterFailed, this, _1));
 
-  m_scheduler.schedule (TIME_SECONDS (0), // no need to add jitter
-                        func_lib::bind (&SyncLogic::sendSyncInterest, this),
-                        REEXPRESSING_INTEREST);
+  m_reexpressingInterestId = m_scheduler.scheduleEvent (time::seconds (0), // no need to add jitter
+                                                        bind (&SyncLogic::sendSyncInterest, this));
 #endif
 }
 
 SyncLogic::~SyncLogic ()
-{
-  m_face->unsetInterestFilter(m_syncRegisteredPrefixId);
+{ 
+  // m_face->unsetInterestFilter(m_syncRegisteredPrefixId); 
 }
 
 #ifdef NS3_MODULE
@@ -169,8 +165,8 @@
 SyncLogic::stop()
 {
   m_face->unsetInterestFilter(m_syncRegisteredPrefixId);
-  m_scheduler.cancel (REEXPRESSING_INTEREST);
-  m_scheduler.cancel (DELAYED_INTEREST_PROCESSING);
+  m_scheduler.cancelEvent (m_reexpressingInterestId);
+  m_scheduler.cancelEvent (m_delayedInterestProcessingId);
 }
 
 /**
@@ -207,9 +203,7 @@
 
 void
 SyncLogic::onSyncInterest (const shared_ptr<const Name>& prefix, 
-                           const shared_ptr<const ndn::Interest>& interest, 
-                           Transport& transport, 
-                           uint64_t registeredPrefixId)
+                           const shared_ptr<const ndn::Interest>& interest)
 {
   Name name = interest->getName();
 
@@ -249,46 +243,24 @@
 void
 SyncLogic::onSyncData(const shared_ptr<const ndn::Interest>& interest, 
                       const shared_ptr<Data>& data,
-                      const OnVerified& onVerified,
-                      const OnVerifyFailed& onVerifyFailed)
-{
-  m_verifier->verifyData(data, onVerified, onVerifyFailed);
+                      const OnDataValidated& onValidated,
+                      const OnDataValidationFailed& onValidationFailed)
+{ m_validator->validate(data, onValidated, onValidationFailed); }
+
+void
+SyncLogic::onSyncTimeout(const shared_ptr<const ndn::Interest>& interest)
+{ 
+  // It is OK. Others will handle the time out situation. 
 }
 
 void
-SyncLogic::onSyncDataTimeout(const shared_ptr<const ndn::Interest>& interest, 
-                             int retry,
-                             const OnVerified& onVerified,
-                             const OnVerifyFailed& onVerifyFailed)
-{
-  if(retry > 0)
-    {
-      m_face->expressInterest(*interest, 
-                              func_lib::bind(&SyncLogic::onSyncData,
-                                   this,
-                                   _1,
-                                   _2,     
-                                   onVerified,
-                                   onVerifyFailed),
-                              func_lib::bind(&SyncLogic::onSyncDataTimeout, 
-                                   this,
-                                   _1,
-                                   retry - 1,
-                                   onVerified,
-                                   onVerifyFailed));
-    }
-  else
-    _LOG_DEBUG("Sync interest eventually times out!");
-}
-
-void
-SyncLogic::onSyncDataVerifyFailed(const shared_ptr<Data>& data)
+SyncLogic::onSyncDataValidationFailed(const shared_ptr<const Data>& data)
 {
   _LOG_DEBUG("Sync data cannot be verified!");
 }
 
 void
-SyncLogic::onSyncDataVerified(const shared_ptr<Data>& data)
+SyncLogic::onSyncDataValidated(const shared_ptr<const Data>& data)
 {
   Name name = data->getName();
   const char* wireData = (const char*)data->getContent().value();
@@ -309,7 +281,7 @@
       else
         {
           // timer is always restarted when we schedule recovery
-          m_scheduler.cancel (REEXPRESSING_RECOVERY_INTEREST);
+          m_scheduler.cancelEvent (m_reexpressingRecoveryInterestId);
           processSyncData (name, digest, wireData, len);
         }
     }
@@ -367,15 +339,14 @@
       if (exists) // somebody else replied, so restart random-game timer
         {
           _LOG_DEBUG ("Unknown digest, but somebody may have already replied, so restart our timer");
-          m_scheduler.cancel (DELAYED_INTEREST_PROCESSING);
+          m_scheduler.cancelEvent (m_delayedInterestProcessingId);
         }
 
       uint32_t waitDelay = GET_RANDOM (m_rangeUniformRandom);      
       _LOG_DEBUG ("Digest is not in the log. Schedule processing after small delay: " << waitDelay << "ms");
 
-      m_scheduler.schedule (TIME_MILLISECONDS (waitDelay),
-                            func_lib::bind (&SyncLogic::processSyncInterest, this, name, digest, true),
-                            DELAYED_INTEREST_PROCESSING);
+      m_delayedInterestProcessingId = m_scheduler.scheduleEvent (time::milliseconds (waitDelay),
+                                                                 bind (&SyncLogic::processSyncInterest, this, name, digest, true));
     }
   else
     {
@@ -411,7 +382,7 @@
       vector<MissingDataInfo> v;
       BOOST_FOREACH (LeafConstPtr leaf, diff.getLeaves().get<ordered>())
         {
-          DiffLeafConstPtr diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
+          DiffLeafConstPtr diffLeaf = boost::dynamic_pointer_cast<const DiffLeaf> (leaf);
           BOOST_ASSERT (diffLeaf != 0);
 
           NameInfoConstPtr info = diffLeaf->getInfo();
@@ -424,7 +395,7 @@
               SeqNo oldSeq;
               {
                 boost::recursive_mutex::scoped_lock lock (m_stateMutex);
-                tie (inserted, updated, oldSeq) = m_state->update (info, seq);
+                boost::tie (inserted, updated, oldSeq) = m_state->update (info, seq);
               }
 
               if (inserted || updated)
@@ -499,10 +470,9 @@
       // satisfyPendingSyncInterests (diffLog); // if there are interests in PIT, there is a point to satisfy them using new state
   
       // if state has changed, then it is safe to express a new interest
-      m_scheduler.cancel (REEXPRESSING_INTEREST);
-      m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (0),
-                            func_lib::bind (&SyncLogic::sendSyncInterest, this),
-                            REEXPRESSING_INTEREST);
+      m_scheduler.cancelEvent (m_reexpressingInterestId);
+      m_reexpressingInterestId = m_scheduler.scheduleEvent (time::milliseconds(GET_RANDOM (m_reexpressionJitter)),
+                                                            bind (&SyncLogic::sendSyncInterest, this));
     }
 }
 
@@ -580,7 +550,7 @@
 }
 
 void
-SyncLogic::addLocalNames (const Name &prefix, uint32_t session, uint32_t seq)
+SyncLogic::addLocalNames (const Name &prefix, uint64_t session, uint64_t seq)
 {
   DiffStatePtr diff;
   {
@@ -651,19 +621,19 @@
 
   _LOG_DEBUG("sendSyncInterest: " << m_outstandingInterestName);
 
-  m_scheduler.cancel (REEXPRESSING_INTEREST);
-  m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (m_syncInterestReexpress),
-                        func_lib::bind (&SyncLogic::sendSyncInterest, this),
-                        REEXPRESSING_INTEREST);
+  m_scheduler.cancelEvent (m_reexpressingInterestId);
+  m_reexpressingInterestId = m_scheduler.scheduleEvent (time::seconds(m_syncInterestReexpress)+time::milliseconds(GET_RANDOM (m_reexpressionJitter)),
+                                                        bind (&SyncLogic::sendSyncInterest, this));
 
   ndn::Interest interest(m_outstandingInterestName);
+  interest.setMustBeFresh(true);
 
-  OnVerified onVerified = func_lib::bind(&SyncLogic::onSyncDataVerified, this, _1);
-  OnVerifyFailed onVerifyFailed = func_lib::bind(&SyncLogic::onSyncDataVerifyFailed, this, _1);
+  OnDataValidated onValidated = bind(&SyncLogic::onSyncDataValidated, this, _1);
+  OnDataValidationFailed onValidationFailed = bind(&SyncLogic::onSyncDataValidationFailed, this, _1);
 
   m_face->expressInterest(interest,
-                          func_lib::bind(&SyncLogic::onSyncData, this, _1, _2, onVerified, onVerifyFailed),
-                          func_lib::bind(&SyncLogic::onSyncDataTimeout, this, _1, 0, onVerified, onVerifyFailed));
+                          bind(&SyncLogic::onSyncData, this, _1, _2, onValidated, onValidationFailed),
+                          bind(&SyncLogic::onSyncTimeout, this, _1));
 }
 
 void
@@ -675,25 +645,24 @@
   Name interestName = m_syncPrefix;
   interestName.append("recovery").append(os.str());
 
-  TimeDuration nextRetransmission = TIME_MILLISECONDS_WITH_JITTER (m_recoveryRetransmissionInterval);
+  time::Duration nextRetransmission = time::milliseconds (m_recoveryRetransmissionInterval + GET_RANDOM (m_reexpressionJitter));
+
   m_recoveryRetransmissionInterval <<= 1;
     
-  m_scheduler.cancel (REEXPRESSING_RECOVERY_INTEREST);
+  m_scheduler.cancelEvent (m_reexpressingRecoveryInterestId);
   if (m_recoveryRetransmissionInterval < 100*1000) // <100 seconds
-    {
-      m_scheduler.schedule (nextRetransmission,
-                            func_lib::bind (&SyncLogic::sendSyncRecoveryInterests, this, digest),
-                            REEXPRESSING_RECOVERY_INTEREST);
-    }
+    m_reexpressingRecoveryInterestId = m_scheduler.scheduleEvent (nextRetransmission,
+                                                                  bind (&SyncLogic::sendSyncRecoveryInterests, this, digest));
 
   ndn::Interest interest(interestName);
+  interest.setMustBeFresh(true);
 
-  OnVerified onVerified = func_lib::bind(&SyncLogic::onSyncDataVerified, this, _1);
-  OnVerifyFailed onVerifyFailed = func_lib::bind(&SyncLogic::onSyncDataVerifyFailed, this, _1);
+  OnDataValidated onValidated = bind(&SyncLogic::onSyncDataValidated, this, _1);
+  OnDataValidationFailed onValidationFailed = bind(&SyncLogic::onSyncDataValidationFailed, this, _1);
 
   m_face->expressInterest(interest,
-                          func_lib::bind(&SyncLogic::onSyncData, this, _1, _2, onVerified, onVerifyFailed),
-                          func_lib::bind(&SyncLogic::onSyncDataTimeout, this, _1, 0, onVerified, onVerifyFailed));
+                          bind(&SyncLogic::onSyncData, this, _1, _2, onValidated, onValidationFailed),
+                          bind(&SyncLogic::onSyncTimeout, this, _1));
 }
 
 
@@ -713,12 +682,12 @@
   _LOG_TRACE (">> D " << name);
   int size = ssm.ByteSize();
   char *wireData = new char[size];
-  Name signingIdentity = m_policy->inferSigningIdentity(name);
+  ssm.SerializeToArray(wireData, size);
 
   Data syncData(name);
   syncData.setContent(reinterpret_cast<const uint8_t*>(wireData), size);
   
-  m_keyChain->signByIdentity(syncData, signingIdentity);
+  m_keyChain->sign(syncData);
   
   m_face->put(syncData);
   
@@ -735,10 +704,9 @@
     {
       _LOG_TRACE ("Satisfied our own Interest. Re-expressing (hopefully with a new digest)");
       
-      m_scheduler.cancel (REEXPRESSING_INTEREST);
-      m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (0),
-                            bind (&SyncLogic::sendSyncInterest, this),
-                            REEXPRESSING_INTEREST);
+      m_scheduler.cancelEvent (m_reexpressingInterestId);
+      m_reexpressingInterestId = m_scheduler.scheduleEvent (time::milliseconds(GET_RANDOM (m_reexpressionJitter)),
+                                                            bind (&SyncLogic::sendSyncInterest, this));
     }
 }
 
diff --git a/src/sync-logic.h b/src/sync-logic.h
index d3e70c1..5efb81e 100644
--- a/src/sync-logic.h
+++ b/src/sync-logic.h
@@ -31,15 +31,14 @@
 #include <map>
 
 #include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/security/verifier.hpp>
+#include <ndn-cpp-dev/security/validator.hpp>
 #include <ndn-cpp-dev/security/key-chain.hpp>
+#include <ndn-cpp-dev/util/scheduler.hpp>
 
 #include "sync-interest-table.h"
 #include "sync-diff-state.h"
 #include "sync-full-state.h"
 #include "sync-std-name-info.h"
-#include "sync-scheduler.h"
-#include "sec-policy-sync.h"
 
 #include "sync-diff-state-container.h"
 
@@ -88,14 +87,14 @@
    * the app data when new remote names are learned
    */
   SyncLogic (const ndn::Name& syncPrefix,
-             ndn::ptr_lib::shared_ptr<SecPolicySync> syncPolicyManager,
-             ndn::ptr_lib::shared_ptr<ndn::Face> face,
+             ndn::shared_ptr<ndn::Validator> validator,
+             ndn::shared_ptr<ndn::Face> face,
              LogicUpdateCallback onUpdate,
              LogicRemoveCallback onRemove);
 
   SyncLogic (const ndn::Name& syncPrefix,
-             ndn::ptr_lib::shared_ptr<SecPolicySync> syncPolicyManager,
-             ndn::ptr_lib::shared_ptr<ndn::Face> face,
+             ndn::shared_ptr<ndn::Validator> validator,
+             ndn::shared_ptr<ndn::Face> face,
              LogicPerBranchCallback onUpdateBranch);
 
   ~SyncLogic ();
@@ -103,20 +102,20 @@
   /**
    * a wrapper for the same func in SyncApp
    */
-  void addLocalNames (const ndn::Name &prefix, uint32_t session, uint32_t seq);
+  void addLocalNames (const ndn::Name &prefix, uint64_t session, uint64_t seq);
 
   /**
    * @brief respond to the Sync Interest; a lot of logic needs to go in here
    * @param interest the Sync Interest in string format
    */
-  void respondSyncInterest (ndn::ptr_lib::shared_ptr<ndn::Interest> interest);
+  void respondSyncInterest (ndn::shared_ptr<ndn::Interest> interest);
 
   /**
    * @brief process the fetched sync data
    * @param name the data name
    * @param dataBuffer the sync data
    */
-  void respondSyncData (ndn::ptr_lib::shared_ptr<ndn::Data> data);
+  void respondSyncData (ndn::shared_ptr<ndn::Data> data);
 
   /**
    * @brief remove a participant's subtree from the sync tree
@@ -128,7 +127,7 @@
   getRootDigest();
 
 #ifdef _DEBUG
-  Scheduler &
+  ndn::Scheduler &
   getScheduler () { return m_scheduler; }
 #endif
 
@@ -146,46 +145,31 @@
   std::map<std::string, bool>
   getBranchPrefixes() const;
 
-private:
-  // void
-  // connectToDaemon();
-
-  // void
-  // onConnectionData(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
-  //                  const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
- 
-  // void
-  // onConnectionDataTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest);
- 
+private: 
   void
   delayedChecksLoop ();
 
   void
-  onSyncInterest (const ndn::ptr_lib::shared_ptr<const ndn::Name>& prefix, 
-                  const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
-                  ndn::Transport& transport, 
-                  uint64_t registeredPrefixId);
+  onSyncInterest (const ndn::shared_ptr<const ndn::Name>& prefix, 
+                  const ndn::shared_ptr<const ndn::Interest>& interest);
 
   void
-  onSyncRegisterFailed(const ndn::ptr_lib::shared_ptr<const ndn::Name>& prefix);
+  onSyncRegisterFailed(const ndn::shared_ptr<const ndn::Name>& prefix);
 
   void
-  onSyncData(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
-             const ndn::ptr_lib::shared_ptr<ndn::Data>& data,
-             const ndn::OnVerified& onVerified,
-             const ndn::OnVerifyFailed& onVerifyFailed);
+  onSyncData(const ndn::shared_ptr<const ndn::Interest>& interest, 
+             const ndn::shared_ptr<ndn::Data>& data,
+             const ndn::OnDataValidated& onValidated,
+             const ndn::OnDataValidationFailed& onValidationFailed);
 
   void
-  onSyncDataTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
-                    int retry,
-                    const ndn::OnVerified& onVerified,
-                    const ndn::OnVerifyFailed& onVerifyFailed);
+  onSyncTimeout(const ndn::shared_ptr<const ndn::Interest>& interest);
 
   void
-  onSyncDataVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
+  onSyncDataValidationFailed(const ndn::shared_ptr<const ndn::Data>& data);
 
   void
-  onSyncDataVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
+  onSyncDataValidated(const ndn::shared_ptr<const ndn::Data>& data);
 
   void
   processSyncInterest (const ndn::Name &name,
@@ -238,13 +222,12 @@
   LogicRemoveCallback m_onRemove;
   LogicPerBranchCallback m_onUpdateBranch;
   bool m_perBranch;
-  ndn::ptr_lib::shared_ptr<SecPolicySync> m_policy;
-  ndn::ptr_lib::shared_ptr<ndn::Verifier> m_verifier;
+  ndn::ptr_lib::shared_ptr<ndn::Validator> m_validator;
   ndn::ptr_lib::shared_ptr<ndn::KeyChain> m_keyChain;
   ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
-  uint64_t m_syncRegisteredPrefixId;
+  const ndn::RegisteredPrefixId* m_syncRegisteredPrefixId;
 
-  Scheduler m_scheduler;
+  ndn::Scheduler m_scheduler;
 
 #ifndef NS3_MODULE
   boost::mt19937 m_randomGenerator;
@@ -268,12 +251,9 @@
   static const int m_defaultRecoveryRetransmitInterval = 200; // milliseconds
   uint32_t m_recoveryRetransmissionInterval; // milliseconds
   
-  enum EventLabels
-    {
-      DELAYED_INTEREST_PROCESSING = 1,
-      REEXPRESSING_INTEREST = 2,
-      REEXPRESSING_RECOVERY_INTEREST = 3
-    };
+  ndn::EventId m_delayedInterestProcessingId;
+  ndn::EventId m_reexpressingInterestId;
+  ndn::EventId m_reexpressingRecoveryInterestId;
 };
 
 
diff --git a/src/sync-seq-no.h b/src/sync-seq-no.h
index e2ed016..bf21704 100644
--- a/src/sync-seq-no.h
+++ b/src/sync-seq-no.h
@@ -18,6 +18,7 @@
  * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
  *         Chaoyi Bian <bcy@pku.edu.cn>
  *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ *         Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
 #ifndef SYNC_SEQ_NO_H
@@ -72,7 +73,7 @@
    * @brief Constructor with just sequence number. Session assumed to be zero
    * @param seq Sequence number
    */
-  SeqNo (uint32_t seq)
+  SeqNo (uint64_t seq)
     : m_valid (true)
     , m_session (0)
     , m_seq (seq)
@@ -83,7 +84,7 @@
    * @param session Session ID
    * @param seq Sequence number
    */
-  SeqNo (uint32_t session, uint32_t seq)
+  SeqNo (uint64_t session, uint64_t seq)
     : m_valid (true)
     , m_session (session)
     , m_seq (seq)
@@ -148,20 +149,20 @@
   /**
    * @brief Get session id
    */
-  uint32_t getSession () const
+  uint64_t getSession () const
   { return m_session; }
 
   /**
    * @brief Get sequence number
    */
-  uint32_t getSeq () const
+  uint64_t getSeq () const
   { return m_seq; }
 
   /**
    * @brief Set sequence number
    */
    void
-   setSeq(uint32_t seq)
+   setSeq(uint64_t seq)
    { m_seq = seq; }
   
 private:
@@ -173,7 +174,7 @@
    * Note that session IDs for the same name should always increase. So, the good choice
    * for the session ID is client's timestamp
    */
-  uint32_t m_session;
+  uint64_t m_session;
 
   /**
    * @brief Sequence number
@@ -182,7 +183,7 @@
    *
    * For now, wrapping sequence number after max to zero is not supported
    */
-  uint32_t m_seq;
+  uint64_t m_seq;
 };
 
 inline std::ostream &
diff --git a/src/sync-socket.cc b/src/sync-socket.cc
index 02fb85d..259e730 100644
--- a/src/sync-socket.cc
+++ b/src/sync-socket.cc
@@ -23,53 +23,44 @@
 
 using namespace std;
 using namespace ndn;
-using namespace ndn::ptr_lib;
 
 INIT_LOGGER ("SyncSocket");
 
 namespace Sync {
 
-SyncSocket::SyncSocket (const string &syncPrefix, 
-                        shared_ptr<SecPolicySync> policy,
+SyncSocket::SyncSocket (const Name &syncPrefix, 
+                        shared_ptr<Validator> validator,
                         shared_ptr<Face> face,
                         NewDataCallback dataCallback, 
                         RemoveCallback rmCallback )
   : m_newDataCallback(dataCallback)
-  , m_policy(policy)
-  , m_verifier(new Verifier(policy))
+  , m_validator(validator)
   , m_keyChain(new KeyChain())
   , m_face(face)
   , m_syncLogic (syncPrefix,
-                 policy,
+                 validator,
                  face,
                  bind(&SyncSocket::passCallback, this, _1),
                  rmCallback)
-{
-  m_verifier->setFace(face);
-}
+{}
 
 SyncSocket::~SyncSocket()
 {
 }
 
 bool 
-SyncSocket::publishData(const Name &prefix, uint32_t session, const char *buf, size_t len, int freshness)
+SyncSocket::publishData(const Name &prefix, uint64_t session, const char *buf, size_t len, int freshness)
 {
-  uint32_t sequence = getNextSeq(prefix, session);
-  ostringstream sessionStream;
-  ostringstream seqStream;
-  sessionStream <<  session;
-  seqStream << sequence;
+  uint64_t sequence = getNextSeq(prefix, session);
   
   Name dataName = prefix;
-  dataName.append(sessionStream.str()).append(seqStream.str());
-  
-  Name signingIdentity = m_policy->inferSigningIdentity(dataName);
+  dataName.append(boost::lexical_cast<string>(session)).append(boost::lexical_cast<string>(sequence));
 
   Data data(dataName);
   data.setContent(reinterpret_cast<const uint8_t*>(buf), len);
+  data.setFreshnessPeriod(freshness);
 
-  m_keyChain->signByIdentity(data, signingIdentity);
+  m_keyChain->sign(data);
   
   m_face->put(data);
   
@@ -80,40 +71,35 @@
 }
 
 void 
-SyncSocket::fetchData(const Name &prefix, const SeqNo &seq, const OnVerified& onVerified, int retry)
+SyncSocket::fetchData(const Name &prefix, const SeqNo &seq, const OnDataValidated& onValidated, int retry)
 {
-  ostringstream sessionStream;
-  ostringstream seqStream;
-  sessionStream << seq.getSession();
-  seqStream << seq.getSeq();
-
   Name interestName = prefix;
-  interestName.append(sessionStream.str()).append(seqStream.str());
+  interestName.append(boost::lexical_cast<string>(seq.getSession())).append(boost::lexical_cast<string>(seq.getSeq()));
 
-  const OnVerifyFailed& onVerifyFailed = bind(&SyncSocket::onDataVerifyFailed, this, _1);
-  
+  const OnDataValidationFailed& onValidationFailed = bind(&SyncSocket::onDataValidationFailed, this, _1);
   
   ndn::Interest interest(interestName);
+  interest.setMustBeFresh(true);
   m_face->expressInterest(interest, 
-                          bind(&SyncSocket::onData, this, _1, _2, onVerified, onVerifyFailed), 
-                          bind(&SyncSocket::onDataTimeout, this, _1, retry, onVerified, onVerifyFailed));
+                          bind(&SyncSocket::onData, this, _1, _2, onValidated, onValidationFailed), 
+                          bind(&SyncSocket::onDataTimeout, this, _1, retry, onValidated, onValidationFailed));
 
 }
 
 void
 SyncSocket::onData(const shared_ptr<const ndn::Interest>& interest, 
                    const shared_ptr<Data>& data,
-                   const OnVerified& onVerified,
-                   const OnVerifyFailed& onVerifyFailed)
+                   const OnDataValidated& onValidated,
+                   const OnDataValidationFailed& onValidationFailed)
 {
-  m_verifier->verifyData(data, onVerified, onVerifyFailed);
+  m_validator->validate(data, onValidated, onValidationFailed);
 }
 
 void
 SyncSocket::onDataTimeout(const shared_ptr<const ndn::Interest>& interest, 
                           int retry,
-                          const OnVerified& onVerified,
-                          const OnVerifyFailed& onVerifyFailed)
+                          const OnDataValidated& onValidated,
+                          const OnDataValidationFailed& onValidationFailed)
 {
   if(retry > 0)
     {
@@ -122,14 +108,14 @@
                                    this,
                                    _1,
                                    _2,
-                                   onVerified,
-                                   onVerifyFailed),
+                                   onValidated,
+                                   onValidationFailed),
                               bind(&SyncSocket::onDataTimeout, 
                                    this,
                                    _1,
                                    retry - 1,
-                                   onVerified,
-                                   onVerifyFailed));
+                                   onValidated,
+                                   onValidationFailed));
                               
     }
   else
@@ -137,14 +123,14 @@
 }
 
 void
-SyncSocket::onDataVerifyFailed(const shared_ptr<Data>& data)
+SyncSocket::onDataValidationFailed(const shared_ptr<const Data>& data)
 {
   _LOG_DEBUG("data cannot be verified!");
 }
 
 
-uint32_t
-SyncSocket::getNextSeq (const Name &prefix, uint32_t session)
+uint64_t
+SyncSocket::getNextSeq (const Name &prefix, uint64_t session)
 {
   SequenceLog::iterator i = m_sequenceLog.find (prefix);
 
diff --git a/src/sync-socket.h b/src/sync-socket.h
index b558ff9..f1af423 100644
--- a/src/sync-socket.h
+++ b/src/sync-socket.h
@@ -22,11 +22,12 @@
 #define SYNC_SOCKET_H
 
 #include "sync-logic.h"
-#include <boost/function.hpp>
 #include "sync-seq-no.h"
+
 #include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/security/verifier.hpp>
+#include <ndn-cpp-dev/security/validator.hpp>
 #include <ndn-cpp-dev/security/key-chain.hpp>
+
 #include <utility>
 #include <map>
 #include <vector>
@@ -41,8 +42,9 @@
 class SyncSocket
 {
 public:
-  typedef boost::function< void (const std::vector<MissingDataInfo> &, SyncSocket * ) > NewDataCallback;
-  typedef boost::function< void ( const std::string &/*prefix*/ ) > RemoveCallback;
+  typedef ndn::function< void (const std::vector<MissingDataInfo> &, SyncSocket * ) > NewDataCallback;
+  typedef ndn::function< void (const std::string &/*prefix*/ ) > RemoveCallback;
+
   /**
    * @brief the constructor for SyncAppSocket; the parameter syncPrefix
    * should be passed to the constructor of m_syncAppWrapper; the other
@@ -54,30 +56,30 @@
    * @param syncPrefix the name prefix for Sync Interest
    * @param dataCallback the callback to process data
    */
-  SyncSocket (const std::string &syncPrefix, 
-              ndn::ptr_lib::shared_ptr<SecPolicySync> policy,
-              ndn::ptr_lib::shared_ptr<ndn::Face> face,
+  SyncSocket (const ndn::Name &syncPrefix, 
+              ndn::shared_ptr<ndn::Validator> validator,
+              ndn::shared_ptr<ndn::Face> face,
               NewDataCallback dataCallback, 
               RemoveCallback rmCallback);
 
   ~SyncSocket ();
 
   bool 
-  publishData(const ndn::Name &prefix, uint32_t session, const char *buf, size_t len, int freshness);
+  publishData(const ndn::Name &prefix, uint64_t session, const char *buf, size_t len, int freshness);
 
   void 
   remove (const ndn::Name &prefix) 
   { m_syncLogic.remove(prefix); }
 
   void 
-  fetchData(const ndn::Name &prefix, const SeqNo &seq, const ndn::OnVerified& onVerified, int retry = 0);
+  fetchData(const ndn::Name &prefix, const SeqNo &seq, const ndn::OnDataValidated& onValidated, int retry = 0);
 
   std::string 
   getRootDigest() 
   { return m_syncLogic.getRootDigest(); }
 
-  uint32_t
-  getNextSeq (const ndn::Name &prefix, uint32_t session);
+  uint64_t
+  getNextSeq (const ndn::Name &prefix, uint64_t session);
 
   SyncLogic &
   getLogic () 
@@ -94,28 +96,27 @@
   { m_newDataCallback(v, this); }
 
   void
-  onData(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
-             const ndn::ptr_lib::shared_ptr<ndn::Data>& data,
-             const ndn::OnVerified& onVerified,
-             const ndn::OnVerifyFailed& onVerifyFailed);
+  onData(const ndn::shared_ptr<const ndn::Interest>& interest, 
+         const ndn::shared_ptr<ndn::Data>& data,
+         const ndn::OnDataValidated& onValidated,
+         const ndn::OnDataValidationFailed& onValidationFailed);
 
   void
-  onDataTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
-                    int retry,
-                    const ndn::OnVerified& onVerified,
-                    const ndn::OnVerifyFailed& onVerifyFailed);
+  onDataTimeout(const ndn::shared_ptr<const ndn::Interest>& interest, 
+                int retry,
+                const ndn::OnDataValidated& onValidated,
+                const ndn::OnDataValidationFailed& onValidationFailed);
 
   void
-  onDataVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
+  onDataValidationFailed(const ndn::shared_ptr<const ndn::Data>& data);
 
 private:
   typedef std::map<ndn::Name, SeqNo> SequenceLog;
   NewDataCallback m_newDataCallback;
   SequenceLog m_sequenceLog;
-  ndn::ptr_lib::shared_ptr<SecPolicySync> m_policy;
-  ndn::ptr_lib::shared_ptr<ndn::Verifier> m_verifier;
-  ndn::ptr_lib::shared_ptr<ndn::KeyChain> m_keyChain;
-  ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
+  ndn::shared_ptr<ndn::Validator> m_validator;
+  ndn::shared_ptr<ndn::KeyChain> m_keyChain;
+  ndn::shared_ptr<ndn::Face> m_face;
   SyncLogic      m_syncLogic;
 };
 
diff --git a/src/sync-state.cc b/src/sync-state.cc
index 71d664e..6c374a4 100644
--- a/src/sync-state.cc
+++ b/src/sync-state.cc
@@ -156,8 +156,8 @@
     NameInfoConstPtr info = StdNameInfo::FindOrCreate (ss.name());
     if (ss.type() == SyncState::UPDATE)
     {
-      uint32_t session = lexical_cast<uint32_t>(ss.seqno().session());
-      uint32_t seq = lexical_cast<uint32_t>(ss.seqno().seq());
+      uint64_t session = lexical_cast<uint64_t>(ss.seqno().session());
+      uint64_t seq = lexical_cast<uint64_t>(ss.seqno().seq());
       SeqNo seqNo(session, seq);
       state.update(info, seqNo);
     }
diff --git a/src/sync-state.proto b/src/sync-state.proto
index 18892fb..7cc6b18 100644
--- a/src/sync-state.proto
+++ b/src/sync-state.proto
@@ -12,8 +12,8 @@
   required ActionType type = 2;
   message SeqNo
   {
-    required uint32 seq = 1;
-    required uint32 session = 2;
+    required uint64 seq = 1;
+    required uint64 session = 2;
   }
   optional SeqNo seqno = 3;
 }
