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());
   }
 }
