diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index f2ff6cc..f755965 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -9,15 +9,7 @@
  */
 
 #if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
 #pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
 #endif
 
 
@@ -26,31 +18,33 @@
 #ifndef Q_MOC_RUN
 #include <ndn-cpp-dev/face.hpp>
 #include <ndn-cpp-dev/security/signature-sha256-with-rsa.hpp>
-#include <ndn-cpp-dev/security/verifier.hpp>
+
+#ifndef WITH_SECURITY
+#include <ndn-cpp-dev/security/validator-null.hpp>
+#else
+#include <ndn-cpp-dev/security/validator-regex.hpp>
 #include <cryptopp/base64.h>
-#include <ndn-cpp-et/policy/sec-rule-relative.hpp>
-#include <ndn-cpp-et/policy/sec-policy-simple.hpp>
-#include <fstream>
+#include <ndn-cpp-dev/security/sec-rule-relative.hpp>
+#endif
+
 #include "endorse-collection.pb.h"
 #include "logging.h"
 #endif
 
 using namespace ndn;
-using namespace ndn::ptr_lib;
 using namespace std;
 
 INIT_LOGGER("ContactManager");
 
-ContactManager::ContactManager(shared_ptr<KeyChain> keyChain, 
-                               shared_ptr<Face> face,
-                               QObject* parent)
-  : QObject(parent),
-    m_face(face)
-{
-  m_keyChain = keyChain;
-  m_contactStorage = make_shared<ContactStorage>();
-  m_dnsStorage = make_shared<DnsStorage>();
+namespace chronos{
 
+ContactManager::ContactManager(shared_ptr<Face> face,
+                               QObject* parent)
+  : QObject(parent)
+  , m_contactStorage(new ContactStorage())
+  , m_dnsStorage(new DnsStorage())
+  , m_face(face)
+{
   initializeSecurity();
 }
 
@@ -60,6 +54,14 @@
 void
 ContactManager::initializeSecurity()
 {
+  
+#ifndef WITH_SECURITY
+  
+  m_keyChain = make_shared<KeyChain>();
+  m_validator = make_shared<ValidatorNull>();
+
+#else
+
   shared_ptr<SecPolicySimple> policy = make_shared<SecPolicySimple>();
   m_verifier = make_shared<Verifier>(policy);
   m_verifier->setFace(m_face);
@@ -116,37 +118,6 @@
   data.wireDecode(Block(reinterpret_cast<const uint8_t*>(decoded.c_str()), decoded.size()));
   shared_ptr<IdentityCertificate> anchor = make_shared<IdentityCertificate>(data);
   policy->addTrustAnchor(anchor);  
-
-#ifdef _DEBUG
-
-  const string FakeAnchor("BIICqgOyEIVAaoHnQZIx5osAuY2fKte4HBSrxyam7MY6/kp+w47O1bGdd2KjeZKV\
-zZzQd3EQorDC3KUPbB6ql30jYfspvo4OPSlIuDrkyROaoZ+MSKyzQYpB6CZcTjBa\
-qcWYFOfwUlcWvkbd00X4bkc5PkcWpVdRrx+NCTiq9EXes//hOHpEJHMNsJUi45O+\
-6M4OE6/sNEqs/ryHn2w1vCqwPpG8xzcd0prQUdCH2MGE77F+H0XFDuWp8mrT37Uw\
-DUy7Ltm+7nDTHSQy2J3Zk4Q+0tjxCzSw4owEpwOHr+afdkuE3v9aB2NRQBBDCEmL\
-Ykz4sYX3XE8MVFqRn1HHWCkszjDg+F0UAADy+p1uZG4A+p1LRVkA+vVrc2stMTM4\
-MjkzNDE5OAD6vUlELUNFUlQA+s39/////95rc7MAAAGiA+IChaK1eVvzlkg6BJAw\
-qiOpxRoezQ0hAHOBbPRLeBllxMN7AAK6tQUm3mtztQAB4gHq8vqdbmRuAPqdS0VZ\
-APr1a3NrLTEzODI5MzQxOTgA+r1JRC1DRVJUAAAAAAABmhblMIIBaDAiGA8yMDEz\
-MTAyODAwMDAwMFoYDzIwMzMxMDI4MDAwMDAwWjAcMBoGA1UEKRMTL25kbi9rc2st\
-MTM4MjkzNDE5ODCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK2htIFF\
-/PH+SJsGOA6jhpFT74xfLJlgZNJOnKzl27HI2gupE0mainWj/HqVzdGxD6jOOReI\
-sul+eQyEyBYq4e35pLmdJGlux/+UPQ51DD8jg04GrUPewV7+iGm6usp/7xEGHbah\
-H2Grv/bsGrt6aRA8cKmdIc+rehxZCVFtiwSEHTnOWzn3lfZR5xnjF9aGX+uGo1hA\
-gMwu1ECxg4H3O4z1tbTzji5+WH0RDsPRlgzQX6wAQH8btlQyoFJfljEA3QaOtDaB\
-OcfegIlClzutmgJnK9i5ZLz2Mjvx49dlCWAVKg65vOXMLC/33jD9F+V8urwsBlOb\
-F7Wh5ayeo8NBKDsCAwEAAQAA");
-
-  string decoded2;
-  CryptoPP::StringSource ss2(reinterpret_cast<const unsigned char *>(FakeAnchor.c_str()), 
-                            FakeAnchor.size(), 
-                            true,
-                            new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded2)));
-  Data data2;
-  data2.wireDecode(Block(reinterpret_cast<const uint8_t*>(decoded.c_str()), decoded.size()));
-  shared_ptr<IdentityCertificate>anchor2 = make_shared<IdentityCertificate>(data2);
-  policy->addTrustAnchor(anchor2);  
-
 #endif
 }
 
@@ -158,206 +129,94 @@
   interestName.append("DNS").append("PROFILE");
   
   Interest interest(interestName);
+  interest.setMustBeFresh(true);
 
-  OnVerified onVerified = func_lib::bind(&ContactManager::onDnsSelfEndorseCertificateVerified, this, _1, identity);
-  OnVerifyFailed onVerifyFailed = func_lib::bind(&ContactManager::onDnsSelfEndorseCertificateVerifyFailed, this, _1, identity);
-  TimeoutNotify timeoutNotify = func_lib::bind(&ContactManager::onDnsSelfEndorseCertificateTimeoutNotify, this, identity);
+  OnDataValidated onValidated = bind(&ContactManager::onDnsSelfEndorseCertValidated, this, _1, identity);
+  OnDataValidationFailed onValidationFailed = bind(&ContactManager::onDnsSelfEndorseCertValidationFailed, this, _1, identity);
+  TimeoutNotify timeoutNotify = bind(&ContactManager::onDnsSelfEndorseCertTimeoutNotify, this, identity);
 
-  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify);
+  sendInterest(interest, onValidated, onValidationFailed, timeoutNotify);
 }
 
 void
-ContactManager::onDnsSelfEndorseCertificateTimeoutNotify(const Name& identity)
-{ emit contactFetchFailed(identity); }
-
-void
-ContactManager::onDnsSelfEndorseCertificateVerified(const shared_ptr<Data>& data, 
-                                                    const Name& identity)
+ContactManager::onDnsSelfEndorseCertValidated(const shared_ptr<const Data>& data, 
+                                              const Name& identity)
 {
   try{
     Data plainData;
-    plainData.wireDecode(Block(data->getContent().value(), data->getContent().value_size()));
+    plainData.wireDecode(data->getContent().blockFromValue());
     EndorseCertificate selfEndorseCertificate(plainData);
-    if(Verifier::verifySignature(plainData, plainData.getSignature(), selfEndorseCertificate.getPublicKeyInfo()))
-      emit contactFetched (selfEndorseCertificate); 
+    if(Validator::verifySignature(plainData, plainData.getSignature(), selfEndorseCertificate.getPublicKeyInfo()))
+      emit contactFetched(selfEndorseCertificate); 
     else
-      emit contactFetchFailed (identity);
-  }catch(std::exception& e){
-    _LOG_ERROR("Exception: " << e.what());
+      emit contactFetchFailed(identity);
+  }catch(...){
     emit contactFetchFailed (identity);
   }
 }
 
 void
-ContactManager::onDnsSelfEndorseCertificateVerifyFailed(const shared_ptr<Data>& data, 
-                                                        const Name& identity)
-{ emit contactFetchFailed (identity); }
-
-void
-ContactManager::fetchCollectEndorse(const ndn::Name& identity)
+ContactManager::fetchCollectEndorse(const Name& identity)
 {
   Name interestName = identity;
   interestName.append("DNS").append("ENDORSED");
 
   Interest interest(interestName);
   interest.setInterestLifetime(1000);
+  interest.setMustBeFresh(true);
 
-  OnVerified onVerified = func_lib::bind(&ContactManager::onDnsCollectEndorseVerified, this, _1, identity);
-  OnVerifyFailed onVerifyFailed = func_lib::bind(&ContactManager::onDnsCollectEndorseVerifyFailed, this, _1, identity);
-  TimeoutNotify timeoutNotify = func_lib::bind(&ContactManager::onDnsCollectEndorseTimeoutNotify, this, identity);
+  OnDataValidated onValidated = bind(&ContactManager::onDnsCollectEndorseValidated, this, _1, identity);
+  OnDataValidationFailed onValidationFailed = bind(&ContactManager::onDnsCollectEndorseValidationFailed, this, _1, identity);
+  TimeoutNotify timeoutNotify = bind(&ContactManager::onDnsCollectEndorseTimeoutNotify, this, identity);
 
-  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify);
+  sendInterest(interest, onValidated, onValidationFailed, 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)
+ContactManager::fetchKey(const Name& certName)
 {
   Name interestName = certName;
   
   Interest interest(interestName);
   interest.setInterestLifetime(1000);
+  interest.setMustBeFresh(true);
 
-  OnVerified onVerified = func_lib::bind(&ContactManager::onKeyVerified, this, _1, certName);
-  OnVerifyFailed onVerifyFailed = func_lib::bind(&ContactManager::onKeyVerifyFailed, this, _1, certName);
-  TimeoutNotify timeoutNotify = func_lib::bind(&ContactManager::onKeyTimeoutNotify, this, certName);
+  OnDataValidated onValidated = bind(&ContactManager::onKeyValidated, this, _1, certName);
+  OnDataValidationFailed onValidationFailed = bind(&ContactManager::onKeyValidationFailed, this, _1, certName);
+  TimeoutNotify timeoutNotify = bind(&ContactManager::onKeyTimeoutNotify, this, certName);
 
-  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify);
+  sendInterest(interest, onValidated, onValidationFailed, timeoutNotify);
 }
 
-
 void
-ContactManager::onKeyVerified(const shared_ptr<Data>& data, const Name& identity)
+ContactManager::onKeyValidated(const shared_ptr<const Data>& data, const Name& identity)
 {
   IdentityCertificate identityCertificate(*data);
-
   Profile profile(identityCertificate);
-  ProfileData profileData(profile);
-
-  Name certificateName = m_keyChain->getDefaultCertificateName();
-  m_keyChain->sign(profileData, certificateName);
 
   try{
-    EndorseCertificate endorseCertificate(identityCertificate, profileData);
-    m_keyChain->sign(endorseCertificate, certificateName);
+    EndorseCertificate endorseCertificate(identityCertificate, profile);
+    m_keyChain->sign(endorseCertificate);
     emit contactKeyFetched (endorseCertificate); 
-  }catch(std::exception& e){
-    _LOG_ERROR("Exception: " << e.what());
+  }catch(...){
     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
 ContactManager::fetchIdCertificate(const Name& certName)
 {
   Name interestName = certName;
   
   Interest interest(interestName);
   interest.setInterestLifetime(1000);
+  interest.setMustBeFresh(true);
 
-  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);
+  OnDataValidated onValidated = bind(&ContactManager::onIdCertValidated, this, _1, certName);
+  OnDataValidationFailed onValidationFailed = bind(&ContactManager::onIdCertValidationFailed, this, _1, certName);
+  TimeoutNotify timeoutNotify = bind(&ContactManager::onIdCertTimeoutNotify, this, certName);
 
-  sendInterest(interest, onVerified, onVerifyFailed, timeoutNotify);
-}
-
-void
-ContactManager::onIdCertificateTimeoutNotify(const Name& identity)
-{ 
-  emit contactCertificateFetchFailed (identity); 
-}
-
-
-void
-ContactManager::onIdCertificateVerified(const shared_ptr<Data>& data, const Name& identity)
-{
-  IdentityCertificate identityCertificate(*data);
-  emit contactCertificateFetched(identityCertificate);
-}
-
-void
-ContactManager::onIdCertificateVerifyFailed(const shared_ptr<Data>& data, const Name& identity)
-{ 
-  emit contactCertificateFetchFailed (identity); 
-}
-
-void
-ContactManager::onTargetData(const shared_ptr<const ndn::Interest>& interest, 
-                             const shared_ptr<Data>& data,
-                             const OnVerified& onVerified,
-                             const OnVerifyFailed& onVerifyFailed)
-{
-  m_verifier->verifyData(data, onVerified, onVerifyFailed);
-}
-
-void
-ContactManager::onTargetTimeout(const shared_ptr<const ndn::Interest>& interest, 
-                                int retry,
-                                const OnVerified& onVerified,
-                                const OnVerifyFailed& onVerifyFailed,
-                                const TimeoutNotify& timeoutNotify)
-{
-  if(retry > 0)
-    sendInterest(*interest, onVerified, onVerifyFailed, timeoutNotify, retry-1);
-  else
-    {
-      _LOG_DEBUG("Interest: " << interest->getName().toUri() << " eventually times out!");
-      timeoutNotify();
-    }
-}
-
-void
-ContactManager::sendInterest(const Interest& interest,
-                             const OnVerified& onVerified,
-                             const OnVerifyFailed& onVerifyFailed,
-                             const TimeoutNotify& timeoutNotify,
-                             int retry /* = 1 */)
-{
-  uint64_t id = m_face->expressInterest(interest, 
-                          boost::bind(&ContactManager::onTargetData, 
-                                      this,
-                                      _1,
-                                      _2,
-                                      onVerified, 
-                                      onVerifyFailed),
-                          boost::bind(&ContactManager::onTargetTimeout,
-                                      this,
-                                      _1,
-                                      retry,
-                                      onVerified,
-                                      onVerifyFailed,
-                                      timeoutNotify));
-
-  // _LOG_DEBUG("id: " << id << " entry id: " << m_face->getNode().getEntryIndexForExpressedInterest(interest.getName()));
+  sendInterest(interest, onValidated, onValidationFailed, timeoutNotify);
 }
 
 void
@@ -365,21 +224,15 @@
 {
   // Get current profile;
   shared_ptr<Profile> newProfile = m_contactStorage->getSelfProfile(identity);
-  if(static_cast<bool>(newProfile))
+  if(!static_cast<bool>(newProfile))
     return;
 
   shared_ptr<EndorseCertificate> newEndorseCertificate = getSignedSelfEndorseCertificate(identity, *newProfile);
 
-  if(static_cast<bool>(newEndorseCertificate))
+  if(!static_cast<bool>(newEndorseCertificate))
     return;
 
-  // Check if profile exists
-  try{
-    Block profileDataBlob = m_contactStorage->getSelfEndorseCertificate(identity);
-    m_contactStorage->updateSelfEndorseCertificate(*newEndorseCertificate, identity);
-  }catch(ContactStorage::Error &e){
-    m_contactStorage->addSelfEndorseCertificate(*newEndorseCertificate, identity);
-  }
+  m_contactStorage->addSelfEndorseCertificate(*newEndorseCertificate, identity);
 
   publishSelfEndorseCertificateInDNS(*newEndorseCertificate);
 }
@@ -389,15 +242,10 @@
 {
   shared_ptr<EndorseCertificate> newEndorseCertificate = generateEndorseCertificate(identity, signerIdentity);
 
-  if(static_cast<bool>(newEndorseCertificate))
+  if(!static_cast<bool>(newEndorseCertificate))
     return;
 
-  try{
-    Block oldEndorseCertificateBlob = m_contactStorage->getEndorseCertificate(identity);
-    m_contactStorage->updateEndorseCertificate(*newEndorseCertificate, identity);
-  }catch(ContactStorage::Error &e){
-    m_contactStorage->addEndorseCertificate(*newEndorseCertificate, identity);
-  }
+  m_contactStorage->addEndorseCertificate(*newEndorseCertificate, identity);
 
   publishEndorseCertificateInDNS(*newEndorseCertificate, signerIdentity);
 }
@@ -406,34 +254,23 @@
 ContactManager::generateEndorseCertificate(const Name& identity, const Name& signerIdentity)
 {
   shared_ptr<ContactItem> contact = getContact(identity);
-  if(static_cast<bool>(contact))
+  if(!static_cast<bool>(contact))
     return shared_ptr<EndorseCertificate>();
 
   Name signerKeyName = m_keyChain->getDefaultKeyNameForIdentity(signerIdentity);
-  Name signerCertName = m_keyChain->getDefaultCertificateNameForIdentity(signerIdentity);
 
   vector<string> endorseList;
   m_contactStorage->getEndorseList(identity, endorseList);
 
-  
   try{
     shared_ptr<EndorseCertificate> cert = make_shared<EndorseCertificate>(contact->getSelfEndorseCertificate(), signerKeyName, endorseList); 
-    m_keyChain->sign(*cert, signerCertName);
+    m_keyChain->signByIdentity(*cert, signerIdentity);
     return cert;
-  }catch(std::exception& e){
-    _LOG_ERROR("Exception: " << e.what());
+  }catch(...){
     return shared_ptr<EndorseCertificate>();
   } 
 }
 
-void
-ContactManager::getContactItemList(vector<shared_ptr<ContactItem> >& contacts)
-{ return m_contactStorage->getAllContacts(contacts); }
-
-shared_ptr<ContactItem>
-ContactManager::getContact(const ndn::Name& contactNamespace)
-{ return m_contactStorage->getContact(contactNamespace); }
-
 shared_ptr<EndorseCertificate>
 ContactManager::getSignedSelfEndorseCertificate(const Name& identity,
                                                 const Profile& profile)
@@ -442,33 +279,28 @@
   if(0 == certificateName.size())
     return shared_ptr<EndorseCertificate>();
 
-  ProfileData profileData(profile);
-  m_keyChain->sign(profileData, certificateName);
-
-  shared_ptr<IdentityCertificate> signingCert = m_keyChain->getCertificate(certificateName);
-  if(static_cast<bool>(signingCert))
-    return shared_ptr<EndorseCertificate>();
-
-  Name signingKeyName = IdentityCertificate::certificateNameToPublicKeyName(signingCert->getName());
-
+  Name signingKeyName = IdentityCertificate::certificateNameToPublicKeyName(certificateName);
   shared_ptr<IdentityCertificate> kskCert;
-  if(signingKeyName.get(-1).toEscapedString().substr(0,4) == string("dsk-"))
+
+  if(signingKeyName.get(-1).toEscapedString().substr(0,4) == "dsk-")
     {
-      SignatureSha256WithRsa dskCertSig(signingCert->getSignature());
-      // HACK! KSK certificate should be retrieved from network.
-      Name keyName = IdentityCertificate::certificateNameToPublicKeyName(dskCertSig.getKeyLocator().getName());
+      shared_ptr<IdentityCertificate> signingCert = m_keyChain->getCertificate(certificateName);
+      if(!static_cast<bool>(signingCert))
+        return shared_ptr<EndorseCertificate>();
 
-      // TODO: check null existing cases.
-      Name kskCertName = m_keyChain->getDefaultCertificateNameForIdentity(keyName.getPrefix(-1));
-
-      kskCert = m_keyChain->getCertificate(kskCertName);
-    }
+      try{
+        SignatureSha256WithRsa dskCertSig(signingCert->getSignature());
+        Name keyName = IdentityCertificate::certificateNameToPublicKeyName(dskCertSig.getKeyLocator().getName());
+        Name kskCertName = m_keyChain->getDefaultCertificateNameForKey(keyName);
+        kskCert = m_keyChain->getCertificate(kskCertName);
+      }catch(...){
+        return shared_ptr<EndorseCertificate>();
+      }
+    }      
   else
-    {
-      kskCert = signingCert;
-    }
+    kskCert = m_keyChain->getCertificate(certificateName);
 
-  if(static_cast<bool>(kskCert))
+  if(!static_cast<bool>(kskCert))
     return shared_ptr<EndorseCertificate>();
 
   vector<string> endorseList;
@@ -477,40 +309,28 @@
     endorseList.push_back(it->first);
   
   try{
-    shared_ptr<EndorseCertificate> selfEndorseCertificate = make_shared<EndorseCertificate>(*kskCert, profileData, endorseList);
+    shared_ptr<EndorseCertificate> selfEndorseCertificate = make_shared<EndorseCertificate>(*kskCert, profile, endorseList);
     m_keyChain->sign(*selfEndorseCertificate, kskCert->getName());
-
     return selfEndorseCertificate;
-  }catch(std::exception& e){
-    _LOG_ERROR("Exception: " << e.what());
+  }catch(...){
     return shared_ptr<EndorseCertificate>();
   } 
 }
 
-
 void
 ContactManager::publishSelfEndorseCertificateInDNS(const EndorseCertificate& selfEndorseCertificate)
 {
   Data data;
 
-  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 identity = selfEndorseCertificate.getPublicKeyName().getPrefix(-1);
 
   Name dnsName = identity;
-  dnsName.append("DNS").append("PROFILE").appendVersion(version);
+  dnsName.append("DNS").append("PROFILE").appendVersion();
   data.setName(dnsName);
-
   data.setContent(selfEndorseCertificate.wireEncode());
 
-  Name signCertName = m_keyChain->getDefaultCertificateNameForIdentity(identity);
-  m_keyChain->sign(data, signCertName);
-
+  m_keyChain->signByIdentity(data, identity);
   m_dnsStorage->updateDnsSelfProfileData(data, identity);
-  
   m_face->put(data);
 }
 
@@ -519,38 +339,26 @@
 {
   Data data;
 
-  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 endorsee = endorseCertificate.getPublicKeyName().getPrefix(-1);
 
   Name dnsName = signerIdentity;
-  dnsName.append("DNS").append(endorsee).append("ENDORSEE").appendVersion(version);
+  dnsName.append("DNS").append(endorsee.wireEncode()).append("ENDORSEE").appendVersion();
   data.setName(dnsName);
 
   data.setContent(endorseCertificate.wireEncode());
 
-  Name signCertName = m_keyChain->getDefaultCertificateNameForIdentity(signerIdentity);
-  m_keyChain->sign(data, signCertName);
-
+  m_keyChain->signByIdentity(data, signerIdentity);
   m_dnsStorage->updateDnsEndorseOthers(data, signerIdentity, endorsee);
-
   m_face->put(data);
 }
 
 void
-ContactManager::publishEndorsedDataInDns(const Name& identity)
+ContactManager::publishCollectEndorsedDataInDNS(const Name& identity)
 {
   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(version);
+  dnsName.append("DNS").append("ENDORSED").appendVersion();
   data.setName(dnsName);
   
   vector<Buffer> collectEndorseList;
@@ -570,27 +378,18 @@
 
   data.setContent(reinterpret_cast<const uint8_t*>(encoded.c_str()), encoded.size());
   
-  Name signCertName = m_keyChain->getDefaultCertificateNameForIdentity(identity);
-  m_keyChain->sign(data, signCertName);
-
+  m_keyChain->signByIdentity(data, identity);
   m_dnsStorage->updateDnsOthersEndorse(data, identity);
-
   m_face->put(data);
 }
 
 void
 ContactManager::addContact(const IdentityCertificate& identityCertificate, const Profile& profile)
 {
-  ProfileData profileData(profile);
-  
-  Name certificateName = m_keyChain->getDefaultCertificateNameForIdentity (m_defaultIdentity);
-  m_keyChain->sign(profileData, certificateName);
-
-
   try{
-    EndorseCertificate endorseCertificate(identityCertificate, profileData);
+    EndorseCertificate endorseCertificate(identityCertificate, profile);
     
-    m_keyChain->sign(endorseCertificate, certificateName);
+    m_keyChain->signByIdentity(endorseCertificate, m_defaultIdentity);
 
     ContactItem contactItem(endorseCertificate);
 
@@ -598,7 +397,7 @@
 
     emit contactAdded(contactItem.getNameSpace());
 
-  }catch(std::exception& e){
+  }catch(std::runtime_error& e){
     emit warning(e.what());
     _LOG_ERROR("Exception: " << e.what());
     return;
@@ -606,15 +405,17 @@
 }
 
 void
-ContactManager::removeContact(const ndn::Name& contactNameSpace)
+ContactManager::removeContact(const Name& contactNameSpace)
 {
   shared_ptr<ContactItem> contact = getContact(contactNameSpace);
-  if(static_cast<bool>(contact))
+  if(!static_cast<bool>(contact))
     return;
   m_contactStorage->removeContact(contactNameSpace);
   emit contactRemoved(contact->getPublicKeyName());
 }
 
+}//chronos
+
 
 #if WAF
 #include "contact-manager.moc"
