diff --git a/nlsr.conf b/nlsr.conf
index 2f2287b..2f2440f 100644
--- a/nlsr.conf
+++ b/nlsr.conf
@@ -1,14 +1,97 @@
-network ndn
-site-name memphis.edu
-router-name cs/macbook
+; the general section contains all the general settings for router
 
-ndnneighbor /ndn/memphis.edu/cs/maia 7
-link-cost /ndn/memphis.edu/cs/maia 30
-ndnneighbor /ndn/memphis.edu/cs/pollux 10
-link-cost /ndn/memphis.edu/cs/pollux 25
+general
+{
+; mandatory configuration command section network, site and router
 
-ndnname /ndn/memphis.edu/cs/macbook/name1
-ndnname /ndn/memphis.edu/cs/macbook/name2
+    network /ndn/         ; name of the network the router belongs to in ndn URI format
+    site /memphis.edu/    ; name of the site the router belongs to in ndn URI format
+    router /cs/pollux/    ; name of the network the router belongs to in ndn URI format
+
+; lsa-refresh-time is the time in seconds, after which router will refresh its LSAs
+
+    lsa-refresh-time 1800      ; default value 1800. Valid values 240-7200
+
+; log-level is to set the levels of log for NLSR
+
+    log-level  INFO            ; default value INFO, valid value DEBUG, INFO
+}
+
+; the neighbors section contains the configuration for router's neighbors and hello's behavior
+
+neighbors
+{
+; in case hello interest timed out, router will try 'hello-retries' times at 'hello-time-out'
+; seconds interval before giving up for any neighbors (deciding link is down)
+
+   hello-retries 3                     ; interest retries number in integer. Default value 3
+                                       ; valid values 1-10
+
+   hello-timeout 1                    ; interest time out value in integer. Default value 1
+                                       ; Valid values 1-15
+
+   hello-interval  60                  ; interest sending interval in seconds. Default value 60
+                                       ; valid values 30-90
+; neighbor command is used to configure router's neighbor. Each neighbor will need
+; one block of neighbor command
+
+   neighbor
+   {
+       name /ndn/memphis.edu/cs/castor        ; name prefix of the neighbor router consists
+                                              ; of network, site-name and router-name
+
+       face-uri  udp://castor.cs.memphis.edu  ; face id of the face connected to the neighbor
+       link-cost 25                         ; cost of the connecting link to neighbor
+   }
+   
+   neighbor
+   {
+       name /ndn/memphis.edu/cs/mira          ; name prefix of the neighbor router consists
+                                              ; of network, site-name and router-name
+
+       face-uri  udp://mira.cs.memphis.edu    ; face id of the face connected to the neighbor
+       link-cost 30                        ; cost of the connecting link to neighbor
+   }
+}
+
+; the hyperbolic section contains the configuration settings of enabling a router to calculate
+; routing table using [hyperbolic routing table calculation](http://arxiv.org/abs/0805.1266) method
+
+hyperbolic
+{
+; commands in this section follows a strict order
+; the switch is used to set hyperbolic routing calculation in NLSR
+
+    state off             ; default value 'off', set value 'on' to enable hyperbolic routing table 
+                           ; calculation which turns link state routing 'off'. set value to 'dry-run"
+                           ; to test hyperbolic routing and compare with link state routing.
 
 
-!logdir /Users/akmhoque/NLSR-CPP/log
+    radius   123.456       ; radius of the router in hyperbolic coordinate system
+    angle    1.45          ; angle of the router in hyperbolic coordinate system
+}
+
+
+; the fib section is used to configure fib entry's type to ndn FIB updated by NLSR
+
+fib
+{
+; the max-faces-per-prefix is used to limit the number of faces for each name prefixes
+; by NLSR in ndn FIB
+
+    max-faces-per-prefix 3   ; default value 0. Valid value 0-60. By default (value 0) NLSR adds
+                             ; all available faces for each reachable name prefixes in NDN FIB
+
+}
+
+; the advertising section contains the configuration settings of the name prefixes 
+; hosted by this router
+
+advertising
+{
+; the ndnname is used to advertised name from the router. To advertise each name prefix
+; configure one block of ndnname configuration command for every name prefix.
+
+    prefix /ndn/edu/memphis/cs/netlab           ; name in ndn URI format
+    prefix /ndn/edu/memphis/sports/basketball 
+}
diff --git a/nsync/sync-logic.cc b/nsync/sync-logic.cc
index 3038532..af864d3 100644
--- a/nsync/sync-logic.cc
+++ b/nsync/sync-logic.cc
@@ -17,7 +17,7 @@
  *
  * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
  *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  *         Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
@@ -46,10 +46,10 @@
 #define GET_RANDOM(var) var ()
 
 #define TIME_SECONDS_WITH_JITTER(sec) \
-  (time::seconds(sec) + time::milliseconds(GET_RANDOM (m_reexpressionJitter)))
+  (ndn::time::seconds(sec) + ndn::time::milliseconds(GET_RANDOM (m_reexpressionJitter)))
 
 #define TIME_MILLISECONDS_WITH_JITTER(ms) \
-  (time::seconds(ms) + time::milliseconds(GET_RANDOM (m_reexpressionJitter)))
+  (ndn::time::seconds(ms) + ndn::time::milliseconds(GET_RANDOM (m_reexpressionJitter)))
 
 namespace Sync {
 
@@ -66,7 +66,7 @@
                       LogicUpdateCallback onUpdate,
                       LogicRemoveCallback onRemove)
   : m_state (new FullState)
-  , m_syncInterestTable (*face->ioService(), time::seconds(m_syncInterestReexpress))
+  , m_syncInterestTable (face->getIoService(), ndn::time::seconds(m_syncInterestReexpress))
   , m_syncPrefix (syncPrefix)
   , m_onUpdate (onUpdate)
   , m_onRemove (onRemove)
@@ -74,18 +74,22 @@
   , m_validator(validator)
   , m_keyChain(new KeyChain())
   , m_face(face)
-  , m_scheduler(*face->ioService())
+  , m_scheduler(face->getIoService())
   , m_randomGenerator (static_cast<unsigned int> (std::time (0)))
   , m_rangeUniformRandom (m_randomGenerator, boost::uniform_int<> (200,1000))
   , m_reexpressionJitter (m_randomGenerator, boost::uniform_int<> (100,500))
   , m_recoveryRetransmissionInterval (m_defaultRecoveryRetransmitInterval)
 {
   m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix,
-                                                        bind(&SyncLogic::onSyncInterest, this, _1, _2),
-                                                        bind(&SyncLogic::onSyncRegisterFailed, this, _1, _2));
+                                                        bind(&SyncLogic::onSyncInterest,
+                                                             this, _1, _2),
+                                                        bind(&SyncLogic::onSyncRegisterSucceed,
+                                                             this, _1),
+                                                        bind(&SyncLogic::onSyncRegisterFailed,
+                                                             this, _1, _2));
 
 
-  m_reexpressingInterestId = m_scheduler.scheduleEvent (time::seconds (0), // no need to add jitter
+  m_reexpressingInterestId = m_scheduler.scheduleEvent (ndn::time::seconds (0),
                                                         bind (&SyncLogic::sendSyncInterest, this));
 
   m_instanceId = string("Instance " + boost::lexical_cast<string>(m_instanceCounter++) + " ");
@@ -96,24 +100,28 @@
                       shared_ptr<Face> face,
                       LogicPerBranchCallback onUpdateBranch)
   : m_state (new FullState)
-  , m_syncInterestTable (*face->ioService(), time::seconds (m_syncInterestReexpress))
+  , m_syncInterestTable (face->getIoService(), ndn::time::seconds (m_syncInterestReexpress))
   , m_syncPrefix (syncPrefix)
   , m_onUpdateBranch (onUpdateBranch)
   , m_perBranch(true)
   , m_validator(validator)
   , m_keyChain(new KeyChain())
   , m_face(face)
-  , m_scheduler(*face->ioService())
+  , m_scheduler(face->getIoService())
   , m_randomGenerator (static_cast<unsigned int> (std::time (0)))
   , m_rangeUniformRandom (m_randomGenerator, boost::uniform_int<> (200,1000))
   , m_reexpressionJitter (m_randomGenerator, boost::uniform_int<> (100,500))
   , m_recoveryRetransmissionInterval (m_defaultRecoveryRetransmitInterval)
 {
   m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix,
-                                                        bind(&SyncLogic::onSyncInterest, this, _1, _2),
-                                                        bind(&SyncLogic::onSyncRegisterFailed, this, _1, _2));
+                                                        bind(&SyncLogic::onSyncInterest,
+                                                             this, _1, _2),
+                                                        bind(&SyncLogic::onSyncRegisterSucceed,
+                                                             this, _1),
+                                                        bind(&SyncLogic::onSyncRegisterFailed,
+                                                             this, _1, _2));
 
-  m_reexpressingInterestId = m_scheduler.scheduleEvent (time::seconds (0), // no need to add jitter
+  m_reexpressingInterestId = m_scheduler.scheduleEvent (ndn::time::seconds (0),
                                                         bind (&SyncLogic::sendSyncInterest, this));
 }
 
@@ -139,13 +147,13 @@
   BOOST_ASSERT (nameLengthDiff > 0);
   BOOST_ASSERT (nameLengthDiff < 3);
 
-  string hash = name.get(-1).toEscapedString();
+  string hash = name.get(-1).toUri();
   string interestType;
 
   if(nameLengthDiff == 1)
     interestType = "normal";
   else
-    interestType = name.get(-2).toEscapedString();
+    interestType = name.get(-2).toUri();
 
   _LOG_DEBUG_ID (hash << ", " << interestType);
 
@@ -189,6 +197,12 @@
 }
 
 void
+SyncLogic::onSyncRegisterSucceed(const Name& prefix)
+{
+  _LOG_DEBUG_ID("Sync prefix registration succeeded! " << prefix);
+}
+
+void
 SyncLogic::onSyncRegisterFailed(const Name& prefix, const string& msg)
 {
   _LOG_DEBUG_ID("Sync prefix registration failed! " << msg);
@@ -249,7 +263,8 @@
 }
 
 void
-SyncLogic::processSyncInterest (const Name &name, DigestConstPtr digest, bool timedProcessing/*=false*/)
+SyncLogic::processSyncInterest (const Name &name, DigestConstPtr digest,
+                                bool timedProcessing/*=false*/)
 {
   _LOG_DEBUG_ID("processSyncInterest");
   DigestConstPtr rootDigest;
@@ -291,19 +306,22 @@
       bool exists = m_syncInterestTable.insert (digest, name.toUri(), true);
       if (exists) // somebody else replied, so restart random-game timer
         {
-          _LOG_DEBUG_ID ("Unknown digest, but somebody may have already replied, so restart our timer");
+          _LOG_DEBUG_ID("Unknown digest, but somebody may have already replied, " <<
+                        "so restart our timer");
           m_scheduler.cancelEvent (m_delayedInterestProcessingId);
         }
 
       uint32_t waitDelay = GET_RANDOM (m_rangeUniformRandom);
-      _LOG_DEBUG_ID ("Digest is not in the log. Schedule processing after small delay: " << time::milliseconds (waitDelay));
+      _LOG_DEBUG_ID("Digest is not in the log. Schedule processing after small delay: " <<
+                    ndn::time::milliseconds (waitDelay));
 
-      m_delayedInterestProcessingId = m_scheduler.scheduleEvent (time::milliseconds (waitDelay),
-                                                                 bind (&SyncLogic::processSyncInterest, this, name, digest, true));
+      m_delayedInterestProcessingId =
+        m_scheduler.scheduleEvent(ndn::time::milliseconds (waitDelay),
+                                  bind (&SyncLogic::processSyncInterest, this, name, digest, true));
     }
   else
     {
-      _LOG_DEBUG_ID ("                                                      (timed processing)");
+      _LOG_DEBUG_ID("                                                      (timed processing)");
 
       m_recoveryRetransmissionInterval = m_defaultRecoveryRetransmitInterval;
       sendSyncRecoveryInterests (digest);
@@ -311,7 +329,8 @@
 }
 
 void
-SyncLogic::processSyncData (const Name &name, DigestConstPtr digest, const char *wireData, size_t len)
+SyncLogic::processSyncData (const Name &name, DigestConstPtr digest,
+                            const char *wireData, size_t len)
 {
   DiffStatePtr diffLog = boost::make_shared<DiffState> ();
   bool ownInterestSatisfied = false;
@@ -367,13 +386,17 @@
                     MissingDataInfo mdi = {info->toString(), oldSeq, seq};
                     {
                       ostringstream interestName;
-                      interestName << mdi.prefix << "/" << mdi.high.getSession() << "/" << mdi.high.getSeq();
+                      interestName << mdi.prefix <<
+                        "/" << mdi.high.getSession() <<
+                        "/" << mdi.high.getSeq();
                       _LOG_DEBUG_ID("+++++++++++++++ " + interestName.str());
                     }
                     if (m_perBranch)
                     {
                        ostringstream interestName;
-                       interestName << mdi.prefix << "/" << mdi.high.getSession() << "/" << mdi.high.getSeq();
+                       interestName << mdi.prefix <<
+                         "/" << mdi.high.getSession() <<
+                         "/" << mdi.high.getSeq();
                        m_onUpdateBranch(interestName.str());
                     }
                     else
@@ -424,10 +447,12 @@
       // Do it only if everything went fine and state changed
 
       // this is kind of wrong
-      // satisfyPendingSyncInterests (diffLog); // if there are interests in PIT, there is a point to satisfy them using new state
+      // satisfyPendingSyncInterests (diffLog); // if there are interests in PIT,
+      //                                        // there is a point to satisfy them using new state
 
       // if state has changed, then it is safe to express a new interest
-      time::system_clock::Duration after = time::milliseconds(GET_RANDOM (m_reexpressionJitter));
+      ndn::time::system_clock::Duration after =
+        ndn::time::milliseconds(GET_RANDOM (m_reexpressionJitter));
       // cout << "------------ reexpress interest after: " << after << endl;
       EventId eventId = m_scheduler.scheduleEvent (after,
                                                    bind (&SyncLogic::sendSyncInterest, this));
@@ -503,7 +528,8 @@
     {
       m_log.get<sequenced> ().front ()->setNext (diffLog);
     }
-  m_log.erase (m_state->getDigest()); // remove diff state with the same digest.  next pointers are still valid
+  m_log.erase (m_state->getDigest()); // remove diff state with the same digest.
+                                      // next pointers are still valid
   /// @todo Optimization
   m_log.get<sequenced> ().push_front (diffLog);
 }
@@ -577,8 +603,10 @@
 
   _LOG_DEBUG_ID("sendSyncInterest: " << m_outstandingInterestName);
 
-  EventId eventId = m_scheduler.scheduleEvent (time::seconds(m_syncInterestReexpress) + time::milliseconds(GET_RANDOM (m_reexpressionJitter)),
-                                               bind (&SyncLogic::sendSyncInterest, this));
+  EventId eventId =
+    m_scheduler.scheduleEvent(ndn::time::seconds(m_syncInterestReexpress) +
+                              ndn::time::milliseconds(GET_RANDOM(m_reexpressionJitter)),
+                              bind (&SyncLogic::sendSyncInterest, this));
   m_scheduler.cancelEvent (m_reexpressingInterestId);
   m_reexpressingInterestId = eventId;
 
@@ -599,14 +627,16 @@
   Name interestName = m_syncPrefix;
   interestName.append("recovery").append(os.str());
 
-  time::system_clock::Duration nextRetransmission = time::milliseconds (m_recoveryRetransmissionInterval + GET_RANDOM (m_reexpressionJitter));
+  ndn::time::system_clock::Duration nextRetransmission =
+    ndn::time::milliseconds(m_recoveryRetransmissionInterval + GET_RANDOM (m_reexpressionJitter));
 
   m_recoveryRetransmissionInterval <<= 1;
 
   m_scheduler.cancelEvent (m_reexpressingRecoveryInterestId);
   if (m_recoveryRetransmissionInterval < 100*1000) // <100 seconds
-    m_reexpressingRecoveryInterestId = m_scheduler.scheduleEvent (nextRetransmission,
-                                                                  bind (&SyncLogic::sendSyncRecoveryInterests, this, digest));
+    m_reexpressingRecoveryInterestId =
+      m_scheduler.scheduleEvent (nextRetransmission,
+                                 bind (&SyncLogic::sendSyncRecoveryInterests, this, digest));
 
   ndn::Interest interest(interestName);
   interest.setMustBeFresh(true);
@@ -637,7 +667,7 @@
 
   Data syncData(name);
   syncData.setContent(reinterpret_cast<const uint8_t*>(wireData), size);
-  syncData.setFreshnessPeriod(time::seconds(m_syncResponseFreshness));
+  syncData.setFreshnessPeriod(ndn::time::seconds(m_syncResponseFreshness));
 
   m_keyChain->sign(syncData);
 
@@ -655,7 +685,8 @@
     {
       _LOG_DEBUG_ID ("Satisfied our own Interest. Re-expressing (hopefully with a new digest)");
 
-      time::system_clock::Duration after = time::milliseconds(GET_RANDOM (m_reexpressionJitter));
+      ndn::time::system_clock::Duration after =
+        ndn::time::milliseconds(GET_RANDOM(m_reexpressionJitter));
       // cout << "------------ reexpress interest after: " << after << endl;
       EventId eventId = m_scheduler.scheduleEvent (after,
                                                    bind (&SyncLogic::sendSyncInterest, this));
diff --git a/nsync/sync-logic.h b/nsync/sync-logic.h
index afb732a..25c3aae 100644
--- a/nsync/sync-logic.h
+++ b/nsync/sync-logic.h
@@ -63,7 +63,6 @@
 class SyncLogic
 {
 public:
-  //typedef boost::function< void ( const std::string &/*prefix*/, const SeqNo &/*newSeq*/, const SeqNo &/*oldSeq*/ ) > LogicUpdateCallback;
   typedef boost::function< void (const std::vector<MissingDataInfo> & ) > LogicUpdateCallback;
   typedef boost::function< void (const std::string &/*prefix*/ ) > LogicRemoveCallback;
   typedef boost::function< void (const std::string &)> LogicPerBranchCallback;
@@ -122,6 +121,9 @@
   onSyncInterest (const ndn::Name& prefix, const ndn::Interest& interest);
 
   void
+  onSyncRegisterSucceed(const ndn::Name& prefix);
+
+  void
   onSyncRegisterFailed(const ndn::Name& prefix, const std::string& msg);
 
   void
diff --git a/nsync/sync-socket.cc b/nsync/sync-socket.cc
index 7c4e410..e3fbcf1 100644
--- a/nsync/sync-socket.cc
+++ b/nsync/sync-socket.cc
@@ -40,7 +40,6 @@
   , m_validator(validator)
   , m_keyChain(new KeyChain())
   , m_face(face)
-  , m_ioService(face->ioService())
   , m_syncLogic (syncPrefix,
                  validator,
                  face,
@@ -53,23 +52,28 @@
 }
 
 bool
-SyncSocket::publishData(const Name &prefix, uint64_t session, const char *buf, size_t len, int freshness,uint64_t seq)
+SyncSocket::publishData(const Name &prefix, uint64_t session,
+                        const char *buf, size_t len,
+                        int freshness,uint64_t seq)
 {
   shared_ptr<Data> data = make_shared<Data>();
   data->setContent(reinterpret_cast<const uint8_t*>(buf), len);
-  data->setFreshnessPeriod(time::seconds(freshness));
+  data->setFreshnessPeriod(ndn::time::seconds(freshness));
 
-  m_ioService->post(bind(&SyncSocket::publishDataInternal, this, data, prefix, session,seq));
+  m_face->getIoService().post(bind(&SyncSocket::publishDataInternal, this,
+                                   data, prefix, session,seq));
 
   return true;
 }
 
 void
-SyncSocket::publishDataInternal(shared_ptr<Data> data, const Name &prefix, uint64_t session,uint64_t seq)
+SyncSocket::publishDataInternal(shared_ptr<Data> data,
+                                const Name &prefix, uint64_t session, uint64_t seq)
 {
   uint64_t sequence = seq;
   Name dataName = prefix;
-  dataName.append(boost::lexical_cast<string>(session)).append(boost::lexical_cast<string>(sequence));
+  dataName.append(boost::lexical_cast<string>(session))
+    .append(boost::lexical_cast<string>(sequence));
   data->setName(dataName);
 
   m_keyChain->sign(*data);
@@ -82,18 +86,23 @@
 }
 
 void
-SyncSocket::fetchData(const Name &prefix, const SeqNo &seq, const OnDataValidated& onValidated, int retry)
+SyncSocket::fetchData(const Name &prefix, const SeqNo &seq,
+                      const OnDataValidated& onValidated, int retry)
 {
   Name interestName = prefix;
-  interestName.append(boost::lexical_cast<string>(seq.getSession())).append(boost::lexical_cast<string>(seq.getSeq()));
+  interestName.append(boost::lexical_cast<string>(seq.getSession()))
+    .append(boost::lexical_cast<string>(seq.getSeq()));
 
-  const OnDataValidationFailed& onValidationFailed = bind(&SyncSocket::onDataValidationFailed, this, _1);
+  const OnDataValidationFailed& onValidationFailed =
+    bind(&SyncSocket::onDataValidationFailed, this, _1);
 
   ndn::Interest interest(interestName);
   interest.setMustBeFresh(true);
   m_face->expressInterest(interest,
-                          bind(&SyncSocket::onData, this, _1, _2, onValidated, onValidationFailed),
-                          bind(&SyncSocket::onDataTimeout, this, _1, retry, onValidated, onValidationFailed));
+                          bind(&SyncSocket::onData, this, _1, _2,
+                               onValidated, onValidationFailed),
+                          bind(&SyncSocket::onDataTimeout, this, _1, retry,
+                               onValidated, onValidationFailed));
 
 }
 
diff --git a/nsync/sync-socket.h b/nsync/sync-socket.h
index 541673c..ef54a99 100644
--- a/nsync/sync-socket.h
+++ b/nsync/sync-socket.h
@@ -42,8 +42,8 @@
 class SyncSocket
 {
 public:
-  typedef ndn::function< void (const std::vector<MissingDataInfo> &, SyncSocket * ) > NewDataCallback;
-  typedef ndn::function< void (const std::string &/*prefix*/ ) > RemoveCallback;
+  typedef ndn::function<void(const std::vector<MissingDataInfo> &, SyncSocket *)> NewDataCallback;
+  typedef ndn::function<void(const std::string &/*prefix*/)> RemoveCallback;
 
   /**
    * @brief the constructor for SyncAppSocket; the parameter syncPrefix
@@ -56,47 +56,52 @@
    * @param syncPrefix the name prefix for Sync Interest
    * @param dataCallback the callback to process data
    */
-  SyncSocket (const ndn::Name &syncPrefix, 
+  SyncSocket (const ndn::Name &syncPrefix,
               ndn::shared_ptr<ndn::Validator> validator,
               ndn::shared_ptr<ndn::Face> face,
-              NewDataCallback dataCallback, 
+              NewDataCallback dataCallback,
               RemoveCallback rmCallback);
 
   ~SyncSocket ();
 
-  bool 
-  publishData(const ndn::Name &prefix, uint64_t session, const char *buf, size_t len, int freshness,uint64_t seq);
+  bool
+  publishData(const ndn::Name &prefix, uint64_t session, const char *buf, size_t len,
+              int freshness,uint64_t seq);
 
-  void 
-  remove (const ndn::Name &prefix) 
+  void
+  remove (const ndn::Name &prefix)
   { m_syncLogic.remove(prefix); }
 
-  void 
-  fetchData(const ndn::Name &prefix, const SeqNo &seq, const ndn::OnDataValidated& onValidated, int retry = 0);
+  void
+  fetchData(const ndn::Name &prefix, const SeqNo &seq,
+            const ndn::OnDataValidated& onValidated, int retry = 0);
 
-  std::string 
-  getRootDigest() 
+  std::string
+  getRootDigest()
   { return m_syncLogic.getRootDigest(); }
 
   uint64_t
   getNextSeq (const ndn::Name &prefix, uint64_t session);
 
   SyncLogic &
-  getLogic () 
+  getLogic ()
   { return m_syncLogic; }
 
   // make this a static function so we don't have to create socket instance without
   // knowing the local prefix. it's a wrong place for this function anyway
   static std::string
-  GetLocalPrefix (); 
-  
+  GetLocalPrefix ();
+
 private:
   void
-  publishDataInternal(ndn::shared_ptr<ndn::Data> data, const ndn::Name &prefix, uint64_t session,uint64_t seq);
+  publishDataInternal(ndn::shared_ptr<ndn::Data> data,
+                      const ndn::Name &prefix, uint64_t session,uint64_t seq);
 
-  void 
-  passCallback(const std::vector<MissingDataInfo> &v) 
-  { m_newDataCallback(v, this); }
+  void
+  passCallback(const std::vector<MissingDataInfo> &v)
+  {
+    m_newDataCallback(v, this);
+  }
 
   void
   onData(const ndn::Interest& interest, ndn::Data& data,
@@ -104,7 +109,7 @@
          const ndn::OnDataValidationFailed& onValidationFailed);
 
   void
-  onDataTimeout(const ndn::Interest& interest, 
+  onDataTimeout(const ndn::Interest& interest,
                 int retry,
                 const ndn::OnDataValidated& onValidated,
                 const ndn::OnDataValidationFailed& onValidationFailed);
@@ -119,7 +124,6 @@
   ndn::shared_ptr<ndn::Validator> m_validator;
   ndn::shared_ptr<ndn::KeyChain> m_keyChain;
   ndn::shared_ptr<ndn::Face> m_face;
-  ndn::shared_ptr<boost::asio::io_service> m_ioService;
   SyncLogic      m_syncLogic;
 };
 
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
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 8ec3a4e..576b87f 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -2,7 +2,7 @@
  * Copyright (C) 2014 Regents of the University of Memphis.
  * See COPYING for copyright and distribution information.
  */
-
+#include <fstream>
 #include "conf-file-processor.hpp"
 #include "nlsr.hpp"
 #include <boost/test/unit_test.hpp>
@@ -18,16 +18,47 @@
   Nlsr nlsr1;
 
   const std::string CONFIG =
-    "network ndn\n"
-    "site-name memphis.edu\n"
-    "router-name cs/macbook\n\n"
-    "ndnneighbor /ndn/memphis.edu/cs/maia 7\n"
-    "link-cost /ndn/memphis.edu/cs/maia 30\n"
-    "ndnneighbor /ndn/memphis.edu/cs/pollux 10\n"
-    "link-cost /ndn/memphis.edu/cs/pollux 25\n\n"
-    "ndnname /ndn/memphis.edu/cs/macbook/name1\n"
-    "ndnname /ndn/memphis.edu/cs/macbook/name2\n\n\n"
-    ;
+     "general\n"
+    "{\n"
+    "  network /ndn/\n"      
+    "  site /memphis.edu/\n"
+    "  router /cs/pollux/\n"
+    "  lsa-refresh-time 1800\n"
+    "  log-level  INFO\n"
+    "}\n\n"
+    "neighbors\n"
+    "{\n"
+    "  hello-retries 3\n"
+    "  hello-time-out 1\n"
+    "  hello-interval  60\n\n"
+    "  neighbor\n"
+    "  {\n"
+    "    name /ndn/memphis.edu/cs/castor\n"
+    "    face-id  15\n"
+    "    link-cost 20\n"
+    "  }\n\n"
+    "  neighbor\n"
+    "  {\n"
+    "    name /ndn/memphis.edu/cs/mira\n"
+    "    face-id  17\n"
+    "    link-cost 30\n"
+    "  }\n"
+    "}\n\n"
+    "hyperbolic\n"
+    "{\n"
+    "state off\n"
+    "radius   123.456\n"
+    "angle    1.45\n"
+    "}\n\n"
+    "fib\n"
+    "{\n"
+    "   max-faces-per-prefix 3\n"
+    "}\n\n"
+    "advertising\n"
+    "{\n"
+    "prefix /ndn/edu/memphis/cs/netlab\n"
+    "prefix /ndn/edu/memphis/sports/basketball\n"
+    "}\n";
 
   std::ofstream config;
   config.open("unit-test-nlsr.conf");
@@ -40,12 +71,12 @@
 
   cfp1.processConfFile();
 
-  BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/maia"));
+  BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira"));
   BOOST_CHECK_EQUAL(
-    nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/maia").getName(),
-    "/ndn/memphis.edu/cs/maia");
+    nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getName(),
+    "/ndn/memphis.edu/cs/mira");
   BOOST_CHECK_EQUAL(
-    nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/maia").getLinkCost(),
+    nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getLinkCost(),
     30);
 
   BOOST_CHECK_EQUAL(nlsr1.getNamePrefixList().getSize(), 2);
diff --git a/tests/test-conf-parameter.cpp b/tests/test-conf-parameter.cpp
index 95ae19e..d9a38f9 100644
--- a/tests/test-conf-parameter.cpp
+++ b/tests/test-conf-parameter.cpp
@@ -28,8 +28,6 @@
 
   cp1.setNetwork(NETWORK);
 
-  cp1.setRootKeyPrefix("adminRootKey");
-
   cp1.setInterestRetryNumber(2);
 
   cp1.setInterestResendTime(1000);
@@ -40,29 +38,12 @@
 
   cp1.setMaxFacesPerPrefix(50);
 
-  cp1.setLogDir("log");
-
-  cp1.setCertDir("cert");
-
-  cp1.setSeqFileDir("ssfd");
-
-  cp1.setDetailedLogging(1);
-
-  cp1.setDebugging(1);
-
-  cp1.setIsHyperbolicCalc(1);
+  cp1.setHyperbolicState(1);
 
   cp1.setCorR(2.5);
 
   cp1.setCorTheta(102.5);
 
-  cp1.setTunnelType(2);
-
-  const string a = "csp";
-  cp1.setChronosyncSyncPrefix(a);
-
-  cp1.setChronosyncLsaPrefix("cla");
-
   cp1.setInfoInterestInterval(3);
 
   BOOST_CHECK_EQUAL(cp1.getRouterName(), "router1");
@@ -75,8 +56,6 @@
 
   BOOST_CHECK_EQUAL(cp1.getRouterPrefix(), "/ATT/memphis/router1");
 
-  BOOST_CHECK_EQUAL(cp1.getRootKeyPrefix(), "adminRootKey");
-
   BOOST_CHECK_EQUAL(cp1.getInterestRetryNumber(), (uint32_t)2);
 
   BOOST_CHECK_EQUAL(cp1.getInterestResendTime(), 1000);
@@ -87,26 +66,10 @@
 
   BOOST_CHECK_EQUAL(cp1.getMaxFacesPerPrefix(), 50);
 
-  BOOST_CHECK_EQUAL(cp1.getLogDir(), "log");
-
-  BOOST_CHECK_EQUAL(cp1.getCertDir(), "cert");
-
-  BOOST_CHECK_EQUAL(cp1.getSeqFileDir(), "ssfd");
-
-  BOOST_CHECK_EQUAL(cp1.getDetailedLogging(), 1);
-
-  BOOST_CHECK_EQUAL(cp1.getDebugging(), 1);
-
-  BOOST_CHECK_EQUAL(cp1.getIsHyperbolicCalc(), 1);
+  BOOST_CHECK_EQUAL(cp1.getHyperbolicState(), 1);
 
   BOOST_CHECK_CLOSE(cp1.getCorTheta(), 102.5, 0.0001);
 
-  BOOST_CHECK_EQUAL(cp1.getTunnelType(), 2);
-
-  BOOST_CHECK_EQUAL(cp1.getChronosyncSyncPrefix(), "csp");
-
-  BOOST_CHECK_EQUAL(cp1.getChronosyncLsaPrefix(), "cla");
-
   BOOST_CHECK_EQUAL(cp1.getInfoInterestInterval(), 3);
 }
 
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 022efa7..a72c55e 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -28,7 +28,7 @@
   npl1.insert(s1);
   npl1.insert(s2);
 
-//For NameLsa lsType is 1.
+//For NameLsa lsType is name.
 //12 is seqNo, randomly generated.
 //1800 is the default life time.
   NameLsa nlsa1("router1", std::string("name"), 12, 1800, npl1);
diff --git a/tests/test-nexthop.cpp b/tests/test-nexthop.cpp
index 0cdf23c..fb6a8fb 100644
--- a/tests/test-nexthop.cpp
+++ b/tests/test-nexthop.cpp
@@ -16,11 +16,11 @@
 {
   NextHop np1;
 
-  np1.setConnectingFace(1);
+  np1.setConnectingFaceUri("udp://test/uri");
 
   np1.setRouteCost(10.5);
 
-  BOOST_CHECK_EQUAL(np1.getConnectingFace(), (uint32_t)1);
+  BOOST_CHECK_EQUAL(np1.getConnectingFaceUri(), "udp://test/uri");
   BOOST_CHECK_CLOSE(np1.getRouteCost(), 10.5, 0.0001);
 }
 
diff --git a/tests/test-tokenizer.cpp b/tests/test-tokenizer.cpp
deleted file mode 100644
index b3a8234..0000000
--- a/tests/test-tokenizer.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2014 Regents of the University of Memphis.
- * See COPYING for copyright and distribution information.
- */
-
-#include "utility/tokenizer.hpp"
-#include <boost/test/unit_test.hpp>
-
-namespace nlsr {
-
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TestTokenizer)
-
-BOOST_AUTO_TEST_CASE(TokenizerBasic)
-{
-  Tokenizer token1("/ndn/memphis.edu/cs", "/");
-  Tokenizer token2("/ndn/memphis.edu/cs", "/");
-
-  Tokenizer token3("/test/hello");
-
-  BOOST_CHECK(token1.getFirstToken() == token2.getFirstToken());
-
-  BOOST_CHECK_EQUAL(token1.getRestOfLine(), token2.getRestOfLine());
-
-  BOOST_CHECK(token1.getFirstToken() != token3.getFirstToken());
-
-  BOOST_CHECK(token1.getRestOfLine() != token3.getRestOfLine());
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} //namespace test
-} //namespace nlsr
diff --git a/wscript b/wscript
index 146b5e8..909a2df 100644
--- a/wscript
+++ b/wscript
@@ -46,7 +46,7 @@
     conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
                    uselib_store='NDN_CPP', mandatory=True)
 
-    boost_libs = 'system chrono program_options iostreams thread'
+    boost_libs = 'system chrono program_options iostreams thread regex'
     if conf.options.with_tests:
         conf.env['WITH_TESTS'] = 1
         conf.define('WITH_TESTS', 1);
