diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index fb792db..7653cd0 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -12,7 +12,7 @@
 #pragma clang diagnostic ignored "-Wtautological-compare"
 #endif
 
-#include "contact-manager.h"
+#include "contact-manager.hpp"
 #include <QStringList>
 #include <QFile>
 
@@ -21,24 +21,33 @@
 #include <ndn-cxx/util/io.hpp>
 #include <ndn-cxx/security/sec-rule-relative.hpp>
 #include <ndn-cxx/security/validator-regex.hpp>
-#include <cryptopp/base64.h>
-#include <cryptopp/files.h>
-#include <cryptopp/sha.h>
-#include <cryptopp/filters.h>
+#include "cryptopp.hpp"
 #include <boost/asio.hpp>
 #include <boost/tokenizer.hpp>
 #include <boost/filesystem.hpp>
 #include "logging.h"
 #endif
 
-using namespace ndn;
 namespace fs = boost::filesystem;
 
-INIT_LOGGER("chronos.ContactManager");
+// INIT_LOGGER("chronos.ContactManager");
 
 namespace chronos{
 
-using ndn::shared_ptr;
+using std::string;
+using std::map;
+using std::vector;
+
+using ndn::Face;
+using ndn::OBufferStream;
+using ndn::IdentityCertificate;
+using ndn::Validator;
+using ndn::ValidatorRegex;
+using ndn::SecRuleRelative;
+using ndn::OnDataValidated;
+using ndn::OnDataValidationFailed;
+using ndn::OnInterestValidated;
+using ndn::OnInterestValidationFailed;
 
 static const uint8_t DNS_RP_SEPARATOR[2] = {0xF0, 0x2E}; // %F0.
 
@@ -52,7 +61,8 @@
 }
 
 ContactManager::~ContactManager()
-{}
+{
+}
 
 // private methods
 shared_ptr<IdentityCertificate>
@@ -62,38 +72,33 @@
 
   QFile anchorFile(":/security/anchor.cert");
 
-  if (!anchorFile.open(QIODevice::ReadOnly))
-    {
-      emit warning(QString("Cannot load trust anchor!"));
-
-      return anchor;
-    }
+  if (!anchorFile.open(QIODevice::ReadOnly)) {
+    emit warning(QString("Cannot load trust anchor!"));
+    return anchor;
+  }
 
   qint64 fileSize = anchorFile.size();
   char* buf = new char[fileSize];
   anchorFile.read(buf, fileSize);
 
-  try
-    {
-      using namespace CryptoPP;
+  try {
+    using namespace CryptoPP;
 
-      OBufferStream os;
-      StringSource(reinterpret_cast<const uint8_t*>(buf), fileSize, true, new Base64Decoder(new FileSink(os)));
-      anchor = make_shared<IdentityCertificate>();
-      anchor->wireDecode(Block(os.buf()));
-    }
-  catch(CryptoPP::Exception& e)
-    {
-      emit warning(QString("Cannot load trust anchor!"));
-    }
-  catch(IdentityCertificate::Error& e)
-    {
-      emit warning(QString("Cannot load trust anchor!"));
-    }
-  catch(Block::Error& e)
-    {
-      emit warning(QString("Cannot load trust anchor!"));
-    }
+    OBufferStream os;
+    StringSource(reinterpret_cast<const uint8_t*>(buf), fileSize, true,
+                 new Base64Decoder(new FileSink(os)));
+    anchor = make_shared<IdentityCertificate>();
+    anchor->wireDecode(Block(os.buf()));
+  }
+  catch (CryptoPP::Exception& e) {
+    emit warning(QString("Cannot load trust anchor!"));
+  }
+  catch (IdentityCertificate::Error& e) {
+    emit warning(QString("Cannot load trust anchor!"));
+  }
+  catch(Block::Error& e) {
+    emit warning(QString("Cannot load trust anchor!"));
+  }
 
   delete [] buf;
 
@@ -141,9 +146,12 @@
   interest.setInterestLifetime(time::milliseconds(1000));
   interest.setMustBeFresh(true);
 
-  OnDataValidated onValidated = bind(&ContactManager::onDnsCollectEndorseValidated, this, _1, identity);
-  OnDataValidationFailed onValidationFailed = bind(&ContactManager::onDnsCollectEndorseValidationFailed, this, _1, _2, identity);
-  TimeoutNotify timeoutNotify = bind(&ContactManager::onDnsCollectEndorseTimeoutNotify, this, _1, identity);
+  OnDataValidated onValidated =
+    bind(&ContactManager::onDnsCollectEndorseValidated, this, _1, identity);
+  OnDataValidationFailed onValidationFailed =
+    bind(&ContactManager::onDnsCollectEndorseValidationFailed, this, _1, _2, identity);
+  TimeoutNotify timeoutNotify =
+    bind(&ContactManager::onDnsCollectEndorseTimeoutNotify, this, _1, identity);
 
   sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, 0);
 }
@@ -151,7 +159,8 @@
 void
 ContactManager::fetchEndorseCertificateInternal(const Name& identity, int certIndex)
 {
-  shared_ptr<EndorseCollection> endorseCollection = m_bufferedContacts[identity].m_endorseCollection;
+  shared_ptr<EndorseCollection> endorseCollection =
+    m_bufferedContacts[identity].m_endorseCollection;
 
   if(certIndex >= endorseCollection->endorsement_size())
     prepareEndorseInfo(identity);
@@ -176,58 +185,51 @@
   // _LOG_DEBUG("prepareEndorseInfo");
   const Profile& profile = m_bufferedContacts[identity].m_selfEndorseCert->getProfile();
 
-  shared_ptr<EndorseInfo> endorseInfo = make_shared<EndorseInfo>();
+  shared_ptr<Chronos::EndorseInfo> endorseInfo = make_shared<Chronos::EndorseInfo>();
   m_bufferedContacts[identity].m_endorseInfo = endorseInfo;
 
-  Profile::const_iterator pIt  = profile.begin();
-  Profile::const_iterator pEnd = profile.end();
-
-  std::map<std::string, int> endorseCount;
-  for(; pIt != pEnd; pIt++)
-    {
-      // _LOG_DEBUG("prepareEndorseInfo: profile[" << pIt->first << "]: " << pIt->second);
-      endorseCount[pIt->first] = 0;
-    }
+  map<string, int> endorseCount;
+  for (Profile::const_iterator pIt = profile.begin(); pIt != profile.end(); pIt++) {
+    // _LOG_DEBUG("prepareEndorseInfo: profile[" << pIt->first << "]: " << pIt->second);
+    endorseCount[pIt->first] = 0;
+  }
 
   int endorseCertCount = 0;
 
-  std::vector<shared_ptr<EndorseCertificate> >::const_iterator cIt  = m_bufferedContacts[identity].m_endorseCertList.begin();
-  std::vector<shared_ptr<EndorseCertificate> >::const_iterator cEnd = m_bufferedContacts[identity].m_endorseCertList.end();
+  vector<shared_ptr<EndorseCertificate> >::const_iterator cIt =
+    m_bufferedContacts[identity].m_endorseCertList.begin();
+  vector<shared_ptr<EndorseCertificate> >::const_iterator cEnd =
+    m_bufferedContacts[identity].m_endorseCertList.end();
 
-  for(; cIt != cEnd; cIt++, endorseCertCount++)
-    {
-      shared_ptr<Contact> contact = getContact((*cIt)->getSigner().getPrefix(-1));
-      if(!static_cast<bool>(contact))
-        continue;
+  for (; cIt != cEnd; cIt++, endorseCertCount++) {
+    shared_ptr<Contact> contact = getContact((*cIt)->getSigner().getPrefix(-1));
+    if (!static_cast<bool>(contact))
+      continue;
 
-      if(!contact->isIntroducer()
-         || !contact->canBeTrustedFor(profile.getIdentityName()))
-        continue;
+    if (!contact->isIntroducer() ||
+        !contact->canBeTrustedFor(profile.getIdentityName()))
+      continue;
 
-      if(!Validator::verifySignature(**cIt, contact->getPublicKey()))
-        continue;
+    if (!Validator::verifySignature(**cIt, contact->getPublicKey()))
+      continue;
 
-      const Profile& tmpProfile = (*cIt)->getProfile();
-      if(tmpProfile != profile)
-        continue;
+    const Profile& tmpProfile = (*cIt)->getProfile();
+    if (tmpProfile != profile)
+      continue;
 
-      const std::vector<std::string>& endorseList = (*cIt)->getEndorseList();
-      std::vector<std::string>::const_iterator eIt = endorseList.begin();
-      for(; eIt != endorseList.end(); eIt++)
-        endorseCount[*eIt] += 1;
-    }
+    const vector<string>& endorseList = (*cIt)->getEndorseList();
+    for (vector<string>::const_iterator eIt = endorseList.begin(); eIt != endorseList.end(); eIt++)
+      endorseCount[*eIt] += 1;
+  }
 
-  pIt  = profile.begin();
-  pEnd = profile.end();
-  for(; pIt != pEnd; pIt++)
-    {
-      EndorseInfo::Endorsement* endorsement = endorseInfo->add_endorsement();
-      endorsement->set_type(pIt->first);
-      endorsement->set_value(pIt->second);
-      std::stringstream ss;
-      ss << endorseCount[pIt->first] << "/" << endorseCertCount;
-      endorsement->set_endorse(ss.str());
-    }
+  for (Profile::const_iterator pIt = profile.begin(); pIt != profile.end(); pIt++) {
+    Chronos::EndorseInfo::Endorsement* endorsement = endorseInfo->add_endorsement();
+    endorsement->set_type(pIt->first);
+    endorsement->set_value(pIt->second);
+    std::stringstream ss;
+    ss << endorseCount[pIt->first] << "/" << endorseCertCount;
+    endorsement->set_endorse(ss.str());
+  }
 
   emit contactEndorseInfoReady (*endorseInfo);
 }
@@ -236,36 +238,32 @@
 ContactManager::onDnsSelfEndorseCertValidated(const shared_ptr<const Data>& data,
                                               const Name& identity)
 {
-  try
-    {
-      Data plainData;
-      plainData.wireDecode(data->getContent().blockFromValue());
-      shared_ptr<EndorseCertificate> selfEndorseCertificate = make_shared<EndorseCertificate>(boost::cref(plainData));
-      if(Validator::verifySignature(plainData, selfEndorseCertificate->getPublicKeyInfo()))
-        {
-          m_bufferedContacts[identity].m_selfEndorseCert = selfEndorseCertificate;
-          fetchCollectEndorse(identity);
-        }
-      else
-        emit contactInfoFetchFailed(QString::fromStdString(identity.toUri()));
+  try {
+    Data plainData;
+    plainData.wireDecode(data->getContent().blockFromValue());
+    shared_ptr<EndorseCertificate> selfEndorseCertificate =
+      make_shared<EndorseCertificate>(boost::cref(plainData));
+    if (Validator::verifySignature(plainData, selfEndorseCertificate->getPublicKeyInfo())) {
+      m_bufferedContacts[identity].m_selfEndorseCert = selfEndorseCertificate;
+      fetchCollectEndorse(identity);
     }
-  catch(Block::Error& e)
-    {
+    else
       emit contactInfoFetchFailed(QString::fromStdString(identity.toUri()));
-    }
-  catch(Data::Error& e)
-    {
-      emit contactInfoFetchFailed(QString::fromStdString(identity.toUri()));
-    }
-  catch(EndorseCertificate::Error& e)
-    {
-      emit contactInfoFetchFailed(QString::fromStdString(identity.toUri()));
-    }
+  }
+  catch(Block::Error& e) {
+    emit contactInfoFetchFailed(QString::fromStdString(identity.toUri()));
+  }
+  catch(Data::Error& e) {
+    emit contactInfoFetchFailed(QString::fromStdString(identity.toUri()));
+  }
+  catch(EndorseCertificate::Error& e) {
+    emit contactInfoFetchFailed(QString::fromStdString(identity.toUri()));
+  }
 }
 
 void
 ContactManager::onDnsSelfEndorseCertValidationFailed(const shared_ptr<const Data>& data,
-                                                     const std::string& failInfo,
+                                                     const string& failInfo,
                                                      const Name& identity)
 {
   // If we cannot validate the Self-Endorse-Certificate, we may retry or fetch id-cert,
@@ -287,37 +285,33 @@
                                              const Name& identity)
 {
   shared_ptr<EndorseCollection> endorseCollection = make_shared<EndorseCollection>();
-  if(!endorseCollection->ParseFromArray(data->getContent().value(), data->getContent().value_size()))
-    {
-      m_bufferedContacts[identity].m_endorseCollection = endorseCollection;
-      fetchEndorseCertificateInternal(identity, 0);
-    }
+  if (!endorseCollection->ParseFromArray(data->getContent().value(),
+                                         data->getContent().value_size())) {
+    m_bufferedContacts[identity].m_endorseCollection = endorseCollection;
+    fetchEndorseCertificateInternal(identity, 0);
+  }
   else
     prepareEndorseInfo(identity);
 }
 
 void
 ContactManager::onDnsCollectEndorseValidationFailed(const shared_ptr<const Data>& data,
-                                                    const std::string& failInfo,
+                                                    const string& failInfo,
                                                     const Name& identity)
 {
   prepareEndorseInfo(identity);
 }
 
 void
-ContactManager::onDnsCollectEndorseTimeoutNotify(const Interest& interest,
-                                                 const Name& identity)
+ContactManager::onDnsCollectEndorseTimeoutNotify(const Interest& interest, const Name& identity)
 {
   // _LOG_DEBUG("onDnsCollectEndorseTimeoutNotify: " << interest.getName());
   prepareEndorseInfo(identity);
 }
 
 void
-ContactManager::onEndorseCertificateInternal(const Interest& interest,
-                                             Data& data,
-                                             const Name& identity,
-                                             int certIndex,
-                                             std::string hash)
+ContactManager::onEndorseCertificateInternal(const Interest& interest, Data& data,
+                                             const Name& identity, int certIndex, string hash)
 {
   std::stringstream ss;
   {
@@ -328,11 +322,11 @@
                  new HashFilter(hash, new FileSink(ss)));
   }
 
-  if(ss.str() == hash)
-    {
-      shared_ptr<EndorseCertificate> endorseCertificate = make_shared<EndorseCertificate>(boost::cref(data));
-      m_bufferedContacts[identity].m_endorseCertList.push_back(endorseCertificate);
-    }
+  if (ss.str() == hash) {
+    shared_ptr<EndorseCertificate> endorseCertificate =
+      make_shared<EndorseCertificate>(boost::cref(data));
+    m_bufferedContacts[identity].m_endorseCertList.push_back(endorseCertificate);
+  }
 
   fetchEndorseCertificateInternal(identity, certIndex+1);
 }
@@ -352,23 +346,20 @@
     boost::recursive_mutex::scoped_lock lock(m_collectCountMutex);
     m_collectCount = m_contactList.size();
 
-    ContactList::iterator it  = m_contactList.begin();
-    ContactList::iterator end = m_contactList.end();
+    for (ContactList::iterator it  = m_contactList.begin(); it != m_contactList.end(); it++) {
+      Name interestName = (*it)->getNameSpace();
+      interestName.append("DNS").append(m_identity.wireEncode()).append("ENDORSEE");
 
-    for(; it != end ; it++)
-      {
-        Name interestName = (*it)->getNameSpace();
-        interestName.append("DNS").append(m_identity.wireEncode()).append("ENDORSEE");
+      Interest interest(interestName);
+      interest.setInterestLifetime(time::milliseconds(1000));
 
-        Interest interest(interestName);
-        interest.setInterestLifetime(time::milliseconds(1000));
+      OnDataValidated onValidated = bind(&ContactManager::onDnsEndorseeValidated, this, _1);
+      OnDataValidationFailed onValidationFailed =
+        bind(&ContactManager::onDnsEndorseeValidationFailed, this, _1, _2);
+      TimeoutNotify timeoutNotify = bind(&ContactManager::onDnsEndorseeTimeoutNotify, this, _1);
 
-        OnDataValidated onValidated = bind(&ContactManager::onDnsEndorseeValidated, this, _1);
-        OnDataValidationFailed onValidationFailed = bind(&ContactManager::onDnsEndorseeValidationFailed, this, _1, _2);
-        TimeoutNotify timeoutNotify = bind(&ContactManager::onDnsEndorseeTimeoutNotify, this, _1);
-
-        sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, 0);
-      }
+      sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, 0);
+    }
   }
 }
 
@@ -385,7 +376,8 @@
 }
 
 void
-ContactManager::onDnsEndorseeValidationFailed(const shared_ptr<const Data>& data, const std::string& failInfo)
+ContactManager::onDnsEndorseeValidationFailed(const shared_ptr<const Data>& data,
+                                              const string& failInfo)
 {
   decreaseCollectStatus();
 }
@@ -441,16 +433,17 @@
 }
 
 void
-ContactManager::onIdentityCertValidationFailed(const shared_ptr<const Data>& data, const std::string& failInfo)
+ContactManager::onIdentityCertValidationFailed(const shared_ptr<const Data>& data,
+                                               const string& failInfo)
 {
-  _LOG_DEBUG("ContactManager::onIdentityCertValidationFailed " << data->getName());
+  // _LOG_DEBUG("ContactManager::onIdentityCertValidationFailed " << data->getName());
   decreaseIdCertCount();
 }
 
 void
 ContactManager::onIdentityCertTimeoutNotify(const Interest& interest)
 {
-  _LOG_DEBUG("ContactManager::onIdentityCertTimeoutNotify: " << interest.getName());
+  // _LOG_DEBUG("ContactManager::onIdentityCertTimeoutNotify: " << interest.getName());
   decreaseIdCertCount();
 }
 
@@ -464,23 +457,20 @@
     count = m_idCertCount;
   }
 
-  if(count == 0)
-    {
-      QStringList certNameList;
-      QStringList nameList;
+  if (count == 0) {
+    QStringList certNameList;
+    QStringList nameList;
 
-      BufferedIdCerts::const_iterator it  = m_bufferedIdCerts.begin();
-      BufferedIdCerts::const_iterator end = m_bufferedIdCerts.end();
-      for(; it != end; it++)
-        {
-          certNameList << QString::fromStdString(it->second->getName().toUri());
-          Profile profile(*(it->second));
-          nameList << QString::fromStdString(profile.get("name"));
-        }
-
-      emit idCertNameListReady(certNameList);
-      emit nameListReady(nameList);
+    for(BufferedIdCerts::const_iterator it = m_bufferedIdCerts.begin();
+        it != m_bufferedIdCerts.end(); it++) {
+      certNameList << QString::fromStdString(it->second->getName().toUri());
+      Profile profile(*(it->second));
+      nameList << QString::fromStdString(profile.get("name"));
     }
+
+    emit idCertNameListReady(certNameList);
+    emit nameListReady(nameList);
+  }
 }
 
 shared_ptr<EndorseCertificate>
@@ -490,13 +480,14 @@
 
   shared_ptr<IdentityCertificate> signingCert = m_keyChain.getCertificate(certificateName);
 
-  std::vector<std::string> endorseList;
-  Profile::const_iterator it = profile.begin();
-  for(; it != profile.end(); it++)
+  vector<string> endorseList;
+  for (Profile::const_iterator it = profile.begin(); it != profile.end(); it++)
     endorseList.push_back(it->first);
 
   shared_ptr<EndorseCertificate> selfEndorseCertificate =
-    shared_ptr<EndorseCertificate>(new EndorseCertificate(*signingCert, profile, endorseList));
+    make_shared<EndorseCertificate>(boost::cref(*signingCert),
+                                    boost::cref(profile),
+                                    boost::cref(endorseList));
 
   m_keyChain.sign(*selfEndorseCertificate, certificateName);
 
@@ -524,12 +515,12 @@
 ContactManager::generateEndorseCertificate(const Name& identity)
 {
   shared_ptr<Contact> contact = getContact(identity);
-  if(!static_cast<bool>(contact))
+  if (!static_cast<bool>(contact))
     return shared_ptr<EndorseCertificate>();
 
   Name signerKeyName = m_keyChain.getDefaultKeyNameForIdentity(m_identity);
 
-  std::vector<std::string> endorseList;
+  vector<string> endorseList;
   m_contactStorage->getEndorseList(identity, endorseList);
 
   shared_ptr<EndorseCertificate> cert =
@@ -561,7 +552,7 @@
 
   m_keyChain.signByIdentity(data, m_identity);
 
-  m_contactStorage->updateDnsEndorseOthers(data, dnsName.get(-3).toEscapedString());
+  m_contactStorage->updateDnsEndorseOthers(data, dnsName.get(-3).toUri());
   m_face->put(data);
 }
 
@@ -597,7 +588,7 @@
                                 const TimeoutNotify& timeoutNotify)
 {
   // _LOG_DEBUG("On interest timeout: " << interest.getName());
-  if(retry > 0)
+  if (retry > 0)
     sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, retry-1);
   else
     timeoutNotify(interest);
@@ -609,25 +600,23 @@
   const Name& interestName = interest.getName();
   shared_ptr<Data> data;
 
-  if(interestName.size() <= prefix.size())
+  if (interestName.size() <= prefix.size())
     return;
 
-  if(interestName.size() == (prefix.size()+1))
-    {
-      data = m_contactStorage->getDnsData("N/A", interestName.get(prefix.size()).toEscapedString());
-      if(static_cast<bool>(data))
-        m_face->put(*data);
-      return;
-    }
+  if (interestName.size() == (prefix.size()+1)) {
+    data = m_contactStorage->getDnsData("N/A", interestName.get(prefix.size()).toUri());
+    if (static_cast<bool>(data))
+      m_face->put(*data);
+    return;
+  }
 
-  if(interestName.size() == (prefix.size()+2))
-    {
-      data = m_contactStorage->getDnsData(interestName.get(prefix.size()).toEscapedString(),
-                                          interestName.get(prefix.size()+1).toEscapedString());
-      if(static_cast<bool>(data))
-        m_face->put(*data);
-      return;
-    }
+  if (interestName.size() == (prefix.size()+2)) {
+    data = m_contactStorage->getDnsData(interestName.get(prefix.size()).toUri(),
+                                        interestName.get(prefix.size()+1).toUri());
+    if (static_cast<bool>(data))
+      m_face->put(*data);
+    return;
+  }
 }
 
 void
@@ -645,14 +634,16 @@
 
   m_contactStorage = make_shared<ContactStorage>(m_identity);
 
-  if(m_dnsListenerId)
+  if (m_dnsListenerId)
     m_face->unsetInterestFilter(m_dnsListenerId);
 
   Name dnsPrefix;
   dnsPrefix.append(m_identity).append("DNS");
   m_dnsListenerId = m_face->setInterestFilter(dnsPrefix,
-                                              bind(&ContactManager::onDnsInterest, this, _1, _2),
-                                              bind(&ContactManager::onDnsRegisterFailed, this, _1, _2));
+                                              bind(&ContactManager::onDnsInterest,
+                                                   this, _1, _2),
+                                              bind(&ContactManager::onDnsRegisterFailed,
+                                                   this, _1, _2));
 
   m_contactList.clear();
   m_contactStorage->getAllContacts(m_contactList);
@@ -676,9 +667,12 @@
   interest.setInterestLifetime(time::milliseconds(1000));
   interest.setMustBeFresh(true);
 
-  OnDataValidated onValidated = bind(&ContactManager::onDnsSelfEndorseCertValidated, this, _1, identityName);
-  OnDataValidationFailed onValidationFailed = bind(&ContactManager::onDnsSelfEndorseCertValidationFailed, this, _1, _2, identityName);
-  TimeoutNotify timeoutNotify = bind(&ContactManager::onDnsSelfEndorseCertTimeoutNotify, this, _1, identityName);
+  OnDataValidated onValidated =
+    bind(&ContactManager::onDnsSelfEndorseCertValidated, this, _1, identityName);
+  OnDataValidationFailed onValidationFailed =
+    bind(&ContactManager::onDnsSelfEndorseCertValidationFailed, this, _1, _2, identityName);
+  TimeoutNotify timeoutNotify =
+    bind(&ContactManager::onDnsSelfEndorseCertTimeoutNotify, this, _1, identityName);
 
   sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, 0);
 }
@@ -691,29 +685,24 @@
   Name identityName(identity.toStdString());
 
   BufferedContacts::const_iterator it = m_bufferedContacts.find(identityName);
-  if(it != m_bufferedContacts.end())
-    {
-      Contact contact(*(it->second.m_selfEndorseCert));
-      // _LOG_DEBUG("onAddFetchedContact: contact ready");
-      try
-        {
-          m_contactStorage->addContact(contact);
-          m_bufferedContacts.erase(identityName);
+  if (it != m_bufferedContacts.end()) {
+    Contact contact(*(it->second.m_selfEndorseCert));
+    // _LOG_DEBUG("onAddFetchedContact: contact ready");
+    try {
+      m_contactStorage->addContact(contact);
+      m_bufferedContacts.erase(identityName);
 
-          m_contactList.clear();
-          m_contactStorage->getAllContacts(m_contactList);
+      m_contactList.clear();
+      m_contactStorage->getAllContacts(m_contactList);
 
-          onWaitForContactList();
-        }
-      catch(ContactStorage::Error& e)
-        {
-          emit warning(QString::fromStdString(e.what()));
-        }
+      onWaitForContactList();
     }
+    catch(ContactStorage::Error& e) {
+      emit warning(QString::fromStdString(e.what()));
+    }
+  }
   else
-    {
-      emit warning(QString("Failure: no information of %1").arg(identity));
-    }
+    emit warning(QString("Failure: no information of %1").arg(identity));
 }
 
 void
@@ -721,12 +710,13 @@
 {
   // Get current profile;
   shared_ptr<Profile> newProfile = m_contactStorage->getSelfProfile();
-  if(!static_cast<bool>(newProfile))
+  if (!static_cast<bool>(newProfile))
     return;
 
-  _LOG_DEBUG("ContactManager::onUpdateProfile: getProfile");
+  // _LOG_DEBUG("ContactManager::onUpdateProfile: getProfile");
 
-  shared_ptr<EndorseCertificate> newEndorseCertificate = getSignedSelfEndorseCertificate(*newProfile);
+  shared_ptr<EndorseCertificate> newEndorseCertificate =
+    getSignedSelfEndorseCertificate(*newProfile);
 
   m_contactStorage->addSelfEndorseCertificate(*newEndorseCertificate);
 
@@ -736,102 +726,98 @@
 void
 ContactManager::onRefreshBrowseContact()
 {
-  std::vector<std::string> bufferedIdCertNames;
-  try
-    {
-      using namespace boost::asio::ip;
-      tcp::iostream request_stream;
-      request_stream.expires_from_now(boost::posix_time::milliseconds(5000));
-      request_stream.connect("ndncert.named-data.net","80");
-      if(!request_stream)
-        {
-          emit warning(QString::fromStdString("Fail to fetch certificate directory! #1"));
-          return;
-        }
-
-      request_stream << "GET /cert/list/ HTTP/1.0\r\n";
-      request_stream << "Host: ndncert.named-data.net\r\n\r\n";
-      request_stream.flush();
-
-      std::string line1;
-      std::getline(request_stream,line1);
-      if (!request_stream)
-        {
-          emit warning(QString::fromStdString("Fail to fetch certificate directory! #2"));
-          return;
-        }
-
-      std::stringstream response_stream(line1);
-      std::string http_version;
-      response_stream >> http_version;
-      unsigned int status_code;
-      response_stream >> status_code;
-      std::string status_message;
-      std::getline(response_stream,status_message);
-
-      if (!response_stream||http_version.substr(0,5)!="HTTP/")
-        {
-          emit warning(QString::fromStdString("Fail to fetch certificate directory! #3"));
-          return;
-        }
-      if (status_code!=200)
-        {
-          emit warning(QString::fromStdString("Fail to fetch certificate directory! #4"));
-          return;
-        }
-      std::vector<std::string> headers;
-      std::string header;
-      while (std::getline(request_stream, header) && header != "\r")
-        headers.push_back(header);
-
-      std::istreambuf_iterator<char> stream_iter (request_stream);
-      std::istreambuf_iterator<char> end_of_stream;
-
-      typedef boost::tokenizer< boost::escaped_list_separator<char>, std::istreambuf_iterator<char> > tokenizer_t;
-      tokenizer_t certItems (stream_iter, end_of_stream,boost::escaped_list_separator<char>('\\', '\n', '"'));
-
-      for (tokenizer_t::iterator it = certItems.begin(); it != certItems.end (); it++)
-        if (!it->empty())
-          bufferedIdCertNames.push_back(*it);
+  vector<string> bufferedIdCertNames;
+  try {
+    using namespace boost::asio::ip;
+    tcp::iostream request_stream;
+    request_stream.expires_from_now(boost::posix_time::milliseconds(5000));
+    request_stream.connect("ndncert.named-data.net","80");
+    if (!request_stream) {
+      emit warning(QString::fromStdString("Fail to fetch certificate directory! #1"));
+      return;
     }
-  catch(std::exception &e)
-    {
-      emit warning(QString::fromStdString("Fail to fetch certificate directory! #N"));
+
+    request_stream << "GET /cert/list/ HTTP/1.0\r\n";
+    request_stream << "Host: ndncert.named-data.net\r\n\r\n";
+    request_stream.flush();
+
+    string line1;
+    std::getline(request_stream,line1);
+    if (!request_stream) {
+      emit warning(QString::fromStdString("Fail to fetch certificate directory! #2"));
+      return;
     }
 
+    std::stringstream response_stream(line1);
+    string http_version;
+    response_stream >> http_version;
+    unsigned int status_code;
+    response_stream >> status_code;
+    string status_message;
+    std::getline(response_stream,status_message);
+
+    if (!response_stream ||
+        http_version.substr(0,5) != "HTTP/") {
+      emit warning(QString::fromStdString("Fail to fetch certificate directory! #3"));
+      return;
+    }
+    if (status_code!=200) {
+      emit warning(QString::fromStdString("Fail to fetch certificate directory! #4"));
+      return;
+    }
+    vector<string> headers;
+    string header;
+    while (std::getline(request_stream, header) && header != "\r")
+      headers.push_back(header);
+
+    std::istreambuf_iterator<char> stream_iter (request_stream);
+    std::istreambuf_iterator<char> end_of_stream;
+
+    typedef boost::tokenizer< boost::escaped_list_separator<char>,
+                              std::istreambuf_iterator<char> > tokenizer_t;
+    tokenizer_t certItems (stream_iter,
+                           end_of_stream,
+                           boost::escaped_list_separator<char>('\\', '\n', '"'));
+
+    for (tokenizer_t::iterator it = certItems.begin(); it != certItems.end (); it++)
+      if (!it->empty())
+        bufferedIdCertNames.push_back(*it);
+  }
+  catch(std::exception &e) {
+    emit warning(QString::fromStdString("Fail to fetch certificate directory! #N"));
+  }
+
   {
     boost::recursive_mutex::scoped_lock lock(m_idCertCountMutex);
     m_idCertCount = bufferedIdCertNames.size();
   }
   m_bufferedIdCerts.clear();
 
-  std::vector<std::string>::const_iterator it  = bufferedIdCertNames.begin();
-  std::vector<std::string>::const_iterator end = bufferedIdCertNames.end();
-  for(; it != end; it++)
-    {
-      Name certName(*it);
+  for (vector<string>::const_iterator it = bufferedIdCertNames.begin();
+       it != bufferedIdCertNames.end(); it++) {
+    Name certName(*it);
 
-      Interest interest(certName);
-      interest.setInterestLifetime(time::milliseconds(1000));
-      interest.setMustBeFresh(true);
+    Interest interest(certName);
+    interest.setInterestLifetime(time::milliseconds(1000));
+    interest.setMustBeFresh(true);
 
-      OnDataValidated onValidated = bind(&ContactManager::onIdentityCertValidated, this, _1);
-      OnDataValidationFailed onValidationFailed = bind(&ContactManager::onIdentityCertValidationFailed, this, _1, _2);
-      TimeoutNotify timeoutNotify = bind(&ContactManager::onIdentityCertTimeoutNotify, this, _1);
+    OnDataValidated onValidated =
+    bind(&ContactManager::onIdentityCertValidated, this, _1);
+    OnDataValidationFailed onValidationFailed =
+    bind(&ContactManager::onIdentityCertValidationFailed, this, _1, _2);
+    TimeoutNotify timeoutNotify =
+    bind(&ContactManager::onIdentityCertTimeoutNotify, this, _1);
 
-      sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, 0);
-    }
-
+    sendInterest(interest, onValidated, onValidationFailed, timeoutNotify, 0);
+  }
 }
 
 void
 ContactManager::onFetchIdCert(const QString& qCertName)
 {
   Name certName(qCertName.toStdString());
-  if(m_bufferedIdCerts.find(certName) != m_bufferedIdCerts.end())
-    {
-      emit idCertReady(*m_bufferedIdCerts[certName]);
-    }
+  if (m_bufferedIdCerts.find(certName) != m_bufferedIdCerts.end())
+    emit idCertReady(*m_bufferedIdCerts[certName]);
 }
 
 void
@@ -841,41 +827,35 @@
   Name identity = IdentityCertificate::certificateNameToPublicKeyName(certName).getPrefix(-1);
 
   BufferedIdCerts::const_iterator it = m_bufferedIdCerts.find(certName);
-  if(it != m_bufferedIdCerts.end())
-    {
-      Contact contact(*it->second);
-      try
-        {
-          m_contactStorage->addContact(contact);
-          m_bufferedIdCerts.erase(certName);
+  if (it != m_bufferedIdCerts.end()) {
+    Contact contact(*it->second);
+    try {
+      m_contactStorage->addContact(contact);
+      m_bufferedIdCerts.erase(certName);
 
-          m_contactList.clear();
-          m_contactStorage->getAllContacts(m_contactList);
+      m_contactList.clear();
+      m_contactStorage->getAllContacts(m_contactList);
 
-          onWaitForContactList();
-        }
-      catch(ContactStorage::Error& e)
-        {
-          emit warning(QString::fromStdString(e.what()));
-        }
+      onWaitForContactList();
     }
+    catch(ContactStorage::Error& e) {
+      emit warning(QString::fromStdString(e.what()));
+    }
+  }
   else
-    emit warning(QString("Failure: no information of %1").arg(QString::fromStdString(identity.toUri())));
+    emit warning(QString("Failure: no information of %1")
+                 .arg(QString::fromStdString(identity.toUri())));
 }
 
 void
 ContactManager::onWaitForContactList()
 {
-  ContactList::const_iterator it  = m_contactList.begin();
-  ContactList::const_iterator end = m_contactList.end();
-
   QStringList aliasList;
   QStringList idList;
-  for(; it != end; it++)
-    {
-      aliasList << QString((*it)->getAlias().c_str());
-      idList << QString((*it)->getNameSpace().toUri().c_str());
-    }
+  for (ContactList::const_iterator it = m_contactList.begin(); it != m_contactList.end(); it++) {
+    aliasList << QString((*it)->getAlias().c_str());
+    idList << QString((*it)->getNameSpace().toUri().c_str());
+  }
 
   emit contactAliasListReady(aliasList);
   emit contactIdListReady(idList);
@@ -884,11 +864,8 @@
 void
 ContactManager::onWaitForContactInfo(const QString& identity)
 {
-  ContactList::const_iterator it  = m_contactList.begin();
-  ContactList::const_iterator end = m_contactList.end();
-
-  for(; it != end; it++)
-    if((*it)->getNameSpace().toUri() == identity.toStdString())
+  for (ContactList::const_iterator it = m_contactList.begin(); it != m_contactList.end(); it++)
+    if ((*it)->getNameSpace().toUri() == identity.toStdString())
       emit contactInfoReady(QString((*it)->getNameSpace().toUri().c_str()),
                             QString((*it)->getName().c_str()),
                             QString((*it)->getInstitution().c_str()),
@@ -927,7 +904,7 @@
   Name identityName(identity.toStdString());
   shared_ptr<EndorseCertificate> newEndorseCertificate = generateEndorseCertificate(identityName);
 
-  if(!static_cast<bool>(newEndorseCertificate))
+  if (!static_cast<bool>(newEndorseCertificate))
     return;
 
   m_contactStorage->addEndorseCertificate(*newEndorseCertificate, identityName);
