diff --git a/src/adl.cpp b/src/adl.cpp
index 57b3307..605cbd6 100644
--- a/src/adl.cpp
+++ b/src/adl.cpp
@@ -45,7 +45,7 @@
 }
 
 int
-Adl::updateAdjacentStatus(string adjName, int s)
+Adl::updateAdjacentStatus(const string& adjName, int s)
 {
   std::list<Adjacent>::iterator it = find(adjName);
   if (it == m_adjList.end())
@@ -57,7 +57,7 @@
 }
 
 Adjacent
-Adl::getAdjacent(string adjName)
+Adl::getAdjacent(const string& adjName)
 {
   Adjacent adj(adjName);
   std::list<Adjacent>::iterator it = find(adjName);
@@ -96,7 +96,7 @@
 
 
 int
-Adl::updateAdjacentLinkCost(string adjName, double lc)
+Adl::updateAdjacentLinkCost(const string& adjName, double lc)
 {
   std::list<Adjacent>::iterator it = find(adjName);
   if (it == m_adjList.end())
@@ -108,7 +108,7 @@
 }
 
 bool
-Adl::isNeighbor(string adjName)
+Adl::isNeighbor(const string& adjName)
 {
   std::list<Adjacent>::iterator it = find(adjName);
   if (it == m_adjList.end())
@@ -119,7 +119,7 @@
 }
 
 void
-Adl::incrementTimedOutInterestCount(string& neighbor)
+Adl::incrementTimedOutInterestCount(const string& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it == m_adjList.end())
@@ -130,7 +130,7 @@
 }
 
 void
-Adl::setTimedOutInterestCount(string& neighbor, int count)
+Adl::setTimedOutInterestCount(const string& neighbor, int count)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it != m_adjList.end())
@@ -140,7 +140,7 @@
 }
 
 int
-Adl::getTimedOutInterestCount(string& neighbor)
+Adl::getTimedOutInterestCount(const string& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it == m_adjList.end())
@@ -151,7 +151,7 @@
 }
 
 int
-Adl::getStatusOfNeighbor(string& neighbor)
+Adl::getStatusOfNeighbor(const string& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it == m_adjList.end())
@@ -162,7 +162,7 @@
 }
 
 void
-Adl::setStatusOfNeighbor(string& neighbor, int status)
+Adl::setStatusOfNeighbor(const string& neighbor, int status)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it != m_adjList.end())
diff --git a/src/adl.hpp b/src/adl.hpp
index 8a7da9f..76f9280 100644
--- a/src/adl.hpp
+++ b/src/adl.hpp
@@ -19,31 +19,31 @@
   insert(Adjacent& adj);
 
   int
-  updateAdjacentStatus(std::string adjName, int s);
+  updateAdjacentStatus(const std::string& adjName, int s);
 
   int
-  updateAdjacentLinkCost(std::string adjName, double lc);
+  updateAdjacentLinkCost(const std::string& adjName, double lc);
 
   std::list<Adjacent>&
   getAdjList();
 
   bool
-  isNeighbor(std::string adjName);
+  isNeighbor(const std::string& adjName);
 
   void
-  incrementTimedOutInterestCount(std::string& neighbor);
+  incrementTimedOutInterestCount(const std::string& neighbor);
 
   int
-  getTimedOutInterestCount(std::string& neighbor);
+  getTimedOutInterestCount(const std::string& neighbor);
 
   int
-  getStatusOfNeighbor(std::string& neighbor);
+  getStatusOfNeighbor(const std::string& neighbor);
 
   void
-  setStatusOfNeighbor(std::string& neighbor, int status);
+  setStatusOfNeighbor(const std::string& neighbor, int status);
 
   void
-  setTimedOutInterestCount(std::string& neighbor, int count);
+  setTimedOutInterestCount(const std::string& neighbor, int count);
 
   void
   addAdjacentsFromAdl(Adl& adl);
@@ -55,7 +55,7 @@
   getNumOfActiveNeighbor();
 
   Adjacent
-  getAdjacent(std::string adjName);
+  getAdjacent(const std::string& adjName);
 
   bool
   isEqual(Adl& adl);
diff --git a/src/communication/data-manager.cpp b/src/communication/data-manager.cpp
index e4cefe5..bcae456 100644
--- a/src/communication/data-manager.cpp
+++ b/src/communication/data-manager.cpp
@@ -17,7 +17,7 @@
 using namespace ndn;
 
 void
-DataManager::processContent(Nlsr& pnlsr, const ndn::Interest& interest,
+DataManager::processContent(const ndn::Interest& interest,
                             const ndn::Data& data, InterestManager& im)
 {
   std::cout << "I: " << interest.toUri() << std::endl;
@@ -26,24 +26,24 @@
   std::string chkString("keys");
   if (nt.doesTokenExist(chkString))
   {
-    processContentKeys(pnlsr, data);
+    processContentKeys(data);
   }
   else
   {
-    if (pnlsr.getKeyManager().verify(data))
+    if (m_nlsr.getKeyManager().verify(data))
     {
       std::cout << "Verified Data Content" << std::endl;
       chkString = "info";
       if (nt.doesTokenExist(chkString))
       {
         string dataContent((char*)data.getContent().value());
-        processContentInfo(pnlsr, dataName, dataContent);
+        processContentInfo(dataName, dataContent);
       }
       chkString = "LSA";
       if (nt.doesTokenExist(chkString))
       {
         string dataContent((char*)data.getContent().value());
-        processContentLsa(pnlsr, dataName, dataContent);
+        processContentLsa(dataName, dataContent);
       }
     }
     else
@@ -54,24 +54,24 @@
 }
 
 void
-DataManager::processContentInfo(Nlsr& pnlsr, string& dataName,
+DataManager::processContentInfo(const string& dataName,
                                 string& dataContent)
 {
   Tokenizer nt(dataName, "/");
   string chkString("info");
   string neighbor = nt.getTokenString(0, nt.getTokenPosition(chkString) - 1);
-  int oldStatus = pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-  int infoIntTimedOutCount = pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+  int oldStatus = m_nlsr.getAdl().getStatusOfNeighbor(neighbor);
+  int infoIntTimedOutCount = m_nlsr.getAdl().getTimedOutInterestCount(neighbor);
   //debugging purpose start
   std::cout << "Before Updates: " << std::endl;
   std::cout << "Neighbor : " << neighbor << std::endl;
   std::cout << "Status: " << oldStatus << std::endl;
   std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
   //debugging purpose end
-  pnlsr.getAdl().setStatusOfNeighbor(neighbor, 1);
-  pnlsr.getAdl().setTimedOutInterestCount(neighbor, 0);
-  int newStatus = pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-  infoIntTimedOutCount = pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+  m_nlsr.getAdl().setStatusOfNeighbor(neighbor, 1);
+  m_nlsr.getAdl().setTimedOutInterestCount(neighbor, 0);
+  int newStatus = m_nlsr.getAdl().getStatusOfNeighbor(neighbor);
+  infoIntTimedOutCount = m_nlsr.getAdl().getTimedOutInterestCount(neighbor);
   //debugging purpose
   std::cout << "After Updates: " << std::endl;
   std::cout << "Neighbor : " << neighbor << std::endl;
@@ -80,22 +80,21 @@
   //debugging purpose end
   if ((oldStatus - newStatus) != 0)  // change in Adjacency list
   {
-    pnlsr.incrementAdjBuildCount();
+    m_nlsr.incrementAdjBuildCount();
     /* Need to schedule event for Adjacency LSA building */
-    if (pnlsr.getIsBuildAdjLsaSheduled() == 0)
+    if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
     {
-      pnlsr.setIsBuildAdjLsaSheduled(1);
+      m_nlsr.setIsBuildAdjLsaSheduled(1);
       // event here
-      pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
-                                         ndn::bind(&Lsdb::scheduledAdjLsaBuild, pnlsr.getLsdb(),
-                                                   boost::ref(pnlsr)));
+      m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
+                                          ndn::bind(&Lsdb::scheduledAdjLsaBuild, m_nlsr.getLsdb(),
+                                                    boost::ref(m_nlsr)));
     }
   }
 }
 
 void
-DataManager::processContentLsa(Nlsr& pnlsr, string& dataName,
-                               string& dataContent)
+DataManager::processContentLsa(const string& dataName, string& dataContent)
 {
   Tokenizer nt(dataName, "/");
   string chkString("LSA");
@@ -114,17 +113,17 @@
   }
   if (lsTypeString == "1")  //Name Lsa
   {
-    processContentNameLsa(pnlsr, origRouter + "/" + lsTypeString,
+    processContentNameLsa(origRouter + "/" + lsTypeString,
                           interestedLsSeqNo, dataContent);
   }
   else if (lsTypeString == "2")  //Adj Lsa
   {
-    processContentAdjLsa(pnlsr, origRouter + "/" + lsTypeString,
+    processContentAdjLsa(origRouter + "/" + lsTypeString,
                          interestedLsSeqNo, dataContent);
   }
   else if (lsTypeString == "3")  //Cor Lsa
   {
-    processContentCorLsa(pnlsr, origRouter + "/" + lsTypeString,
+    processContentCorLsa(origRouter + "/" + lsTypeString,
                          interestedLsSeqNo, dataContent);
   }
   else
@@ -134,15 +133,15 @@
 }
 
 void
-DataManager::processContentNameLsa(Nlsr& pnlsr, string lsaKey,
+DataManager::processContentNameLsa(const string& lsaKey,
                                    uint32_t lsSeqNo, string& dataContent)
 {
-  if (pnlsr.getLsdb().isNameLsaNew(lsaKey, lsSeqNo))
+  if (m_nlsr.getLsdb().isNameLsaNew(lsaKey, lsSeqNo))
   {
     NameLsa nameLsa;
     if (nameLsa.initializeFromContent(dataContent))
     {
-      pnlsr.getLsdb().installNameLsa(pnlsr, nameLsa);
+      m_nlsr.getLsdb().installNameLsa(m_nlsr, nameLsa);
     }
     else
     {
@@ -152,15 +151,15 @@
 }
 
 void
-DataManager::processContentAdjLsa(Nlsr& pnlsr, string lsaKey,
+DataManager::processContentAdjLsa(const string& lsaKey,
                                   uint32_t lsSeqNo, string& dataContent)
 {
-  if (pnlsr.getLsdb().isAdjLsaNew(lsaKey, lsSeqNo))
+  if (m_nlsr.getLsdb().isAdjLsaNew(lsaKey, lsSeqNo))
   {
     AdjLsa adjLsa;
     if (adjLsa.initializeFromContent(dataContent))
     {
-      pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
+      m_nlsr.getLsdb().installAdjLsa(m_nlsr, adjLsa);
     }
     else
     {
@@ -170,15 +169,15 @@
 }
 
 void
-DataManager::processContentCorLsa(Nlsr& pnlsr, string lsaKey,
+DataManager::processContentCorLsa(const string& lsaKey,
                                   uint32_t lsSeqNo, string& dataContent)
 {
-  if (pnlsr.getLsdb().isCorLsaNew(lsaKey, lsSeqNo))
+  if (m_nlsr.getLsdb().isCoordinateLsaNew(lsaKey, lsSeqNo))
   {
-    CorLsa corLsa;
+    CoordinateLsa corLsa;
     if (corLsa.initializeFromContent(dataContent))
     {
-      pnlsr.getLsdb().installCorLsa(pnlsr, corLsa);
+      m_nlsr.getLsdb().installCoordinateLsa(m_nlsr, corLsa);
     }
     else
     {
@@ -188,7 +187,7 @@
 }
 
 void
-DataManager::processContentKeys(Nlsr& pnlsr, const ndn::Data& data)
+DataManager::processContentKeys(const ndn::Data& data)
 {
   std::cout << " processContentKeys called " << std::endl;
   ndn::shared_ptr<ndn::IdentityCertificate> cert =
@@ -201,15 +200,14 @@
   uint32_t seqNum = boost::lexical_cast<uint32_t>(nt.getToken(
                                                     nt.getTokenNumber() - 2));
   std::cout << "Cert Name: " << certName << " Seq Num: " << seqNum << std::endl;
-  if (pnlsr.getKeyManager().verify(pnlsr, *(cert)))
+  if (m_nlsr.getKeyManager().verify(m_nlsr, *(cert)))
   {
-    pnlsr.getKeyManager().addCertificate(cert, seqNum, true);
+    m_nlsr.getKeyManager().addCertificate(cert, seqNum, true);
   }
   else
   {
-    pnlsr.getKeyManager().addCertificate(cert, seqNum, false);
+    m_nlsr.getKeyManager().addCertificate(cert, seqNum, false);
   }
-
-  pnlsr.getKeyManager().printCertStore();
+  m_nlsr.getKeyManager().printCertStore();
 }
 }//namespace nlsr
diff --git a/src/communication/data-manager.hpp b/src/communication/data-manager.hpp
index 153e0a0..ece3fca 100644
--- a/src/communication/data-manager.hpp
+++ b/src/communication/data-manager.hpp
@@ -13,32 +13,37 @@
 class DataManager
 {
 public:
+  DataManager(Nlsr& nlsr)
+    : m_nlsr(nlsr)
+  {}
   void
-  processContent(Nlsr& pnlsr, const ndn::Interest& interest,
+  processContent(const ndn::Interest& interest,
                  const ndn::Data& data, InterestManager& im);
 private:
   void
-  processContentInfo(Nlsr& pnlsr, std::string& dataName,
+  processContentInfo(const std::string& dataName,
                      std::string& dataContent);
 
   void
-  processContentLsa(Nlsr& pnlsr, std::string& dataName,
-                    std::string& dataContent);
+  processContentLsa(const std::string& dataName, std::string& dataContent);
 
   void
-  processContentNameLsa(Nlsr& pnlsr, std::string lsaKey,
+  processContentNameLsa(const std::string& lsaKey,
                         uint32_t lsSeqNo, std::string& dataContent);
 
   void
-  processContentAdjLsa(Nlsr& pnlsr, std::string lsaKey,
+  processContentAdjLsa(const std::string& lsaKey,
                        uint32_t lsSeqNo, std::string& dataContent);
 
   void
-  processContentCorLsa(Nlsr& pnlsr, std::string lsaKey,
+  processContentCorLsa(const std::string& lsaKey,
                        uint32_t lsSeqNo, std::string& dataContent);
 
   void
-  processContentKeys(Nlsr& pnlsr, const ndn::Data& data);
+  processContentKeys(const ndn::Data& data);
+
+private:
+  Nlsr& m_nlsr;
 
 
 };
diff --git a/src/communication/interest-manager.cpp b/src/communication/interest-manager.cpp
index 73a43e9..226efaf 100644
--- a/src/communication/interest-manager.cpp
+++ b/src/communication/interest-manager.cpp
@@ -17,8 +17,7 @@
 using namespace ndn;
 
 void
-InterestManager::processInterest(Nlsr& pnlsr,
-                                 const ndn::Name& name,
+InterestManager::processInterest(const ndn::Name& name,
                                  const ndn::Interest& interest)
 {
   cout << "<< I: " << interest << endl;
@@ -30,45 +29,45 @@
   {
     string nbr = nt.getTokenString(nt.getTokenPosition(chkString) + 1);
     cout << "Neighbor: " << nbr << endl;
-    processInterestInfo(pnlsr, nbr, interest);
+    processInterestInfo(nbr, interest);
   }
   chkString = "LSA";
   if (nt.doesTokenExist(chkString))
   {
-    processInterestLsa(pnlsr, interest);
+    processInterestLsa(interest);
   }
   chkString = "keys";
   if (nt.doesTokenExist(chkString))
   {
-    processInterestKeys(pnlsr, interest);
+    processInterestKeys(interest);
   }
 }
 
 void
-InterestManager::processInterestInfo(Nlsr& pnlsr, string& neighbor,
+InterestManager::processInterestInfo(const string& neighbor,
                                      const ndn::Interest& interest)
 {
-  if (pnlsr.getAdl().isNeighbor(neighbor))
+  if (m_nlsr.getAdl().isNeighbor(neighbor))
   {
     Data data(ndn::Name(interest.getName()).appendVersion());
     data.setFreshnessPeriod(time::seconds(10)); // 10 sec
     data.setContent((const uint8_t*)"info", sizeof("info"));
-    pnlsr.getKeyManager().signData(data);
+    m_nlsr.getKeyManager().signData(data);
     cout << ">> D: " << data << endl;
-    pnlsr.getNlsrFace()->put(data);
-    int status = pnlsr.getAdl().getStatusOfNeighbor(neighbor);
+    m_nlsr.getNlsrFace()->put(data);
+    int status = m_nlsr.getAdl().getStatusOfNeighbor(neighbor);
     if (status == 0)
     {
       string intName = neighbor + "/" + "info" +
-                       pnlsr.getConfParameter().getRouterPrefix();
-      expressInterest(pnlsr, intName, 2,
-                      pnlsr.getConfParameter().getInterestResendTime());
+                       m_nlsr.getConfParameter().getRouterPrefix();
+      expressInterest(intName, 2,
+                      m_nlsr.getConfParameter().getInterestResendTime());
     }
   }
 }
 
 void
-InterestManager::processInterestLsa(Nlsr& pnlsr, const ndn::Interest& interest)
+InterestManager::processInterestLsa(const ndn::Interest& interest)
 {
   string intName = interest.getName().toUri();
   Tokenizer nt(intName, "/");
@@ -94,17 +93,17 @@
   std::cout << "Ls Type: " << interestedLsType << std::endl;
   if (lsTypeString == "1") //Name Lsa
   {
-    processInterestForNameLsa(pnlsr, interest,
+    processInterestForNameLsa(interest,
                               origRouter + "/" + lsTypeString, interestedLsSeqNo);
   }
   else if (lsTypeString == "2") //Adj Lsa
   {
-    processInterestForAdjLsa(pnlsr, interest,
+    processInterestForAdjLsa(interest,
                              origRouter + "/" + lsTypeString, interestedLsSeqNo);
   }
   else if (lsTypeString == "3") //Cor Lsa
   {
-    processInterestForCorLsa(pnlsr, interest,
+    processInterestForCorLsa(interest,
                              origRouter + "/" + lsTypeString, interestedLsSeqNo);
   }
   else
@@ -114,70 +113,67 @@
 }
 
 void
-InterestManager::processInterestForNameLsa(Nlsr& pnlsr,
-                                           const ndn::Interest& interest,
-                                           string lsaKey, uint32_t interestedlsSeqNo)
+InterestManager::processInterestForNameLsa(const ndn::Interest& interest,
+                                           const string& lsaKey, uint32_t interestedlsSeqNo)
 {
-  std::pair<NameLsa&, bool>  nameLsa = pnlsr.getLsdb().getNameLsa(lsaKey);
-  if (nameLsa.second)
+  NameLsa*  nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
+  if (nameLsa != 0)
   {
-    if (nameLsa.first.getLsSeqNo() >= interestedlsSeqNo)
+    if (nameLsa->getLsSeqNo() >= interestedlsSeqNo)
     {
       Data data(ndn::Name(interest.getName()).appendVersion());
       data.setFreshnessPeriod(time::seconds(10)); // 10 sec
-      string content = nameLsa.first.getData();
+      string content = nameLsa->getData();
       data.setContent((const uint8_t*)content.c_str(), content.size());
-      pnlsr.getKeyManager().signData(data);
+      m_nlsr.getKeyManager().signData(data);
       std::cout << ">> D: " << data << std::endl;
-      pnlsr.getNlsrFace()->put(data);
+      m_nlsr.getNlsrFace()->put(data);
     }
   }
 }
 
 void
-InterestManager::processInterestForAdjLsa(Nlsr& pnlsr,
-                                          const ndn::Interest& interest,
-                                          string lsaKey, uint32_t interestedlsSeqNo)
+InterestManager::processInterestForAdjLsa(const ndn::Interest& interest,
+                                          const string& lsaKey, uint32_t interestedlsSeqNo)
 {
-  std::pair<AdjLsa&, bool> adjLsa = pnlsr.getLsdb().getAdjLsa(lsaKey);
-  if (adjLsa.second)
+  AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
+  if (adjLsa != 0)
   {
-    if (adjLsa.first.getLsSeqNo() >= interestedlsSeqNo)
+    if (adjLsa->getLsSeqNo() >= interestedlsSeqNo)
     {
       Data data(ndn::Name(interest.getName()).appendVersion());
       data.setFreshnessPeriod(time::seconds(10)); // 10 sec
-      string content = adjLsa.first.getData();
+      string content = adjLsa->getData();
       data.setContent((const uint8_t*)content.c_str(), content.size());
-      pnlsr.getKeyManager().signData(data);
+      m_nlsr.getKeyManager().signData(data);
       std::cout << ">> D: " << data << std::endl;
-      pnlsr.getNlsrFace()->put(data);
+      m_nlsr.getNlsrFace()->put(data);
     }
   }
 }
 
 void
-InterestManager::processInterestForCorLsa(Nlsr& pnlsr,
-                                          const ndn::Interest& interest,
-                                          string lsaKey, uint32_t interestedlsSeqNo)
+InterestManager::processInterestForCorLsa(const ndn::Interest& interest,
+                                          const string& lsaKey, uint32_t interestedlsSeqNo)
 {
-  std::pair<CorLsa&, bool> corLsa = pnlsr.getLsdb().getCorLsa(lsaKey);
-  if (corLsa.second)
+  CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
+  if (corLsa != 0)
   {
-    if (corLsa.first.getLsSeqNo() >= interestedlsSeqNo)
+    if (corLsa->getLsSeqNo() >= interestedlsSeqNo)
     {
       Data data(ndn::Name(interest.getName()).appendVersion());
       data.setFreshnessPeriod(time::seconds(10)); // 10 sec
-      string content = corLsa.first.getData();
+      string content = corLsa->getData();
       data.setContent((const uint8_t*)content.c_str(), content.size());
-      pnlsr.getKeyManager().signData(data);
+      m_nlsr.getKeyManager().signData(data);
       std::cout << ">> D: " << data << std::endl;
-      pnlsr.getNlsrFace()->put(data);
+      m_nlsr.getNlsrFace()->put(data);
     }
   }
 }
 
 void
-InterestManager::processInterestKeys(Nlsr& pnlsr, const ndn::Interest& interest)
+InterestManager::processInterestKeys(const ndn::Interest& interest)
 {
   std::cout << "processInterestKeys called " << std::endl;
   string intName = interest.getName().toUri();
@@ -192,14 +188,14 @@
   {
     certName = nt.getTokenString(0, nt.getTokenNumber() - 1);
     cout << "Cert Name: " << certName << std::endl;
-    chkCert = pnlsr.getKeyManager().getCertificateFromStore(certName);
+    chkCert = m_nlsr.getKeyManager().getCertificateFromStore(certName);
   }
   else
   {
     certName = nt.getTokenString(0, nt.getTokenNumber() - 2);
     seqNum = boost::lexical_cast<uint32_t>(nt.getToken(nt.getTokenNumber() - 1));
     std::cout << "Cert Name: " << certName << " Seq Num: " << seqNum << std::endl;
-    chkCert = pnlsr.getKeyManager().getCertificateFromStore(certName, seqNum);
+    chkCert = m_nlsr.getKeyManager().getCertificateFromStore(certName, seqNum);
   }
   if (chkCert.second)
   {
@@ -208,7 +204,7 @@
       std::string dn;
       dataName = ndn::Name(interest.getName()).appendVersion();
       std::pair<uint32_t, bool> seqChk =
-        pnlsr.getKeyManager().getCertificateSeqNum(certName);
+        m_nlsr.getKeyManager().getCertificateSeqNum(certName);
       if (seqChk.second)
       {
         dn = dataName.toUri() + "/" + boost::lexical_cast<std::string>(seqChk.first);
@@ -219,7 +215,6 @@
         dn = dataName.toUri() + "/" + boost::lexical_cast<std::string>(10);
         dataName = ndn::Name(dn);
       }
-
     }
     else
     {
@@ -228,15 +223,14 @@
     Data data(dataName.appendVersion());
     data.setFreshnessPeriod(time::seconds(10)); //10 sec
     data.setContent(chkCert.first->wireEncode());
-    pnlsr.getKeyManager().signData(data);
-    pnlsr.getNlsrFace()->put(data);
+    m_nlsr.getKeyManager().signData(data);
+    m_nlsr.getNlsrFace()->put(data);
   }
 }
 
 
 void
-InterestManager::processInterestTimedOut(Nlsr& pnlsr,
-                                         const ndn::Interest& interest)
+InterestManager::processInterestTimedOut(const ndn::Interest& interest)
 {
   std::cout << "Timed out interest : " << interest.getName().toUri() << std::endl;
   string intName = interest.getName().toUri();
@@ -245,94 +239,92 @@
   if (nt.doesTokenExist(chkString))
   {
     string nbr = nt.getTokenString(0, nt.getTokenPosition(chkString) - 1);
-    processInterestTimedOutInfo(pnlsr , nbr , interest);
+    processInterestTimedOutInfo(nbr , interest);
   }
   chkString = "LSA";
   if (nt.doesTokenExist(chkString))
   {
-    processInterestTimedOutLsa(pnlsr, interest);
+    processInterestTimedOutLsa(interest);
   }
 }
 
 void
-InterestManager::processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
+InterestManager::processInterestTimedOutInfo(const string& neighbor,
                                              const ndn::Interest& interest)
 {
-  pnlsr.getAdl().incrementTimedOutInterestCount(neighbor);
-  int status = pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-  int infoIntTimedOutCount = pnlsr.getAdl().getTimedOutInterestCount(neighbor);
+  m_nlsr.getAdl().incrementTimedOutInterestCount(neighbor);
+  int status = m_nlsr.getAdl().getStatusOfNeighbor(neighbor);
+  int infoIntTimedOutCount = m_nlsr.getAdl().getTimedOutInterestCount(neighbor);
   std::cout << "Neighbor: " << neighbor << std::endl;
   std::cout << "Status: " << status << std::endl;
   std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
-  if ((infoIntTimedOutCount < pnlsr.getConfParameter().getInterestRetryNumber()))
+  if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber()))
   {
     string intName = neighbor + "/" + "info" +
-                     pnlsr.getConfParameter().getRouterPrefix();
-    expressInterest(pnlsr, intName, 2,
-                    pnlsr.getConfParameter().getInterestResendTime());
+                     m_nlsr.getConfParameter().getRouterPrefix();
+    expressInterest(intName, 2,
+                    m_nlsr.getConfParameter().getInterestResendTime());
   }
   else if ((status == 1) &&
-           (infoIntTimedOutCount == pnlsr.getConfParameter().getInterestRetryNumber()))
+           (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()))
   {
-    pnlsr.getAdl().setStatusOfNeighbor(neighbor, 0);
-    pnlsr.incrementAdjBuildCount();
-    if (pnlsr.getIsBuildAdjLsaSheduled() == 0)
+    m_nlsr.getAdl().setStatusOfNeighbor(neighbor, 0);
+    m_nlsr.incrementAdjBuildCount();
+    if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
     {
-      pnlsr.setIsBuildAdjLsaSheduled(1);
+      m_nlsr.setIsBuildAdjLsaSheduled(1);
       // event here
-      pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
-                                         ndn::bind(&Lsdb::scheduledAdjLsaBuild,
-                                                   &pnlsr.getLsdb(),
-                                                   boost::ref(pnlsr)));
+      m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
+                                          ndn::bind(&Lsdb::scheduledAdjLsaBuild,
+                                                    &m_nlsr.getLsdb(),
+                                                    boost::ref(m_nlsr)));
     }
   }
 }
 
 void
-InterestManager::processInterestTimedOutLsa(Nlsr& pnlsr,
-                                            const ndn::Interest& interest)
+InterestManager::processInterestTimedOutLsa(const ndn::Interest& interest)
 {
 }
 
 void
-InterestManager::expressInterest(Nlsr& pnlsr, const string& interestNamePrefix,
+InterestManager::expressInterest(const string& interestNamePrefix,
                                  int scope, int seconds)
 {
   std::cout << "Expressing Interest :" << interestNamePrefix << std::endl;
   ndn::Interest i((ndn::Name(interestNamePrefix)));
   i.setInterestLifetime(time::seconds(seconds));
   i.setMustBeFresh(true);
-  pnlsr.getNlsrFace()->expressInterest(i,
-                                       ndn::func_lib::bind(&DataManager::processContent,
-                                                           &pnlsr.getDm(),
-                                                           boost::ref(pnlsr), _1,
-                                                           _2, boost::ref(*this)),
-                                       ndn::func_lib::bind(&InterestManager::processInterestTimedOut,
-                                                           this, boost::ref(pnlsr), _1));
+  m_nlsr.getNlsrFace()->expressInterest(i,
+                                        ndn::bind(&DataManager::processContent,
+                                                  &m_nlsr.getDm(),
+                                                  _1, _2, boost::ref(*this)),
+                                        ndn::bind(&InterestManager::processInterestTimedOut,
+                                                  this, _1));
 }
 
 
 void
-InterestManager::sendScheduledInfoInterest(Nlsr& pnlsr, int seconds)
+InterestManager::sendScheduledInfoInterest(int seconds)
 {
-  std::list<Adjacent> adjList = pnlsr.getAdl().getAdjList();
+  std::list<Adjacent> adjList = m_nlsr.getAdl().getAdjList();
   for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
        ++it)
   {
     string adjName = (*it).getName() + "/" + "info" +
-                     pnlsr.getConfParameter().getRouterPrefix();
-    expressInterest(pnlsr, adjName, 2,
-                    pnlsr.getConfParameter().getInterestResendTime());
+                     m_nlsr.getConfParameter().getRouterPrefix();
+    expressInterest(adjName, 2,
+                    m_nlsr.getConfParameter().getInterestResendTime());
   }
-  scheduleInfoInterest(pnlsr, pnlsr.getConfParameter().getInfoInterestInterval());
+  scheduleInfoInterest(m_nlsr.getConfParameter().getInfoInterestInterval());
 }
 
 void
-InterestManager::scheduleInfoInterest(Nlsr& pnlsr, int seconds)
+InterestManager::scheduleInfoInterest(int seconds)
 {
-  EventId eid = pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
-                                                   ndn::bind(&InterestManager::sendScheduledInfoInterest, this,
-                                                             boost::ref(pnlsr), seconds));
+  EventId eid = m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
+                                                    ndn::bind(&InterestManager::sendScheduledInfoInterest, this,
+                                                              seconds));
 }
 
 
diff --git a/src/communication/interest-manager.hpp b/src/communication/interest-manager.hpp
index 5975e7f..86d590b 100644
--- a/src/communication/interest-manager.hpp
+++ b/src/communication/interest-manager.hpp
@@ -12,57 +12,55 @@
 class InterestManager
 {
 public:
-  InterestManager()
+  InterestManager(Nlsr& nlsr)
+    : m_nlsr(nlsr)
   {
   }
   void
-  processInterest(Nlsr& pnlsr, const ndn::Name& name,
-                  const ndn::Interest& interest);
+  processInterest(const ndn::Name& name, const ndn::Interest& interest);
 
   void
-  processInterestInfo(Nlsr& pnlsr, std::string& neighbor,
-                      const ndn::Interest& interest);
+  processInterestInfo(const std::string& neighbor, const ndn::Interest& interest);
 
   void
-  processInterestLsa(Nlsr& pnlsr, const ndn::Interest& interest);
+  processInterestLsa(const ndn::Interest& interest);
 
   void
-  processInterestForNameLsa(Nlsr& pnlsr, const ndn::Interest& interest,
-                            std::string lsaKey, uint32_t interestedlsSeqNo);
+  processInterestForNameLsa(const ndn::Interest& interest,
+                            const std::string& lsaKey, uint32_t interestedlsSeqNo);
 
   void
-  processInterestForAdjLsa(Nlsr& pnlsr, const ndn::Interest& interest,
-                           std::string lsaKey, uint32_t interestedlsSeqNo);
+  processInterestForAdjLsa(const ndn::Interest& interest,
+                           const std::string& lsaKey, uint32_t interestedlsSeqNo);
 
   void
-  processInterestForCorLsa(Nlsr& pnlsr, const ndn::Interest& interest,
-                           std::string lsaKey, uint32_t interestedlsSeqNo);
+  processInterestForCorLsa(const ndn::Interest& interest,
+                           const std::string& lsaKey, uint32_t interestedlsSeqNo);
 
   void
-  processInterestKeys(Nlsr& pnlsr, const ndn::Interest& interest);
+  processInterestKeys(const ndn::Interest& interest);
 
   void
-  processInterestTimedOut(Nlsr& pnlsr, const ndn::Interest& interest);
+  processInterestTimedOut(const ndn::Interest& interest);
 
   void
-  processInterestTimedOutInfo(Nlsr& pnlsr, std::string& neighbor,
+  processInterestTimedOutInfo(const std::string& neighbor,
                               const ndn::Interest& interest);
 
   void
-  processInterestTimedOutLsa(Nlsr& pnlsr, const ndn::Interest& interest);
+  processInterestTimedOutLsa(const ndn::Interest& interest);
 
   void
-  expressInterest(Nlsr& pnlsr,
-                  const std::string& interestNamePrefix, int scope, int seconds);
+  expressInterest(const std::string& interestNamePrefix, int scope, int seconds);
 
   void
-  sendScheduledInfoInterest(Nlsr& pnlsr, int seconds);
+  sendScheduledInfoInterest(int seconds);
 
   void
-  scheduleInfoInterest(Nlsr& pnlsr, int seconds);
+  scheduleInfoInterest(int seconds);
 
 private:
-
+  Nlsr& m_nlsr;
 
 };
 
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index a38fe98..696f06a 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -81,7 +81,7 @@
         pnlsr.getConfParameter().getChronosyncLsaPrefix() +
         routerName + "/1/" +
         boost::lexical_cast<std::string>(sm.getNameLsaSeq());
-      pnlsr.getIm().expressInterest(pnlsr, lsaPrefix, 3,
+      pnlsr.getIm().expressInterest(lsaPrefix, 3,
                                     pnlsr.getConfParameter().getInterestResendTime());
     }
     if (pnlsr.getLsdb().isAdjLsaNew(routerName + "/2", sm.getAdjLsaSeq()))
@@ -91,17 +91,17 @@
         pnlsr.getConfParameter().getChronosyncLsaPrefix() +
         routerName + "/2/" +
         boost::lexical_cast<std::string>(sm.getAdjLsaSeq());
-      pnlsr.getIm().expressInterest(pnlsr, lsaPrefix, 3,
+      pnlsr.getIm().expressInterest(lsaPrefix, 3,
                                     pnlsr.getConfParameter().getInterestResendTime());
     }
-    if (pnlsr.getLsdb().isCorLsaNew(routerName + "/3", sm.getCorLsaSeq()))
+    if (pnlsr.getLsdb().isCoordinateLsaNew(routerName + "/3", sm.getCorLsaSeq()))
     {
       std::cout << "Updated Cor LSA. Need to fetch it" << std::endl;
       string lsaPrefix =
         pnlsr.getConfParameter().getChronosyncLsaPrefix() +
         routerName + "/3/" +
         boost::lexical_cast<std::string>(sm.getCorLsaSeq());
-      pnlsr.getIm().expressInterest(pnlsr, lsaPrefix, 3,
+      pnlsr.getIm().expressInterest(lsaPrefix, 3,
                                     pnlsr.getConfParameter().getInterestResendTime());
     }
   }
@@ -116,7 +116,7 @@
   {
     string certNamePrefix = certName + "/" +
                             boost::lexical_cast<string>(seqNo);
-    pnlsr.getIm().expressInterest(pnlsr, certNamePrefix, 3,
+    pnlsr.getIm().expressInterest(certNamePrefix, 3,
                                   pnlsr.getConfParameter().getInterestResendTime());
   }
 }
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index a19fa09..eac9db6 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -15,7 +15,7 @@
 using namespace std;
 
 int
-ConfFileProcessor::processConfFile(Nlsr& pnlsr)
+ConfFileProcessor::processConfFile()
 {
   int ret = 0;
   if (!m_confFileName.empty())
@@ -29,7 +29,7 @@
         {
           if (line[0] != '#' && line[0] != '!')
           {
-            ret = processConfCommand(pnlsr, line);
+            ret = processConfCommand(line);
             if (ret == -1)
             {
               break;
@@ -50,85 +50,85 @@
 
 
 int
-ConfFileProcessor::processConfCommand(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommand(string command)
 {
   int ret = 0;
   Tokenizer nt(command, " ");
   if ((nt.getFirstToken() == "network"))
   {
-    ret = processConfCommandNetwork(pnlsr, nt.getRestOfLine());
+    ret = processConfCommandNetwork(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "site-name"))
   {
-    ret = processConfCommandSiteName(pnlsr, nt.getRestOfLine());
+    ret = processConfCommandSiteName(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "root-key-prefix"))
   {
-    ret = processConfCommandRootKeyPrefix(pnlsr, nt.getRestOfLine());
+    ret = processConfCommandRootKeyPrefix(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "router-name"))
   {
-    ret = processConfCommandRouterName(pnlsr, nt.getRestOfLine());
+    ret = processConfCommandRouterName(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "ndnneighbor"))
   {
-    ret = processConfCommandNdnNeighbor(pnlsr, nt.getRestOfLine());
+    ret = processConfCommandNdnNeighbor(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "link-cost"))
   {
-    ret = processConfCommandLinkCost(pnlsr, nt.getRestOfLine());
+    ret = processConfCommandLinkCost(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "ndnname"))
   {
-    ret = processConfCommandNdnName(pnlsr, nt.getRestOfLine());
+    ret = processConfCommandNdnName(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "interest-retry-num"))
   {
-    processConfCommandInterestRetryNumber(pnlsr, nt.getRestOfLine());
+    processConfCommandInterestRetryNumber(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "interest-resend-time"))
   {
-    processConfCommandInterestResendTime(pnlsr, nt.getRestOfLine());
+    processConfCommandInterestResendTime(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "lsa-refresh-time"))
   {
-    processConfCommandLsaRefreshTime(pnlsr, nt.getRestOfLine());
+    processConfCommandLsaRefreshTime(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "max-faces-per-prefix"))
   {
-    processConfCommandMaxFacesPerPrefix(pnlsr, nt.getRestOfLine());
+    processConfCommandMaxFacesPerPrefix(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "log-dir"))
   {
-    processConfCommandLogDir(pnlsr, nt.getRestOfLine());
+    processConfCommandLogDir(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "cert-dir"))
   {
-    processConfCommandCertDir(pnlsr, nt.getRestOfLine());
+    processConfCommandCertDir(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "detailed-logging"))
   {
-    processConfCommandDetailedLogging(pnlsr, nt.getRestOfLine());
+    processConfCommandDetailedLogging(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "debugging"))
   {
-    processConfCommandDebugging(pnlsr, nt.getRestOfLine());
+    processConfCommandDebugging(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "chronosync-sync-prefix"))
   {
-    processConfCommandChronosyncSyncPrefix(pnlsr, nt.getRestOfLine());
+    processConfCommandChronosyncSyncPrefix(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "hyperbolic-cordinate"))
   {
-    processConfCommandHyperbolicCordinate(pnlsr, nt.getRestOfLine());
+    processConfCommandHyperbolicCordinate(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "hyperbolic-routing"))
   {
-    processConfCommandIsHyperbolicCalc(pnlsr, nt.getRestOfLine());
+    processConfCommandIsHyperbolicCalc(nt.getRestOfLine());
   }
   else if ((nt.getFirstToken() == "tunnel-type"))
   {
-    processConfCommandTunnelType(pnlsr, nt.getRestOfLine());
+    processConfCommandTunnelType(nt.getRestOfLine());
   }
   else
   {
@@ -138,7 +138,7 @@
 }
 
 int
-ConfFileProcessor::processConfCommandNetwork(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandNetwork(string command)
 {
   if (command.empty())
   {
@@ -155,13 +155,13 @@
     {
       command.erase(0, 1);
     }
-    pnlsr.getConfParameter().setNetwork(command);
+    m_nlsr.getConfParameter().setNetwork(command);
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandSiteName(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandSiteName(string command)
 {
   if (command.empty())
   {
@@ -178,13 +178,13 @@
     {
       command.erase(0, 1);
     }
-    pnlsr.getConfParameter().setSiteName(command);
+    m_nlsr.getConfParameter().setSiteName(command);
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandRootKeyPrefix(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandRootKeyPrefix(string command)
 {
   if (command.empty())
   {
@@ -201,14 +201,14 @@
     {
       command.erase(0, 1);
     }
-    pnlsr.getConfParameter().setRootKeyPrefix(command);
+    m_nlsr.getConfParameter().setRootKeyPrefix(command);
   }
   return 0;
 }
 
 
 int
-ConfFileProcessor::processConfCommandRouterName(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandRouterName(string command)
 {
   if (command.empty())
   {
@@ -225,14 +225,13 @@
     {
       command.erase(0, 1);
     }
-    pnlsr.getConfParameter().setRouterName(command);
+    m_nlsr.getConfParameter().setRouterName(command);
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandInterestRetryNumber(Nlsr& pnlsr,
-                                                         string command)
+ConfFileProcessor::processConfCommandInterestRetryNumber(string command)
 {
   if (command.empty())
   {
@@ -245,15 +244,14 @@
     ss >> irn;
     if (irn >= 1 && irn <= 5)
     {
-      pnlsr.getConfParameter().setInterestRetryNumber(irn);
+      m_nlsr.getConfParameter().setInterestRetryNumber(irn);
     }
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandInterestResendTime(Nlsr& pnlsr,
-                                                        string command)
+ConfFileProcessor::processConfCommandInterestResendTime(string command)
 {
   if (command.empty())
   {
@@ -266,14 +264,14 @@
     ss >> irt;
     if (irt >= 1 && irt <= 20)
     {
-      pnlsr.getConfParameter().setInterestResendTime(irt);
+      m_nlsr.getConfParameter().setInterestResendTime(irt);
     }
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandLsaRefreshTime(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandLsaRefreshTime(string command)
 {
   if (command.empty())
   {
@@ -286,15 +284,14 @@
     ss >> lrt;
     if (lrt >= 240 && lrt <= 7200)
     {
-      pnlsr.getConfParameter().setLsaRefreshTime(lrt);
+      m_nlsr.getConfParameter().setLsaRefreshTime(lrt);
     }
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandMaxFacesPerPrefix(Nlsr& pnlsr,
-                                                       string command)
+ConfFileProcessor::processConfCommandMaxFacesPerPrefix(string command)
 {
   if (command.empty())
   {
@@ -307,14 +304,14 @@
     ss >> mfpp;
     if (mfpp >= 0 && mfpp <= 60)
     {
-      pnlsr.getConfParameter().setMaxFacesPerPrefix(mfpp);
+      m_nlsr.getConfParameter().setMaxFacesPerPrefix(mfpp);
     }
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandTunnelType(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandTunnelType(string command)
 {
   if (command.empty())
   {
@@ -324,11 +321,11 @@
   {
     if (command == "tcp" || command == "TCP")
     {
-      pnlsr.getConfParameter().setTunnelType(1);
+      m_nlsr.getConfParameter().setTunnelType(1);
     }
     else if (command == "udp" || command == "UDP")
     {
-      pnlsr.getConfParameter().setTunnelType(0);
+      m_nlsr.getConfParameter().setTunnelType(0);
     }
     else
     {
@@ -339,8 +336,7 @@
 }
 
 int
-ConfFileProcessor::processConfCommandChronosyncSyncPrefix(Nlsr& pnlsr,
-                                                          string command)
+ConfFileProcessor::processConfCommandChronosyncSyncPrefix(string command)
 {
   if (command.empty())
   {
@@ -348,14 +344,14 @@
   }
   else
   {
-    pnlsr.getConfParameter().setChronosyncSyncPrefix(command);
+    m_nlsr.getConfParameter().setChronosyncSyncPrefix(command);
   }
   return 0;
 }
 
 
 int
-ConfFileProcessor::processConfCommandLogDir(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandLogDir(string command)
 {
   if (command.empty())
   {
@@ -363,13 +359,13 @@
   }
   else
   {
-    pnlsr.getConfParameter().setLogDir(command);
+    m_nlsr.getConfParameter().setLogDir(command);
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandCertDir(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandCertDir(string command)
 {
   if (command.empty())
   {
@@ -377,13 +373,13 @@
   }
   else
   {
-    pnlsr.getConfParameter().setCertDir(command);
+    m_nlsr.getConfParameter().setCertDir(command);
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandDebugging(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandDebugging(string command)
 {
   if (command.empty())
   {
@@ -393,11 +389,11 @@
   {
     if (command == "on" || command == "ON")
     {
-      pnlsr.getConfParameter().setDebugging(1);
+      m_nlsr.getConfParameter().setDebugging(1);
     }
     else if (command == "off" || command == "off")
     {
-      pnlsr.getConfParameter().setDebugging(0);
+      m_nlsr.getConfParameter().setDebugging(0);
     }
     else
     {
@@ -408,8 +404,7 @@
 }
 
 int
-ConfFileProcessor::processConfCommandDetailedLogging(Nlsr& pnlsr,
-                                                     string command)
+ConfFileProcessor::processConfCommandDetailedLogging(string command)
 {
   if (command.empty())
   {
@@ -419,11 +414,11 @@
   {
     if (command == "on" || command == "ON")
     {
-      pnlsr.getConfParameter().setDetailedLogging(1);
+      m_nlsr.getConfParameter().setDetailedLogging(1);
     }
     else if (command == "off" || command == "off")
     {
-      pnlsr.getConfParameter().setDetailedLogging(0);
+      m_nlsr.getConfParameter().setDetailedLogging(0);
     }
     else
     {
@@ -434,8 +429,7 @@
 }
 
 int
-ConfFileProcessor::processConfCommandIsHyperbolicCalc(Nlsr& pnlsr,
-                                                      string command)
+ConfFileProcessor::processConfCommandIsHyperbolicCalc(string command)
 {
   if (command.empty())
   {
@@ -445,15 +439,15 @@
   {
     if (command == "on" || command == "ON")
     {
-      pnlsr.getConfParameter().setIsHyperbolicCalc(1);
+      m_nlsr.getConfParameter().setIsHyperbolicCalc(1);
     }
     else if (command == "dry-run" || command == "DRY-RUN")
     {
-      pnlsr.getConfParameter().setIsHyperbolicCalc(2);
+      m_nlsr.getConfParameter().setIsHyperbolicCalc(2);
     }
     else if (command == "off" || command == "off")
     {
-      pnlsr.getConfParameter().setIsHyperbolicCalc(0);
+      m_nlsr.getConfParameter().setIsHyperbolicCalc(0);
     }
     else
     {
@@ -464,13 +458,12 @@
 }
 
 int
-ConfFileProcessor::processConfCommandHyperbolicCordinate(Nlsr& pnlsr,
-                                                         string command)
+ConfFileProcessor::processConfCommandHyperbolicCordinate(string command)
 {
   if (command.empty())
   {
     cerr << " Wrong command format ! [hyperbolic-cordinate r 0]!" << endl;
-    if (pnlsr.getConfParameter().getIsHyperbolicCalc() > 0)
+    if (m_nlsr.getConfParameter().getIsHyperbolicCalc() > 0)
     {
       return -1;
     }
@@ -483,15 +476,15 @@
     double r, theta;
     ssr >> r;
     sst >> theta;
-    pnlsr.getConfParameter().setCorR(r);
-    pnlsr.getConfParameter().setCorTheta(theta);
+    m_nlsr.getConfParameter().setCorR(r);
+    m_nlsr.getConfParameter().setCorTheta(theta);
   }
   return 0;
 }
 
 
 int
-ConfFileProcessor::processConfCommandNdnNeighbor(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandNdnNeighbor(string command)
 {
   if (command.empty())
   {
@@ -511,14 +504,14 @@
       int faceId;
       sst >> faceId;
       Adjacent adj(nt.getFirstToken(), faceId, 0.0, 0, 0);
-      pnlsr.getAdl().insert(adj);
+      m_nlsr.getAdl().insert(adj);
     }
   }
   return 0;
 }
 
 int
-ConfFileProcessor::processConfCommandNdnName(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandNdnName(string command)
 {
   if (command.empty())
   {
@@ -526,19 +519,19 @@
   }
   else
   {
-    pnlsr.getNpl().insert(command);
+    m_nlsr.getNpl().insert(command);
   }
   return 0;
 }
 
 
 int
-ConfFileProcessor::processConfCommandLinkCost(Nlsr& pnlsr, string command)
+ConfFileProcessor::processConfCommandLinkCost(string command)
 {
   if (command.empty())
   {
     cerr << " Wrong command format ! [link-cost nbr/name cost]!" << endl;
-    if (pnlsr.getConfParameter().getIsHyperbolicCalc() > 0)
+    if (m_nlsr.getConfParameter().getIsHyperbolicCalc() > 0)
     {
       return -1;
     }
@@ -549,7 +542,7 @@
     stringstream sst(nt.getRestOfLine().c_str());
     double cost;
     sst >> cost;
-    pnlsr.getAdl().updateAdjacentLinkCost(nt.getFirstToken(), cost);
+    m_nlsr.getAdl().updateAdjacentLinkCost(nt.getFirstToken(), cost);
   }
   return 0;
 }
diff --git a/src/conf-file-processor.hpp b/src/conf-file-processor.hpp
index a17ba12..c4015a3 100644
--- a/src/conf-file-processor.hpp
+++ b/src/conf-file-processor.hpp
@@ -4,85 +4,83 @@
 #include "nlsr.hpp"
 
 namespace nlsr {
+
 class ConfFileProcessor
 {
 public:
-  ConfFileProcessor()
-    : m_confFileName()
+  ConfFileProcessor(Nlsr& nlsr, const string& cfile)
+    : m_confFileName(cfile)
+    , m_nlsr(nlsr)
   {
   }
 
-  ConfFileProcessor(const string& cfile)
-  {
-    m_confFileName = cfile;
-  }
-
-  int processConfFile(Nlsr& pnlsr);
+  int processConfFile();
 
 private:
   int
-  processConfCommand(Nlsr& pnlsr, string command);
+  processConfCommand(string command);
 
   int
-  processConfCommandNetwork(Nlsr& pnlsr, string command);
+  processConfCommandNetwork(string command);
 
   int
-  processConfCommandSiteName(Nlsr& pnlsr, string command);
+  processConfCommandSiteName(string command);
 
   int
-  processConfCommandRootKeyPrefix(Nlsr& pnlsr, string command);
+  processConfCommandRootKeyPrefix(string command);
 
   int
-  processConfCommandRouterName(Nlsr& pnlsr, string command);
+  processConfCommandRouterName(string command);
 
   int
-  processConfCommandInterestRetryNumber(Nlsr& pnlsr, string command);
+  processConfCommandInterestRetryNumber(string command);
 
   int
-  processConfCommandInterestResendTime(Nlsr& pnlsr, string command);
+  processConfCommandInterestResendTime(string command);
 
   int
-  processConfCommandLsaRefreshTime(Nlsr& pnlsr, string command);
+  processConfCommandLsaRefreshTime(string command);
 
   int
-  processConfCommandMaxFacesPerPrefix(Nlsr& pnlsr, string command);
+  processConfCommandMaxFacesPerPrefix(string command);
 
   int
-  processConfCommandTunnelType(Nlsr& pnlsr, string command);
+  processConfCommandTunnelType(string command);
 
   int
-  processConfCommandChronosyncSyncPrefix(Nlsr& pnlsr, string command);
+  processConfCommandChronosyncSyncPrefix(string command);
 
   int
-  processConfCommandLogDir(Nlsr& pnlsr, string command);
+  processConfCommandLogDir(string command);
 
   int
-  processConfCommandCertDir(Nlsr& pnlsr, string command);
+  processConfCommandCertDir(string command);
 
   int
-  processConfCommandDebugging(Nlsr& pnlsr, string command);
+  processConfCommandDebugging(string command);
 
   int
-  processConfCommandDetailedLogging(Nlsr& pnlsr, string command);
+  processConfCommandDetailedLogging(string command);
 
   int
-  processConfCommandIsHyperbolicCalc(Nlsr& pnlsr, string command);
+  processConfCommandIsHyperbolicCalc(string command);
 
   int
-  processConfCommandHyperbolicCordinate(Nlsr& pnlsr, string command);
+  processConfCommandHyperbolicCordinate(string command);
 
   int
-  processConfCommandNdnNeighbor(Nlsr& pnlsr, string command);
+  processConfCommandNdnNeighbor(string command);
 
   int
-  processConfCommandNdnName(Nlsr& pnlsr, string command);
+  processConfCommandNdnName(string command);
 
   int
-  processConfCommandLinkCost(Nlsr& pnlsr, string command);
+  processConfCommandLinkCost(string command);
 
 
 private:
   string m_confFileName;
+  Nlsr& m_nlsr;
 };
 
 } //namespace nlsr
diff --git a/src/lsa.cpp b/src/lsa.cpp
index 0bd450c..e2b6dcf 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -18,7 +18,7 @@
 
 
 string
-NameLsa::getKey()
+NameLsa::getKey() const
 {
   string key;
   key = m_origRouter + "/" + boost::lexical_cast<std::string>(1);
@@ -110,8 +110,9 @@
 
 
 
-CorLsa::CorLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt
-               , double r, double theta)
+CoordinateLsa::CoordinateLsa(string origR, uint8_t lst, uint32_t lsn,
+                             uint32_t lt
+                             , double r, double theta)
 {
   m_origRouter = origR;
   m_lsType = lst;
@@ -122,7 +123,7 @@
 }
 
 string
-CorLsa::getKey()
+CoordinateLsa::getKey() const
 {
   string key;
   key = m_origRouter + "/" + boost::lexical_cast<std::string>(3);
@@ -130,7 +131,7 @@
 }
 
 bool
-CorLsa::isEqual(CorLsa& clsa)
+CoordinateLsa::isEqual(const CoordinateLsa& clsa)
 {
   return (std::abs(m_corRad - clsa.getCorRadius()) <
           std::numeric_limits<double>::epsilon()) &&
@@ -139,7 +140,7 @@
 }
 
 string
-CorLsa::getData()
+CoordinateLsa::getData()
 {
   string corLsaData;
   corLsaData = m_origRouter + "|";
@@ -152,7 +153,7 @@
 }
 
 bool
-CorLsa::initializeFromContent(string content)
+CoordinateLsa::initializeFromContent(string content)
 {
   Tokenizer nt(content, "|");
   m_origRouter = nt.getNextToken();
@@ -176,7 +177,7 @@
 }
 
 std::ostream&
-operator<<(std::ostream& os, CorLsa& cLsa)
+operator<<(std::ostream& os, const CoordinateLsa& cLsa)
 {
   os << "Cor Lsa: " << endl;
   os << "  Origination Router: " << cLsa.getOrigRouter() << endl;
diff --git a/src/lsa.hpp b/src/lsa.hpp
index 23ff395..c795159 100644
--- a/src/lsa.hpp
+++ b/src/lsa.hpp
@@ -118,7 +118,7 @@
   }
 
   std::string
-  getKey();
+  getKey() const;
 
   std::string
   getData();
@@ -194,10 +194,10 @@
 std::ostream&
 operator<<(std::ostream& os, AdjLsa& aLsa);
 
-class CorLsa: public Lsa
+class CoordinateLsa: public Lsa
 {
 public:
-  CorLsa()
+  CoordinateLsa()
     : Lsa()
     , m_corRad(0)
     , m_corTheta(0)
@@ -205,11 +205,11 @@
     setLsType(3);
   }
 
-  CorLsa(std::string origR, uint8_t lst, uint32_t lsn, uint32_t lt
-         , double r, double theta);
+  CoordinateLsa(std::string origR, uint8_t lst, uint32_t lsn, uint32_t lt
+                , double r, double theta);
 
   std::string
-  getKey();
+  getKey() const;
 
   std::string
   getData();
@@ -218,7 +218,7 @@
   initializeFromContent(std::string content);
 
   double
-  getCorRadius()
+  getCorRadius() const
   {
     if (m_corRad >= 0)
     {
@@ -237,7 +237,7 @@
   }
 
   double
-  getCorTheta()
+  getCorTheta() const
   {
     return m_corTheta;
   }
@@ -249,7 +249,7 @@
   }
 
   bool
-  isEqual(CorLsa& clsa);
+  isEqual(const CoordinateLsa& clsa);
 
 private:
   double m_corRad;
@@ -258,7 +258,7 @@
 };
 
 std::ostream&
-operator<<(std::ostream& os, CorLsa& cLsa);
+operator<<(std::ostream& os, const CoordinateLsa& cLsa);
 
 
 }//namespace nlsr
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index de65646..e4bbb4f 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -14,7 +14,7 @@
 }
 
 static bool
-nameLsaCompareByKey(NameLsa& nlsa1, string& key)
+nameLsaCompareByKey(const NameLsa& nlsa1, const string& key)
 {
   return nlsa1.getKey() == key;
 }
@@ -32,27 +32,26 @@
   return installNameLsa(pnlsr, nameLsa);
 }
 
-std::pair<NameLsa&, bool>
-Lsdb::getNameLsa(string key)
+NameLsa*
+Lsdb::findNameLsa(const string key)
 {
   std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
                                                  m_nameLsdb.end(),
                                                  bind(nameLsaCompareByKey, _1, key));
   if (it != m_nameLsdb.end())
   {
-    return std::make_pair(boost::ref((*it)), true);
+    return &(*it);
   }
-  NameLsa nlsa;
-  return std::make_pair(boost::ref(nlsa), false);
+  return 0;
 }
 
 bool
 Lsdb::isNameLsaNew(string key, uint64_t seqNo)
 {
-  std::pair<NameLsa&, bool>  nameLsaCheck = getNameLsa(key);
-  if (nameLsaCheck.second)
+  NameLsa* nameLsaCheck = findNameLsa(key);
+  if (nameLsaCheck != 0)
   {
-    if (nameLsaCheck.first.getLsSeqNo() < seqNo)
+    if (nameLsaCheck->getLsSeqNo() < seqNo)
     {
       return true;
     }
@@ -76,8 +75,8 @@
 Lsdb::installNameLsa(Nlsr& pnlsr, NameLsa& nlsa)
 {
   int timeToExpire = m_lsaRefreshTime;
-  std::pair<NameLsa&, bool> chkNameLsa = getNameLsa(nlsa.getKey());
-  if (!chkNameLsa.second)
+  NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
+  if (chkNameLsa == 0)
   {
     addNameLsa(nlsa);
     nlsa.writeLog();
@@ -107,23 +106,23 @@
   }
   else
   {
-    if (chkNameLsa.first.getLsSeqNo() < nlsa.getLsSeqNo())
+    if (chkNameLsa->getLsSeqNo() < nlsa.getLsSeqNo())
     {
-      chkNameLsa.first.writeLog();
-      chkNameLsa.first.setLsSeqNo(nlsa.getLsSeqNo());
-      chkNameLsa.first.setLifeTime(nlsa.getLifeTime());
-      chkNameLsa.first.getNpl().sort();
+      chkNameLsa->writeLog();
+      chkNameLsa->setLsSeqNo(nlsa.getLsSeqNo());
+      chkNameLsa->setLifeTime(nlsa.getLifeTime());
+      chkNameLsa->getNpl().sort();
       nlsa.getNpl().sort();
       std::list<string> nameToAdd;
       std::set_difference(nlsa.getNpl().getNameList().begin(),
                           nlsa.getNpl().getNameList().end(),
-                          chkNameLsa.first.getNpl().getNameList().begin(),
-                          chkNameLsa.first.getNpl().getNameList().end(),
+                          chkNameLsa->getNpl().getNameList().begin(),
+                          chkNameLsa->getNpl().getNameList().end(),
                           std::inserter(nameToAdd, nameToAdd.begin()));
       for (std::list<string>::iterator it = nameToAdd.begin(); it != nameToAdd.end();
            ++it)
       {
-        chkNameLsa.first.addName((*it));
+        chkNameLsa->addName((*it));
         if (nlsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
         {
           if ((*it) != pnlsr.getConfParameter().getRouterPrefix())
@@ -133,15 +132,15 @@
         }
       }
       std::list<string> nameToRemove;
-      std::set_difference(chkNameLsa.first.getNpl().getNameList().begin(),
-                          chkNameLsa.first.getNpl().getNameList().end(),
+      std::set_difference(chkNameLsa->getNpl().getNameList().begin(),
+                          chkNameLsa->getNpl().getNameList().end(),
                           nlsa.getNpl().getNameList().begin(),
                           nlsa.getNpl().getNameList().end(),
                           std::inserter(nameToRemove, nameToRemove.begin()));
       for (std::list<string>::iterator it = nameToRemove.begin();
            it != nameToRemove.end(); ++it)
       {
-        chkNameLsa.first.removeName((*it));
+        chkNameLsa->removeName((*it));
         if (nlsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
         {
           if ((*it) != pnlsr.getConfParameter().getRouterPrefix())
@@ -155,12 +154,12 @@
         timeToExpire = nlsa.getLifeTime();
       }
       cancelScheduleLsaExpiringEvent(pnlsr,
-                                     chkNameLsa.first.getExpiringEventId());
-      chkNameLsa.first.setExpiringEventId(scheduleNameLsaExpiration(pnlsr,
-                                                                    nlsa.getKey(),
-                                                                    nlsa.getLsSeqNo(),
-                                                                    timeToExpire));
-      chkNameLsa.first.writeLog();
+                                     chkNameLsa->getExpiringEventId());
+      chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(pnlsr,
+                                                               nlsa.getKey(),
+                                                               nlsa.getLsSeqNo(),
+                                                               timeToExpire));
+      chkNameLsa->writeLog();
     }
   }
   return true;
@@ -236,46 +235,45 @@
 
 
 static bool
-corLsaCompareByKey(CorLsa& clsa, string& key)
+corLsaCompareByKey(const CoordinateLsa& clsa, const string& key)
 {
   return clsa.getKey() == key;
 }
 
 bool
-Lsdb::buildAndInstallOwnCorLsa(Nlsr& pnlsr)
+Lsdb::buildAndInstallOwnCoordinateLsa(Nlsr& pnlsr)
 {
-  CorLsa corLsa(pnlsr.getConfParameter().getRouterPrefix()
-                , 3
-                , pnlsr.getSm().getCorLsaSeq() + 1
-                , pnlsr.getConfParameter().getRouterDeadInterval()
-                , pnlsr.getConfParameter().getCorR()
-                , pnlsr.getConfParameter().getCorTheta());
+  CoordinateLsa corLsa(pnlsr.getConfParameter().getRouterPrefix()
+                       , 3
+                       , pnlsr.getSm().getCorLsaSeq() + 1
+                       , pnlsr.getConfParameter().getRouterDeadInterval()
+                       , pnlsr.getConfParameter().getCorR()
+                       , pnlsr.getConfParameter().getCorTheta());
   pnlsr.getSm().setCorLsaSeq(pnlsr.getSm().getCorLsaSeq() + 1);
-  installCorLsa(pnlsr, corLsa);
+  installCoordinateLsa(pnlsr, corLsa);
   return true;
 }
 
-std::pair<CorLsa&, bool>
-Lsdb::getCorLsa(string key)
+CoordinateLsa*
+Lsdb::findCoordinateLsa(const string& key)
 {
-  std::list<CorLsa>::iterator it = std::find_if(m_corLsdb.begin(),
-                                                m_corLsdb.end(),
-                                                bind(corLsaCompareByKey, _1, key));
+  std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
+                                                       m_corLsdb.end(),
+                                                       bind(corLsaCompareByKey, _1, key));
   if (it != m_corLsdb.end())
   {
-    return std::make_pair(boost::ref((*it)), true);
+    return &(*it);
   }
-  CorLsa clsa;
-  return std::make_pair(boost::ref(clsa), false);
+  return 0;
 }
 
 bool
-Lsdb::isCorLsaNew(string key, uint64_t seqNo)
+Lsdb::isCoordinateLsaNew(const string& key, uint64_t seqNo)
 {
-  std::pair<CorLsa&, bool>  corLsaCheck = getCorLsa(key);
-  if (corLsaCheck.second)
+  CoordinateLsa* clsa = findCoordinateLsa(key);
+  if (clsa != 0)
   {
-    if (corLsaCheck.first.getLsSeqNo() < seqNo)
+    if (clsa->getLsSeqNo() < seqNo)
     {
       return true;
     }
@@ -288,22 +286,23 @@
 }
 
 ndn::EventId
-Lsdb::scheduleCorLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime)
+Lsdb::scheduleCoordinateLsaExpiration(Nlsr& pnlsr, const string& key, int seqNo,
+                                      int expTime)
 {
   return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
-                                            ndn::bind(&Lsdb::exprireOrRefreshCorLsa,
+                                            ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
                                                       this, boost::ref(pnlsr),
                                                       key, seqNo));
 }
 
 bool
-Lsdb::installCorLsa(Nlsr& pnlsr, CorLsa& clsa)
+Lsdb::installCoordinateLsa(Nlsr& pnlsr, CoordinateLsa& clsa)
 {
   int timeToExpire = m_lsaRefreshTime;
-  std::pair<CorLsa&, bool> chkCorLsa = getCorLsa(clsa.getKey());
-  if (!chkCorLsa.second)
+  CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
+  if (chkCorLsa == 0)
   {
-    addCorLsa(clsa);
+    addCoordinateLsa(clsa);
     printCorLsdb(); //debugging purpose
     if (clsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
     {
@@ -318,19 +317,19 @@
     {
       timeToExpire = clsa.getLifeTime();
     }
-    scheduleCorLsaExpiration(pnlsr, clsa.getKey(),
-                             clsa.getLsSeqNo(), timeToExpire);
+    scheduleCoordinateLsaExpiration(pnlsr, clsa.getKey(),
+                                    clsa.getLsSeqNo(), timeToExpire);
   }
   else
   {
-    if (chkCorLsa.first.getLsSeqNo() < clsa.getLsSeqNo())
+    if (chkCorLsa->getLsSeqNo() < clsa.getLsSeqNo())
     {
-      chkCorLsa.first.setLsSeqNo(clsa.getLsSeqNo());
-      chkCorLsa.first.setLifeTime(clsa.getLifeTime());
-      if (!chkCorLsa.first.isEqual(clsa))
+      chkCorLsa->setLsSeqNo(clsa.getLsSeqNo());
+      chkCorLsa->setLifeTime(clsa.getLifeTime());
+      if (!chkCorLsa->isEqual(clsa))
       {
-        chkCorLsa.first.setCorRadius(clsa.getCorRadius());
-        chkCorLsa.first.setCorTheta(clsa.getCorTheta());
+        chkCorLsa->setCorRadius(clsa.getCorRadius());
+        chkCorLsa->setCorTheta(clsa.getCorTheta());
         if (pnlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
         {
           pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
@@ -341,23 +340,23 @@
         timeToExpire = clsa.getLifeTime();
       }
       cancelScheduleLsaExpiringEvent(pnlsr,
-                                     chkCorLsa.first.getExpiringEventId());
-      chkCorLsa.first.setExpiringEventId(scheduleCorLsaExpiration(pnlsr,
-                                                                  clsa.getKey(),
-                                                                  clsa.getLsSeqNo(),
-                                                                  timeToExpire));
+                                     chkCorLsa->getExpiringEventId());
+      chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(pnlsr,
+                                                                    clsa.getKey(),
+                                                                    clsa.getLsSeqNo(),
+                                                                    timeToExpire));
     }
   }
   return true;
 }
 
 bool
-Lsdb::addCorLsa(CorLsa& clsa)
+Lsdb::addCoordinateLsa(CoordinateLsa& clsa)
 {
-  std::list<CorLsa>::iterator it = std::find_if(m_corLsdb.begin(),
-                                                m_corLsdb.end(),
-                                                bind(corLsaCompareByKey, _1,
-                                                     clsa.getKey()));
+  std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
+                                                       m_corLsdb.end(),
+                                                       bind(corLsaCompareByKey, _1,
+                                                            clsa.getKey()));
   if (it == m_corLsdb.end())
   {
     m_corLsdb.push_back(clsa);
@@ -367,11 +366,11 @@
 }
 
 bool
-Lsdb::removeCorLsa(Nlsr& pnlsr, string& key)
+Lsdb::removeCoordinateLsa(Nlsr& pnlsr, const string& key)
 {
-  std::list<CorLsa>::iterator it = std::find_if(m_corLsdb.begin(),
-                                                m_corLsdb.end(),
-                                                bind(corLsaCompareByKey, _1, key));
+  std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
+                                                       m_corLsdb.end(),
+                                                       bind(corLsaCompareByKey, _1, key));
   if (it != m_corLsdb.end())
   {
     if ((*it).getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
@@ -385,11 +384,11 @@
 }
 
 bool
-Lsdb::doesCorLsaExist(string key)
+Lsdb::doesCoordinateLsaExist(const string& key)
 {
-  std::list<CorLsa>::iterator it = std::find_if(m_corLsdb.begin(),
-                                                m_corLsdb.end(),
-                                                bind(corLsaCompareByKey, _1, key));
+  std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
+                                                       m_corLsdb.end(),
+                                                       bind(corLsaCompareByKey, _1, key));
   if (it == m_corLsdb.end())
   {
     return false;
@@ -401,7 +400,7 @@
 Lsdb::printCorLsdb() //debugging
 {
   cout << "---------------Cor LSDB-------------------" << endl;
-  for (std::list<CorLsa>::iterator it = m_corLsdb.begin();
+  for (std::list<CoordinateLsa>::iterator it = m_corLsdb.begin();
        it != m_corLsdb.end() ; it++)
   {
     cout << (*it) << endl;
@@ -468,28 +467,27 @@
   return false;
 }
 
-std::pair<AdjLsa&, bool>
-Lsdb::getAdjLsa(string key)
+AdjLsa*
+Lsdb::findAdjLsa(const string key)
 {
   std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
                                                 m_adjLsdb.end(),
                                                 bind(adjLsaCompareByKey, _1, key));
   if (it != m_adjLsdb.end())
   {
-    return std::make_pair(boost::ref((*it)), true);
+    return &(*it);
   }
-  AdjLsa alsa;
-  return std::make_pair(boost::ref(alsa), false);
+  return 0;
 }
 
 
 bool
 Lsdb::isAdjLsaNew(string key, uint64_t seqNo)
 {
-  std::pair<AdjLsa&, bool>  adjLsaCheck = getAdjLsa(key);
-  if (adjLsaCheck.second)
+  AdjLsa*  adjLsaCheck = findAdjLsa(key);
+  if (adjLsaCheck != 0)
   {
-    if (adjLsaCheck.first.getLsSeqNo() < seqNo)
+    if (adjLsaCheck->getLsSeqNo() < seqNo)
     {
       return true;
     }
@@ -515,8 +513,8 @@
 Lsdb::installAdjLsa(Nlsr& pnlsr, AdjLsa& alsa)
 {
   int timeToExpire = m_lsaRefreshTime;
-  std::pair<AdjLsa&, bool> chkAdjLsa = getAdjLsa(alsa.getKey());
-  if (!chkAdjLsa.second)
+  AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
+  if (chkAdjLsa == 0)
   {
     addAdjLsa(alsa);
     alsa.addNptEntries(pnlsr);
@@ -530,26 +528,25 @@
   }
   else
   {
-    if (chkAdjLsa.first.getLsSeqNo() < alsa.getLsSeqNo())
+    if (chkAdjLsa->getLsSeqNo() < alsa.getLsSeqNo())
     {
-      chkAdjLsa.first.setLsSeqNo(alsa.getLsSeqNo());
-      chkAdjLsa.first.setLifeTime(alsa.getLifeTime());
-      if (!chkAdjLsa.first.isEqual(alsa))
+      chkAdjLsa->setLsSeqNo(alsa.getLsSeqNo());
+      chkAdjLsa->setLifeTime(alsa.getLifeTime());
+      if (!chkAdjLsa->isEqual(alsa))
       {
-        chkAdjLsa.first.getAdl().reset();
-        chkAdjLsa.first.getAdl().addAdjacentsFromAdl(alsa.getAdl());
+        chkAdjLsa->getAdl().reset();
+        chkAdjLsa->getAdl().addAdjacentsFromAdl(alsa.getAdl());
         pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
       }
       if (alsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
       {
         timeToExpire = alsa.getLifeTime();
       }
-      cancelScheduleLsaExpiringEvent(pnlsr,
-                                     chkAdjLsa.first.getExpiringEventId());
-      chkAdjLsa.first.setExpiringEventId(scheduleAdjLsaExpiration(pnlsr,
-                                                                  alsa.getKey(),
-                                                                  alsa.getLsSeqNo(),
-                                                                  timeToExpire));
+      cancelScheduleLsaExpiringEvent(pnlsr, chkAdjLsa->getExpiringEventId());
+      chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(pnlsr,
+                                                             alsa.getKey(),
+                                                             alsa.getLsSeqNo(),
+                                                             timeToExpire));
     }
   }
   return true;
@@ -622,19 +619,19 @@
 {
   cout << "Lsdb::exprireOrRefreshNameLsa Called " << endl;
   cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
-  std::pair<NameLsa&, bool> chkNameLsa = getNameLsa(lsaKey);
-  if (chkNameLsa.second)
+  NameLsa* chkNameLsa = findNameLsa(lsaKey);
+  if (chkNameLsa != 0)
   {
-    cout << " LSA Exists with seq no: " << chkNameLsa.first.getLsSeqNo() << endl;
-    if (chkNameLsa.first.getLsSeqNo() == seqNo)
+    cout << " LSA Exists with seq no: " << chkNameLsa->getLsSeqNo() << endl;
+    if (chkNameLsa->getLsSeqNo() == seqNo)
     {
-      if (chkNameLsa.first.getOrigRouter() == m_thisRouterPrefix)
+      if (chkNameLsa->getOrigRouter() == m_thisRouterPrefix)
       {
-        chkNameLsa.first.writeLog();
+        chkNameLsa->writeLog();
         cout << "Own Name LSA, so refreshing name LSA" << endl;
-        chkNameLsa.first.setLsSeqNo(chkNameLsa.first.getLsSeqNo() + 1);
-        pnlsr.getSm().setNameLsaSeq(chkNameLsa.first.getLsSeqNo());
-        chkNameLsa.first.writeLog();
+        chkNameLsa->setLsSeqNo(chkNameLsa->getLsSeqNo() + 1);
+        pnlsr.getSm().setNameLsaSeq(chkNameLsa->getLsSeqNo());
+        chkNameLsa->writeLog();
         // publish routing update
         string lsaPrefix = pnlsr.getConfParameter().getChronosyncLsaPrefix()
                            + pnlsr.getConfParameter().getRouterPrefix();
@@ -654,17 +651,17 @@
 {
   cout << "Lsdb::exprireOrRefreshAdjLsa Called " << endl;
   cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
-  std::pair<AdjLsa&, bool> chkAdjLsa = getAdjLsa(lsaKey);
-  if (chkAdjLsa.second)
+  AdjLsa* chkAdjLsa = findAdjLsa(lsaKey);
+  if (chkAdjLsa != 0)
   {
-    cout << " LSA Exists with seq no: " << chkAdjLsa.first.getLsSeqNo() << endl;
-    if (chkAdjLsa.first.getLsSeqNo() == seqNo)
+    cout << " LSA Exists with seq no: " << chkAdjLsa->getLsSeqNo() << endl;
+    if (chkAdjLsa->getLsSeqNo() == seqNo)
     {
-      if (chkAdjLsa.first.getOrigRouter() == m_thisRouterPrefix)
+      if (chkAdjLsa->getOrigRouter() == m_thisRouterPrefix)
       {
         cout << "Own Adj LSA, so refreshing Adj LSA" << endl;
-        chkAdjLsa.first.setLsSeqNo(chkAdjLsa.first.getLsSeqNo() + 1);
-        pnlsr.getSm().setAdjLsaSeq(chkAdjLsa.first.getLsSeqNo());
+        chkAdjLsa->setLsSeqNo(chkAdjLsa->getLsSeqNo() + 1);
+        pnlsr.getSm().setAdjLsaSeq(chkAdjLsa->getLsSeqNo());
         // publish routing update
         string lsaPrefix = pnlsr.getConfParameter().getChronosyncLsaPrefix()
                            + pnlsr.getConfParameter().getRouterPrefix();
@@ -682,21 +679,22 @@
 }
 
 void
-Lsdb::exprireOrRefreshCorLsa(Nlsr& pnlsr, string lsaKey, uint64_t seqNo)
+Lsdb::exprireOrRefreshCoordinateLsa(Nlsr& pnlsr, const string& lsaKey,
+                                    uint64_t seqNo)
 {
   cout << "Lsdb::exprireOrRefreshCorLsa Called " << endl;
   cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
-  std::pair<CorLsa&, bool> chkCorLsa = getCorLsa(lsaKey);
-  if (chkCorLsa.second)
+  CoordinateLsa* chkCorLsa = findCoordinateLsa(lsaKey);
+  if (chkCorLsa != 0)
   {
-    cout << " LSA Exists with seq no: " << chkCorLsa.first.getLsSeqNo() << endl;
-    if (chkCorLsa.first.getLsSeqNo() == seqNo)
+    cout << " LSA Exists with seq no: " << chkCorLsa->getLsSeqNo() << endl;
+    if (chkCorLsa->getLsSeqNo() == seqNo)
     {
-      if (chkCorLsa.first.getOrigRouter() == m_thisRouterPrefix)
+      if (chkCorLsa->getOrigRouter() == m_thisRouterPrefix)
       {
         cout << "Own Cor LSA, so refreshing Cor LSA" << endl;
-        chkCorLsa.first.setLsSeqNo(chkCorLsa.first.getLsSeqNo() + 1);
-        pnlsr.getSm().setCorLsaSeq(chkCorLsa.first.getLsSeqNo());
+        chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
+        pnlsr.getSm().setCorLsaSeq(chkCorLsa->getLsSeqNo());
         // publish routing update
         string lsaPrefix = pnlsr.getConfParameter().getChronosyncLsaPrefix()
                            + pnlsr.getConfParameter().getRouterPrefix();
@@ -705,7 +703,7 @@
       else
       {
         cout << "Other's Cor LSA, so removing form LSDB" << endl;
-        removeCorLsa(pnlsr, lsaKey);
+        removeCoordinateLsa(pnlsr, lsaKey);
       }
       if (pnlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
       {
@@ -741,7 +739,7 @@
   }
   else if (lsType == 3)
   {
-    return doesCorLsaExist(key);
+    return doesCoordinateLsaExist(key);
   }
   return false;
 }
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 96f0ff1..9814034 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -23,8 +23,8 @@
   bool
   buildAndInstallOwnNameLsa(Nlsr& pnlsr);
 
-  std::pair<NameLsa&, bool>
-  getNameLsa(std::string key);
+  NameLsa*
+  findNameLsa(const std::string key);
 
   bool
   installNameLsa(Nlsr& pnlsr, NameLsa& nlsa);
@@ -40,19 +40,19 @@
 
   //function related to Cor LSDB
   bool
-  buildAndInstallOwnCorLsa(Nlsr& pnlsr);
+  buildAndInstallOwnCoordinateLsa(Nlsr& pnlsr);
 
-  std::pair<CorLsa&, bool>
-  getCorLsa(std::string key);
+  CoordinateLsa*
+  findCoordinateLsa(const std::string& key);
 
   bool
-  installCorLsa(Nlsr& pnlsr, CorLsa& clsa);
+  installCoordinateLsa(Nlsr& pnlsr, CoordinateLsa& clsa);
 
   bool
-  removeCorLsa(Nlsr& pnlsr, std::string& key);
+  removeCoordinateLsa(Nlsr& pnlsr, const std::string& key);
 
   bool
-  isCorLsaNew(std::string key, uint64_t seqNo);
+  isCoordinateLsaNew(const std::string& key, uint64_t seqNo);
 
   void
   printCorLsdb(); //debugging
@@ -72,8 +72,8 @@
   bool
   installAdjLsa(Nlsr& pnlsr, AdjLsa& alsa);
 
-  std::pair<AdjLsa&, bool>
-  getAdjLsa(std::string key);
+  AdjLsa*
+  findAdjLsa(std::string key);
 
   std::list<AdjLsa>&
   getAdjLsdb();
@@ -97,10 +97,10 @@
 
 
   bool
-  addCorLsa(CorLsa& clsa);
+  addCoordinateLsa(CoordinateLsa& clsa);
 
   bool
-  doesCorLsaExist(std::string key);
+  doesCoordinateLsaExist(const std::string& key);
 
   bool
   addAdjLsa(AdjLsa& alsa);
@@ -121,10 +121,12 @@
   exprireOrRefreshAdjLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
 
   ndn::EventId
-  scheduleCorLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime);
+  scheduleCoordinateLsaExpiration(Nlsr& pnlsr, const std::string& key, int seqNo,
+                                  int expTime);
 
   void
-  exprireOrRefreshCorLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
+  exprireOrRefreshCoordinateLsa(Nlsr& pnlsr, const std::string& lsaKey,
+                                uint64_t seqNo);
 
 
 private:
@@ -133,7 +135,7 @@
 
   std::list<NameLsa> m_nameLsdb;
   std::list<AdjLsa> m_adjLsdb;
-  std::list<CorLsa> m_corLsdb;
+  std::list<CoordinateLsa> m_corLsdb;
 
   int m_lsaRefreshTime;
   std::string m_thisRouterPrefix;
diff --git a/src/main.cpp b/src/main.cpp
index 20c132e..b074385 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -26,47 +26,46 @@
 int
 main(int argc, char** argv)
 {
-  nlsr::Nlsr nlsr_;
+  nlsr::Nlsr nlsr;
   string programName(argv[0]);
-  nlsr_.setConfFileName("nlsr.conf");
+  nlsr.setConfFileName("nlsr.conf");
   int opt;
   while ((opt = getopt(argc, argv, "df:p:h")) != -1)
   {
     switch (opt)
-      {
+     {
       case 'f':
-        nlsr_.setConfFileName(optarg);
+        nlsr.setConfFileName(optarg);
         break;
       case 'd':
-        nlsr_.setIsDaemonProcess(optarg);
+        nlsr.setIsDaemonProcess(optarg);
         break;
       case 'p':
       {
         stringstream sst(optarg);
         int ap;
         sst >> ap;
-        nlsr_.setApiPort(ap);
+        nlsr.setApiPort(ap);
       }
       break;
       case 'h':
-
       default:
-        nlsr_.usage(programName);
+        nlsr.usage(programName);
         return EXIT_FAILURE;
-      }
+     }
   }
-  ConfFileProcessor cfp(nlsr_.getConfFileName());
-  int res = cfp.processConfFile(nlsr_);
+  ConfFileProcessor cfp(nlsr, nlsr.getConfFileName());
+  int res = cfp.processConfFile();
   if (res < 0)
   {
     std::cerr << "Error in configuration file processing! Exiting from NLSR" <<
               std::endl;
     return EXIT_FAILURE;
   }
-  nlsr_.initialize();
+  nlsr.initialize();
   try
   {
-    nlsr_.startEventLoop();
+    nlsr.startEventLoop();
   }
   catch (std::exception& e)
   {
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 00bd510..70a07cf 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -28,9 +28,8 @@
 Nlsr::setInterestFilterNlsr(const string& name)
 {
   getNlsrFace()->setInterestFilter(name,
-                                   func_lib::bind(&InterestManager::processInterest, &m_im,
-                                                  boost::ref(*this), _1, _2),
-                                   func_lib::bind(&Nlsr::registrationFailed, this, _1));
+                                   ndn::bind(&InterestManager::processInterest, &m_im,_1, _2),
+                                   ndn::bind(&Nlsr::registrationFailed, this, _1));
 }
 
 void
@@ -52,7 +51,7 @@
   m_npl.print();
   /* debugging purpose end */
   m_nlsrLsdb.buildAndInstallOwnNameLsa(boost::ref(*this));
-  m_nlsrLsdb.buildAndInstallOwnCorLsa(boost::ref(*this));
+  m_nlsrLsdb.buildAndInstallOwnCoordinateLsa(boost::ref(*this));
   setInterestFilterNlsr(m_confParam.getRouterPrefix());
   setInterestFilterNlsr(m_confParam.getChronosyncLsaPrefix() +
                         m_confParam.getRouterPrefix());
@@ -60,7 +59,7 @@
   m_slh.setSyncPrefix(m_confParam.getChronosyncSyncPrefix());
   m_slh.createSyncSocket(boost::ref(*this));
   m_slh.publishKeyUpdate(m_km);
-  m_im.scheduleInfoInterest(boost::ref(*this), 10);
+  m_im.scheduleInfoInterest(10);
 }
 
 void
diff --git a/src/nlsr.hpp b/src/nlsr.hpp
index bef8189..ac254c3 100644
--- a/src/nlsr.hpp
+++ b/src/nlsr.hpp
@@ -33,13 +33,13 @@
   Nlsr()
     : m_io(new boost::asio::io_service)
     , m_nlsrFace(new Face(ndn::shared_ptr<boost::asio::io_service>(&*m_io,
-                                                              &NullDeleter)))
+                                                                   &NullDeleter)))
     , m_scheduler(*m_io)
     , m_confParam()
     , m_adl()
     , m_npl()
-    , m_im()
-    , m_dm()
+    , m_im(*this)
+    , m_dm(*this)
     , m_sm()
     , m_km()
     , m_isDaemonProcess(false)
diff --git a/src/route/npt.cpp b/src/route/npt.cpp
index 665dbb2..e094fe3 100644
--- a/src/route/npt.cpp
+++ b/src/route/npt.cpp
@@ -83,11 +83,11 @@
 void
 Npt::addNpteByDestName(string name, string destRouter, Nlsr& pnlsr)
 {
-  std::pair<RoutingTableEntry&, bool> rteCheck =
+  RoutingTableEntry* rteCheck =
     pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
-  if (rteCheck.second)
+  if (rteCheck != 0)
   {
-    addNpte(name, rteCheck.first, pnlsr);
+    addNpte(name, *(rteCheck) , pnlsr);
   }
   else
   {
@@ -99,11 +99,11 @@
 void
 Npt::removeNpte(string name, string destRouter, Nlsr& pnlsr)
 {
-  std::pair<RoutingTableEntry&, bool> rteCheck =
+  RoutingTableEntry* rteCheck =
     pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
-  if (rteCheck.second)
+  if (rteCheck != 0)
   {
-    removeNpte(name, rteCheck.first, pnlsr);
+    removeNpte(name, *(rteCheck), pnlsr);
   }
   else
   {
@@ -122,11 +122,11 @@
     for (std::list<RoutingTableEntry>::iterator rteit = rteList.begin();
          rteit != rteList.end(); ++rteit)
     {
-      std::pair<RoutingTableEntry&, bool> rteCheck =
+      RoutingTableEntry* rteCheck =
         pnlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
-      if (rteCheck.second)
+      if (rteCheck != 0)
       {
-        addNpte((*it).getNamePrefix(), rteCheck.first, pnlsr);
+        addNpte((*it).getNamePrefix(), *(rteCheck), pnlsr);
       }
       else
       {
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index 6c6dad3..d63904e 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -448,13 +448,14 @@
   double distance = 0.0;
   string srcRouterKey = pMap.getRouterNameByMappingNo(src) + "/3";
   string destRouterKey = pMap.getRouterNameByMappingNo(dest) + "/3";
-  double srcRadius = (pnlsr.getLsdb().getCorLsa(
-                        srcRouterKey).first).getCorRadius();
-  double srcTheta = (pnlsr.getLsdb().getCorLsa(srcRouterKey).first).getCorTheta();
-  double destRadius = (pnlsr.getLsdb().getCorLsa(
-                         destRouterKey).first).getCorRadius();
-  double destTheta = (pnlsr.getLsdb().getCorLsa(
-                        destRouterKey).first).getCorTheta();
+  double srcRadius = (pnlsr.getLsdb().findCoordinateLsa(
+                        srcRouterKey))->getCorRadius();
+  double srcTheta = (pnlsr.getLsdb().findCoordinateLsa(
+                       srcRouterKey))->getCorTheta();
+  double destRadius = (pnlsr.getLsdb().findCoordinateLsa(
+                         destRouterKey))->getCorRadius();
+  double destTheta = (pnlsr.getLsdb().findCoordinateLsa(
+                        destRouterKey))->getCorTheta();
   double diffTheta = fabs(srcTheta - destTheta);
   if (diffTheta > MATH_PI)
   {
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 9e2c19c..097e95a 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -140,8 +140,8 @@
 void
 RoutingTable::addNextHop(string destRouter, NextHop& nh)
 {
-  std::pair<RoutingTableEntry&, bool> rte = findRoutingTableEntry(destRouter);
-  if (!rte.second)
+  RoutingTableEntry* rteChk = findRoutingTableEntry(destRouter);
+  if (rteChk == 0)
   {
     RoutingTableEntry rte(destRouter);
     rte.getNhl().addNextHop(nh);
@@ -149,22 +149,21 @@
   }
   else
   {
-    (rte.first).getNhl().addNextHop(nh);
+    rteChk->getNhl().addNextHop(nh);
   }
 }
 
-std::pair<RoutingTableEntry&, bool>
-RoutingTable::findRoutingTableEntry(string destRouter)
+RoutingTableEntry*
+RoutingTable::findRoutingTableEntry(const string destRouter)
 {
   std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(),
                                                            m_rTable.end(),
                                                            bind(&routingTableEntryCompare, _1, destRouter));
   if (it != m_rTable.end())
   {
-    return std::make_pair(boost::ref((*it)), true);
+    return &(*it);
   }
-  RoutingTableEntry rteEmpty;
-  return std::make_pair(boost::ref(rteEmpty), false);
+  return 0;
 }
 
 void
diff --git a/src/route/routing-table.hpp b/src/route/routing-table.hpp
index cc04915..8518b12 100644
--- a/src/route/routing-table.hpp
+++ b/src/route/routing-table.hpp
@@ -34,8 +34,8 @@
   void
   printDryRoutingTable();
 
-  std::pair<RoutingTableEntry&, bool>
-  findRoutingTableEntry(std::string destRouter);
+  RoutingTableEntry*
+  findRoutingTableEntry(const std::string destRouter);
 
   void
   scheduleRoutingTableCalculation(Nlsr& pnlsr);
diff --git a/src/security/certificate-store.cpp b/src/security/certificate-store.cpp
index 3ac5361..6990b07 100644
--- a/src/security/certificate-store.cpp
+++ b/src/security/certificate-store.cpp
@@ -58,7 +58,6 @@
       }
     }
   }
-
   //remove that entry from waiting list
   m_waitingList.remove(respCertName);
 }
@@ -149,7 +148,6 @@
   {
     return it->getIsSignerVerified();
   }
-
   return false;
 }
 
diff --git a/src/security/key-manager.cpp b/src/security/key-manager.cpp
index 5ab63a8..7379c1b 100644
--- a/src/security/key-manager.cpp
+++ b/src/security/key-manager.cpp
@@ -339,27 +339,21 @@
   ndn::SignatureSha256WithRsa signature(packet.getSignature());
   std::string signingCertName = signature.getKeyLocator().getName().toUri();
   std::string packetName = packet.getName().toUri();
-
   std::cout << "Packet Name: " << packetName << std::endl;
   std::cout << "Signee Name: " << signingCertName << std::endl;
-
   int paketCertType = getKeyTypeFromName(packetName);
   int signingCertType = getKeyTypeFromName(signingCertName);
-
   if (signingCertType > paketCertType)  //lower level Cert can not sign
   {
     //upper level Cert
     return false;
   }
-
   if ((signingCertType == paketCertType) && (paketCertType != KEY_TYPE_ROOT))
   {
     return false;
   }
-
   std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> signee =
     m_certStore.getCertificateFromStore(signingCertName);
-
   if (signee.second)
   {
     switch (paketCertType)
@@ -393,7 +387,7 @@
   else
   {
     std::cout << "Certificate Not Found in store. Sending Interest" << std::endl;
-    pnlsr.getIm().expressInterest(pnlsr, signingCertName, 3,
+    pnlsr.getIm().expressInterest(signingCertName, 3,
                                   pnlsr.getConfParameter().getInterestResendTime());
     return false;
   }
diff --git a/src/security/key-manager.hpp b/src/security/key-manager.hpp
index 9becfe2..c343108 100644
--- a/src/security/key-manager.hpp
+++ b/src/security/key-manager.hpp
@@ -180,9 +180,7 @@
   verify(T& packet)
   {
     std::cout << "KeyManager::verify Called" << std::endl;
-
     return verifyDataPacket(packet);
-
     return false;
   }
 
diff --git a/src/security/waiting-list-entry.cpp b/src/security/waiting-list-entry.cpp
index 1172698..6b83904 100644
--- a/src/security/waiting-list-entry.cpp
+++ b/src/security/waiting-list-entry.cpp
@@ -20,7 +20,6 @@
     m_waitingCerts.push_back(waiteeName);
     return true;
   }
-
   return false;
 }
 
diff --git a/src/security/waiting-list.cpp b/src/security/waiting-list.cpp
index dbf9b68..39a7192 100644
--- a/src/security/waiting-list.cpp
+++ b/src/security/waiting-list.cpp
@@ -17,10 +17,8 @@
   {
     return std::make_pair(*(it), true);
   }
-
   WaitingListEntry wle;
   return std::make_pair(wle, false);
-
 }
 
 bool
