diff --git a/src/adjacency-list.cpp b/src/adjacency-list.cpp
index 117ba76..48e35cf 100644
--- a/src/adjacency-list.cpp
+++ b/src/adjacency-list.cpp
@@ -22,8 +22,7 @@
 AdjacencyList::insert(Adjacent& adjacent)
 {
   std::list<Adjacent>::iterator it = find(adjacent.getName());
-  if (it != m_adjList.end())
-  {
+  if (it != m_adjList.end()) {
     return -1;
   }
   m_adjList.push_back(adjacent);
@@ -34,8 +33,7 @@
 AdjacencyList::addAdjacents(AdjacencyList& adl)
 {
   for (std::list<Adjacent>::iterator it = adl.getAdjList().begin();
-       it != adl.getAdjList().end(); ++it)
-  {
+       it != adl.getAdjList().end(); ++it) {
     insert((*it));
   }
 }
@@ -44,8 +42,7 @@
 AdjacencyList::updateAdjacentStatus(const ndn::Name& adjName, int32_t s)
 {
   std::list<Adjacent>::iterator it = find(adjName);
-  if (it == m_adjList.end())
-  {
+  if (it == m_adjList.end()) {
     return -1;
   }
   (*it).setStatus(s);
@@ -57,8 +54,7 @@
 {
   Adjacent adj(adjName);
   std::list<Adjacent>::iterator it = find(adjName);
-  if (it != m_adjList.end())
-  {
+  if (it != m_adjList.end()) {
     return (*it);
   }
   return adj;
@@ -73,8 +69,7 @@
 bool
 AdjacencyList::operator==(AdjacencyList& adl)
 {
-  if (getSize() != adl.getSize())
-  {
+  if (getSize() != adl.getSize()) {
     return false;
   }
   m_adjList.sort(compareAdjacent);
@@ -84,10 +79,8 @@
   std::list<Adjacent>::iterator it1;
   std::list<Adjacent>::iterator it2;
   for (it1 = m_adjList.begin(), it2 = adjList2.begin();
-       it1 != m_adjList.end(); it1++, it2++)
-  {
-    if (!((*it1) == (*it2)))
-    {
+       it1 != m_adjList.end(); it1++, it2++) {
+    if (!((*it1) == (*it2))) {
       break;
     }
     equalAdjCount++;
@@ -99,8 +92,7 @@
 AdjacencyList::updateAdjacentLinkCost(const ndn::Name& adjName, double lc)
 {
   std::list<Adjacent>::iterator it = find(adjName);
-  if (it == m_adjList.end())
-  {
+  if (it == m_adjList.end()) {
     return -1;
   }
   (*it).setLinkCost(lc);
@@ -122,8 +114,7 @@
 AdjacencyList::incrementTimedOutInterestCount(const ndn::Name& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
-  if (it == m_adjList.end())
-  {
+  if (it == m_adjList.end()) {
     return ;
   }
   (*it).setInterestTimedOutNo((*it).getInterestTimedOutNo() + 1);
@@ -134,8 +125,7 @@
                                         uint32_t count)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
-  if (it != m_adjList.end())
-  {
+  if (it != m_adjList.end()) {
     (*it).setInterestTimedOutNo(count);
   }
 }
@@ -144,8 +134,7 @@
 AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
-  if (it == m_adjList.end())
-  {
+  if (it == m_adjList.end()) {
     return -1;
   }
   return (*it).getInterestTimedOutNo();
@@ -155,8 +144,7 @@
 AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
-  if (it == m_adjList.end())
-  {
+  if (it == m_adjList.end()) {
     return -1;
   }
   return (*it).getStatus();
@@ -166,8 +154,7 @@
 AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, int32_t status)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
-  if (it != m_adjList.end())
-  {
+  if (it != m_adjList.end()) {
     (*it).setStatus(status);
   }
 }
@@ -183,23 +170,18 @@
 {
   uint32_t nbrCount = 0;
   for (std::list<Adjacent>::iterator it = m_adjList.begin();
-       it != m_adjList.end() ; it++)
-  {
-    if (((*it).getStatus() == 1))
-    {
+       it != m_adjList.end() ; it++) {
+    if (((*it).getStatus() == 1)) {
       nbrCount++;
     }
-    else
-    {
+    else {
       if ((*it).getInterestTimedOutNo() >=
-          pnlsr.getConfParameter().getInterestRetryNumber())
-      {
+          pnlsr.getConfParameter().getInterestRetryNumber()) {
         nbrCount++;
       }
     }
   }
-  if (nbrCount == m_adjList.size())
-  {
+  if (nbrCount == m_adjList.size()) {
     return true;
   }
   return false;
@@ -210,10 +192,8 @@
 {
   int32_t actNbrCount = 0;
   for (std::list<Adjacent>::iterator it = m_adjList.begin();
-       it != m_adjList.end(); it++)
-  {
-    if (((*it).getStatus() == 1))
-    {
+       it != m_adjList.end(); it++) {
+    if (((*it).getStatus() == 1)) {
       actNbrCount++;
     }
   }
@@ -235,8 +215,7 @@
 AdjacencyList::print()
 {
   for (std::list<Adjacent>::iterator it = m_adjList.begin();
-       it != m_adjList.end(); it++)
-  {
+       it != m_adjList.end(); it++) {
     cout << (*it) << endl;
   }
 }
diff --git a/src/adjacency-list.hpp b/src/adjacency-list.hpp
index c3c2195..95600cc 100644
--- a/src/adjacency-list.hpp
+++ b/src/adjacency-list.hpp
@@ -71,8 +71,7 @@
   void
   reset()
   {
-    if (m_adjList.size() > 0)
-    {
+    if (m_adjList.size() > 0) {
       m_adjList.clear();
     }
   }
diff --git a/src/adjacent.cpp b/src/adjacent.cpp
index 94dceee..f27c4b8 100644
--- a/src/adjacent.cpp
+++ b/src/adjacent.cpp
@@ -10,11 +10,31 @@
 
 using namespace std;
 
-Adjacent::Adjacent(const ndn::Name& an, uint32_t cf, double lc, uint32_t s,
-                   uint32_t iton)
+const float Adjacent::DEFAULT_LINK_COST = 10.0;
+
+Adjacent::Adjacent()
+    : m_name()
+    , m_connectingFaceUri()
+    , m_linkCost(DEFAULT_LINK_COST)
+    , m_status(ADJACENT_STATUS_INACTIVE)
+    , m_interestTimedOutNo(0)
+{
+}
+
+Adjacent::Adjacent(const ndn::Name& an)
+    : m_name(an)
+    , m_connectingFaceUri()
+    , m_linkCost(DEFAULT_LINK_COST)
+    , m_status(ADJACENT_STATUS_INACTIVE)
+    , m_interestTimedOutNo(0)
+  {
+  }
+
+Adjacent::Adjacent(const ndn::Name& an, const std::string& cfu,  double lc,
+          uint32_t s, uint32_t iton)
 {
   m_name = an;
-  m_connectingFace = cf;
+  m_connectingFaceUri = cfu;
   m_linkCost = lc;
   m_status = s;
   m_interestTimedOutNo = iton;
@@ -24,7 +44,7 @@
 Adjacent::operator==(const Adjacent& adjacent) const
 {
   return (m_name == adjacent.getName()) &&
-         (m_connectingFace == adjacent.getConnectingFace()) &&
+         (m_connectingFaceUri == adjacent.getConnectingFaceUri()) &&
          (std::abs(m_linkCost - adjacent.getLinkCost()) <
           std::numeric_limits<double>::epsilon()) ;
 }
@@ -39,7 +59,7 @@
 operator<<(std::ostream& os, const Adjacent& adj)
 {
   os << "Adjacent : " << adj.getName() << endl;
-  os << "Connecting Face: " << adj.getConnectingFace() << endl;
+  os << "Connecting FaceUri: " << adj.getConnectingFaceUri() << endl;
   os << "Link Cost: " << adj.getLinkCost() << endl;
   os << "Status: " << adj.getStatus() << endl;
   os << "Interest Timed out: " << adj.getInterestTimedOutNo() << endl;
diff --git a/src/adjacent.hpp b/src/adjacent.hpp
index bb043f8..cbfb0fa 100644
--- a/src/adjacent.hpp
+++ b/src/adjacent.hpp
@@ -6,30 +6,22 @@
 #define NLSR_ADJACENT_HPP
 
 namespace nlsr {
+
+enum {
+  ADJACENT_STATUS_INACTIVE = 0,
+  ADJACENT_STATUS_ACTIVE = 1
+};
+
 class Adjacent
 {
 
 public:
-  Adjacent()
-    : m_name()
-    , m_connectingFace(0)
-    , m_linkCost(10.0)
-    , m_status(0)
-    , m_interestTimedOutNo(0)
-  {
-  }
+  Adjacent();
 
-  Adjacent(const ndn::Name& an)
-    : m_connectingFace(0)
-    , m_linkCost(0.0)
-    , m_status(0)
-    , m_interestTimedOutNo(0)
-  {
-    m_name = an;
-  }
+  Adjacent(const ndn::Name& an);
 
-  Adjacent(const ndn::Name& an, uint32_t cf, double lc, uint32_t s,
-           uint32_t iton);
+  Adjacent(const ndn::Name& an, const std::string& cfu,  double lc,
+          uint32_t s, uint32_t iton);
 
   const ndn::Name&
   getName() const
@@ -43,16 +35,16 @@
     m_name = an;
   }
 
-  uint32_t
-  getConnectingFace() const
+  const std::string&
+  getConnectingFaceUri() const
   {
-    return m_connectingFace;
+    return m_connectingFaceUri;
   }
 
   void
-  setConnectingFace(uint32_t cf)
+  setConnectingFaceUri(const std::string& cfu)
   {
-    m_connectingFace = cf;
+    m_connectingFaceUri = cfu;
   }
 
   double
@@ -97,9 +89,12 @@
   bool
   compare(const ndn::Name& adjacencyName);
 
+public:
+  static const float DEFAULT_LINK_COST;
+
 private:
   ndn::Name m_name;
-  uint32_t m_connectingFace;
+  std::string m_connectingFaceUri;
   double m_linkCost;
   uint32_t m_status;
   uint32_t m_interestTimedOutNo;
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 10a40ec..85b1da0 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -14,12 +14,12 @@
 {
   std::cout << "Creating Sync socket ......" << std::endl;
   std::cout << "Sync prefix: " << m_syncPrefix << std::endl;
-  m_syncSocket = make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator,
-                                               m_syncFace,
-                                               bind(&SyncLogicHandler::nsyncUpdateCallBack, this,
-                                                    _1, _2, boost::ref(pnlsr)),
-                                               bind(&SyncLogicHandler::nsyncRemoveCallBack, this,
-                                                    _1, boost::ref(pnlsr)));
+  m_syncSocket = ndn::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator,
+                                                    m_syncFace,
+                                                    ndn::bind(&SyncLogicHandler::nsyncUpdateCallBack,
+                                                              this, _1, _2, ndn::ref(pnlsr)),
+                                                    ndn::bind(&SyncLogicHandler::nsyncRemoveCallBack,
+                                                              this, _1, ndn::ref(pnlsr)));
 }
 
 void
@@ -28,8 +28,7 @@
 {
   std::cout << "nsyncUpdateCallBack called ...." << std::endl;
   int32_t n = v.size();
-  for (int32_t i = 0; i < n; i++)
-  {
+  for (int32_t i = 0; i < n; i++){
     std::cout << "Data Name: " << v[i].prefix << " Seq: " << v[i].high.getSeq() <<
               endl;
     processUpdateFromSync(v[i].prefix, v[i].high.getSeq(), pnlsr);
@@ -51,11 +50,9 @@
 SyncLogicHandler::processUpdateFromSync(const ndn::Name& updateName,
                                         uint64_t seqNo,  Nlsr& pnlsr)
 {
-  //const ndn::Name name(updateName);
   string chkString("LSA");
   int32_t lasPosition = util::getNameComponentPosition(updateName, chkString);
-  if (lasPosition >= 0)
-  {
+  if (lasPosition >= 0) {
     ndn::Name routerName = updateName.getSubName(lasPosition + 1);
     processRoutingUpdateFromSync(routerName, seqNo, pnlsr);
     return;
@@ -67,17 +64,14 @@
                                                uint64_t seqNo,  Nlsr& pnlsr)
 {
   ndn::Name rName = routerName;
-  if (routerName != pnlsr.getConfParameter().getRouterPrefix())
-  {
+  if (routerName != pnlsr.getConfParameter().getRouterPrefix()) {
     SequencingManager sm(seqNo);
     std::cout << sm;
     std::cout << "Router Name: " << routerName << endl;
-    try
-    {
-      if (pnlsr.getLsdb().isNameLsaNew(rName.append("name"), sm.getNameLsaSeq()))
-      {
+    try {
+      if (pnlsr.getLsdb().isNameLsaNew(rName.append("name"), sm.getNameLsaSeq())) {
         std::cout << "Updated Name LSA. Need to fetch it" << std::endl;
-        ndn::Name interestName(pnlsr.getConfParameter().getChronosyncLsaPrefix());
+        ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
         interestName.append(routerName);
         interestName.append("name");
         interestName.appendNumber(sm.getNameLsaSeq());
@@ -85,10 +79,9 @@
                                         pnlsr.getConfParameter().getInterestResendTime());
       }
       if (pnlsr.getLsdb().isAdjLsaNew(rName.append("adjacency"),
-                                      sm.getAdjLsaSeq()))
-      {
+                                      sm.getAdjLsaSeq())) {
         std::cout << "Updated Adj LSA. Need to fetch it" << std::endl;
-        ndn::Name interestName(pnlsr.getConfParameter().getChronosyncLsaPrefix());
+        ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
         interestName.append(routerName);
         interestName.append("adjacency");
         interestName.appendNumber(sm.getAdjLsaSeq());
@@ -96,10 +89,9 @@
                                         pnlsr.getConfParameter().getInterestResendTime());
       }
       if (pnlsr.getLsdb().isCoordinateLsaNew(rName.append("coordinate"),
-                                             sm.getCorLsaSeq()))
-      {
+                                             sm.getCorLsaSeq())) {
         std::cout << "Updated Cor LSA. Need to fetch it" << std::endl;
-        ndn::Name interestName(pnlsr.getConfParameter().getChronosyncLsaPrefix());
+        ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
         interestName.append(routerName);
         interestName.append("coordinate");
         interestName.appendNumber(sm.getCorLsaSeq());
@@ -107,8 +99,7 @@
                                         pnlsr.getConfParameter().getInterestResendTime());
       }
     }
-    catch (std::exception& e)
-    {
+    catch (std::exception& e) {
       std::cerr << e.what() << std::endl;
       return;
     }
diff --git a/src/communication/sync-logic-handler.hpp b/src/communication/sync-logic-handler.hpp
index 1f62554..739f90b 100644
--- a/src/communication/sync-logic-handler.hpp
+++ b/src/communication/sync-logic-handler.hpp
@@ -7,7 +7,6 @@
 #include <ndn-cxx/face.hpp>
 #include <nsync/sync-socket.h>
 #include <ndn-cxx/security/validator-null.hpp>
-#include <ndn-cxx/util/scheduler.hpp>
 
 #include "sequencing-manager.hpp"
 
@@ -26,7 +25,8 @@
   SyncLogicHandler(boost::asio::io_service& ioService)
     : m_validator(new ndn::ValidatorNull())
     , m_syncFace(new ndn::Face(ioService))
-  {}
+  {
+  }
 
 
   void
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index 18ae0a5..7726869 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -1,551 +1,352 @@
 #include <iostream>
 #include <fstream>
-#include <string>
-#include <cstdlib>
-#include <sstream>
+#include <boost/algorithm/string.hpp>
+#include <boost/property_tree/info_parser.hpp>
+#include <boost/property_tree/ptree.hpp>
 
-#include "conf-file-processor.hpp"
+#include <ndn-cxx/name.hpp>
+
 #include "conf-parameter.hpp"
-#include "utility/tokenizer.hpp"
+#include "conf-file-processor.hpp"
 #include "adjacent.hpp"
+#include "utility/name-helper.hpp"
 
 
 namespace nlsr {
 
 using namespace std;
 
-int
+bool
 ConfFileProcessor::processConfFile()
 {
-  int ret = 0;
-  if (!m_confFileName.empty())
+  bool ret = true;
+  ifstream inputFile;
+  inputFile.open(m_confFileName.c_str());
+  if (!inputFile.is_open()) {
+    string msg = "Failed to read configuration file: ";
+    msg += m_confFileName;
+    cerr << msg << endl;
+    ret = false;
+  }
+  ret = load(inputFile);
+  inputFile.close();
+  return ret;
+}
+
+bool
+ConfFileProcessor::load(istream& input)
+{
+  boost::property_tree::ptree pt;
+  bool ret = true;
+  try {
+    boost::property_tree::read_info(input, pt);
+  }
+  catch (const boost::property_tree::info_parser_error& error) {
+    stringstream msg;
+    std::cerr << "Failed to parse configuration file " << std::endl;
+    std::cerr << m_confFileName << std::endl;
+    return false;
+  }
+  for (boost::property_tree::ptree::const_iterator tn = pt.begin();
+       tn != pt.end(); ++tn) {
+    std::string section = tn->first;
+    boost::property_tree::ptree SectionAttributeTree = tn ->second;
+    ret = processSection(section, SectionAttributeTree);
+    if (ret == false) {
+      break;
+    }
+  }
+  return ret;
+}
+
+bool
+ConfFileProcessor::processSection(const std::string& section,
+                                  boost::property_tree::ptree SectionAttributeTree)
+{
+  bool ret = true;
+  if (section == "general")
   {
-    std::ifstream inputFile(m_confFileName.c_str());
-    if (inputFile.is_open())
+    ret = processConfSectionGeneral(SectionAttributeTree);
+  }
+  else if (section == "neighbors")
+  {
+    ret = processConfSectionNeighbors(SectionAttributeTree);
+  }
+  else if (section == "hyperbolic")
+  {
+    ret = processConfSectionHyperbolic(SectionAttributeTree);
+  }
+  else if (section == "fib")
+  {
+    ret = processConfSectionFib(SectionAttributeTree);
+  }
+  else if (section == "advertising")
+  {
+    ret = processConfSectionAdvertising(SectionAttributeTree);
+  }
+  else
+  {
+    std::cerr << "Wrong configuration Command: " << section << std::endl;
+  }
+  return ret;
+}
+
+bool
+ConfFileProcessor::processConfSectionGeneral(boost::property_tree::ptree
+                                            SectionAttributeTree)
+{
+  try {
+    std::string network = SectionAttributeTree.get<string>("network");
+    std::string site = SectionAttributeTree.get<string>("site");
+    std::string router = SectionAttributeTree.get<string>("router");
+    ndn::Name networkName(network);
+    if (!networkName.empty()) {
+      m_nlsr.getConfParameter().setNetwork(networkName);
+    }
+    else {
+      cerr << " Network can not be null or empty or in bad URI format :(!" << endl;
+      return false;
+    }
+    ndn::Name siteName(site);
+    if (!siteName.empty()) {
+      m_nlsr.getConfParameter().setSiteName(siteName);
+    }
+    else {
+      cerr << "Site can not be null or empty or in bad URI format:( !" << endl;
+      return false;
+    }
+    ndn::Name routerName(router);
+    if (!routerName.empty()) {
+      m_nlsr.getConfParameter().setRouterName(routerName);
+    }
+    else {
+      cerr << " Router name can not be null or empty or in bad URI format:( !" << endl;
+      return false;
+    }
+  }
+  catch (const std::exception& ex) {
+    cerr << ex.what() << endl;
+    return false;
+  }
+  
+  try {
+    int32_t lsaRefreshTime = SectionAttributeTree.get<int32_t>("lsa-refresh-time");
+    if (lsaRefreshTime >= LSA_REFRESH_TIME_MIN &&
+        lsaRefreshTime <= LSA_REFRESH_TIME_MAX) {
+      m_nlsr.getConfParameter().setLsaRefreshTime(lsaRefreshTime);
+    }
+    else {
+      std::cerr << "Wrong value for lsa-refresh-time ";
+      std::cerr << "Allowed value: " << LSA_REFRESH_TIME_MIN << "-";;
+      std::cerr << LSA_REFRESH_TIME_MAX << std::endl;
+      return false;
+    }
+  }
+  catch (const std::exception& ex) {
+    std::cerr << ex.what() << std::endl;
+    return false;
+  }
+  
+  try {
+    std::string logLevel = SectionAttributeTree.get<string>("log-level");
+    if ( boost::iequals(logLevel, "info") || boost::iequals(logLevel, "debug")) {
+      m_nlsr.getConfParameter().setLogLevel(logLevel);
+    }
+    else {
+      std::cerr << "Wrong value for log-level ";
+      std::cerr << "Allowed value: INFO, DEBUG" << std::endl;
+      return false;
+    }
+  }
+  catch (const std::exception& ex) {
+    std::cerr << ex.what() << std::endl;
+    return false;
+  }
+  
+  return true;
+}
+
+bool
+ConfFileProcessor::processConfSectionNeighbors(boost::property_tree::ptree
+                                           SectionAttributeTree)
+{
+  try {
+    int retrials = SectionAttributeTree.get<int>("hello-retries");
+    if (retrials >= HELLO_RETRIES_MIN && retrials <= HELLO_RETRIES_MAX) {
+      m_nlsr.getConfParameter().setInterestRetryNumber(retrials);
+    }
+    else {
+      std::cerr << "Wrong value for hello-retries. ";
+      std::cerr << "Allowed value:" << HELLO_RETRIES_MIN << "-";
+      std::cerr << HELLO_RETRIES_MAX << std::endl;
+      return false;
+    }
+  }
+  catch (const std::exception& ex) {
+    std::cerr << ex.what() << std::endl;
+    return false;
+  }
+  try {
+    int timeOut = SectionAttributeTree.get<int>("hello-timeout");
+    if (timeOut >= HELLO_TIMEOUT_MIN && timeOut <= HELLO_TIMEOUT_MAX) {
+      m_nlsr.getConfParameter().setInterestResendTime(timeOut);
+    }
+    else {
+      std::cerr << "Wrong value for hello-timeout. ";
+      std::cerr << "Allowed value:" << HELLO_TIMEOUT_MIN << "-";
+      std::cerr << HELLO_TIMEOUT_MAX << std::endl;
+      return false;
+    }
+  }
+  catch (const std::exception& ex) {
+    std::cerr << ex.what() << std::endl;
+  }
+  try {
+    int interval = SectionAttributeTree.get<int>("hello-interval");
+    if (interval >= HELLO_INTERVAL_MIN && interval <= HELLO_INTERVAL_MAX) {
+      m_nlsr.getConfParameter().setInfoInterestInterval(interval);
+    }
+    else {
+      std::cerr << "Wrong value for hello-interval. ";
+      std::cerr << "Allowed value:" << HELLO_INTERVAL_MIN << "-";
+      std::cerr << HELLO_INTERVAL_MAX << std::endl;
+      return false;
+    }
+  }
+  catch (const std::exception& ex) {
+    std::cerr << ex.what() << std::endl;
+  }
+  for (boost::property_tree::ptree::const_iterator tn =
+           SectionAttributeTree.begin(); tn != SectionAttributeTree.end(); ++tn) {
+      
+    if (tn->first == "neighbor")
     {
-      for (string line; getline(inputFile, line);)
-      {
-        if (!line.empty())
-        {
-          if (line[0] != '#' && line[0] != '!')
-          {
-            ret = processConfCommand(line);
-            if (ret == -1)
-            {
-              break;
-            }
-          }
+      try {
+        boost::property_tree::ptree CommandAttriTree = tn->second;
+        std::string name = CommandAttriTree.get<std::string>("name");
+        std::string faceUri = CommandAttriTree.get<std::string>("face-uri");
+        double linkCost = CommandAttriTree.get<double>("link-cost",
+                                                       Adjacent::DEFAULT_LINK_COST);
+        ndn::Name neighborName(name);
+        if (!neighborName.empty()) {
+          Adjacent adj(name, faceUri, linkCost, ADJACENT_STATUS_INACTIVE, 0);
+          m_nlsr.getAdjacencyList().insert(adj);
+        }
+        else {
+          cerr << " Wrong command format ! [name /nbr/name/ \n face-uri /uri\n]";
+          std::cerr << " or bad URI format" << std::endl;
         }
       }
-    }
-    else
-    {
-      std::cerr << "Configuration file: (" << m_confFileName << ") does not exist :(";
-      std::cerr << endl;
-      ret = -1;
+      catch (const std::exception& ex) {
+        std::cerr << ex.what() << std::endl;
+        return false;
+      }
     }
   }
-  return ret;
+  return true;
 }
 
-
-int
-ConfFileProcessor::processConfCommand(string command)
+bool
+ConfFileProcessor::processConfSectionHyperbolic(boost::property_tree::ptree
+                                                SectionAttributeTree)
 {
-  int ret = 0;
-  Tokenizer nt(command, " ");
-  if ((nt.getFirstToken() == "network"))
-  {
-    ret = processConfCommandNetwork(nt.getRestOfLine());
+  std::string state;
+  try {
+    state= SectionAttributeTree.get<string>("state","off");
+    if (boost::iequals(state, "off")) {
+      m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_OFF);
+    }
+    else if (boost::iequals(state, "on")) {
+        m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
+    }
+    else if (state == "dry-run") {
+      m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
+    }
+    else {
+      std::cerr << "Wrong format for hyperbolic state." << std::endl;
+      std::cerr << "Allowed value: off, on, dry-run" << std::endl;
+      return false;
+    }
   }
-  else if ((nt.getFirstToken() == "site-name"))
-  {
-    ret = processConfCommandSiteName(nt.getRestOfLine());
+  catch (const std::exception& ex) {
+    std::cerr << ex.what() << std::endl;
+    return false;
   }
-  else if ((nt.getFirstToken() == "root-key-prefix"))
-  {
-    ret = processConfCommandRootKeyPrefix(nt.getRestOfLine());
+  
+  try {
+    /* Radius and angle is mandatory configuration parameter in hyperbolic section.
+     * Even if router can have hyperbolic routing calculation off but other router
+     * in the network may use hyperbolic routing calculation for FIB generation.
+     * So each router need to advertise its hyperbolic coordinates in the network
+     */
+    double radius = SectionAttributeTree.get<double>("radius");
+    double angle = SectionAttributeTree.get<double>("angle");
+    if (!m_nlsr.getConfParameter().setCorR(radius)) {
+      return false;
+    }
+    m_nlsr.getConfParameter().setCorTheta(angle);
   }
-  else if ((nt.getFirstToken() == "router-name"))
-  {
-    ret = processConfCommandRouterName(nt.getRestOfLine());
+  catch (const std::exception& ex) {
+    std::cerr << ex.what() << std::endl;
+    if (state == "on" || state == "dry-run") {
+      return false;
+    }
   }
-  else if ((nt.getFirstToken() == "ndnneighbor"))
-  {
-    ret = processConfCommandNdnNeighbor(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "link-cost"))
-  {
-    ret = processConfCommandLinkCost(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "ndnname"))
-  {
-    ret = processConfCommandNdnName(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "interest-retry-num"))
-  {
-    processConfCommandInterestRetryNumber(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "interest-resend-time"))
-  {
-    processConfCommandInterestResendTime(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "lsa-refresh-time"))
-  {
-    processConfCommandLsaRefreshTime(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "max-faces-per-prefix"))
-  {
-    processConfCommandMaxFacesPerPrefix(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "log-dir"))
-  {
-    processConfCommandLogDir(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "cert-dir"))
-  {
-    processConfCommandCertDir(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "detailed-logging"))
-  {
-    processConfCommandDetailedLogging(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "debugging"))
-  {
-    processConfCommandDebugging(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "chronosync-sync-prefix"))
-  {
-    processConfCommandChronosyncSyncPrefix(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "hyperbolic-cordinate"))
-  {
-    processConfCommandHyperbolicCordinate(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "hyperbolic-routing"))
-  {
-    processConfCommandIsHyperbolicCalc(nt.getRestOfLine());
-  }
-  else if ((nt.getFirstToken() == "tunnel-type"))
-  {
-    processConfCommandTunnelType(nt.getRestOfLine());
-  }
-  else
-  {
-    cout << "Wrong configuration Command: " << nt.getFirstToken() << endl;
-  }
-  return ret;
+  
+  return true;
 }
 
-int
-ConfFileProcessor::processConfCommandNetwork(string command)
+bool
+ConfFileProcessor::processConfSectionFib(boost::property_tree::ptree
+                                         SectionAttributeTree)
 {
-  if (command.empty())
-  {
-    cerr << " Network can not be null or empty :( !" << endl;
-    return -1;
-  }
-  else
-  {
-    if (command[command.size() - 1] == '/')
+  try {
+    int maxFacesPerPrefixNumber =
+      SectionAttributeTree.get<int>("max-faces-per-prefix");
+    if (maxFacesPerPrefixNumber >= MAX_FACES_PER_PREFIX_MIN &&
+        maxFacesPerPrefixNumber <= MAX_FACES_PER_PREFIX_MAX)
     {
-      command.erase(command.size() - 1);
+      m_nlsr.getConfParameter().setMaxFacesPerPrefix(maxFacesPerPrefixNumber);
     }
-    if (command[0] == '/')
-    {
-      command.erase(0, 1);
+    else {
+      std::cerr << "Wrong value for max-faces-per-prefix. ";
+      std::cerr << "NLSR will user default value";
+      std::cerr << MAX_FACES_PER_PREFIX_MIN << std::endl;
+      return false;
     }
-    m_nlsr.getConfParameter().setNetwork(command);
   }
-  return 0;
+  catch (const std::exception& ex) {
+    cerr << ex.what() << endl;
+    return false;
+  }
+  return true;
 }
 
-int
-ConfFileProcessor::processConfCommandSiteName(string command)
+bool
+ConfFileProcessor::processConfSectionAdvertising(boost::property_tree::ptree
+                                                 SectionAttributeTree)
 {
-  if (command.empty())
-  {
-    cerr << "Site name can not be null or empty :( !" << endl;
-    return -1;
-  }
-  else
-  {
-    if (command[command.size() - 1] == '/')
-    {
-      command.erase(command.size() - 1);
+  for (boost::property_tree::ptree::const_iterator tn =
+         SectionAttributeTree.begin(); tn != SectionAttributeTree.end(); ++tn) {
+   if (tn->first == "prefix") {
+     try {
+       std::string prefix = tn->second.data();
+       ndn::Name namePrefix(prefix);
+       if (!namePrefix.empty()) {
+         m_nlsr.getNamePrefixList().insert(namePrefix);
+       }
+       else {
+         std::cerr << " Wrong command format ! [prefix /name/prefix] or bad URI";
+         std::cerr << std::endl;
+         return false;
+       }
+     }
+     catch (const std::exception& ex) {
+       std::cerr << ex.what() << std::endl;
+       return false;
+     }
     }
-    if (command[0] == '/')
-    {
-      command.erase(0, 1);
-    }
-    m_nlsr.getConfParameter().setSiteName(command);
   }
-  return 0;
+  return true;
 }
-
-int
-ConfFileProcessor::processConfCommandRootKeyPrefix(string command)
-{
-  if (command.empty())
-  {
-    cerr << "Root Key Prefix can not be null or empty :( !" << endl;
-    return -1;
-  }
-  else
-  {
-    if (command[command.size() - 1] == '/')
-    {
-      command.erase(command.size() - 1);
-    }
-    if (command[0] == '/')
-    {
-      command.erase(0, 1);
-    }
-    m_nlsr.getConfParameter().setRootKeyPrefix(command);
-  }
-  return 0;
-}
-
-
-int
-ConfFileProcessor::processConfCommandRouterName(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Router name can not be null or empty :( !" << endl;
-    return -1;
-  }
-  else
-  {
-    if (command[command.size() - 1] == '/')
-    {
-      command.erase(command.size() - 1);
-    }
-    if (command[0] == '/')
-    {
-      command.erase(0, 1);
-    }
-    m_nlsr.getConfParameter().setRouterName(command);
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandInterestRetryNumber(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [interest-retry-num n]" << endl;
-  }
-  else
-  {
-    int irn;
-    stringstream ss(command.c_str());
-    ss >> irn;
-    if (irn >= 1 && irn <= 5)
-    {
-      m_nlsr.getConfParameter().setInterestRetryNumber(irn);
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandInterestResendTime(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [interest-resend-time s]" << endl;
-  }
-  else
-  {
-    int irt;
-    stringstream ss(command.c_str());
-    ss >> irt;
-    if (irt >= 1 && irt <= 20)
-    {
-      m_nlsr.getConfParameter().setInterestResendTime(irt);
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandLsaRefreshTime(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [interest-resend-time s]" << endl;
-  }
-  else
-  {
-    int lrt;
-    stringstream ss(command.c_str());
-    ss >> lrt;
-    if (lrt >= 240 && lrt <= 7200)
-    {
-      m_nlsr.getConfParameter().setLsaRefreshTime(lrt);
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandMaxFacesPerPrefix(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [max-faces-per-prefix n]" << endl;
-  }
-  else
-  {
-    int mfpp;
-    stringstream ss(command.c_str());
-    ss >> mfpp;
-    if (mfpp >= 0 && mfpp <= 60)
-    {
-      m_nlsr.getConfParameter().setMaxFacesPerPrefix(mfpp);
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandTunnelType(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [tunnel-type tcp/udp]!" << endl;
-  }
-  else
-  {
-    if (command == "tcp" || command == "TCP")
-    {
-      m_nlsr.getConfParameter().setTunnelType(1);
-    }
-    else if (command == "udp" || command == "UDP")
-    {
-      m_nlsr.getConfParameter().setTunnelType(0);
-    }
-    else
-    {
-      cerr << " Wrong command format ! [tunnel-type tcp/udp]!" << endl;
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandChronosyncSyncPrefix(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [chronosync-sync-prefix name/prefix]!" << endl;
-  }
-  else
-  {
-    m_nlsr.getConfParameter().setChronosyncSyncPrefix(command);
-  }
-  return 0;
-}
-
-
-int
-ConfFileProcessor::processConfCommandLogDir(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [log-dir /path/to/log/dir]!" << endl;
-  }
-  else
-  {
-    m_nlsr.getConfParameter().setLogDir(command);
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandCertDir(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [cert-dir /path/to/cert/dir]!" << endl;
-  }
-  else
-  {
-    m_nlsr.getConfParameter().setCertDir(command);
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandDebugging(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [debugging on/of]!" << endl;
-  }
-  else
-  {
-    if (command == "on" || command == "ON")
-    {
-      m_nlsr.getConfParameter().setDebugging(1);
-    }
-    else if (command == "off" || command == "off")
-    {
-      m_nlsr.getConfParameter().setDebugging(0);
-    }
-    else
-    {
-      cerr << " Wrong command format ! [debugging on/off]!" << endl;
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandDetailedLogging(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [detailed-logging on/off]!" << endl;
-  }
-  else
-  {
-    if (command == "on" || command == "ON")
-    {
-      m_nlsr.getConfParameter().setDetailedLogging(1);
-    }
-    else if (command == "off" || command == "off")
-    {
-      m_nlsr.getConfParameter().setDetailedLogging(0);
-    }
-    else
-    {
-      cerr << " Wrong command format ! [detailed-logging on/off]!" << endl;
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandIsHyperbolicCalc(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [hyperbolic-routing on/off/dry-run]!" << endl;
-  }
-  else
-  {
-    if (command == "on" || command == "ON")
-    {
-      m_nlsr.getConfParameter().setIsHyperbolicCalc(1);
-    }
-    else if (command == "dry-run" || command == "DRY-RUN")
-    {
-      m_nlsr.getConfParameter().setIsHyperbolicCalc(2);
-    }
-    else if (command == "off" || command == "off")
-    {
-      m_nlsr.getConfParameter().setIsHyperbolicCalc(0);
-    }
-    else
-    {
-      cerr << " Wrong command format ! [hyperbolic-routing on/off/dry-run]!" << endl;
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandHyperbolicCordinate(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [hyperbolic-cordinate r 0]!" << endl;
-    if (m_nlsr.getConfParameter().getIsHyperbolicCalc() > 0)
-    {
-      return -1;
-    }
-  }
-  else
-  {
-    Tokenizer nt(command, " ");
-    stringstream ssr(nt.getFirstToken().c_str());
-    stringstream sst(nt.getRestOfLine().c_str());
-    double r, theta;
-    ssr >> r;
-    sst >> theta;
-    m_nlsr.getConfParameter().setCorR(r);
-    m_nlsr.getConfParameter().setCorTheta(theta);
-  }
-  return 0;
-}
-
-
-int
-ConfFileProcessor::processConfCommandNdnNeighbor(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [ndnneighbor /nbr/name/ FaceId]!" << endl;
-  }
-  else
-  {
-    Tokenizer nt(command, " ");
-    if (nt.getRestOfLine().empty())
-    {
-      cerr << " Wrong command format ! [ndnneighbor /nbr/name/ FaceId]!" << endl;
-      return 0;
-    }
-    else
-    {
-      stringstream sst(nt.getRestOfLine().c_str());
-      int faceId;
-      sst >> faceId;
-      Adjacent adj(nt.getFirstToken(), faceId, 10, 0, 0);
-      m_nlsr.getAdjacencyList().insert(adj);
-    }
-  }
-  return 0;
-}
-
-int
-ConfFileProcessor::processConfCommandNdnName(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [ndnname name/prefix]!" << endl;
-  }
-  else
-  {
-    m_nlsr.getNamePrefixList().insert(command);
-  }
-  return 0;
-}
-
-
-int
-ConfFileProcessor::processConfCommandLinkCost(string command)
-{
-  if (command.empty())
-  {
-    cerr << " Wrong command format ! [link-cost nbr/name cost]!" << endl;
-    if (m_nlsr.getConfParameter().getIsHyperbolicCalc() > 0)
-    {
-      return -1;
-    }
-  }
-  else
-  {
-    Tokenizer nt(command, " ");
-    stringstream sst(nt.getRestOfLine().c_str());
-    double cost;
-    sst >> cost;
-    m_nlsr.getAdjacencyList().updateAdjacentLinkCost(nt.getFirstToken(), cost);
-  }
-  return 0;
-}
-
-} //namespace nlsr
-
+}//namespace NLSR
diff --git a/src/conf-file-processor.hpp b/src/conf-file-processor.hpp
index 61265b7..b12e8f9 100644
--- a/src/conf-file-processor.hpp
+++ b/src/conf-file-processor.hpp
@@ -1,7 +1,10 @@
-#ifndef CONF_FILE_PROCESSOR_HPP
-#define CONF_FILE_PROCESSOR_HPP
+#ifndef CONF_PROCESSOR_HPP
+#define CONF_PROCESSOR_HPP
 
+#include <boost/smart_ptr/shared_ptr.hpp>
+#include <boost/property_tree/ptree.hpp>
 #include <boost/cstdint.hpp>
+
 #include "nlsr.hpp"
 
 namespace nlsr {
@@ -15,69 +18,31 @@
   {
   }
 
-  int processConfFile();
+  bool
+  processConfFile();
 
 private:
-  int
-  processConfCommand(std::string command);
+  bool
+  load(std::istream& input);
 
-  int
-  processConfCommandNetwork(std::string command);
+  bool
+  processSection(const std::string& section,
+                 boost::property_tree::ptree SectionAttributeTree);
 
-  int
-  processConfCommandSiteName(std::string command);
+  bool
+  processConfSectionGeneral(boost::property_tree::ptree SectionAttributeTree);
 
-  int
-  processConfCommandRootKeyPrefix(std::string command);
+  bool
+  processConfSectionNeighbors(boost::property_tree::ptree SectionAttributeTree);
 
-  int
-  processConfCommandRouterName(std::string command);
+  bool
+  processConfSectionHyperbolic(boost::property_tree::ptree SectionAttributeTree);
 
-  int
-  processConfCommandInterestRetryNumber(std::string command);
+  bool
+  processConfSectionFib(boost::property_tree::ptree SectionAttributeTree);
 
-  int
-  processConfCommandInterestResendTime(std::string command);
-
-  int
-  processConfCommandLsaRefreshTime(std::string command);
-
-  int
-  processConfCommandMaxFacesPerPrefix(std::string command);
-
-  int
-  processConfCommandTunnelType(std::string command);
-
-  int
-  processConfCommandChronosyncSyncPrefix(std::string command);
-
-  int
-  processConfCommandLogDir(std::string command);
-
-  int
-  processConfCommandCertDir(std::string command);
-
-  int
-  processConfCommandDebugging(std::string command);
-
-  int
-  processConfCommandDetailedLogging(std::string command);
-
-  int
-  processConfCommandIsHyperbolicCalc(std::string command);
-
-  int
-  processConfCommandHyperbolicCordinate(std::string command);
-
-  int
-  processConfCommandNdnNeighbor(std::string command);
-
-  int
-  processConfCommandNdnName(std::string command);
-
-  int
-  processConfCommandLinkCost(std::string command);
-
+  bool
+  processConfSectionAdvertising(boost::property_tree::ptree SectionAttributeTree);
 
 private:
   std::string m_confFileName;
@@ -85,4 +50,4 @@
 };
 
 } //namespace nlsr
-#endif //CONF_FILE_PROCESSOR_HPP
+#endif //CONF_PROCESSOR_HPP
diff --git a/src/conf-parameter.cpp b/src/conf-parameter.cpp
deleted file mode 100644
index 2bb337f..0000000
--- a/src/conf-parameter.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <iostream>
-#include "conf-parameter.hpp"
-
-namespace nlsr {
-
-using namespace std;
-
-ostream&
-operator<<(ostream& os, ConfParameter& cfp)
-{
-  os  << "Router Name: " << cfp.getRouterName() << endl;
-  os  << "Site Name: " << cfp.getSiteName() << endl;
-  os  << "Network: " << cfp.getNetwork() << endl;
-  os  << "Router Prefix: " << cfp.getRouterPrefix() << endl;
-  os  << "ChronoSync sync Prifex: " << cfp.getChronosyncSyncPrefix() << endl;
-  os  << "Interest Retry number: " << cfp.getInterestRetryNumber() << endl;
-  os  << "Interest Resend second: " << cfp.getInterestResendTime() << endl;
-  os  << "Info Interest Interval: " << cfp.getInfoInterestInterval() << endl;
-  os  << "LSA refresh time: " << cfp.getLsaRefreshTime() << endl;
-  os  << "Max Faces Per Prefix: " << cfp.getMaxFacesPerPrefix() << endl;
-  os  << "Log Dir: " << cfp.getLogDir() << endl;
-  os  << "Detalied logging: " << cfp.getDetailedLogging() << endl;
-  os  << "Debugging: " << cfp.getDebugging() << endl;
-  os  << "Hyperbolic ROuting: " << cfp.getIsHyperbolicCalc() << endl;
-  os  << "Hyp R: " << cfp.getCorR() << endl;
-  os  << "Hyp theta: " << cfp.getCorTheta() << endl;
-  os  << "Tunnel Type: " << cfp.getTunnelType() << endl;
-  return  os;
-}
-
-} //namespace nlsr
diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp
index 5b5b560..6f1dc86 100644
--- a/src/conf-parameter.hpp
+++ b/src/conf-parameter.hpp
@@ -7,58 +7,70 @@
 #include <ndn-cxx/face.hpp>
 
 namespace nlsr {
+
+enum {
+  LSA_REFRESH_TIME_MIN = 240,
+  LSA_REFRESH_TIME_DEFAULT = 1800,
+  LSA_REFRESH_TIME_MAX = 7200
+};
+
+enum {
+  HELLO_RETRIES_MIN = 1,
+  HELLO_RETRIES_DEFAULT = 3,
+  HELLO_RETRIES_MAX = 15
+};
+
+enum {
+  HELLO_TIMEOUT_MIN = 1,
+  HELLO_TIMEOUT_DEFAULT = 3,
+  HELLO_TIMEOUT_MAX = 15
+};
+
+enum {
+  HELLO_INTERVAL_MIN = 30,
+  HELLO_INTERVAL_DEFAULT = 60,
+  HELLO_INTERVAL_MAX =90
+};
+
+enum {
+  MAX_FACES_PER_PREFIX_MIN = 0,
+  MAX_FACES_PER_PREFIX_MAX = 60
+};
+
+enum {
+  HYPERBOLIC_STATE_OFF = 0,
+  HYPERBOLIC_STATE_ON = 1,
+  HYPERBOLIC_STATE_DRY_RUN = 2
+};
+
 class ConfParameter
 {
 
 public:
   ConfParameter()
-    : m_chronosyncSyncPrefix("ndn/nlsr/sync")
-    , m_chronosyncLsaPrefix("/ndn/nlsr/LSA")
-    , m_rootKeyPrefix("/ndn/keys")
-    , m_interestRetryNumber(3)
-    , m_interestResendTime(5)
-    , m_infoInterestInterval(60)
-    , m_lsaRefreshTime(1800)
-    , m_routerDeadInterval(3600)
-    , m_maxFacesPerPrefix(0)
-    , m_tunnelType(0)
-    , m_detailedLogging(0)
-    , m_certDir()
-    , m_debugging(0)
-    , m_seqFileDir()
-    , m_isHyperbolicCalc(0)
+    : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
+    , m_routerDeadInterval(2*LSA_REFRESH_TIME_DEFAULT)
+    , m_logLevel("INFO")
+    , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
+    , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
+    , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
+    , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
     , m_corR(0)
     , m_corTheta(0)
+    , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
   {}
 
   void
-  setRouterName(const std::string& rn)
+  setNetwork(const ndn::Name& networkName)
   {
-    m_routerName = ndn::Name(rn);
-  }
-
-  const ndn::Name&
-  getRouterName()
-  {
-    return m_routerName;
-  }
-
-  void
-  setSiteName(const std::string& sn)
-  {
-    m_siteName = ndn::Name(sn);
-  }
-
-  const ndn::Name&
-  getSiteName()
-  {
-    return m_siteName;
-  }
-
-  void
-  setNetwork(const std::string& nn)
-  {
-    m_network = ndn::Name(nn);
+    m_network = networkName;
+    m_chronosyncPrefix = m_network;
+    m_chronosyncPrefix.append("nlsr");
+    m_chronosyncPrefix.append("sync");
+    
+    m_lsaPrefix = m_network;
+    m_lsaPrefix.append("nlsr");
+    m_lsaPrefix.append("LSA");
   }
 
   const ndn::Name&
@@ -68,9 +80,32 @@
   }
 
   void
+  setRouterName(const ndn::Name& routerName)
+  {
+    m_routerName = routerName;
+  }
+
+  const ndn::Name&
+  getRouterName()
+  {
+    return m_routerName;
+  }
+
+  void
+  setSiteName(const ndn::Name& siteName)
+  {
+    m_siteName = siteName;
+  }
+
+  const ndn::Name&
+  getSiteName()
+  {
+    return m_siteName;
+  }
+
+  void
   buildRouterPrefix()
   {
-    //m_routerPrefix = "/" + m_network + "/" + m_siteName + "/" + m_routerName;
     m_routerPrefix = m_network;
     m_routerPrefix.append(m_siteName);
     m_routerPrefix.append(m_routerName);
@@ -82,40 +117,17 @@
     return m_routerPrefix;
   }
 
+
   const ndn::Name&
-  getRootKeyPrefix()
+  getChronosyncPrefix()
   {
-    return m_rootKeyPrefix;
+    return m_chronosyncPrefix;
   }
 
-  void
-  setRootKeyPrefix(std::string rkp)
+  const ndn::Name&
+  getLsaPrefix()
   {
-    m_rootKeyPrefix = ndn::Name(rkp);
-  }
-
-  void
-  setInterestRetryNumber(uint32_t irn)
-  {
-    m_interestRetryNumber = irn;
-  }
-
-  uint32_t
-  getInterestRetryNumber()
-  {
-    return m_interestRetryNumber;
-  }
-
-  void
-  setInterestResendTime(int32_t irt)
-  {
-    m_interestResendTime = irt;
-  }
-
-  int32_t
-  getInterestResendTime()
-  {
-    return m_interestResendTime;
+    return m_lsaPrefix;
   }
 
   void
@@ -142,95 +154,75 @@
   {
     return m_routerDeadInterval;
   }
+  
+  void 
+  setLogLevel(const std::string& logLevel)
+  {
+    m_logLevel = logLevel;
+  }
+  
+  const std::string& 
+  getLogLevel()
+  {
+    return m_logLevel;
+  }
 
   void
-  setMaxFacesPerPrefix(int32_t mfpp)
+  setInterestRetryNumber(uint32_t irn)
   {
-    m_maxFacesPerPrefix = mfpp;
+    m_interestRetryNumber = irn;
+  }
+
+  uint32_t
+  getInterestRetryNumber()
+  {
+    return m_interestRetryNumber;
+  }
+
+  void
+  setInterestResendTime(int32_t irt)
+  {
+    m_interestResendTime = irt;
   }
 
   int32_t
-  getMaxFacesPerPrefix()
+  getInterestResendTime()
   {
-    return m_maxFacesPerPrefix;
-  }
-
-  void
-  setLogDir(const std::string& ld)
-  {
-    m_logDir = ld;
-  }
-
-  std::string
-  getLogDir()
-  {
-    return m_logDir;
-  }
-
-  void
-  setCertDir(const std::string& cd)
-  {
-    m_certDir = cd;
-  }
-
-  const std::string&
-  getCertDir()
-  {
-    return m_certDir;
-  }
-
-  void
-  setSeqFileDir(const std::string& ssfd)
-  {
-    m_seqFileDir = ssfd;
-  }
-
-  const std::string&
-  getSeqFileDir()
-  {
-    return m_seqFileDir;
-  }
-
-  void
-  setDetailedLogging(int dl)
-  {
-    m_detailedLogging = dl;
-  }
-
-  int
-  getDetailedLogging()
-  {
-    return m_detailedLogging;
-  }
-
-  void
-  setDebugging(int32_t d)
-  {
-    m_debugging = d;
+    return m_interestResendTime;
   }
 
   int32_t
-  getDebugging()
+  getInfoInterestInterval()
   {
-    return m_debugging;
+    return m_infoInterestInterval;
   }
 
   void
-  setIsHyperbolicCalc(int32_t ihc)
+  setInfoInterestInterval(int32_t iii)
   {
-    m_isHyperbolicCalc = ihc;
+    m_infoInterestInterval = iii;
+  }
+
+  void
+  setHyperbolicState(int32_t ihc)
+  {
+    m_hyperbolicState = ihc;
   }
 
   int32_t
-  getIsHyperbolicCalc()
+  getHyperbolicState()
   {
-    return m_isHyperbolicCalc;
+    return m_hyperbolicState;
   }
 
-  void
+  bool
   setCorR(double cr)
   {
-    m_corR = cr;
+    if ( cr >= 0 ) {
+     m_corR = cr;
+     return true;
+    }
+    return false;
   }
 
   double
@@ -250,54 +242,31 @@
   {
     return m_corTheta;
   }
-
+  
   void
-  setTunnelType(int tt)
+  setMaxFacesPerPrefix(int32_t mfpp)
   {
-    m_tunnelType = tt;
+    m_maxFacesPerPrefix = mfpp;
   }
 
   int32_t
-  getTunnelType()
+  getMaxFacesPerPrefix()
   {
-    return m_tunnelType;
+    return m_maxFacesPerPrefix;
   }
 
   void
-  setChronosyncSyncPrefix(const std::string& csp)
+  setSeqFileDir(const std::string& ssfd)
   {
-    m_chronosyncSyncPrefix = ndn::Name(csp);
+    m_seqFileDir = ssfd;
   }
 
-  const ndn::Name&
-  getChronosyncSyncPrefix()
+  const std::string&
+  getSeqFileDir()
   {
-    return m_chronosyncSyncPrefix;
+    return m_seqFileDir;
   }
 
-  void
-  setChronosyncLsaPrefix(const std::string& clp)
-  {
-    m_chronosyncLsaPrefix = ndn::Name(clp);
-  }
-
-  const ndn::Name&
-  getChronosyncLsaPrefix()
-  {
-    return m_chronosyncLsaPrefix;
-  }
-
-  int32_t
-  getInfoInterestInterval()
-  {
-    return m_infoInterestInterval;
-  }
-
-  void
-  setInfoInterestInterval(int32_t iii)
-  {
-    m_infoInterestInterval = iii;
-  }
 
 private:
   ndn::Name m_routerName;
@@ -307,35 +276,48 @@
   ndn::Name m_routerPrefix;
   ndn::Name m_lsaRouterPrefix;
 
-  ndn::Name m_chronosyncSyncPrefix;
-  ndn::Name m_chronosyncLsaPrefix;
-  ndn::Name m_rootKeyPrefix;
+  ndn::Name m_chronosyncPrefix;
+  ndn::Name m_lsaPrefix;
+
+  int32_t  m_lsaRefreshTime;
+  int64_t  m_routerDeadInterval;
+  std::string m_logLevel;
 
   uint32_t m_interestRetryNumber;
-  int32_t m_interestResendTime;
-  int32_t m_infoInterestInterval;
-  int32_t m_lsaRefreshTime;
-  int64_t m_routerDeadInterval;
-
-  int32_t m_maxFacesPerPrefix;
-  int32_t m_tunnelType;
-  int32_t m_detailedLogging;
-
-  std::string m_certDir;
-  int32_t m_debugging;
-  std::string m_seqFileDir;
-
-  int32_t m_isHyperbolicCalc;
+  int32_t  m_interestResendTime;
+  
+  
+  int32_t  m_infoInterestInterval;
+  
+  int32_t m_hyperbolicState;
   double m_corR;
   double m_corTheta;
 
-  std::string m_logFile;
-  std::string m_logDir;
+  int32_t m_maxFacesPerPrefix;
+  
+  std::string m_seqFileDir;
 
 };
 
-std::ostream&
-operator<<(std::ostream& os, ConfParameter& cfp);
+inline std::ostream&
+operator<<(std::ostream& os, ConfParameter& cfp)
+{
+  os  << "Router Name: " << cfp.getRouterName() << std::endl;
+  os  << "Site Name: " << cfp.getSiteName() << std::endl;
+  os  << "Network: " << cfp.getNetwork() << std::endl;
+  os  << "Router Prefix: " << cfp.getRouterPrefix() << std::endl;
+  os  << "ChronoSync sync Prifex: " << cfp.getChronosyncPrefix() << std::endl;
+  os  << "ChronoSync LSA prefix: " << cfp.getLsaPrefix() << std::endl;
+  os  << "Interest Retry number: " << cfp.getInterestRetryNumber() << std::endl;
+  os  << "Interest Resend second: " << cfp.getInterestResendTime() << std::endl;
+  os  << "Info Interest Interval: " << cfp.getInfoInterestInterval() << std::endl;
+  os  << "LSA refresh time: " << cfp.getLsaRefreshTime() << std::endl;
+  os  << "Max Faces Per Prefix: " << cfp.getMaxFacesPerPrefix() << std::endl;
+  os  << "Hyperbolic ROuting: " << cfp.getHyperbolicState() << std::endl;
+  os  << "Hyp R: " << cfp.getCorR() << std::endl;
+  os  << "Hyp theta: " << cfp.getCorTheta() << std::endl;
+  return  os;
+}
 
 } // namespace nlsr
 
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
index ccc2f5b..2dc106c 100644
--- a/src/hello-protocol.cpp
+++ b/src/hello-protocol.cpp
@@ -5,6 +5,8 @@
 
 namespace nlsr {
 
+const std::string HelloProtocol::INFO_COMPONENT="info";
+
 void
 HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
 {
@@ -25,11 +27,10 @@
 {
   std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList();
   for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
-       ++it)
-  {
+       ++it) {
     ndn::Name interestName = (*it).getName() ;
-    interestName.append("info");
-    interestName.append(ndn::Name(m_nlsr.getConfParameter().getRouterPrefix()));
+    interestName.append(INFO_COMPONENT);
+    interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
     expressInterest(interestName,
                     m_nlsr.getConfParameter().getInterestResendTime());
   }
@@ -50,27 +51,24 @@
 {
   const ndn::Name interestName = interest.getName();
   std::cout << "Interest Received for Name: " << interestName << std::endl;
-  std::string chkString("info");
-  int32_t infoPosition = util::getNameComponentPosition(interestName, chkString);
-  if (infoPosition < 0)
-  {
+  if (interestName.get(-2).toUri() != INFO_COMPONENT) {
     return;
   }
-  ndn::Name neighbor = interestName.getSubName(infoPosition + 1);
+  ndn::Name neighbor;
+  neighbor.wireDecode(interestName.get(-1).blockFromValue());
   std::cout << "Neighbor: " << neighbor << std::endl;
-  if (m_nlsr.getAdjacencyList().isNeighbor(neighbor))
-  {
+  if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) {
     ndn::Data data(ndn::Name(interest.getName()).appendVersion());
     data.setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
-    data.setContent((const uint8_t*)"info", sizeof("info"));
+    data.setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()),
+                    INFO_COMPONENT.size());
     m_keyChain.sign(data);
     std::cout << ">> D: " << data << std::endl;
     m_nlsr.getNlsrFace().put(data);
     int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
-    if (status == 0)
-    {
+    if (status == 0) {
       ndn::Name interestName(neighbor);
-      interestName.append("info");
+      interestName.append(INFO_COMPONENT);
       interestName.append(m_nlsr.getConfParameter().getRouterPrefix());
       expressInterest(interestName,
                       m_nlsr.getConfParameter().getInterestResendTime());
@@ -83,13 +81,10 @@
 {
   const ndn::Name interestName(interest.getName());
   std::cout << "Interest timed out for Name: " << interestName << std::endl;
-  std::string chkString("info");
-  int32_t infoPosition = util::getNameComponentPosition(interestName, chkString);
-  if (infoPosition < 0)
-  {
+  if (interestName.get(-2).toUri() != INFO_COMPONENT) {
     return;
   }
-  ndn::Name neighbor = interestName.getSubName(0, infoPosition);
+  ndn::Name neighbor = interestName.getPrefix(-2);
   std::cout << "Neighbor: " << neighbor << std::endl;
   m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor);
   int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
@@ -98,22 +93,19 @@
   std::cout << "Neighbor: " << neighbor << std::endl;
   std::cout << "Status: " << status << std::endl;
   std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
-  if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber()))
-  {
+  if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber())) {
     ndn::Name interestName(neighbor);
-    interestName.append("info");
-    interestName.append(m_nlsr.getConfParameter().getRouterPrefix());
+    interestName.append(INFO_COMPONENT);
+    interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
     expressInterest(interestName,
                     m_nlsr.getConfParameter().getInterestResendTime());
   }
   else if ((status == 1) &&
-           (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()))
-  {
+           (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber())) {
     m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 0);
     m_nlsr.incrementAdjBuildCount();
-    if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
-    {
-      m_nlsr.setIsBuildAdjLsaSheduled(1);
+    if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
+      m_nlsr.setIsBuildAdjLsaSheduled(true);
       // event here
       m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
                                           ndn::bind(&Lsdb::scheduledAdjLsaBuild,
@@ -129,11 +121,8 @@
 {
   ndn::Name dataName = data.getName();
   std::cout << "Data received for name: " << dataName << std::endl;
-  std::string chkString("info");
-  int32_t infoPosition = util::getNameComponentPosition(dataName, chkString);
-  if (infoPosition >= 0)
-  {
-    ndn::Name neighbor = dataName.getSubName(0, infoPosition);
+  if (dataName.get(-3).toUri() == INFO_COMPONENT) {
+    ndn::Name neighbor = dataName.getPrefix(-3);
     int oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
     int infoIntTimedOutCount = m_nlsr.getAdjacencyList().getTimedOutInterestCount(
                                  neighbor);
@@ -154,17 +143,16 @@
     std::cout << "Status: " << newStatus << std::endl;
     std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
     //debugging purpose end
-    if ((oldStatus - newStatus) != 0)  // change in Adjacency list
-    {
+    // change in Adjacency list
+    if ((oldStatus - newStatus) != 0) {
       m_nlsr.incrementAdjBuildCount();
       /* Need to schedule event for Adjacency LSA building */
-      if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
-      {
-        m_nlsr.setIsBuildAdjLsaSheduled(1);
+      if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
+        m_nlsr.setIsBuildAdjLsaSheduled(true);
         // event here
         m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
                                             ndn::bind(&Lsdb::scheduledAdjLsaBuild,
-                                                      boost::ref(m_nlsr.getLsdb())));
+                                                      ndn::ref(m_nlsr.getLsdb())));
       }
     }
   }
diff --git a/src/hello-protocol.hpp b/src/hello-protocol.hpp
index 984413d..ecdd6c5 100644
--- a/src/hello-protocol.hpp
+++ b/src/hello-protocol.hpp
@@ -41,6 +41,7 @@
 private:
   Nlsr& m_nlsr;
   ndn::KeyChain m_keyChain;
+  static const std::string INFO_COMPONENT;
 };
 
 } //namespace nlsr
diff --git a/src/lsa.cpp b/src/lsa.cpp
index 2ad95c5..14d033a 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -11,14 +11,12 @@
 #include "lsa.hpp"
 #include "name-prefix-list.hpp"
 #include "adjacent.hpp"
-#include "utility/tokenizer.hpp"
 
 
 namespace nlsr {
 
 using namespace std;
 
-
 const ndn::Name
 NameLsa::getKey() const
 {
@@ -36,8 +34,7 @@
   m_lsSeqNo = lsn;
   m_lifeTime = lt;
   std::list<ndn::Name>& nl = npl.getNameList();
-  for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++)
-  {
+  for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++) {
     addName((*it));
   }
 }
@@ -52,8 +49,7 @@
   nameLsaData += "|";
   nameLsaData += boost::lexical_cast<std::string>(m_npl.getSize());
   std::list<ndn::Name> nl = m_npl.getNameList();
-  for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++)
-  {
+  for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++) {
     nameLsaData += "|";
     nameLsaData += (*it).toUri();
   }
@@ -69,8 +65,7 @@
   boost::tokenizer<boost::char_separator<char> >::iterator tok_iter =
                                                tokens.begin();
   m_origRouter = ndn::Name(*tok_iter++);
-  if (!(m_origRouter.size() > 0))
-  {
+  if (!(m_origRouter.size() > 0)) {
     return false;
   }
   try {
@@ -82,8 +77,7 @@
   catch (std::exception& e) {
     return false;
   }
-  for (uint32_t i = 0; i < numName; i++)
-  {
+  for (uint32_t i = 0; i < numName; i++) {
     string name(*tok_iter++);
     addName(name);
   }
@@ -167,8 +161,7 @@
   boost::tokenizer<boost::char_separator<char> >::iterator tok_iter =
                                                tokens.begin();
   m_origRouter = ndn::Name(*tok_iter++);
-  if (!(m_origRouter.size() > 0))
-  {
+  if (!(m_origRouter.size() > 0)) {
     return false;
   }
   try {
@@ -208,10 +201,8 @@
   m_lifeTime = lt;
   m_noLink = nl;
   std::list<Adjacent> al = adl.getAdjList();
-  for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++)
-  {
-    if ((*it).getStatus() == 1)
-    {
+  for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++) {
+    if ((*it).getStatus() == 1) {
       addAdjacent((*it));
     }
   }
@@ -242,12 +233,11 @@
   adjLsaData += "|";
   adjLsaData += boost::lexical_cast<std::string>(m_adl.getSize());
   std::list<Adjacent> al = m_adl.getAdjList();
-  for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++)
-  {
+  for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++) {
     adjLsaData += "|";
     adjLsaData += (*it).getName().toUri();
     adjLsaData += "|";
-    adjLsaData += boost::lexical_cast<std::string>((*it).getConnectingFace());
+    adjLsaData += (*it).getConnectingFaceUri();
     adjLsaData += "|";
     adjLsaData += boost::lexical_cast<std::string>((*it).getLinkCost());
   }
@@ -263,8 +253,7 @@
   boost::tokenizer<boost::char_separator<char> >::iterator tok_iter =
                                                tokens.begin();
   m_origRouter = ndn::Name(*tok_iter++);
-  if (!(m_origRouter.size() > 0))
-  {
+  if (!(m_origRouter.size() > 0)) {
     return false;
   }
   try {
@@ -276,13 +265,12 @@
   catch (std::exception& e) {
     return false;
   }
-  for (uint32_t i = 0; i < numLink; i++)
-  {
+  for (uint32_t i = 0; i < numLink; i++) {
     try {
       string adjName(*tok_iter++);
-      int connectingFace = boost::lexical_cast<int>(*tok_iter++);
+      std::string connectingFaceUri(*tok_iter++);
       double linkCost = boost::lexical_cast<double>(*tok_iter++);
-      Adjacent adjacent(adjName, connectingFace, linkCost, 0, 0);
+      Adjacent adjacent(adjName, connectingFaceUri, linkCost, 0, 0);
       addAdjacent(adjacent);
     }
     catch (std::exception& e) {
@@ -296,8 +284,7 @@
 void
 AdjLsa::addNptEntries(Nlsr& pnlsr)
 {
-  if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
-  {
+  if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix()) {
     pnlsr.getNamePrefixTable().addEntry(getOrigRouter(), getOrigRouter());
   }
 }
@@ -306,8 +293,7 @@
 void
 AdjLsa::removeNptEntries(Nlsr& pnlsr)
 {
-  if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
-  {
+  if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix()) {
     pnlsr.getNamePrefixTable().removeEntry(getOrigRouter(), getOrigRouter());
   }
 }
@@ -330,7 +316,7 @@
   {
     os << "    Adjacent " << i << ": " << endl;
     os << "      Adjacent Name: " << (*it).getName() << endl;
-    os << "      Connecting Face: " << (*it).getConnectingFace() << endl;
+    os << "      Connecting FaceUri: " << (*it).getConnectingFaceUri() << endl;
     os << "      Link Cost: " << (*it).getLinkCost() << endl;
   }
   return os;
diff --git a/src/lsa.hpp b/src/lsa.hpp
index 0220897..041e32c 100644
--- a/src/lsa.hpp
+++ b/src/lsa.hpp
@@ -152,8 +152,7 @@
   }
 
   AdjLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
-         uint32_t lt,
-         uint32_t nl , AdjacencyList& adl);
+         uint32_t lt, uint32_t nl , AdjacencyList& adl);
 
   AdjacencyList&
   getAdl()
@@ -226,20 +225,13 @@
   double
   getCorRadius() const
   {
-    if (m_corRad >= 0)
-    {
       return m_corRad;
-    }
-    else
-    {
-      return -1;
-    }
   }
 
   void
   setCorRadius(double cr)
   {
-    m_corRad = cr;
+      m_corRad = cr;
   }
 
   double
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index a5eb2b2..0b34867 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -1,7 +1,9 @@
 #include <string>
 #include <utility>
+
 #include "lsdb.hpp"
 #include "nlsr.hpp"
+#include "conf-parameter.hpp"
 #include "utility/name-helper.hpp"
 
 namespace nlsr {
@@ -39,8 +41,7 @@
   std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
                                                  m_nameLsdb.end(),
                                                  bind(nameLsaCompareByKey, _1, key));
-  if (it != m_nameLsdb.end())
-  {
+  if (it != m_nameLsdb.end()) {
     return &(*it);
   }
   return 0;
@@ -50,14 +51,11 @@
 Lsdb::isNameLsaNew(const ndn::Name& key, uint64_t seqNo)
 {
   NameLsa* nameLsaCheck = findNameLsa(key);
-  if (nameLsaCheck != 0)
-  {
-    if (nameLsaCheck->getLsSeqNo() < seqNo)
-    {
+  if (nameLsaCheck != 0) {
+    if (nameLsaCheck->getLsSeqNo() < seqNo) {
       return true;
     }
-    else
-    {
+    else {
       return false;
     }
   }
@@ -77,37 +75,30 @@
 {
   int timeToExpire = m_lsaRefreshTime;
   NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
-  if (chkNameLsa == 0)
-  {
+  if (chkNameLsa == 0) {
     addNameLsa(nlsa);
     nlsa.writeLog();
     printNameLsdb();
-    if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-    {
+    if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
       m_nlsr.getNamePrefixTable().addEntry(nlsa.getOrigRouter(),
                                            nlsa.getOrigRouter());
       std::list<ndn::Name> nameList = nlsa.getNpl().getNameList();
       for (std::list<ndn::Name>::iterator it = nameList.begin(); it != nameList.end();
-           it++)
-      {
-        if ((*it) != m_nlsr.getConfParameter().getRouterPrefix())
-        {
+           it++) {
+        if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
           m_nlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter());
         }
       }
     }
-    if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-    {
+    if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
       timeToExpire = nlsa.getLifeTime();
     }
     nlsa.setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
                                                       nlsa.getLsSeqNo(),
                                                       timeToExpire));
   }
-  else
-  {
-    if (chkNameLsa->getLsSeqNo() < nlsa.getLsSeqNo())
-    {
+  else {
+    if (chkNameLsa->getLsSeqNo() < nlsa.getLsSeqNo()) {
       chkNameLsa->writeLog();
       chkNameLsa->setLsSeqNo(nlsa.getLsSeqNo());
       chkNameLsa->setLifeTime(nlsa.getLifeTime());
@@ -120,14 +111,10 @@
                           chkNameLsa->getNpl().getNameList().end(),
                           std::inserter(nameToAdd, nameToAdd.begin()));
       for (std::list<ndn::Name>::iterator it = nameToAdd.begin();
-           it != nameToAdd.end();
-           ++it)
-      {
+           it != nameToAdd.end(); ++it) {
         chkNameLsa->addName((*it));
-        if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-        {
-          if ((*it) != m_nlsr.getConfParameter().getRouterPrefix())
-          {
+        if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
+          if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
             m_nlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter());
           }
         }
@@ -139,19 +126,15 @@
                           nlsa.getNpl().getNameList().end(),
                           std::inserter(nameToRemove, nameToRemove.begin()));
       for (std::list<ndn::Name>::iterator it = nameToRemove.begin();
-           it != nameToRemove.end(); ++it)
-      {
+           it != nameToRemove.end(); ++it) {
         chkNameLsa->removeName((*it));
-        if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-        {
-          if ((*it) != m_nlsr.getConfParameter().getRouterPrefix())
-          {
+        if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
+          if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
             m_nlsr.getNamePrefixTable().removeEntry((*it), nlsa.getOrigRouter());
           }
         }
       }
-      if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-      {
+      if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
         timeToExpire = nlsa.getLifeTime();
       }
       cancelScheduleLsaExpiringEvent(chkNameLsa->getExpiringEventId());
@@ -171,8 +154,7 @@
                                                  m_nameLsdb.end(),
                                                  bind(nameLsaCompareByKey, _1,
                                                       nlsa.getKey()));
-  if (it == m_nameLsdb.end())
-  {
+  if (it == m_nameLsdb.end()) {
     m_nameLsdb.push_back(nlsa);
     return true;
   }
@@ -184,20 +166,16 @@
 {
   std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
                                                  m_nameLsdb.end(),
-                                                 bind(nameLsaCompareByKey, _1, key));
-  if (it != m_nameLsdb.end())
-  {
+                                                 ndn::bind(nameLsaCompareByKey, _1, key));
+  if (it != m_nameLsdb.end()) {
     (*it).writeLog();
     if ((*it).getOrigRouter() !=
-        m_nlsr.getConfParameter().getRouterPrefix())
-    {
+        m_nlsr.getConfParameter().getRouterPrefix()) {
       m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
                                               (*it).getOrigRouter());
       for (std::list<ndn::Name>::iterator nit = (*it).getNpl().getNameList().begin();
-           nit != (*it).getNpl().getNameList().end(); ++nit)
-      {
-        if ((*nit) != m_nlsr.getConfParameter().getRouterPrefix())
-        {
+           nit != (*it).getNpl().getNameList().end(); ++nit) {
+        if ((*nit) != m_nlsr.getConfParameter().getRouterPrefix()) {
           m_nlsr.getNamePrefixTable().removeEntry((*nit), (*it).getOrigRouter());
         }
       }
@@ -213,9 +191,8 @@
 {
   std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
                                                  m_nameLsdb.end(),
-                                                 bind(nameLsaCompareByKey, _1, key));
-  if (it == m_nameLsdb.end())
-  {
+                                                 ndn::bind(nameLsaCompareByKey, _1, key));
+  if (it == m_nameLsdb.end()) {
     return false;
   }
   return true;
@@ -226,8 +203,7 @@
 {
   cout << "---------------Name LSDB-------------------" << endl;
   for (std::list<NameLsa>::iterator it = m_nameLsdb.begin();
-       it != m_nameLsdb.end() ; it++)
-  {
+       it != m_nameLsdb.end() ; it++) {
     cout << (*it) << endl;
   }
 }
@@ -260,9 +236,8 @@
 {
   std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
                                                        m_corLsdb.end(),
-                                                       bind(corLsaCompareByKey, _1, key));
-  if (it != m_corLsdb.end())
-  {
+                                                       ndn::bind(corLsaCompareByKey, _1, key));
+  if (it != m_corLsdb.end()) {
     return &(*it);
   }
   return 0;
@@ -272,14 +247,11 @@
 Lsdb::isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo)
 {
   CoordinateLsa* clsa = findCoordinateLsa(key);
-  if (clsa != 0)
-  {
-    if (clsa->getLsSeqNo() < seqNo)
-    {
+  if (clsa != 0) {
+    if (clsa->getLsSeqNo() < seqNo) {
       return true;
     }
-    else
-    {
+    else {
       return false;
     }
   }
@@ -300,43 +272,35 @@
 {
   int timeToExpire = m_lsaRefreshTime;
   CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
-  if (chkCorLsa == 0)
-  {
+  if (chkCorLsa == 0) {
     addCoordinateLsa(clsa);
-    printCorLsdb(); //debugging purpose
-    if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-    {
+    //debugging purpose
+    printCorLsdb();
+    if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
       m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
                                            clsa.getOrigRouter());
     }
-    if (m_nlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
-    {
+    if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
       m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
     }
-    if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-    {
+    if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
       timeToExpire = clsa.getLifeTime();
     }
     scheduleCoordinateLsaExpiration(clsa.getKey(),
                                     clsa.getLsSeqNo(), timeToExpire);
   }
-  else
-  {
-    if (chkCorLsa->getLsSeqNo() < clsa.getLsSeqNo())
-    {
+  else {
+    if (chkCorLsa->getLsSeqNo() < clsa.getLsSeqNo()) {
       chkCorLsa->setLsSeqNo(clsa.getLsSeqNo());
       chkCorLsa->setLifeTime(clsa.getLifeTime());
-      if (!chkCorLsa->isEqualContent(clsa))
-      {
+      if (!chkCorLsa->isEqualContent(clsa)) {
         chkCorLsa->setCorRadius(clsa.getCorRadius());
         chkCorLsa->setCorTheta(clsa.getCorTheta());
-        if (m_nlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
-        {
+        if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
           m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
         }
       }
-      if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-      {
+      if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
         timeToExpire = clsa.getLifeTime();
       }
       cancelScheduleLsaExpiringEvent(chkCorLsa->getExpiringEventId());
@@ -353,10 +317,9 @@
 {
   std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
                                                        m_corLsdb.end(),
-                                                       bind(corLsaCompareByKey, _1,
-                                                            clsa.getKey()));
-  if (it == m_corLsdb.end())
-  {
+                                                       ndn::bind(corLsaCompareByKey, _1,
+                                                                 clsa.getKey()));
+  if (it == m_corLsdb.end()) {
     m_corLsdb.push_back(clsa);
     return true;
   }
@@ -368,12 +331,11 @@
 {
   std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
                                                        m_corLsdb.end(),
-                                                       bind(corLsaCompareByKey, _1, key));
-  if (it != m_corLsdb.end())
-  {
+                                                       ndn::bind(corLsaCompareByKey,
+                                                                 _1, key));
+  if (it != m_corLsdb.end()) {
     if ((*it).getOrigRouter() !=
-        m_nlsr.getConfParameter().getRouterPrefix())
-    {
+        m_nlsr.getConfParameter().getRouterPrefix()) {
       m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
                                               (*it).getOrigRouter());
     }
@@ -388,21 +350,21 @@
 {
   std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
                                                        m_corLsdb.end(),
-                                                       bind(corLsaCompareByKey, _1, key));
-  if (it == m_corLsdb.end())
-  {
+                                                       ndn::bind(corLsaCompareByKey,
+                                                                 _1, key));
+  if (it == m_corLsdb.end()) {
     return false;
   }
   return true;
 }
 
+//debugging
 void
-Lsdb::printCorLsdb() //debugging
+Lsdb::printCorLsdb()
 {
   cout << "---------------Cor LSDB-------------------" << endl;
   for (std::list<CoordinateLsa>::iterator it = m_corLsdb.begin();
-       it != m_corLsdb.end() ; it++)
-  {
+       it != m_corLsdb.end() ; it++) {
     cout << (*it) << endl;
   }
 }
@@ -422,17 +384,13 @@
 {
   cout << "scheduledAdjLsaBuild Called" << endl;
   m_nlsr.setIsBuildAdjLsaSheduled(0);
-  if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr))
-  {
+  if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr)) {
     int adjBuildCount = m_nlsr.getAdjBuildCount();
-    if (adjBuildCount > 0)
-    {
-      if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0)
-      {
+    if (adjBuildCount > 0) {
+      if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0) {
         buildAndInstallOwnAdjLsa();
       }
-      else
-      {
+      else {
         ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
         key.append("adjacency");
         removeAdjLsa(key);
@@ -441,8 +399,7 @@
       m_nlsr.setAdjBuildCount(m_nlsr.getAdjBuildCount() - adjBuildCount);
     }
   }
-  else
-  {
+  else {
     m_nlsr.setIsBuildAdjLsaSheduled(1);
     int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
                          m_nlsr.getConfParameter().getInterestResendTime();
@@ -460,8 +417,7 @@
                                                 m_adjLsdb.end(),
                                                 bind(adjLsaCompareByKey, _1,
                                                      alsa.getKey()));
-  if (it == m_adjLsdb.end())
-  {
+  if (it == m_adjLsdb.end()) {
     m_adjLsdb.push_back(alsa);
     return true;
   }
@@ -474,8 +430,7 @@
   std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
                                                 m_adjLsdb.end(),
                                                 bind(adjLsaCompareByKey, _1, key));
-  if (it != m_adjLsdb.end())
-  {
+  if (it != m_adjLsdb.end()) {
     return &(*it);
   }
   return 0;
@@ -486,14 +441,11 @@
 Lsdb::isAdjLsaNew(const ndn::Name& key, uint64_t seqNo)
 {
   AdjLsa*  adjLsaCheck = findAdjLsa(key);
-  if (adjLsaCheck != 0)
-  {
-    if (adjLsaCheck->getLsSeqNo() < seqNo)
-    {
+  if (adjLsaCheck != 0) {
+    if (adjLsaCheck->getLsSeqNo() < seqNo) {
       return true;
     }
-    else
-    {
+    else {
       return false;
     }
   }
@@ -514,32 +466,26 @@
 {
   int timeToExpire = m_lsaRefreshTime;
   AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
-  if (chkAdjLsa == 0)
-  {
+  if (chkAdjLsa == 0) {
     addAdjLsa(alsa);
     alsa.addNptEntries(m_nlsr);
     m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
-    if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-    {
+    if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
       timeToExpire = alsa.getLifeTime();
     }
     scheduleAdjLsaExpiration(alsa.getKey(),
                              alsa.getLsSeqNo(), timeToExpire);
   }
-  else
-  {
-    if (chkAdjLsa->getLsSeqNo() < alsa.getLsSeqNo())
-    {
+  else {
+    if (chkAdjLsa->getLsSeqNo() < alsa.getLsSeqNo()) {
       chkAdjLsa->setLsSeqNo(alsa.getLsSeqNo());
       chkAdjLsa->setLifeTime(alsa.getLifeTime());
-      if (!chkAdjLsa->isEqualContent(alsa))
-      {
+      if (!chkAdjLsa->isEqualContent(alsa)) {
         chkAdjLsa->getAdl().reset();
         chkAdjLsa->getAdl().addAdjacents(alsa.getAdl());
         m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
       }
-      if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
-      {
+      if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
         timeToExpire = alsa.getLifeTime();
       }
       cancelScheduleLsaExpiringEvent(chkAdjLsa->getExpiringEventId());
@@ -562,7 +508,7 @@
                 m_nlsr.getAdjacencyList());
   m_nlsr.getSequencingManager().increaseAdjLsaSeq();
   // publish routing update
-  ndn::Name lsaPrefix = m_nlsr.getConfParameter().getChronosyncLsaPrefix();
+  ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
   lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
   m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
                                                     lsaPrefix);
@@ -574,9 +520,8 @@
 {
   std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
                                                 m_adjLsdb.end(),
-                                                bind(adjLsaCompareByKey, _1, key));
-  if (it != m_adjLsdb.end())
-  {
+                                                ndn::bind(adjLsaCompareByKey, _1, key));
+  if (it != m_adjLsdb.end()) {
     (*it).removeNptEntries(m_nlsr);
     m_adjLsdb.erase(it);
     return true;
@@ -590,8 +535,7 @@
   std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
                                                 m_adjLsdb.end(),
                                                 bind(adjLsaCompareByKey, _1, key));
-  if (it == m_adjLsdb.end())
-  {
+  if (it == m_adjLsdb.end()) {
     return false;
   }
   return true;
@@ -621,13 +565,10 @@
   cout << "Lsdb::exprireOrRefreshNameLsa Called " << endl;
   cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
   NameLsa* chkNameLsa = findNameLsa(lsaKey);
-  if (chkNameLsa != 0)
-  {
+  if (chkNameLsa != 0) {
     cout << " LSA Exists with seq no: " << chkNameLsa->getLsSeqNo() << endl;
-    if (chkNameLsa->getLsSeqNo() == seqNo)
-    {
-      if (chkNameLsa->getOrigRouter() == m_thisRouterPrefix)
-      {
+    if (chkNameLsa->getLsSeqNo() == seqNo) {
+      if (chkNameLsa->getOrigRouter() == m_thisRouterPrefix) {
         chkNameLsa->writeLog();
         cout << "Own Name LSA, so refreshing name LSA" << endl;
         chkNameLsa->setLsSeqNo(chkNameLsa->getLsSeqNo() + 1);
@@ -638,13 +579,12 @@
                                                                  chkNameLsa->getLsSeqNo(),
                                                                  m_lsaRefreshTime));
         // publish routing update
-        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getChronosyncLsaPrefix();
+        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
         lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
         m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
                                                           lsaPrefix);
       }
-      else
-      {
+      else {
         cout << "Other's Name LSA, so removing form LSDB" << endl;
         removeNameLsa(lsaKey);
       }
@@ -658,13 +598,10 @@
   cout << "Lsdb::exprireOrRefreshAdjLsa Called " << endl;
   cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
   AdjLsa* chkAdjLsa = findAdjLsa(lsaKey);
-  if (chkAdjLsa != 0)
-  {
+  if (chkAdjLsa != 0) {
     cout << " LSA Exists with seq no: " << chkAdjLsa->getLsSeqNo() << endl;
-    if (chkAdjLsa->getLsSeqNo() == seqNo)
-    {
-      if (chkAdjLsa->getOrigRouter() == m_thisRouterPrefix)
-      {
+    if (chkAdjLsa->getLsSeqNo() == seqNo) {
+      if (chkAdjLsa->getOrigRouter() == m_thisRouterPrefix) {
         cout << "Own Adj LSA, so refreshing Adj LSA" << endl;
         chkAdjLsa->setLsSeqNo(chkAdjLsa->getLsSeqNo() + 1);
         m_nlsr.getSequencingManager().setAdjLsaSeq(chkAdjLsa->getLsSeqNo());
@@ -673,13 +610,12 @@
                                                                chkAdjLsa->getLsSeqNo(),
                                                                m_lsaRefreshTime));
         // publish routing update
-        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getChronosyncLsaPrefix();
+        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
         lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
         m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
                                                           lsaPrefix);
       }
-      else
-      {
+      else {
         cout << "Other's Adj LSA, so removing form LSDB" << endl;
         removeAdjLsa(lsaKey);
       }
@@ -696,13 +632,10 @@
   cout << "Lsdb::exprireOrRefreshCorLsa Called " << endl;
   cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
   CoordinateLsa* chkCorLsa = findCoordinateLsa(lsaKey);
-  if (chkCorLsa != 0)
-  {
+  if (chkCorLsa != 0) {
     cout << " LSA Exists with seq no: " << chkCorLsa->getLsSeqNo() << endl;
-    if (chkCorLsa->getLsSeqNo() == seqNo)
-    {
-      if (chkCorLsa->getOrigRouter() == m_thisRouterPrefix)
-      {
+    if (chkCorLsa->getLsSeqNo() == seqNo) {
+      if (chkCorLsa->getOrigRouter() == m_thisRouterPrefix) {
         cout << "Own Cor LSA, so refreshing Cor LSA" << endl;
         chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
         m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
@@ -712,18 +645,16 @@
                                         chkCorLsa->getLsSeqNo(),
                                         m_lsaRefreshTime));
         // publish routing update
-        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getChronosyncLsaPrefix();
+        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
         lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
         m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
                                                           lsaPrefix);
       }
-      else
-      {
+      else {
         cout << "Other's Cor LSA, so removing form LSDB" << endl;
         removeCoordinateLsa(lsaKey);
       }
-      if (m_nlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
-      {
+      if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
         m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
       }
     }
@@ -753,41 +684,36 @@
   string chkString("LSA");
   int32_t lsaPosition = util::getNameComponentPosition(interest.getName(),
                                                        chkString);
-  if (lsaPosition >= 0)
-  {
+  if (lsaPosition >= 0) {
     std::string interestedLsType;
     uint64_t interestedLsSeqNo;
     ndn::Name origRouter = intName.getSubName(lsaPosition + 1,
                                               interest.getName().size() - lsaPosition - 3);
-    interestedLsType  = intName[-2].toEscapedString();
+    interestedLsType  = intName[-2].toUri();
     interestedLsSeqNo = intName[-1].toNumber();
     std::cout << "Router Name: " << origRouter << std::endl;
     std::cout << "Ls Type    : " << interestedLsType << std::endl;
     std::cout << "Ls Seq     : " << interestedLsSeqNo << endl;
     std::cout << "Ls Type: " << interestedLsType << std::endl;
-    if (interestedLsType == "name")
-    {
+    if (interestedLsType == "name") {
       processInterestForNameLsa(interest,
                                 origRouter.append(interestedLsType),
                                 interestedLsSeqNo);
       return;
     }
-    else if (interestedLsType == "adjacency")
-    {
+    else if (interestedLsType == "adjacency") {
       processInterestForAdjacencyLsa(interest,
                                      origRouter.append(interestedLsType),
                                      interestedLsSeqNo);
       return;
     }
-    else if (interestedLsType == "coordinate")
-    {
+    else if (interestedLsType == "coordinate") {
       processInterestForCoordinateLsa(interest,
                                       origRouter.append(interestedLsType),
                                       interestedLsSeqNo);
       return;
     }
-    else
-    {
+    else {
       cout << "Unrecognized LSA Type :(" << endl;
     }
   }
@@ -799,10 +725,8 @@
                                 uint32_t interestedlsSeqNo)
 {
   NameLsa*  nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
-  if (nameLsa != 0)
-  {
-    if (nameLsa->getLsSeqNo() >= interestedlsSeqNo)
-    {
+  if (nameLsa != 0) {
+    if (nameLsa->getLsSeqNo() >= interestedlsSeqNo) {
       ndn::Data data(ndn::Name(interest.getName()).appendVersion());
       data.setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
       std::string content = nameLsa->getData();
@@ -821,10 +745,8 @@
                                      uint32_t interestedlsSeqNo)
 {
   AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
-  if (adjLsa != 0)
-  {
-    if (adjLsa->getLsSeqNo() >= interestedlsSeqNo)
-    {
+  if (adjLsa != 0) {
+    if (adjLsa->getLsSeqNo() >= interestedlsSeqNo) {
       ndn::Data data(ndn::Name(interest.getName()).appendVersion());
       data.setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
       std::string content = adjLsa->getData();
@@ -843,10 +765,8 @@
                                       uint32_t interestedlsSeqNo)
 {
   CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
-  if (corLsa != 0)
-  {
-    if (corLsa->getLsSeqNo() >= interestedlsSeqNo)
-    {
+  if (corLsa != 0) {
+    if (corLsa->getLsSeqNo() >= interestedlsSeqNo) {
       ndn::Data data(ndn::Name(interest.getName()).appendVersion());
       data.setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
       std::string content = corLsa->getData();
@@ -867,37 +787,32 @@
   string dataContent(reinterpret_cast<const char*>(data.getContent().value()));
   string chkString("LSA");
   int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);
-  if (lsaPosition >= 0)
-  {
+  if (lsaPosition >= 0) {
     std::string interestedLsType;
     uint64_t interestedLsSeqNo;
     ndn::Name origRouter = dataName.getSubName(lsaPosition + 1,
                                                dataName.size() - lsaPosition - 4);
-    interestedLsType  = dataName[-3].toEscapedString();
+    interestedLsType  = dataName[-3].toUri();
     interestedLsSeqNo = dataName[-2].toNumber();
     std::cout << "Ls Type    : " << interestedLsType << std::endl;
     std::cout << "Ls Seq     : " << interestedLsSeqNo << std::endl;
     std::cout << "Ls Type: " << interestedLsType << std::endl;
-    if (interestedLsType == "name")
-    {
+    if (interestedLsType == "name") {
       processContentNameLsa(origRouter.append(interestedLsType),
                             interestedLsSeqNo, dataContent);
       return;
     }
-    else if (interestedLsType == "adjacency")
-    {
+    else if (interestedLsType == "adjacency") {
       processContentAdjacencyLsa(origRouter.append(interestedLsType),
                                  interestedLsSeqNo, dataContent);
       return;
     }
-    else if (interestedLsType == "coordinate")
-    {
+    else if (interestedLsType == "coordinate") {
       processContentCoordinateLsa(origRouter.append(interestedLsType),
                                   interestedLsSeqNo, dataContent);
       return;
     }
-    else
-    {
+    else {
       cout << "Unrecognized LSA Type :(" << endl;
     }
   }
@@ -907,15 +822,12 @@
 Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
                             uint32_t lsSeqNo, std::string& dataContent)
 {
-  if (isNameLsaNew(lsaKey, lsSeqNo))
-  {
+  if (isNameLsaNew(lsaKey, lsSeqNo)) {
     NameLsa nameLsa;
-    if (nameLsa.initializeFromContent(dataContent))
-    {
+    if (nameLsa.initializeFromContent(dataContent)) {
       installNameLsa(nameLsa);
     }
-    else
-    {
+    else {
       std::cout << "LSA data decoding error :(" << std::endl;
     }
   }
@@ -925,15 +837,12 @@
 Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
                                  uint32_t lsSeqNo, std::string& dataContent)
 {
-  if (isAdjLsaNew(lsaKey, lsSeqNo))
-  {
+  if (isAdjLsaNew(lsaKey, lsSeqNo)) {
     AdjLsa adjLsa;
-    if (adjLsa.initializeFromContent(dataContent))
-    {
+    if (adjLsa.initializeFromContent(dataContent)) {
       installAdjLsa(adjLsa);
     }
-    else
-    {
+    else {
       std::cout << "LSA data decoding error :(" << std::endl;
     }
   }
@@ -943,15 +852,12 @@
 Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
                                   uint32_t lsSeqNo, std::string& dataContent)
 {
-  if (isCoordinateLsaNew(lsaKey, lsSeqNo))
-  {
+  if (isCoordinateLsaNew(lsaKey, lsSeqNo)) {
     CoordinateLsa corLsa;
-    if (corLsa.initializeFromContent(dataContent))
-    {
+    if (corLsa.initializeFromContent(dataContent)) {
       installCoordinateLsa(corLsa);
     }
-    else
-    {
+    else {
       std::cout << "LSA data decoding error :(" << std::endl;
     }
   }
@@ -970,8 +876,7 @@
 {
   cout << "---------------Adj LSDB-------------------" << endl;
   for (std::list<AdjLsa>::iterator it = m_adjLsdb.begin();
-       it != m_adjLsdb.end() ; it++)
-  {
+       it != m_adjLsdb.end() ; it++) {
     cout << (*it) << endl;
   }
 }
@@ -980,16 +885,13 @@
 bool
 Lsdb::doesLsaExist(const ndn::Name& key, const std::string& lsType)
 {
-  if (lsType == "name")
-  {
+  if (lsType == "name") {
     return doesNameLsaExist(key);
   }
-  else if (lsType == "adjacency")
-  {
+  else if (lsType == "adjacency") {
     return doesAdjLsaExist(key);
   }
-  else if (lsType == "coordinate")
-  {
+  else if (lsType == "coordinate") {
     return doesCoordinateLsaExist(key);
   }
   return false;
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 3ad3007..ff7450a 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -39,8 +39,9 @@
   bool
   isNameLsaNew(const ndn::Name& key, uint64_t seqNo);
 
+  //debugging
   void
-  printNameLsdb(); //debugging
+  printNameLsdb();
 
   //function related to Cor LSDB
   bool
@@ -58,8 +59,9 @@
   bool
   isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo);
 
+  //debugging
   void
-  printCorLsdb(); //debugging
+  printCorLsdb();
 
   //function related to Adj LSDB
   void
diff --git a/src/main.cpp b/src/main.cpp
index 59829b1..9e3bf12 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -30,8 +30,7 @@
   std::string programName(argv[0]);
   nlsr.setConfFileName("nlsr.conf");
   int32_t opt;
-  while ((opt = getopt(argc, argv, "df:p:h")) != -1)
-  {
+  while ((opt = getopt(argc, argv, "df:p:h")) != -1) {
     switch (opt)
     {
       case 'f':
@@ -56,8 +55,7 @@
   }
   ConfFileProcessor cfp(nlsr, nlsr.getConfFileName());
   int32_t res = cfp.processConfFile();
-  if (res < 0)
-  {
+  if (res < 0) {
     std::cerr << "Error in configuration file processing! Exiting from NLSR" <<
               std::endl;
     return EXIT_FAILURE;
diff --git a/src/name-prefix-list.cpp b/src/name-prefix-list.cpp
index c8d9285..f00d0d0 100644
--- a/src/name-prefix-list.cpp
+++ b/src/name-prefix-list.cpp
@@ -30,8 +30,7 @@
                                                    m_nameList.end(),
                                                    ndn::bind(&nameCompare, _1 ,
                                                              ndn::cref(name)));
-  if (it != m_nameList.end())
-  {
+  if (it != m_nameList.end()) {
     return -1;
   }
   m_nameList.push_back(name);
@@ -45,8 +44,7 @@
                                                    m_nameList.end(),
                                                    ndn::bind(&nameCompare, _1 ,
                                                    ndn::cref(name)));
-  if (it != m_nameList.end())
-  {
+  if (it != m_nameList.end()) {
     m_nameList.erase(it);
   }
   return -1;
@@ -63,9 +61,7 @@
 {
   int i = 1;
   for (std::list<ndn::Name>::iterator it = m_nameList.begin();
-       it != m_nameList.end();
-       it++)
-  {
+       it != m_nameList.end(); it++) {
     cout << "Name " << i << " : " << (*it) << endl;
     i++;
   }
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 91b4c25..a55f634 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -4,6 +4,7 @@
 #include <cstdio>
 
 #include "nlsr.hpp"
+#include "adjacent.hpp"
 
 
 namespace nlsr {
@@ -18,6 +19,10 @@
   throw Error("Error: Prefix registration failed");
 }
 
+void
+Nlsr::onRegistrationSuccess(const ndn::Name& name)
+{
+}
 
 void
 Nlsr::setInfoInterestFilter()
@@ -26,23 +31,43 @@
   getNlsrFace().setInterestFilter(name,
                                   ndn::bind(&HelloProtocol::processInterest,
                                             &m_helloProtocol, _1, _2),
+                                  ndn::bind(&Nlsr::onRegistrationSuccess, this, _1),
                                   ndn::bind(&Nlsr::registrationFailed, this, _1));
 }
 
 void
 Nlsr::setLsaInterestFilter()
 {
-  // ndn::Name name(m_confParam.getChronosyncLsaPrefix() +
-  //                m_confParam.getRouterPrefix());
-  ndn::Name name = m_confParam.getChronosyncLsaPrefix();
+  ndn::Name name = m_confParam.getLsaPrefix();
   name.append(m_confParam.getRouterPrefix());
   getNlsrFace().setInterestFilter(name,
                                   ndn::bind(&Lsdb::processInterest,
                                             &m_nlsrLsdb, _1, _2),
+                                  ndn::bind(&Nlsr::onRegistrationSuccess, this, _1),
                                   ndn::bind(&Nlsr::registrationFailed, this, _1));
 }
 
 void
+Nlsr::registerPrefixes()
+{
+  std::string strategy("ndn:/localhost/nfd/strategy/broadcast");
+  std::list<Adjacent>& adjacents = m_adjacencyList.getAdjList();
+  for (std::list<Adjacent>::iterator it = adjacents.begin();
+       it != adjacents.end(); it++) {
+    m_fib.registerPrefix((*it).getName(), (*it).getConnectingFaceUri(),
+                         (*it).getLinkCost(), 31536000); /* One Year in seconds */
+    m_fib.registerPrefix(m_confParam.getChronosyncPrefix(),
+                         (*it).getConnectingFaceUri(), (*it).getLinkCost(), 31536000);
+    m_fib.registerPrefix(m_confParam.getLsaPrefix(),
+                         (*it).getConnectingFaceUri(), (*it).getLinkCost(), 31536000);
+     m_fib.setStrategy((*it).getName(), strategy);
+  }
+  
+  m_fib.setStrategy(m_confParam.getChronosyncPrefix(), strategy);
+  m_fib.setStrategy(m_confParam.getLsaPrefix(), strategy);
+}
+
+void
 Nlsr::initialize()
 {
   m_confParam.buildRouterPrefix();
@@ -56,11 +81,12 @@
   m_adjacencyList.print();
   m_namePrefixList.print();
   /* debugging purpose end */
+  registerPrefixes();
   m_nlsrLsdb.buildAndInstallOwnNameLsa();
   m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
   setInfoInterestFilter();
   setLsaInterestFilter();
-  m_syncLogicHandler.setSyncPrefix(m_confParam.getChronosyncSyncPrefix().toUri());
+  m_syncLogicHandler.setSyncPrefix(m_confParam.getChronosyncPrefix().toUri());
   m_syncLogicHandler.createSyncSocket(boost::ref(*this));
   //m_interestManager.scheduleInfoInterest(10);
   m_helloProtocol.scheduleInterest(10);
diff --git a/src/nlsr.hpp b/src/nlsr.hpp
index 6bf45bd..6fc255d 100644
--- a/src/nlsr.hpp
+++ b/src/nlsr.hpp
@@ -59,6 +59,9 @@
   registrationFailed(const ndn::Name& name);
 
   void
+  onRegistrationSuccess(const ndn::Name& name);
+
+  void
   setInfoInterestFilter();
 
   void
@@ -172,7 +175,7 @@
     m_adjBuildCount = abc;
   }
 
-  int
+  bool
   getIsBuildAdjLsaSheduled()
   {
     return m_isBuildAdjLsaSheduled;
@@ -231,6 +234,10 @@
   initialize();
 
 private:
+  void
+  registerPrefixes();
+
+private:
   ndn::Face m_nlsrFace;
   ndn::Scheduler m_scheduler;
   ConfParameter m_confParam;
diff --git a/src/route/face-map.hpp b/src/route/face-map.hpp
new file mode 100644
index 0000000..d861339
--- /dev/null
+++ b/src/route/face-map.hpp
@@ -0,0 +1,115 @@
+#ifndef NLSR_FACE_MAP_HPP
+#define NLSR_FACE_MAP_HPP
+
+namespace nlsr {
+
+class FaceMapEntry {
+
+public:
+  FaceMapEntry(const std::string& faceUri, uint32_t faceId)
+    : m_faceUri(faceUri)
+    , m_faceId(faceId)
+  {
+  }
+
+  void
+  setFaceUri(const std::string& faceUri)
+  {
+    m_faceUri = faceUri;
+  }
+
+  const std::string&
+  getFaceUri() const
+  {
+    return m_faceUri;
+  }
+
+  void
+  setFaceId(uint32_t faceId)
+  {
+    m_faceId = faceId;
+  }
+
+  uint32_t
+  getFaceId() const
+  {
+    return m_faceId;
+  }
+
+  bool
+  compare(const FaceMapEntry& fme)
+  {
+    return m_faceUri == fme.getFaceUri();
+  }
+
+private:
+  std::string m_faceUri;
+  uint32_t m_faceId;
+};
+
+inline std::ostream&
+operator<<(std::ostream& os, const FaceMapEntry& fme)
+{
+  os << "Face Map Entry (FaceUri: " << fme.getFaceUri() << " Face Id: ";
+  os << fme.getFaceId() << ")" << std::endl;
+  return os;
+}
+
+class FaceMap {
+
+public:
+  FaceMap()
+  {
+  }
+
+  ~FaceMap()
+  {
+  }
+
+  inline void
+  update(const std::string& faceUri, uint32_t faceId)
+  {
+    FaceMapEntry fme(faceUri, faceId);
+    std::list<FaceMapEntry>::iterator it = std::find_if(m_table.begin(),
+                                                        m_table.end(),
+                                                        bind(&FaceMapEntry::compare,
+                                                             &fme, _1));
+    if (it == m_table.end()) {
+      m_table.push_back(fme);
+    }
+    else {
+      (*it).setFaceId(fme.getFaceId());
+    }
+  }
+
+  inline uint32_t
+  getFaceId(const std::string& faceUri)
+  {
+    FaceMapEntry fme(faceUri, 0);
+    std::list<FaceMapEntry>::iterator it = std::find_if(m_table.begin(),
+                                                        m_table.end(),
+                                                        bind(&FaceMapEntry::compare,
+                                                             &fme, _1));
+    if (it != m_table.end()) {
+      return (*it).getFaceId();
+    }
+    return 0;
+  }
+
+  inline void
+  print()
+  {
+    std::cout << "------- Face Map-----------" << std::endl;
+    for(std::list<FaceMapEntry>::iterator it = m_table.begin();
+        it != m_table.end(); ++it) {
+          std::cout << (*it);
+    }
+  }
+
+private:
+  std::list<FaceMapEntry> m_table;
+};
+
+} //namespace nlsr
+
+#endif //NLSR_FACE_MAP_HPP
diff --git a/src/route/fib-entry.cpp b/src/route/fib-entry.cpp
index 524b04c..ba3d77a 100644
--- a/src/route/fib-entry.cpp
+++ b/src/route/fib-entry.cpp
@@ -9,25 +9,20 @@
 bool
 FibEntry::isEqualNextHops(NexthopList& nhlOther)
 {
-  if (m_nexthopList.getSize() != nhlOther.getSize())
-  {
+  if (m_nexthopList.getSize() != nhlOther.getSize()) {
     return false;
   }
-  else
-  {
+  else {
     uint32_t nhCount = 0;
     std::list<NextHop>::iterator it1, it2;
     for (it1 = m_nexthopList.getNextHops().begin(),
          it2 = nhlOther.getNextHops().begin() ;
-         it1 != m_nexthopList.getNextHops().end() ; it1++, it2++)
-    {
-      if (it1->getConnectingFace() == it2->getConnectingFace())
-      {
+         it1 != m_nexthopList.getNextHops().end() ; it1++, it2++) {
+      if (it1->getConnectingFaceUri() == it2->getConnectingFaceUri()) {
         it1->setRouteCost(it2->getRouteCost());
         nhCount++;
       }
-      else
-      {
+      else {
         break;
       }
     }
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index fc823c1..a68d4d6 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -1,8 +1,10 @@
 #include <list>
 #include <cmath>
+#include <ndn-cxx/common.hpp>
 
 #include "nlsr.hpp"
 #include "nexthop-list.hpp"
+#include "face-map.hpp"
 #include "fib.hpp"
 
 
@@ -45,19 +47,16 @@
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
                                                   bind(&fibEntryNameCompare, _1, name));
-  if (it != m_table.end())
-  {
+  if (it != m_table.end()) {
     std::cout << "Entry found with Seq Num: " << feSeqNum << std::endl;
-    if (it->getSeqNo() == feSeqNum)
-    {
+    if (it->getSeqNo() == feSeqNum) {
       std::cout << "Refreshing the FIB entry" << std::endl;
       for (std::list<NextHop>::iterator nhit =
              (*it).getNexthopList().getNextHops().begin();
-           nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
-      {
+           nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
         // add entry to NDN-FIB
-        registerPrefixInNfd(it->getName(), nhit->getConnectingFace(),
-                            std::ceil(nhit->getRouteCost()));
+        registerPrefix(it->getName(), nhit->getConnectingFaceUri(),
+                       std::ceil(nhit->getRouteCost()), m_refreshTime);
       }
       // increase sequence number and schedule refresh again
       it->setSeqNo(feSeqNum + 1);
@@ -74,23 +73,19 @@
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
                                                   bind(&fibEntryNameCompare, _1, name));
-  if (it != m_table.end())
-  {
+  if (it != m_table.end()) {
     for (std::list<NextHop>::iterator nhit =
            (*it).getNexthopList().getNextHops().begin();
-         nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
-    {
+         nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
       //remove entry from NDN-FIB
-      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName()))
-      {
-        unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
+      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName())) {
+        unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
       }
       else
       {
-        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() !=
-            nhit->getConnectingFace())
-        {
-          unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
+        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFaceUri() !=
+            nhit->getConnectingFaceUri()) {
+          unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
         }
       }
     }
@@ -112,20 +107,17 @@
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
                                                   bind(&fibEntryNameCompare, _1, name));
-  if (it == m_table.end())
-  {
-    if (nextHopList.getSize() > 0)
-    {
+  if (it == m_table.end()) {
+    if (nextHopList.getSize() > 0) {
       nextHopList.sort();
       FibEntry newEntry(name);
       std::list<NextHop> nhl = nextHopList.getNextHops();
       std::list<NextHop>::iterator nhit = nhl.begin();
-      for (int i = startFace; i < endFace && nhit != nhl.end(); ++nhit, i++)
-      {
+      for (int i = startFace; i < endFace && nhit != nhl.end(); ++nhit, i++) {
         newEntry.getNexthopList().addNextHop((*nhit));
         //Add entry to NDN-FIB
-        registerPrefixInNfd(name, nhit->getConnectingFace(),
-                            std::ceil(nhit->getRouteCost()));
+        registerPrefix(name, nhit->getConnectingFaceUri(),
+                       std::ceil(nhit->getRouteCost()), m_refreshTime);
       }
       newEntry.getNexthopList().sort();
       newEntry.setTimeToRefresh(m_refreshTime);
@@ -134,30 +126,26 @@
       m_table.push_back(newEntry);
     }
   }
-  else
-  {
+  else {
     std::cout << "Old FIB Entry" << std::endl;
-    if (nextHopList.getSize() > 0)
-    {
+    if (nextHopList.getSize() > 0) {
       nextHopList.sort();
-      if (!it->isEqualNextHops(nextHopList))
-      {
+      if (!it->isEqualNextHops(nextHopList)) {
         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(it->getNexthopList(), nhit->getConnectingFace(), name);
+        registerPrefix(name, nhit->getConnectingFaceUri(),
+                       std::ceil(nhit->getRouteCost()), m_refreshTime);
+        removeHop(it->getNexthopList(), nhit->getConnectingFaceUri(), name);
         it->getNexthopList().reset();
         it->getNexthopList().addNextHop((*nhit));
         ++startFace;
         ++nhit;
-        for (int i = startFace; i < endFace && nhit != nhl.end(); ++nhit, i++)
-        {
+        for (int i = startFace; i < endFace && nhit != nhl.end(); ++nhit, i++) {
           it->getNexthopList().addNextHop((*nhit));
           //Add Entry to NDN_FIB
-          registerPrefixInNfd(name, nhit->getConnectingFace(),
-                              std::ceil(nhit->getRouteCost()));
+          registerPrefix(name, nhit->getConnectingFaceUri(),
+                         std::ceil(nhit->getRouteCost()), m_refreshTime);
         }
       }
       it->setTimeToRefresh(m_refreshTime);
@@ -168,8 +156,7 @@
       (*it).setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
                                                        it->getSeqNo(), m_refreshTime));
     }
-    else
-    {
+    else {
       remove(name);
     }
   }
@@ -181,33 +168,27 @@
 Fib::clean()
 {
   for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
-       ++it)
-  {
+       ++it) {
     std::cout << "Cancellling Scheduled event" << std::endl;
     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++)
-    {
+         nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
       //Remove entry from NDN-FIB
-      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName()))
-      {
-        unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
+      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName())) {
+        unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
       }
-      else
-      {
-        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() !=
-            nhit->getConnectingFace())
-        {
-          unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
+      else {
+        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFaceUri() !=
+            nhit->getConnectingFaceUri()) {
+          unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
         }
       }
     }
   }
-  if (m_table.size() > 0)
-  {
+  if (m_table.size() > 0) {
     m_table.clear();
   }
 }
@@ -217,37 +198,30 @@
                              uint32_t maxFacesPerPrefix)
 {
   int endFace = 0;
-  if ((maxFacesPerPrefix == 0) || (nextHopList.getSize() <= maxFacesPerPrefix))
-  {
+  if ((maxFacesPerPrefix == 0) || (nextHopList.getSize() <= maxFacesPerPrefix)) {
     return nextHopList.getSize();
   }
-  else
-  {
+  else {
     return maxFacesPerPrefix;
   }
   return endFace;
 }
 
 void
-Fib::removeHop(NexthopList& nl, uint32_t doNotRemoveHopFaceId,
+Fib::removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
                const ndn::Name& name)
 {
   for (std::list<NextHop>::iterator it = nl.getNextHops().begin();
-       it != nl.getNextHops().end();   ++it)
-  {
-    if (it->getConnectingFace() != doNotRemoveHopFaceId)
-    {
+       it != nl.getNextHops().end();   ++it) {
+    if (it->getConnectingFaceUri() != doNotRemoveHopFaceUri) {
       //Remove FIB Entry from NDN-FIB
-      if (!m_nlsr.getAdjacencyList().isNeighbor(name))
-      {
-        unregisterPrefixFromNfd(name, it->getConnectingFace());
+      if (!m_nlsr.getAdjacencyList().isNeighbor(name)) {
+        unregisterPrefix(name, it->getConnectingFaceUri());
       }
-      else
-      {
-        if (m_nlsr.getAdjacencyList().getAdjacent(name).getConnectingFace() !=
-            it->getConnectingFace())
-        {
-          unregisterPrefixFromNfd(name, it->getConnectingFace());
+      else {
+        if (m_nlsr.getAdjacencyList().getAdjacent(name).getConnectingFaceUri() !=
+            it->getConnectingFaceUri()) {
+          unregisterPrefix(name, it->getConnectingFaceUri());
         }
       }
     }
@@ -255,43 +229,88 @@
 }
 
 void
-Fib::registerPrefixInNfd(const ndn::Name& namePrefix, uint64_t faceId,
-                         uint64_t faceCost)
+Fib::registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
+                    uint64_t faceCost, uint64_t timeout)
+{
+  ndn::nfd::ControlParameters faceParameters;
+  faceParameters
+  .setUri(faceUri);
+
+  m_controller.start<ndn::nfd::FaceCreateCommand>(faceParameters,
+                                                  ndn::bind(&Fib::registerPrefixInNfd, this,_1,
+                                                            namePrefix, faceCost, timeout),
+                                                  ndn::bind(&Fib::onFailure, this, _1, _2,
+                                                             "Failed in name registration"));
+  
+}
+
+void
+Fib::registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult, 
+                         const ndn::Name& namePrefix, uint64_t faceCost, uint64_t timeout)
 {
   ndn::nfd::ControlParameters controlParameters;
   controlParameters
-  .setName(namePrefix)
-  .setCost(faceCost)
-  .setFaceId(faceId)
-  .setExpirationPeriod(ndn::time::milliseconds(m_refreshTime * 1000))
-  .setOrigin(128);
+    .setName(namePrefix)
+    .setFaceId(faceCreateResult.getFaceId())
+    .setCost(faceCost)
+    .setExpirationPeriod(ndn::time::milliseconds(timeout * 1000))
+    .setOrigin(128);
   m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
-                                                   ndn::bind(&Fib::onSuccess, this, _1,
-                                                             "Successful in name registration"),
+                                                   ndn::bind(&Fib::onRegistration, this, _1,
+                                                             "Successful in name registration",
+                                                             faceCreateResult.getUri()),
                                                    ndn::bind(&Fib::onFailure, this, _1, _2,
                                                              "Failed in name registration"));
 }
 
 void
-Fib::unregisterPrefixFromNfd(const ndn::Name& namePrefix, uint64_t faceId)
+Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
 {
-  ndn::nfd::ControlParameters controlParameters;
-  controlParameters
-  .setName(namePrefix)
-  .setFaceId(faceId)
-  .setOrigin(128);
-  m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
+  uint32_t faceId = m_faceMap.getFaceId(faceUri);
+  if (faceId > 0) {
+    ndn::nfd::ControlParameters controlParameters;
+    controlParameters
+      .setName(namePrefix)
+      .setFaceId(faceId)
+      .setOrigin(128);
+    m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
                                                      ndn::bind(&Fib::onSuccess, this, _1,
                                                                "Successful in unregistering name"),
                                                      ndn::bind(&Fib::onFailure, this, _1, _2,
                                                                "Failed in unregistering name"));
+  }
 }
 
 void
+Fib::setStrategy(const ndn::Name& name, const std::string& strategy)
+{
+  ndn::nfd::ControlParameters parameters;
+  parameters
+    .setName(name)
+    .setStrategy(strategy);
+
+  m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
+                                                         bind(&Fib::onSuccess, this, _1,
+                                                              "Successfully set strategy choice"),
+                                                         bind(&Fib::onFailure, this, _1, _2,
+                                                              "Failed to set strategy choice"));
+}
+
+void
+Fib::onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
+                    const std::string& message, const std::string& faceUri)
+{
+  //std::cout << message << ": " << commandSuccessResult << std::endl;
+  m_faceMap.update(faceUri, commandSuccessResult.getFaceId());
+  m_faceMap.print();
+}
+
+
+void
 Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
                const std::string& message)
 {
-  std::cout << message << ": " << commandSuccessResult << std::endl;
+  //std::cout << message << ": " << commandSuccessResult << std::endl;
 }
 
 void
@@ -307,8 +326,7 @@
 {
   cout << "-------------------FIB-----------------------------" << endl;
   for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
-       ++it)
-  {
+       ++it) {
     cout << (*it);
   }
 }
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index 0f58351..559df7a 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -5,7 +5,7 @@
 #include <boost/cstdint.hpp>
 
 #include <ndn-cxx/management/nfd-controller.hpp>
-
+#include "face-map.hpp"
 #include "fib-entry.hpp"
 
 namespace nlsr {
@@ -21,6 +21,7 @@
     , m_table()
     , m_refreshTime(0)
     , m_controller(face)
+    , m_faceMap()
   {
   }
   ~Fib()
@@ -47,7 +48,7 @@
 
 private:
   void
-  removeHop(NexthopList& nl, uint32_t doNotRemoveHopFaceId,
+  removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
             const ndn::Name& name);
 
   int
@@ -63,12 +64,25 @@
   void
   refreshEntry(const ndn::Name& name, int32_t feSeqNum);
 
+public:
   void
-  registerPrefixInNfd(const ndn::Name& namePrefix, uint64_t faceId,
-                      uint64_t faceCost);
+  registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
+                 uint64_t faceCost, uint64_t timeout);
 
   void
-  unregisterPrefixFromNfd(const ndn::Name& namePrefix, uint64_t faceId);
+  registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
+                      const ndn::Name& namePrefix, uint64_t faceCost, uint64_t timeout);
+  
+  void
+  setStrategy(const ndn::Name& name, const std::string& strategy);
+
+private:
+  void
+  unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri);
+
+  void
+  onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
+                 const std::string& message, const std::string& faceUri);
 
   void
   onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
@@ -82,6 +96,7 @@
   std::list<FibEntry> m_table;
   int32_t m_refreshTime;
   ndn::nfd::Controller m_controller;
+  FaceMap m_faceMap;
 };
 
 }//namespace nlsr
diff --git a/src/route/map.cpp b/src/route/map.cpp
index 07310e7..8dca590 100644
--- a/src/route/map.cpp
+++ b/src/route/map.cpp
@@ -27,8 +27,7 @@
 Map::addEntry(const ndn::Name& rtrName)
 {
   MapEntry me(rtrName, m_mappingIndex);
-  if (addEntry(me))
-  {
+  if (addEntry(me)) {
     m_mappingIndex++;
   }
 }
@@ -39,9 +38,9 @@
   //cout << mpe;
   std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
-                                                  bind(&mapEntryCompareByRouter, _1, mpe.getRouter()));
-  if (it == m_table.end())
-  {
+                                                  ndn::bind(&mapEntryCompareByRouter,
+                                                            _1, mpe.getRouter()));
+  if (it == m_table.end()) {
     m_table.push_back(mpe);
     return true;
   }
@@ -53,10 +52,9 @@
 {
   std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
-                                                  bind(&mapEntryCompareByMappingNo,
-                                                       _1, mn));
-  if (it != m_table.end())
-  {
+                                                  ndn::bind(&mapEntryCompareByMappingNo,
+                                                            _1, mn));
+  if (it != m_table.end()) {
     return (*it).getRouter();
   }
   return ndn::Name();
@@ -67,10 +65,9 @@
 {
   std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
-                                                  bind(&mapEntryCompareByRouter,
-                                                       _1, rName));
-  if (it != m_table.end())
-  {
+                                                  ndn::bind(&mapEntryCompareByRouter,
+                                                            _1, rName));
+  if (it != m_table.end()) {
     return (*it).getMappingNumber();
   }
   return -1;
@@ -81,15 +78,11 @@
 {
   std::list<AdjLsa> adjLsdb = pnlsr.getLsdb().getAdjLsdb();
   for (std::list<AdjLsa>::iterator it = adjLsdb.begin();
-       it != adjLsdb.end() ; it++)
-  {
-    //ndn::Name& linkStartRouter = (*it).getOrigRouter();
+       it != adjLsdb.end() ; it++) {
     addEntry((*it).getOrigRouter());
     std::list<Adjacent> adl = (*it).getAdl().getAdjList();
     for (std::list<Adjacent>::iterator itAdl = adl.begin();
-         itAdl != adl.end() ; itAdl++)
-    {
-      //ndn::Name& linkEndRouter = (*itAdl).getName();
+         itAdl != adl.end() ; itAdl++) {
       addEntry((*itAdl).getName());
     }
   }
@@ -107,8 +100,7 @@
 {
   os << "---------------Map----------------------" << endl;
   std::list<MapEntry> ml = map.getMapList();
-  for (std::list<MapEntry>::iterator it = ml.begin(); it != ml.end() ; it++)
-  {
+  for (std::list<MapEntry>::iterator it = ml.begin(); it != ml.end() ; it++) {
     os << (*it);
   }
   return os;
diff --git a/src/route/name-prefix-table-entry.cpp b/src/route/name-prefix-table-entry.cpp
index 0ca9bcb..cb7b869 100644
--- a/src/route/name-prefix-table-entry.cpp
+++ b/src/route/name-prefix-table-entry.cpp
@@ -59,8 +59,7 @@
     (*it).getNexthopList().reset(); // reseting existing routing table's next hop
     for (std::list<NextHop>::iterator nhit =
            rte.getNexthopList().getNextHops().begin();
-         nhit != rte.getNexthopList().getNextHops().end(); ++nhit)
-    {
+         nhit != rte.getNexthopList().getNextHops().end(); ++nhit) {
       (*it).getNexthopList().addNextHop((*nhit));
     }
   }
@@ -73,8 +72,7 @@
   os << "Name: " << npte.getNamePrefix() << endl;
   std::list<RoutingTableEntry> rteList = npte.getRteList();
   for (std::list<RoutingTableEntry>::iterator it = rteList.begin();
-       it != rteList.end(); ++it)
-  {
+       it != rteList.end(); ++it) {
     cout << (*it);
   }
   os << npte.getNexthopList();
diff --git a/src/route/name-prefix-table-entry.hpp b/src/route/name-prefix-table-entry.hpp
index ab507d7..13a31ea 100644
--- a/src/route/name-prefix-table-entry.hpp
+++ b/src/route/name-prefix-table-entry.hpp
@@ -37,11 +37,9 @@
   void
   resetRteListNextHop()
   {
-    if (m_rteList.size() > 0)
-    {
+    if (m_rteList.size() > 0) {
       for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
-           it != m_rteList.end(); ++it)
-      {
+           it != m_rteList.end(); ++it) {
         (*it).getNexthopList().reset();
       }
     }
diff --git a/src/route/name-prefix-table.cpp b/src/route/name-prefix-table.cpp
index f791d0a..61b2722 100644
--- a/src/route/name-prefix-table.cpp
+++ b/src/route/name-prefix-table.cpp
@@ -25,30 +25,26 @@
 NamePrefixTable::addEntry(const ndn::Name& name, RoutingTableEntry& rte)
 {
   std::list<NamePrefixTableEntry>::iterator it = std::find_if(m_table.begin(),
-                                                              m_table.end(), bind(&npteCompare, _1, name));
-  if (it == m_table.end())
-  {
+                                                              m_table.end(),
+                                                              ndn::bind(&npteCompare, _1, name));
+  if (it == m_table.end()) {
     NamePrefixTableEntry newEntry(name);
     newEntry.addRoutingTableEntry(rte);
     newEntry.generateNhlfromRteList();
     newEntry.getNexthopList().sort();
     m_table.push_back(newEntry);
-    if (rte.getNexthopList().getSize() > 0)
-    {
+    if (rte.getNexthopList().getSize() > 0) {
       m_nlsr.getFib().update(name, newEntry.getNexthopList());
     }
   }
-  else
-  {
-    if (rte.getNexthopList().getSize() > 0)
-    {
+  else {
+    if (rte.getNexthopList().getSize() > 0) {
       (*it).addRoutingTableEntry(rte);
       (*it).generateNhlfromRteList();
       (*it).getNexthopList().sort();
       m_nlsr.getFib().update(name, (*it).getNexthopList());
     }
-    else
-    {
+    else {
       (*it).resetRteListNextHop();
       (*it).getNexthopList().reset();
       m_nlsr.getFib().remove(name);
@@ -60,9 +56,9 @@
 NamePrefixTable::removeEntry(const ndn::Name& name, RoutingTableEntry& rte)
 {
   std::list<NamePrefixTableEntry>::iterator it = std::find_if(m_table.begin(),
-                                                              m_table.end(), bind(&npteCompare, _1, name));
-  if (it != m_table.end())
-  {
+                                                              m_table.end(),
+                                                              ndn::bind(&npteCompare, _1, name));
+  if (it != m_table.end()) {
     ndn::Name destRouter = rte.getDestination();
     (*it).removeRoutingTableEntry(rte);
     if (((*it).getRteListSize() == 0) &&
@@ -71,13 +67,11 @@
         (!m_nlsr.getLsdb().doesLsaExist(destRouter.append("/adjacency"),
                                         std::string("adjacency"))) &&
         (!m_nlsr.getLsdb().doesLsaExist(destRouter.append("/coordinate"),
-                                        std::string("coordinate"))))
-    {
+                                        std::string("coordinate")))) {
       m_table.erase(it);
       m_nlsr.getFib().remove(name);
     }
-    else
-    {
+    else {
       (*it).generateNhlfromRteList();
       m_nlsr.getFib().update(name, (*it).getNexthopList());
     }
@@ -91,12 +85,10 @@
   //
   RoutingTableEntry* rteCheck =
     m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
-  if (rteCheck != 0)
-  {
+  if (rteCheck != 0) {
     addEntry(name, *(rteCheck));
   }
-  else
-  {
+  else {
     RoutingTableEntry rte(destRouter);
     addEntry(name, rte);
   }
@@ -108,12 +100,10 @@
   //
   RoutingTableEntry* rteCheck =
     m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
-  if (rteCheck != 0)
-  {
+  if (rteCheck != 0) {
     removeEntry(name, *(rteCheck));
   }
-  else
-  {
+  else {
     RoutingTableEntry rte(destRouter);
     removeEntry(name, rte);
   }
@@ -123,20 +113,16 @@
 NamePrefixTable::updateWithNewRoute()
 {
   for (std::list<NamePrefixTableEntry>::iterator it = m_table.begin();
-       it != m_table.end(); ++it)
-  {
+       it != m_table.end(); ++it) {
     std::list<RoutingTableEntry> rteList = (*it).getRteList();
     for (std::list<RoutingTableEntry>::iterator rteit = rteList.begin();
-         rteit != rteList.end(); ++rteit)
-    {
+         rteit != rteList.end(); ++rteit) {
       RoutingTableEntry* rteCheck =
         m_nlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
-      if (rteCheck != 0)
-      {
+      if (rteCheck != 0) {
         addEntry((*it).getNamePrefix(), *(rteCheck));
       }
-      else
-      {
+      else {
         RoutingTableEntry rte((*rteit).getDestination());
         addEntry((*it).getNamePrefix(), rte);
       }
@@ -150,8 +136,7 @@
   std::cout << "----------------NPT----------------------" << std::endl;
   for (std::list<NamePrefixTableEntry>::iterator it = m_table.begin();
        it != m_table.end();
-       ++it)
-  {
+       ++it) {
     cout << (*it) << endl;
   }
 }
diff --git a/src/route/nexthop-list.cpp b/src/route/nexthop-list.cpp
index 5468b40..12536f1 100644
--- a/src/route/nexthop-list.cpp
+++ b/src/route/nexthop-list.cpp
@@ -9,13 +9,13 @@
 static bool
 nexthopCompare(NextHop& nh1, NextHop& nh2)
 {
-  return nh1.getConnectingFace() == nh2.getConnectingFace();
+  return nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri();
 }
 
 static bool
 nexthopRemoveCompare(NextHop& nh1, NextHop& nh2)
 {
-  return (nh1.getConnectingFace() == nh2.getConnectingFace() &&
+  return (nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri() &&
           nh1.getRouteCost() == nh2.getRouteCost()) ;
 }
 
@@ -38,13 +38,11 @@
 {
   std::list<NextHop>::iterator it = std::find_if(m_nexthopList.begin(),
                                                  m_nexthopList.end(),
-                                                 bind(&nexthopCompare, _1, nh));
-  if (it == m_nexthopList.end())
-  {
+                                                 ndn::bind(&nexthopCompare, _1, nh));
+  if (it == m_nexthopList.end()) {
     m_nexthopList.push_back(nh);
   }
-  if ((*it).getRouteCost() > nh.getRouteCost())
-  {
+  if ((*it).getRouteCost() > nh.getRouteCost()) {
     (*it).setRouteCost(nh.getRouteCost());
   }
 }
@@ -59,9 +57,8 @@
 {
   std::list<NextHop>::iterator it = std::find_if(m_nexthopList.begin(),
                                                  m_nexthopList.end(),
-                                                 bind(&nexthopRemoveCompare, _1, nh));
-  if (it != m_nexthopList.end())
-  {
+                                                 ndn::bind(&nexthopRemoveCompare, _1, nh));
+  if (it != m_nexthopList.end()) {
     m_nexthopList.erase(it);
   }
 }
@@ -78,8 +75,7 @@
   std::list<NextHop> nexthopList = nhl.getNextHops();
   int i = 1;
   for (std::list<NextHop>::iterator it = nexthopList.begin();
-       it != nexthopList.end() ; it++, i++)
-  {
+       it != nexthopList.end() ; it++, i++) {
     os << "Nexthop " << i << ": " << (*it) << endl;
   }
   return os;
diff --git a/src/route/nexthop.cpp b/src/route/nexthop.cpp
deleted file mode 100644
index 0a375b0..0000000
--- a/src/route/nexthop.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "nexthop.hpp"
-
-namespace nlsr {
-
-std::ostream&
-operator<<(std::ostream& os, NextHop& nh)
-{
-  os << "Face: " << nh.getConnectingFace() << "  Route Cost: " <<
-     nh.getRouteCost();
-  return os;
-}
-
-}//namespace nlsr
diff --git a/src/route/nexthop.hpp b/src/route/nexthop.hpp
index ed8d319..73ee473 100644
--- a/src/route/nexthop.hpp
+++ b/src/route/nexthop.hpp
@@ -9,27 +9,27 @@
 {
 public:
   NextHop()
-    : m_connectingFace(0)
+    : m_connectingFaceUri()
     , m_routeCost(0)
   {
   }
 
-  NextHop(uint32_t cf, double rc)
+  NextHop(const std::string& cfu, double rc)
   {
-    m_connectingFace = cf;
+    m_connectingFaceUri = cfu;
     m_routeCost = rc;
   }
 
-  uint32_t
-  getConnectingFace() const
+  const std::string&
+  getConnectingFaceUri() const
   {
-    return m_connectingFace;
+    return m_connectingFaceUri;
   }
 
   void
-  setConnectingFace(uint32_t cf)
+  setConnectingFaceUri(const std::string& cfu)
   {
-    m_connectingFace = cf;
+    m_connectingFaceUri = cfu;
   }
 
   double
@@ -45,13 +45,18 @@
   }
 
 private:
-  uint32_t m_connectingFace;
+  std::string m_connectingFaceUri;
   double m_routeCost;
 };
 
 
-std::ostream&
-operator<<(std::ostream& os, NextHop& nh);
+inline std::ostream&
+operator<<(std::ostream& os, const NextHop& nh)
+{
+  os << "Face: " << nh.getConnectingFaceUri() << "  Route Cost: " <<
+     nh.getRouteCost();
+  return os;
+}
 
 }//namespace nlsr
 
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index 33a703d..7eab0eb 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -15,8 +15,7 @@
 RoutingTableCalculator::allocateAdjMatrix()
 {
   adjMatrix = new double*[numOfRouter];
-  for (int i = 0; i < numOfRouter; ++i)
-  {
+  for (int i = 0; i < numOfRouter; ++i) {
     adjMatrix[i] = new double[numOfRouter];
   }
 }
@@ -24,10 +23,10 @@
 void
 RoutingTableCalculator::initMatrix()
 {
-  for (int i = 0; i < numOfRouter; i++)
-  {
-    for (int j = 0; j < numOfRouter; j++)
+  for (int i = 0; i < numOfRouter; i++) {
+    for (int j = 0; j < numOfRouter; j++) {
       adjMatrix[i][j] = 0;
+    }
   }
 }
 
@@ -36,17 +35,14 @@
 {
   std::list<AdjLsa> adjLsdb = pnlsr.getLsdb().getAdjLsdb();
   for (std::list<AdjLsa>::iterator it = adjLsdb.begin();
-       it != adjLsdb.end() ; it++)
-  {
+       it != adjLsdb.end() ; it++) {
     int row = pMap.getMappingNoByRouterName((*it).getOrigRouter());
     std::list<Adjacent> adl = (*it).getAdl().getAdjList();
     for (std::list<Adjacent>::iterator itAdl = adl.begin();
-         itAdl != adl.end() ; itAdl++)
-    {
+         itAdl != adl.end() ; itAdl++) {
       int col = pMap.getMappingNoByRouterName((*itAdl).getName());
       double cost = (*itAdl).getLinkCost();
-      if ((row >= 0 && row < numOfRouter) && (col >= 0 && col < numOfRouter))
-      {
+      if ((row >= 0 && row < numOfRouter) && (col >= 0 && col < numOfRouter)) {
         adjMatrix[row][col] = cost;
       }
     }
@@ -56,10 +52,10 @@
 void
 RoutingTableCalculator::printAdjMatrix()
 {
-  for (int i = 0; i < numOfRouter; i++)
-  {
-    for (int j = 0; j < numOfRouter; j++)
+  for (int i = 0; i < numOfRouter; i++) {
+    for (int j = 0; j < numOfRouter; j++) {
       printf("%f ", adjMatrix[i][j]);
+    }
     printf("\n");
   }
 }
@@ -67,14 +63,11 @@
 void
 RoutingTableCalculator::adjustAdMatrix(int source, int link, double linkCost)
 {
-  for (int i = 0; i < numOfRouter; i++)
-  {
-    if (i == link)
-    {
+  for (int i = 0; i < numOfRouter; i++) {
+    if (i == link) {
       adjMatrix[source][i] = linkCost;
     }
-    else
-    {
+    else {
       adjMatrix[source][i] = 0;
     }
   }
@@ -84,10 +77,8 @@
 RoutingTableCalculator::getNumOfLinkfromAdjMatrix(int sRouter)
 {
   int noLink = 0;
-  for (int i = 0; i < numOfRouter; i++)
-  {
-    if (adjMatrix[sRouter][i] > 0)
-    {
+  for (int i = 0; i < numOfRouter; i++) {
+    if (adjMatrix[sRouter][i] > 0) {
       noLink++;
     }
   }
@@ -99,10 +90,8 @@
                                               double* linkCosts, int source)
 {
   int j = 0;
-  for (int i = 0; i < numOfRouter; i++)
-  {
-    if (adjMatrix[source][i] > 0)
-    {
+  for (int i = 0; i < numOfRouter; i++) {
+    if (adjMatrix[source][i] > 0) {
       links[j] = i;
       linkCosts[j] = adjMatrix[source][i];
       j++;
@@ -113,8 +102,7 @@
 void
 RoutingTableCalculator::freeAdjMatrix()
 {
-  for (int i = 0; i < numOfRouter; ++i)
-  {
+  for (int i = 0; i < numOfRouter; ++i) {
     delete [] adjMatrix[i];
   }
   delete [] adjMatrix;
@@ -160,8 +148,7 @@
   //int noLink=getNumOfLinkfromAdjMatrix(sourceRouter);
   allocateParent();
   allocateDistance();
-  if (pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1)
-  {
+  if (pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1) {
     // Single Path
     doDijkstraPathCalculation(sourceRouter);
     // print all ls path -- debugging purpose
@@ -169,15 +156,13 @@
     // update routing table
     addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
   }
-  else
-  {
+  else {
     // Multi Path
     setNoLink(getNumOfLinkfromAdjMatrix(sourceRouter));
     allocateLinks();
     allocateLinkCosts();
     getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
-    for (int i = 0 ; i < vNoLink; i++)
-    {
+    for (int i = 0 ; i < vNoLink; i++) {
       adjustAdMatrix(sourceRouter, links[i], linkCosts[i]);
       printAdjMatrix();
       doDijkstraPathCalculation(sourceRouter);
@@ -202,31 +187,23 @@
   int* Q = new int[numOfRouter];
   int head = 0;
   /* Initiate the Parent */
-  for (i = 0 ; i < numOfRouter; i++)
-  {
+  for (i = 0 ; i < numOfRouter; i++) {
     m_parent[i] = EMPTY_PARENT;
     m_distance[i] = INF_DISTANCE;
     Q[i] = i;
   }
-  if (sourceRouter != NO_MAPPING_NUM)
-  {
+  if (sourceRouter != NO_MAPPING_NUM) {
     m_distance[sourceRouter] = 0;
     sortQueueByDistance(Q, m_distance, head, numOfRouter);
-    while (head < numOfRouter)
-    {
+    while (head < numOfRouter) {
       u = Q[head];
-      if (m_distance[u] == INF_DISTANCE)
-      {
+      if (m_distance[u] == INF_DISTANCE) {
         break;
       }
-      for (v = 0 ; v < numOfRouter; v++)
-      {
-        if (adjMatrix[u][v] > 0)
-        {
-          if (isNotExplored(Q, v, head + 1, numOfRouter))
-          {
-            if (m_distance[u] + adjMatrix[u][v] <  m_distance[v])
-            {
+      for (v = 0 ; v < numOfRouter; v++) {
+        if (adjMatrix[u][v] > 0) {
+          if (isNotExplored(Q, v, head + 1, numOfRouter)) {
+            if (m_distance[u] + adjMatrix[u][v] <  m_distance[v]) {
               m_distance[v] = m_distance[u] + adjMatrix[u][v] ;
               m_parent[v] = u;
             }
@@ -248,24 +225,21 @@
             "LinkStateRoutingTableCalculator::addAllNextHopsToRoutingTable Called";
   std::cout << std::endl;
   int nextHopRouter = 0;
-  for (int i = 0; i < numOfRouter ; i++)
-  {
-    if (i != sourceRouter)
-    {
+  for (int i = 0; i < numOfRouter ; i++) {
+    if (i != sourceRouter) {
       nextHopRouter = getLsNextHop(i, sourceRouter);
-      if (nextHopRouter != NO_NEXT_HOP)
-      {
+      if (nextHopRouter != NO_NEXT_HOP) {
         double routeCost = m_distance[i];
         ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
-        int nxtHopFace =
-          pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFace();
+        std::string nextHopFace =
+          pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFaceUri();
         std::cout << "Dest Router: " << pMap.getRouterNameByMappingNo(i) << std::endl;
         std::cout << "Next hop Router: " << nextHopRouterName << std::endl;
-        std::cout << "Next hop Face: " << nxtHopFace << std::endl;
+        std::cout << "Next hop Face: " << nextHopFace << std::endl;
         std::cout << "Route Cost: " << routeCost << std::endl;
         std::cout << std::endl;
         // Add next hop to routing table
-        NextHop nh(nxtHopFace, routeCost);
+        NextHop nh(nextHopFace, routeCost);
         rt.addNextHop(pMap.getRouterNameByMappingNo(i), nh);
       }
     }
@@ -276,13 +250,11 @@
 LinkStateRoutingTableCalculator::getLsNextHop(int dest, int source)
 {
   int nextHop = NO_NEXT_HOP;
-  while (m_parent[dest] != EMPTY_PARENT)
-  {
+  while (m_parent[dest] != EMPTY_PARENT) {
     nextHop = dest;
     dest = m_parent[dest];
   }
-  if (dest != source)
-  {
+  if (dest != source) {
     nextHop = NO_NEXT_HOP;
   }
   return nextHop;
@@ -294,10 +266,8 @@
   std::cout << "LinkStateRoutingTableCalculator::printAllLsPath Called" <<
             std::endl;
   std::cout << "Source Router: " << sourceRouter << std::endl;
-  for (int i = 0; i < numOfRouter ; i++)
-  {
-    if (i != sourceRouter)
-    {
+  for (int i = 0; i < numOfRouter ; i++) {
+    if (i != sourceRouter) {
       printLsPath(i);
       std::cout << std::endl;
     }
@@ -307,8 +277,7 @@
 void
 LinkStateRoutingTableCalculator::printLsPath(int destRouter)
 {
-  if (m_parent[destRouter] != EMPTY_PARENT)
-  {
+  if (m_parent[destRouter] != EMPTY_PARENT) {
     printLsPath(m_parent[destRouter]);
   }
   std:: cout << " " << destRouter;
@@ -318,12 +287,9 @@
 LinkStateRoutingTableCalculator::sortQueueByDistance(int* Q,
                                                      double* dist, int start, int element)
 {
-  for (int i = start ; i < element ; i++)
-  {
-    for (int j = i + 1; j < element; j++)
-    {
-      if (dist[Q[j]] < dist[Q[i]])
-      {
+  for (int i = start ; i < element ; i++) {
+    for (int j = i + 1; j < element; j++) {
+      if (dist[Q[j]] < dist[Q[i]]) {
         int tempU = Q[j];
         Q[j] = Q[i];
         Q[i] = tempU;
@@ -337,10 +303,8 @@
                                                int u, int start, int element)
 {
   int ret = 0;
-  for (int i = start; i < element; i++)
-  {
-    if (Q[i] == u)
-    {
+  for (int i = start; i < element; i++) {
+    if (Q[i] == u) {
       ret = 1;
       break;
     }
@@ -385,26 +349,22 @@
   allocateLinks();
   allocateLinkCosts();
   getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
-  for (int i = 0 ; i < numOfRouter ; ++i)
-  {
+  for (int i = 0 ; i < numOfRouter ; ++i) {
     int k = 0;
-    if (i != sourceRouter)
-    {
+    if (i != sourceRouter) {
       allocateLinkFaces();
       allocateDistanceToNeighbor();
       allocateDistFromNbrToDest();
-      for (int j = 0; j < vNoLink; j++)
-      {
+      for (int j = 0; j < vNoLink; j++) {
         ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(links[j]);
-        int nextHopFace =
-          pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFace();
+        std::string nextHopFaceUri =
+          pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFaceUri();
         double distToNbr = getHyperbolicDistance(pnlsr, pMap,
                                                  sourceRouter, links[j]);
         double distToDestFromNbr = getHyperbolicDistance(pnlsr,
                                                          pMap, links[j], i);
-        if (distToDestFromNbr >= 0)
-        {
-          m_linkFaces[k] = nextHopFace;
+        if (distToDestFromNbr >= 0) {
+          m_linkFaceUris[k] = nextHopFaceUri;
           m_distanceToNeighbor[k] = distToNbr;
           m_distFromNbrToDest[k] = distToDestFromNbr;
           k++;
@@ -425,13 +385,11 @@
 HypRoutingTableCalculator::addHypNextHopsToRoutingTable(Nlsr& pnlsr, Map& pMap,
                                                         RoutingTable& rt, int noFaces, int dest)
 {
-  for (int i = 0 ; i < noFaces ; ++i)
-  {
+  for (int i = 0 ; i < noFaces ; ++i) {
     ndn::Name destRouter = pMap.getRouterNameByMappingNo(dest);
-    NextHop nh(m_linkFaces[i], m_distFromNbrToDest[i]);
+    NextHop nh(m_linkFaceUris[i], m_distFromNbrToDest[i]);
     rt.addNextHop(destRouter, nh);
-    if (m_isDryRun)
-    {
+    if (m_isDryRun) {
       rt.addNextHopToDryTable(destRouter, nh);
     }
   }
@@ -455,20 +413,19 @@
   double destTheta = (pnlsr.getLsdb().findCoordinateLsa(
                         destRouterKey))->getCorTheta();
   double diffTheta = fabs(srcTheta - destTheta);
-  if (diffTheta > MATH_PI)
-  {
+  if (diffTheta > MATH_PI) {
     diffTheta = 2 * MATH_PI - diffTheta;
   }
-  if (srcRadius != -1 && destRadius != -1)
-  {
-    if (diffTheta == 0)
+  if (srcRadius != -1 && destRadius != -1) {
+    if (diffTheta == 0) {
       distance = fabs(srcRadius - destRadius);
-    else
+    }
+    else {
       distance = acosh((cosh(srcRadius) * cosh(destRadius)) -
                        (sinh(srcRadius) * sinh(destRadius) * cos(diffTheta)));
+    }
   }
-  else
-  {
+  else {
     distance = -1;
   }
   return distance;
@@ -477,7 +434,7 @@
 void
 HypRoutingTableCalculator::allocateLinkFaces()
 {
-  m_linkFaces = new int[vNoLink];
+  m_linkFaceUris.reserve(vNoLink);
 }
 
 void
@@ -495,7 +452,7 @@
 void
 HypRoutingTableCalculator::freeLinkFaces()
 {
-  delete [] m_linkFaces;
+  m_linkFaceUris.clear();
 }
 
 void
diff --git a/src/route/routing-table-calculator.hpp b/src/route/routing-table-calculator.hpp
index 544896c..b7df54b 100644
--- a/src/route/routing-table-calculator.hpp
+++ b/src/route/routing-table-calculator.hpp
@@ -189,7 +189,7 @@
 private:
   bool m_isDryRun;
 
-  int* m_linkFaces;
+  std::vector<std::string> m_linkFaceUris;
   double* m_distanceToNeighbor;
   double* m_distFromNbrToDest;
 
diff --git a/src/route/routing-table-entry.hpp b/src/route/routing-table-entry.hpp
index fbba243..ce26f59 100644
--- a/src/route/routing-table-entry.hpp
+++ b/src/route/routing-table-entry.hpp
@@ -48,8 +48,7 @@
   int32_t i = 1;
   std::list<NextHop> nhl = rte.getNexthopList().getNextHops();
   for (std::list<NextHop>::iterator it = nhl.begin();
-       it != nhl.end() ; it++, i++)
-  {
+       it != nhl.end() ; it++, i++) {
     os << "  Nexthop " << i << ": " << (*it) << std::endl;
   }
   return os;
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 7664b89..bcfb61c 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -5,6 +5,7 @@
 #include "routing-table.hpp"
 #include "nlsr.hpp"
 #include "map.hpp"
+#include "conf-parameter.hpp"
 #include "routing-table-calculator.hpp"
 #include "routing-table-entry.hpp"
 #include "name-prefix-table.hpp"
@@ -21,32 +22,28 @@
   pnlsr.getLsdb().printAdjLsdb();
   pnlsr.getLsdb().printCorLsdb();
   pnlsr.getLsdb().printNameLsdb();
-  if (pnlsr.getIsRoutingTableCalculating() == 0)
-  {
-    pnlsr.setIsRoutingTableCalculating(1); //setting routing table calculation
+  if (pnlsr.getIsRoutingTableCalculating() == false) {
+    //setting routing table calculation
+    pnlsr.setIsRoutingTableCalculating(true);
     if (pnlsr.getLsdb().doesLsaExist(
           pnlsr.getConfParameter().getRouterPrefix().toUri() + "/" + "adjacency",
-          std::string("adjacency")))
-    {
-      if (pnlsr.getIsBuildAdjLsaSheduled() != 1)
-      {
+          std::string("adjacency"))) {
+      if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
         std::cout << "CLearing old routing table ....." << std::endl;
         clearRoutingTable();
-        clearDryRoutingTable(); // for dry run options
+        // for dry run options
+        clearDryRoutingTable();
         // calculate Link State routing
-        if ((pnlsr.getConfParameter().getIsHyperbolicCalc() == 0)
-            || (pnlsr.getConfParameter().getIsHyperbolicCalc() == 2))
-        {
+        if ((pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF)
+            || (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN)) {
           calculateLsRoutingTable(pnlsr);
         }
         //calculate hyperbolic routing
-        if (pnlsr.getConfParameter().getIsHyperbolicCalc() == 1)
-        {
+        if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
           calculateHypRoutingTable(pnlsr);
         }
         //calculate dry hyperbolic routing
-        if (pnlsr.getConfParameter().getIsHyperbolicCalc() == 2)
-        {
+        if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
           calculateHypDryRoutingTable(pnlsr);
         }
         //need to update NPT here
@@ -57,14 +54,12 @@
         pnlsr.getFib().print();
         //debugging purpose end
       }
-      else
-      {
+      else {
         std::cout << "Adjacency building is scheduled, so ";
         std::cout << "routing table can not be calculated :(" << std::endl;
       }
     }
-    else
-    {
+    else {
       std::cout << "No Adj LSA of router itself,";
       std::cout <<	" so Routing table can not be calculated :(" << std::endl;
       clearRoutingTable();
@@ -78,11 +73,10 @@
       pnlsr.getFib().print();
       //debugging purpose end
     }
-    pnlsr.setIsRouteCalculationScheduled(0); //clear scheduled flag
-    pnlsr.setIsRoutingTableCalculating(0); //unsetting routing table calculation
+    pnlsr.setIsRouteCalculationScheduled(false); //clear scheduled flag
+    pnlsr.setIsRoutingTableCalculating(false); //unsetting routing table calculation
   }
-  else
-  {
+  else {
     scheduleRoutingTableCalculation(pnlsr);
   }
 }
@@ -96,7 +90,7 @@
   vMap.createFromAdjLsdb(pnlsr);
   int numOfRouter = vMap.getMapSize();
   LinkStateRoutingTableCalculator lsrtc(numOfRouter);
-  lsrtc.calculatePath(vMap, boost::ref(*this), pnlsr);
+  lsrtc.calculatePath(vMap, ndn::ref(*this), pnlsr);
 }
 
 void
@@ -106,7 +100,7 @@
   vMap.createFromAdjLsdb(pnlsr);
   int numOfRouter = vMap.getMapSize();
   HypRoutingTableCalculator hrtc(numOfRouter, 0);
-  hrtc.calculatePath(vMap, boost::ref(*this), pnlsr);
+  hrtc.calculatePath(vMap, ndn::ref(*this), pnlsr);
 }
 
 void
@@ -116,17 +110,17 @@
   vMap.createFromAdjLsdb(pnlsr);
   int numOfRouter = vMap.getMapSize();
   HypRoutingTableCalculator hrtc(numOfRouter, 1);
-  hrtc.calculatePath(vMap, boost::ref(*this), pnlsr);
+  hrtc.calculatePath(vMap, ndn::ref(*this), pnlsr);
 }
 
 void
 RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
 {
-  if (pnlsr.getIsRouteCalculationScheduled() != 1)
-  {
+  if (pnlsr.getIsRouteCalculationScheduled() != true) {
     pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
-                                       ndn::bind(&RoutingTable::calculate, this, boost::ref(pnlsr)));
-    pnlsr.setIsRouteCalculationScheduled(1);
+                                       ndn::bind(&RoutingTable::calculate, this,
+                                                 ndn::ref(pnlsr)));
+    pnlsr.setIsRouteCalculationScheduled(true);
   }
 }
 
@@ -141,14 +135,12 @@
 RoutingTable::addNextHop(const ndn::Name& destRouter, NextHop& nh)
 {
   RoutingTableEntry* rteChk = findRoutingTableEntry(destRouter);
-  if (rteChk == 0)
-  {
+  if (rteChk == 0) {
     RoutingTableEntry rte(destRouter);
     rte.getNexthopList().addNextHop(nh);
     m_rTable.push_back(rte);
   }
-  else
-  {
+  else {
     rteChk->getNexthopList().addNextHop(nh);
   }
 }
@@ -158,9 +150,9 @@
 {
   std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(),
                                                            m_rTable.end(),
-                                                           bind(&routingTableEntryCompare, _1, destRouter));
-  if (it != m_rTable.end())
-  {
+                                                           ndn::bind(&routingTableEntryCompare,
+                                                                     _1, destRouter));
+  if (it != m_rTable.end()) {
     return &(*it);
   }
   return 0;
@@ -171,8 +163,7 @@
 {
   std::cout << "---------------Routing Table------------------" << std::endl;
   for (std::list<RoutingTableEntry>::iterator it = m_rTable.begin() ;
-       it != m_rTable.end(); ++it)
-  {
+       it != m_rTable.end(); ++it) {
     std::cout << (*it) << std::endl;
   }
 }
@@ -184,15 +175,14 @@
 {
   std::list<RoutingTableEntry>::iterator it = std::find_if(m_dryTable.begin(),
                                                            m_dryTable.end(),
-                                                           bind(&routingTableEntryCompare, _1, destRouter));
-  if (it == m_dryTable.end())
-  {
+                                                           ndn::bind(&routingTableEntryCompare,
+                                                                     _1, destRouter));
+  if (it == m_dryTable.end()) {
     RoutingTableEntry rte(destRouter);
     rte.getNexthopList().addNextHop(nh);
     m_dryTable.push_back(rte);
   }
-  else
-  {
+  else {
     (*it).getNexthopList().addNextHop(nh);
   }
 }
@@ -202,8 +192,7 @@
 {
   std::cout << "--------Dry Run's Routing Table--------------" << std::endl;
   for (std::list<RoutingTableEntry>::iterator it = m_dryTable.begin() ;
-       it != m_dryTable.end(); ++it)
-  {
+       it != m_dryTable.end(); ++it) {
     cout << (*it) << endl;
   }
 }
@@ -212,8 +201,7 @@
 void
 RoutingTable::clearRoutingTable()
 {
-  if (m_rTable.size() > 0)
-  {
+  if (m_rTable.size() > 0) {
     m_rTable.clear();
   }
 }
@@ -221,8 +209,7 @@
 void
 RoutingTable::clearDryRoutingTable()
 {
-  if (m_dryTable.size() > 0)
-  {
+  if (m_dryTable.size() > 0) {
     m_dryTable.clear();
   }
 }
diff --git a/src/sequencing-manager.cpp b/src/sequencing-manager.cpp
index 9a5ec89..3d63a3d 100644
--- a/src/sequencing-manager.cpp
+++ b/src/sequencing-manager.cpp
@@ -42,8 +42,7 @@
 {
   cout << "Seq File Name: " << m_seqFileNameWithPath << endl;
   std::ifstream inputFile(m_seqFileNameWithPath.c_str(), ios::binary);
-  if (inputFile.good())
-  {
+  if (inputFile.good()) {
     inputFile >> m_combinedSeqNo;
     splittSequenceNo(m_combinedSeqNo);
     m_adjLsaSeq += 10;
@@ -52,8 +51,7 @@
     combineSequenceNo();
     inputFile.close();
   }
-  else
-  {
+  else {
     splittSequenceNo(0);
   }
 }
@@ -62,8 +60,7 @@
 SequencingManager::setSeqFileName(string filePath)
 {
   m_seqFileNameWithPath = filePath;
-  if (m_seqFileNameWithPath.empty())
-  {
+  if (m_seqFileNameWithPath.empty()) {
     m_seqFileNameWithPath = getUserHomeDirectory();
   }
   m_seqFileNameWithPath = m_seqFileNameWithPath + "/nlsrSeqNo.txt";
@@ -73,8 +70,7 @@
 SequencingManager::getUserHomeDirectory()
 {
   string homeDirPath(getpwuid(getuid())->pw_dir);
-  if (homeDirPath.empty())
-  {
+  if (homeDirPath.empty()) {
     homeDirPath = getenv("HOME");
   }
   return homeDirPath;
diff --git a/src/utility/name-helper.hpp b/src/utility/name-helper.hpp
index 5a01a1a..90b3eca 100644
--- a/src/utility/name-helper.hpp
+++ b/src/utility/name-helper.hpp
@@ -1,6 +1,9 @@
 #ifndef NLSR_NAME_HELPER_HPP
 #define NLSR_NAME_HELPER_HPP
 
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/regex_find_format.hpp>
+#include <boost/regex.hpp>
 #include <boost/cstdint.hpp>
 #include <ndn-cxx/name-component.hpp>
 #include <ndn-cxx/name.hpp>
@@ -20,10 +23,8 @@
 {
   ndn::name::Component component(searchString);
   size_t nameSize = name.size();
-  for (uint32_t i = 0; i < nameSize; i++)
-  {
-    if (component == name[i])
-    {
+  for (uint32_t i = 0; i < nameSize; i++) {
+    if (component == name[i]) {
       return (int32_t)i;
     }
   }
diff --git a/src/utility/tokenizer.cpp b/src/utility/tokenizer.cpp
deleted file mode 100644
index 095e55d..0000000
--- a/src/utility/tokenizer.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-#include <iostream>
-#include <boost/tokenizer.hpp>
-#include <boost/algorithm/string.hpp>
-#include <string>
-#include <algorithm>
-
-#include <ndn-cxx/face.hpp>
-
-#include "tokenizer.hpp"
-
-namespace nlsr {
-
-using namespace std;
-using namespace boost;
-
-void
-Tokenizer::makeToken()
-{
-  char_separator<char> sep(m_seps.c_str());
-  tokenizer<char_separator<char> >tokens(m_originalString, sep);
-  tokenizer<char_separator<char> >::iterator tok_iter = tokens.begin();
-  for (; tok_iter != tokens.end(); ++tok_iter)
-  {
-    string oneToken(*tok_iter);
-    trim(oneToken);
-    if (!oneToken.empty())
-    {
-      insertToken(oneToken);
-    }
-  }
-  m_firstToken = m_vTokenList[0];
-  makeRestOfTheLine();
-}
-
-void
-Tokenizer::insertToken(const string& token)
-{
-  m_tokenList.push_back(token);
-  m_vTokenList.push_back(token);
-}
-
-uint32_t
-Tokenizer::getTokenPosition(string& token)
-{
-  uint32_t pos = -1;
-  uint32_t i = 0;
-  for (std::list<string>::iterator it = m_tokenList.begin();
-       it != m_tokenList.end(); it++)
-  {
-    if ((*it) == token)
-    {
-      break;
-    }
-    i++;
-  }
-  if (i < m_tokenList.size())
-  {
-    pos = i;
-  }
-  return pos;
-}
-
-string
-Tokenizer::getTokenString(uint32_t from , uint32_t to)
-{
-  string returnString = "";
-  if ((to < m_tokenList.size()) &&
-      (to >= from && to < m_tokenList.size()))
-  {
-    for (uint32_t i = from; i <= to; i++)
-    {
-      returnString += m_seps;
-      returnString += m_vTokenList[i];
-    }
-  }
-  trim(returnString);
-  return returnString;
-}
-
-string
-Tokenizer::getTokenString(uint32_t from)
-{
-  return getTokenString(from, m_tokenList.size() - 1);
-}
-
-static bool
-tokenCompare(string& s1, string& s2)
-{
-  return s1 == s2;
-}
-
-void
-Tokenizer::makeRestOfTheLine()
-{
-  m_restOfTheLine = getTokenString(1);
-}
-
-bool
-Tokenizer::doesTokenExist(string token)
-{
-  std::list<string>::iterator it = std::find_if(m_tokenList.begin(),
-                                                m_tokenList.end(),
-                                                ndn::bind(&tokenCompare, _1 , token));
-  if (it != m_tokenList.end())
-  {
-    return true;
-  }
-  return false;
-}
-
-}//namespace nlsr
diff --git a/src/utility/tokenizer.hpp b/src/utility/tokenizer.hpp
deleted file mode 100644
index 8ae6f88..0000000
--- a/src/utility/tokenizer.hpp
+++ /dev/null
@@ -1,117 +0,0 @@
-#ifndef NLSR_TOKENIZER_HPP
-#define NLSR_TOKENIZER_HPP
-
-#include <iostream>
-#include <boost/tokenizer.hpp>
-#include <boost/algorithm/string.hpp>
-#include <string>
-#include <list>
-#include <vector>
-
-namespace nlsr {
-
-class Tokenizer
-{
-public:
-  Tokenizer(const std::string& inputString)
-    : m_firstToken()
-    , m_restOfTheLine()
-    , m_currentPosition(0)
-  {
-    m_seps = " ";
-    m_originalString = inputString;
-    makeToken();
-  }
-
-  Tokenizer(const std::string& inputString, const std::string& separator)
-    : m_firstToken()
-    , m_restOfTheLine()
-    , m_currentPosition(0)
-  {
-    m_seps = separator;
-    m_originalString = inputString;
-    makeToken();
-  }
-
-  std::string
-  getFirstToken()
-  {
-    return m_firstToken;
-  }
-
-  std::string
-  getRestOfLine()
-  {
-    return m_restOfTheLine;
-  }
-
-  void
-  resetCurrentPosition(uint32_t cp = 0)
-  {
-    if (cp <= m_vTokenList.size())
-    {
-      m_currentPosition = cp;
-    }
-  }
-
-  std::string
-  getNextToken()
-  {
-    if (m_currentPosition <= (m_vTokenList.size() - 1))
-    {
-      return m_vTokenList[m_currentPosition++];
-    }
-    return "";
-  }
-
-  uint32_t
-  getTokenNumber()
-  {
-    return m_tokenList.size();
-  }
-
-  std::string
-  getToken(unsigned int position)
-  {
-    if (position < m_vTokenList.size())
-    {
-      return m_vTokenList[position];
-    }
-    return "";
-  }
-
-  uint32_t
-  getTokenPosition(std::string& token);
-
-  std::string
-  getTokenString(uint32_t from , uint32_t to);
-
-  std::string
-  getTokenString(uint32_t from);
-
-  bool
-  doesTokenExist(std::string token);
-
-
-private:
-
-  void
-  makeToken();
-
-  void
-  insertToken(const std::string& token);
-
-  void
-  makeRestOfTheLine();
-
-  std::string m_seps;
-  std::string m_originalString;
-  std::string m_firstToken;
-  std::string m_restOfTheLine;
-  std::list<std::string> m_tokenList;
-  std::vector<std::string> m_vTokenList;
-  uint32_t m_currentPosition;
-};
-
-}//namespace nlsr
-#endif //NLSR_TOKENIZER_HPP
