diff --git a/src/specific-policy-rule.cc b/src/specific-policy-rule.cc
index 9fbd23a..7057ba5 100644
--- a/src/specific-policy-rule.cc
+++ b/src/specific-policy-rule.cc
@@ -9,15 +9,15 @@
  */
 
 #include "specific-policy-rule.h"
-#include <ndn.cxx/fields/signature-sha256-with-rsa.h>
+#include <ndn-cpp/sha256-with-rsa-signature.hpp>
 
 using namespace ndn;
+using namespace ndn::ptr_lib;
 using namespace std;
-using namespace ndn::security;
 
 
-SpecificPolicyRule::SpecificPolicyRule(Ptr<Regex> dataRegex,
-				       Ptr<Regex> signerRegex)
+SpecificPolicyRule::SpecificPolicyRule(shared_ptr<Regex> dataRegex,
+				       shared_ptr<Regex> signerRegex)
   : PolicyRule(PolicyRule::IDENTITY_POLICY, true)
   , m_dataRegex(dataRegex)
   , m_signerRegex(signerRegex)
@@ -30,14 +30,14 @@
 {}
 
 bool 
-SpecificPolicyRule::matchDataName(const Data & data)
+SpecificPolicyRule::matchDataName(const Data& data)
 { return m_dataRegex->match(data.getName()); }
 
 bool 
-SpecificPolicyRule::matchSignerName(const Data & data)
+SpecificPolicyRule::matchSignerName(const Data& data)
 { 
-  Ptr<const signature::Sha256WithRsa> sigPtr = DynamicCast<const signature::Sha256WithRsa> (data.getSignature());
-  Name signerName = sigPtr->getKeyLocator ().getKeyName ();
+  const Sha256WithRsaSignature* sigPtr = dynamic_cast<const Sha256WithRsaSignature*> (data.getSignature());
+  Name signerName = sigPtr->getKeyLocator().getKeyName ();
   return m_signerRegex->match(signerName); 
 }
 
diff --git a/src/specific-policy-rule.h b/src/specific-policy-rule.h
index e2b859b..429eff7 100644
--- a/src/specific-policy-rule.h
+++ b/src/specific-policy-rule.h
@@ -11,15 +11,15 @@
 #ifndef SPECIFIC_POLICY_RULE_H
 #define SPECIFIC_POLICY_RULE_H
 
-#include <ndn.cxx/security/policy/policy-rule.h>
-#include <ndn.cxx/regex/regex.h>
+#include <ndn-cpp-et/policy-manager/policy-rule.hpp>
+#include <ndn-cpp-et/regex/regex.hpp>
 
-class SpecificPolicyRule : public ndn::security::PolicyRule
+class SpecificPolicyRule : public ndn::PolicyRule
 {
   
 public:
-  SpecificPolicyRule(ndn::Ptr<ndn::Regex> dataRegex,
-                     ndn::Ptr<ndn::Regex> signerRegex);
+  SpecificPolicyRule(ndn::ptr_lib::shared_ptr<ndn::Regex> dataRegex,
+                     ndn::ptr_lib::shared_ptr<ndn::Regex> signerRegex);
 
   SpecificPolicyRule(const SpecificPolicyRule& rule);
 
@@ -27,20 +27,20 @@
   ~SpecificPolicyRule() {};
 
   bool 
-  matchDataName(const ndn::Data & data);
+  matchDataName(const ndn::Data& data);
 
   bool 
-  matchSignerName(const ndn::Data & data);
+  matchSignerName(const ndn::Data& data);
 
   bool
-  satisfy(const ndn::Data & data);
+  satisfy(const ndn::Data& data);
 
   bool
-  satisfy(const ndn::Name & dataName, const ndn::Name & signerName);
+  satisfy(const ndn::Name& dataName, const ndn::Name& signerName);
   
 private:
-  ndn::Ptr<ndn::Regex> m_dataRegex;
-  ndn::Ptr<ndn::Regex> m_signerRegex;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_dataRegex;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_signerRegex;
 };
 
 #endif //CHAT_POLICY_RULE_H
diff --git a/src/sync-intro-certificate.cc b/src/sync-intro-certificate.cc
index e9587e9..d7e75f8 100644
--- a/src/sync-intro-certificate.cc
+++ b/src/sync-intro-certificate.cc
@@ -9,11 +9,13 @@
  */
 
 #include "sync-intro-certificate.h"
-#include <ndn.cxx/security/exception.h>
+#include <ndn-cpp/security/security-exception.hpp>
+
+#include <boost/date_time/posix_time/posix_time.hpp>
 
 using namespace ndn;
-using namespace ndn::security;
 using namespace std;
+using namespace boost;
 
 SyncIntroCertificate::SyncIntroCertificate ()
   : Certificate()
@@ -22,9 +24,9 @@
 SyncIntroCertificate::SyncIntroCertificate (const Name& nameSpace,
 					    const Name& keyName,
 					    const Name& signerName,
-					    const Time& notBefore,
-					    const Time& notAfter,
-					    const Publickey& key,
+					    const MillisecondsSince1970& notBefore,
+					    const MillisecondsSince1970& notAfter,
+					    const PublicKey& key,
 					    const IntroType& introType)
   : m_keyName(keyName)
   , m_introType(introType)
@@ -40,15 +42,18 @@
       certificateName.append("INTRODUCER");
       break;
     default:
-      throw SecException("Wrong Introduction Type!");
+      throw SecurityException("Wrong Introduction Type!");
     }
-  certificateName.appendVersion();
+
+  posix_time::time_duration now = posix_time::microsec_clock::universal_time () - posix_time::ptime(gregorian::date (1970, boost::gregorian::Jan, 1));
+  uint64_t version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244));
+  certificateName.appendVersion(version);
  
   Data::setName(certificateName);
   setNotBefore(notBefore);
   setNotAfter(notAfter);
   setPublicKeyInfo(key);
-  addSubjectDescription(CertificateSubDescrypt("2.5.4.41", keyName.toUri()));
+  addSubjectDescription(CertificateSubjectDescription("2.5.4.41", keyName.toUri()));
   encode();
 }
 
@@ -71,15 +76,17 @@
       certificateName.append("INTRODUCER");
       break;
     default:
-      throw SecException("Wrong Introduction Type!");
+      throw SecurityException("Wrong Introduction Type!");
     }
-  certificateName.appendVersion();
+  posix_time::time_duration now = posix_time::microsec_clock::universal_time () - posix_time::ptime(gregorian::date (1970, boost::gregorian::Jan, 1));
+  uint64_t version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244));
+  certificateName.appendVersion(version);
  
   setName(certificateName);
   setNotBefore(identityCertificate.getNotBefore());
   setNotAfter(identityCertificate.getNotAfter());
   setPublicKeyInfo(identityCertificate.getPublicKeyInfo());
-  addSubjectDescription(CertificateSubDescrypt("2.5.4.41", m_keyName.toUri()));
+  addSubjectDescription(CertificateSubjectDescription("2.5.4.41", m_keyName.toUri()));
 }
   
 SyncIntroCertificate::SyncIntroCertificate (const Data& data)
@@ -91,7 +98,7 @@
   int keyNameEnd = 0;
   for(; i < certificateName.size(); i++)
     {
-      if(certificateName.get(i).toUri() == string("WOT"))
+      if(certificateName.get(i).toEscapedString() == string("WOT"))
 	{
 	  keyNameStart = i + 1;
 	  break;
@@ -99,11 +106,11 @@
     }
   
   if(i >= certificateName.size())
-    throw SecException("Wrong SyncIntroCertificate Name!");
+    throw SecurityException("Wrong SyncIntroCertificate Name!");
     
   for(; i< certificateName.size(); i++)
     {
-      if(certificateName.get(i).toUri() == string("INTRO-CERT"))
+      if(certificateName.get(i).toEscapedString() == string("INTRO-CERT"))
 	{
 	  keyNameEnd = i;
 	  break;
@@ -111,17 +118,17 @@
     }
 
   if(i >= certificateName.size())
-    throw SecException("Wrong SyncIntroCertificate Name!");
+    throw SecurityException("Wrong SyncIntroCertificate Name!");
 
   m_keyName = certificateName.getSubName(keyNameStart, keyNameEnd - keyNameStart);
 
-  string typeComponent = certificateName.get(certificateName.size() - 2).toUri();
+  string typeComponent = certificateName.get(certificateName.size() - 2).toEscapedString();
   if(typeComponent == string("PRODUCER"))
     m_introType = PRODUCER;
   else if(typeComponent == string("INTRODUCER"))
     m_introType = INTRODUCER;
   else
-    throw SecException("Wrong SyncIntroCertificate Name!");
+    throw SecurityException("Wrong SyncIntroCertificate Name!");
 }
 
 SyncIntroCertificate::SyncIntroCertificate (const SyncIntroCertificate& chronosIntroCertificate)
@@ -138,7 +145,7 @@
   int keyNameEnd = 0;
   for(; i < certificateName.size(); i++)
     {
-      if(certificateName.get(i).toUri() == string("WOT"))
+      if(certificateName.get(i).toEscapedString() == string("WOT"))
 	{
 	  keyNameStart = i + 1;
 	  break;
@@ -146,11 +153,11 @@
     }
     
   if(i >= certificateName.size())
-    throw SecException("Wrong SyncIntroCertificate Name!");
+    throw SecurityException("Wrong SyncIntroCertificate Name!");
   
   for(; i< certificateName.size(); i++)
     {
-      if(certificateName.get(i).toUri() == string("INTRO-CERT"))
+      if(certificateName.get(i).toEscapedString() == string("INTRO-CERT"))
 	{
 	  keyNameEnd = i;
 	  break;
@@ -158,17 +165,17 @@
     }
 
   if(i >= certificateName.size())
-    throw SecException("Wrong SyncIntroCertificate Name!");
+    throw SecurityException("Wrong SyncIntroCertificate Name!");
 
-  m_keyName = certificateName.getSubName(keyNameStart, keyNameEnd);
+  m_keyName = certificateName.getSubName(keyNameStart, keyNameEnd - keyNameStart);
 
-  string typeComponent = certificateName.get(certificateName.size() - 2).toUri();
+  string typeComponent = certificateName.get(certificateName.size() - 2).toEscapedString();
   if(typeComponent == string("PRODUCER"))
     m_introType = PRODUCER;
   else if(typeComponent == string("INTRODUCER"))
     m_introType = INTRODUCER;
   else
-    throw SecException("Wrong SyncIntroCertificate Name!");
+    throw SecurityException("Wrong SyncIntroCertificate Name!");
     
   return *this;
 }
@@ -177,7 +184,7 @@
 SyncIntroCertificate::isSyncIntroCertificate(const Certificate& certificate)
 {
   const Name& certificateName = certificate.getName();
-  string introType = certificateName.get(certificateName.size() - 2).toUri();
+  string introType = certificateName.get(certificateName.size() - 2).toEscapedString();
   if(introType != string("PRODUCER") && introType != string("INTRODUCER"))
     return false;
 
@@ -186,7 +193,7 @@
   bool findIntroCert = false;
   for(; i < certificateName.size(); i++)
     {
-      if(certificateName.get(i).toUri() == string("WOT"))
+      if(certificateName.get(i).toEscapedString() == string("WOT"))
 	{
 	  findWot = true;
 	  break;
@@ -198,7 +205,7 @@
   
   for(; i < certificateName.size(); i++)
     {
-      if(certificateName.get(i).toUri() == string("INTRO-CERT"))
+      if(certificateName.get(i).toEscapedString() == string("INTRO-CERT"))
 	{
 	  findIntroCert = true;
 	  break;
diff --git a/src/sync-intro-certificate.h b/src/sync-intro-certificate.h
index db41627..cfc5596 100644
--- a/src/sync-intro-certificate.h
+++ b/src/sync-intro-certificate.h
@@ -11,10 +11,10 @@
 #ifndef SYNC_INTRO_CERTIFICATE_H
 #define SYNC_INTRO_CERTIFICATE_H
 
-#include <ndn.cxx/security/certificate/certificate.h>
-#include <ndn.cxx/security/certificate/identity-certificate.h>
+#include <ndn-cpp/security/certificate/certificate.hpp>
+#include <ndn-cpp/security/certificate/identity-certificate.hpp>
 
-class SyncIntroCertificate : public ndn::security::Certificate
+class SyncIntroCertificate : public ndn::Certificate
 {
 public:
   enum IntroType{
@@ -28,13 +28,13 @@
   SyncIntroCertificate (const ndn::Name& nameSpace,
                         const ndn::Name& keyName,
                         const ndn::Name& signerName,
-                        const ndn::Time& notBefore,
-                        const ndn::Time& notAfter,
-                        const ndn::security::Publickey& key,
+                        const ndn::MillisecondsSince1970& notBefore,
+                        const ndn::MillisecondsSince1970& notAfter,
+                        const ndn::PublicKey& key,
                         const IntroType& introType = PRODUCER);
   
   SyncIntroCertificate (const ndn::Name& nameSpace,
-                        const ndn::security::IdentityCertificate& identityCertificate,
+                        const ndn::IdentityCertificate& identityCertificate,
                         const ndn::Name& signerName,
                         const IntroType& introType);
   
@@ -47,7 +47,7 @@
   ~SyncIntroCertificate ()
   {}
   
-  ndn::Data &
+  ndn::Data&
   setName (const ndn::Name& name);
   
   inline virtual ndn::Name 
@@ -59,7 +59,7 @@
   { return m_introType; }
 
   static bool
-  isSyncIntroCertificate(const ndn::security::Certificate& certificate);
+  isSyncIntroCertificate(const ndn::Certificate& certificate);
 
 protected:
   ndn::Name m_keyName;
diff --git a/src/sync-logic.cc b/src/sync-logic.cc
index 06d142a..eccb3fa 100644
--- a/src/sync-logic.cc
+++ b/src/sync-logic.cc
@@ -31,6 +31,9 @@
 #include "sync-logging.h"
 #include "sync-state.h"
 
+#include <ndn-cpp/security/identity/basic-identity-storage.hpp>
+#include <ndn-cpp/security/identity/osx-private-key-storage.hpp>
+
 #include <boost/make_shared.hpp>
 #include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
@@ -39,6 +42,8 @@
 using namespace std;
 using namespace boost;
 using namespace ndn;
+using namespace ndn::ptr_lib;
+using namespace ndn::func_lib;
 
 INIT_LOGGER ("SyncLogic");
 
@@ -59,8 +64,7 @@
 {
 
   SyncLogic::SyncLogic (const Name& syncPrefix,
-                        Ptr<SyncPolicyManager> syncPolicyManager, 
-                        Ptr<Wrapper> handler,
+                        shared_ptr<SyncPolicyManager> syncPolicyManager, 
                         LogicUpdateCallback onUpdate,
                         LogicRemoveCallback onRemove)
     : m_state (new FullState)
@@ -70,7 +74,6 @@
     , m_onRemove (onRemove)
     , m_perBranch (false)
     , m_policyManager(syncPolicyManager)
-    , m_handler (handler)
 #ifndef NS3_MODULE
     , m_randomGenerator (static_cast<unsigned int> (std::time (0)))
     , m_rangeUniformRandom (m_randomGenerator, uniform_int<> (200,1000))
@@ -84,8 +87,19 @@
 #ifndef NS3_MODULE
   // In NS3 module these functions are moved to StartApplication method
 
-  m_handler->setInterestFilter (m_syncPrefix, 
-                                bind (&SyncLogic::respondSyncInterest, this, _1));
+  m_transport = make_shared<TcpTransport>();
+  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
+
+  connectToDaemon();
+
+  shared_ptr<BasicIdentityStorage> publicStorage = make_shared<BasicIdentityStorage>();
+  shared_ptr<OSXPrivateKeyStorage> privateStorage = make_shared<OSXPrivateKeyStorage>();
+  m_identityManager = make_shared<IdentityManager>(publicStorage, privateStorage);
+
+  m_syncRegisteredPrefixId = m_face->registerPrefix(m_syncPrefix, 
+                                                    bind(&SyncLogic::onSyncInterest, this, _1, _2, _3, _4), 
+                                                    bind(&SyncLogic::onSyncRegisterFailed, this, _1));
+
 
   m_scheduler.schedule (TIME_SECONDS (0), // no need to add jitter
                         bind (&SyncLogic::sendSyncInterest, this),
@@ -94,8 +108,7 @@
 }
 
 SyncLogic::SyncLogic (const Name& syncPrefix,
-                      Ptr<SyncPolicyManager> syncPolicyManager,
-                      Ptr<Wrapper> handler,
+                      shared_ptr<SyncPolicyManager> syncPolicyManager,
                       LogicPerBranchCallback onUpdateBranch)
   : m_state (new FullState)
   , m_syncInterestTable (TIME_SECONDS (m_syncInterestReexpress))
@@ -103,7 +116,6 @@
   , m_onUpdateBranch (onUpdateBranch)
   , m_perBranch(true)
   , m_policyManager(syncPolicyManager)
-  , m_handler (handler)
 #ifndef NS3_MODULE
   , m_randomGenerator (static_cast<unsigned int> (std::time (0)))
   , m_rangeUniformRandom (m_randomGenerator, uniform_int<> (200,1000))
@@ -116,9 +128,19 @@
 { 
 #ifndef NS3_MODULE
   // In NS3 module these functions are moved to StartApplication method
+
+  m_transport = make_shared<TcpTransport>();
+  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
+
+  connectToDaemon();
+
+  shared_ptr<BasicIdentityStorage> publicStorage = make_shared<BasicIdentityStorage>();
+  shared_ptr<OSXPrivateKeyStorage> privateStorage = make_shared<OSXPrivateKeyStorage>();
+  m_identityManager = make_shared<IdentityManager>(publicStorage, privateStorage);
   
-  m_handler->setInterestFilter (m_syncPrefix,
-                                bind (&SyncLogic::respondSyncInterest, this, _1));
+  m_syncRegisteredPrefixId = m_face->registerPrefix(m_syncPrefix, 
+                                                    bind(&SyncLogic::onSyncInterest, this, _1, _2, _3, _4), 
+                                                    bind(&SyncLogic::onSyncRegisterFailed, this, _1));
 
   m_scheduler.schedule (TIME_SECONDS (0), // no need to add jitter
                         bind (&SyncLogic::sendSyncInterest, this),
@@ -128,8 +150,32 @@
 
 SyncLogic::~SyncLogic ()
 {
-  m_handler->clearInterestFilter (Name(m_syncPrefix));
-  m_handler->shutdown();
+  m_face->removeRegisteredPrefix(m_syncRegisteredPrefixId);
+  m_face->shutdown();
+}
+
+void
+SyncLogic::connectToDaemon()
+{
+  //Hack! transport does not connect to daemon unless an interest is expressed.
+  Name name("/ndn");
+  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(name);
+  m_face->expressInterest(*interest, 
+                          bind(&SyncLogic::onConnectionData, this, _1, _2),
+                          bind(&SyncLogic::onConnectionDataTimeout, this, _1));
+}
+
+void
+SyncLogic::onConnectionData(const shared_ptr<const ndn::Interest>& interest,
+                            const shared_ptr<Data>& data)
+{
+  _LOG_DEBUG("onConnectionData");
+}
+
+void
+SyncLogic::onConnectionDataTimeout(const shared_ptr<const ndn::Interest>& interest)
+{
+  _LOG_DEBUG("onConnectionDataTimeout");
 }
 
 #ifdef NS3_MODULE
@@ -160,7 +206,7 @@
 void
 SyncLogic::stop()
 {
-  m_handler->clearInterestFilter (Name(m_syncPrefix));
+  m_face->removeRegisteredPrefix(m_syncRegisteredPrefixId);
   m_scheduler.cancel (REEXPRESSING_INTEREST);
   m_scheduler.cancel (DELAYED_INTEREST_PROCESSING);
 }
@@ -198,7 +244,10 @@
 }
 
 void
-SyncLogic::respondSyncInterest (ndn::Ptr<ndn::Interest> interest)
+SyncLogic::onSyncInterest (const shared_ptr<const Name>& prefix, 
+                           const shared_ptr<const ndn::Interest>& interest, 
+                           Transport& transport, 
+                           uint64_t registeredPrefixId)
 {
   _LOG_DEBUG("respondSyncInterest: " << interest->getName().toUri());
   string name = interest->getName().toUri();
@@ -228,11 +277,68 @@
 }
 
 void
-SyncLogic::respondSyncData (Ptr<Data> data)
+SyncLogic::onSyncRegisterFailed(const shared_ptr<const Name>& prefix)
+{
+  _LOG_DEBUG("Sync prefix registration failed!");
+}
+
+void
+SyncLogic::onSyncData(const shared_ptr<const ndn::Interest>& interest, 
+                      const shared_ptr<Data>& data,
+                      int stepCount,
+                      const OnVerified& onVerified,
+                      const OnVerifyFailed& onVerifyFailed)
+{
+  shared_ptr<ValidationRequest> nextStep = m_policyManager->checkVerificationPolicy(data, stepCount, onVerified, onVerifyFailed);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       bind(&SyncLogic::onSyncCert, this, _1, _2, nextStep), 
+       bind(&SyncLogic::onSyncCertTimeout, this, _1, onVerifyFailed, data, nextStep));
+}
+
+void
+SyncLogic::onSyncDataTimeout(const shared_ptr<const ndn::Interest>& interest, 
+                             int retry,
+                             int stepCount,
+                             const OnVerified& onVerified,
+                             const OnVerifyFailed& onVerifyFailed)
+{
+  if(retry > 0)
+    {
+      m_face->expressInterest(*interest, 
+                              bind(&SyncLogic::onSyncData,
+                                   this,
+                                   _1,
+                                   _2,     
+                                   stepCount,
+                                   onVerified,
+                                   onVerifyFailed),
+                              bind(&SyncLogic::onSyncDataTimeout, 
+                                   this,
+                                   _1,
+                                   retry - 1,
+                                   stepCount,
+                                   onVerified,
+                                   onVerifyFailed));
+    }
+  else
+    _LOG_DEBUG("Sync interest eventually times out!");
+}
+
+void
+SyncLogic::onSyncDataVerifyFailed(const shared_ptr<Data>& data)
+{
+  _LOG_DEBUG("Sync data cannot be verified!");
+}
+
+void
+SyncLogic::onSyncDataVerified(const shared_ptr<Data>& data)
 {
   string name = data->getName().toUri();
-  const char *wireData = data->content().buf();
-  size_t len = data->content().size();
+  const char* wireData = (const char*)data->getContent().buf();
+  size_t len = data->getContent().size();
 
   try
     {
@@ -262,26 +368,44 @@
 }
 
 void
-SyncLogic::onSyncDataTimeout(Ptr<Closure> closure, Ptr<ndn::Interest> interest, int retry)
+SyncLogic::onSyncCert(const shared_ptr<const ndn::Interest>& interest, 
+                      const shared_ptr<Data>& cert,
+                      shared_ptr<ValidationRequest> previousStep)
 {
-  if(retry > 0)
-    {
-      Ptr<Closure> newClosure = Ptr<Closure>(new Closure(closure->m_dataCallback,
-                                                         boost::bind(&SyncLogic::onSyncDataTimeout, 
-                                                                     this, 
-                                                                     _1, 
-                                                                     _2, 
-                                                                     retry - 1),
-                                                         closure->m_unverifiedCallback,
-                                                         closure->m_stepCount)
-                                             );
-      m_handler->sendInterest(interest, newClosure);
-    }
+  shared_ptr<ValidationRequest> nextStep = m_policyManager->checkVerificationPolicy(cert, 
+                                                                                    previousStep->stepCount_, 
+                                                                                    previousStep->onVerified_, 
+                                                                                    previousStep->onVerifyFailed_);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       bind(&SyncLogic::onSyncCert, this, _1, _2, nextStep), 
+       bind(&SyncLogic::onSyncCertTimeout, this, _1, previousStep->onVerifyFailed_, cert, nextStep));
 }
 
 void
-SyncLogic::onSyncDataUnverified()
-{}
+SyncLogic::onSyncCertTimeout(const ptr_lib::shared_ptr<const ndn::Interest>& interest,
+                             const OnVerifyFailed& onVerifyFailed,
+                             const shared_ptr<Data>& data,
+                             shared_ptr<ValidationRequest> nextStep)
+{
+  if(nextStep->retry_ > 0)
+      m_face->expressInterest(*interest, 
+                              bind(&SyncLogic::onSyncCert,
+                                   this,
+                                   _1,
+                                   _2,
+                                   nextStep),
+                              bind(&SyncLogic::onSyncCertTimeout,
+                                   this,
+                                   _1,
+                                   onVerifyFailed,
+                                   data,
+                                   nextStep));
+  else
+    onVerifyFailed(data);
+}
 
 void
 SyncLogic::processSyncInterest (const std::string &name, DigestConstPtr digest, bool timedProcessing/*=false*/)
@@ -506,7 +630,7 @@
       uint32_t counter = 0;
       while (m_syncInterestTable.size () > 0)
         {
-          Interest interest = m_syncInterestTable.pop ();
+          Sync::Interest interest = m_syncInterestTable.pop ();
 
           if (!interest.m_unknown)
             {
@@ -618,18 +742,14 @@
                         bind (&SyncLogic::sendSyncInterest, this),
                         REEXPRESSING_INTEREST);
 
-  Ptr<ndn::Interest> interestPtr = Ptr<ndn::Interest>(new ndn::Interest(os.str()));
-  Ptr<Closure> closure = Ptr<Closure> (new Closure(boost::bind(&SyncLogic::respondSyncData, 
-                                                               this, 
-                                                               _1),
-						   boost::bind(&SyncLogic::onSyncDataTimeout,
-                                                               this,
-                                                               _1, 
-                                                               _2,
-                                                               0),
-						   boost::bind(&SyncLogic::onSyncDataUnverified,
-                                                               this)));
-  m_handler->sendInterest(interestPtr, closure);
+  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(os.str());
+
+  OnVerified onVerified = bind(&SyncLogic::onSyncDataVerified, this, _1);
+  OnVerifyFailed onVerifyFailed = bind(&SyncLogic::onSyncDataVerifyFailed, this, _1);
+
+  m_face->expressInterest(*interest,
+                          bind(&SyncLogic::onSyncData, this, _1, _2, 0, onVerified, onVerifyFailed),
+                          bind(&SyncLogic::onSyncDataTimeout, this, _1, 1, 0, onVerified, onVerifyFailed));
 }
 
 void
@@ -650,18 +770,14 @@
                             REEXPRESSING_RECOVERY_INTEREST);
     }
 
-  Ptr<ndn::Interest> interestPtr = Ptr<ndn::Interest>(new ndn::Interest(os.str()));
-  Ptr<Closure> closure = Ptr<Closure> (new Closure(boost::bind(&SyncLogic::respondSyncData, 
-                                                               this, 
-                                                               _1),
-						   boost::bind(&SyncLogic::onSyncDataTimeout,
-                                                               this,
-                                                               _1, 
-                                                               _2,
-                                                               0),
-						   boost::bind(&SyncLogic::onSyncDataUnverified,
-                                                               this)));
-  m_handler->sendInterest (interestPtr, closure);
+  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(os.str());
+
+  OnVerified onVerified = bind(&SyncLogic::onSyncDataVerified, this, _1);
+  OnVerifyFailed onVerifyFailed = bind(&SyncLogic::onSyncDataVerifyFailed, this, _1);
+
+  m_face->expressInterest(*interest,
+                          bind(&SyncLogic::onSyncData, this, _1, _2, 0, onVerified, onVerifyFailed),
+                          bind(&SyncLogic::onSyncDataTimeout, this, _1, 1, 0, onVerified, onVerifyFailed));
 }
 
 
@@ -682,13 +798,19 @@
   int size = ssm.ByteSize();
   char *wireData = new char[size];
   ssm.SerializeToArray(wireData, size);
-  Blob blob(wireData, size);
+  Blob blob((const uint8_t*)wireData, size);
   Name dataName(name);
   Name signingIdentity = m_policyManager->inferSigningIdentity(dataName);
-  m_handler->publishDataByIdentity (dataName,
-                                    blob,
-                                    signingIdentity,
-                                    m_syncResponseFreshness); // in NS-3 it doesn't have any effect... yet
+
+  shared_ptr<Data> syncData = make_shared<Data>(dataName);
+  syncData->setContent(blob.buf(), blob.size());
+  syncData->getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
+  
+  Name certificateName = m_identityManager->getDefaultCertificateNameForIdentity(signingIdentity);
+  m_identityManager->signByCertificate(*syncData, certificateName);
+  
+  m_transport->send(*syncData->wireEncode());
+  
   delete []wireData;
 
   // checking if our own interest got satisfied
diff --git a/src/sync-logic.h b/src/sync-logic.h
index 3b7df8c..b9b3057 100644
--- a/src/sync-logic.h
+++ b/src/sync-logic.h
@@ -29,7 +29,9 @@
 #include <memory>
 #include <map>
 
-#include <ndn.cxx/wrapper/wrapper.h>
+#include <ndn-cpp/face.hpp>
+#include <ndn-cpp/security/identity/identity-manager.hpp>
+
 #include "sync-interest-table.h"
 #include "sync-diff-state.h"
 #include "sync-full-state.h"
@@ -84,14 +86,12 @@
    * the app data when new remote names are learned
    */
   SyncLogic (const ndn::Name& syncPrefix,
-             ndn::Ptr<SyncPolicyManager> syncPolicyManager,
-             ndn::Ptr<ndn::Wrapper> handler,
+             ndn::ptr_lib::shared_ptr<SyncPolicyManager> syncPolicyManager,
              LogicUpdateCallback onUpdate,
              LogicRemoveCallback onRemove);
 
   SyncLogic (const ndn::Name& syncPrefix,
-             ndn::Ptr<SyncPolicyManager> syncPolicyManager,
-             ndn::Ptr<ndn::Wrapper> handler,
+             ndn::ptr_lib::shared_ptr<SyncPolicyManager> syncPolicyManager,
              LogicPerBranchCallback onUpdateBranch);
 
   ~SyncLogic ();
@@ -105,14 +105,14 @@
    * @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<ndn::Interest>);
+  void respondSyncInterest (ndn::ptr_lib::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<ndn::Data> data);
+  void respondSyncData (ndn::ptr_lib::shared_ptr<ndn::Data> data);
 
   /**
    * @brief remove a participant's subtree from the sync tree
@@ -144,13 +144,57 @@
 
 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);
+ 
+  void
   delayedChecksLoop ();
 
   void
-  onSyncDataTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, int retry);
+  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);
 
   void
-  onSyncDataUnverified();
+  onSyncRegisterFailed(const ndn::ptr_lib::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,
+             int stepCount,
+             const ndn::OnVerified& onVerified,
+             const ndn::OnVerifyFailed& onVerifyFailed);
+
+  void
+  onSyncDataTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                    int retry,
+                    int stepCount,
+                    const ndn::OnVerified& onVerified,
+                    const ndn::OnVerifyFailed& onVerifyFailed);
+
+  void
+  onSyncDataVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
+
+  void
+  onSyncDataVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
+
+  void
+  onSyncCert(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+             const ndn::ptr_lib::shared_ptr<ndn::Data>& cert,
+             ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> previousStep);
+
+  void
+  onSyncCertTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
+                    const ndn::OnVerifyFailed& onVerifyFailed,
+                    const ndn::ptr_lib::shared_ptr<ndn::Data>& data,
+                    ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> nextStep);
 
   void
   processSyncInterest (const std::string &name,
@@ -203,8 +247,11 @@
   LogicRemoveCallback m_onRemove;
   LogicPerBranchCallback m_onUpdateBranch;
   bool m_perBranch;
-  ndn::Ptr<SyncPolicyManager> m_policyManager;
-  ndn::Ptr<ndn::Wrapper> m_handler;
+  ndn::ptr_lib::shared_ptr<SyncPolicyManager> m_policyManager;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityManager> m_identityManager;
+  ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
+  ndn::ptr_lib::shared_ptr<ndn::Transport> m_transport;
+  uint64_t m_syncRegisteredPrefixId;
 
   Scheduler m_scheduler;
 
diff --git a/src/sync-policy-manager.cc b/src/sync-policy-manager.cc
index a788b66..d0850b6 100644
--- a/src/sync-policy-manager.cc
+++ b/src/sync-policy-manager.cc
@@ -8,14 +8,17 @@
  * Author: Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
-#include "sync-policy-manager.h"
-
 #include "sync-intro-certificate.h"
 #include "sync-logging.h"
-#include <ndn.cxx/security/identity/identity-manager.h>
+#include <ndn-cpp/security/identity/basic-identity-storage.hpp>
+#include <ndn-cpp/security/identity/osx-private-key-storage.hpp>
+#include <ndn-cpp/sha256-with-rsa-signature.hpp>
+#include <ndn-cpp/security/signature/sha256-with-rsa-handler.hpp>
+
+#include "sync-policy-manager.h"
 
 using namespace ndn;
-using namespace ndn::security;
+using namespace ndn::ptr_lib;
 using namespace std;
 
 INIT_LOGGER("SyncPolicyManager");
@@ -28,20 +31,52 @@
   , m_signingCertificateName(signingCertificateName.getPrefix(signingCertificateName.size()-1))
   , m_syncPrefix(syncPrefix)
   , m_stepLimit(stepLimit)
-  , m_identityManager(Ptr<security::IdentityManager>::Create())
 {
+  m_transport = make_shared<TcpTransport>();
+  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
+
+  connectToDaemon();
+  
+  shared_ptr<IdentityStorage> publicStorage = make_shared<BasicIdentityStorage>();
+  shared_ptr<PrivateKeyStorage> privateStorage = make_shared<OSXPrivateKeyStorage>();
+  m_identityManager = make_shared<IdentityManager>(publicStorage, privateStorage);
+
   Name wotPrefix = syncPrefix;
   wotPrefix.append("WOT");
   m_syncPrefixRegex = Regex::fromName(syncPrefix);
   m_wotPrefixRegex = Regex::fromName(wotPrefix);
-  m_chatDataPolicy = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^[^<%F0.>]*<%F0.>([^<chronos>]*)<chronos><>",
-                                                                    "^([^<KEY>]*)<KEY>(<>*)[<dsk-.*><ksk-.*>]<ID-CERT>$",
-                                                                    "==", "\\1", "\\1", true));  
+  m_chatDataPolicy = make_shared<IdentityPolicyRule>("^[^<%F0.>]*<%F0.>([^<chronos>]*)<chronos><>",
+                                                              "^([^<KEY>]*)<KEY>(<>*)[<dsk-.*><ksk-.*>]<ID-CERT>$",
+                                                              "==", "\\1", "\\1", true);  
 }
   
 SyncPolicyManager::~SyncPolicyManager()
 {}
 
+void
+SyncPolicyManager::connectToDaemon()
+{
+  //Hack! transport does not connect to daemon unless an interest is expressed.
+  Name name("/ndn");
+  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(name);
+  m_face->expressInterest(*interest, 
+                          bind(&SyncPolicyManager::onConnectionData, this, _1, _2),
+                          bind(&SyncPolicyManager::onConnectionDataTimeout, this, _1));
+}
+
+void
+SyncPolicyManager::onConnectionData(const shared_ptr<const ndn::Interest>& interest,
+                                    const shared_ptr<Data>& data)
+{
+  _LOG_DEBUG("onConnectionData");
+}
+
+void
+SyncPolicyManager::onConnectionDataTimeout(const shared_ptr<const ndn::Interest>& interest)
+{
+  _LOG_DEBUG("onConnectionDataTimeout");
+}
+
 bool 
 SyncPolicyManager::skipVerifyAndTrust (const Data& data)
 { return false; }
@@ -50,104 +85,82 @@
 SyncPolicyManager::requireVerify (const Data& data)
 { return true; }
 
-Ptr<ValidationRequest>
-SyncPolicyManager::checkVerificationPolicy(Ptr<Data> data, 
-					   const int& stepCount, 
-					   const DataCallback& verifiedCallback,
-					   const UnverifiedCallback& unverifiedCallback)
+shared_ptr<ValidationRequest>
+SyncPolicyManager::checkVerificationPolicy(const shared_ptr<Data>& data, 
+					   int stepCount, 
+					   const OnVerified& onVerified,
+					   const OnVerifyFailed& onVerifyFailed)
 {
-// #ifdef _DEBUG
-//   _LOG_DEBUG("checkVerificationPolicy");
-//   verifiedCallback(data);
-//   return NULL;
-// #else
-  //TODO:
   if(stepCount > m_stepLimit)
     {
-      unverifiedCallback(data);
-      return NULL;
+      onVerifyFailed(data);
+      return SYNC_POLICY_MANAGER_NULL_VALIDATION_REQUEST_PTR;
     }
 
-  Ptr<const signature::Sha256WithRsa> sha256sig = DynamicCast<const signature::Sha256WithRsa> (data->getSignature());
-  if(KeyLocator::KEYNAME != sha256sig->getKeyLocator().getType())
+  const Sha256WithRsaSignature* sigPtr = dynamic_cast<const Sha256WithRsaSignature*> (data->getSignature());
+  if(ndn_KeyLocatorType_KEYNAME != sigPtr->getKeyLocator().getType())
     {
-      unverifiedCallback(data);
-      return NULL;
+      onVerifyFailed(data);
+      return SYNC_POLICY_MANAGER_NULL_VALIDATION_REQUEST_PTR;
     }
 
-  const Name& keyLocatorName = sha256sig->getKeyLocator().getKeyName();
-  // _LOG_DEBUG("data name: " << data->getName());
-  // _LOG_DEBUG("signer name: " << keyLocatorName);
+  const Name& keyLocatorName = sigPtr->getKeyLocator().getKeyName();
   
   // if data is intro cert
   if(m_wotPrefixRegex->match(data->getName()))
     {
       // _LOG_DEBUG("Intro Cert");
       Name keyName = IdentityCertificate::certificateNameToPublicKeyName(keyLocatorName);
-      map<Name, Publickey>::const_iterator it = m_trustedIntroducers.find(keyName);
+      map<string, PublicKey>::const_iterator it = m_trustedIntroducers.find(keyName.toUri());
       if(m_trustedIntroducers.end() != it)
 	{
-	  if(verifySignature(*data, it->second))
-	    verifiedCallback(data);
+	  if(Sha256WithRsaHandler::verifySignature(*data, it->second))
+	    onVerified(data);
 	  else
-	    unverifiedCallback(data);
-	  return NULL;
+	    onVerifyFailed(data);
+	  return SYNC_POLICY_MANAGER_NULL_VALIDATION_REQUEST_PTR;
 	}
       else
-	return prepareRequest(keyName, true, data, stepCount, verifiedCallback, unverifiedCallback);
+	return prepareRequest(keyName, true, data, stepCount, onVerified, onVerifyFailed);
     }
 
   // if data is sync data or chat data
   if(m_syncPrefixRegex->match(data->getName()) || m_chatDataPolicy->satisfy(*data))
     {
-      // _LOG_DEBUG("Sync/Chat Data");
       Name keyName = IdentityCertificate::certificateNameToPublicKeyName(keyLocatorName);
-      // _LOG_DEBUG("keyName: " << keyName.toUri());
 
-      map<Name, Publickey>::const_iterator it = m_trustedIntroducers.find(keyName);
+      map<string, PublicKey>::const_iterator it = m_trustedIntroducers.find(keyName.toUri());
       if(m_trustedIntroducers.end() != it)
 	{
-          // _LOG_DEBUG("Find trusted introducer!");
-	  if(verifySignature(*data, it->second))
-	    verifiedCallback(data);
+	  if(Sha256WithRsaHandler::verifySignature(*data, it->second))
+	    onVerified(data);
 	  else
-	    unverifiedCallback(data);
-	  return NULL;
+	    onVerifyFailed(data);
+	  return SYNC_POLICY_MANAGER_NULL_VALIDATION_REQUEST_PTR;
 	}
 
-      it = m_trustedProducers.find(keyName);
+      it = m_trustedProducers.find(keyName.toUri());
       if(m_trustedProducers.end() != it)
 	{
-          // _LOG_DEBUG("Find trusted producer!");
-	  if(verifySignature(*data, it->second))
-	    verifiedCallback(data);
+	  if(Sha256WithRsaHandler::verifySignature(*data, it->second))
+	    onVerified(data);
 	  else
-	    unverifiedCallback(data);
-	  return NULL;
+	    onVerifyFailed(data);
+	  return SYNC_POLICY_MANAGER_NULL_VALIDATION_REQUEST_PTR;
 	}
 
-      // _LOG_DEBUG("Did not find any trusted one!");
-      return prepareRequest(keyName, false, data, stepCount, verifiedCallback, unverifiedCallback);
+      return prepareRequest(keyName, false, data, stepCount, onVerified, onVerifyFailed);
     }
   
-  unverifiedCallback(data);
-  return NULL;
-// #endif
+  onVerifyFailed(data);
+  return SYNC_POLICY_MANAGER_NULL_VALIDATION_REQUEST_PTR;
 }
 
 bool 
 SyncPolicyManager::checkSigningPolicy(const Name& dataName, 
 				      const Name& certificateName)
 { 
-
   return true;
-
-// #ifdef _DEBUG
-//   _LOG_DEBUG("checkSigningPolicy");
-//   return true;
-// #else
-  // return (m_syncPrefixRegex->match(dataName) && certificateName.getPrefix(certificateName.size()-1) == m_signingCertificateName) ? true : false; 
-// #endif
 }
     
 Name 
@@ -159,9 +172,11 @@
 {
   // _LOG_DEBUG("Add intro/producer: " << identityCertificate.getPublicKeyName());
   if(isIntroducer)
-    m_trustedIntroducers.insert(pair <Name, Publickey > (identityCertificate.getPublicKeyName(), identityCertificate.getPublicKeyInfo()));
+    m_trustedIntroducers.insert(pair <string, PublicKey > (identityCertificate.getPublicKeyName().toUri(),
+                                                           identityCertificate.getPublicKeyInfo()));
   else
-    m_trustedProducers.insert(pair <Name, Publickey > (identityCertificate.getPublicKeyName(), identityCertificate.getPublicKeyInfo()));
+    m_trustedProducers.insert(pair <string, PublicKey > (identityCertificate.getPublicKeyName().toUri(),
+                                                         identityCertificate.getPublicKeyInfo()));
 }
 
 void
@@ -187,34 +202,34 @@
 }
 
 
-Ptr<const vector<Name> >
+shared_ptr<const vector<Name> >
 SyncPolicyManager::getAllIntroducerName()
 {
-  Ptr<vector<Name> > nameList = Ptr<vector<Name> >(new vector<Name>);
+  shared_ptr<vector<Name> > nameList = make_shared<vector<Name> >();
   
-  map<Name, Publickey>::iterator it =  m_trustedIntroducers.begin();
+  map<string, PublicKey>::iterator it =  m_trustedIntroducers.begin();
   for(; it != m_trustedIntroducers.end(); it++)
-    nameList->push_back(it->first);
+    nameList->push_back(Name(it->first));
   
   return nameList;
 }
 
-Ptr<ValidationRequest>
+shared_ptr<ValidationRequest>
 SyncPolicyManager::prepareRequest(const Name& keyName, 
 				  bool forIntroducer,
-				  Ptr<Data> data,
+				  shared_ptr<Data> data,
 				  const int & stepCount, 
-				  const DataCallback& verifiedCallback,
-				  const UnverifiedCallback& unverifiedCallback)
+				  const OnVerified& onVerified,
+				  const OnVerifyFailed& onVerifyFailed)
 {
-  Ptr<Name> interestPrefixName = Ptr<Name>(new Name(m_syncPrefix));
+  shared_ptr<Name> interestPrefixName = make_shared<Name>(m_syncPrefix);
   interestPrefixName->append("WOT").append(keyName).append("INTRO-CERT");
 
-  Ptr<const std::vector<ndn::Name> > nameList = getAllIntroducerName();
+  shared_ptr<const vector<Name> > nameList = getAllIntroducerName();
   if(0 == nameList->size())
     {
-      unverifiedCallback(data);
-      return NULL;
+      onVerifyFailed(data);
+      return SYNC_POLICY_MANAGER_NULL_VALIDATION_REQUEST_PTR;
     }
 
   Name interestName = *interestPrefixName;
@@ -223,50 +238,70 @@
   if(forIntroducer)
     interestName.append("INTRODUCER");
 
-  Ptr<Interest> interest = Ptr<Interest>(new Interest(interestName));
+  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(interestName);
   // _LOG_DEBUG("send interest for intro cert: " << interest->getName());
-  interest->setChildSelector(Interest::CHILD_RIGHT);
+  interest->setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
 
-  DataCallback requestedCertVerifiedCallback = boost::bind(&SyncPolicyManager::onIntroCertVerified, 
-							   this, 
-							   _1,
-							   forIntroducer, 
-							   data,
-							   verifiedCallback,
-							   unverifiedCallback);
+  OnVerified requestedCertVerifiedCallback = boost::bind(&SyncPolicyManager::onIntroCertVerified, 
+                                                         this, 
+                                                         _1,
+                                                         forIntroducer, 
+                                                         data,
+                                                         onVerified,
+                                                         onVerifyFailed);
                                                              
-  UnverifiedCallback requestedCertUnverifiedCallback = boost::bind(&SyncPolicyManager::onIntroCertUnverified, 
-								   this, 
-								   _1, 
-								   interestPrefixName,
-								   forIntroducer,
-								   nameList,
-								   1,
-								   data,
-								   verifiedCallback,
-								   unverifiedCallback);
+  OnVerifyFailed requestedCertUnverifiedCallback = boost::bind(&SyncPolicyManager::onIntroCertVerifyFailed, 
+                                                               this, 
+                                                               _1, 
+                                                               interestPrefixName,
+                                                               forIntroducer,
+                                                               nameList,
+                                                               1,
+                                                               data,
+                                                               onVerified,
+                                                               onVerifyFailed);
 
     
-  Ptr<ValidationRequest> nextStep = Ptr<ValidationRequest>(new ValidationRequest(interest, 
-										 requestedCertVerifiedCallback,
-										 requestedCertUnverifiedCallback,
-										 1,
-										 m_stepLimit-1)
-							   );
+  shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(interest, 
+                                                                          requestedCertVerifiedCallback,
+                                                                          requestedCertUnverifiedCallback,
+                                                                          1,
+                                                                          m_stepLimit-1);
   return nextStep;
 }
 
 void
-SyncPolicyManager::onIntroCertVerified(Ptr<Data> introCertificateData,
-				       bool forIntroducer,
-				       Ptr<Data> originalData,
-				       const DataCallback& verifiedCallback,
-				       const UnverifiedCallback& unverifiedCallback)
+SyncPolicyManager::OnIntroCertInterest(const shared_ptr<const Name>& prefix, 
+                                       const shared_ptr<const ndn::Interest>& interest, 
+                                       Transport& transport, 
+                                       uint64_t registeredPrefixId)
 {
-  Ptr<SyncIntroCertificate> introCertificate = Ptr<SyncIntroCertificate>(new SyncIntroCertificate(*introCertificateData));
+  map<string, Data>::const_iterator it = m_introCert.find(prefix->toUri());
+
+  if(m_introCert.end() != it)
+    {
+      Blob encodedData = it->second.wireEncode();
+      transport.send(*encodedData);
+    }
+}
+
+void
+SyncPolicyManager::OnIntroCertRegisterFailed(const shared_ptr<const Name>& prefix)
+{
+}
+
+void
+SyncPolicyManager::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);
   if(forIntroducer)
     {
-      m_trustedIntroducers.insert(pair <Name, Publickey > (introCertificate->getPublicKeyName(), introCertificate->getPublicKeyInfo()));
+      m_trustedIntroducers.insert(pair <string, PublicKey > (introCertificate->getPublicKeyName().toUri(),
+                                                             introCertificate->getPublicKeyInfo()));
       SyncIntroCertificate syncIntroCertificate(m_syncPrefix,
                                                 introCertificate->getPublicKeyName(),
                                                 m_identityManager->getDefaultKeyNameForIdentity(m_signingIdentity),
@@ -274,15 +309,32 @@
                                                 introCertificate->getNotAfter(),
                                                 introCertificate->getPublicKeyInfo(),
                                                 SyncIntroCertificate::INTRODUCER);
-                                                // : SyncIntroCertificate::PRODUCER)
-      ndn::Name certName = m_identityManager->getDefaultCertificateNameByIdentity(m_signingIdentity);
+
+      Name certName = m_identityManager->getDefaultCertificateNameForIdentity(m_signingIdentity);
       _LOG_DEBUG("Publish Intro Certificate on Verified: " << syncIntroCertificate.getName());
       m_identityManager->signByCertificate(syncIntroCertificate, certName);
-      m_handler->putToNdnd(*syncIntroCertificate.encodeToWire());
+
+      m_transport->send(*syncIntroCertificate.wireEncode());
+
+      // Name prefix = syncIntroCertificate.getName().getPrefix(syncIntroCertificate.getName().size()-1);
+
+      // map<string, Data>::const_iterator it = m_introCert.find(prefix.toEscapedString());
+      // if(m_introCert.end() != it)
+      //   {
+      //     it->second = syncIntroCertificate;
+      //   }
+      // else
+      //   {         
+      //     m_introCert.insert(pair <string, Data> (prefix.toEscapedString(), syncIntroCertificate));
+      //     m_face->registerPrefix(prefix, 
+      //                           boost::bind(&SyncPolicyManager::onIntroCertInterest, this, _1, _2, _3, _4), 
+      //                           boost::bind(&SyncPolicyManager::onIntroCertRegisterFailed, this, _1));
+      //   }
     }
   else
     {
-      m_trustedProducers.insert(pair <Name, Publickey > (introCertificate->getPublicKeyName(), introCertificate->getPublicKeyInfo()));
+      m_trustedProducers.insert(pair <string, PublicKey > (introCertificate->getPublicKeyName().toUri(), 
+                                                           introCertificate->getPublicKeyInfo()));
       SyncIntroCertificate syncIntroCertificate(m_syncPrefix,
                                                 introCertificate->getPublicKeyName(),
                                                 m_identityManager->getDefaultKeyNameForIdentity(m_signingIdentity),
@@ -290,99 +342,161 @@
                                                 introCertificate->getNotAfter(),
                                                 introCertificate->getPublicKeyInfo(),
                                                 SyncIntroCertificate::PRODUCER);
-      // : SyncIntroCertificate::PRODUCER)
-      ndn::Name certName = m_identityManager->getDefaultCertificateNameByIdentity(m_signingIdentity);
+
+      Name certName = m_identityManager->getDefaultCertificateNameForIdentity(m_signingIdentity);
       _LOG_DEBUG("Publish Intro Certificate on Verified: " << syncIntroCertificate.getName());
       m_identityManager->signByCertificate(syncIntroCertificate, certName);
-      m_handler->putToNdnd(*syncIntroCertificate.encodeToWire());
+      
+      m_transport->send(*syncIntroCertificate.wireEncode());
+
+      // Name prefix = syncIntroCertificate.getName().getPrefix(syncIntroCertificate.getName().size()-1);
+
+      // map<string, Data>::const_iterator it = m_introCert.find(prefix.toEscapedString());
+      // if(m_introCert.end() != it)
+      //   {
+      //     it->second = syncIntroCertificate;
+      //   }
+      // else
+      //   {
+      //     m_introCert.insert(pair <string, Data> (prefix.toEscapedString(), syncIntroCertificate));
+      //     m_face->registerPrefix(prefix, 
+      //                           boost::bind(&SyncPolicyManager::onIntroCertInterest, this, _1, _2, _3, _4), 
+      //                           boost::bind(&SyncPolicyManager::onIntroCertRegisterFailed, this, _1));
+      //   }
     }
 
-  if(verifySignature(*originalData, introCertificate->getPublicKeyInfo()))      
-    verifiedCallback(originalData);    
+  if(Sha256WithRsaHandler::verifySignature(*originalData, introCertificate->getPublicKeyInfo()))      
+    onVerified(originalData);    
   else
-    unverifiedCallback(originalData);
+    onVerifyFailed(originalData);
 }
 
 void 
-SyncPolicyManager::onIntroCertUnverified(Ptr<Data> introCertificateData,
-					 Ptr<Name> interestPrefixName,
-					 bool forIntroducer,
-					 Ptr<const std::vector<ndn::Name> > introNameList,
-					 const int& nextIntroducerIndex,
-					 Ptr<Data> originalData,
-					 const DataCallback& verifiedCallback,
-					 const UnverifiedCallback& unverifiedCallback)
+SyncPolicyManager::onIntroCertVerifyFailed(const shared_ptr<Data>& introCertificateData,
+                                           shared_ptr<Name> interestPrefixName,
+                                           bool forIntroducer,
+                                           shared_ptr<const vector<Name> > introNameList,
+                                           int nextIntroducerIndex,
+                                           shared_ptr<Data> originalData,
+                                           const OnVerified& onVerified,
+                                           const OnVerifyFailed& onVerifyFailed)
 {
   Name interestName = *interestPrefixName;
   if(nextIntroducerIndex < introNameList->size())
     interestName.append(introNameList->at(nextIntroducerIndex));
   else
-    unverifiedCallback(originalData);
+    onVerifyFailed(originalData);
 
   if(forIntroducer)
     interestName.append("INTRODUCER");
   
-  Ptr<Interest> interest = Ptr<Interest>(new Interest(interestName));
-  interest->setChildSelector(Interest::CHILD_RIGHT);
+  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(interestName);
+  interest->setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
 
-  DataCallback requestedCertVerifiedCallback = boost::bind(&SyncPolicyManager::onIntroCertVerified, 
-							   this, 
-							   _1,
-							   forIntroducer, 
-							   originalData,
-							   verifiedCallback,
-							   unverifiedCallback);
-    
-  UnverifiedCallback requestedCertUnverifiedCallback = boost::bind(&SyncPolicyManager::onIntroCertUnverified, 
-								   this, 
-								   _1,
-								   interestPrefixName,
-								   forIntroducer,
-								   introNameList,
-								   nextIntroducerIndex + 1,
-								   originalData, 
-								   verifiedCallback,
-								   unverifiedCallback);
-  
-  TimeoutCallback requestedCertTimeoutCallback = boost::bind(&SyncPolicyManager::onIntroCertTimeOut, 
-							     this, 
-							     _1, 
-							     _2, 
-							     1,
-							     requestedCertUnverifiedCallback,
-							     originalData);
-      
-  Ptr<Closure> closure = Ptr<Closure> (new Closure(requestedCertVerifiedCallback,
-						   requestedCertTimeoutCallback,
-						   requestedCertUnverifiedCallback,
-						   m_stepLimit-1)
-				       );
-    
-  m_handler->sendInterest(interest, closure);
+  OnVerified onRecursiveVerified = boost::bind(&SyncPolicyManager::onIntroCertVerified, 
+                                      this, 
+                                      _1,
+                                      forIntroducer, 
+                                      originalData,
+                                      onVerified,
+                                      onVerifyFailed);
+
+  OnVerifyFailed onRecursiveVerifyFailed = boost::bind(&SyncPolicyManager::onIntroCertVerifyFailed, 
+                                              this, 
+                                              _1,
+                                              interestPrefixName,
+                                              forIntroducer,
+                                              introNameList,
+                                              nextIntroducerIndex + 1,
+                                              originalData, 
+                                              onVerified,
+                                              onVerifyFailed);
+        
+  m_face->expressInterest(*interest, 
+                          boost::bind(&SyncPolicyManager::onIntroCertData,
+                                      this,
+                                      _1,
+                                      _2,     
+                                      m_stepLimit-1,
+                                      onRecursiveVerified,
+                                      onRecursiveVerifyFailed,
+                                      originalData,
+                                      onVerifyFailed),
+                          boost::bind(&SyncPolicyManager::onIntroCertTimeout, 
+                                      this,
+                                      _1,
+                                      1,
+                                      m_stepLimit-1,
+                                      onRecursiveVerified,
+                                      onRecursiveVerifyFailed,
+                                      originalData,
+                                      onVerifyFailed));
 }
 
 void
-SyncPolicyManager::onIntroCertTimeOut(Ptr<Closure> closure, 
-				      Ptr<Interest> interest, 
+SyncPolicyManager::onIntroCertData(const shared_ptr<const ndn::Interest> &interest,
+                                   const shared_ptr<Data>& introCertificateData,
+                                   int stepCount,
+                                   const OnVerified& onRecursiveVerified,
+                                   const OnVerifyFailed& onRecursiveVerifyFailed,
+                                   shared_ptr<Data> originalData,
+                                   const OnVerifyFailed& onVerifyFailed)
+{
+  shared_ptr<ValidationRequest> nextStep = checkVerificationPolicy(introCertificateData, stepCount, onRecursiveVerified, onRecursiveVerifyFailed);
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       boost::bind(&SyncPolicyManager::onIntroCertData, 
+                   this, 
+                   _1, 
+                   _2,
+                   nextStep->stepCount_,
+                   nextStep->onVerified_, 
+                   nextStep->onVerifyFailed_,
+                   introCertificateData,
+                   onRecursiveVerifyFailed), 
+       boost::bind(&SyncPolicyManager::onIntroCertTimeout, 
+                   this, 
+                   _1, 
+                   nextStep->retry_, 
+                   nextStep->stepCount_, 
+                   nextStep->onVerified_, 
+                   nextStep->onVerifyFailed_,
+                   introCertificateData,
+                   onRecursiveVerifyFailed));
+}
+
+void
+SyncPolicyManager::onIntroCertTimeout(const shared_ptr<const ndn::Interest>& interest, 
 				      int retry, 
-				      const UnverifiedCallback& unverifiedCallback,
-				      Ptr<Data> data)
+                                      int stepCount,
+                                      const OnVerified& onRecursiveVerified,
+                                      const OnVerifyFailed& onRecursiveVerifyFailed,
+                                      shared_ptr<Data> originalData,
+                                      const OnVerifyFailed& onVerifyFailed)
 {
   if(retry > 0)
     {
-      Ptr<Closure> newClosure = Ptr<Closure>(new Closure(closure->m_dataCallback,
-							 boost::bind(&SyncPolicyManager::onIntroCertTimeOut, 
-								     this, 
-								     _1, 
-								     _2, 
-								     retry - 1, 
-								     unverifiedCallback,
-								     data),
-							 closure->m_unverifiedCallback,
-							 closure->m_stepCount)
-					     );
-      m_handler->sendInterest(interest, newClosure);
+      m_face->expressInterest(*interest, 
+                              boost::bind(&SyncPolicyManager::onIntroCertData, 
+                                          this,
+                                          _1,
+                                          _2,
+                                          stepCount,
+                                          onRecursiveVerified,
+                                          onRecursiveVerifyFailed,
+                                          originalData,
+                                          onVerifyFailed),
+                              boost::bind(&SyncPolicyManager::onIntroCertTimeout, 
+                                          this,
+                                          _1,
+                                          retry - 1,
+                                          stepCount,
+                                          onRecursiveVerified,
+                                          onRecursiveVerifyFailed,
+                                          originalData,
+                                          onVerifyFailed));
     }
   else
-    unverifiedCallback(data);
+    onVerifyFailed(originalData);
 }
diff --git a/src/sync-policy-manager.h b/src/sync-policy-manager.h
index ad4345a..b7ec402 100644
--- a/src/sync-policy-manager.h
+++ b/src/sync-policy-manager.h
@@ -11,15 +11,19 @@
 #ifndef SYNC_POLICY_MANAGER_H
 #define SYNC_POLICY_MANAGER_H
 
-#include <ndn.cxx/security/policy/policy-manager.h>
-#include <ndn.cxx/security/policy/identity-policy-rule.h>
-#include <ndn.cxx/security/certificate/identity-certificate.h>
-#include <ndn.cxx/regex/regex.h>
-#include <ndn.cxx/wrapper/wrapper.h>
+#include <ndn-cpp/face.hpp>
+#include <ndn-cpp/security/identity/identity-manager.hpp>
+#include <ndn-cpp/security/policy/policy-manager.hpp>
+#include <ndn-cpp/security/certificate/identity-certificate.hpp>
+#include <ndn-cpp-et/regex/regex.hpp>
+#include <ndn-cpp-et/policy-manager/identity-policy-rule.hpp>
+#include <map>
+
 #include "specific-policy-rule.h"
 
+static ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> SYNC_POLICY_MANAGER_NULL_VALIDATION_REQUEST_PTR;
 
-class SyncPolicyManager : public ndn::security::PolicyManager
+class SyncPolicyManager : public ndn::PolicyManager
 {
 public:
   SyncPolicyManager(const ndn::Name& signingIdentity,
@@ -36,11 +40,11 @@
   bool
   requireVerify (const ndn::Data& data);
 
-  ndn::Ptr<ndn::security::ValidationRequest>
-  checkVerificationPolicy(ndn::Ptr<ndn::Data> data, 
-                          const int& stepCount, 
-                          const ndn::DataCallback& verifiedCallback,
-                          const ndn::UnverifiedCallback& unverifiedCallback);
+  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, 
@@ -50,59 +54,89 @@
   inferSigningIdentity(const ndn::Name& dataName);
 
   void
-  addTrustAnchor(const ndn::security::IdentityCertificate& identityCertificate, bool isIntroducer);
+  addTrustAnchor(const ndn::IdentityCertificate& identityCertificate, bool isIntroducer);
 
   void
   addChatDataRule(const ndn::Name& prefix, 
-                  const ndn::security::IdentityCertificate& identityCertificate,
+                  const ndn::IdentityCertificate& identityCertificate,
                   bool isIntroducer);
 
-  inline void 
-  setWrapper(ndn::Ptr<ndn::Wrapper> handler)
-  { m_handler = handler; }
+  // inline void 
+  // setFace(ndn::ndn::ptr_lib::shared_ptr<Face> face) 
+  // { face_ = face; }
 
 private:
-  ndn::Ptr<ndn::security::ValidationRequest>
+  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);
+
+  ndn::ptr_lib::shared_ptr<ndn::ValidationRequest>
   prepareIntroducerRequest(const ndn::Name& keyName,
-                           ndn::Ptr<ndn::Data> data, 
+                           ndn::ptr_lib::shared_ptr<ndn::Data> data, 
                            const int & stepCount, 
-                           const ndn::DataCallback& verifiedCallback,
-                           const ndn::UnverifiedCallback& unverifiedCallback);
+                           const ndn::OnVerified& onVerified,
+                           const ndn::OnVerifyFailed& onVerifyFailed);
   
-  ndn::Ptr<const std::vector<ndn::Name> >
+  ndn::ptr_lib::shared_ptr<const std::vector<ndn::Name> >
   getAllIntroducerName();
 
-  ndn::Ptr<ndn::security::ValidationRequest>
+  ndn::ptr_lib::shared_ptr<ndn::ValidationRequest>
   prepareRequest(const ndn::Name& keyName, 
                  bool forIntroducer,
-                 ndn::Ptr<ndn::Data> data,
+                 ndn::ptr_lib::shared_ptr<ndn::Data> data,
                  const int & stepCount, 
-                 const ndn::DataCallback& verifiedCallback,
-                 const ndn::UnverifiedCallback& unverifiedCallback);
+                 const ndn::OnVerified& onVerified,
+                 const ndn::OnVerifyFailed& onVerifyFailed);
 
   void
-  onIntroCertVerified(ndn::Ptr<ndn::Data> introCertificateData,
+  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<ndn::Data> originalData,
-                      const ndn::DataCallback& verifiedCallback,
-                      const ndn::UnverifiedCallback& unverifiedCallback);
+                      ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
+                      const ndn::OnVerified& onVerified,
+                      const ndn::OnVerifyFailed& onVerifyFailed);
 
   void 
-  onIntroCertUnverified(ndn::Ptr<ndn::Data> introCertificateData,
-                        ndn::Ptr<ndn::Name> interestPrefixName,
-                        bool forIntroducer,
-                        ndn::Ptr<const std::vector<ndn::Name> > introNameList,
-                        const int& nextIntroducerIndex,
-                        ndn::Ptr<ndn::Data> originalData,
-                        const ndn::DataCallback& verifiedCallback,
-                        const ndn::UnverifiedCallback& unverifiedCallback);
+  onIntroCertVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& introCertificateData,
+                          ndn::ptr_lib::shared_ptr<ndn::Name> interestPrefixName,
+                          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& onRecursiveVerified,
+                  const ndn::OnVerifyFailed& onRecursiveVerifyFailed,
+                  ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
+                  const ndn::OnVerifyFailed& onVerifyFailed);
 
   void
-  onIntroCertTimeOut(ndn::Ptr<ndn::Closure> closure, 
-                     ndn::Ptr<ndn::Interest> interest, 
-                     int retry, 
-                     const ndn::UnverifiedCallback& unverifiedCallback,
-                     ndn::Ptr<ndn::Data> data);
+  onIntroCertTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                     int retry,                      
+                     int stepCount,
+                     const ndn::OnVerified& onRecursiveVerified,
+                     const ndn::OnVerifyFailed& onRecursiveVerifyFailed,
+                     ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
+                     const ndn::OnVerifyFailed& onVerifyFailed);
 
 
 
@@ -111,15 +145,18 @@
   ndn::Name m_signingCertificateName;
   ndn::Name m_syncPrefix;
   int m_stepLimit;
-  ndn::Ptr<ndn::Regex> m_syncPrefixRegex;
-  ndn::Ptr<ndn::Regex> m_wotPrefixRegex;
-  ndn::Ptr<ndn::security::IdentityPolicyRule> m_chatDataPolicy; 
-  std::map<ndn::Name, ndn::security::Publickey> m_trustedIntroducers;
-  std::map<ndn::Name, ndn::security::Publickey> m_trustedProducers;
-  std::map<ndn::Name, SpecificPolicyRule> m_chatDataRules;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_syncPrefixRegex;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_wotPrefixRegex;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_chatDataPolicy; 
+  std::map<std::string, ndn::PublicKey> m_trustedIntroducers;
+  std::map<std::string, ndn::PublicKey> m_trustedProducers;
+  std::map<std::string, SpecificPolicyRule> m_chatDataRules;
+  std::map<std::string, ndn::Data> m_introCert;
 
-  ndn::Ptr<ndn::security::IdentityManager> m_identityManager;
-  ndn::Ptr<ndn::Wrapper> m_handler;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityManager> m_identityManager;
+  ndn::ptr_lib::shared_ptr<ndn::Transport> m_transport;
+  ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
+
 };
 
 #endif
diff --git a/src/sync-socket.cc b/src/sync-socket.cc
index f70f6ba..42612e0 100644
--- a/src/sync-socket.cc
+++ b/src/sync-socket.cc
@@ -19,35 +19,67 @@
  */
 
 #include "sync-socket.h"
+#include "sync-logging.h"
+
+#include <ndn-cpp/security/identity/basic-identity-storage.hpp>
+#include <ndn-cpp/security/identity/osx-private-key-storage.hpp>
 
 using namespace std;
 using namespace ndn;
+using namespace ndn::ptr_lib;
+
+INIT_LOGGER ("SyncSocket");
 
 namespace Sync {
 
 SyncSocket::SyncSocket (const string &syncPrefix, 
-                        Ptr<SyncPolicyManager> syncPolicyManager, 
+                        shared_ptr<SyncPolicyManager> syncPolicyManager, 
                         NewDataCallback dataCallback, 
                         RemoveCallback rmCallback )
   : m_newDataCallback(dataCallback)
   , m_syncPolicyManager(syncPolicyManager)
-  , m_handler(Ptr<Wrapper>(new Wrapper(Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(), 
-                                                                                      m_syncPolicyManager, 
-                                                                                      NULL)))))
   , m_syncLogic (syncPrefix,
                  syncPolicyManager,
-                 m_handler,
                  bind(&SyncSocket::passCallback, this, _1),
                  rmCallback)
 {
-  // Ptr<security::Keychain> keychain = Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(), m_syncPolicyManager, NULL));
-  // m_handler = Ptr<Wrapper>(new Wrapper(keychain));
-  m_syncPolicyManager->setWrapper(m_handler);
+  m_transport = make_shared<TcpTransport>();
+  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
+
+  connectToDaemon();
+
+  shared_ptr<BasicIdentityStorage> publicStorage = make_shared<BasicIdentityStorage>();
+  shared_ptr<OSXPrivateKeyStorage> privateStorage = make_shared<OSXPrivateKeyStorage>();
+  m_identityManager = make_shared<IdentityManager>(publicStorage, privateStorage);
 }
 
 SyncSocket::~SyncSocket()
 {
-  m_handler->shutdown();
+  m_face->shutdown();
+}
+
+void
+SyncSocket::connectToDaemon()
+{
+  //Hack! transport does not connect to daemon unless an interest is expressed.
+  Name name("/ndn");
+  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(name);
+  m_face->expressInterest(*interest, 
+                          bind(&SyncSocket::onConnectionData, this, _1, _2),
+                          bind(&SyncSocket::onConnectionDataTimeout, this, _1));
+}
+
+void
+SyncSocket::onConnectionData(const shared_ptr<const ndn::Interest>& interest,
+                             const shared_ptr<Data>& data)
+{
+  _LOG_DEBUG("onConnectionData");
+}
+
+void
+SyncSocket::onConnectionDataTimeout(const shared_ptr<const ndn::Interest>& interest)
+{
+  _LOG_DEBUG("onConnectionDataTimeout");
 }
 
 bool 
@@ -58,13 +90,17 @@
   contentNameWithSeqno << prefix << "/" << session << "/" << sequence;
   
   Name dataName(contentNameWithSeqno.str ());
-  Blob blob(buf, len);
+  Blob blob((const uint8_t*)buf, len);
   Name signingIdentity = m_syncPolicyManager->inferSigningIdentity(dataName);
+
+  shared_ptr<Data> data = make_shared<Data>(dataName);
+  data->setContent(blob.buf(), blob.size());
+  data->getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
+
+  Name certificateName = m_identityManager->getDefaultCertificateNameForIdentity(signingIdentity);
+  m_identityManager->signByCertificate(*data, certificateName);
   
-  m_handler->publishDataByIdentity (dataName, 
-                                    blob, 
-                                    signingIdentity, 
-                                    freshness);
+  m_transport->send(*data->wireEncode());
   
   SeqNo s(session, sequence + 1);
   m_sequenceLog[prefix] = s;
@@ -73,47 +109,109 @@
 }
 
 void 
-SyncSocket::fetchData(const string &prefix, const SeqNo &seq, const DataCallback& callback, int retry)
+SyncSocket::fetchData(const string &prefix, const SeqNo &seq, const OnVerified& onVerified, int retry)
 {
   ostringstream interestName;
   interestName << prefix << "/" << seq.getSession() << "/" << seq.getSeq();
   //std::cout << "Socket " << this << " Send Interest <" << interestName.str() << "> for raw data " << endl;
+
+  const OnVerifyFailed& onVerifyFailed = bind(&SyncSocket::onChatDataVerifyFailed, this, _1);
   
   
-  Ptr<ndn::Interest> interestPtr = Ptr<ndn::Interest>(new ndn::Interest(interestName.str()));
-  Ptr<Closure> closure = Ptr<Closure> (new Closure(callback,
-						   boost::bind(&SyncSocket::onChatDataTimeout,
-                                                               this,
-                                                               _1, 
-                                                               _2,
-                                                               retry),
-						   boost::bind(&SyncSocket::onChatDataUnverified,
-                                                               this,
-                                                               _1)));
-  m_handler->sendInterest(interestPtr, closure);
+  shared_ptr<ndn::Interest> interest = make_shared<ndn::Interest>(interestName.str());
+  m_face->expressInterest(*interest, 
+                          bind(&SyncSocket::onChatData, this, _1, _2, onVerified, onVerifyFailed), 
+                          bind(&SyncSocket::onChatDataTimeout, this, _1, retry, onVerified, onVerifyFailed));
+
 }
 
 void
-SyncSocket::onChatDataTimeout(Ptr<Closure> closure, Ptr<ndn::Interest> interest, int retry)
+SyncSocket::onChatCert(const shared_ptr<const ndn::Interest>& interest,
+                       const shared_ptr<Data>& cert,
+                       shared_ptr<ValidationRequest> previousStep)
+{
+  shared_ptr<ValidationRequest> nextStep = m_syncPolicyManager->checkVerificationPolicy(cert, 
+                                                                                        previousStep->stepCount_, 
+                                                                                        previousStep->onVerified_, 
+                                                                                        previousStep->onVerifyFailed_);
+  
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       bind(&SyncSocket::onChatCert, this, _1, _2, nextStep), 
+       bind(&SyncSocket::onChatCertTimeout, this, _1, previousStep->onVerifyFailed_, cert, nextStep));
+}
+
+void
+SyncSocket::onChatCertTimeout(const shared_ptr<const ndn::Interest>& interest,
+                              const OnVerifyFailed& onVerifyFailed,
+                              const shared_ptr<Data>& data,
+                              shared_ptr<ValidationRequest> nextStep)
+{
+  if(nextStep->retry_ > 0)
+    m_face->expressInterest(*interest, 
+                            bind(&SyncSocket::onChatCert,
+                                 this,
+                                 _1,
+                                 _2,
+                                 nextStep),
+                            bind(&SyncSocket::onChatCertTimeout,
+                                 this,
+                                 _1,
+                                 onVerifyFailed,
+                                 data,
+                                 nextStep));
+  else
+    onVerifyFailed(data);
+}
+
+void
+SyncSocket::onChatData(const shared_ptr<const ndn::Interest>& interest, 
+                       const shared_ptr<Data>& data,
+                       const OnVerified& onVerified,
+                       const OnVerifyFailed& onVerifyFailed)
+{
+  shared_ptr<ValidationRequest> nextStep = m_syncPolicyManager->checkVerificationPolicy(data, 0, onVerified, onVerifyFailed);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       bind(&SyncSocket::onChatCert, this, _1, _2, nextStep), 
+       bind(&SyncSocket::onChatCertTimeout, this, _1, onVerifyFailed, data, nextStep));
+}
+
+void
+SyncSocket::onChatDataTimeout(const shared_ptr<const ndn::Interest>& interest, 
+                              int retry,
+                              const OnVerified& onVerified,
+                              const OnVerifyFailed& onVerifyFailed)
 {
   if(retry > 0)
     {
-      Ptr<Closure> newClosure = Ptr<Closure>(new Closure(closure->m_dataCallback,
-                                                         boost::bind(&SyncSocket::onChatDataTimeout, 
-                                                                     this, 
-                                                                     _1, 
-                                                                     _2, 
-                                                                     retry - 1),
-                                                         closure->m_unverifiedCallback,
-                                                         closure->m_stepCount)
-                                             );
-      m_handler->sendInterest(interest, newClosure);
+      m_face->expressInterest(*interest,
+                              bind(&SyncSocket::onChatData,
+                                   this,
+                                   _1,
+                                   _2,
+                                   onVerified,
+                                   onVerifyFailed),
+                              bind(&SyncSocket::onChatDataTimeout, 
+                                   this,
+                                   _1,
+                                   retry - 1,
+                                   onVerified,
+                                   onVerifyFailed));
+                              
     }
+  else
+    _LOG_DEBUG("Chat interest eventually time out!");
 }
 
 void
-SyncSocket::onChatDataUnverified(Ptr<Data> data)
-{}
+SyncSocket::onChatDataVerifyFailed(const shared_ptr<Data>& data)
+{
+  _LOG_DEBUG("Chat data cannot be verified!");
+}
 
 
 uint32_t
diff --git a/src/sync-socket.h b/src/sync-socket.h
index a4530ba..170fde5 100644
--- a/src/sync-socket.h
+++ b/src/sync-socket.h
@@ -25,7 +25,8 @@
 #include <boost/function.hpp>
 #include <boost/unordered_map.hpp>
 #include "sync-seq-no.h"
-#include <ndn.cxx/wrapper/wrapper.h>
+#include <ndn-cpp/face.hpp>
+#include <ndn-cpp/security/identity/identity-manager.hpp>
 #include <utility>
 #include <map>
 #include <vector>
@@ -54,7 +55,7 @@
    * @param dataCallback the callback to process data
    */
   SyncSocket (const std::string &syncPrefix, 
-              ndn::Ptr<SyncPolicyManager> syncPolicyManager,
+              ndn::ptr_lib::shared_ptr<SyncPolicyManager> syncPolicyManager,
               NewDataCallback dataCallback, 
               RemoveCallback rmCallback);
 
@@ -68,7 +69,7 @@
   { m_syncLogic.remove(prefix); }
 
   void 
-  fetchData(const std::string &prefix, const SeqNo &seq, const ndn::DataCallback& callback, int retry = 0);
+  fetchData(const std::string &prefix, const SeqNo &seq, const ndn::OnVerified& onVerified, int retry = 0);
 
   std::string 
   getRootDigest() 
@@ -87,22 +88,54 @@
   GetLocalPrefix (); 
   
 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);
+
   void 
   passCallback(const std::vector<MissingDataInfo> &v) 
   { m_newDataCallback(v, this); }
 
   void
-  onChatDataTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, int retry);
+  onChatCert(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
+             const ndn::ptr_lib::shared_ptr<ndn::Data>& cert,
+             ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> previousStep);
 
   void
-  onChatDataUnverified(ndn::Ptr<ndn::Data> data);
+  onChatCertTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
+                    const ndn::OnVerifyFailed& onVerifyFailed,
+                    const ndn::ptr_lib::shared_ptr<ndn::Data>& data,
+                    ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> nextStep);
+
+  void
+  onChatData(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);
+
+  void
+  onChatDataTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                    int retry,
+                    const ndn::OnVerified& onVerified,
+                    const ndn::OnVerifyFailed& onVerifyFailed);
+
+  void
+  onChatDataVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
 
 private:
   typedef boost::unordered_map<std::string, SeqNo> SequenceLog;
   NewDataCallback m_newDataCallback;
   SequenceLog m_sequenceLog;
-  ndn::Ptr<SyncPolicyManager> m_syncPolicyManager;
-  ndn::Ptr<ndn::Wrapper> m_handler;
+  ndn::ptr_lib::shared_ptr<SyncPolicyManager> m_syncPolicyManager;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityManager> m_identityManager;
+  ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
+  ndn::ptr_lib::shared_ptr<ndn::Transport> m_transport;
   SyncLogic      m_syncLogic;
 };
 
