diff --git a/ChronoSync b/ChronoSync
index 5cf4134..46c9f1a 160000
--- a/ChronoSync
+++ b/ChronoSync
@@ -1 +1 @@
-Subproject commit 5cf4134f3c0e8023124b753ae52feeca60d8e71c
+Subproject commit 46c9f1a1c1f64ed429a4b1f3a9cb67a99d5486a2
diff --git a/src/addcontactpanel.cpp b/src/addcontactpanel.cpp
index 38bc6e9..f43cddb 100644
--- a/src/addcontactpanel.cpp
+++ b/src/addcontactpanel.cpp
@@ -13,18 +13,20 @@
 #include <QMessageBox>
 
 #ifndef Q_MOC_RUN
-// #include <cryptopp/base64.h>
-// #include <ndn.cxx/helpers/der/der.h>
-#include <ndn.cxx/helpers/der/visitor/simple-visitor.h>
+#include <ndn-cpp/security/signature/sha256-with-rsa-handler.hpp>
+#include <boost/iostreams/stream.hpp>
+#include "null-ptrs.h"
+#include "endorse-collection.pb.h"
 #include "logging.h"
 #endif
 
 using namespace ndn;
+using namespace ndn::ptr_lib;
 using namespace std;
 
 INIT_LOGGER("AddContactPanel");
 
-AddContactPanel::AddContactPanel(Ptr<ContactManager> contactManager,
+AddContactPanel::AddContactPanel(shared_ptr<ContactManager> contactManager,
                                  QWidget *parent) 
   : QDialog(parent)
   , ui(new Ui::AddContactPanel)
@@ -78,7 +80,7 @@
   for(int i = ui->infoView->rowCount() - 1; i >= 0 ; i--)
     ui->infoView->removeRow(i);
   QString inputIdentity = ui->contactInput->text();
-  m_searchIdentity = Name(inputIdentity.toUtf8().constData());
+  m_searchIdentity = Name(inputIdentity.toStdString());
 
   if(Qt::Checked == ui->fetchBox->checkState())
     {
@@ -102,13 +104,13 @@
   string key("KEY");
   string idCert("ID-CERT");
 
-  if(name.get(-1).toUri() != idCert)
+  if(name.get(-1).toEscapedString() != idCert)
     return false;
   
   int keyIndex = -1;
   for(int i = 0; i < name.size(); i++)
     {
-      if(name.get(i).toUri() == key)
+      if(name.get(i).toEscapedString() == key)
         {
           keyIndex = i;
           break;
@@ -127,7 +129,7 @@
   ContactItem contactItem(*m_currentEndorseCertificate);
   try{
     m_contactManager->getContactStorage()->addContact(contactItem);
-  }catch(exception& e){
+  }catch(std::exception& e){
     QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what()));
     _LOG_ERROR("Exception: " << e.what());
     return;
@@ -140,8 +142,8 @@
 AddContactPanel::selfEndorseCertificateFetched(const EndorseCertificate& endorseCertificate)
 {
   try{
-    m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
-  }catch(exception& e){
+    m_currentEndorseCertificate = make_shared<EndorseCertificate>(endorseCertificate);
+  }catch(std::exception& e){
     QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what()));
     _LOG_ERROR("Exception: " << e.what());
     return;
@@ -162,8 +164,8 @@
 AddContactPanel::onContactKeyFetched(const EndorseCertificate& endorseCertificate)
 {
   try{
-    m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
-  }catch(exception& e){
+    m_currentEndorseCertificate = make_shared<EndorseCertificate>(endorseCertificate);
+  }catch(std::exception& e){
     QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what()));
     _LOG_ERROR("Exception: " << e.what());
     return;
@@ -183,7 +185,7 @@
 void
 AddContactPanel::onCollectEndorseFetched(const Data& data)
 {
-  m_currentCollectEndorse = Ptr<Data>(new Data(data));
+  m_currentCollectEndorse = make_shared<Data>(data);
   m_currentCollectEndorseReady = true;
 
   if(m_currentEndorseCertificateReady == true)
@@ -193,7 +195,7 @@
 void
 AddContactPanel::onCollectEndorseFetchFailed(const Name& identity)
 {
-  m_currentCollectEndorse = NULL;
+  m_currentCollectEndorse = CHRONOCHAT_NULL_DATA_PTR;
   m_currentCollectEndorseReady = true;
   
   if(m_currentEndorseCertificateReady == true)
@@ -204,55 +206,52 @@
 AddContactPanel::displayContactInfo()
 {
   // _LOG_TRACE("displayContactInfo");
-  const Profile& profile = m_currentEndorseCertificate->getProfileData()->getProfile();
-  const Blob& profileBlob = m_currentEndorseCertificate->getProfileData()->content();
+  const Profile& profile = m_currentEndorseCertificate->getProfileData().getProfile();
+  const Blob& profileBlob = m_currentEndorseCertificate->getProfileData().getContent();
 
   map<string, int> endorseCount;
 
-  if(m_currentCollectEndorse != NULL)
+  if(m_currentCollectEndorse != CHRONOCHAT_NULL_DATA_PTR)
     {
-      boost::iostreams::stream
-        <boost::iostreams::array_source> is (m_currentCollectEndorse->content().buf(), m_currentCollectEndorse->content().size());
-  
-      Ptr<der::DerSequence> root = DynamicCast<der::DerSequence>(der::DerNode::parse(reinterpret_cast<InputIterator &>(is)));
-      const der::DerNodePtrList & children = root->getChildren();
-      der::SimpleVisitor simpleVisitor;
+      Chronos::EndorseCollection endorseCollection;
       
-      for(int i = 0; i < children.size(); i++)
+      boost::iostreams::stream
+        <boost::iostreams::array_source> is ((const char*)m_currentCollectEndorse->getContent().buf(), m_currentCollectEndorse->getContent().size());
+      
+      endorseCollection.ParseFromIstream(&is);
+
+      for(int i = 0; i < endorseCollection.endorsement_size(); i ++)
         {
-          Ptr<Blob> dataBlob = boost::any_cast<Ptr<Blob> >(children[i]->accept(simpleVisitor));
-          
-          Ptr<Data> data = NULL;
-          Ptr<EndorseCertificate> endorseCert = NULL;
           try{
-            data = Data::decodeFromWire(dataBlob);
-            endorseCert = Ptr<EndorseCertificate>(new EndorseCertificate(*data));
-          }catch(exception& e){
-            continue;
-          }
-
-          Name signerKeyName = endorseCert->getSigner();
-          Name signerName = signerKeyName.getPrefix(signerKeyName.size()-1);
+            Data data;
+            data.wireDecode((const uint8_t*)endorseCollection.endorsement(i).blob().c_str(), endorseCollection.endorsement(i).blob().size());
+            EndorseCertificate endorseCert(data);
+            
+            Name signerKeyName = endorseCert.getSigner();
+            Name signerName = signerKeyName.getPrefix(-1);
           
-          Ptr<ContactItem> contact = m_contactManager->getContact(signerName);
-          if(contact == NULL)
-            continue;
+            shared_ptr<ContactItem> contact = m_contactManager->getContact(signerName);
+            if(contact == CHRONOCHAT_NULL_CONTACTITEM_PTR)
+              continue;
 
-          if(!contact->isIntroducer() || !contact->canBeTrustedFor(m_currentEndorseCertificate->getProfileData()->getIdentityName()))
-            continue;
+            if(!contact->isIntroducer() || !contact->canBeTrustedFor(m_currentEndorseCertificate->getProfileData().getIdentityName()))
+              continue;
           
-          if(!security::PolicyManager::verifySignature(*data, contact->getSelfEndorseCertificate().getPublicKeyInfo()))
-            continue;
+            if(!Sha256WithRsaHandler::verifySignature(data, contact->getSelfEndorseCertificate().getPublicKeyInfo()))
+              continue;
 
-          const Blob& tmpProfileBlob = endorseCert->getProfileData()->content();
-          if(profileBlob != tmpProfileBlob)
-            continue;
+            const Blob& tmpProfileBlob = endorseCert.getProfileData().getContent();
+            if(!isSameBlob(profileBlob, tmpProfileBlob))
+              continue;
 
-          const vector<string>& endorseList = endorseCert->getEndorseList();
+          const vector<string>& endorseList = endorseCert.getEndorseList();
           vector<string>::const_iterator it = endorseList.begin();
           for(; it != endorseList.end(); it++)
             endorseCount[*it] += 1;
-        }
+          }catch(std::exception& e){
+            continue;
+          }
+        }  
     }
   
   ui->infoView->setColumnCount(3);
@@ -269,11 +268,10 @@
   for(; it != profile.end(); it++)
   {
     ui->infoView->insertRow(rowCount);  
-    QTableWidgetItem *type = new QTableWidgetItem(QString::fromUtf8(it->first.c_str()));
+    QTableWidgetItem *type = new QTableWidgetItem(QString::fromStdString(it->first));
     ui->infoView->setItem(rowCount, 0, type);
     
-    string valueString(it->second.buf(), it->second.size());
-    QTableWidgetItem *value = new QTableWidgetItem(QString::fromUtf8(valueString.c_str()));
+    QTableWidgetItem *value = new QTableWidgetItem(QString::fromStdString(it->second));
     ui->infoView->setItem(rowCount, 1, value);
     
     map<string, int>::iterator map_it = endorseCount.find(it->first);
@@ -288,6 +286,28 @@
   }
 }
 
+bool
+AddContactPanel::isSameBlob(const ndn::Blob& blobA, const ndn::Blob& blobB)
+{
+  size_t size = blobA.size();
+
+  if(size != blobB.size())
+    return false;
+
+  const uint8_t* ap = blobA.buf();
+  const uint8_t* bp = blobB.buf();
+  
+  for(int i = 0; i < size; i++)
+    {
+      if(ap[i] != bp[i])
+        return false;
+    }
+
+  return true;
+
+}
+
+
 #if WAF
 #include "addcontactpanel.moc"
 #include "addcontactpanel.cpp.moc"
diff --git a/src/addcontactpanel.h b/src/addcontactpanel.h
index 3437e54..efc1dc0 100644
--- a/src/addcontactpanel.h
+++ b/src/addcontactpanel.h
@@ -36,7 +36,7 @@
   Q_OBJECT
 
 public:
-  explicit AddContactPanel(ndn::Ptr<ContactManager> contactManager,
+  explicit AddContactPanel(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
                            QWidget *parent = 0);
 
   ~AddContactPanel();
@@ -48,6 +48,9 @@
   bool
   isCorrectName(const ndn::Name& name);
 
+  static bool
+  isSameBlob(const ndn::Blob& blobA, const ndn::Blob& blobB);
+
 private slots:
   void
   onCancelClicked();
@@ -83,10 +86,10 @@
 private:
   Ui::AddContactPanel *ui;
   ndn::Name m_searchIdentity;
-  ndn::Ptr<ContactManager> m_contactManager;
+  ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager;
   WarningDialog* m_warningDialog;
-  ndn::Ptr<EndorseCertificate> m_currentEndorseCertificate;
-  ndn::Ptr<ndn::Data> m_currentCollectEndorse;
+  ndn::ptr_lib::shared_ptr<EndorseCertificate> m_currentEndorseCertificate;
+  ndn::ptr_lib::shared_ptr<ndn::Data> m_currentCollectEndorse;
   bool m_currentEndorseCertificateReady;
   bool m_currentCollectEndorseReady;
 };
diff --git a/src/browsecontactdialog.cpp b/src/browsecontactdialog.cpp
index e556e0c..ee783e5 100644
--- a/src/browsecontactdialog.cpp
+++ b/src/browsecontactdialog.cpp
@@ -18,17 +18,18 @@
 #include <boost/tokenizer.hpp>
 #include "logging.h"
 #include "exception.h"
-#include "ndn.cxx/error.h"
+// #include "ndn.cxx/error.h"
 #endif
 
 using namespace std;
 using namespace ndn;
+using namespace ndn::ptr_lib;
 
 INIT_LOGGER("BrowseContactDialog");
 
 // Q_DECLARE_METATYPE(ndn::security::IdentityCertificate)
 
-BrowseContactDialog::BrowseContactDialog(Ptr<ContactManager> contactManager,
+BrowseContactDialog::BrowseContactDialog(shared_ptr<ContactManager> contactManager,
 					 QWidget *parent) 
   : QDialog(parent)
   , ui(new Ui::BrowseContactDialog)
@@ -139,24 +140,24 @@
   
   if(filter)
     {
-      map<Name, Name> certificateMap;
+      map<Name, Name, Name::BreadthFirstLess> certificateMap;
 
       vector<string>::iterator it = certNameList.begin();
   
       for(; it != certNameList.end(); it++)
 	{
 	  Name newCertName(*it);
-	  Name keyName = security::IdentityCertificate::certificateNameToPublicKeyName(newCertName, true);
-	  Name identity = keyName.getPrefix(keyName.size()-1);
+	  Name keyName = IdentityCertificate::certificateNameToPublicKeyName(newCertName);
+	  Name identity = keyName.getPrefix(-1);
 	  
 	  map<Name, Name>::iterator map_it = certificateMap.find(identity);
 	  if(map_it != certificateMap.end())
 	    {
 	      Name oldCertName = map_it->second;
-	      Name oldKeyName = security::IdentityCertificate::certificateNameToPublicKeyName(oldCertName, true);
-	      if(keyName > oldKeyName)
+	      Name oldKeyName = IdentityCertificate::certificateNameToPublicKeyName(oldCertName);
+	      if(keyName.get(-1).toEscapedString() > oldKeyName.get(-1).toEscapedString())
 		map_it->second = newCertName;
-	      else if(keyName == oldKeyName && newCertName > oldCertName)
+	      else if(keyName == oldKeyName && newCertName.get(-1).toVersion() > oldCertName.get(-1).toVersion())
 		map_it->second = newCertName;
 	    }
 	  else
@@ -174,17 +175,18 @@
   
       for(; it != certNameList.end(); it++)
 	{
-          try {
-            m_certificateNameList.push_back(Name (*it));
-          }
-          catch(error::Name)
-            {
-              _LOG_ERROR ("Error parsing: [" << *it << "]");
-            }
-          catch(error::name::Component)
-            {
-              _LOG_ERROR ("Error parsing: [" << *it << "]");
-            }
+          m_certificateNameList.push_back(Name (*it));
+          // try {
+          //   m_certificateNameList.push_back(Name (*it));
+          // }
+          // catch(error::Name)
+          //   {
+          //     _LOG_ERROR ("Error parsing: [" << *it << "]");
+          //   }
+          // catch(error::name::Component)
+          //   {
+          //     _LOG_ERROR ("Error parsing: [" << *it << "]");
+          //   }
 	}
     }
 }
@@ -201,13 +203,13 @@
 }
 
 void
-BrowseContactDialog::onCertificateFetched(const security::IdentityCertificate& identityCertificate)
+BrowseContactDialog::onCertificateFetched(const IdentityCertificate& identityCertificate)
 {
   Name certName = identityCertificate.getName();
   Name certNameNoVersion = certName.getPrefix(certName.size()-1);
-  m_certificateMap.insert(pair<Name, security::IdentityCertificate>(certNameNoVersion, identityCertificate));
+  m_certificateMap.insert(pair<Name, IdentityCertificate>(certNameNoVersion, identityCertificate));
   m_profileMap.insert(pair<Name, Profile>(certNameNoVersion, Profile(identityCertificate)));
-  string name(m_profileMap[certNameNoVersion].getProfileEntry("name")->buf(), m_profileMap[certNameNoVersion].getProfileEntry("name")->size());
+  string name = m_profileMap[certNameNoVersion].getProfileEntry("name");
   // Name contactName = m_profileMap[certNameNoVersion].getIdentityName();
   {
       UniqueRecLock lock(m_mutex);
@@ -270,8 +272,7 @@
 	  QTableWidgetItem *type = new QTableWidgetItem(QString::fromStdString(pro_it->first));
 	  ui->InfoTable->setItem(rowCount, 0, type);
 	  
-	  string valueString(pro_it->second.buf(), pro_it->second.size());
-	  QTableWidgetItem *value = new QTableWidgetItem(QString::fromStdString(valueString));
+	  QTableWidgetItem *value = new QTableWidgetItem(QString::fromStdString(pro_it->second));
 	  ui->InfoTable->setItem(rowCount, 1, value);	  
 	}
     }
diff --git a/src/browsecontactdialog.h b/src/browsecontactdialog.h
index 9369d05..1f74bc1 100644
--- a/src/browsecontactdialog.h
+++ b/src/browsecontactdialog.h
@@ -19,7 +19,7 @@
 
 
 #ifndef Q_MOC_RUN
-#include <ndn.cxx/security/certificate/identity-certificate.h>
+#include <ndn-cpp/security/certificate/identity-certificate.hpp>
 #include <boost/thread/locks.hpp>
 #include <boost/thread/recursive_mutex.hpp>
 #include "profile.h"
@@ -35,7 +35,7 @@
   Q_OBJECT
   
 public:
-  explicit BrowseContactDialog(ndn::Ptr<ContactManager> contactManager,
+  explicit BrowseContactDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
                                QWidget *parent = 0);
 
   ~BrowseContactDialog();
@@ -67,7 +67,7 @@
                   const QItemSelection &deselected);
 
   void
-  onCertificateFetched(const ndn::security::IdentityCertificate& identityCertificate);
+  onCertificateFetched(const ndn::IdentityCertificate& identityCertificate);
 
   void
   onCertificateFetchFailed(const ndn::Name& identity);
@@ -95,7 +95,7 @@
 private:
   Ui::BrowseContactDialog *ui;
   
-  ndn::Ptr<ContactManager> m_contactManager;
+  ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager;
 
   WarningDialog* m_warningDialog;
   QStringListModel* m_contactListModel;
@@ -103,8 +103,8 @@
   QStringList m_contactList;  
   std::vector<ndn::Name> m_contactNameList;
   std::vector<ndn::Name> m_certificateNameList;
-  std::map<ndn::Name, ndn::security::IdentityCertificate> m_certificateMap;
-  std::map<ndn::Name, Profile> m_profileMap;
+  std::map<ndn::Name, ndn::IdentityCertificate, ndn::Name::BreadthFirstLess> m_certificateMap;
+  std::map<ndn::Name, Profile, ndn::Name::BreadthFirstLess> m_profileMap;
 
   RecLock m_mutex;
 
diff --git a/src/chat-policy-rule.cpp b/src/chat-policy-rule.cpp
index 76d0cf1..db1d910 100644
--- a/src/chat-policy-rule.cpp
+++ b/src/chat-policy-rule.cpp
@@ -9,15 +9,15 @@
  */
 
 #include "chat-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 std;
-using namespace ndn::security;
+using namespace ndn::ptr_lib;
 
 
-ChatPolicyRule::ChatPolicyRule(Ptr<Regex> dataRegex,
-			       Ptr<Regex> signerRegex)
+ChatPolicyRule::ChatPolicyRule(shared_ptr<Regex> dataRegex,
+			       shared_ptr<Regex> signerRegex)
   : PolicyRule(PolicyRule::IDENTITY_POLICY, true)
   , m_dataRegex(dataRegex)
   , m_signerRegex(signerRegex)
@@ -36,13 +36,12 @@
 bool 
 ChatPolicyRule::matchSignerName(const Data & data)
 { 
-  Ptr<const Signature> sig = data.getSignature();
+  const Sha256WithRsaSignature* sigPtr = dynamic_cast<const Sha256WithRsaSignature*> (data.getSignature());
 
-  if(NULL == sig)
+  if(NULL == sigPtr)
     return false;
 
-  Ptr<const signature::Sha256WithRsa> sigPtr = DynamicCast<const signature::Sha256WithRsa> (sig);
-  if(KeyLocator::KEYNAME != sigPtr->getKeyLocator().getType())
+  if(ndn_KeyLocatorType_KEYNAME != sigPtr->getKeyLocator().getType())
     return false;
 
   Name signerName = sigPtr->getKeyLocator ().getKeyName ();
diff --git a/src/chat-policy-rule.h b/src/chat-policy-rule.h
index 4534bab..fec4b69 100644
--- a/src/chat-policy-rule.h
+++ b/src/chat-policy-rule.h
@@ -11,15 +11,15 @@
 #ifndef CHAT_POLICY_RULE_H
 #define CHAT_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 ChatPolicyRule : public ndn::security::PolicyRule
+class ChatPolicyRule : public ndn::PolicyRule
 {
   
 public:
-  ChatPolicyRule(ndn::Ptr<ndn::Regex> dataRegex,
-                 ndn::Ptr<ndn::Regex> signerRegex);
+  ChatPolicyRule(ndn::ptr_lib::shared_ptr<ndn::Regex> dataRegex,
+                 ndn::ptr_lib::shared_ptr<ndn::Regex> signerRegex);
 
   ChatPolicyRule(const ChatPolicyRule& rule);
 
@@ -39,8 +39,8 @@
   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/chatdialog.cpp b/src/chatdialog.cpp
index 6a3f70c..5a6d483 100644
--- a/src/chatdialog.cpp
+++ b/src/chatdialog.cpp
@@ -18,12 +18,10 @@
 #include <QCloseEvent>
 
 #ifndef Q_MOC_RUN
-#include <ndn.cxx/security/identity/identity-manager.h>
-#include <ndn.cxx/security/policy/no-verify-policy-manager.h>
-#include <ndn.cxx/security/encryption/basic-encryption-manager.h>
 #include <sync-intro-certificate.h>
 #include <boost/random/random_device.hpp>
 #include <boost/random/uniform_int_distribution.hpp>
+#include <ndn-cpp/sha256-with-rsa-signature.hpp>
 #include "logging.h"
 #endif
 
@@ -36,7 +34,7 @@
 Q_DECLARE_METATYPE(std::vector<Sync::MissingDataInfo> )
 Q_DECLARE_METATYPE(size_t)
 
-ChatDialog::ChatDialog(ndn::Ptr<ContactManager> contactManager,
+ChatDialog::ChatDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
                        const ndn::Name& chatroomPrefix,
 		       const ndn::Name& localPrefix,
                        const ndn::Name& defaultIdentity,
@@ -49,7 +47,7 @@
   , m_chatroomPrefix(chatroomPrefix)
   , m_localPrefix(localPrefix)
   , m_defaultIdentity(defaultIdentity)
-  , m_invitationPolicyManager(ndn::Ptr<InvitationPolicyManager>(new InvitationPolicyManager(m_chatroomPrefix.get(-1).toUri(), m_defaultIdentity)))
+  , m_invitationPolicyManager(new InvitationPolicyManager(m_chatroomPrefix.get(-1).toEscapedString(), m_defaultIdentity))
   , m_nick(nick)
   , m_sock(NULL)
   , m_lastMsgTime(0)
@@ -87,7 +85,13 @@
 
   m_timer = new QTimer(this);
 
-  setWrapper(trial);
+  ndn::Name certificateName = m_identityManager->getDefaultCertificateNameForIdentity(m_defaultIdentity);
+  m_syncPolicyManager = ndn::ptr_lib::make_shared<SyncPolicyManager>(m_defaultIdentity, certificateName, m_chatroomPrefix);
+
+  m_transport = ndn::ptr_lib::make_shared<ndn::TcpTransport>();
+  m_face = ndn::ptr_lib::make_shared<ndn::Face>(m_transport, ndn::ptr_lib::make_shared<ndn::TcpTransport::ConnectionInfo>("localhost"));
+
+  connectToDaemon();
 
   connect(ui->inviteButton, SIGNAL(clicked()),
           this, SLOT(openInviteListDialog()));
@@ -125,34 +129,34 @@
       delete m_sock;
       m_sock = NULL;
     }
-  m_handler->shutdown();
+  m_face->shutdown();
 }
 
 void
-ChatDialog::setWrapper(bool trial)
+ChatDialog::connectToDaemon()
 {
-  m_identityManager = ndn::Ptr<ndn::security::IdentityManager>::Create();
-
-  ndn::Name certificateName = m_identityManager->getDefaultCertificateNameByIdentity(m_defaultIdentity);
-  m_syncPolicyManager = ndn::Ptr<SyncPolicyManager>(new SyncPolicyManager(m_defaultIdentity, certificateName, m_chatroomPrefix));
-
-  m_keychain = ndn::Ptr<ndn::security::Keychain>(new ndn::security::Keychain(m_identityManager, m_invitationPolicyManager, NULL));
-
-  ndn::Ptr<ndn::security::Keychain> noVerifyKeychain = ndn::Ptr<ndn::security::Keychain>(new ndn::security::Keychain(m_identityManager,
-ndn::Ptr<ndn::security::NoVerifyPolicyManager>::Create(), NULL));
-  try{
-    m_handler = ndn::Ptr<ndn::Wrapper>(new ndn::Wrapper(m_keychain));
-    m_localPrefixHandler = ndn::Ptr<ndn::Wrapper>(new ndn::Wrapper(noVerifyKeychain));
-  }catch(ndn::Error::ndnOperation& e){
-    emit noNdnConnection(QString::fromStdString("Cannot conect to ndnd!\n Have you started your ndnd?"));
-  }
+  //Hack! transport does not connect to daemon unless an interest is expressed.
+  ndn::Name name("/ndn");
+  ndn::ptr_lib::shared_ptr<ndn::Interest> interest = ndn::ptr_lib::make_shared<ndn::Interest>(name);
+  m_face->expressInterest(*interest, 
+                          boost::bind(&ChatDialog::onConnectionData, this, _1, _2),
+                          boost::bind(&ChatDialog::onConnectionDataTimeout, this, _1));
 }
 
 void
+ChatDialog::onConnectionData(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
+                             const ndn::ptr_lib::shared_ptr<ndn::Data>& data)
+{ _LOG_DEBUG("onConnectionData"); }
+
+void
+ChatDialog::onConnectionDataTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest)
+{ _LOG_DEBUG("onConnectionDataTimeout"); }
+
+void
 ChatDialog::initializeSetting()
 {
   m_user.setNick(QString::fromStdString(m_nick));
-  m_user.setChatroom(QString::fromStdString(m_chatroomPrefix.get(-1).toUri()));
+  m_user.setChatroom(QString::fromStdString(m_chatroomPrefix.get(-1).toEscapedString()));
   m_user.setOriginPrefix(QString::fromStdString(m_localPrefix.toUri()));
   m_user.setPrefix(QString::fromStdString(m_localChatPrefix.toUri()));
   m_scene->setCurrentPrefix(QString::fromStdString(m_localChatPrefix.toUri()));
@@ -179,11 +183,121 @@
 }
 
 void
-ChatDialog::sendInvitation(ndn::Ptr<ContactItem> contact, bool isIntroducer)
+ChatDialog::sendInterest(const ndn::Interest& interest,
+                         const ndn::OnVerified& onVerified,
+                         const ndn::OnVerifyFailed& onVerifyFailed,
+                         const OnEventualTimeout& timeoutNotify,
+                         const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager,
+                         int retry /* = 1 */,
+                         int stepCount /* = 0 */)
+{
+  m_face->expressInterest(interest, 
+                          boost::bind(&ChatDialog::onTargetData, 
+                                      this,
+                                      _1,
+                                      _2,
+                                      stepCount,
+                                      onVerified, 
+                                      onVerifyFailed,
+                                      timeoutNotify,
+                                      policyManager),
+                          boost::bind(&ChatDialog::onTargetTimeout,
+                                      this,
+                                      _1,
+                                      retry,
+                                      stepCount,
+                                      onVerified,
+                                      onVerifyFailed,
+                                      timeoutNotify,
+                                      policyManager));
+}
+
+void
+ChatDialog::onTargetData(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,
+                         const OnEventualTimeout& timeoutNotify,
+                         const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager)
+{
+  ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> nextStep = policyManager->checkVerificationPolicy(data, stepCount, onVerified, onVerifyFailed);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       boost::bind(&ChatDialog::onCertData, this, _1, _2, nextStep, policyManager), 
+       boost::bind(&ChatDialog::onCertTimeout, this, _1, onVerifyFailed, data, nextStep, policyManager));
+}
+
+void
+ChatDialog::onTargetTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                            int retry,
+                            int stepCount,
+                            const ndn::OnVerified& onVerified,
+                            const ndn::OnVerifyFailed& onVerifyFailed,
+                            const OnEventualTimeout& timeoutNotify,
+                            const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager)
+{
+  if(retry > 0)
+    sendInterest(*interest, onVerified, onVerifyFailed, timeoutNotify, policyManager, retry-1, stepCount);
+  else
+    {
+      _LOG_DEBUG("Interest: " << interest->getName().toUri() << " eventually times out!");
+      timeoutNotify();
+    }
+}
+
+void
+ChatDialog::onCertData(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,
+                       const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager)
+{
+  ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> nextStep = policyManager->checkVerificationPolicy(cert, 
+                                                                                                     previousStep->stepCount_, 
+                                                                                                     previousStep->onVerified_, 
+                                                                                                     previousStep->onVerifyFailed_);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       boost::bind(&ChatDialog::onCertData, this, _1, _2, nextStep, policyManager), 
+       boost::bind(&ChatDialog::onCertTimeout, this, _1, previousStep->onVerifyFailed_, cert, nextStep, policyManager));
+}
+
+void
+ChatDialog::onCertTimeout(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,
+                          const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager)
+{
+  if(nextStep->retry_ > 0)
+    m_face->expressInterest(*interest, 
+                            boost::bind(&ChatDialog::onCertData,
+                                        this,
+                                        _1,
+                                        _2,
+                                        nextStep,
+                                        policyManager),
+                            boost::bind(&ChatDialog::onCertTimeout,
+                                        this,
+                                        _1,
+                                        onVerifyFailed,
+                                        data,
+                                        nextStep,
+                                        policyManager));
+ else
+   onVerifyFailed(data);
+}
+
+void
+ChatDialog::sendInvitation(ndn::ptr_lib::shared_ptr<ContactItem> contact, bool isIntroducer)
 {
   m_invitationPolicyManager->addTrustAnchor(contact->getSelfEndorseCertificate());
 
-  ndn::Name certificateName = m_identityManager->getDefaultCertificateNameByIdentity(m_defaultIdentity);
+  ndn::Name certificateName = m_identityManager->getDefaultCertificateNameForIdentity(m_defaultIdentity);
 
   ndn::Name interestName("/ndn/broadcast/chronos/invitation");
   interestName.append(contact->getNameSpace());
@@ -195,57 +309,63 @@
   interestName.append(certificateName);
 
   string signedUri = interestName.toUri();
-  ndn::Blob signedBlob(signedUri.c_str(), signedUri.size());
+  ndn::Blob signedBlob((const uint8_t*)signedUri.c_str(), signedUri.size());
 
-  ndn::Ptr<const ndn::signature::Sha256WithRsa> sha256sig = ndn::DynamicCast<const ndn::signature::Sha256WithRsa>(m_identityManager->signByCertificate(signedBlob, certificateName));
-  const ndn::Blob& sigBits = sha256sig->getSignatureBits();
+  ndn::ptr_lib::shared_ptr<const ndn::Sha256WithRsaSignature> sha256sig = ndn::ptr_lib::dynamic_pointer_cast<const ndn::Sha256WithRsaSignature>(m_identityManager->signByCertificate(signedBlob.buf(), signedBlob.size(), certificateName));
+  const ndn::Blob& sigBits = sha256sig->getSignature();
 
-  interestName.append(sigBits.buf(), sigBits.size());
-  interestName.appendVersion();
+  interestName.append(sigBits);
+  //TODO... remove version from invitation interest
+  //  interestName.appendVersion();
 
-  ndn::Ptr<ndn::Interest> interest = ndn::Ptr<ndn::Interest>(new ndn::Interest(interestName));
-  ndn::Ptr<ndn::Closure> closure = ndn::Ptr<ndn::Closure>(new ndn::Closure(boost::bind(&ChatDialog::onInviteReplyVerified,
-                                                                                       this,
-                                                                                       _1,
-                                                                                       contact->getNameSpace(),
-                                                                                       isIntroducer),
-                                                                           boost::bind(&ChatDialog::onInviteTimeout,
-                                                                                       this,
-                                                                                       _1,
-                                                                                       _2,
-                                                                                       contact->getNameSpace(),
-                                                                                       7),
-                                                                           boost::bind(&ChatDialog::onUnverified,
-                                                                                       this,
-                                                                                       _1)));
+  ndn::Interest interest(interestName);
+  ndn::OnVerified onVerified = boost::bind(&ChatDialog::onInviteReplyVerified,
+                                           this,
+                                           _1,
+                                           contact->getNameSpace(),
+                                           isIntroducer);
 
-  m_handler->sendInterest(interest, closure);
+  ndn::OnVerifyFailed onVerifyFailed = boost::bind(&ChatDialog::onInviteReplyVerifyFailed,
+                                                   this,
+                                                   _1,
+                                                   contact->getNameSpace());
+
+  OnEventualTimeout timeoutNotify = boost::bind(&ChatDialog::onInviteReplyTimeout,
+                                                     this,
+                                                     contact->getNameSpace());
+                                                 
+
+  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify, m_invitationPolicyManager);
+}
+
+void 
+ChatDialog::onInviteReplyVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, 
+                                  const ndn::Name& identity, 
+                                  bool isIntroducer)
+{
+  string content((const char*)data->getContent().buf(), data->getContent().size());
+  if(content == string("nack"))
+    invitationRejected(identity);
+  else
+    invitationAccepted(identity, data, content, isIntroducer);
 }
 
 void
-ChatDialog::addTrustAnchor(const EndorseCertificate& selfEndorseCertificate)
-{ m_invitationPolicyManager->addTrustAnchor(selfEndorseCertificate); }
-
-void
-ChatDialog::addChatDataRule(const ndn::Name& prefix, 
-                            const ndn::security::IdentityCertificate& identityCertificate,
-                            bool isIntroducer)
-{ m_syncPolicyManager->addChatDataRule(prefix, identityCertificate, isIntroducer); }
-
-void
-ChatDialog::publishIntroCert(const ndn::security::IdentityCertificate& dskCertificate, bool isIntroducer)
+ChatDialog::onInviteReplyVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data,
+                                      const ndn::Name& identity)
 {
-  SyncIntroCertificate syncIntroCertificate(m_chatroomPrefix,
-                                            dskCertificate.getPublicKeyName(),
-                                            m_identityManager->getDefaultKeyNameForIdentity(m_defaultIdentity),
-                                            dskCertificate.getNotBefore(),
-                                            dskCertificate.getNotAfter(),
-                                            dskCertificate.getPublicKeyInfo(),
-                                            (isIntroducer ? SyncIntroCertificate::INTRODUCER : SyncIntroCertificate::PRODUCER));
-  ndn::Name certName = m_identityManager->getDefaultCertificateNameByIdentity(m_defaultIdentity);
-  _LOG_DEBUG("Publish Intro Certificate: " << syncIntroCertificate.getName());
-  m_identityManager->signByCertificate(syncIntroCertificate, certName);
-  m_handler->putToNdnd(*syncIntroCertificate.encodeToWire());
+  _LOG_DEBUG("Reply from " << identity.toUri() << " cannot be verified!");
+  QString msg = QString::fromUtf8("Reply from ") + QString::fromStdString(identity.toUri()) + " cannot be verified!";
+  emit inivationRejection(msg);
+}
+
+
+void
+ChatDialog::onInviteReplyTimeout(const ndn::Name& identity)
+{
+  _LOG_DEBUG("Your invitation to " << identity.toUri() << " times out!");
+  QString msg = QString::fromUtf8("Your invitation to ") + QString::fromStdString(identity.toUri()) + " times out!";
+  emit inivationRejection(msg);
 }
 
 void
@@ -257,55 +377,43 @@
 }
 
 void
-ChatDialog::invitationAccepted(const ndn::Name& identity, ndn::Ptr<ndn::Data> data, const string& inviteePrefix, bool isIntroducer)
+ChatDialog::invitationAccepted(const ndn::Name& identity, ndn::ptr_lib::shared_ptr<ndn::Data> data, const string& inviteePrefix, bool isIntroducer)
 {
   _LOG_DEBUG(" " << identity.toUri() << " Accepted your invitation!");
-  ndn::Ptr<const ndn::signature::Sha256WithRsa> sha256sig = boost::dynamic_pointer_cast<const ndn::signature::Sha256WithRsa> (data->getSignature());
+  const ndn::Sha256WithRsaSignature* sha256sig = dynamic_cast<const ndn::Sha256WithRsaSignature*>(data->getSignature());
   const ndn::Name & keyLocatorName = sha256sig->getKeyLocator().getKeyName();
-  ndn::Ptr<ndn::security::IdentityCertificate> dskCertificate = m_invitationPolicyManager->getValidatedDskCertificate(keyLocatorName);
+  ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate> dskCertificate = m_invitationPolicyManager->getValidatedDskCertificate(keyLocatorName);
   m_syncPolicyManager->addChatDataRule(inviteePrefix, *dskCertificate, isIntroducer);
   publishIntroCert(*dskCertificate, isIntroducer);
 }
 
-void 
-ChatDialog::onInviteReplyVerified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity, bool isIntroducer)
+void
+ChatDialog::publishIntroCert(const ndn::IdentityCertificate& dskCertificate, bool isIntroducer)
 {
-  string content(data->content().buf(), data->content().size());
-  if(content == string("nack"))
-    invitationRejected(identity);
-  else
-    invitationAccepted(identity, data, content, isIntroducer);
+  SyncIntroCertificate syncIntroCertificate(m_chatroomPrefix,
+                                            dskCertificate.getPublicKeyName(),
+                                            m_identityManager->getDefaultKeyNameForIdentity(m_defaultIdentity),
+                                            dskCertificate.getNotBefore(),
+                                            dskCertificate.getNotAfter(),
+                                            dskCertificate.getPublicKeyInfo(),
+                                            (isIntroducer ? SyncIntroCertificate::INTRODUCER : SyncIntroCertificate::PRODUCER));
+  ndn::Name certName = m_identityManager->getDefaultCertificateNameForIdentity(m_defaultIdentity);
+  _LOG_DEBUG("Publish Intro Certificate: " << syncIntroCertificate.getName());
+  m_identityManager->signByCertificate(syncIntroCertificate, certName);
+  m_transport->send(*syncIntroCertificate.wireEncode());
 }
 
-void 
-ChatDialog::onInviteTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry)
-{
-  if(retry > 0)
-    {
-      ndn::Ptr<ndn::Closure> newClosure = ndn::Ptr<ndn::Closure>(new ndn::Closure(closure->m_dataCallback,
-                                                                                  boost::bind(&ChatDialog::onInviteTimeout, 
-                                                                                              this, 
-                                                                                              _1, 
-                                                                                              _2, 
-                                                                                              identity,
-                                                                                              retry - 1),
-                                                                                  closure->m_unverifiedCallback,
-                                                                                  closure->m_stepCount)
-                                                                 );
-      m_handler->sendInterest(interest, newClosure);
-    }
-  else
-    invitationRejected(identity);
-}
+void
+ChatDialog::addTrustAnchor(const EndorseCertificate& selfEndorseCertificate)
+{ m_invitationPolicyManager->addTrustAnchor(selfEndorseCertificate); }
+
+void
+ChatDialog::addChatDataRule(const ndn::Name& prefix, 
+                            const ndn::IdentityCertificate& identityCertificate,
+                            bool isIntroducer)
+{ m_syncPolicyManager->addChatDataRule(prefix, identityCertificate, isIntroducer); }
+
  
-void
-ChatDialog::onUnverified(ndn::Ptr<ndn::Data> data)
-{}
-
-void
-ChatDialog::onTimeout(ndn::Ptr<ndn::Closure> closure, 
-                      ndn::Ptr<ndn::Interest> interest)
-{}
 
 void
 ChatDialog::initializeSync()
@@ -313,8 +421,8 @@
   
   m_sock = new Sync::SyncSocket(m_chatroomPrefix.toUri(),
                                 m_syncPolicyManager,
-                                bind(&ChatDialog::processTreeUpdateWrapper, this, _1, _2),
-                                bind(&ChatDialog::processRemoveWrapper, this, _1));
+                                boost::bind(&ChatDialog::processTreeUpdateWrapper, this, _1, _2),
+                                boost::bind(&ChatDialog::processRemoveWrapper, this, _1));
   
   usleep(100000);
 
@@ -449,11 +557,11 @@
 }
 
 void
-ChatDialog::processDataWrapper(ndn::Ptr<ndn::Data> data)
+ChatDialog::processDataWrapper(const ndn::ptr_lib::shared_ptr<ndn::Data>& data)
 {
   string name = data->getName().toUri();
-  const char* buf = data->content().buf();
-  size_t len = data->content().size();
+  const char* buf = (const char*)data->getContent().buf();
+  size_t len = data->getContent().size();
 
   char *tempBuf = new char[len];
   memcpy(tempBuf, buf, len);
@@ -462,11 +570,11 @@
 }
 
 void
-ChatDialog::processDataNoShowWrapper(ndn::Ptr<ndn::Data> data)
+ChatDialog::processDataNoShowWrapper(const ndn::ptr_lib::shared_ptr<ndn::Data>& data)
 {
   string name = data->getName().toUri();
-  const char* buf = data->content().buf();
-  size_t len = data->content().size();
+  const char* buf = (const char*)data->getContent().buf();
+  size_t len = data->getContent().size();
 
   char *tempBuf = new char[len];
   memcpy(tempBuf, buf, len);
@@ -755,7 +863,7 @@
       m_timer->start(FRESHNESS * 1000);
       disableTreeDisplay();
       QTimer::singleShot(2200, this, SLOT(enableTreeDisplay()));
-    }catch(ndn::Error::ndnOperation& e){
+    }catch(std::exception& e){
       emit noNdnConnection(QString::fromStdString("Cannot conect to ndnd!\n Have you started your ndnd?"));
     }
   }
@@ -894,22 +1002,15 @@
 ChatDialog::updateLocalPrefix()
 {
   m_newLocalPrefixReady = false;
-  ndn::Ptr<ndn::Interest> interest = ndn::Ptr<ndn::Interest>(new ndn::Interest(ndn::Name("/local/ndn/prefix")));
-  interest->setChildSelector(ndn::Interest::CHILD_RIGHT);
-  interest->setInterestLifetime(1);
+  ndn::Name interestName("/local/ndn/prefix");
+  ndn::Interest interest(interestName);
+  interest.setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
+  interest.setInterestLifetimeMilliseconds(1000);
 
-  ndn::Ptr<ndn::Closure> closure = ndn::Ptr<ndn::Closure>(new ndn::Closure(boost::bind(&ChatDialog::onLocalPrefix,
-                                                                                       this,
-                                                                                       _1),
-                                                                           boost::bind(&ChatDialog::onLocalPrefixTimeout,
-                                                                                       this,
-                                                                                       _1,
-                                                                                       _2),
-                                                                           boost::bind(&ChatDialog::onLocalPrefix,
-                                                                                       this,
-                                                                                       _1)));
+  m_face->expressInterest(interest, 
+                          bind(&ChatDialog::onLocalPrefix, this, _1, _2), 
+                          bind(&ChatDialog::onLocalPrefixTimeout, this, _1));
   
-  m_localPrefixHandler->sendInterest(interest, closure);
   while(m_newLocalPrefixReady == false)
     {
 #if BOOST_VERSION >= 1050000
@@ -926,6 +1027,25 @@
     emit settingUpdated(m_user.getNick (), m_user.getChatroom (), originPrefix);
 }
 
+
+void
+ChatDialog::onLocalPrefix(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                          const ndn::ptr_lib::shared_ptr<ndn::Data>& data)
+{
+  string dataString((const char*)data->getContent().buf(), data->getContent().size());
+  QString originPrefix = QString::fromStdString (dataString).trimmed ();
+  string trimmedString = originPrefix.toStdString();
+  m_newLocalPrefix = ndn::Name(trimmedString);
+  m_newLocalPrefixReady = true;
+}
+
+void
+ChatDialog::onLocalPrefixTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest)
+{
+  m_newLocalPrefix = m_localPrefix;
+  m_newLocalPrefixReady = true;
+}
+
 static std::string chars2("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789");
 
 QString
@@ -942,23 +1062,6 @@
 }
 
 void
-ChatDialog::onLocalPrefix(ndn::Ptr<ndn::Data> data)
-{
-  string dataString(data->content().buf(), data->content().size());
-  QString originPrefix = QString::fromStdString (dataString).trimmed ();
-  string trimmedString = originPrefix.toStdString();
-  m_newLocalPrefix = ndn::Name(trimmedString);
-  m_newLocalPrefixReady = true;
-}
-
-void
-ChatDialog::onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest)
-{
-  m_newLocalPrefix = m_localPrefix;
-  m_newLocalPrefixReady = true;
-}
-
-void
 ChatDialog::changeEvent(QEvent *e)
 {
   switch(e->type())
@@ -1155,8 +1258,8 @@
 void
 ChatDialog::sendInvitationWrapper(QString invitee, bool isIntroducer)
 {
-  ndn::Name inviteeNamespace(invitee.toUtf8().constData());
-  ndn::Ptr<ContactItem> inviteeItem = m_contactManager->getContact(inviteeNamespace);
+  ndn::Name inviteeNamespace(invitee.toStdString());
+  ndn::ptr_lib::shared_ptr<ContactItem> inviteeItem = m_contactManager->getContact(inviteeNamespace);
   sendInvitation(inviteeItem, isIntroducer);
 }
 
diff --git a/src/chatdialog.h b/src/chatdialog.h
index 504d60f..0c06783 100644
--- a/src/chatdialog.h
+++ b/src/chatdialog.h
@@ -23,9 +23,9 @@
 #include "invitelistdialog.h"
 
 #ifndef Q_MOC_RUN
-#include <ndn.cxx/data.h>
-#include <ndn.cxx/security/keychain.h>
-#include <ndn.cxx/wrapper/wrapper.h>
+#include <ndn-cpp/data.hpp>
+#include <ndn-cpp/face.hpp>
+#include <ndn-cpp/security/identity/identity-manager.hpp>
 #include "invitation-policy-manager.h"
 #include "contact-item.h"
 
@@ -35,6 +35,8 @@
 #include "digesttreescene.h"
 #endif
 
+typedef ndn::func_lib::function<void()> OnEventualTimeout;
+
 #define MAX_HISTORY_ENTRY   20
 
 namespace Ui {
@@ -46,7 +48,7 @@
   Q_OBJECT
 
 public:
-  explicit ChatDialog(ndn::Ptr<ContactManager> contactManager,
+  explicit ChatDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
                       const ndn::Name& chatroomPrefix,
                       const ndn::Name& localPrefix,
                       const ndn::Name& defaultIdentity,
@@ -71,14 +73,14 @@
   { return m_localPrefix; }
 
   void
-  sendInvitation(ndn::Ptr<ContactItem> contact, bool isIntroducer);
+  sendInvitation(ndn::ptr_lib::shared_ptr<ContactItem> contact, bool isIntroducer);
 
   void
   addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);
 
   void
   addChatDataRule(const ndn::Name& prefix, 
-                  const ndn::security::IdentityCertificate& identityCertificate,
+                  const ndn::IdentityCertificate& identityCertificate,
                   bool isIntroducer);
 
   void 
@@ -88,16 +90,16 @@
   processTreeUpdateWrapper(const std::vector<Sync::MissingDataInfo>, Sync::SyncSocket *);
 
   void 
-  processDataWrapper(ndn::Ptr<ndn::Data> data);
+  processDataWrapper(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
 
   void 
-  processDataNoShowWrapper(ndn::Ptr<ndn::Data> data);
+  processDataNoShowWrapper(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
 
   void 
   processRemoveWrapper(std::string);
 
   void
-  publishIntroCert(const ndn::security::IdentityCertificate& dskCertificate, bool isIntroducer);
+  publishIntroCert(const ndn::IdentityCertificate& dskCertificate, bool isIntroducer);
 
 protected:
   void 
@@ -109,6 +111,16 @@
 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
   initializeSetting();
 
   QString 
@@ -118,42 +130,76 @@
   updateLabels();
 
   void
-  setWrapper(bool trial);
+  initializeSync();
 
   void
-  initializeSync();
+  onTargetData(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,
+               const OnEventualTimeout& timeoutNotify,
+               const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager);
+
+  void
+  onTargetTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                  int retry,
+                  int stepCount,
+                  const ndn::OnVerified& onVerified,
+                  const ndn::OnVerifyFailed& onVerifyFailed,
+                  const OnEventualTimeout& timeoutNotify,
+                  const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager);
+  
+  void
+  onCertData(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,
+             const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager);
+
+  void
+  onCertTimeout(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,
+                const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager);
+
+  void
+  sendInterest(const ndn::Interest& interest,
+               const ndn::OnVerified& onVerified,
+               const ndn::OnVerifyFailed& onVerifyFailed,
+               const OnEventualTimeout& timeoutNotify,
+               const ndn::ptr_lib::shared_ptr<ndn::PolicyManager>& policyManager,
+               int retry = 1,
+               int stepCount = 0);
   
   void 
-  onInviteReplyVerified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity, bool isIntroducer);
+  onInviteReplyVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, 
+                        const ndn::Name& identity, 
+                        bool isIntroduce);
+
+  void
+  onInviteReplyVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data,
+                            const ndn::Name& identity);
 
   void 
-  onInviteTimeout(ndn::Ptr<ndn::Closure> closure, 
-                  ndn::Ptr<ndn::Interest> interest, 
-                  const ndn::Name& identity, 
-                  int retry);
+  onInviteReplyTimeout(const ndn::Name& identity);
+
 
   void
   invitationRejected(const ndn::Name& identity);
   
   void 
-  invitationAccepted(const ndn::Name& identity,
-                     ndn::Ptr<ndn::Data> data, 
-                     const std::string& inviteePrefix,
+  invitationAccepted(const ndn::Name& identity, 
+                     ndn::ptr_lib::shared_ptr<ndn::Data> data, 
+                     const std::string& inviteePrefix, 
                      bool isIntroducer);
 
   void
-  onUnverified(ndn::Ptr<ndn::Data> data);
+  onLocalPrefix(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
 
   void
-  onTimeout(ndn::Ptr<ndn::Closure> closure, 
-            ndn::Ptr<ndn::Interest> interest);
-
-  void
-  onLocalPrefix(ndn::Ptr<ndn::Data> data);
-
-  void
-  onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, 
-                        ndn::Ptr<ndn::Interest> interest);
+  onLocalPrefixTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest);
 
   // void 
   // fetchHistory(std::string name);
@@ -277,18 +323,17 @@
     
 private:
   Ui::ChatDialog *ui;
-  ndn::Ptr<ContactManager> m_contactManager;
+  ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager;
   ndn::Name m_chatroomPrefix;
   ndn::Name m_localPrefix;
   ndn::Name m_localChatPrefix;
   ndn::Name m_defaultIdentity;
-  ndn::Ptr<InvitationPolicyManager> m_invitationPolicyManager;
-  ndn::Ptr<SyncPolicyManager> m_syncPolicyManager; 
-  ndn::Ptr<ndn::security::IdentityManager> m_identityManager;
-  ndn::Ptr<ndn::security::Keychain> m_keychain;
-  ndn::Ptr<ndn::Wrapper> m_handler;
+  ndn::ptr_lib::shared_ptr<InvitationPolicyManager> m_invitationPolicyManager;
+  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;
 
-  ndn::Ptr<ndn::Wrapper> m_localPrefixHandler;
   ndn::Name m_newLocalPrefix;
   bool m_newLocalPrefixReady;
 
diff --git a/src/chronos-invitation.cpp b/src/chronos-invitation.cpp
index f918342..28d36e1 100644
--- a/src/chronos-invitation.cpp
+++ b/src/chronos-invitation.cpp
@@ -10,7 +10,7 @@
 
 #include "chronos-invitation.h"
 
-#include <ndn.cxx/security/certificate/identity-certificate.h>
+#include <ndn-cpp/security/certificate/identity-certificate.hpp>
 #include "exception.h"
 #include "logging.h"
 
@@ -22,11 +22,11 @@
 ChronosInvitation::ChronosInvitation(const ndn::Name& originalInterestName)
   : m_interestName(originalInterestName)
 {
-  Name interestName = originalInterestName.getPrefix(originalInterestName.size()-1);
-  if(interestName.get(0).toUri() != string("ndn")
-     || interestName.get(1).toUri() != string("broadcast")
-     || interestName.get(2).toUri() != string("chronos")
-     || interestName.get(3).toUri() != string("invitation"))
+  Name interestName = originalInterestName.getPrefix(-1);
+  if(interestName.get(0).toEscapedString() != string("ndn")
+     || interestName.get(1).toEscapedString() != string("broadcast")
+     || interestName.get(2).toEscapedString() != string("chronos")
+     || interestName.get(3).toEscapedString() != string("invitation"))
     throw LnException("Wrong ChronosInvitation Name");
     
   int i = 4;
@@ -35,7 +35,7 @@
   string chatroomStr("chatroom");
   int inviteeBegin = 4;
   for(; i < size; i++)
-    if(interestName.get(i).toUri() == chatroomStr)
+    if(interestName.get(i).toEscapedString() == chatroomStr)
       break;
 
   if(i >= size)
@@ -45,7 +45,7 @@
   string inviterPrefixStr("inviter-prefix");
   int chatroomBegin = (++i);
   for(; i < size;  i++)
-    if(interestName.get(i).toUri() == inviterPrefixStr)
+    if(interestName.get(i).toEscapedString() == inviterPrefixStr)
       break;
 
   if(i > size)
@@ -55,7 +55,7 @@
   string inviterStr("inviter");
   int inviterPrefixBegin = (++i);
   for(; i < size; i++)
-    if(interestName.get(i).toUri() == inviterStr)
+    if(interestName.get(i).toEscapedString() == inviterStr)
       break;
   
   if(i > size)
@@ -65,14 +65,13 @@
   int inviterCertBegin = (++i);
   m_inviterCertificateName = interestName.getSubName(inviterCertBegin, size - 1 - inviterCertBegin);
   
-  string signature = interestName.get(-1).toBlob();
-  m_signatureBits.insert(m_signatureBits.end(), signature.begin(), signature.end());
+  m_signatureBits = interestName.get(-1).getValue();
  
-  Name keyName = security::IdentityCertificate::certificateNameToPublicKeyName(m_inviterCertificateName, true);
-  m_inviterNameSpace = keyName.getPrefix(keyName.size()-1);
+  Name keyName = IdentityCertificate::certificateNameToPublicKeyName(m_inviterCertificateName);
+  m_inviterNameSpace = keyName.getPrefix(-1);
 
   string signedName = interestName.getSubName(0, size - 1).toUri();
-  m_signedBlob.insert(m_signedBlob.end(), signedName.begin(), signedName.end());
+  m_signedBlob = Blob((const uint8_t*)signedName.c_str(), signedName.size());
 }
 
 ChronosInvitation::ChronosInvitation(const ChronosInvitation& invitation)
diff --git a/src/chronos-invitation.h b/src/chronos-invitation.h
index 7f660db..e343b15 100644
--- a/src/chronos-invitation.h
+++ b/src/chronos-invitation.h
@@ -12,7 +12,7 @@
 #define CHRONOS_INVITATION_H
 
 
-#include <ndn.cxx/fields/name.h>
+#include <ndn-cpp/name.hpp>
 
 class ChronosInvitation
 {
@@ -26,35 +26,35 @@
   virtual
   ~ChronosInvitation() {};
 
-  inline const ndn::Name&
+  const ndn::Name&
   getInviteeNameSpace() const
   { return m_inviteeNameSpace; }
 
-  inline const ndn::Name&
+  const ndn::Name&
   getChatroom() const
   { return m_chatroom; }
 
-  inline const ndn::Name&
+  const ndn::Name&
   getInviterPrefix() const
   { return m_inviterPrefix; }
 
-  inline const ndn::Name&
+  const ndn::Name&
   getInviterCertificateName() const
   { return m_inviterCertificateName; }
 
-  inline const ndn::Blob&
+  const ndn::Blob&
   getSignatureBits() const
   { return m_signatureBits; }
 
-  inline const ndn::Name&
+  const ndn::Name&
   getInviterNameSpace() const
   { return m_inviterNameSpace; }
 
-  inline const ndn::Blob&
+  const ndn::Blob&
   getSignedBlob() const
   { return m_signedBlob; }
   
-  inline const ndn::Name&
+  const ndn::Name&
   getInterestName() const
   { return m_interestName; }
 
diff --git a/src/contact-item.cpp b/src/contact-item.cpp
index 60e9a93..46cc4a3 100644
--- a/src/contact-item.cpp
+++ b/src/contact-item.cpp
@@ -10,14 +10,13 @@
 
 #include "contact-item.h"
 #include "exception.h"
-
-#include <ndn.cxx/fields/signature-sha256-with-rsa.h>
+#include "null-ptrs.h"
 
 #include "logging.h"
 
 using namespace std;
 using namespace ndn;
-using namespace ndn::security;
+using namespace ndn::ptr_lib;
 
 INIT_LOGGER("ContactItem");
 
@@ -32,15 +31,10 @@
   m_namespace = endorsedkeyName.getSubName(0, endorsedkeyName.size() - 1);
 
 
-  Ptr<ProfileData> profileData = selfEndorseCertificate.getProfileData();
-  Ptr<const Blob> nameBlob = profileData->getProfile().getProfileEntry("name");
-  m_name = string(nameBlob->buf(), nameBlob->size());
+  const ProfileData& profileData = selfEndorseCertificate.getProfileData();
+  m_name = profileData.getProfile().getProfileEntry("name");
   m_alias = alias.empty() ? m_name : alias;
-  Ptr<const Blob> institutionBlob = profileData->getProfile().getProfileEntry("institution");
-  if(institutionBlob != NULL)
-    m_institution = string(institutionBlob->buf(), institutionBlob->size());
-  else
-    m_institution = string();
+  m_institution = profileData.getProfile().getProfileEntry("institution");
 }
 
 ContactItem::ContactItem(const ContactItem& contactItem)
@@ -57,7 +51,7 @@
 bool 
 ContactItem::canBeTrustedFor(const Name& name)
 {
-  vector<Ptr<Regex> >::iterator it = m_trustScope.begin();
+  vector<shared_ptr<Regex> >::iterator it = m_trustScope.begin();
 
   for(; it != m_trustScope.end(); it++)
     if((*it)->match(name))
diff --git a/src/contact-item.h b/src/contact-item.h
index 9ab478b..238f647 100644
--- a/src/contact-item.h
+++ b/src/contact-item.h
@@ -11,14 +11,14 @@
 #ifndef LINKNDN_CONTACT_ITEM_H
 #define LINKNDN_CONTACT_ITEM_H
 
-#include <ndn.cxx/data.h>
-#include <ndn.cxx/regex/regex.h>
+#include <ndn-cpp/data.hpp>
+#include <ndn-cpp-et/regex/regex.hpp>
 #include <vector>
 #include "endorse-certificate.h"
 
 class ContactItem
 {
-  typedef std::vector<ndn::Ptr<EndorseCertificate> > EndorseCertificateList;
+  typedef std::vector<ndn::ptr_lib::shared_ptr<EndorseCertificate> > EndorseCertificateList;
 
 public:
   ContactItem(const EndorseCertificate& selfEndorseCertificate,
@@ -30,35 +30,35 @@
   virtual
   ~ContactItem() {}
 
-  inline const EndorseCertificate&
+  const EndorseCertificate&
   getSelfEndorseCertificate() const
   { return m_selfEndorseCertificate; }
 
-  inline const ndn::Name&
+  const ndn::Name&
   getNameSpace() const
   { return m_namespace; }
 
-  inline const std::string&
+  const std::string&
   getAlias() const
   { return m_alias; }
 
-  inline const std::string&
+  const std::string&
   getName() const
   { return m_name; }
 
-  inline const std::string&
+  const std::string&
   getInstitution() const
   { return m_institution; }
 
-  inline const ndn::Name
+  const ndn::Name
   getPublicKeyName() const
   { return m_selfEndorseCertificate.getPublicKeyName(); }
 
-  inline bool
+  bool
   isIntroducer() const
   { return m_isIntroducer; }
 
-  inline void
+  void
   setIsIntroducer(bool isIntroducer) 
   { m_isIntroducer = isIntroducer; }
 
@@ -72,7 +72,7 @@
   bool
   canBeTrustedFor(const ndn::Name& name);
 
-  inline const std::vector<ndn::Name>&
+  const std::vector<ndn::Name>&
   getTrustScopeList() const
   { return m_trustScopeName; }
 
@@ -87,7 +87,7 @@
 
   bool m_isIntroducer;
 
-  std::vector<ndn::Ptr<ndn::Regex> > m_trustScope;
+  std::vector<ndn::ptr_lib::shared_ptr<ndn::Regex> > m_trustScope;
   std::vector<ndn::Name> m_trustScopeName;
 };
 
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index 2d722d7..25c32a1 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -11,28 +11,36 @@
 #include "contact-manager.h"
 
 #ifndef Q_MOC_RUN
-#include <ndn.cxx/wrapper/wrapper.h>
-#include <ndn.cxx/security/keychain.h>
-#include <ndn.cxx/security/policy/simple-policy-manager.h>
-#include <ndn.cxx/security/policy/identity-policy-rule.h>
-#include <ndn.cxx/helpers/der/der.h>
+#include <ndn-cpp/face.hpp>
+#include <ndn-cpp/sha256-with-rsa-signature.hpp>
+#include <ndn-cpp/security/signature/sha256-with-rsa-handler.hpp>
 #include <cryptopp/base64.h>
+#include <ndn-cpp-et/policy-manager/identity-policy-rule.hpp>
 #include <fstream>
+#include "endorse-collection.pb.h"
+#include "null-ptrs.h"
 #include "logging.h"
 #endif
 
 using namespace ndn;
-using namespace ndn::security;
+using namespace ndn::ptr_lib;
+using namespace std;
 
 INIT_LOGGER("ContactManager");
 
-ContactManager::ContactManager(QObject* parent)
+ContactManager::ContactManager(shared_ptr<IdentityManager> identityManager, QObject* parent)
   : QObject(parent)
 {
-  m_contactStorage = Ptr<ContactStorage>::Create();
-  m_dnsStorage = Ptr<DnsStorage>::Create();
+  m_identityManager = identityManager;
+  m_contactStorage = make_shared<ContactStorage>();
+  m_dnsStorage = make_shared<DnsStorage>();
 
-  setKeychain();
+  m_transport = make_shared<TcpTransport>();
+  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
+  
+  connectToDaemon();
+
+  initializeSecurity();
 }
 
 ContactManager::~ContactManager()
@@ -40,46 +48,57 @@
 }
 
 void
-ContactManager::setWrapper()
+ContactManager::connectToDaemon()
 {
-  try{
-    m_wrapper = Ptr<Wrapper>(new Wrapper(m_keychain));
-  }catch(ndn::Error::ndnOperation& e){
-    emit noNdnConnection(QString::fromStdString("Cannot conect to ndnd!\nHave you started your ndnd?"));
-  }
+  //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(&ContactManager::onConnectionData, this, _1, _2),
+                          bind(&ContactManager::onConnectionDataTimeout, this, _1));
 }
 
 void
-ContactManager::setKeychain()
+ContactManager::onConnectionData(const shared_ptr<const ndn::Interest>& interest,
+                            const shared_ptr<Data>& data)
 {
-  Ptr<IdentityManager> identityManager = Ptr<IdentityManager>::Create();
-  Ptr<SimplePolicyManager> policyManager = Ptr<SimplePolicyManager>::Create();
+  _LOG_DEBUG("onConnectionData");
+}
 
-  Ptr<Keychain> keychain = Ptr<Keychain>(new Keychain(identityManager, policyManager, NULL));
+void
+ContactManager::onConnectionDataTimeout(const shared_ptr<const ndn::Interest>& interest)
+{
+  _LOG_DEBUG("onConnectionDataTimeout");
+}
 
-  policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<DNS>]*)<DNS><ENDORSED>",
-                                                                                          "^([^<KEY>]*)<KEY>(<>*)[<ksk-.*><dsk-.*>]<ID-CERT>$",
-                                                                                          "==", "\\1", "\\1\\2", true)));
-  policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<DNS>]*)<DNS><PROFILE>",
-                                                                                          "^([^<KEY>]*)<KEY>(<>*)[<ksk-.*><dsk-.*>]<ID-CERT>$",
-                                                                                          "==", "\\1", "\\1\\2", true)));
-  policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<PROFILE-CERT>]*)<PROFILE-CERT>",
-											  "^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>$", 
-											  "==", "\\1", "\\1\\2", true)));
-  policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>",
-											  "^([^<KEY>]*)<KEY><dsk-.*><ID-CERT>$",
-											  ">", "\\1\\2", "\\1", true)));
-  policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<KEY>]*)<KEY><dsk-.*><ID-CERT>",
-											  "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$",
-											  "==", "\\1", "\\1\\2", true)));
-  policyManager->addVerificationPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^(<>*)$", 
-                                                                                          "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", 
-                                                                                          ">", "\\1", "\\1\\2", true)));
+void
+ContactManager::initializeSecurity()
+{
+  m_policyManager = make_shared<SimplePolicyManager>();
+
+  m_policyManager->addVerificationPolicyRule(make_shared<IdentityPolicyRule>("^([^<DNS>]*)<DNS><ENDORSED>",
+                                                                             "^([^<KEY>]*)<KEY>(<>*)[<ksk-.*><dsk-.*>]<ID-CERT>$",
+                                                                             "==", "\\1", "\\1\\2", true));
+  m_policyManager->addVerificationPolicyRule(make_shared<IdentityPolicyRule>("^([^<DNS>]*)<DNS><PROFILE>",
+                                                                             "^([^<KEY>]*)<KEY>(<>*)[<ksk-.*><dsk-.*>]<ID-CERT>$",
+                                                                             "==", "\\1", "\\1\\2", true));
+  m_policyManager->addVerificationPolicyRule(make_shared<IdentityPolicyRule>("^([^<PROFILE-CERT>]*)<PROFILE-CERT>",
+                                                                             "^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>$", 
+                                                                             "==", "\\1", "\\1\\2", true));
+  m_policyManager->addVerificationPolicyRule(make_shared<IdentityPolicyRule>("^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>",
+                                                                             "^([^<KEY>]*)<KEY><dsk-.*><ID-CERT>$",
+                                                                             ">", "\\1\\2", "\\1", true));
+  m_policyManager->addVerificationPolicyRule(make_shared<IdentityPolicyRule>("^([^<KEY>]*)<KEY><dsk-.*><ID-CERT>",
+                                                                             "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$",
+                                                                             "==", "\\1", "\\1\\2", true));
+  m_policyManager->addVerificationPolicyRule(make_shared<IdentityPolicyRule>("^(<>*)$", 
+                                                                             "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", 
+                                                                             ">", "\\1", "\\1\\2", true));
   
 
-  policyManager->addSigningPolicyRule(Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<DNS>]*)<DNS><PROFILE>",
-                                                                                     "^([^<KEY>]*)<KEY>(<>*)<><ID-CERT>",
-                                                                                     "==", "\\1", "\\1\\2", true)));
+  m_policyManager->addSigningPolicyRule(make_shared<IdentityPolicyRule>("^([^<DNS>]*)<DNS><PROFILE>",
+                                                                        "^([^<KEY>]*)<KEY>(<>*)<><ID-CERT>",
+                                                                        "==", "\\1", "\\1\\2", true));
 
 
   const string TrustAnchor("BIICqgOyEIWlKzDI2xX2hdq5Azheu9IVyewcV4uM7ylfh67Y8MIxF3tDCTx5JgEn\
@@ -105,10 +124,10 @@
                             TrustAnchor.size(), 
                             true,
                             new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
-  Ptr<Blob> blob = Ptr<Blob>(new Blob(decoded.c_str(), decoded.size()));
-  Ptr<Data> data = Data::decodeFromWire(blob);
-  Ptr<IdentityCertificate>anchor = Ptr<IdentityCertificate>(new IdentityCertificate(*data));
-  policyManager->addTrustAnchor(anchor);  
+  Data data;
+  data.wireDecode((const uint8_t*)decoded.c_str(), decoded.size());
+  shared_ptr<IdentityCertificate> anchor = make_shared<IdentityCertificate>(data);
+  m_policyManager->addTrustAnchor(anchor);  
 
 #ifdef _DEBUG
 
@@ -135,14 +154,12 @@
                             FakeAnchor.size(), 
                             true,
                             new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded2)));
-  Ptr<Blob> blob2 = Ptr<Blob>(new Blob(decoded2.c_str(), decoded2.size()));
-  Ptr<Data> data2 = Data::decodeFromWire(blob2);
-  Ptr<IdentityCertificate>anchor2 = Ptr<IdentityCertificate>(new IdentityCertificate(*data2));
-  policyManager->addTrustAnchor(anchor2);  
+  Data data2;
+  data2.wireDecode((const uint8_t*)decoded2.c_str(), decoded2.size());
+  shared_ptr<IdentityCertificate>anchor2 = make_shared<IdentityCertificate>(data2);
+  m_policyManager->addTrustAnchor(anchor2);  
 
 #endif
-
-  m_keychain = keychain;
 }
 
 
@@ -152,74 +169,125 @@
   Name interestName = identity;
   interestName.append("DNS").append("PROFILE");
   
-  Ptr<Interest> interestPtr = Ptr<Interest>(new Interest(interestName));
-  interestPtr->setChildSelector(Interest::CHILD_RIGHT);
-  Ptr<Closure> closure = Ptr<Closure> (new Closure(boost::bind(&ContactManager::onDnsSelfEndorseCertificateVerified, 
-                                                               this,
-                                                               _1,
-                                                               identity),
-						   boost::bind(&ContactManager::onDnsSelfEndorseCertificateTimeout,
-                                                               this,
-                                                               _1, 
-                                                               _2,
-                                                               identity,
-                                                               0),
-						   boost::bind(&ContactManager::onDnsSelfEndorseCertificateUnverified,
-                                                               this,
-                                                               _1,
-                                                               identity)));
-  m_wrapper->sendInterest(interestPtr, closure);
+  Interest interest(interestName);
+  interest.setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
+
+  OnVerified onVerified = boost::bind(&ContactManager::onDnsSelfEndorseCertificateVerified, this, _1, identity);
+  OnVerifyFailed onVerifyFailed = boost::bind(&ContactManager::onDnsSelfEndorseCertificateVerifyFailed, this, _1, identity);
+  TimeoutNotify timeoutNotify = boost::bind(&ContactManager::onDnsSelfEndorseCertificateTimeoutNotify, this, identity);
+
+  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify);
 }
 
 void
+ContactManager::onDnsSelfEndorseCertificateTimeoutNotify(const Name& identity)
+{ emit contactFetchFailed(identity); }
+
+void
+ContactManager::onDnsSelfEndorseCertificateVerified(const shared_ptr<Data>& data, 
+                                                    const Name& identity)
+{
+  try{
+    Data plainData;
+    plainData.wireDecode(data->getContent().buf(), data->getContent().size());
+    EndorseCertificate selfEndorseCertificate(plainData);
+    if(Sha256WithRsaHandler::verifySignature(plainData, selfEndorseCertificate.getPublicKeyInfo()))
+      emit contactFetched (selfEndorseCertificate); 
+    else
+      emit contactFetchFailed (identity);
+  }catch(std::exception& e){
+    _LOG_ERROR("Exception: " << e.what());
+    emit contactFetchFailed (identity);
+  }
+}
+
+void
+ContactManager::onDnsSelfEndorseCertificateVerifyFailed(const shared_ptr<Data>& data, 
+                                                        const Name& identity)
+{ emit contactFetchFailed (identity); }
+
+void
 ContactManager::fetchCollectEndorse(const ndn::Name& identity)
 {
   Name interestName = identity;
   interestName.append("DNS").append("ENDORSED");
 
-  Ptr<Interest> interestPtr = Ptr<Interest>(new Interest(interestName));
-  interestPtr->setChildSelector(Interest::CHILD_RIGHT);
-  interestPtr->setInterestLifetime(1);
-  Ptr<Closure> closure = Ptr<Closure> (new Closure(boost::bind(&ContactManager::onDnsCollectEndorseVerified, 
-                                                               this,
-                                                               _1,
-                                                               identity),
-						   boost::bind(&ContactManager::onDnsCollectEndorseTimeout,
-                                                               this,
-                                                               _1, 
-                                                               _2,
-                                                               identity,
-                                                               0),
-						   boost::bind(&ContactManager::onDnsCollectEndorseUnverified,
-                                                               this,
-                                                               _1,
-                                                               identity)));
-  m_wrapper->sendInterest(interestPtr, closure);
+  Interest interest(interestName);
+  interest.setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
+  interest.setInterestLifetimeMilliseconds(1000);
+
+  OnVerified onVerified = boost::bind(&ContactManager::onDnsCollectEndorseVerified, this, _1, identity);
+  OnVerifyFailed onVerifyFailed = boost::bind(&ContactManager::onDnsCollectEndorseVerifyFailed, this, _1, identity);
+  TimeoutNotify timeoutNotify = boost::bind(&ContactManager::onDnsCollectEndorseTimeoutNotify, this, identity);
+
+  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify);
 }
 
 void
+ContactManager::onDnsCollectEndorseTimeoutNotify(const Name& identity)
+{
+  emit collectEndorseFetchFailed (identity);
+}
+
+void
+ContactManager::onDnsCollectEndorseVerified(const shared_ptr<Data>& data, const Name& identity)
+{ emit collectEndorseFetched (*data); }
+
+void
+ContactManager::onDnsCollectEndorseVerifyFailed(const shared_ptr<Data>& data, const Name& identity)
+{ emit collectEndorseFetchFailed (identity); }
+
+
+void
 ContactManager::fetchKey(const ndn::Name& certName)
 {
   Name interestName = certName;
   
-  Ptr<Interest> interestPtr = Ptr<Interest>(new Interest(interestName));
-  interestPtr->setChildSelector(Interest::CHILD_RIGHT);
-  interestPtr->setInterestLifetime(1);
-  Ptr<Closure> closure = Ptr<Closure> (new Closure(boost::bind(&ContactManager::onKeyVerified, 
-                                                               this,
-                                                               _1,
-                                                               certName),
-						   boost::bind(&ContactManager::onKeyTimeout,
-                                                               this,
-                                                               _1, 
-                                                               _2,
-                                                               certName,
-                                                               0),
-						   boost::bind(&ContactManager::onKeyUnverified,
-                                                               this,
-                                                               _1,
-                                                               certName)));
-  m_wrapper->sendInterest(interestPtr, closure);
+  Interest interest(interestName);
+  interest.setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
+  interest.setInterestLifetimeMilliseconds(1000);
+
+  OnVerified onVerified = boost::bind(&ContactManager::onKeyVerified, this, _1, certName);
+  OnVerifyFailed onVerifyFailed = boost::bind(&ContactManager::onKeyVerifyFailed, this, _1, certName);
+  TimeoutNotify timeoutNotify = boost::bind(&ContactManager::onKeyTimeoutNotify, this, certName);
+
+  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify);
+}
+
+
+void
+ContactManager::onKeyVerified(const shared_ptr<Data>& data, const Name& identity)
+{
+  IdentityCertificate identityCertificate(*data);
+
+  Profile profile(identityCertificate);
+  ProfileData profileData(profile);
+
+  Name certificateName = m_identityManager->getDefaultCertificateName();
+  m_identityManager->signByCertificate(profileData, certificateName);
+
+  try{
+    EndorseCertificate endorseCertificate(identityCertificate, profileData);
+    m_identityManager->signByCertificate(endorseCertificate, certificateName);
+    emit contactKeyFetched (endorseCertificate); 
+  }catch(std::exception& e){
+    _LOG_ERROR("Exception: " << e.what());
+    return;
+  }
+}
+
+void
+ContactManager::onKeyVerifyFailed(const shared_ptr<Data>& data, const Name& identity)
+{ 
+  _LOG_DEBUG("Key cannot be verified!");
+  emit contactKeyFetchFailed (identity); 
+}
+
+void
+ContactManager::onKeyTimeoutNotify(const Name& identity)
+{ 
+  _LOG_DEBUG("Key timeout!");
+  emit contactKeyFetchFailed(identity); 
 }
 
 void
@@ -227,410 +295,372 @@
 {
   Name interestName = certName;
   
-  Ptr<Interest> interestPtr = Ptr<Interest>(new Interest(interestName));
-  interestPtr->setChildSelector(Interest::CHILD_RIGHT);
-  interestPtr->setInterestLifetime(1);
-  Ptr<Closure> closure = Ptr<Closure> (new Closure(boost::bind(&ContactManager::onIdCertificateVerified, 
-                                                               this,
-                                                               _1,
-                                                               certName),
-						   boost::bind(&ContactManager::onIdCertificateTimeout,
-                                                               this,
-                                                               _1, 
-                                                               _2,
-                                                               certName,
-                                                               0),
-						   boost::bind(&ContactManager::onIdCertificateUnverified,
-                                                               this,
-                                                               _1,
-                                                               certName)));
-  m_wrapper->sendInterest(interestPtr, closure);
+  Interest interest(interestName);
+  interest.setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
+  interest.setInterestLifetimeMilliseconds(1000);
+
+  OnVerified onVerified = boost::bind(&ContactManager::onIdCertificateVerified, this, _1, certName);
+  OnVerifyFailed onVerifyFailed = boost::bind(&ContactManager::onIdCertificateVerifyFailed, this, _1, certName);
+  TimeoutNotify timeoutNotify = boost::bind(&ContactManager::onIdCertificateTimeoutNotify, this, certName);
+
+  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify);
 }
 
 void
-ContactManager::onDnsCollectEndorseVerified(Ptr<Data> data, const Name& identity)
-{ emit collectEndorseFetched (*data); }
+ContactManager::onIdCertificateTimeoutNotify(const Name& identity)
+{ emit contactCertificateFetchFailed (identity); }
+
 
 void
-ContactManager::onDnsCollectEndorseTimeout(Ptr<Closure> closure, Ptr<Interest> interest, const Name& identity, int retry)
-{ emit collectEndorseFetchFailed (identity); }
-
-void
-ContactManager::onDnsCollectEndorseUnverified(Ptr<Data> data, const Name& identity)
-{ emit collectEndorseFetchFailed (identity); }
-
-void
-ContactManager::onKeyVerified(Ptr<Data> data, const Name& identity)
-{
-  IdentityCertificate identityCertificate(*data);
-
-  Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(Profile(identityCertificate)));
-  
-  Ptr<IdentityManager> identityManager = m_keychain->getIdentityManager();
-  Name certificateName = identityManager->getDefaultCertificateName ();
-  identityManager->signByCertificate(*profileData, certificateName);
-
-  Ptr<EndorseCertificate> endorseCertificate = NULL;
-  try{
-    endorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(identityCertificate, profileData));
-  }catch(exception& e){
-    _LOG_ERROR("Exception: " << e.what());
-    return;
-  }
-
-  identityManager->signByCertificate(*endorseCertificate, certificateName);
-
-  emit contactKeyFetched (*endorseCertificate); 
-}
-
-void
-ContactManager::onKeyUnverified(Ptr<Data> data, const Name& identity)
-{ 
-  _LOG_DEBUG("Key cannot be verified!");
-  emit contactKeyFetchFailed (identity); 
-}
-
-void
-ContactManager::onKeyTimeout(Ptr<Closure> closure, Ptr<Interest> interest, const Name& identity, int retry)
-{ 
-  _LOG_DEBUG("Key timeout!");
-  emit contactKeyFetchFailed(identity); 
-}
-
-void
-ContactManager::onIdCertificateVerified(Ptr<Data> data, const Name& identity)
+ContactManager::onIdCertificateVerified(const shared_ptr<Data>& data, const Name& identity)
 {
   IdentityCertificate identityCertificate(*data);
   emit contactCertificateFetched(identityCertificate);
 }
 
 void
-ContactManager::onIdCertificateUnverified(Ptr<Data> data, const Name& identity)
+ContactManager::onIdCertificateVerifyFailed(const shared_ptr<Data>& data, const Name& identity)
 { emit contactCertificateFetchFailed (identity); }
 
 void
-ContactManager::onIdCertificateTimeout(Ptr<Closure> closure, Ptr<Interest> interest, const Name& identity, int retry)
-{ emit contactCertificateFetchFailed (identity); }
+ContactManager::onTargetData(const shared_ptr<const ndn::Interest>& interest, 
+                             const shared_ptr<Data>& data,
+                             int stepCount,
+                             const OnVerified& onVerified,
+                             const OnVerifyFailed& onVerifyFailed,
+                             const TimeoutNotify& timeoutNotify)
+{
+  shared_ptr<ValidationRequest> nextStep = m_policyManager->checkVerificationPolicy(data, stepCount, onVerified, onVerifyFailed);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       bind(&ContactManager::onCertData, this, _1, _2, nextStep), 
+       bind(&ContactManager::onCertTimeout, this, _1, onVerifyFailed, data, nextStep));
+
+}
+
+void
+ContactManager::onTargetTimeout(const shared_ptr<const ndn::Interest>& interest, 
+                                int retry,
+                                int stepCount,
+                                const OnVerified& onVerified,
+                                const OnVerifyFailed& onVerifyFailed,
+                                const TimeoutNotify& timeoutNotify)
+{
+  if(retry > 0)
+    sendInterest(*interest, onVerified, onVerifyFailed, timeoutNotify, retry-1, stepCount);
+  else
+    {
+      _LOG_DEBUG("Interest: " << interest->getName().toUri() << " eventually times out!");
+      timeoutNotify();
+    }
+}
+
+void
+ContactManager::onCertData(const shared_ptr<const ndn::Interest>& interest, 
+                           const shared_ptr<Data>& cert,
+                           shared_ptr<ValidationRequest> previousStep)
+{
+  shared_ptr<ValidationRequest> nextStep = m_policyManager->checkVerificationPolicy(cert, 
+                                                                                    previousStep->stepCount_, 
+                                                                                    previousStep->onVerified_, 
+                                                                                    previousStep->onVerifyFailed_);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       bind(&ContactManager::onCertData, this, _1, _2, nextStep), 
+       bind(&ContactManager::onCertTimeout, this, _1, previousStep->onVerifyFailed_, cert, nextStep));
+}
+
+void
+ContactManager::onCertTimeout(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(&ContactManager::onCertData,
+                                 this,
+                                 _1,
+                                 _2,
+                                 nextStep),
+                            bind(&ContactManager::onCertTimeout,
+                                 this,
+                                 _1,
+                                 onVerifyFailed,
+                                 data,
+                                 nextStep));
+ else
+   onVerifyFailed(data);
+}
+
+void
+ContactManager::sendInterest(const Interest& interest,
+                             const OnVerified& onVerified,
+                             const OnVerifyFailed& onVerifyFailed,
+                             const TimeoutNotify& timeoutNotify,
+                             int retry /* = 1 */,
+                             int stepCount /* = 0 */)
+{
+  m_face->expressInterest(interest, 
+                          boost::bind(&ContactManager::onTargetData, 
+                                      this,
+                                      _1,
+                                      _2,
+                                      stepCount,
+                                      onVerified, 
+                                      onVerifyFailed,
+                                      timeoutNotify),
+                          boost::bind(&ContactManager::onTargetTimeout,
+                                      this,
+                                      _1,
+                                      retry,
+                                      stepCount,
+                                      onVerified,
+                                      onVerifyFailed,
+                                      timeoutNotify));
+}
 
 void
 ContactManager::updateProfileData(const Name& identity)
 {
   // Get current profile;
-  Ptr<Profile> newProfile = m_contactStorage->getSelfProfile(identity);
-  if(NULL == newProfile)
+  shared_ptr<Profile> newProfile = m_contactStorage->getSelfProfile(identity);
+  if(CHRONOCHAT_NULL_PROFILE_PTR == newProfile)
     return;
-  Ptr<Blob> newProfileBlob = newProfile->toDerBlob();
+
+  shared_ptr<EndorseCertificate> newEndorseCertificate = getSignedSelfEndorseCertificate(identity, *newProfile);
+
+  if(CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR == newEndorseCertificate)
+    return;
 
   // Check if profile exists
-  Ptr<Blob> profileDataBlob = m_contactStorage->getSelfEndorseCertificate(identity);
-  if(NULL != profileDataBlob)
-    {
-      
-      Ptr<EndorseCertificate> oldEndorseCertificate = NULL;
-      try{
-        Ptr<Data> plainData = Data::decodeFromWire(profileDataBlob);
-        oldEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*plainData));
-      }catch(exception& e){
-        _LOG_ERROR("Exception: " << e.what());
-        return;
-      }
-
-      const Blob& oldProfileBlob = oldEndorseCertificate->getProfileData()->content();
-
-      if(oldProfileBlob == *newProfileBlob)
-        return;
-
-      Ptr<EndorseCertificate> newEndorseCertificate = getSignedSelfEndorseCertificate(identity, *newProfile);
-
-      if(NULL == newEndorseCertificate)
-        return;
-
-      m_contactStorage->updateSelfEndorseCertificate(newEndorseCertificate, identity);
-
-      publishSelfEndorseCertificateInDNS(newEndorseCertificate);
-    }
+  Blob profileDataBlob = m_contactStorage->getSelfEndorseCertificate(identity);
+  if(CHRONOCHAT_NULL_BLOB != profileDataBlob)
+    m_contactStorage->updateSelfEndorseCertificate(*newEndorseCertificate, identity);
   else
-    {
-      Ptr<EndorseCertificate> newEndorseCertificate = getSignedSelfEndorseCertificate(identity, *newProfile);
+    m_contactStorage->addSelfEndorseCertificate(*newEndorseCertificate, identity);
 
-      if(NULL == newEndorseCertificate)
-        return;
-
-      m_contactStorage->addSelfEndorseCertificate(newEndorseCertificate, identity);
-
-      publishSelfEndorseCertificateInDNS(newEndorseCertificate);
-    }
+  publishSelfEndorseCertificateInDNS(*newEndorseCertificate);
 }
 
 void
 ContactManager::updateEndorseCertificate(const ndn::Name& identity, const ndn::Name& signerIdentity)
 {
-  Ptr<Blob> oldEndorseCertificateBlob = m_contactStorage->getEndorseCertificate(identity);
-  Ptr<EndorseCertificate> newEndorseCertificate = generateEndorseCertificate(identity, signerIdentity);
-  if(NULL != oldEndorseCertificateBlob)
-    {
-      Ptr<EndorseCertificate> oldEndorseCertificate = NULL;
-      try{
-        Ptr<Data> plainData = Data::decodeFromWire(oldEndorseCertificateBlob);
-        oldEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*plainData));
-      }catch(exception& e){
-        _LOG_ERROR("Exception: " << e.what());
-        return;
-      }
-      const Blob& oldEndorseContent = oldEndorseCertificate->content();
-      const Blob& newEndorseContent = newEndorseCertificate->content();
-      if(oldEndorseContent == newEndorseContent)
-        return;
-    }
+  Blob oldEndorseCertificateBlob = m_contactStorage->getEndorseCertificate(identity);
+  shared_ptr<EndorseCertificate> newEndorseCertificate = generateEndorseCertificate(identity, signerIdentity);
+
+  if(CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR == newEndorseCertificate)
+    return;
+
+  if(CHRONOCHAT_NULL_BLOB != oldEndorseCertificateBlob)
+    m_contactStorage->updateEndorseCertificate(*newEndorseCertificate, identity);
   else
-    {
-      if(NULL == newEndorseCertificate)
-        return;
-    }
-  m_contactStorage->addEndorseCertificate(newEndorseCertificate, identity);
-  publishEndorseCertificateInDNS(newEndorseCertificate, signerIdentity);
+    m_contactStorage->addEndorseCertificate(*newEndorseCertificate, identity);
+ 
+  publishEndorseCertificateInDNS(*newEndorseCertificate, signerIdentity);
 }
 
-Ptr<EndorseCertificate> 
+shared_ptr<EndorseCertificate> 
 ContactManager::generateEndorseCertificate(const Name& identity, const Name& signerIdentity)
 {
-  Ptr<ContactItem> contact = getContact(identity);
-  if(contact == NULL)
-    return NULL;
+  shared_ptr<ContactItem> contact = getContact(identity);
+  if(contact == CHRONOCHAT_NULL_CONTACTITEM_PTR)
+    return CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR;
 
-  Ptr<IdentityManager> identityManager = m_keychain->getIdentityManager();
-  Name signerKeyName = identityManager->getDefaultKeyNameForIdentity(signerIdentity);
-  Name signerCertName = identityManager->getDefaultCertificateNameByIdentity(signerIdentity);
+  Name signerKeyName = m_identityManager->getDefaultKeyNameForIdentity(signerIdentity);
+  Name signerCertName = m_identityManager->getDefaultCertificateNameForIdentity(signerIdentity);
 
-  vector<string> endorseList = m_contactStorage->getEndorseList(identity);
+  vector<string> endorseList;
+  m_contactStorage->getEndorseList(identity, endorseList);
 
-  Ptr<EndorseCertificate> cert = NULL;
+  
   try{
-    cert = Ptr<EndorseCertificate>(new EndorseCertificate(contact->getSelfEndorseCertificate(), signerKeyName, endorseList)); 
-  }catch(exception& e){
+    shared_ptr<EndorseCertificate> cert = make_shared<EndorseCertificate>(contact->getSelfEndorseCertificate(), signerKeyName, endorseList); 
+    m_identityManager->signByCertificate(*cert, signerCertName);
+    return cert;
+  }catch(std::exception& e){
     _LOG_ERROR("Exception: " << e.what());
-    return NULL;
+    return CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR;
   } 
-  identityManager->signByCertificate(*cert, signerCertName);
-
-  return cert;
 }
 
-vector<Ptr<ContactItem> >
-ContactManager::getContactItemList()
-{ return m_contactStorage->getAllContacts(); }
+void
+ContactManager::getContactItemList(vector<shared_ptr<ContactItem> >& contacts)
+{ return m_contactStorage->getAllContacts(contacts); }
 
-Ptr<ContactItem>
+shared_ptr<ContactItem>
 ContactManager::getContact(const ndn::Name& contactNamespace)
 { return m_contactStorage->getContact(contactNamespace); }
 
-Ptr<EndorseCertificate>
+shared_ptr<EndorseCertificate>
 ContactManager::getSignedSelfEndorseCertificate(const Name& identity,
                                                 const Profile& profile)
 {
-  Ptr<IdentityManager> identityManager = m_keychain->getIdentityManager();
-  Name certificateName = identityManager->getDefaultCertificateNameByIdentity(identity);
+  Name certificateName = m_identityManager->getDefaultCertificateNameForIdentity(identity);
   if(0 == certificateName.size())
-    return NULL;
+    return CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR;
 
-  Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(profile));
-  identityManager->signByCertificate(*profileData, certificateName);
+  ProfileData profileData(profile);
+  m_identityManager->signByCertificate(profileData, certificateName);
 
-  Ptr<security::IdentityCertificate> signingCert = identityManager->getCertificate(certificateName);
-  if(NULL == signingCert)
-    return NULL;
+  shared_ptr<IdentityCertificate> signingCert = m_identityManager->getCertificate(certificateName);
+  if(CHRONOCHAT_NULL_IDENTITYCERTIFICATE_PTR == signingCert)
+    return CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR;
 
-  Name signingKeyName = security::IdentityCertificate::certificateNameToPublicKeyName(signingCert->getName(), true);
+  Name signingKeyName = IdentityCertificate::certificateNameToPublicKeyName(signingCert->getName());
 
-  Ptr<security::IdentityCertificate> kskCert;
-  if(signingKeyName.get(-1).toUri().substr(0,4) == string("dsk-"))
+  shared_ptr<IdentityCertificate> kskCert;
+  if(signingKeyName.get(-1).toEscapedString().substr(0,4) == string("dsk-"))
     {
-      Ptr<const signature::Sha256WithRsa> dskCertSig = DynamicCast<const signature::Sha256WithRsa>(signingCert->getSignature());
+      const Sha256WithRsaSignature* dskCertSig = dynamic_cast<const Sha256WithRsaSignature*>(signingCert->getSignature());
       // HACK! KSK certificate should be retrieved from network.
-      Name keyName = security::IdentityCertificate::certificateNameToPublicKeyName(dskCertSig->getKeyLocator().getKeyName());
+      Name keyName = IdentityCertificate::certificateNameToPublicKeyName(dskCertSig->getKeyLocator().getKeyName());
 
-      Name kskCertName = identityManager->getPublicStorage()->getDefaultCertificateNameForKey(keyName);
+      // TODO: check null existing cases.
+      Name kskCertName = m_identityManager->getDefaultCertificateNameForIdentity(keyName.getPrefix(-1));
 
-      kskCert = identityManager->getCertificate(kskCertName);
-
+      kskCert = m_identityManager->getCertificate(kskCertName);
     }
   else
     {
       kskCert = signingCert;
     }
 
-  if(NULL == kskCert)
-    return NULL;
+  if(CHRONOCHAT_NULL_IDENTITYCERTIFICATE_PTR == kskCert)
+    return CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR;
 
   vector<string> endorseList;
   Profile::const_iterator it = profile.begin();
   for(; it != profile.end(); it++)
     endorseList.push_back(it->first);
   
-  Ptr<EndorseCertificate> selfEndorseCertificate = NULL;
   try{
-    selfEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*kskCert,
-                                                                            profileData,
-                                                                            endorseList));
-  }catch(exception& e){
+    shared_ptr<EndorseCertificate> selfEndorseCertificate = make_shared<EndorseCertificate>(*kskCert, profileData, endorseList);
+    m_identityManager->signByCertificate(*selfEndorseCertificate, kskCert->getName());
+
+    return selfEndorseCertificate;
+  }catch(std::exception& e){
     _LOG_ERROR("Exception: " << e.what());
-    return NULL;
+    return CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR;
   } 
-
-  identityManager->signByCertificate(*selfEndorseCertificate, kskCert->getName());
-
-  return selfEndorseCertificate;
 }
 
 
 void
-ContactManager::onDnsSelfEndorseCertificateVerified(Ptr<Data> data, const Name& identity)
+ContactManager::publishSelfEndorseCertificateInDNS(const EndorseCertificate& selfEndorseCertificate)
 {
-  Ptr<Blob> dataContentBlob = Ptr<Blob>(new Blob(data->content().buf(), data->content().size()));
+  Data data;
 
-  Ptr<Data> plainData = NULL;
-  Ptr<EndorseCertificate> selfEndorseCertificate = NULL;
-  try{
-    plainData = Data::decodeFromWire(dataContentBlob);
-    selfEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(*plainData));
-  }catch(exception& e){
-    _LOG_ERROR("Exception: " << e.what());
-    return;
-  }
-
-  const security::Publickey& ksk = selfEndorseCertificate->getPublicKeyInfo();
-
-  if(security::PolicyManager::verifySignature(*plainData, ksk))
-    emit contactFetched (*selfEndorseCertificate); 
-  else
-    emit contactFetchFailed (identity);
-}
-
-void
-ContactManager::onDnsSelfEndorseCertificateUnverified(Ptr<Data> data, const Name& identity)
-{ emit contactFetchFailed (identity); }
-
-void
-ContactManager::onDnsSelfEndorseCertificateTimeout(Ptr<Closure> closure, Ptr<Interest> interest, const Name& identity, int retry)
-{ emit contactFetchFailed(identity); }
-
-void
-ContactManager::publishSelfEndorseCertificateInDNS(Ptr<EndorseCertificate> selfEndorseCertificate)
-{
-  Ptr<Data> data = Ptr<Data>::Create();
-
-  Name keyName = selfEndorseCertificate->getPublicKeyName();
+  Name keyName = selfEndorseCertificate.getPublicKeyName();
   Name identity = keyName.getSubName(0, keyName.size()-1);
 
+  time_t nowSeconds = time(NULL);
+  struct tm current = *gmtime(&nowSeconds);
+  MillisecondsSince1970 version = timegm(&current) * 1000.0;
 
   Name dnsName = identity;
-  dnsName.append("DNS").append("PROFILE").appendVersion();
+  dnsName.append("DNS").append("PROFILE").appendVersion(version);
+  data.setName(dnsName);
+
+  data.setContent(selfEndorseCertificate.wireEncode());
+
+  Name signCertName = m_identityManager->getDefaultCertificateNameForIdentity(identity);
+  m_identityManager->signByCertificate(data, signCertName);
+
+  m_dnsStorage->updateDnsSelfProfileData(data, identity);
   
-  data->setName(dnsName);
-  Ptr<Blob> blob = selfEndorseCertificate->encodeToWire();
-
-  Content content(blob->buf(), blob->size());
-  data->setContent(content);
-
-  m_keychain->signByIdentity(*data, identity);
-
-  m_dnsStorage->updateDnsSelfProfileData(*data, identity);
-  
-  Ptr<Blob> dnsBlob = data->encodeToWire();
-
-  m_wrapper->putToNdnd(*dnsBlob);
+   m_transport->send(*data.wireEncode());
 }
 
 void
-ContactManager::publishEndorseCertificateInDNS(Ptr<EndorseCertificate> endorseCertificate, const Name& signerIdentity)
+ContactManager::publishEndorseCertificateInDNS(const EndorseCertificate& endorseCertificate, const Name& signerIdentity)
 {
-  Ptr<Data> data = Ptr<Data>::Create();
+  Data data;
 
-  Name keyName = endorseCertificate->getPublicKeyName();
+  Name keyName = endorseCertificate.getPublicKeyName();
   Name endorsee = keyName.getSubName(0, keyName.size()-1);
 
+  time_t nowSeconds = time(NULL);
+  struct tm current = *gmtime(&nowSeconds);
+  MillisecondsSince1970 version = timegm(&current) * 1000.0;
 
   Name dnsName = signerIdentity;
-  dnsName.append("DNS").append(endorsee).append("ENDORSEE").appendVersion();
-  
-  data->setName(dnsName);
-  Ptr<Blob> blob = endorseCertificate->encodeToWire();
+  dnsName.append("DNS").append(endorsee).append("ENDORSEE").appendVersion(version);
+  data.setName(dnsName);
 
-  Content content(blob->buf(), blob->size());
-  data->setContent(content);
+  data.setContent(endorseCertificate.wireEncode());
 
-  Name signCertName = m_keychain->getIdentityManager()->getDefaultCertificateNameByIdentity(signerIdentity);
-  m_keychain->getIdentityManager()->signByCertificate(*data, signCertName);
+  Name signCertName = m_identityManager->getDefaultCertificateNameForIdentity(signerIdentity);
+  m_identityManager->signByCertificate(data, signCertName);
 
-  m_dnsStorage->updateDnsEndorseOthers(*data, signerIdentity, endorsee);
-  
-  Ptr<Blob> dnsBlob = data->encodeToWire();
+  m_dnsStorage->updateDnsEndorseOthers(data, signerIdentity, endorsee);
 
-  m_wrapper->putToNdnd(*dnsBlob);
+  m_transport->send(*data.wireEncode());
 }
 
 void
 ContactManager::publishEndorsedDataInDns(const Name& identity)
 {
-  Ptr<Data> data = Ptr<Data>::Create();
+  Data data;
+
+  time_t nowSeconds = time(NULL);
+  struct tm current = *gmtime(&nowSeconds);
+  MillisecondsSince1970 version = timegm(&current) * 1000.0;
 
   Name dnsName = identity;
-  dnsName.append("DNS").append("ENDORSED").appendVersion();
-  data->setName(dnsName);
+  dnsName.append("DNS").append("ENDORSED").appendVersion(version);
+  data.setName(dnsName);
   
-  Ptr<vector<Blob> > collectEndorseList = m_contactStorage->getCollectEndorseList(identity);
+  vector<Blob> collectEndorseList;
+  m_contactStorage->getCollectEndorseList(identity, collectEndorseList);
+  
+  Chronos::EndorseCollection endorseCollection;
 
-  Ptr<der::DerSequence> root = Ptr<der::DerSequence>::Create();
-
-  vector<Blob>::const_iterator it = collectEndorseList->begin();
-  for(; it != collectEndorseList->end(); it++)
+  vector<Blob>::const_iterator it = collectEndorseList.begin();
+  for(; it != collectEndorseList.end(); it++)
     {
-      Ptr<der::DerOctetString> entry = Ptr<der::DerOctetString>(new der::DerOctetString(*it));
-      root->addChild(entry);
+      string entryStr((const char*)it->buf(), it->size());
+      endorseCollection.add_endorsement()->set_blob(entryStr);
     }
-  
-  blob_stream blobStream;
-  OutputIterator & start = reinterpret_cast<OutputIterator &> (blobStream);
-  root->encode(start);
 
-  Content content(blobStream.buf()->buf(), blobStream.buf()->size());
-  data->setContent(content);
-  
-  Name signCertName = m_keychain->getIdentityManager()->getDefaultCertificateNameByIdentity(identity);
-  m_keychain->getIdentityManager()->signByCertificate(*data, signCertName);
+  string encoded;
+  endorseCollection.SerializeToString(&encoded);
 
-  m_dnsStorage->updateDnsOthersEndorse(*data, identity);
+  data.setContent((const uint8_t*)encoded.c_str(), encoded.size());
   
-  Ptr<Blob> dnsBlob = data->encodeToWire();
+  Name signCertName = m_identityManager->getDefaultCertificateNameForIdentity(identity);
+  m_identityManager->signByCertificate(data, signCertName);
 
-  m_wrapper->putToNdnd(*dnsBlob);
+  m_dnsStorage->updateDnsOthersEndorse(data, identity);
+
+  m_transport->send(*data.wireEncode());
 }
 
 void
 ContactManager::addContact(const IdentityCertificate& identityCertificate, const Profile& profile)
 {
-  Ptr<ProfileData> profileData = Ptr<ProfileData>(new ProfileData(profile));
+  ProfileData profileData(profile);
   
-  Ptr<IdentityManager> identityManager = m_keychain->getIdentityManager();
-  Name certificateName = identityManager->getDefaultCertificateNameByIdentity (m_defaultIdentity);
-  identityManager->signByCertificate(*profileData, certificateName);
+  Name certificateName = m_identityManager->getDefaultCertificateNameForIdentity (m_defaultIdentity);
+  m_identityManager->signByCertificate(profileData, certificateName);
 
-  Ptr<EndorseCertificate> endorseCertificate = NULL;
-  try{
-    endorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(identityCertificate, profileData));
-  }catch(exception& e){
-    _LOG_ERROR("Exception: " << e.what());
-    return;
-  }
-
-  identityManager->signByCertificate(*endorseCertificate, certificateName);
-
-  ContactItem contactItem(*endorseCertificate);
 
   try{
+    EndorseCertificate endorseCertificate(identityCertificate, profileData);
+    
+    m_identityManager->signByCertificate(endorseCertificate, certificateName);
+
+    ContactItem contactItem(endorseCertificate);
+
     m_contactStorage->addContact(contactItem);
+
     emit contactAdded(contactItem.getNameSpace());
-  }catch(exception& e){
+
+  }catch(std::exception& e){
     emit warning(e.what());
     _LOG_ERROR("Exception: " << e.what());
     return;
@@ -640,8 +670,8 @@
 void
 ContactManager::removeContact(const ndn::Name& contactNameSpace)
 {
-  Ptr<ContactItem> contact = getContact(contactNameSpace);
-  if(contact == NULL)
+  shared_ptr<ContactItem> contact = getContact(contactNameSpace);
+  if(contact == CHRONOCHAT_NULL_CONTACTITEM_PTR)
     return;
   m_contactStorage->removeContact(contactNameSpace);
   emit contactRemoved(contact->getPublicKeyName());
diff --git a/src/contact-manager.h b/src/contact-manager.h
index a19135f..0c4cc06 100644
--- a/src/contact-manager.h
+++ b/src/contact-manager.h
@@ -18,23 +18,24 @@
 #include "dns-storage.h"
 #include "endorse-certificate.h"
 #include "profile.h"
-#include <ndn.cxx/wrapper/wrapper.h>
+#include <ndn-cpp/face.hpp>
+#include <ndn-cpp/security/policy/validation-request.hpp>
+#include <ndn-cpp-et/policy-manager/simple-policy-manager.hpp>
 #endif
 
+typedef ndn::func_lib::function<void()> TimeoutNotify;
 
 class ContactManager : public QObject
 {
   Q_OBJECT
 
 public:
-  ContactManager(QObject* parent = 0);
+  ContactManager(ndn::ptr_lib::shared_ptr<ndn::IdentityManager> identityManager,
+                 QObject* parent = 0);
 
   ~ContactManager();
 
   void
-  setWrapper();
-
-  void
   fetchSelfEndorseCertificate(const ndn::Name& identity);
 
   void
@@ -52,93 +53,142 @@
   void
   updateEndorseCertificate(const ndn::Name& identity, const ndn::Name& signerIdentity);
 
-  std::vector<ndn::Ptr<ContactItem> >
-  getContactItemList();
+  void
+  getContactItemList(std::vector<ndn::ptr_lib::shared_ptr<ContactItem> >& contacts);
 
-  inline ndn::Ptr<ContactStorage>
+  ndn::ptr_lib::shared_ptr<ContactStorage>
   getContactStorage()
   { return m_contactStorage; }
 
-  ndn::Ptr<ContactItem>
+  ndn::ptr_lib::shared_ptr<ContactItem>
   getContact(const ndn::Name& contactNamespace);
 
-  inline ndn::Ptr<DnsStorage>
+  ndn::ptr_lib::shared_ptr<DnsStorage>
   getDnsStorage()
   { return m_dnsStorage; }
 
-  inline ndn::Name
+  ndn::Name
   getDefaultIdentity()
-  { return m_keychain->getDefaultIdentity(); }
-
-  inline ndn::Ptr<ndn::Wrapper>
-  getWrapper()
-  { return m_wrapper; }
+  { return m_identityManager->getDefaultIdentity(); }
 
   void
   publishEndorsedDataInDns(const ndn::Name& identity);
 
-  inline void
+  void
   setDefaultIdentity(const ndn::Name& identity)
   { m_defaultIdentity = identity; }
 
   void
-  addContact(const ndn::security::IdentityCertificate& idCert, const Profile& profile);
+  addContact(const ndn::IdentityCertificate& idCert, const Profile& profile);
 
   void
   removeContact(const ndn::Name& contactNameSpace);
   
+  ndn::ptr_lib::shared_ptr<ndn::IdentityManager>
+  getIdentityManager()
+  { return m_identityManager; }
 
 private:
-  void
-  setKeychain();
+  void 
+  connectToDaemon();
 
-  ndn::Ptr<EndorseCertificate>
+  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
+  initializeSecurity();
+
+  ndn::ptr_lib::shared_ptr<EndorseCertificate>
   getSignedSelfEndorseCertificate(const ndn::Name& identity, const Profile& profile);
 
-  ndn::Ptr<EndorseCertificate> 
+  ndn::ptr_lib::shared_ptr<EndorseCertificate> 
   generateEndorseCertificate(const ndn::Name& identity, const ndn::Name& signerIdentity);
 
   void
-  publishSelfEndorseCertificateInDNS(ndn::Ptr<EndorseCertificate> selfEndorseCertificate);
+  publishSelfEndorseCertificateInDNS(const EndorseCertificate& selfEndorseCertificate);
 
   void
-  publishEndorseCertificateInDNS(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& signerIdentity);
+  publishEndorseCertificateInDNS(const EndorseCertificate& endorseCertificate, const ndn::Name& signerIdentity);
+
+  void
+  sendInterest(const ndn::Interest& interest,
+               const ndn::OnVerified& onVerified,
+               const ndn::OnVerifyFailed& onVerifyFailed,
+               const TimeoutNotify& timeoutNotify,
+               int retry = 1,
+               int stepCount = 0);
+
+  void
+  onTargetData(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,
+               const TimeoutNotify& timeoutNotify);
+
+  void
+  onTargetTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                  int retry,
+                  int stepCount,
+                  const ndn::OnVerified& onVerified,
+                  const ndn::OnVerifyFailed& onVerifyFailed,
+                  const TimeoutNotify& timeoutNotify);
+
+
+  void
+  onCertData(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
+  onCertTimeout(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
+  onDnsSelfEndorseCertificateTimeoutNotify(const ndn::Name& identity);
 
   void 
-  onDnsSelfEndorseCertificateVerified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity);
+  onDnsSelfEndorseCertificateVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& selfEndorseCertificate, const ndn::Name& identity);
 
   void
-  onDnsSelfEndorseCertificateUnverified(ndn::Ptr<ndn::Data> selfEndorseCertificate, const ndn::Name& identity);
+  onDnsSelfEndorseCertificateVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& selfEndorseCertificate, const ndn::Name& identity);
+ 
 
   void
-  onDnsSelfEndorseCertificateTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry);
+  onDnsCollectEndorseVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity);
 
   void
-  onKeyVerified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity);
+  onDnsCollectEndorseVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity);
 
   void
-  onKeyUnverified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity);
+  onDnsCollectEndorseTimeoutNotify(const ndn::Name& identity);
+
 
   void
-  onKeyTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry);
+  onKeyVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity);
 
   void
-  onDnsCollectEndorseVerified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity);
+  onKeyVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity);
 
   void
-  onDnsCollectEndorseTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry);
+  onKeyTimeoutNotify(const ndn::Name& identity);
+
 
   void
-  onDnsCollectEndorseUnverified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity);
+  onIdCertificateVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity);
 
   void
-  onIdCertificateVerified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity);
+  onIdCertificateVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, const ndn::Name& identity);
 
   void
-  onIdCertificateUnverified(ndn::Ptr<ndn::Data> data, const ndn::Name& identity);
-
-  void
-  onIdCertificateTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest, const ndn::Name& identity, int retry);
+  onIdCertificateTimeoutNotify(const ndn::Name& identity);
   
 
 signals:
@@ -158,7 +208,7 @@
   contactKeyFetchFailed(const ndn::Name& identity);
 
   void 
-  contactCertificateFetched(const ndn::security::IdentityCertificate& identityCertificate);
+  contactCertificateFetched(const ndn::IdentityCertificate& identityCertificate);
   
   void
   contactCertificateFetchFailed(const ndn::Name& identity);
@@ -182,10 +232,12 @@
   
   
 private:
-  ndn::Ptr<ContactStorage> m_contactStorage;
-  ndn::Ptr<DnsStorage> m_dnsStorage;
-  ndn::Ptr<ndn::security::Keychain> m_keychain;
-  ndn::Ptr<ndn::Wrapper> m_wrapper;
+  ndn::ptr_lib::shared_ptr<ContactStorage> m_contactStorage;
+  ndn::ptr_lib::shared_ptr<DnsStorage> m_dnsStorage;
+  ndn::ptr_lib::shared_ptr<ndn::SimplePolicyManager> 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;
   ndn::Name m_defaultIdentity;
 };
 
diff --git a/src/contact-storage.cpp b/src/contact-storage.cpp
index 595dd68..61ed746 100644
--- a/src/contact-storage.cpp
+++ b/src/contact-storage.cpp
@@ -9,14 +9,15 @@
  */
 
 #include "contact-storage.h"
+#include "null-ptrs.h"
 #include "exception.h"
 
 #include <boost/filesystem.hpp>
-#include <ndn.cxx/fields/signature-sha256-with-rsa.h>
 #include "logging.h"
 
 using namespace std;
 using namespace ndn;
+using namespace ndn::ptr_lib;
 namespace fs = boost::filesystem;
 
 INIT_LOGGER ("ContactStorage");
@@ -270,7 +271,7 @@
   if(doesSelfEntryExist(identity, profileType))
     {
       sqlite3_prepare_v2 (m_db, "UPDATE SelfProfile SET profile_value=? WHERE profile_type=? and profile_identity=?", -1, &stmt, 0);
-      sqlite3_bind_text(stmt, 1, profileValue.buf(), profileValue.size(), SQLITE_TRANSIENT);
+      sqlite3_bind_text(stmt, 1, (const char*)profileValue.buf(), profileValue.size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 2, profileType.c_str(), profileType.size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 3, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
     }
@@ -279,17 +280,17 @@
       sqlite3_prepare_v2 (m_db, "INSERT INTO SelfProfile (profile_identity, profile_type, profile_value) values (?, ?, ?)", -1, &stmt, 0);
       sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 2, profileType.c_str(), profileType.size(), SQLITE_TRANSIENT);
-      sqlite3_bind_text(stmt, 3, profileValue.buf(), profileValue.size(), SQLITE_TRANSIENT);
+      sqlite3_bind_text(stmt, 3, (const char*)profileValue.buf(), profileValue.size(), SQLITE_TRANSIENT);
     }
   sqlite3_step (stmt);
   sqlite3_finalize (stmt);
 }
 
-Ptr<Profile>
+shared_ptr<Profile>
 ContactStorage::getSelfProfile(const Name& identity)
 {
   sqlite3_stmt *stmt;
-  Ptr<Profile> profile = Ptr<Profile>(new Profile(identity));
+  shared_ptr<Profile> profile = make_shared<Profile>(identity);
   
   sqlite3_prepare_v2(m_db, "SELECT profile_type, profile_value FROM SelfProfile WHERE profile_identity=?", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
@@ -297,7 +298,7 @@
   while(sqlite3_step (stmt) == SQLITE_ROW)
     {
       string profileType(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
-      Blob profileValue(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1));
+      string profileValue(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1));
 
       profile->setProfileEntry(profileType, profileValue );
     }
@@ -310,7 +311,7 @@
 void 
 ContactStorage::removeContact(const Name& contactNameSpace)
 {
-  Ptr<ContactItem> contact = getContact(contactNameSpace);
+  shared_ptr<ContactItem> contact = getContact(contactNameSpace);
   string identity = contactNameSpace.toUri();
   
   if(contact == NULL)
@@ -353,15 +354,14 @@
 
   sqlite3_bind_text(stmt, 1, contact.getNameSpace().toUri().c_str(),  contact.getNameSpace().toUri().size (), SQLITE_TRANSIENT);
   sqlite3_bind_text(stmt, 2, contact.getAlias().c_str(), contact.getAlias().size(), SQLITE_TRANSIENT);
-  Ptr<Blob> selfCertificateBlob = contact.getSelfEndorseCertificate().encodeToWire();
-  sqlite3_bind_text(stmt, 3, selfCertificateBlob->buf(), selfCertificateBlob->size(), SQLITE_TRANSIENT);
+  Blob selfCertificateBlob = contact.getSelfEndorseCertificate().wireEncode();
+  sqlite3_bind_text(stmt, 3, (const char*)selfCertificateBlob.buf(), selfCertificateBlob.size(), SQLITE_TRANSIENT);
   sqlite3_bind_int(stmt, 4, (isIntroducer ? 1 : 0));
 
   int res = sqlite3_step (stmt);
   sqlite3_finalize (stmt);
 
-  Ptr<ProfileData> profileData = contact.getSelfEndorseCertificate().getProfileData();
-  const Profile&  profile = profileData->getProfile();
+  const Profile&  profile = contact.getSelfEndorseCertificate().getProfileData().getProfile();
   Profile::const_iterator it = profile.begin();
   string identity = contact.getNameSpace().toUri();
   for(; it != profile.end(); it++)
@@ -373,7 +373,7 @@
                           0);
       sqlite3_bind_text(stmt, 1, identity.c_str(),  identity.size (), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 2, it->first.c_str(), it->first.size(), SQLITE_TRANSIENT);
-      sqlite3_bind_text(stmt, 3, it->second.buf(), it->second.size(), SQLITE_TRANSIENT);
+      sqlite3_bind_text(stmt, 3, it->second.c_str(), it->second.size(), SQLITE_TRANSIENT);
       res = sqlite3_step (stmt);
       sqlite3_finalize (stmt);
     }
@@ -445,27 +445,27 @@
   return result;
 }
 
-vector<Ptr<ContactItem> >
-ContactStorage::getAllContacts() const
+void
+ContactStorage::getAllContacts(vector<shared_ptr<ContactItem> >& contacts) const
 {
-  vector<Ptr<ContactItem> > contacts;
-
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "SELECT contact_alias, self_certificate, is_introducer FROM Contact", -1, &stmt, 0);
   
   while( sqlite3_step (stmt) == SQLITE_ROW)
     {
       string alias(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
-      Ptr<Blob> certBlob = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1)));
-      Ptr<Data> certData = Data::decodeFromWire(certBlob);
-      EndorseCertificate endorseCertificate(*certData);
+
+      Data certData;
+      certData.wireDecode(reinterpret_cast<const uint8_t*>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1));
+      EndorseCertificate endorseCertificate(certData);
+
       int isIntroducer = sqlite3_column_int (stmt, 2);
 
-      contacts.push_back(Ptr<ContactItem>(new ContactItem(endorseCertificate, isIntroducer, alias)));      
+      contacts.push_back(make_shared<ContactItem>(endorseCertificate, isIntroducer, alias));      
     }
   sqlite3_finalize (stmt);  
 
-  vector<Ptr<ContactItem> >::iterator it = contacts.begin();
+  vector<shared_ptr<ContactItem> >::iterator it = contacts.begin();
   for(; it != contacts.end(); it++)
     {
       if((*it)->isIntroducer())
@@ -481,11 +481,9 @@
           sqlite3_finalize (stmt);  
         }
     }
-
-  return contacts;
 }
 
-Ptr<ContactItem>
+shared_ptr<ContactItem>
 ContactStorage::getContact(const Name& name)
 {
   sqlite3_stmt *stmt;
@@ -495,14 +493,16 @@
   if( sqlite3_step (stmt) == SQLITE_ROW)
     {
       string alias(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
-      Ptr<Blob> certBlob = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1)));
-      Ptr<Data> certData = Data::decodeFromWire(certBlob);
-      EndorseCertificate endorseCertificate(*certData);
+
+      Data certData;
+      certData.wireDecode(reinterpret_cast<const uint8_t*>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1));
+      EndorseCertificate endorseCertificate(certData);
+
       int isIntroducer = sqlite3_column_int (stmt, 2);
 
       sqlite3_finalize (stmt);
       
-      Ptr<ContactItem> contact = Ptr<ContactItem>(new ContactItem(endorseCertificate, isIntroducer, alias));
+      shared_ptr<ContactItem> contact = make_shared<ContactItem>(endorseCertificate, isIntroducer, alias);
 
       if(contact->isIntroducer())
         {
@@ -519,13 +519,13 @@
 
       return contact;      
     } 
-  return NULL;
+  return CHRONOCHAT_NULL_CONTACTITEM_PTR;
 }
 
-Ptr<Profile>
+shared_ptr<Profile>
 ContactStorage::getSelfProfile(const Name& identity) const
 {  
-  Ptr<Profile> profile = Ptr<Profile>(new Profile(identity));
+  shared_ptr<Profile> profile = make_shared<Profile>(identity);
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "SELECT profile_type, profile_value FROM SelfProfile WHERE profile_identity=?", -1, &stmt, 0);
   sqlite3_bind_text (stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
@@ -533,7 +533,7 @@
   while( sqlite3_step (stmt) == SQLITE_ROW)
     {
       string profileType(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
-      Blob profileValue(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1));
+      string profileValue(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 1)), sqlite3_column_bytes (stmt, 1));
       profile->setProfileEntry(profileType, profileValue);
     }
 
@@ -542,30 +542,33 @@
   return profile;
 }
 
-Ptr<Blob>
+Blob
 ContactStorage::getSelfEndorseCertificate(const Name& identity)
 {
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "SELECT endorse_data FROM SelfEndorse where identity=?", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
 
-  Ptr<Blob> result = NULL;
   if(sqlite3_step (stmt) == SQLITE_ROW)
-    result = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0)));
+    {
+      Blob result(reinterpret_cast<const uint8_t*>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
+      sqlite3_finalize (stmt);
+      return result;
+    }
 
   sqlite3_finalize (stmt);
 
-  return result;
+  return CHRONOCHAT_NULL_BLOB;
 }
 
 void
-ContactStorage::updateSelfEndorseCertificate(Ptr<EndorseCertificate> newEndorseCertificate, const Name& identity)
+ContactStorage::updateSelfEndorseCertificate(const EndorseCertificate& newEndorseCertificate, const Name& identity)
 {
-  Ptr<Blob> newEndorseCertificateBlob = newEndorseCertificate->encodeToWire();
+  Blob newEndorseCertificateBlob = newEndorseCertificate.wireEncode();
 
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "UPDATE SelfEndorse SET endorse_data=? WHERE identity=?", -1, &stmt, 0);
-  sqlite3_bind_text(stmt, 1, newEndorseCertificateBlob->buf(), newEndorseCertificateBlob->size(), SQLITE_TRANSIENT);
+  sqlite3_bind_text(stmt, 1, (const char*)newEndorseCertificateBlob.buf(), newEndorseCertificateBlob.size(), SQLITE_TRANSIENT);
   sqlite3_bind_text(stmt, 2, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
   sqlite3_step(stmt);
   
@@ -573,43 +576,47 @@
 }
 
 void
-ContactStorage::addSelfEndorseCertificate(Ptr<EndorseCertificate> newEndorseCertificate, const Name& identity)
+ContactStorage::addSelfEndorseCertificate(const EndorseCertificate& newEndorseCertificate, const Name& identity)
 {
-  Ptr<Blob> newEndorseCertificateBlob = newEndorseCertificate->encodeToWire();
+  Blob newEndorseCertificateBlob = newEndorseCertificate.wireEncode();
 
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "INSERT INTO SelfEndorse (identity, endorse_data) values (?, ?)", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
-  sqlite3_bind_text(stmt, 2, newEndorseCertificateBlob->buf(), newEndorseCertificateBlob->size(), SQLITE_TRANSIENT);
+  sqlite3_bind_text(stmt, 2, (const char*)newEndorseCertificateBlob.buf(), newEndorseCertificateBlob.size(), SQLITE_TRANSIENT);
   sqlite3_step(stmt);
 
   sqlite3_finalize (stmt);
 }
 
-Ptr<Blob>
-ContactStorage::getEndorseCertificate(const ndn::Name& identity)
+Blob
+ContactStorage::getEndorseCertificate(const Name& identity)
 {
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "SELECT endorse_data FROM ProfileEndorse where identity=?", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
 
-  Ptr<Blob> result = NULL;
+  
   if(sqlite3_step (stmt) == SQLITE_ROW)
-    result = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0)));
+    {
+      Blob result(reinterpret_cast<const uint8_t*>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
+      sqlite3_finalize (stmt);
+      return result;
+    }
 
   sqlite3_finalize (stmt);
-
-  return result;
+  
+  return CHRONOCHAT_NULL_BLOB;
 }
 
 void
-ContactStorage::updateEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity)
+ContactStorage::updateEndorseCertificate(const EndorseCertificate& endorseCertificate, const Name& identity)
 {
-  Ptr<Blob> newEndorseCertificateBlob = endorseCertificate->encodeToWire();
+  Blob newEndorseCertificateBlob = endorseCertificate.wireEncode();
 
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "UPDATE ProfileEndorse SET endorse_data=? WHERE identity=?", -1, &stmt, 0);
-  sqlite3_bind_text(stmt, 1, newEndorseCertificateBlob->buf(), newEndorseCertificateBlob->size(), SQLITE_TRANSIENT);
+  sqlite3_bind_text(stmt, 1, (const char*)newEndorseCertificateBlob.buf(), newEndorseCertificateBlob.size(), SQLITE_TRANSIENT);
   sqlite3_bind_text(stmt, 2, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
   sqlite3_step(stmt);
 
@@ -617,24 +624,22 @@
 }
 
 void
-ContactStorage::addEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity)
+ContactStorage::addEndorseCertificate(const EndorseCertificate& endorseCertificate, const Name& identity)
 {
-  Ptr<Blob> newEndorseCertificateBlob = endorseCertificate->encodeToWire();
+  Blob newEndorseCertificateBlob = endorseCertificate.wireEncode();
 
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "INSERT INTO ProfileEndorse (identity, endorse_data) values (?, ?)", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
-  sqlite3_bind_text(stmt, 2, newEndorseCertificateBlob->buf(), newEndorseCertificateBlob->size(), SQLITE_TRANSIENT);
+  sqlite3_bind_text(stmt, 2, (const char*)newEndorseCertificateBlob.buf(), newEndorseCertificateBlob.size(), SQLITE_TRANSIENT);
   sqlite3_step(stmt);
 
   sqlite3_finalize (stmt);
 }
 
-vector<string>
-ContactStorage::getEndorseList(const Name& identity)
+void
+ContactStorage::getEndorseList(const Name& identity, vector<string>& endorseList)
 {
-  vector<string> endorseList;
-
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "SELECT profile_type FROM ContactProfile WHERE profile_identity=? AND endorse=1 ORDER BY profile_type", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size(), SQLITE_TRANSIENT);
@@ -645,8 +650,6 @@
       endorseList.push_back(profileType);      
     }
   sqlite3_finalize (stmt);  
-  
-  return endorseList;
 }
 
 void
@@ -680,8 +683,8 @@
       sqlite3_bind_text(stmt, 1, endorserName.toUri().c_str(), endorserName.toUri().size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 2, endorseeName.toUri().c_str(), endorseeName.toUri().size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 3, getCertName.toUri().c_str(), getCertName.toUri().size(), SQLITE_TRANSIENT);
-      Ptr<Blob> blob = endorseCertificate.encodeToWire();
-      sqlite3_bind_text(stmt, 4, blob->buf(), blob->size(), SQLITE_TRANSIENT);
+      Blob blob = endorseCertificate.wireEncode();
+      sqlite3_bind_text(stmt, 4, (const char*)blob.buf(), blob.size(), SQLITE_TRANSIENT);
       int res = sqlite3_step (stmt);
       sqlite3_finalize (stmt); 
       return;
@@ -690,8 +693,8 @@
     {
       sqlite3_prepare_v2 (m_db, "UPDATE CollectEndorse SET endorse_name=?, endorse_data=? WHERE endorser=? AND endorsee=?", -1, &stmt, 0);
       sqlite3_bind_text(stmt, 1, getCertName.toUri().c_str(), getCertName.toUri().size(), SQLITE_TRANSIENT);
-      Ptr<Blob> blob = endorseCertificate.encodeToWire();
-      sqlite3_bind_text(stmt, 2, blob->buf(), blob->size(), SQLITE_TRANSIENT);
+      Blob blob = endorseCertificate.wireEncode();
+      sqlite3_bind_text(stmt, 2, (const char*)blob.buf(), blob.size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 3, endorserName.toUri().c_str(), endorserName.toUri().size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 4, endorseeName.toUri().c_str(), endorseeName.toUri().size(), SQLITE_TRANSIENT);
       int res = sqlite3_step (stmt);
@@ -700,22 +703,18 @@
     }
 }
 
-Ptr<vector<Blob> >
-ContactStorage::getCollectEndorseList(const Name& name)
+void
+ContactStorage::getCollectEndorseList(const Name& name, vector<Blob>& endorseList)
 {
-  Ptr<vector<Blob> > collectEndorseList = Ptr<vector<Blob> >::Create();
-
   sqlite3_stmt *stmt;
   sqlite3_prepare_v2 (m_db, "SELECT endorse_data FROM CollectEndorse WHERE endorsee=?", -1, &stmt, 0);
   sqlite3_bind_text(stmt, 1, name.toUri().c_str(), name.toUri().size(), SQLITE_TRANSIENT);
 
   while(sqlite3_step (stmt) == SQLITE_ROW)
     {
-      Blob blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
-      collectEndorseList->push_back(blob);
+      Blob blob(reinterpret_cast<const uint8_t*>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
+      endorseList.push_back(blob);
     }
 
   sqlite3_finalize (stmt);
-
-  return collectEndorseList;
 }
diff --git a/src/contact-storage.h b/src/contact-storage.h
index 4887dbf..8b7bc6e 100644
--- a/src/contact-storage.h
+++ b/src/contact-storage.h
@@ -14,8 +14,7 @@
 #include <sqlite3.h>
 #include "contact-item.h"
 #include "endorse-certificate.h"
-#include <ndn.cxx/security/identity/identity-manager.h>
-#include <ndn.cxx/fields/signature-sha256-with-rsa.h>
+#include <ndn-cpp/security/identity/identity-manager.hpp>
 
 
 class ContactStorage
@@ -30,7 +29,7 @@
   void
   setSelfProfileEntry(const ndn::Name& identity, const std::string& profileType, const ndn::Blob& profileValue);
 
-  ndn::Ptr<Profile>
+  ndn::ptr_lib::shared_ptr<Profile>
   getSelfProfile(const ndn::Name& identity);
 
   void
@@ -45,47 +44,47 @@
   void 
   updateAlias(const ndn::Name& identity, std::string alias);
 
-  std::vector<ndn::Ptr<ContactItem> >
-  getAllContacts() const;
+  void
+  getAllContacts(std::vector<ndn::ptr_lib::shared_ptr<ContactItem> >& contacts) const;
 
-  ndn::Ptr<ContactItem>
+  ndn::ptr_lib::shared_ptr<ContactItem>
   getContact(const ndn::Name& name);
     
-  ndn::Ptr<Profile>
+  ndn::ptr_lib::shared_ptr<Profile>
   getSelfProfile(const ndn::Name& identity) const;
 
 
   //SelfEndorse
-  ndn::Ptr<ndn::Blob>
+  ndn::Blob
   getSelfEndorseCertificate(const ndn::Name& identity);
 
   void
-  updateSelfEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity);
+  updateSelfEndorseCertificate(const EndorseCertificate& endorseCertificate, const ndn::Name& identity);
 
   void
-  addSelfEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity);
+  addSelfEndorseCertificate(const EndorseCertificate& endorseCertificate, const ndn::Name& identity);
 
 
   //ProfileEndorse
-  ndn::Ptr<ndn::Blob>
+  ndn::Blob
   getEndorseCertificate(const ndn::Name& identity);
 
   void
-  updateEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity);
+  updateEndorseCertificate(const EndorseCertificate& endorseCertificate, const ndn::Name& identity);
 
   void
-  addEndorseCertificate(ndn::Ptr<EndorseCertificate> endorseCertificate, const ndn::Name& identity);
+  addEndorseCertificate(const EndorseCertificate& endorseCertificate, const ndn::Name& identity);
 
-  std::vector<std::string>
-  getEndorseList(const ndn::Name& identity);
+  void
+  getEndorseList(const ndn::Name& identity, std::vector<std::string>& endorseList);
 
   
   //CollectEndorse
   void
   updateCollectEndorse(const EndorseCertificate& endorseCertificate);
 
-  ndn::Ptr<std::vector<ndn::Blob> >
-  getCollectEndorseList(const ndn::Name& name);
+  void
+  getCollectEndorseList(const ndn::Name& name, std::vector<ndn::Blob>& endorseList);
   
 
 private:
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index e9fafaa..f3ad618 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -21,25 +21,27 @@
 #include <QtSql/QSqlError>
 
 #ifndef Q_MOC_RUN
-#include <ndn.cxx/security/keychain.h>
-#include <ndn.cxx/security/identity/identity-manager.h>
-#include <ndn.cxx/common.h>
+#include <ndn-cpp/security/identity/osx-private-key-storage.hpp>
+#include <ndn-cpp/security/identity/basic-identity-storage.hpp>
+#include <ndn-cpp/security/signature/sha256-with-rsa-handler.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/random/random_device.hpp>
 #include <boost/random/uniform_int_distribution.hpp>
 #include "panel-policy-manager.h"
+#include "null-ptrs.h"
 #include "logging.h"
 #include "exception.h"
 #endif
 
 namespace fs = boost::filesystem;
 using namespace ndn;
+using namespace ndn::ptr_lib;
 
 using namespace std;
 
 INIT_LOGGER("ContactPanel");
 
-Q_DECLARE_METATYPE(ndn::security::IdentityCertificate)
+Q_DECLARE_METATYPE(ndn::IdentityCertificate)
 Q_DECLARE_METATYPE(ChronosInvitation)
 
 ContactPanel::ContactPanel(QWidget *parent) 
@@ -50,35 +52,38 @@
   , m_startChatDialog(new StartChatDialog)
   , m_invitationDialog(new InvitationDialog)
   , m_settingDialog(new SettingDialog)
+  , m_policyManager(new PanelPolicyManager())
 {
-  qRegisterMetaType<ndn::security::IdentityCertificate>("IdentityCertificate");
+  qRegisterMetaType<IdentityCertificate>("IdentityCertificate");
   qRegisterMetaType<ChronosInvitation>("ChronosInvitation");
   
   createAction();
 
-  m_contactManager = Ptr<ContactManager>::Create();
+  shared_ptr<BasicIdentityStorage> publicStorage = make_shared<BasicIdentityStorage>();
+  shared_ptr<OSXPrivateKeyStorage> privateStorage = make_shared<OSXPrivateKeyStorage>();
+  m_identityManager = make_shared<IdentityManager>(publicStorage, privateStorage);
+
+  m_contactManager = make_shared<ContactManager>(m_identityManager);
 
   connect(&*m_contactManager, SIGNAL(noNdnConnection(const QString&)),
           this, SLOT(showError(const QString&)));
-
-  m_contactManager->setWrapper();
   
   openDB();    
 
   refreshContactList();
 
-  setKeychain();
+  loadTrustAnchor();
 
-  m_defaultIdentity = m_keychain->getDefaultIdentity();
+  m_defaultIdentity = m_identityManager->getDefaultIdentity();
   if(m_defaultIdentity.size() == 0)
     showError(QString::fromStdString("certificate of ") + QString::fromStdString(m_defaultIdentity.toUri()) + " is missing!\nHave you installed the certificate?");
-  Name defaultCertName = m_keychain->getIdentityManager()->getDefaultCertificateNameByIdentity(m_defaultIdentity);
+  Name defaultCertName = m_identityManager->getDefaultCertificateNameForIdentity(m_defaultIdentity);
   if(defaultCertName.size() == 0)
     showError(QString::fromStdString("certificate of ") + QString::fromStdString(m_defaultIdentity.toUri()) + " is missing!\nHave you installed the certificate?");
 
 
   m_contactManager->setDefaultIdentity(m_defaultIdentity);
-  m_nickName = m_defaultIdentity.get(-1).toUri();
+  m_nickName = m_defaultIdentity.get(-1).toEscapedString();
   m_settingDialog->setIdentity(m_defaultIdentity.toUri(), m_nickName);
   
 
@@ -91,11 +96,10 @@
  
   ui->setupUi(this);
 
-  try{
-    m_handler = Ptr<Wrapper>(new Wrapper(m_keychain));  
-  }catch(ndn::Error::ndnOperation& e){
-    showError(QString::fromStdString("Cannot conect to ndnd!\n Have you started your ndnd?"));
-  }
+  m_transport = make_shared<TcpTransport>();
+  m_face = make_shared<Face>(m_transport, make_shared<TcpTransport::ConnectionInfo>("localhost"));
+  
+  connectToDaemon();
   
   m_localPrefix = Name("/private/local");
   setLocalPrefix();
@@ -144,8 +148,8 @@
   connect(m_startChatDialog, SIGNAL(chatroomConfirmed(const QString&, const QString&, bool)),
           this, SLOT(startChatroom(const QString&, const QString&, bool)));
 
-  connect(m_invitationDialog, SIGNAL(invitationAccepted(const ChronosInvitation&, const ndn::security::IdentityCertificate&)),
-          this, SLOT(acceptInvitation(const ChronosInvitation&, const ndn::security::IdentityCertificate&)));
+  connect(m_invitationDialog, SIGNAL(invitationAccepted(const ChronosInvitation&, const ndn::IdentityCertificate&)),
+          this, SLOT(acceptInvitation(const ChronosInvitation&, const ndn::IdentityCertificate&)));
   connect(m_invitationDialog, SIGNAL(invitationRejected(const ChronosInvitation&)),
           this, SLOT(rejectInvitation(const ChronosInvitation&)));
   
@@ -200,6 +204,26 @@
 }
 
 void
+ContactPanel::connectToDaemon()
+{
+  //Hack! transport does not connect to daemon unless an interest is expressed.
+  Name name("/ndn");
+  ndn::Interest interest(name);
+  m_face->expressInterest(interest, 
+                          bind(&ContactPanel::onConnectionData, this, _1, _2),
+                          bind(&ContactPanel::onConnectionDataTimeout, this, _1));
+}
+
+void
+ContactPanel::onConnectionData(const shared_ptr<const ndn::Interest>& interest,
+                               const shared_ptr<Data>& data)
+{ _LOG_DEBUG("onConnectionData"); }
+
+void
+ContactPanel::onConnectionDataTimeout(const shared_ptr<const ndn::Interest>& interest)
+{ _LOG_DEBUG("onConnectionDataTimeout"); }
+
+void
 ContactPanel::createAction()
 {
   m_menuInvite = new QAction("&Chat", this);
@@ -222,46 +246,33 @@
 }
 
 void 
-ContactPanel::setKeychain()
+ContactPanel::loadTrustAnchor()
 {
-  m_panelPolicyManager = Ptr<PanelPolicyManager>::Create();
-
-  vector<Ptr<ContactItem> >::const_iterator it = m_contactList.begin();
+  vector<shared_ptr<ContactItem> >::const_iterator it = m_contactList.begin();
   for(; it != m_contactList.end(); it++)
     {
-      m_panelPolicyManager->addTrustAnchor((*it)->getSelfEndorseCertificate());
+      m_policyManager->addTrustAnchor((*it)->getSelfEndorseCertificate());
     }
-
-  m_keychain = Ptr<security::Keychain>(new security::Keychain(Ptr<security::IdentityManager>::Create(), 
-                                                              m_panelPolicyManager, 
-                                                              NULL));
 }
 
 void
 ContactPanel::setLocalPrefix(int retry)
 {
-  Ptr<Interest> interest = Ptr<Interest>(new Interest(Name("/local/ndn/prefix")));
-  interest->setChildSelector(Interest::CHILD_RIGHT);
-  
-  Ptr<Closure> closure = Ptr<Closure>(new Closure(boost::bind(&ContactPanel::onLocalPrefixVerified, 
-                                                              this,
-                                                              _1),
-                                                  boost::bind(&ContactPanel::onLocalPrefixTimeout,
-                                                              this,
-                                                              _1, 
-                                                              _2,
-                                                              10),
-                                                  boost::bind(&ContactPanel::onLocalPrefixVerified,
-                                                              this,
-                                                              _1)));
+  Name interestName("/local/ndn/prefix");
+  Interest interest(interestName);
+  interest.setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
 
-  m_handler->sendInterest(interest, closure);
+  m_face->expressInterest(interest, 
+                          bind(&ContactPanel::onLocalPrefix, this, _1, _2), 
+                          bind(&ContactPanel::onLocalPrefixTimeout, this, _1, 10));
+  
 }
 
 void
-ContactPanel::onLocalPrefixVerified(Ptr<Data> data)
+ContactPanel::onLocalPrefix(const shared_ptr<const Interest>& interest, 
+                            const shared_ptr<Data>& data)
 {
-  string originPrefix(data->content().buf(), data->content().size());
+  string originPrefix((const char*)data->getContent().buf(), data->getContent().size());
   string prefix = QString::fromStdString (originPrefix).trimmed ().toUtf8().constData();
   string randomSuffix = getRandomString();
   m_localPrefix = Name(prefix);
@@ -269,7 +280,8 @@
 }
 
 void
-ContactPanel::onLocalPrefixTimeout(Ptr<Closure> closure, Ptr<Interest> interest, int retry)
+ContactPanel::onLocalPrefixTimeout(const shared_ptr<const Interest>& interest,
+                                   int retry)
 { 
   if(retry > 0)
     {
@@ -287,21 +299,131 @@
   m_inviteListenPrefix = Name("/ndn/broadcast/chronos/invitation");
   m_inviteListenPrefix.append(m_defaultIdentity);
   _LOG_DEBUG("Listening for invitation on prefix: " << m_inviteListenPrefix.toUri());
-  m_handler->setInterestFilter (m_inviteListenPrefix, 
-                                boost::bind(&ContactPanel::onInvitation, 
-                                            this,
-                                            _1));
+  m_invitationListenerId = m_face->registerPrefix(m_inviteListenPrefix, 
+                                                  boost::bind(&ContactPanel::onInvitation, this, _1, _2, _3, _4),
+                                                  boost::bind(&ContactPanel::onInvitationRegisterFailed, this, _1));
 }
 
 void
-ContactPanel::onInvitation(Ptr<Interest> interest)
+ContactPanel::sendInterest(const Interest& interest,
+                           const OnVerified& onVerified,
+                           const OnVerifyFailed& onVerifyFailed,
+                           const TimeoutNotify& timeoutNotify,
+                           int retry /* = 1 */,
+                           int stepCount /* = 0 */)
+{
+  m_face->expressInterest(interest, 
+                          boost::bind(&ContactPanel::onTargetData, 
+                                      this,
+                                      _1,
+                                      _2,
+                                      stepCount,
+                                      onVerified, 
+                                      onVerifyFailed,
+                                      timeoutNotify),
+                          boost::bind(&ContactPanel::onTargetTimeout,
+                                      this,
+                                      _1,
+                                      retry,
+                                      stepCount,
+                                      onVerified,
+                                      onVerifyFailed,
+                                      timeoutNotify));
+}
+
+void
+ContactPanel::onTargetData(const shared_ptr<const ndn::Interest>& interest, 
+                           const shared_ptr<Data>& data,
+                           int stepCount,
+                           const OnVerified& onVerified,
+                           const OnVerifyFailed& onVerifyFailed,
+                           const TimeoutNotify& timeoutNotify)
+{
+  shared_ptr<ValidationRequest> nextStep = m_policyManager->checkVerificationPolicy(data, stepCount, onVerified, onVerifyFailed);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       bind(&ContactPanel::onCertData, this, _1, _2, nextStep), 
+       bind(&ContactPanel::onCertTimeout, this, _1, onVerifyFailed, data, nextStep));
+
+}
+
+void
+ContactPanel::onTargetTimeout(const shared_ptr<const ndn::Interest>& interest, 
+                              int retry,
+                              int stepCount,
+                              const OnVerified& onVerified,
+                              const OnVerifyFailed& onVerifyFailed,
+                              const TimeoutNotify& timeoutNotify)
+{
+  if(retry > 0)
+    sendInterest(*interest, onVerified, onVerifyFailed, timeoutNotify, retry-1, stepCount);
+  else
+    {
+      _LOG_DEBUG("Interest: " << interest->getName().toUri() << " eventually times out!");
+      timeoutNotify();
+    }
+}
+
+void
+ContactPanel::onCertData(const shared_ptr<const ndn::Interest>& interest, 
+                         const shared_ptr<Data>& cert,
+                         shared_ptr<ValidationRequest> previousStep)
+{
+  shared_ptr<ValidationRequest> nextStep = m_policyManager->checkVerificationPolicy(cert, 
+                                                                                    previousStep->stepCount_, 
+                                                                                    previousStep->onVerified_, 
+                                                                                    previousStep->onVerifyFailed_);
+
+  if (nextStep)
+    m_face->expressInterest
+      (*nextStep->interest_, 
+       bind(&ContactPanel::onCertData, this, _1, _2, nextStep), 
+       bind(&ContactPanel::onCertTimeout, this, _1, previousStep->onVerifyFailed_, cert, nextStep));
+}
+
+void
+ContactPanel::onCertTimeout(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(&ContactPanel::onCertData,
+                                 this,
+                                 _1,
+                                 _2,
+                                 nextStep),
+                            bind(&ContactPanel::onCertTimeout,
+                                 this,
+                                 _1,
+                                 onVerifyFailed,
+                                 data,
+                                 nextStep));
+ else
+   onVerifyFailed(data);
+}
+
+void
+ContactPanel::onInvitationRegisterFailed(const shared_ptr<const Name>& prefix)
+{
+  showError(QString::fromStdString("Cannot register invitation listening prefix"));
+}
+
+void
+ContactPanel::onInvitation(const shared_ptr<const Name>& prefix, 
+                           const shared_ptr<const Interest>& interest, 
+                           Transport& transport, 
+                           uint64_t registeredPrefixId)
 {
   _LOG_DEBUG("Receive invitation!" << interest->getName().toUri());
   
-  Ptr<ChronosInvitation> invitation = NULL;
+  shared_ptr<ChronosInvitation> invitation;
   try{
-    invitation = Ptr<ChronosInvitation>(new ChronosInvitation(interest->getName()));
-  }catch(exception& e){
+    invitation = make_shared<ChronosInvitation>(interest->getName());
+  }catch(std::exception& e){
     _LOG_ERROR("Exception: " << e.what());
     return;
   }
@@ -315,14 +437,14 @@
       return;
     }
 
-  Ptr<security::Publickey> keyPtr = m_panelPolicyManager->getTrustedKey(invitation->getInviterCertificateName());
-  if(NULL != keyPtr && security::PolicyManager::verifySignature(invitation->getSignedBlob(), invitation->getSignatureBits(), *keyPtr))
+  shared_ptr<PublicKey> keyPtr = m_policyManager->getTrustedKey(invitation->getInviterCertificateName());
+  if(CHRONOCHAT_NULL_PUBLICKEY_PTR != keyPtr && Sha256WithRsaHandler::verifySignature(invitation->getSignedBlob(), invitation->getSignatureBits(), *keyPtr))
     {
-      Ptr<security::IdentityCertificate> certificate = Ptr<security::IdentityCertificate>::Create();
+      shared_ptr<IdentityCertificate> certificate = make_shared<IdentityCertificate>();
       // hack: incomplete certificate, we don't send it to the wire nor store it anywhere, we only use it to carry information
       certificate->setName(invitation->getInviterCertificateName());
       bool findCert = false;
-      vector<Ptr<ContactItem> >::const_iterator it = m_contactList.begin();
+      vector<shared_ptr<ContactItem> >::const_iterator it = m_contactList.begin();
       for(; it != m_contactList.end(); it++)
         {
           if((*it)->getNameSpace() == invitation->getInviterNameSpace())
@@ -343,51 +465,43 @@
       return;
     }
 
-  Ptr<Interest> newInterest = Ptr<Interest>(new Interest(invitation->getInviterCertificateName()));
-  Ptr<Closure> closure = Ptr<Closure>(new Closure(boost::bind(&ContactPanel::onInvitationCertVerified, 
-                                                              this,
-                                                              _1,
-                                                              invitation),
-                                                  boost::bind(&ContactPanel::onTimeout,
-                                                              this,
-                                                              _1,
-                                                              _2),
-                                                  boost::bind(&ContactPanel::onUnverified,
-                                                              this,
-                                                              _1)));
-  m_handler->sendInterest(newInterest, closure);
+  Interest newInterest(invitation->getInviterCertificateName());
+  OnVerified onVerified = boost::bind(&ContactPanel::onInvitationCertVerified, this, _1, invitation);
+  OnVerifyFailed onVerifyFailed = boost::bind(&ContactPanel::onInvitationCertVerifyFailed, this, _1);
+  TimeoutNotify timeoutNotify = boost::bind(&ContactPanel::onInvitationCertTimeoutNotify, this);
+
+  sendInterest(newInterest, onVerified, onVerifyFailed, timeoutNotify);
 }
 
 void
-ContactPanel::onInvitationCertVerified(Ptr<Data> data, 
-                                       Ptr<ChronosInvitation> invitation)
+ContactPanel::onInvitationCertVerified(const shared_ptr<Data>& data, 
+                                       shared_ptr<ChronosInvitation> invitation)
 {
-  using namespace ndn::security;
-  Ptr<IdentityCertificate> certificate = Ptr<IdentityCertificate>(new IdentityCertificate(*data));
+  shared_ptr<IdentityCertificate> certificate = make_shared<IdentityCertificate>(*data);
   
-  if(PolicyManager::verifySignature(invitation->getSignedBlob(), invitation->getSignatureBits(), certificate->getPublicKeyInfo()))
+  if(Sha256WithRsaHandler::verifySignature(invitation->getSignedBlob(), invitation->getSignatureBits(), certificate->getPublicKeyInfo()))
     {
       Name keyName = certificate->getPublicKeyName();
-      Name inviterNameSpace = keyName.getPrefix(keyName.size() - 1);
+      Name inviterNameSpace = keyName.getPrefix(-1);
       popChatInvitation(invitation, inviterNameSpace, certificate);
     }
 }
 
 void
-ContactPanel::onUnverified(Ptr<Data> data)
-{}
+ContactPanel::onInvitationCertVerifyFailed(const shared_ptr<Data>& data)
+{ _LOG_DEBUG("Cannot verify invitation certificate!"); }
 
 void
-ContactPanel::onTimeout(Ptr<Closure> closure, Ptr<Interest> interest)
-{}
+ContactPanel::onInvitationCertTimeoutNotify()
+{ _LOG_DEBUG("interest for invitation certificate times out eventually!"); }
 
 void
-ContactPanel::popChatInvitation(Ptr<ChronosInvitation> invitation,
+ContactPanel::popChatInvitation(shared_ptr<ChronosInvitation> invitation,
                                 const Name& inviterNameSpace,
-                                Ptr<security::IdentityCertificate> certificate)
+                                shared_ptr<IdentityCertificate> certificate)
 {
   string alias;
-  vector<Ptr<ContactItem> >::iterator it = m_contactList.begin();
+  vector<shared_ptr<ContactItem> >::iterator it = m_contactList.begin();
   for(; it != m_contactList.end(); it++)
     if((*it)->getNameSpace() == inviterNameSpace)
       alias = (*it)->getAlias();
@@ -402,43 +516,33 @@
 void
 ContactPanel::collectEndorsement()
 {
-  m_collectStatus = Ptr<vector<bool> >::Create();
+  m_collectStatus = make_shared<vector<bool> >();
   m_collectStatus->assign(m_contactList.size(), false);
 
-  vector<Ptr<ContactItem> >::iterator it = m_contactList.begin();
+  vector<shared_ptr<ContactItem> >::iterator it = m_contactList.begin();
   int count = 0;
   for(; it != m_contactList.end(); it++, count++)
     {
       Name interestName = (*it)->getNameSpace();
       interestName.append("DNS").append(m_defaultIdentity).append("ENDORSEE");
-      Ptr<Interest> interest = Ptr<Interest>(new Interest(interestName));
-      interest->setChildSelector(Interest::CHILD_RIGHT);
-      interest->setInterestLifetime(1);
-  
-      Ptr<Closure> closure = Ptr<Closure>(new Closure(boost::bind(&ContactPanel::onDnsEndorseeVerified, 
-                                                                  this,
-                                                                  _1,
-                                                                  count),
-                                                      boost::bind(&ContactPanel::onDnsEndorseeTimeout,
-                                                                  this,
-                                                                  _1, 
-                                                                  _2,
-                                                                  count),
-                                                      boost::bind(&ContactPanel::onDnsEndorseeUnverified,
-                                                                  this,
-                                                                  _1,
-                                                                  count)));
+      Interest interest(interestName);
+      interest.setChildSelector(ndn_Interest_CHILD_SELECTOR_RIGHT);
+      interest.setInterestLifetimeMilliseconds(1000);
 
-      m_handler->sendInterest(interest, closure);
+      OnVerified onVerified = boost::bind(&ContactPanel::onDnsEndorseeVerified, this, _1, count);
+      OnVerifyFailed onVerifyFailed = boost::bind(&ContactPanel::onDnsEndorseeVerifyFailed, this, _1, count);
+      TimeoutNotify timeoutNotify = boost::bind(&ContactPanel::onDnsEndorseeTimeoutNotify, this, count);
+  
+      sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify, 0);
     }
 }
 
 void
-ContactPanel::onDnsEndorseeVerified(Ptr<Data> data, int count)
+ContactPanel::onDnsEndorseeVerified(const shared_ptr<Data>& data, int count)
 {
-  Ptr<Blob> contentBlob = Ptr<Blob>(new Blob(data->content().buf(), data->content().size()));
-  Ptr<Data> endorseData = Data::decodeFromWire(contentBlob);
-  EndorseCertificate endorseCertificate(*endorseData);
+  Data endorseData;
+  endorseData.wireDecode(data->getContent().buf(), data->getContent().size());
+  EndorseCertificate endorseCertificate(endorseData);
 
   m_contactManager->getContactStorage()->updateCollectEndorse(endorseCertificate);
 
@@ -446,11 +550,11 @@
 }
 
 void
-ContactPanel::onDnsEndorseeTimeout(Ptr<Closure> closure, Ptr<Interest> interest, int count)
+ContactPanel::onDnsEndorseeTimeoutNotify(int count)
 { updateCollectStatus(count); }
 
 void
-ContactPanel::onDnsEndorseeUnverified(Ptr<Data> data, int count)
+ContactPanel::onDnsEndorseeVerifyFailed(const shared_ptr<Data>& data, int count)
 { updateCollectStatus(count); }
 
 void 
@@ -585,13 +689,7 @@
 { 
   // _LOG_DEBUG(identity.toStdString());
   Name defaultIdentity = Name(identity.toStdString());
-  Name defaultKeyName = m_keychain->getIdentityManager()->getPublicStorage()->getDefaultKeyNameForIdentity(defaultIdentity);
-  if(defaultKeyName.size() == 0)
-    {
-      showWarning(QString::fromStdString("Corresponding key is missing!\nHave you created the key?"));
-      return;
-    }
-  Name defaultCertName = m_keychain->getIdentityManager()->getPublicStorage()->getDefaultCertificateNameForKey(defaultKeyName);
+  Name defaultCertName = m_identityManager->getDefaultCertificateNameForIdentity(defaultIdentity);
   if(defaultCertName.size() == 0)
     {
       showWarning(QString::fromStdString("Corresponding certificate is missing!\nHave you installed the certificate?"));
@@ -600,7 +698,7 @@
   m_defaultIdentity = defaultIdentity;
   m_profileEditor->setCurrentIdentity(m_defaultIdentity);
   m_nickName = nickName.toStdString();
-  m_handler->clearInterestFilter(m_inviteListenPrefix);
+  m_face->removeRegisteredPrefix(m_invitationListenerId);
   m_contactManager->setDefaultIdentity(m_defaultIdentity);
   setInvitationListener();
   collectEndorsement();
@@ -630,7 +728,7 @@
   for(; it != selectedList.end(); it++)
     {
       string alias =  m_contactListModel->data(*it, Qt::DisplayRole).toString().toStdString();
-      vector<Ptr<ContactItem> >::iterator contactIt = m_contactList.begin();
+      vector<shared_ptr<ContactItem> >::iterator contactIt = m_contactList.begin();
       for(; contactIt != m_contactList.end(); contactIt++)
         {
           if((*contactIt)->getAlias() == alias)
@@ -651,19 +749,20 @@
 void
 ContactPanel::addContactIntoPanelPolicy(const Name& contactNameSpace)
 {
-  Ptr<ContactItem> contact = m_contactManager->getContact(contactNameSpace);
-  if(contact != NULL)
-    m_panelPolicyManager->addTrustAnchor(contact->getSelfEndorseCertificate());
+  shared_ptr<ContactItem> contact = m_contactManager->getContact(contactNameSpace);
+  if(contact != CHRONOCHAT_NULL_CONTACTITEM_PTR)
+    m_policyManager->addTrustAnchor(contact->getSelfEndorseCertificate());
 }
 
 void
 ContactPanel::removeContactFromPanelPolicy(const Name& keyName)
-{ m_panelPolicyManager->removeTrustAnchor(keyName); }
+{ m_policyManager->removeTrustAnchor(keyName); }
 
 void
 ContactPanel::refreshContactList()
 {
-  m_contactList = m_contactManager->getContactItemList();
+  m_contactList.clear();
+  m_contactManager->getContactItemList(m_contactList);
   QStringList contactNameList;
   for(int i = 0; i < m_contactList.size(); i++)
     contactNameList << QString::fromStdString(m_contactList[i]->getAlias());
@@ -714,10 +813,10 @@
 void
 ContactPanel::startChatroom(const QString& chatroom, const QString& invitee, bool isIntroducer)
 {
-  Name chatroomName(chatroom.toUtf8().constData());
+  Name chatroomName(chatroom.toStdString());
 
   Name inviteeNamespace(invitee.toStdString());
-  Ptr<ContactItem> inviteeItem = m_contactManager->getContact(inviteeNamespace);
+  shared_ptr<ContactItem> inviteeItem = m_contactManager->getContact(inviteeNamespace);
 
   ChatDialog* chatDialog = new ChatDialog(m_contactManager, chatroomName, m_localPrefix, m_defaultIdentity, m_nickName);
   m_chatDialogs.insert(pair <Name, ChatDialog*> (chatroomName, chatDialog));
@@ -738,9 +837,9 @@
 // For Invitee
 void
 ContactPanel::startChatroom2(const ChronosInvitation& invitation, 
-                             const security::IdentityCertificate& identityCertificate)
+                             const IdentityCertificate& identityCertificate)
 {
-  Ptr<ContactItem> inviterItem = m_contactManager->getContact(invitation.getInviterNameSpace());
+  shared_ptr<ContactItem> inviterItem = m_contactManager->getContact(invitation.getInviterNameSpace());
 
   Name chatroomName("/ndn/broadcast/chronos");
   chatroomName.append(invitation.getChatroom());
@@ -766,18 +865,44 @@
 
 void
 ContactPanel::acceptInvitation(const ChronosInvitation& invitation, 
-                               const security::IdentityCertificate& identityCertificate)
+                               const IdentityCertificate& identityCertificate)
 {
-  string prefix = m_localPrefix.toUri();
-  m_handler->publishDataByIdentity (invitation.getInterestName(), prefix);
+  Data data(invitation.getInterestName());
+  string content = m_localPrefix.toUri();
+  data.setContent((const uint8_t *)&content[0], content.size());
+  data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
+
+  Name certificateName;
+  Name inferredIdentity = m_policyManager->inferSigningIdentity(data.getName());
+
+  if(inferredIdentity.getComponentCount() == 0)
+    certificateName = m_identityManager->getDefaultCertificateName();
+  else
+    certificateName = m_identityManager->getDefaultCertificateNameForIdentity(inferredIdentity);   
+  m_identityManager->signByCertificate(data, certificateName);
+
+  m_transport->send(*data.wireEncode());
+
   startChatroom2(invitation, identityCertificate);
 }
 
 void
 ContactPanel::rejectInvitation(const ChronosInvitation& invitation)
 {
-  string empty("nack");
-  m_handler->publishDataByIdentity (invitation.getInterestName(), empty);
+  Data data(invitation.getInterestName());
+  string content("nack");
+  data.setContent((const uint8_t *)&content[0], content.size());
+  data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
+
+  Name certificateName;
+  Name inferredIdentity = m_policyManager->inferSigningIdentity(data.getName());
+  if(inferredIdentity.getComponentCount() == 0)
+    certificateName = m_identityManager->getDefaultCertificateName();
+  else
+    certificateName = m_identityManager->getDefaultCertificateNameForIdentity(inferredIdentity);   
+  m_identityManager->signByCertificate(data, certificateName);
+
+  m_transport->send(*data.wireEncode());
 }
 
 void
@@ -842,7 +967,7 @@
   QSqlRecord record;
   QSqlField identityField("contact_namespace", QVariant::String);
   record.append(identityField);
-  record.setValue("contact_namespace", QString(m_currentSelectedContact->getNameSpace().toUri().c_str()));
+  record.setValue("contact_namespace", QString::fromStdString(m_currentSelectedContact->getNameSpace().toUri()));
   m_trustScopeModel->insertRow(rowCount);
   m_trustScopeModel->setRecord(rowCount, record);
 }
diff --git a/src/contactpanel.h b/src/contactpanel.h
index b171e54..1c2c9fc 100644
--- a/src/contactpanel.h
+++ b/src/contactpanel.h
@@ -49,6 +49,16 @@
   ~ContactPanel();
 
 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
   createAction();
 
@@ -56,54 +66,93 @@
   openDB();
 
   void
-  setKeychain();
+  loadTrustAnchor();
 
   void
   setLocalPrefix(int retry = 10);
 
   void
-  onLocalPrefixVerified(ndn::Ptr<ndn::Data> data);
+  onLocalPrefix(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
   
   void
-  onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, 
-                       ndn::Ptr<ndn::Interest> interest,
+  onLocalPrefixTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest,
                        int retry);
 
   void
   setInvitationListener();
 
   void
-  onInvitation(ndn::Ptr<ndn::Interest> interest);
+  onInvitation(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 registeredPrefixI);
 
   void
-  onUnverified(ndn::Ptr<ndn::Data> data);
-  
+  onInvitationRegisterFailed(const ndn::ptr_lib::shared_ptr<const ndn::Name>& prefix);
+
   void
-  onTimeout(ndn::Ptr<ndn::Closure> closure, 
-            ndn::Ptr<ndn::Interest> interest);
+  sendInterest(const ndn::Interest& interest,
+               const ndn::OnVerified& onVerified,
+               const ndn::OnVerifyFailed& onVerifyFailed,
+               const TimeoutNotify& timeoutNotify,
+               int retry = 1,
+               int stepCount = 0);
+
+  void
+  onTargetData(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,
+               const TimeoutNotify& timeoutNotify);
+
+  void
+  onTargetTimeout(const ndn::ptr_lib::shared_ptr<const ndn::Interest>& interest, 
+                  int retry,
+                  int stepCount,
+                  const ndn::OnVerified& onVerified,
+                  const ndn::OnVerifyFailed& onVerifyFailed,
+                  const TimeoutNotify& timeoutNotify);
+
+
+  void
+  onCertData(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
+  onCertTimeout(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
-  onInvitationCertVerified(ndn::Ptr<ndn::Data> data,
-                           ndn::Ptr<ChronosInvitation> invitation);
+  onInvitationCertVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, 
+                           ndn::ptr_lib::shared_ptr<ChronosInvitation> invitation);
 
   void
-  popChatInvitation(ndn::Ptr<ChronosInvitation> invitation,
+  onInvitationCertVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data);
+
+  void
+  onInvitationCertTimeoutNotify();
+
+  void
+  popChatInvitation(ndn::ptr_lib::shared_ptr<ChronosInvitation> invitation,
                     const ndn::Name& inviterNameSpace,
-                    ndn::Ptr<ndn::security::IdentityCertificate> certificate);
+                    ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate> certificate);
 
   void
   collectEndorsement();
 
   void
-  onDnsEndorseeVerified(ndn::Ptr<ndn::Data> data, int count);
+  onDnsEndorseeVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, int count);
 
   void
-  onDnsEndorseeTimeout(ndn::Ptr<ndn::Closure> closure, 
-                       ndn::Ptr<ndn::Interest> interest, 
-                       int count);
-  
+  onDnsEndorseeVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, int count);
+
   void
-  onDnsEndorseeUnverified(ndn::Ptr<ndn::Data> data, int count);
+  onDnsEndorseeTimeoutNotify(int count);
 
   void 
   updateCollectStatus(int count);
@@ -170,11 +219,11 @@
 
   void 
   startChatroom2(const ChronosInvitation& invitation, 
-                 const ndn::security::IdentityCertificate& identityCertificate);
+                 const ndn::IdentityCertificate& identityCertificate);
 
   void
   acceptInvitation(const ChronosInvitation& invitation, 
-                   const ndn::security::IdentityCertificate& identityCertificate);
+                   const ndn::IdentityCertificate& identityCertificate);
 
   void
   rejectInvitation(const ChronosInvitation& invitation);
@@ -207,7 +256,7 @@
 private:
   Ui::ContactPanel *ui;
   WarningDialog* m_warningDialog;
-  ndn::Ptr<ContactManager> m_contactManager;
+  ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager;
   QStringListModel* m_contactListModel;
   ProfileEditor* m_profileEditor;
   AddContactPanel* m_addContactPanel;
@@ -216,22 +265,24 @@
   StartChatDialog* m_startChatDialog;
   InvitationDialog* m_invitationDialog;
   SettingDialog* m_settingDialog;
-  std::map<ndn::Name, ChatDialog*> m_chatDialogs;
+  std::map<ndn::Name, ChatDialog*, ndn::Name::BreadthFirstLess> m_chatDialogs;
   QAction* m_menuInvite;
   QAction* m_menuAlias;
-  std::vector<ndn::Ptr<ContactItem> > m_contactList;
-  ndn::Ptr<std::vector<bool> > m_collectStatus;
+  std::vector<ndn::ptr_lib::shared_ptr<ContactItem> > m_contactList;
+  ndn::ptr_lib::shared_ptr<std::vector<bool> > m_collectStatus;
 
-  ndn::Ptr<PanelPolicyManager> m_panelPolicyManager;
-  ndn::Ptr<ndn::security::Keychain> m_keychain;
-  ndn::Ptr<ndn::Wrapper> m_handler;
+  ndn::ptr_lib::shared_ptr<PanelPolicyManager> m_policyManager;
+  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;
+  uint64_t m_invitationListenerId;
 
   ndn::Name m_defaultIdentity;
   std::string m_nickName;
   ndn::Name m_localPrefix;
   ndn::Name m_inviteListenPrefix;
 
-  ndn::Ptr<ContactItem> m_currentSelectedContact;
+  ndn::ptr_lib::shared_ptr<ContactItem> m_currentSelectedContact;
   QSqlTableModel* m_trustScopeModel;
   QSqlTableModel* m_endorseDataModel;
   EndorseComboBoxDelegate* m_endorseComboBoxDelegate;
diff --git a/src/dns-storage.cpp b/src/dns-storage.cpp
index 52a23b2..a5a9588 100644
--- a/src/dns-storage.cpp
+++ b/src/dns-storage.cpp
@@ -9,6 +9,7 @@
  */
 
 #include "dns-storage.h"
+#include "null-ptrs.h"
 #include "exception.h"
 
 #include <boost/filesystem.hpp>
@@ -17,6 +18,7 @@
 
 using namespace std;
 using namespace ndn;
+using namespace ndn::ptr_lib;
 namespace fs = boost::filesystem;
 
 INIT_LOGGER("DnsStorage");
@@ -85,7 +87,7 @@
       sqlite3_bind_text(stmt, 1, identity.c_str(), identity.size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 2, name.c_str(), name.size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 3, type.c_str(), type.size(), SQLITE_TRANSIENT);
-      sqlite3_bind_text(stmt, 4, data.buf(), data.size(), SQLITE_TRANSIENT); 
+      sqlite3_bind_text(stmt, 4, (const char*)data.buf(), data.size(), SQLITE_TRANSIENT); 
       sqlite3_bind_text(stmt, 5, dataName.c_str(), dataName.size(), SQLITE_TRANSIENT);
       sqlite3_step(stmt);
       sqlite3_finalize(stmt);
@@ -94,7 +96,7 @@
     {
       sqlite3_finalize(stmt);
       sqlite3_prepare_v2 (m_db, "UPDATE DnsData SET dns_value=?, data_name=? WHERE dns_identity=? and dns_name=?, dns_type=?", -1, &stmt, 0);
-      sqlite3_bind_text(stmt, 1, data.buf(), data.size(), SQLITE_TRANSIENT);
+      sqlite3_bind_text(stmt, 1, (const char*)data.buf(), data.size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 2, dataName.c_str(), dataName.size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 3, identity.c_str(), identity.size(), SQLITE_TRANSIENT);
       sqlite3_bind_text(stmt, 4, name.c_str(), name.size(), SQLITE_TRANSIENT);
@@ -110,9 +112,9 @@
   string dnsIdentity = identity.toUri();
   string dnsName("N/A");
   string dnsType("PROFILE");
-  Ptr<Blob> dnsValue = data.encodeToWire();
+  Blob dnsValue = data.wireEncode();
 
-  updateDnsData(*dnsValue, dnsIdentity, dnsName, dnsType, data.getName().toUri());
+  updateDnsData(dnsValue, dnsIdentity, dnsName, dnsType, data.getName().toUri());
 }
 
 void
@@ -121,9 +123,9 @@
   string dnsIdentity = identity.toUri();
   string dnsName = endorsee.toUri();
   string dnsType("ENDORSEE");
-  Ptr<Blob> dnsValue = data.encodeToWire();
+  Blob dnsValue = data.wireEncode();
 
-  updateDnsData(*dnsValue, dnsIdentity, dnsName, dnsType, data.getName().toUri());
+  updateDnsData(dnsValue, dnsIdentity, dnsName, dnsType, data.getName().toUri());
 }
   
 void
@@ -132,12 +134,12 @@
   string dnsIdentity = identity.toUri();
   string dnsName("N/A");
   string dnsType("ENDORSED");
-  Ptr<Blob> dnsValue = data.encodeToWire();
+  Blob dnsValue = data.wireEncode();
 
-  updateDnsData(*dnsValue, dnsIdentity, dnsName, dnsType, data.getName().toUri());
+  updateDnsData(dnsValue, dnsIdentity, dnsName, dnsType, data.getName().toUri());
 }
 
-Ptr<Data>
+shared_ptr<Data>
 DnsStorage::getData(const Name& dataName)
 {
   sqlite3_stmt *stmt;
@@ -146,13 +148,12 @@
   
   if(sqlite3_step (stmt) == SQLITE_ROW)
     {
-      Ptr<Blob> dnsDataBlob = Ptr<Blob>(new Blob(reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0)));
-      // boost::iostreams::stream
-      //   <boost::iostreams::array_source> is (dnsDataBlob.buf(), dnsDataBlob.size());
+      shared_ptr<Data> data = make_shared<Data>();
+      data->wireDecode(reinterpret_cast<const uint8_t*>(sqlite3_column_text(stmt, 0)), sqlite3_column_bytes (stmt, 0));
       sqlite3_finalize(stmt);
-      return Data::decodeFromWire(dnsDataBlob);
+      return data;
     }
   sqlite3_finalize(stmt);
 
-  return NULL;
+  return CHRONOCHAT_NULL_DATA_PTR;
 }
diff --git a/src/dns-storage.h b/src/dns-storage.h
index f6c19ce..0c7934b 100644
--- a/src/dns-storage.h
+++ b/src/dns-storage.h
@@ -12,7 +12,7 @@
 #define LINKNDN_DNS_STORAGE_H
 
 #include <sqlite3.h>
-#include <ndn.cxx/data.h>
+#include <ndn-cpp/data.hpp>
 
 class DnsStorage
 {
@@ -30,7 +30,7 @@
   void
   updateDnsOthersEndorse(const ndn::Data& data, const ndn::Name& identity);
 
-  ndn::Ptr<ndn::Data>
+  ndn::ptr_lib::shared_ptr<ndn::Data>
   getData(const ndn::Name& name);
 
 private:
diff --git a/src/endorse-certificate.cpp b/src/endorse-certificate.cpp
index 80ff165..8101eb3 100644
--- a/src/endorse-certificate.cpp
+++ b/src/endorse-certificate.cpp
@@ -10,93 +10,91 @@
 
 #include "endorse-certificate.h"
 #include "exception.h"
-#include <ndn.cxx/helpers/der/der.h>
-#include <ndn.cxx/helpers/der/visitor/simple-visitor.h>
-#include <ndn.cxx/security/certificate/certificate-subdescrpt.h>
+#include "endorse-extension.pb.h"
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/iostreams/stream.hpp>
 #include "logging.h"
 
 using namespace std;
 using namespace ndn;
-using namespace ndn::security;
+using namespace ndn::ptr_lib;
+using namespace boost::posix_time;
 
 INIT_LOGGER("EndorseCertificate");
 
 ProfileExtension::ProfileExtension(const ProfileData & profileData)
-  : CertificateExtension("1.3.6.1.5.32.2.1", true, *profileData.encodeToWire())
+  : CertificateExtension("1.3.6.1.5.32.2.1", true, profileData.wireEncode())
 {}
 
 ProfileExtension::ProfileExtension(const ProfileExtension& profileExtension)
-  : CertificateExtension("1.3.6.1.5.32.2.1", true, profileExtension.m_extnValue)
+  : CertificateExtension("1.3.6.1.5.32.2.1", true, profileExtension.extensionValue_)
 {}
 
 ProfileExtension::ProfileExtension(const CertificateExtension& extension)
-  : CertificateExtension(extension.getOID(), extension.getCritical(), extension.getValue())
+  : CertificateExtension(extension.getOid(), extension.getIsCritical(), extension.getValue())
 {
-  if(m_extnID != OID("1.3.6.1.5.32.2.1"))
+  if(extensionId_ != OID("1.3.6.1.5.32.2.1"))
     throw LnException("Wrong ProfileExtension Number!");
 }
 
-Ptr<ProfileData>
+shared_ptr<ProfileData>
 ProfileExtension::getProfileData()
 {
-  Ptr<Blob> dataBlob = Ptr<Blob>(new Blob(m_extnValue.buf (), m_extnValue.size ()));
-  return Ptr<ProfileData>(new ProfileData(*Data::decodeFromWire(dataBlob)));
+  Data data;
+  data.wireDecode(extensionValue_.buf(), extensionValue_.size());
+  return make_shared<ProfileData>(data);
 }
 
-EndorseExtension::EndorseExtension(const vector<string>& endorsedList)
-  : CertificateExtension("1.3.6.1.5.32.2.2", true, *EndorseExtension::prepareValue(endorsedList))
+EndorseExtension::EndorseExtension(const vector<string>& endorseList)
+  : CertificateExtension("1.3.6.1.5.32.2.2", true, EndorseExtension::encodeEndorseList(endorseList))
 {}
 
 EndorseExtension::EndorseExtension(const EndorseExtension& endorseExtension)
-  : CertificateExtension("1.3.6.1.5.32.2.2", true, endorseExtension.m_extnValue)
+  : CertificateExtension("1.3.6.1.5.32.2.2", true, endorseExtension.extensionValue_)
 {}
 
 EndorseExtension::EndorseExtension(const CertificateExtension& extension)
-  : CertificateExtension(extension.getOID(), extension.getCritical(), extension.getValue())
+  : CertificateExtension(extension.getOid(), extension.getIsCritical(), extension.getValue())
 {
-  if(m_extnID != OID("1.3.6.1.5.32.2.2"))
+  if(extensionId_ != OID("1.3.6.1.5.32.2.2"))
     throw LnException("Wrong EndorseExtension Number!");
 }
 
 vector<string>
-EndorseExtension::getEndorsedList()
+EndorseExtension::getEndorseList()
 {
-  vector<string> endorsedList;
+  Chronos::EndorseExtensionMsg endorseExtension;
 
   boost::iostreams::stream
-    <boost::iostreams::array_source> is (m_extnValue.buf(), m_extnValue.size());
+    <boost::iostreams::array_source> is ((const char*)extensionValue_.buf(), extensionValue_.size());
+
+  endorseExtension.ParseFromIstream(&is);
+
+  vector<string> endorseList;
+
+  for(int i = 0; i < endorseExtension.endorseentry_size(); i ++)
+    endorseList.push_back(endorseExtension.endorseentry(i).name());
   
-  Ptr<der::DerSequence> root = DynamicCast<der::DerSequence>(der::DerNode::parse(reinterpret_cast<InputIterator &>(is)));
-  const der::DerNodePtrList & children = root->getChildren();
-  der::SimpleVisitor simpleVisitor;
-
-  for(int i = 0; i < children.size(); i++)
-      endorsedList.push_back(boost::any_cast<string>(children[i]->accept(simpleVisitor)));
-
-  return endorsedList;
+  return endorseList;
 }
 
-Ptr<Blob>
-EndorseExtension::prepareValue(const vector<string>& endorsedList)
+Blob
+EndorseExtension::encodeEndorseList(const vector<string>& endorseList)
 {
-  Ptr<der::DerSequence> root = Ptr<der::DerSequence>::Create();
+  Chronos::EndorseExtensionMsg endorseExtension;
   
-  vector<string>::const_iterator it = endorsedList.begin();
-  for(; it != endorsedList.end(); it++)
-    {
-      Ptr<der::DerPrintableString> entry = Ptr<der::DerPrintableString>(new der::DerPrintableString(*it));
-      root->addChild(entry);
-    }
-  
-  blob_stream blobStream;
-  OutputIterator & start = reinterpret_cast<OutputIterator &> (blobStream);
-  root->encode(start);
+  vector<string>::const_iterator it = endorseList.begin();
+  for(; it != endorseList.end(); it++)
+    endorseExtension.add_endorseentry()->set_name(*it);
 
-  return blobStream.buf ();
+  string encoded;
+  endorseExtension.SerializeToString(&encoded);
+  
+  return Blob((const uint8_t*)encoded.c_str(), encoded.size());
 }
 
 EndorseCertificate::EndorseCertificate(const IdentityCertificate& kskCertificate,
-                                       Ptr<ProfileData> profileData,
+                                       const ProfileData& profileData,
                                        const vector<string>& endorseList)
   : Certificate()
   , m_keyName(kskCertificate.getPublicKeyName())
@@ -104,15 +102,18 @@
   , m_profileData(profileData)
   , m_endorseList(endorseList)
 {
+  time_duration now = microsec_clock::universal_time () - ptime(boost::gregorian::date (1970, boost::gregorian::Jan, 1));
+  uint64_t version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244));
+
   Name dataName = m_keyName;
-  dataName.append("PROFILE-CERT").append(m_signer).appendVersion();
+  dataName.append("PROFILE-CERT").append(m_signer).appendVersion(version);
   setName(dataName);
 
   setNotBefore(kskCertificate.getNotBefore());
   setNotAfter(kskCertificate.getNotAfter());
-  addSubjectDescription(CertificateSubDescrypt("2.5.4.41", m_keyName.toUri()));
+  addSubjectDescription(CertificateSubjectDescription("2.5.4.41", m_keyName.toUri()));
   setPublicKeyInfo(kskCertificate.getPublicKeyInfo());  
-  addExtension(ProfileExtension(*m_profileData));
+  addExtension(ProfileExtension(m_profileData));
   addExtension(EndorseExtension(m_endorseList));
   
   encode();
@@ -127,15 +128,18 @@
   , m_profileData(endorseCertificate.m_profileData)
   , m_endorseList(endorseList)
 {
+  time_duration now = microsec_clock::universal_time () - ptime(boost::gregorian::date (1970, boost::gregorian::Jan, 1));
+  uint64_t version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244));
+  
   Name dataName = m_keyName;
-  dataName.append("PROFILE-CERT").append(m_signer).appendVersion();
+  dataName.append("PROFILE-CERT").append(m_signer).appendVersion(version);
   setName(dataName);
   
   setNotBefore(endorseCertificate.getNotBefore());
   setNotAfter(endorseCertificate.getNotAfter());
-  addSubjectDescription(CertificateSubDescrypt("2.5.4.41", m_keyName.toUri()));
+  addSubjectDescription(CertificateSubjectDescription("2.5.4.41", m_keyName.toUri()));
   setPublicKeyInfo(endorseCertificate.getPublicKeyInfo());
-  addExtension(ProfileExtension(*m_profileData));
+  addExtension(ProfileExtension(m_profileData));
   addExtension(EndorseExtension(m_endorseList));
 
   encode();
@@ -153,7 +157,7 @@
   : Certificate(data)
 {
   const Name& dataName = data.getName();
-  name::Component certFlag(string("PROFILE-CERT"));  
+  Name::Component certFlag(Name::fromEscapedString("PROFILE-CERT"));  
   int profileIndex = -1;
   for(int i = 0; i < dataName.size(); i++)
     {
@@ -172,18 +176,18 @@
   OID profileExtensionOID("1.3.6.1.5.32.2.1");
   OID endorseExtensionOID("1.3.6.1.5.32.2.2");
 
-  ExtensionList::iterator it = m_extnList.begin();
-  for(; it != m_extnList.end(); it++)
+  ExtensionList::iterator it = extensionList_.begin();
+  for(; it != extensionList_.end(); it++)
     {
-      if(profileExtensionOID == it->getOID())
+      if(profileExtensionOID == it->getOid())
 	{
           ProfileExtension profileExtension(*it);
-	  m_profileData = profileExtension.getProfileData();
+	  m_profileData = *profileExtension.getProfileData();
 	}
-      if(endorseExtensionOID == it->getOID())
+      if(endorseExtensionOID == it->getOid())
         {
           EndorseExtension endorseExtension(*it);
-          m_endorseList = endorseExtension.getEndorsedList();
+          m_endorseList = endorseExtension.getEndorseList();
         }
     }
 }
diff --git a/src/endorse-certificate.h b/src/endorse-certificate.h
index 99d9d65..5f076f2 100644
--- a/src/endorse-certificate.h
+++ b/src/endorse-certificate.h
@@ -12,13 +12,13 @@
 #define LINKNDN_ENDORSE_CERTIFICATE_H
 
 #include <vector>
-#include <ndn.cxx/data.h>
-#include <ndn.cxx/security/certificate/identity-certificate.h>
-#include <ndn.cxx/security/certificate/certificate-extension.h>
+#include <ndn-cpp/data.hpp>
+#include <ndn-cpp/security/certificate/identity-certificate.hpp>
+#include <ndn-cpp/security/certificate/certificate-extension.hpp>
 
 #include "profile-data.h"
 
-class ProfileExtension : public ndn::security::CertificateExtension
+class ProfileExtension : public ndn::CertificateExtension
 {
 public:
   ProfileExtension(const ProfileData& profileData);
@@ -29,14 +29,14 @@
 
   ~ProfileExtension() {}
 
-  ndn::Ptr<ProfileData>
+  ndn::ptr_lib::shared_ptr<ProfileData>
   getProfileData();
 };
 
-class EndorseExtension : public ndn::security::CertificateExtension
+class EndorseExtension : public ndn::CertificateExtension
 {
 public:
-  EndorseExtension(const std::vector<std::string>& endorsedList);
+  EndorseExtension(const std::vector<std::string>& endorseList);
 
   EndorseExtension(const EndorseExtension& endorseExtension);
 
@@ -45,20 +45,20 @@
   ~EndorseExtension() {}
 
   std::vector<std::string>
-  getEndorsedList();
+  getEndorseList();
 
 private:
-  static ndn::Ptr<ndn::Blob>
-  prepareValue(const std::vector<std::string>& endorsedList);
+  static ndn::Blob
+  encodeEndorseList(const std::vector<std::string>& endorsedList);
 };
 
-class EndorseCertificate : public ndn::security::Certificate
+class EndorseCertificate : public ndn::Certificate
 {
 public:
   EndorseCertificate() {}
 
-  EndorseCertificate(const ndn::security::IdentityCertificate& kskCertificate,
-                     ndn::Ptr<ProfileData> profileData,
+  EndorseCertificate(const ndn::IdentityCertificate& kskCertificate,
+                     const ProfileData& profileData,
                      const std::vector<std::string>& endorseList = std::vector<std::string>());
 
   EndorseCertificate(const EndorseCertificate& endorseCertificate,
@@ -73,26 +73,26 @@
   ~EndorseCertificate()
   {}
 
-  inline const ndn::Name&
+  const ndn::Name&
   getSigner() const
   { return m_signer; }
 
-  inline ndn::Ptr<ProfileData>
+  const ProfileData&
   getProfileData() const
   { return m_profileData; }
 
-  inline const std::vector<std::string>&
+  const std::vector<std::string>&
   getEndorseList() const
   { return m_endorseList; }
 
-  inline virtual ndn::Name
+  virtual ndn::Name
   getPublicKeyName () const
   { return m_keyName; }
 
 protected:
   ndn::Name m_keyName;
   ndn::Name m_signer;
-  ndn::Ptr<ProfileData> m_profileData;
+  ProfileData m_profileData;
   std::vector<std::string> m_endorseList;
 };
 
diff --git a/src/endorse-collection.proto b/src/endorse-collection.proto
new file mode 100644
index 0000000..d3aa574
--- /dev/null
+++ b/src/endorse-collection.proto
@@ -0,0 +1,10 @@
+package Chronos;
+
+message EndorseCollection
+{
+  message Endorsement
+  {
+    required string blob = 1;
+  }
+  repeated Endorsement endorsement = 1;
+}
\ No newline at end of file
diff --git a/src/endorse-extension.proto b/src/endorse-extension.proto
new file mode 100644
index 0000000..5db625c
--- /dev/null
+++ b/src/endorse-extension.proto
@@ -0,0 +1,10 @@
+package Chronos;
+
+message EndorseExtensionMsg
+{
+  message EndorseEntry
+  {
+    required string name = 1;
+  }	
+  repeated EndorseEntry endorseEntry = 1;
+}
\ No newline at end of file
diff --git a/src/invitation-policy-manager.cpp b/src/invitation-policy-manager.cpp
index 58c9fcc..cd86cbd 100644
--- a/src/invitation-policy-manager.cpp
+++ b/src/invitation-policy-manager.cpp
@@ -9,40 +9,36 @@
  */
 
 #include "invitation-policy-manager.h"
-
-#include <ndn.cxx/security/cache/ttl-certificate-cache.h>
+#include "null-ptrs.h"
+#include <ndn-cpp/sha256-with-rsa-signature.hpp>
+#include <ndn-cpp/security/signature/sha256-with-rsa-handler.hpp>
 
 #include "logging.h"
 
 using namespace std;
 using namespace ndn;
-using namespace ndn::security;
+using namespace ndn::ptr_lib;
 
 INIT_LOGGER("InvitationPolicyManager");
 
 InvitationPolicyManager::InvitationPolicyManager(const string& chatroomName,
                                                  const Name& signingIdentity,
-                                                 int stepLimit,
-                                                 Ptr<CertificateCache> certificateCache)
+                                                 int stepLimit)
   : m_chatroomName(chatroomName)
   , m_signingIdentity(signingIdentity)
   , m_stepLimit(stepLimit)
-  , m_certificateCache(certificateCache)
 {
-  if(m_certificateCache == NULL)
-    m_certificateCache = Ptr<TTLCertificateCache>(new TTLCertificateCache());
+  m_invitationPolicyRule = make_shared<IdentityPolicyRule>("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>", 
+                                                           "^([^<KEY>]*)<KEY>(<>*)[<dsk-.*><ksk-.*>]<ID-CERT>$", 
+                                                           "==", "\\1", "\\1\\2", true);
 
-  m_invitationPolicyRule = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>", 
-									  "^([^<KEY>]*)<KEY>(<>*)[<dsk-.*><ksk-.*>]<ID-CERT>$", 
-									  "==", "\\1", "\\1\\2", true));
+  m_kskRegex = make_shared<Regex>("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT><>$", "\\1\\2");
 
-  m_kskRegex = Ptr<Regex>(new Regex("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT><>$", "\\1\\2"));
+  m_dskRule = make_shared<IdentityPolicyRule>("^([^<KEY>]*)<KEY><dsk-.*><ID-CERT><>$", 
+                                              "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", 
+                                              "==", "\\1", "\\1\\2", true);
 
-  m_dskRule = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<KEY>]*)<KEY><dsk-.*><ID-CERT><>$", 
-							     "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", 
-							     "==", "\\1", "\\1\\2", true));
-
-  m_keyNameRegex = Ptr<Regex>(new Regex("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>$", "\\1\\2"));
+  m_keyNameRegex = make_shared<Regex>("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>$", "\\1\\2");
 } 
 
 InvitationPolicyManager::~InvitationPolicyManager()
@@ -56,26 +52,26 @@
 InvitationPolicyManager::requireVerify (const Data& data)
 { return true; }
 
-Ptr<ValidationRequest>
-InvitationPolicyManager::checkVerificationPolicy(Ptr<Data> data, 
-					       const int& stepCount, 
-					       const DataCallback& verifiedCallback,
-					       const UnverifiedCallback& unverifiedCallback)
+shared_ptr<ValidationRequest>
+InvitationPolicyManager::checkVerificationPolicy(const shared_ptr<Data>& data, 
+                                                 int stepCount, 
+                                                 const OnVerified& onVerified,
+                                                 const OnVerifyFailed& onVerifyFailed)
 {
   if(m_stepLimit == stepCount)
     {
       _LOG_ERROR("Reach the maximum steps of verification!");
-      unverifiedCallback(data);
-      return NULL;
+      onVerifyFailed(data);
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
     }
 
-  Ptr<const signature::Sha256WithRsa> sha256sig = boost::dynamic_pointer_cast<const signature::Sha256WithRsa> (data->getSignature());    
+  const Sha256WithRsaSignature* sha256sig = dynamic_cast<const Sha256WithRsaSignature*> (data->getSignature());    
 
-  if(KeyLocator::KEYNAME != sha256sig->getKeyLocator().getType())
+  if(ndn_KeyLocatorType_KEYNAME != sha256sig->getKeyLocator().getType())
     {
       _LOG_ERROR("KeyLocator is not name!");
-      unverifiedCallback(data);
-      return NULL;
+      onVerifyFailed(data);
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
     }
 
   const Name & keyLocatorName = sha256sig->getKeyLocator().getKeyName();
@@ -94,60 +90,59 @@
       //     return NULL;
       //   }
 
-      Ptr<const IdentityCertificate> trustedCert = m_certificateCache->getCertificate(keyLocatorName);
+      shared_ptr<const Certificate> trustedCert = m_certificateCache.getCertificate(keyLocatorName);
       
-      if(NULL != trustedCert){
-	if(verifySignature(*data, trustedCert->getPublicKeyInfo()))
-	  verifiedCallback(data);
+      if(!trustedCert){
+	if(Sha256WithRsaHandler::verifySignature(*data, trustedCert->getPublicKeyInfo()))
+	  onVerified(data);
 	else
-	  unverifiedCallback(data);
+	  onVerifyFailed(data);
 
-	return NULL;
+	return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
       }
 
-      DataCallback recursiveVerifiedCallback = boost::bind(&InvitationPolicyManager::onDskCertificateVerified, 
-                                                           this, 
-                                                           _1, 
-                                                           data, 
-                                                           verifiedCallback, 
-                                                           unverifiedCallback);
+      OnVerified recursiveVerifiedCallback = boost::bind(&InvitationPolicyManager::onDskCertificateVerified, 
+                                                         this, 
+                                                         _1, 
+                                                         data, 
+                                                         onVerified, 
+                                                         onVerifyFailed);
       
-      UnverifiedCallback recursiveUnverifiedCallback = boost::bind(&InvitationPolicyManager::onDskCertificateUnverified, 
-                                                                   this, 
-                                                                   _1, 
-                                                                   data, 
-                                                                   unverifiedCallback);
+      OnVerifyFailed recursiveUnverifiedCallback = boost::bind(&InvitationPolicyManager::onDskCertificateVerifyFailed, 
+                                                               this, 
+                                                               _1, 
+                                                               data, 
+                                                               onVerifyFailed);
 
 
-      Ptr<Interest> interest = Ptr<Interest>(new Interest(keyLocatorName));
+      shared_ptr<Interest> interest = make_shared<Interest>(keyLocatorName);
       
-      Ptr<ValidationRequest> nextStep = Ptr<ValidationRequest>(new ValidationRequest(interest, 
-                                                                                     recursiveVerifiedCallback,
-                                                                                     recursiveUnverifiedCallback,
-                                                                                     0,
-                                                                                     stepCount + 1)
-                                                               );
+      shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(interest, 
+                                                                              recursiveVerifiedCallback,
+                                                                              recursiveUnverifiedCallback,
+                                                                              0,
+                                                                              stepCount + 1);
       return nextStep;
     }
 
   if(m_kskRegex->match(data->getName()))
     {
       Name keyName = m_kskRegex->expand();
-      map<Name, Publickey>::iterator it = m_trustAnchors.find(keyName);
+      map<Name, PublicKey>::iterator it = m_trustAnchors.find(keyName);
       if(m_trustAnchors.end() != it)
         {
-          Ptr<IdentityCertificate> identityCertificate = Ptr<IdentityCertificate>(new IdentityCertificate(*data));
-          if(it->second.getKeyBlob() == identityCertificate->getPublicKeyInfo().getKeyBlob())
+          IdentityCertificate identityCertificate(*data);
+          if(isSameKey(it->second.getKeyDer(), identityCertificate.getPublicKeyInfo().getKeyDer()))
             {
-              verifiedCallback(data);
+              onVerified(data);
             }
           else
-            unverifiedCallback(data);
+            onVerifyFailed(data);
         }
       else
-        unverifiedCallback(data);
+        onVerifyFailed(data);
 
-      return NULL;
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
     }
 
   if(m_dskRule->satisfy(*data))
@@ -156,23 +151,23 @@
       Name keyName = m_keyNameRegex->expand();
 
       if(m_trustAnchors.end() != m_trustAnchors.find(keyName))
-        if(verifySignature(*data, m_trustAnchors[keyName]))
-          verifiedCallback(data);
+        if(Sha256WithRsaHandler::verifySignature(*data, m_trustAnchors[keyName]))
+          onVerified(data);
         else
-          unverifiedCallback(data);
+          onVerifyFailed(data);
       else
-        unverifiedCallback(data);
+        onVerifyFailed(data);
 
-      return NULL;	
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;	
     }
 
-  unverifiedCallback(data);
-  return NULL;
+  onVerifyFailed(data);
+  return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
 }
 
 bool 
 InvitationPolicyManager::checkSigningPolicy(const Name& dataName, 
-					  const Name& certificateName)
+                                            const Name& certificateName)
 {
   return true;
 }
@@ -185,7 +180,7 @@
 
 void
 InvitationPolicyManager::addTrustAnchor(const EndorseCertificate& selfEndorseCertificate)
-{ m_trustAnchors.insert(pair <Name, Publickey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo())); }
+{ m_trustAnchors.insert(pair <Name, PublicKey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo())); }
 
 
 // void
@@ -209,45 +204,66 @@
 
 
 void 
-InvitationPolicyManager::onDskCertificateVerified(Ptr<Data> certData, 
-                                                  Ptr<Data> originalData,
-                                                  const DataCallback& verifiedCallback, 
-                                                  const UnverifiedCallback& unverifiedCallback)
+InvitationPolicyManager::onDskCertificateVerified(const shared_ptr<Data>& certData, 
+                                                  shared_ptr<Data> originalData,
+                                                  const OnVerified& onVerified, 
+                                                  const OnVerifyFailed& onVerifyFailed)
 {
-  Ptr<IdentityCertificate> certificate = Ptr<IdentityCertificate>(new IdentityCertificate(*certData));
+  shared_ptr<IdentityCertificate> certificate = make_shared<IdentityCertificate>(*certData);
 
   if(!certificate->isTooLate() && !certificate->isTooEarly())
     {
-      Name certName = certificate->getName().getPrefix(certificate->getName().size()-1);
-      map<Name, Ptr<IdentityCertificate> >::iterator it = m_dskCertificates.find(certName);
+      Name certName = certificate->getName().getPrefix(-1);
+      map<Name, shared_ptr<IdentityCertificate> >::iterator it = m_dskCertificates.find(certName);
       if(it == m_dskCertificates.end())
-        m_dskCertificates.insert(pair <Name, Ptr<IdentityCertificate> > (certName, certificate));
+        m_dskCertificates.insert(pair <Name, shared_ptr<IdentityCertificate> > (certName, certificate));
 
-      if(verifySignature(*originalData, certificate->getPublicKeyInfo()))
+      if(Sha256WithRsaHandler::verifySignature(*originalData, certificate->getPublicKeyInfo()))
         {
-          verifiedCallback(originalData);
+          onVerified(originalData);
           return;
         }
     }
   else
     {
-      unverifiedCallback(originalData);
+      onVerifyFailed(originalData);
       return;
     }
 }
 
 void
-InvitationPolicyManager::onDskCertificateUnverified(Ptr<Data> certData, 
-                                                  Ptr<Data> originalData,
-                                                  const UnverifiedCallback& unverifiedCallback)
-{ unverifiedCallback(originalData); }
+InvitationPolicyManager::onDskCertificateVerifyFailed(const shared_ptr<Data>& certData, 
+                                                      shared_ptr<Data> originalData,
+                                                      const OnVerifyFailed& onVerifyFailed)
+{ onVerifyFailed(originalData); }
 
-Ptr<IdentityCertificate> 
+shared_ptr<IdentityCertificate> 
 InvitationPolicyManager::getValidatedDskCertificate(const ndn::Name& certName)
 {
-  map<Name, Ptr<IdentityCertificate> >::iterator it = m_dskCertificates.find(certName);
+  map<Name, shared_ptr<IdentityCertificate> >::iterator it = m_dskCertificates.find(certName);
   if(m_dskCertificates.end() != it)
     return it->second;
   else
-    return NULL;
+    return CHRONOCHAT_NULL_IDENTITYCERTIFICATE_PTR;
+}
+
+
+bool
+InvitationPolicyManager::isSameKey(const Blob& keyA, const Blob& keyB)
+{
+  size_t size = keyA.size();
+
+  if(size != keyB.size())
+    return false;
+
+  const uint8_t* ap = keyA.buf();
+  const uint8_t* bp = keyB.buf();
+  
+  for(int i = 0; i < size; i++)
+    {
+      if(ap[i] != bp[i])
+        return false;
+    }
+
+  return true;
 }
diff --git a/src/invitation-policy-manager.h b/src/invitation-policy-manager.h
index f2cfc1c..a49124f 100644
--- a/src/invitation-policy-manager.h
+++ b/src/invitation-policy-manager.h
@@ -11,22 +11,21 @@
 #ifndef INVITATION_POLICY_MANAGER_H
 #define INVITATION_POLICY_MANAGER_H
 
-#include <ndn.cxx/security/policy/policy-manager.h>
-#include <ndn.cxx/security/policy/identity-policy-rule.h>
-#include <ndn.cxx/security/cache/certificate-cache.h>
-#include <ndn.cxx/regex/regex.h>
+#include <ndn-cpp/security/policy/policy-manager.hpp>
+#include <ndn-cpp-et/policy-manager/identity-policy-rule.hpp>
+#include <ndn-cpp-et/cache/ttl-certificate-cache.hpp>
+#include <ndn-cpp-et/regex/regex.hpp>
 #include <map>
 
 #include "endorse-certificate.h"
 #include "chat-policy-rule.h"
 
-class InvitationPolicyManager : public ndn::security::PolicyManager
+class InvitationPolicyManager : public ndn::PolicyManager
 {
 public:
   InvitationPolicyManager(const std::string& chatroomName,
                           const ndn::Name& signingIdentity,
-                          int stepLimit = 10,
-                          ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL);
+                          int stepLimit = 10);
   
   virtual
   ~InvitationPolicyManager();
@@ -37,11 +36,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, 
@@ -57,20 +56,23 @@
   // addChatDataRule(const ndn::Name& prefix, 
   //                 const ndn::security::IdentityCertificate identityCertificate);
 
-  ndn::Ptr<ndn::security::IdentityCertificate> 
+  ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate> 
   getValidatedDskCertificate(const ndn::Name& certName);
 
 private:
   void 
-  onDskCertificateVerified(ndn::Ptr<ndn::Data> certData, 
-                        ndn::Ptr<ndn::Data> originalData,
-                        const ndn::DataCallback& verifiedCallback, 
-                        const ndn::UnverifiedCallback& unverifiedCallback);
+  onDskCertificateVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& certData, 
+                           ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
+                           const ndn::OnVerified& onVerified, 
+                           const ndn::OnVerifyFailed& onVerifyFailed);
 
   void
-  onDskCertificateUnverified(ndn::Ptr<ndn::Data> certData, 
-                          ndn::Ptr<ndn::Data> originalData,
-                          const ndn::UnverifiedCallback& unverifiedCallback);
+  onDskCertificateVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& certData, 
+                               ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
+                               const ndn::OnVerifyFailed& onVerifyFailed);
+
+  static bool
+  isSameKey(const ndn::Blob& keyA, const ndn::Blob& keyB);
 
 private:
   std::string m_chatroomName;
@@ -78,18 +80,18 @@
 
   int m_stepLimit;
 
-  ndn::Ptr<ndn::security::CertificateCache> m_certificateCache;
+  ndn::TTLCertificateCache m_certificateCache;
 
-  ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationPolicyRule;
-  ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule;
-  std::map<ndn::Name, ChatPolicyRule> m_chatDataRules;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_invitationPolicyRule;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_dskRule;
+  std::map<ndn::Name, ChatPolicyRule, ndn::Name::BreadthFirstLess> m_chatDataRules;
 
-  ndn::Ptr<ndn::Regex> m_kskRegex;
-  ndn::Ptr<ndn::Regex> m_keyNameRegex;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_kskRegex;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_keyNameRegex;
 
-  std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors;
+  std::map<ndn::Name, ndn::PublicKey, ndn::Name::BreadthFirstLess> m_trustAnchors;
 
-  std::map<ndn::Name, ndn::Ptr<ndn::security::IdentityCertificate> > m_dskCertificates;
+  std::map<ndn::Name, ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate>, ndn::Name::BreadthFirstLess> m_dskCertificates;
 
 };
 
diff --git a/src/invitationdialog.cpp b/src/invitationdialog.cpp
index f909a00..c142014 100644
--- a/src/invitationdialog.cpp
+++ b/src/invitationdialog.cpp
@@ -14,6 +14,7 @@
 
 using namespace std;
 using namespace ndn;
+using namespace ndn::ptr_lib;
 
 InvitationDialog::InvitationDialog(QWidget *parent) :
     QDialog(parent),
@@ -34,8 +35,8 @@
 
 void
 InvitationDialog::setInvitation(const string& alias,
-                                Ptr<ChronosInvitation> invitation, 
-                                Ptr<security::IdentityCertificate> identityCertificate)
+                                shared_ptr<ChronosInvitation> invitation, 
+                                shared_ptr<IdentityCertificate> identityCertificate)
 {
   m_inviterAlias = alias;
   string msg = alias;
@@ -43,7 +44,7 @@
   ui->msgLabel->setText(QString::fromStdString(msg));
 
   m_invitation = invitation;
-  ui->chatroomLine->setText(QString::fromStdString(invitation->getChatroom().get(0).toUri()));
+  ui->chatroomLine->setText(QString::fromStdString(invitation->getChatroom().get(0).toEscapedString()));
 
   m_identityCertificate = identityCertificate;
 }
@@ -63,8 +64,8 @@
 
   emit invitationRejected(*m_invitation); 
 
-  m_invitation = NULL;
-  m_identityCertificate = NULL;
+  m_invitation = make_shared<ChronosInvitation>();
+  m_identityCertificate = make_shared<IdentityCertificate>();
   m_inviterAlias.clear();
 
   this->close();
diff --git a/src/invitationdialog.h b/src/invitationdialog.h
index d90b80e..271b207 100644
--- a/src/invitationdialog.h
+++ b/src/invitationdialog.h
@@ -14,8 +14,8 @@
 #include <QDialog>
 
 #ifndef Q_MOC_RUN
-#include <ndn.cxx/data.h>
-#include <ndn.cxx/security/certificate/identity-certificate.h>
+#include <ndn-cpp/data.hpp>
+#include <ndn-cpp/security/certificate/identity-certificate.hpp>
 #include "chronos-invitation.h"
 #endif
 
@@ -33,13 +33,13 @@
 
   void
   setInvitation(const std::string& alias,
-                ndn::Ptr<ChronosInvitation> invitation, 
-                ndn::Ptr<ndn::security::IdentityCertificate> identityCertificate);
+                ndn::ptr_lib::shared_ptr<ChronosInvitation> invitation, 
+                ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate> identityCertificate);
 
 signals:
   void
   invitationAccepted(const ChronosInvitation& invitation, 
-                     const ndn::security::IdentityCertificate& identityCertificate);
+                     const ndn::IdentityCertificate& identityCertificate);
   
   void
   invitationRejected(const ChronosInvitation& invitation);
@@ -55,8 +55,8 @@
 private:
   Ui::InvitationDialog *ui;
   std::string m_inviterAlias;
-  ndn::Ptr<ChronosInvitation> m_invitation;
-  ndn::Ptr<ndn::security::IdentityCertificate> m_identityCertificate;
+  ndn::ptr_lib::shared_ptr<ChronosInvitation> m_invitation;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate> m_identityCertificate;
 };
 
 #endif // INVITATIONDIALOG_H
diff --git a/src/invitelistdialog.cpp b/src/invitelistdialog.cpp
index c3d12af..ea6b790 100644
--- a/src/invitelistdialog.cpp
+++ b/src/invitelistdialog.cpp
@@ -13,7 +13,7 @@
 
 using namespace std;
 
-InviteListDialog::InviteListDialog(ndn::Ptr<ContactManager> contactManager,
+InviteListDialog::InviteListDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
 				   QWidget *parent) 
   :QDialog(parent)
   , ui(new Ui::InviteListDialog)
@@ -50,7 +50,8 @@
 void
 InviteListDialog::refreshContactList()
 {
-  m_contactList = m_contactManager->getContactItemList();
+  m_contactList.clear();
+  m_contactManager->getContactItemList(m_contactList);
   QStringList contactNameList;
   for(int i = 0; i < m_contactList.size(); i++)
     {
diff --git a/src/invitelistdialog.h b/src/invitelistdialog.h
index cda26e5..dc91c7a 100644
--- a/src/invitelistdialog.h
+++ b/src/invitelistdialog.h
@@ -27,7 +27,7 @@
   Q_OBJECT
 
 public:
-  explicit InviteListDialog(ndn::Ptr<ContactManager> contactManager,
+  explicit InviteListDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
                             QWidget *parent = 0);
   ~InviteListDialog();
 
@@ -50,9 +50,9 @@
 
 private:
   Ui::InviteListDialog *ui;
-  ndn::Ptr<ContactManager> m_contactManager;
+  ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager;
   QStringListModel* m_contactListModel;
-  std::vector<ndn::Ptr<ContactItem> > m_contactList;
+  std::vector<ndn::ptr_lib::shared_ptr<ContactItem> > m_contactList;
   std::vector<std::string> m_invitedContacts;
 };
 
diff --git a/src/main.cpp b/src/main.cpp
index df4511b..219151e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -16,7 +16,6 @@
 #include "dns-storage.h"
 #include "contact-manager.h"
 #include "logging.h"
-#include <ndn.cxx/wrapper/wrapper.h>
 
 INIT_LOGGER("MAIN");
 
@@ -34,12 +33,8 @@
     try {
         return QApplication::notify(receiver, event);
     } 
-    catch(ndn::Error::ndnOperation& e){
-      std::cerr << "Canno connect to ndnd!" << endl;
-      return false;
-    }
     catch(std::exception& e){
-      std::cerr << "Exception thrown:" << e.what() << endl;
+      std::cerr << "Exception thrown:" << e.what() << std::endl;
       return false;
     }
     
diff --git a/src/null-ptrs.h b/src/null-ptrs.h
new file mode 100644
index 0000000..0dfd3f2
--- /dev/null
+++ b/src/null-ptrs.h
@@ -0,0 +1,35 @@
+/* -*- 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 NULL_PTRS_H
+#define NULL_PTRS_H
+
+#include <string>
+#include <ndn-cpp/util/blob.hpp>
+#include <ndn-cpp/data.hpp>
+#include "contact-item.h"
+#include "endorse-certificate.h"
+#include "profile.h"
+#include <ndn-cpp/security/certificate/identity-certificate.hpp>
+#include <ndn-cpp/security/policy/validation-request.hpp>
+
+
+static std::string CHRONOCHAT_NULL_STR;
+static ndn::Blob CHRONOCHAT_NULL_BLOB;
+
+static ndn::ptr_lib::shared_ptr<ContactItem> CHRONOCHAT_NULL_CONTACTITEM_PTR;
+static ndn::ptr_lib::shared_ptr<ndn::Data> CHRONOCHAT_NULL_DATA_PTR;
+static ndn::ptr_lib::shared_ptr<EndorseCertificate> CHRONOCHAT_NULL_ENDORSECERTIFICATE_PTR;
+static ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate> CHRONOCHAT_NULL_IDENTITYCERTIFICATE_PTR;
+static ndn::ptr_lib::shared_ptr<Profile> CHRONOCHAT_NULL_PROFILE_PTR;
+static ndn::ptr_lib::shared_ptr<ndn::PublicKey> CHRONOCHAT_NULL_PUBLICKEY_PTR;
+static ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
+
+#endif
diff --git a/src/panel-policy-manager.cpp b/src/panel-policy-manager.cpp
index 96900e7..8d6300d 100644
--- a/src/panel-policy-manager.cpp
+++ b/src/panel-policy-manager.cpp
@@ -9,45 +9,42 @@
  */
 
 #include "panel-policy-manager.h"
-
-#include <ndn.cxx/security/certificate/identity-certificate.h>
-#include <ndn.cxx/security/cache/ttl-certificate-cache.h>
-#include <boost/bind.hpp>
+#include "null-ptrs.h"
+#include <ndn-cpp/sha256-with-rsa-signature.hpp>
+#include <ndn-cpp/security/signature/sha256-with-rsa-handler.hpp>
+// #include <boost/bind.hpp>
 
 #include "logging.h"
 
 using namespace std;
 using namespace ndn;
-using namespace ndn::security;
+using namespace ndn::ptr_lib;
 
 INIT_LOGGER("PanelPolicyManager");
 
-PanelPolicyManager::PanelPolicyManager(const int & stepLimit,
-                                       Ptr<CertificateCache> certificateCache)
+PanelPolicyManager::PanelPolicyManager(const int & stepLimit)
   : m_stepLimit(stepLimit)
-  , m_certificateCache(certificateCache)
-  , m_localPrefixRegex(Ptr<Regex>(new Regex("^<local><ndn><prefix><><>$")))
+  , m_certificateCache()
 {
-  if(NULL == m_certificateCache)
-    m_certificateCache = Ptr<security::CertificateCache>(new security::TTLCertificateCache());
+  m_localPrefixRegex = make_shared<Regex>("^<local><ndn><prefix><><>$");
 
-  m_invitationDataSigningRule = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>", 
-                                                                               "^([^<KEY>]*)<KEY>(<>*)<><ID-CERT><>$", 
-                                                                               "==", "\\1", "\\1\\2", true));
+  m_invitationDataSigningRule = make_shared<IdentityPolicyRule>("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>", 
+                                                                "^([^<KEY>]*)<KEY>(<>*)<><ID-CERT><>$", 
+                                                                "==", "\\1", "\\1\\2", true);
   
-  m_dskRule = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<KEY>]*)<KEY><dsk-.*><ID-CERT><>$", 
-							     "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", 
-							     "==", "\\1", "\\1\\2", true));
+  m_dskRule = make_shared<IdentityPolicyRule>("^([^<KEY>]*)<KEY><dsk-.*><ID-CERT><>$", 
+                                              "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", 
+                                              "==", "\\1", "\\1\\2", true);
   
-  m_endorseeRule = Ptr<IdentityPolicyRule>(new IdentityPolicyRule("^([^<DNS>]*)<DNS><>*<ENDORSEE><>$", 
-                                                                  "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", 
-                                                                  "==", "\\1", "\\1\\2", true));
+  m_endorseeRule = make_shared<IdentityPolicyRule>("^([^<DNS>]*)<DNS><>*<ENDORSEE><>$", 
+                                                   "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", 
+                                                   "==", "\\1", "\\1\\2", true);
   
-  m_kskRegex = Ptr<Regex>(new Regex("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT><>$", "\\1\\2"));
+  m_kskRegex = make_shared<Regex>("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT><>$", "\\1\\2");
 
-  m_keyNameRegex = Ptr<Regex>(new Regex("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>$", "\\1\\2"));
+  m_keyNameRegex = make_shared<Regex>("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>$", "\\1\\2");
 
-  m_signingCertificateRegex = Ptr<Regex>(new Regex("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>", "\\1"));
+  m_signingCertificateRegex = make_shared<Regex>("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>", "\\1");
 }
 
 bool 
@@ -76,26 +73,26 @@
   return false;
 }
 
-Ptr<ValidationRequest>
-PanelPolicyManager::checkVerificationPolicy(Ptr<Data> data, 
-						 const int & stepCount, 
-						 const DataCallback& verifiedCallback,
-						 const UnverifiedCallback& unverifiedCallback)
+shared_ptr<ValidationRequest>
+PanelPolicyManager::checkVerificationPolicy(const shared_ptr<Data>& data, 
+                                            int stepCount, 
+                                            const OnVerified& onVerified,
+                                            const OnVerifyFailed& onVerifyFailed)
 {
   if(m_stepLimit == stepCount)
     {
       _LOG_ERROR("Reach the maximum steps of verification!");
-      unverifiedCallback(data);
-      return NULL;
+      onVerifyFailed(data);
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
     }
 
-  Ptr<const signature::Sha256WithRsa> sha256sig = boost::dynamic_pointer_cast<const signature::Sha256WithRsa> (data->getSignature());    
+  const Sha256WithRsaSignature* sha256sig = dynamic_cast<const Sha256WithRsaSignature*>(data->getSignature());    
 
-  if(KeyLocator::KEYNAME != sha256sig->getKeyLocator().getType())
+  if(ndn_KeyLocatorType_KEYNAME != sha256sig->getKeyLocator().getType())
     {
       _LOG_ERROR("Keylocator is not name!");
-      unverifiedCallback(data);
-      return NULL;
+      onVerifyFailed(data);
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
     }
 
   const Name & keyLocatorName = sha256sig->getKeyLocator().getKeyName();
@@ -103,22 +100,20 @@
   if(m_kskRegex->match(data->getName()))
     {
       Name keyName = m_kskRegex->expand();
-      map<Name, Publickey>::iterator it = m_trustAnchors.find(keyName);
+      map<Name, PublicKey>::iterator it = m_trustAnchors.find(keyName);
       if(m_trustAnchors.end() != it)
         {
           // _LOG_DEBUG("found key!");
-          Ptr<IdentityCertificate> identityCertificate = Ptr<IdentityCertificate>(new IdentityCertificate(*data));
-          if(it->second.getKeyBlob() == identityCertificate->getPublicKeyInfo().getKeyBlob())
-            {
-              verifiedCallback(data);
-            }
+          IdentityCertificate identityCertificate(*data);
+          if(isSameKey(it->second.getKeyDer(), identityCertificate.getPublicKeyInfo().getKeyDer()))
+            onVerified(data);
           else
-            unverifiedCallback(data);
+            onVerifyFailed(data);
         }
       else
-        unverifiedCallback(data);
+        onVerifyFailed(data);
 
-      return NULL;
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
     }
 
   if(m_dskRule->satisfy(*data))
@@ -127,14 +122,14 @@
       Name keyName = m_keyNameRegex->expand();
 
       if(m_trustAnchors.end() != m_trustAnchors.find(keyName))
-        if(verifySignature(*data, m_trustAnchors[keyName]))
-          verifiedCallback(data);
+        if(Sha256WithRsaHandler::verifySignature(*data, m_trustAnchors[keyName]))
+          onVerified(data);
         else
-          unverifiedCallback(data);
+          onVerifyFailed(data);
       else
-        unverifiedCallback(data);
+        onVerifyFailed(data);
 
-      return NULL;	
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;	
     }
 
   if(m_endorseeRule->satisfy(*data))
@@ -142,20 +137,20 @@
       m_keyNameRegex->match(keyLocatorName);
       Name keyName = m_keyNameRegex->expand();
       if(m_trustAnchors.end() != m_trustAnchors.find(keyName))
-        if(verifySignature(*data, m_trustAnchors[keyName]))
-          verifiedCallback(data);
+        if(Sha256WithRsaHandler::verifySignature(*data, m_trustAnchors[keyName]))
+          onVerified(data);
         else
-          unverifiedCallback(data);
+          onVerifyFailed(data);
       else
-        unverifiedCallback(data);
+        onVerifyFailed(data);
 
-      return NULL;
+      return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
     }
 
   _LOG_DEBUG("Unverified!");
 
-  unverifiedCallback(data);
-  return NULL;
+  onVerifyFailed(data);
+  return CHRONOCHAT_NULL_VALIDATIONREQUEST_PTR;
 }
 
 bool 
@@ -177,7 +172,7 @@
 PanelPolicyManager::addTrustAnchor(const EndorseCertificate& selfEndorseCertificate)
 { 
   // _LOG_DEBUG("Add Anchor: " << selfEndorseCertificate.getPublicKeyName().toUri());
-  m_trustAnchors.insert(pair <Name, Publickey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo())); 
+  m_trustAnchors.insert(pair <Name, PublicKey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo())); 
 }
 
 void
@@ -186,14 +181,34 @@
   m_trustAnchors.erase(keyName); 
 }
 
-Ptr<Publickey>
-PanelPolicyManager::getTrustedKey(const ndn::Name& inviterCertName)
+shared_ptr<PublicKey>
+PanelPolicyManager::getTrustedKey(const Name& inviterCertName)
 {
-  Name keyLocatorName = inviterCertName.getPrefix(inviterCertName.size()-1);
+  Name keyLocatorName = inviterCertName.getPrefix(-1);
   m_keyNameRegex->match(keyLocatorName);
   Name keyName = m_keyNameRegex->expand();
 
   if(m_trustAnchors.end() != m_trustAnchors.find(keyName))
-    return Ptr<Publickey>(new Publickey(m_trustAnchors[keyName]));
-  return NULL;
+    return make_shared<PublicKey>(m_trustAnchors[keyName]);
+  return CHRONOCHAT_NULL_PUBLICKEY_PTR;
+}
+
+bool
+PanelPolicyManager::isSameKey(const Blob& keyA, const Blob& keyB)
+{
+  size_t size = keyA.size();
+
+  if(size != keyB.size())
+    return false;
+
+  const uint8_t* ap = keyA.buf();
+  const uint8_t* bp = keyB.buf();
+  
+  for(int i = 0; i < size; i++)
+    {
+      if(ap[i] != bp[i])
+        return false;
+    }
+
+  return true;
 }
diff --git a/src/panel-policy-manager.h b/src/panel-policy-manager.h
index f38e0e8..712f9e5 100644
--- a/src/panel-policy-manager.h
+++ b/src/panel-policy-manager.h
@@ -11,18 +11,17 @@
 #ifndef PANEL_POLICY_MANAGER_H
 #define PANEL_POLICY_MANAGER_H
 
-#include <ndn.cxx/security/policy/policy-manager.h>
-#include <ndn.cxx/security/policy/identity-policy-rule.h>
-#include <ndn.cxx/security/cache/certificate-cache.h>
+#include <ndn-cpp/security/policy/policy-manager.hpp>
+#include <ndn-cpp-et/policy-manager/identity-policy-rule.hpp>
+#include <ndn-cpp-et/cache/ttl-certificate-cache.hpp>
 #include <map>
 
 #include "endorse-certificate.h"
 
-class PanelPolicyManager : public ndn::security::PolicyManager
+class PanelPolicyManager : public ndn::PolicyManager
 {
 public:
-  PanelPolicyManager(const int & stepLimit = 10,                        
-                     ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL);
+  PanelPolicyManager(const int & stepLimit = 10);
 
   ~PanelPolicyManager()
   {}
@@ -51,11 +50,11 @@
    * @param unverifiedCallback the callback function that will be called if the received data packet cannot be validated
    * @return the indication of next verification step, NULL if there is no further step
    */
-  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);
 
     
   /**
@@ -82,32 +81,24 @@
   void
   removeTrustAnchor(const ndn::Name& keyName);
 
-// private:
-//   void 
-//   onCertificateVerified(ndn::Ptr<ndn::Data> certData, 
-//                         ndn::Ptr<ndn::Data> originalData,
-//                         const ndn::DataCallback& verifiedCallback, 
-//                         const ndn::UnverifiedCallback& unverifiedCallback);
-
-//   void
-//   onCertificateUnverified(ndn::Ptr<ndn::Data> certData, 
-//                           ndn::Ptr<ndn::Data> originalData,
-//                           const ndn::UnverifiedCallback& unverifiedCallback);
-
-  ndn::Ptr<ndn::security::Publickey>
+  ndn::ptr_lib::shared_ptr<ndn::PublicKey>
   getTrustedKey(const ndn::Name& inviterCertName);
 
 private:
+  static bool
+  isSameKey(const ndn::Blob& keyA, const ndn::Blob& keyB);
+
+private:
   int m_stepLimit;
-  ndn::Ptr<ndn::security::CertificateCache> m_certificateCache;
-  ndn::Ptr<ndn::Regex> m_localPrefixRegex;
-  ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationDataSigningRule;
-  ndn::Ptr<ndn::Regex> m_kskRegex;
-  ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule;
-  ndn::Ptr<ndn::security::IdentityPolicyRule> m_endorseeRule;
-  ndn::Ptr<ndn::Regex> m_keyNameRegex;
-  ndn::Ptr<ndn::Regex> m_signingCertificateRegex;
-  std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors;
+  ndn::TTLCertificateCache m_certificateCache;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_localPrefixRegex;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_invitationDataSigningRule;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_kskRegex;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_dskRule;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_endorseeRule;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_keyNameRegex;
+  ndn::ptr_lib::shared_ptr<ndn::Regex> m_signingCertificateRegex;
+  std::map<ndn::Name, ndn::PublicKey, ndn::Name::BreadthFirstLess> m_trustAnchors;
   
 };
 
diff --git a/src/profile-data.cpp b/src/profile-data.cpp
index e839f0f..6bb70cc 100644
--- a/src/profile-data.cpp
+++ b/src/profile-data.cpp
@@ -9,56 +9,52 @@
  */
 
 #include "profile-data.h"
+#include <boost/date_time/posix_time/posix_time.hpp>
 #include "exception.h"
-#include <ndn.cxx/fields/signature-sha256-with-rsa.h>
 #include "logging.h"
 
 
 using namespace ndn;
 using namespace std;
+using namespace boost::posix_time;
 
 INIT_LOGGER("ProfileData");
 
+ProfileData::ProfileData()
+  : Data()
+{}
+
 ProfileData::ProfileData(const Profile& profile)
   : Data()
   , m_identity(profile.getIdentityName())
   , m_profile(profile)
 {
   Name dataName = m_identity;
-
-  dataName.append("PROFILE").appendVersion();
+  
+  time_duration now = microsec_clock::universal_time () - ptime(boost::gregorian::date (1970, boost::gregorian::Jan, 1));
+  uint64_t version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244));
+  dataName.append("PROFILE").appendVersion(version);
   setName(dataName);
-  Ptr<Blob> profileBlob = profile.toDerBlob();
-  setContent(Content(profileBlob->buf(), profileBlob->size()));
+
+  string content;
+  profile.encode(&content);
+  setContent((const uint8_t *)&content[0], content.size());
+
+  getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
+
 }
 
 ProfileData::ProfileData(const ProfileData& profileData)
-  : Data()
+  : Data(profileData)
   , m_identity(profileData.m_identity)
   , m_profile(profileData.m_profile)
-{
-  Ptr<const signature::Sha256WithRsa> dataSig = boost::dynamic_pointer_cast<const signature::Sha256WithRsa>(profileData.getSignature());
-  Ptr<signature::Sha256WithRsa> newSig = Ptr<signature::Sha256WithRsa>::Create();
-
-  Ptr<SignedBlob> newSignedBlob = NULL;
-  if(profileData.getSignedBlob() != NULL)
-    newSignedBlob = Ptr<SignedBlob>(new SignedBlob(*profileData.getSignedBlob()));
-  
-  newSig->setKeyLocator(dataSig->getKeyLocator());
-  newSig->setPublisherKeyDigest(dataSig->getPublisherKeyDigest());
-  newSig->setSignatureBits(dataSig->getSignatureBits());
-  
-  setName(profileData.getName());
-  setSignature(newSig);
-  setContent(profileData.getContent());
-  setSignedBlob(newSignedBlob);
-}
+{}
 
 ProfileData::ProfileData(const Data& data)
-  : Data()
+  : Data(data)
 {
   const Name& dataName = data.getName();
-  name::Component appFlag(string("PROFILE"));  
+  Name::Component appFlag(Name::fromEscapedString("PROFILE"));  
 
   int profileIndex = -1;
   for(int i = 0; i < dataName.size(); i++)
@@ -73,24 +69,8 @@
   if(profileIndex < 0)
     throw LnException("No PROFILE component in data name!");
 
-  m_identity = dataName.getSubName(0, profileIndex);
+  m_identity = dataName.getPrefix(profileIndex);
 
-  Ptr<const signature::Sha256WithRsa> dataSig = boost::dynamic_pointer_cast<const signature::Sha256WithRsa>(data.getSignature());
-  Ptr<signature::Sha256WithRsa> newSig = Ptr<signature::Sha256WithRsa>::Create();
-  
-  Ptr<SignedBlob> newSignedBlob = NULL;
-  if(data.getSignedBlob() != NULL)
-    newSignedBlob = Ptr<SignedBlob>(new SignedBlob(*data.getSignedBlob()));
-    
-  newSig->setKeyLocator(dataSig->getKeyLocator());
-  newSig->setPublisherKeyDigest(dataSig->getPublisherKeyDigest());
-  newSig->setSignatureBits(dataSig->getSignatureBits());
-  
-  setName(data.getName());
-  setSignature(newSig);
-  setContent(data.getContent());
-  setSignedBlob(newSignedBlob);
-
-  m_profile = *Profile::fromDerBlob(data.content());
-
+  string encoded((const char*)data.getContent().buf(), data.getContent().size());
+  m_profile = *Profile::decode(encoded);
 }
diff --git a/src/profile-data.h b/src/profile-data.h
index 9c8e184..dcde0d8 100644
--- a/src/profile-data.h
+++ b/src/profile-data.h
@@ -11,12 +11,14 @@
 #ifndef LINKNDN_PROFILE_DATA_H
 #define LINKNDN_PROFILE_DATA_H
 
-#include <ndn.cxx/data.h>
+#include <ndn-cpp/data.hpp>
 #include "profile.h"
 
 class ProfileData : public ndn::Data
 {
 public:
+  ProfileData();
+
   ProfileData(const Profile& profile);
 
   ProfileData(const ProfileData& profileData);
@@ -25,11 +27,11 @@
 
   ~ProfileData() {}
 
-  inline const ndn::Name& 
+  const ndn::Name& 
   getIdentityName() const
   { return m_identity; }
 
-  inline const Profile&
+  const Profile&
   getProfile() const
   { return m_profile; }
 
diff --git a/src/profile.cpp b/src/profile.cpp
index 24372a4..af805b0 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -9,13 +9,12 @@
  */
 
 #include "profile.h"
-#include <ndn.cxx/helpers/der/der.h>
-#include <ndn.cxx/helpers/der/visitor/print-visitor.h>
-#include <ndn.cxx/helpers/der/visitor/simple-visitor.h>
+#include "null-ptrs.h"
 #include "logging.h"
 
 using namespace std;
 using namespace ndn;
+using namespace ndn::ptr_lib;
 
 INIT_LOGGER("Profile");
 
@@ -26,47 +25,44 @@
 static string advisor("2.5.4.80");
 static string emailOid("1.2.840.113549.1.9.1");
 
-Profile::Profile(const security::IdentityCertificate& oldIdentityCertificate)
+Profile::Profile(const IdentityCertificate& oldIdentityCertificate)
 {
-  using namespace ndn::security;
-  security::IdentityCertificate identityCertificate(oldIdentityCertificate);
+  IdentityCertificate identityCertificate(oldIdentityCertificate);
 
   Name keyName = identityCertificate.getPublicKeyName();
-  m_identityName = keyName.getPrefix(keyName.size()-1);
+  m_identityName = keyName.getPrefix(-1);
 
   const string& identityString = m_identityName.toUri();
-  Blob identityBlob (identityString.c_str(), identityString.size());
-  m_entries[string("IDENTITY")] = identityBlob;
+  m_entries[string("IDENTITY")] = identityString;
   
-  const vector<CertificateSubDescrypt>& subList = identityCertificate.getSubjectDescriptionList();
-  vector<CertificateSubDescrypt>::const_iterator it = subList.begin();
+  const vector<CertificateSubjectDescription>& subList = identityCertificate.getSubjectDescriptionList();
+  vector<CertificateSubjectDescription>::const_iterator it = subList.begin();
   for(; it != subList.end(); it++)
     {
-      string oidStr = it->getOidStr();
-      Blob blob (it->getValue().c_str(), it->getValue().size());
+      const string oidStr = it->getOidString();
+      string valueStr = it->getValue();
       if(oidStr == nameOid)
-        m_entries[string("name")] = blob;
+        m_entries[string("name")] = valueStr;
       else if(oidStr == orgOid)
-        m_entries[string("institution")] = blob;
+        m_entries[string("institution")] = valueStr;
       else if(oidStr == groupOid)
-        m_entries[string("group")] = blob;
+        m_entries[string("group")] = valueStr;
       else if(oidStr == homepageOid)
-        m_entries[string("homepage")] = blob;
+        m_entries[string("homepage")] = valueStr;
       else if(oidStr == advisor)
-        m_entries[string("advisor")] = blob;
+        m_entries[string("advisor")] = valueStr;
       else if(oidStr == emailOid)
-        m_entries[string("email")] = blob;
+        m_entries[string("email")] = valueStr;
       else
-        m_entries[oidStr] = blob;
+        m_entries[oidStr] = valueStr;
     }
 }
 
 Profile::Profile(const Name& identityName)
   : m_identityName(identityName)
 {
-  const string& nameString = identityName.toUri();
-  Blob identityBlob (nameString.c_str(), nameString.size());
-  m_entries[string("IDENTITY")] = identityBlob;
+  const string& identityString = identityName.toUri();
+  m_entries[string("IDENTITY")] = identityString;
 }
 
 Profile::Profile(const Name& identityName,
@@ -74,15 +70,11 @@
 		 const string& institution)
   : m_identityName(identityName)
 {
-  const string& nameString = identityName.toUri();
-  Blob identityBlob (nameString.c_str(), nameString.size());
-  m_entries[string("IDENTITY")] = identityBlob;
+  const string& identityString = identityName.toUri();
+  m_entries[string("IDENTITY")] = identityString;
 
-  Blob nameBlob (name.c_str(), name.size());
-  Blob institutionBlob (institution.c_str(), institution.size());
-
-  m_entries[string("name")] = nameBlob;
-  m_entries[string("institution")] = institutionBlob;
+  m_entries[string("name")] = name;
+  m_entries[string("institution")] = institution;
 }
 
 Profile::Profile(const Profile& profile)
@@ -92,63 +84,50 @@
 
 void
 Profile::setProfileEntry(const string& profileType,
-			 const Blob& profileValue)
+			 const string& profileValue)
 { m_entries[profileType] = profileValue; }
 
-Ptr<const Blob>
+string
 Profile::getProfileEntry(const string& profileType) const
 {
   if(m_entries.find(profileType) != m_entries.end())
-    return Ptr<Blob>(new Blob(m_entries.at(profileType).buf(), m_entries.at(profileType).size()));
+    return m_entries.at(profileType);
 
-  return NULL;
+  return CHRONOCHAT_NULL_STR;
 }
 
-Ptr<Blob>
-Profile::toDerBlob() const
+void
+Profile::encode(string* output) const
 {
-  Ptr<der::DerSequence> root = Ptr<der::DerSequence>::Create();
-  
-  Ptr<der::DerPrintableString> identityName = Ptr<der::DerPrintableString>(new der::DerPrintableString(m_identityName.toUri()));
-  root->addChild(identityName);
 
-  map<string, Blob>::const_iterator it = m_entries.begin();
+  Chronos::ProfileMsg profileMsg;
+
+  profileMsg.set_identityname(m_identityName.toUri());
+  
+  map<string, string>::const_iterator it = m_entries.begin();
   for(; it != m_entries.end(); it++)
     {
-      Ptr<der::DerSequence> entry = Ptr<der::DerSequence>::Create();
-      Ptr<der::DerPrintableString> type = Ptr<der::DerPrintableString>(new der::DerPrintableString(it->first));
-      Ptr<der::DerOctetString> value = Ptr<der::DerOctetString>(new der::DerOctetString(it->second));
-      entry->addChild(type);
-      entry->addChild(value);
-      root->addChild(entry);
+      Chronos::ProfileMsg::ProfileEntry* profileEntry = profileMsg.add_entry();
+      profileEntry->set_oid(it->first);
+      profileEntry->set_data(it->second);
     }
-  
-  blob_stream blobStream;
-  OutputIterator & start = reinterpret_cast<OutputIterator &> (blobStream);
-  root->encode(start);
 
-  return blobStream.buf ();
+  profileMsg.SerializeToString(output);
 }
 
-Ptr<Profile>
-Profile::fromDerBlob(const Blob& derBlob)
+shared_ptr<Profile>
+Profile::decode(const string& input)
 {
-  boost::iostreams::stream
-    <boost::iostreams::array_source> is (derBlob.buf(), derBlob.size());
+  Chronos::ProfileMsg profileMsg;
+    
+  profileMsg.ParseFromString(input);
 
-  Ptr<der::DerSequence> root = DynamicCast<der::DerSequence>(der::DerNode::parse(reinterpret_cast<InputIterator &>(is)));
-  const der::DerNodePtrList & children = root->getChildren();
-  der::SimpleVisitor simpleVisitor;
-  string identityName = boost::any_cast<string>(children[0]->accept(simpleVisitor));
-  Ptr<Profile> profile = Ptr<Profile>(new Profile(identityName));
+  shared_ptr<Profile> profile = make_shared<Profile>(profileMsg.identityname());
 
-  for(int i = 1; i < children.size(); i++)
+  for(int i = 0; i < profileMsg.entry_size(); i++)
     {
-      Ptr<der::DerSequence> entry = DynamicCast<der::DerSequence>(children[i]);
-      const der::DerNodePtrList & tuple = entry->getChildren();
-      string type = boost::any_cast<string>(tuple[0]->accept(simpleVisitor));
-      Ptr<Blob> value = boost::any_cast<Ptr<Blob> >(tuple[1]->accept(simpleVisitor));
-      profile->setProfileEntry(type, *value);
+      const Chronos::ProfileMsg::ProfileEntry& profileEntry = profileMsg.entry(i);
+      profile->setProfileEntry(profileEntry.oid(), profileEntry.data());
     }
 
   return profile;
diff --git a/src/profile.h b/src/profile.h
index 7a65553..cbd504d 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -11,22 +11,21 @@
 #ifndef LINKNDN_PROFILE_H
 #define LINKNDN_PROFILE_H
 
-#include <ndn.cxx/common.h>
-#include <ndn.cxx/fields/name.h>
-#include <ndn.cxx/fields/blob.h>
-#include <ndn.cxx/security/certificate/identity-certificate.h>
+#include <ndn-cpp/name.hpp>
+#include <ndn-cpp/security/certificate/identity-certificate.hpp>
 #include <map>
 #include <string>
+#include "profile.pb.h"
 
 class Profile
 {
 public:
-  typedef std::map<std::string, ndn::Blob>::iterator iterator;
-  typedef std::map<std::string, ndn::Blob>::const_iterator const_iterator;
+  typedef std::map<std::string, std::string>::iterator iterator;
+  typedef std::map<std::string, std::string>::const_iterator const_iterator;
 public:
   Profile() {}
 
-  Profile(const ndn::security::IdentityCertificate& identityCertificate);
+  Profile(const ndn::IdentityCertificate& identityCertificate);
 
   Profile(const ndn::Name& identityName);
 
@@ -41,9 +40,9 @@
 
   void
   setProfileEntry(const std::string& profileType,
-                  const ndn::Blob& profileValue);
+                  const std::string& profileValue);
   
-  ndn::Ptr<const ndn::Blob>
+  std::string
   getProfileEntry(const std::string& profileType) const;
 
   inline Profile::iterator
@@ -62,25 +61,23 @@
   end() const
   { return m_entries.end(); }
 
-  ndn::Ptr<ndn::Blob>
-  toDerBlob() const;
+  void
+  encode(std::string* output) const;
 
-  static ndn::Ptr<Profile>
-  fromDerBlob(const ndn::Blob& derBlob);
+  static ndn::ptr_lib::shared_ptr<Profile>
+  decode(const std::string& input);
 
-  inline const std::map<std::string, ndn::Blob>&
+  const std::map<std::string, std::string>&
   getEntries() const
   { return m_entries; }
 
-  inline const ndn::Name&
+  const ndn::Name&
   getIdentityName() const
   { return m_identityName; }
 
 protected:
   ndn::Name m_identityName;
-  std::map<std::string, ndn::Blob> m_entries;
+  std::map<std::string, std::string> m_entries;
 };
 
-
-
 #endif
diff --git a/src/profile.proto b/src/profile.proto
new file mode 100644
index 0000000..34f79da
--- /dev/null
+++ b/src/profile.proto
@@ -0,0 +1,12 @@
+package Chronos;
+
+message ProfileMsg
+{
+  required string identityName = 1;
+  message ProfileEntry
+  {
+    required string oid = 1;
+    required string data = 2;
+  }
+  repeated ProfileEntry entry = 2;
+}
\ No newline at end of file
diff --git a/src/profileeditor.cpp b/src/profileeditor.cpp
index 4804431..4abad5a 100644
--- a/src/profileeditor.cpp
+++ b/src/profileeditor.cpp
@@ -20,16 +20,18 @@
 #endif
 
 using namespace ndn;
+using namespace std;
+using namespace ndn::ptr_lib;
 
 INIT_LOGGER("ProfileEditor");
 
-ProfileEditor::ProfileEditor(Ptr<ContactManager> contactManager, 
+ProfileEditor::ProfileEditor(shared_ptr<ContactManager> contactManager, 
                              QWidget *parent) 
     : QDialog(parent)
     , ui(new Ui::ProfileEditor)
     , m_tableModel(new QSqlTableModel())
     , m_contactManager(contactManager)
-    , m_identityManager(ndn::Ptr<ndn::security::IdentityManager>::Create())
+    , m_identityManager(contactManager->getIdentityManager())
 {
   ui->setupUi(this);
   
@@ -83,14 +85,7 @@
 void
 ProfileEditor::onOkClicked()
 {
-  Name defaultKeyName = m_identityManager->getPublicStorage()->getDefaultKeyNameForIdentity(m_currentIdentity);
-  if(defaultKeyName.size() == 0)
-    {
-      emit noKeyOrCert(QString::fromStdString("Corresponding key is missing!\nHave you created the key?"));
-      return;
-    }
-
-  Name defaultCertName = m_identityManager->getPublicStorage()->getDefaultCertificateNameForKey(defaultKeyName);
+  Name defaultCertName = m_identityManager->getDefaultCertificateNameForIdentity(m_currentIdentity);
   if(defaultCertName.size() == 0)
     {
       emit noKeyOrCert(QString::fromStdString("Corresponding certificate is missing!\nHave you installed the certificate?"));
diff --git a/src/profileeditor.h b/src/profileeditor.h
index 7a5c6f7..6f8477c 100644
--- a/src/profileeditor.h
+++ b/src/profileeditor.h
@@ -16,7 +16,7 @@
 
 #ifndef Q_MOC_RUN
 #include "contact-manager.h"
-#include <ndn.cxx/security/identity/identity-manager.h>
+#include <ndn-cpp/security/identity/identity-manager.hpp>
 #endif
 
 namespace Ui {
@@ -28,12 +28,12 @@
     Q_OBJECT
 
 public:
-  explicit ProfileEditor(ndn::Ptr<ContactManager> contactManager, 
+  explicit ProfileEditor(ndn::ptr_lib::shared_ptr<ContactManager> contactManager, 
                          QWidget *parent = 0);
   
   ~ProfileEditor();
 
-  inline void
+  void
   setCurrentIdentity(const ndn::Name& name)
   { m_currentIdentity = name; }
   
@@ -57,8 +57,8 @@
 private:
   Ui::ProfileEditor *ui;
   QSqlTableModel* m_tableModel;
-  ndn::Ptr<ContactManager> m_contactManager;
-  ndn::Ptr<ndn::security::IdentityManager> m_identityManager;
+  ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager;
+  ndn::ptr_lib::shared_ptr<ndn::IdentityManager> m_identityManager;
   ndn::Name m_currentIdentity;
 };
 
diff --git a/src/setaliasdialog.cpp b/src/setaliasdialog.cpp
index c615127..42d8b2d 100644
--- a/src/setaliasdialog.cpp
+++ b/src/setaliasdialog.cpp
@@ -13,9 +13,10 @@
 
 
 using namespace ndn;
+using namespace ndn::ptr_lib;
 using namespace std;
 
-SetAliasDialog::SetAliasDialog(Ptr<ContactManager> contactManager,
+SetAliasDialog::SetAliasDialog(shared_ptr<ContactManager> contactManager,
 			       QWidget *parent) 
   : QDialog(parent)
   , ui(new Ui::SetAliasDialog)
diff --git a/src/setaliasdialog.h b/src/setaliasdialog.h
index 1e24963..4de2255 100644
--- a/src/setaliasdialog.h
+++ b/src/setaliasdialog.h
@@ -26,7 +26,7 @@
   Q_OBJECT
 
 public:
-  explicit SetAliasDialog(ndn::Ptr<ContactManager> contactManager,
+  explicit SetAliasDialog(ndn::ptr_lib::shared_ptr<ContactManager> contactManager,
 			  QWidget *parent = 0);
   ~SetAliasDialog();
 
@@ -46,7 +46,7 @@
 
 private:
   Ui::SetAliasDialog *ui;
-  ndn::Ptr<ContactManager> m_contactManager;
+  ndn::ptr_lib::shared_ptr<ContactManager> m_contactManager;
   std::string m_target;
 };
 
diff --git a/waf-tools/ndn_cpp.py b/waf-tools/ndn_cpp.py
new file mode 100644
index 0000000..d0432ab
--- /dev/null
+++ b/waf-tools/ndn_cpp.py
@@ -0,0 +1,79 @@
+#! /usr/bin/env python
+# encoding: utf-8
+
+'''
+
+When using this tool, the wscript will look like:
+
+	def options(opt):
+	        opt.tool_options('ndn_cpp', tooldir=["waf-tools"])
+
+	def configure(conf):
+		conf.load('compiler_cxx ndn_cpp')
+
+	def build(bld):
+		bld(source='main.cpp', target='app', use='NDNCPP')
+
+Options are generated, in order to specify the location of ndn-cpp includes/libraries.
+
+
+'''
+
+import sys
+import re
+from waflib import Utils,Logs,Errors
+from waflib.Configure import conf
+NDNCPP_DIR=['/usr/local/ndn', '/usr', '/usr/local', '/opt/local','/sw']
+NDNCPP_VERSION_FILE='ndn-cpp-config.h'
+NDNCPP_VERSION_CODE='''
+#include <iostream>
+#include <ndn-cpp/ndn-cpp-config.h>
+int main() { std::cout << NDN_CPP_PACKAGE_VERSION; }
+'''
+
+def options(opt):
+	opt.add_option('--ndn-cpp',type='string',default='/usr/local/ndn',dest='ndn_cpp_dir',help='''path to where ndn-cpp is installed, e.g. /usr/local/ndn''')
+@conf
+def __ndncpp_get_version_file(self,dir):
+	try:
+		return self.root.find_dir(dir).find_node('%s/%s' % ('include/ndn-cpp', NDNCPP_VERSION_FILE))
+	except:
+		return None
+@conf
+def ndncpp_get_version(self,dir):
+	val=self.check_cxx(fragment=NDNCPP_VERSION_CODE,includes=['%s/%s' % (dir, 'include')], execute=True, define_ret = True, mandatory=True)
+	return val
+@conf
+def ndncpp_get_root(self,*k,**kw):
+	root=k and k[0]or kw.get('path',None)
+	# Logs.pprint ('RED', '   %s' %root)
+	if root and self.__ndncpp_get_version_file(root):
+		return root
+	for dir in NDNCPP_DIR:
+		if self.__ndncpp_get_version_file(dir):
+			return dir
+	if root:
+		self.fatal('NDNCPP not found in %s'%root)
+	else:
+		self.fatal('NDNCPP not found, please provide a --ndn-cpp argument (see help)')
+@conf
+def check_ndncpp(self,*k,**kw):
+	if not self.env['CXX']:
+		self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
+
+	var=kw.get('uselib_store','NDNCPP')
+	self.start_msg('Checking ndn-cpp')
+	root = self.ndncpp_get_root(*k,**kw)
+	self.env.NDNCPP_VERSION=self.ndncpp_get_version(root)
+
+	self.env['INCLUDES_%s'%var]= '%s/%s' % (root, "include")
+	self.env['LIB_%s'%var] = "ndn-cpp"
+	self.env['LIBPATH_%s'%var] = '%s/%s' % (root, "lib")
+
+	self.end_msg(self.env.NDNCPP_VERSION)
+	if Logs.verbose:
+		Logs.pprint('CYAN','	NDNCPP include : %s'%self.env['INCLUDES_%s'%var])
+		Logs.pprint('CYAN','	NDNCPP lib     : %s'%self.env['LIB_%s'%var])
+		Logs.pprint('CYAN','	NDNCPP libpath : %s'%self.env['LIBPATH_%s'%var])
+
+
diff --git a/wscript b/wscript
index 3dcfe07..e147a74 100644
--- a/wscript
+++ b/wscript
@@ -7,16 +7,17 @@
 def options(opt):
     opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
     opt.add_option('--log4cxx',action='store_true',default=False,dest='log4cxx',help='''Enable log4cxx''')
+    opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
     
     opt.load('compiler_c compiler_cxx qt4')
 
     if Utils.unversioned_sys_platform () != "darwin":
         opt.load('gnu_dirs');
 
-    opt.load('boost protoc cryptopp', tooldir=['waf-tools'])
+    opt.load('boost protoc cryptopp ndn_cpp', tooldir=['waf-tools'])
     
 def configure(conf):
-    conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp")
+    conf.load("compiler_c compiler_cxx boost protoc qt4 cryptopp ndn_cpp")
 
     if Utils.unversioned_sys_platform () != "darwin":
         conf.load('gnu_dirs');
@@ -35,7 +36,9 @@
     else:
         conf.add_supported_cxxflags (cxxflags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function'])
         
-    conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='NDNCXX', mandatory=True)
+    conf.check_ndncpp (path=conf.options.ndn_cpp_dir)
+    conf.check_cfg(package='libndn-cpp-et', args=['--cflags', '--libs'], uselib_store='NDN-CPP-ET', mandatory=True)
+    
     conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
     if conf.options.log4cxx:
         conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
@@ -43,72 +46,75 @@
 
     conf.check_cryptopp(path=conf.options.cryptopp_dir)
 
-    conf.check_boost(lib='system random thread filesystem')
+    conf.check_boost(lib='system random thread filesystem test')
 
     conf.write_config_header('config.h')
 
+    if conf.options._test:
+      conf.define('_TEST', 1)
 		
 def build (bld):
     qt = bld (
         target = "ChronoChat",
-        features = "qt4 cxx cxxprogram",
+        # features = "qt4 cxx cxxprogram",
+        features= "qt4 cxx cxxshlib",
         defines = "WAF",
         source = bld.path.ant_glob(['src/*.cpp', 'src/*.ui', '*.qrc', 'logging.cc', 'src/*.proto']),
         includes = "src .",
-        use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC",
+        use = "QTCORE QTGUI QTWIDGETS QTSQL SQLITE3 NDNCPP NDN-CPP-ET BOOST BOOST_FILESYSTEM LOG4CXX CRYPTOPP SYNC",
         )
 
-    # if bld.env['DEBUG']:
-    #     cert_publish = bld (
-    #         target = "CertPublish",
-    #         features = "cxx cxxprogram",
-    #         defines = "WAF",
-    #         source = bld.path.ant_glob(['tmp/cert-publish.cpp']),
-    #         includes = ". src",
-    #         use = "SQLITE3 NDNCXX BOOST BOOST_FILESYSTEM LOG4CXX",
-    #         )
+    # Unit tests
+    if bld.get_define("_TEST"):
+      unittests = bld.program (
+          target="unit-tests",
+          source = bld.path.ant_glob(['test/**/*.cc']),
+          features=['cxx', 'cxxprogram'],
+          use = 'BOOST_TEST ChronoChat',
+          includes = ['src'],
+          )
+      # Tmp disable
+#     if Utils.unversioned_sys_platform () == "darwin":
+#         app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
+# <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+# <plist version="0.9">
+# <dict>
+#     <key>CFBundlePackageType</key>
+#     <string>APPL</string>
+#     <key>CFBundleIconFile</key>
+#     <string>demo.icns</string>
+#     <key>CFBundleGetInfoString</key>
+#     <string>Created by Waf</string>
+#     <key>CFBundleIdentifier</key>
+#     <string>edu.ucla.cs.irl.ChronoChat</string>
+#     <key>CFBundleSignature</key>
+#     <string>????</string>
+#     <key>NOTE</key>
+#     <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
+#     <key>CFBundleExecutable</key>
+#     <string>%s</string>
+#     <key>SUPublicDSAKeyFile</key>
+#     <string>dsa_pub.pem</string>
+#     <key>CFBundleIconFile</key>
+#     <string>demo.icns</string>
+# </dict>
+# </plist>'''
 
-    if Utils.unversioned_sys_platform () == "darwin":
-        app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
-<plist version="0.9">
-<dict>
-    <key>CFBundlePackageType</key>
-    <string>APPL</string>
-    <key>CFBundleIconFile</key>
-    <string>demo.icns</string>
-    <key>CFBundleGetInfoString</key>
-    <string>Created by Waf</string>
-    <key>CFBundleIdentifier</key>
-    <string>edu.ucla.cs.irl.ChronoChat</string>
-    <key>CFBundleSignature</key>
-    <string>????</string>
-    <key>NOTE</key>
-    <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
-    <key>CFBundleExecutable</key>
-    <string>%s</string>
-    <key>SUPublicDSAKeyFile</key>
-    <string>dsa_pub.pem</string>
-    <key>CFBundleIconFile</key>
-    <string>demo.icns</string>
-</dict>
-</plist>'''
+#     # <key>LSUIElement</key>
+#     # <string>1</string>
 
-    # <key>LSUIElement</key>
-    # <string>1</string>
-
-        qt.mac_app = "ChronoChat.app"
-        qt.mac_plist = app_plist % "ChronoChat"
-        qt.mac_resources = 'demo.icns'
-    else:
-        bld (features = "subst",
-             source = 'linux/chronochat.desktop.in',
-             target = 'linux/chronochat.desktop',
-             BINARY = "ChronoChat",
-             install_path = "${DATAROOTDIR}/applications"
-            )
-        bld.install_files("${DATAROOTDIR}/chronochat",
-                          bld.path.ant_glob(['linux/Resources/*']))
+#         qt.mac_app = "ChronoChat.app"
+#         qt.mac_plist = app_plist % "ChronoChat"
+#         qt.mac_resources = 'demo.icns'
+#     else:
+#         bld (features = "subst",
+#              source = 'linux/chronochat.desktop.in',
+#              target = 'linux/chronochat.desktop',
+#              BINARY = "ChronoChat",
+#              install_path = "${DATAROOTDIR}/applications"
+#             )
+#         bld.install_files("${DATAROOTDIR}/chronochat",
+#                           bld.path.ant_glob(['linux/Resources/*']))
 
 
 from waflib import TaskGen
