diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 1272ab1..fc823c1 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -14,32 +14,31 @@
 using namespace ndn;
 
 static bool
-fibEntryNameCompare(const FibEntry& fibEntry, const string& name)
+fibEntryNameCompare(const FibEntry& fibEntry, const ndn::Name& name)
 {
   return fibEntry.getName() == name ;
 }
 
 void
-Fib::cancelScheduledExpiringEvent(Nlsr& pnlsr, EventId eid)
+Fib::cancelScheduledExpiringEvent(EventId eid)
 {
-  pnlsr.getScheduler().cancelEvent(eid);
+  m_nlsr.getScheduler().cancelEvent(eid);
 }
 
 
 ndn::EventId
-Fib::scheduleEntryRefreshing(Nlsr& pnlsr, const string& name, int32_t feSeqNum,
+Fib::scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
                              int32_t refreshTime)
 {
   std::cout << "Fib::scheduleEntryRefreshing Called" << std::endl;
   std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
-  return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
-                                            ndn::bind(&Fib::refreshEntry, this,
-                                                      boost::ref(pnlsr), 
-                                                      name, feSeqNum));
+  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
+                                             ndn::bind(&Fib::refreshEntry, this,
+                                                       name, feSeqNum));
 }
 
 void
-Fib::refreshEntry(Nlsr& nlsr, const string& name, int32_t feSeqNum)
+Fib::refreshEntry(const ndn::Name& name, int32_t feSeqNum)
 {
   std::cout << "Fib::refreshEntry Called" << std::endl;
   std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
@@ -53,26 +52,24 @@
     {
       std::cout << "Refreshing the FIB entry" << std::endl;
       for (std::list<NextHop>::iterator nhit =
-           (*it).getNexthopList().getNextHops().begin();
-         nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
+             (*it).getNexthopList().getNextHops().begin();
+           nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
       {
         // add entry to NDN-FIB
-        registerPrefixInNfd(it->getName(), nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+        registerPrefixInNfd(it->getName(), nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
       }
-      
       // increase sequence number and schedule refresh again
       it->setSeqNo(feSeqNum + 1);
-      it->setExpiringEventId(scheduleEntryRefreshing(nlsr,
-                                                     it->getName() ,
-                                                     it->getSeqNo(), 
+      it->setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
+                                                     it->getSeqNo(),
                                                      m_refreshTime));
-      
     }
   }
 }
 
 void
-Fib::remove(Nlsr& pnlsr, const std::string& name)
+Fib::remove(const ndn::Name& name)
 {
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
@@ -84,14 +81,14 @@
          nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
     {
       //remove entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(it->getName()))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName()))
       {
         unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() != 
-           nhit->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() !=
+            nhit->getConnectingFace())
         {
           unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
         }
@@ -99,19 +96,19 @@
     }
     std::cout << "Cancellling Scheduled event" << std::endl;
     std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
-    cancelScheduledExpiringEvent(pnlsr, (*it).getExpiringEventId());
+    cancelScheduledExpiringEvent((*it).getExpiringEventId());
     m_table.erase(it);
   }
 }
 
 
 void
-Fib::update(Nlsr& pnlsr, const string& name, NexthopList& nextHopList)
+Fib::update(const ndn::Name& name, NexthopList& nextHopList)
 {
   std::cout << "Fib::updateFib Called" << std::endl;
   int startFace = 0;
   int endFace = getNumberOfFacesForName(nextHopList,
-                                        pnlsr.getConfParameter().getMaxFacesPerPrefix());
+                                        m_nlsr.getConfParameter().getMaxFacesPerPrefix());
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
                                                   bind(&fibEntryNameCompare, _1, name));
@@ -127,13 +124,13 @@
       {
         newEntry.getNexthopList().addNextHop((*nhit));
         //Add entry to NDN-FIB
-        registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+        registerPrefixInNfd(name, nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
       }
       newEntry.getNexthopList().sort();
       newEntry.setTimeToRefresh(m_refreshTime);
       newEntry.setSeqNo(1);
-      newEntry.setExpiringEventId(scheduleEntryRefreshing(pnlsr,
-                                                          name , 1, m_refreshTime));
+      newEntry.setExpiringEventId(scheduleEntryRefreshing(name , 1, m_refreshTime));
       m_table.push_back(newEntry);
     }
   }
@@ -148,8 +145,9 @@
         std::list<NextHop> nhl = nextHopList.getNextHops();
         std::list<NextHop>::iterator nhit = nhl.begin();
         // Add first Entry to NDN-FIB
-        registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
-        removeHop(pnlsr, it->getNexthopList(), nhit->getConnectingFace(), name);
+        registerPrefixInNfd(name, nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
+        removeHop(it->getNexthopList(), nhit->getConnectingFace(), name);
         it->getNexthopList().reset();
         it->getNexthopList().addNextHop((*nhit));
         ++startFace;
@@ -158,21 +156,21 @@
         {
           it->getNexthopList().addNextHop((*nhit));
           //Add Entry to NDN_FIB
-          registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+          registerPrefixInNfd(name, nhit->getConnectingFace(),
+                              std::ceil(nhit->getRouteCost()));
         }
       }
       it->setTimeToRefresh(m_refreshTime);
       std::cout << "Cancellling Scheduled event" << std::endl;
       std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
-      cancelScheduledExpiringEvent(pnlsr, it->getExpiringEventId());
+      cancelScheduledExpiringEvent(it->getExpiringEventId());
       it->setSeqNo(it->getSeqNo() + 1);
-      (*it).setExpiringEventId(scheduleEntryRefreshing(pnlsr,
-                                                       it->getName() ,
+      (*it).setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
                                                        it->getSeqNo(), m_refreshTime));
     }
     else
     {
-      remove(pnlsr, name);
+      remove(name);
     }
   }
 }
@@ -180,27 +178,28 @@
 
 
 void
-Fib::clean(Nlsr& pnlsr)
+Fib::clean()
 {
   for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
        ++it)
   {
     std::cout << "Cancellling Scheduled event" << std::endl;
-    std::cout << "Name: " << it->getName() << "Seq num: " << it->getSeqNo() << std::endl;
-    cancelScheduledExpiringEvent(pnlsr, (*it).getExpiringEventId());
+    std::cout << "Name: " << it->getName() << "Seq num: " << it->getSeqNo() <<
+              std::endl;
+    cancelScheduledExpiringEvent((*it).getExpiringEventId());
     for (std::list<NextHop>::iterator nhit =
            (*it).getNexthopList().getNextHops().begin();
          nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
     {
       //Remove entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(it->getName()))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName()))
       {
         unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() != 
-           nhit->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() !=
+            nhit->getConnectingFace())
         {
           unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
         }
@@ -214,7 +213,8 @@
 }
 
 int
-Fib::getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix)
+Fib::getNumberOfFacesForName(NexthopList& nextHopList,
+                             uint32_t maxFacesPerPrefix)
 {
   int endFace = 0;
   if ((maxFacesPerPrefix == 0) || (nextHopList.getSize() <= maxFacesPerPrefix))
@@ -229,8 +229,8 @@
 }
 
 void
-Fib::removeHop(Nlsr& pnlsr, NexthopList& nl, uint32_t doNotRemoveHopFaceId,
-               const std::string& name)
+Fib::removeHop(NexthopList& nl, uint32_t doNotRemoveHopFaceId,
+               const ndn::Name& name)
 {
   for (std::list<NextHop>::iterator it = nl.getNextHops().begin();
        it != nl.getNextHops().end();   ++it)
@@ -238,14 +238,14 @@
     if (it->getConnectingFace() != doNotRemoveHopFaceId)
     {
       //Remove FIB Entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(name))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(name))
       {
         unregisterPrefixFromNfd(name, it->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(name).getConnectingFace() != 
-           it->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(name).getConnectingFace() !=
+            it->getConnectingFace())
         {
           unregisterPrefixFromNfd(name, it->getConnectingFace());
         }
@@ -255,32 +255,31 @@
 }
 
 void
-Fib::registerPrefixInNfd(const std::string& namePrefix, uint64_t faceId, uint64_t faceCost)
+Fib::registerPrefixInNfd(const ndn::Name& namePrefix, uint64_t faceId,
+                         uint64_t faceCost)
 {
   ndn::nfd::ControlParameters controlParameters;
   controlParameters
-    .setName(namePrefix)
-    .setCost(faceCost)
-    .setFaceId(faceId)
-    .setExpirationPeriod(ndn::time::milliseconds(m_refreshTime*1000))
-    .setOrigin(128);
-
+  .setName(namePrefix)
+  .setCost(faceCost)
+  .setFaceId(faceId)
+  .setExpirationPeriod(ndn::time::milliseconds(m_refreshTime * 1000))
+  .setOrigin(128);
   m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
                                                    ndn::bind(&Fib::onSuccess, this, _1,
                                                              "Successful in name registration"),
                                                    ndn::bind(&Fib::onFailure, this, _1, _2,
                                                              "Failed in name registration"));
 }
-  
+
 void
-Fib::unregisterPrefixFromNfd(const std::string& namePrefix, uint64_t faceId)
+Fib::unregisterPrefixFromNfd(const ndn::Name& namePrefix, uint64_t faceId)
 {
   ndn::nfd::ControlParameters controlParameters;
   controlParameters
-    .setName(namePrefix)
-    .setFaceId(faceId)
-    .setOrigin(128);
-
+  .setName(namePrefix)
+  .setFaceId(faceId)
+  .setOrigin(128);
   m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
                                                      ndn::bind(&Fib::onSuccess, this, _1,
                                                                "Successful in unregistering name"),
@@ -289,13 +288,15 @@
 }
 
 void
-Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult, const std::string& message)
+Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
+               const std::string& message)
 {
   std::cout << message << ": " << commandSuccessResult << std::endl;
 }
 
 void
-Fib::onFailure(uint32_t code, const std::string& error, const std::string& message)
+Fib::onFailure(uint32_t code, const std::string& error,
+               const std::string& message)
 {
   std::cout << message << ": " << error << " (code: " << code << ")";
 }
