diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index d4b7193..8d7f1ec 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2015,  The University of Memphis,
+ * Copyright (c) 2014-2016,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -19,24 +19,114 @@
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  **/
 
-#include <string>
-#include <utility>
-
 #include "lsdb.hpp"
-#include "nlsr.hpp"
-#include "conf-parameter.hpp"
-#include "utility/name-helper.hpp"
+
 #include "logger.hpp"
+#include "nlsr.hpp"
+#include "publisher/segment-publisher.hpp"
+#include "utility/name-helper.hpp"
+
+#include <ndn-cxx/security/signing-helpers.hpp>
+#include <ndn-cxx/util/segment-fetcher.hpp>
+
+#include <string>
 
 namespace nlsr {
 
 INIT_LOGGER("Lsdb");
 
+class LsaContentPublisher : public SegmentPublisher<ndn::Face>
+{
+public:
+  LsaContentPublisher(ndn::Face& face,
+                      ndn::KeyChain& keyChain,
+                      const ndn::time::milliseconds& freshnessPeriod,
+                      const std::string& content)
+    : SegmentPublisher(face, keyChain, freshnessPeriod)
+    , m_content(content)
+  {
+  }
+
+  virtual size_t
+  generate(ndn::EncodingBuffer& outBuffer) {
+    size_t totalLength = 0;
+    totalLength += outBuffer.prependByteArray(reinterpret_cast<const uint8_t*>(m_content.c_str()),
+                                              m_content.size());
+    return totalLength;
+  }
+
+private:
+  const std::string m_content;
+};
+
 const ndn::Name::Component Lsdb::NAME_COMPONENT = ndn::Name::Component("lsdb");
 const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
 const steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE = steady_clock::TimePoint::min();
 
-using namespace std;
+Lsdb::Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
+  : m_nlsr(nlsr)
+  , m_scheduler(scheduler)
+  , m_sync(sync)
+  , m_lsaRefreshTime(0)
+  , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
+{
+}
+
+void
+Lsdb::onFetchLsaError(uint32_t errorCode,
+                      const std::string& msg,
+                      ndn::Name& interestName,
+                      uint32_t retransmitNo,
+                      const ndn::time::steady_clock::TimePoint& deadline,
+                      ndn::Name lsaName,
+                      uint64_t seqNo)
+{
+  _LOG_DEBUG("Failed to fetch LSA: " << lsaName << ", Error code: " << errorCode
+                                                << ", Message: " << msg);
+
+  if (ndn::time::steady_clock::now() < deadline) {
+    SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
+
+    if (it != m_highestSeqNo.end() && it->second == seqNo) {
+      // If the SegmentFetcher failed due to an Interest timeout, it is safe to re-express
+      // immediately since at the least the LSA Interest lifetime has elapsed.
+      // Otherwise, it is necessary to delay the Interest re-expression to prevent
+      // the potential for constant Interest flooding.
+      ndn::time::seconds delay = m_nlsr.getConfParameter().getLsaInterestLifetime();
+
+      if (errorCode == ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
+        delay = ndn::time::seconds(0);
+      }
+
+      m_scheduler.scheduleEvent(delay, std::bind(&Lsdb::expressInterest, this,
+                                                 interestName, retransmitNo + 1, deadline));
+    }
+  }
+}
+
+void
+Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, ndn::Name& interestName)
+{
+  shared_ptr<ndn::Data> data = make_shared<ndn::Data>(ndn::Name(interestName));
+  data->setContent(bufferPtr);
+
+  _LOG_DEBUG("Received data for LSA(name): " << data->getName());
+
+  ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
+  uint64_t seqNo = interestName[-1].toNumber();
+
+  if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
+    m_highestSeqNo[lsaName] = seqNo;
+  }
+  else if (seqNo > m_highestSeqNo[lsaName]) {
+    m_highestSeqNo[lsaName] = seqNo;
+  }
+  else if (seqNo < m_highestSeqNo[lsaName]) {
+    return;
+  }
+
+  onContentValidated(data);
+}
 
 void
 Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
@@ -50,7 +140,6 @@
   return nlsa1.getKey() == key;
 }
 
-
 bool
 Lsdb::buildAndInstallOwnNameLsa()
 {
@@ -640,7 +729,7 @@
 }
 
 void
-Lsdb::setThisRouterPrefix(string trp)
+Lsdb::setThisRouterPrefix(std::string trp)
 {
   m_thisRouterPrefix = trp;
 }
@@ -748,7 +837,6 @@
   }
 }
 
-
 void
 Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
                       steady_clock::TimePoint deadline)
@@ -758,8 +846,6 @@
   }
 
   ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
-
-  ndn::Interest interest(interestName);
   uint64_t seqNo = interestName[-1].toNumber();
 
   if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
@@ -772,14 +858,15 @@
     return;
   }
 
+  ndn::Interest interest(interestName);
   interest.setInterestLifetime(m_nlsr.getConfParameter().getLsaInterestLifetime());
 
-  _LOG_DEBUG("Expressing Interest for LSA: " << interestName << " Seq number: " << seqNo);
-  m_nlsr.getNlsrFace().expressInterest(interest,
-                                       ndn::bind(&Lsdb::onContent,
-                                                 this, _2, deadline, lsaName, seqNo),
-                                       ndn::bind(&Lsdb::processInterestTimedOut,
-                                                 this, _1, timeoutCount, deadline, lsaName, seqNo));
+  _LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
+  ndn::util::SegmentFetcher::fetch(m_nlsr.getNlsrFace(), interest,
+                                   m_nlsr.getValidator(),
+                                   ndn::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
+                                   ndn::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
+                                             timeoutCount, deadline, lsaName, seqNo));
 }
 
 void
@@ -788,7 +875,7 @@
   const ndn::Name& interestName(interest.getName());
   _LOG_DEBUG("Interest received for LSA: " << interestName);
 
-  string chkString("LSA");
+  std::string chkString("LSA");
   int32_t lsaPosition = util::getNameComponentPosition(interest.getName(), chkString);
 
   if (lsaPosition >= 0) {
@@ -820,16 +907,12 @@
 void
 Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
 {
-  ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
-  data->setName(ndn::Name(interest.getName()).appendVersion());
-  data->setFreshnessPeriod(m_lsaRefreshTime);
-  data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
-  m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName());
-  ndn::SignatureSha256WithRsa signature(data->getSignature());
-  ndn::Name signingCertName = signature.getKeyLocator().getName();
-  _LOG_DEBUG("Sending data for LSA(name): " << interest.getName());
-  _LOG_DEBUG("Data signed with: " << signingCertName);
-  m_nlsr.getNlsrFace().put(*data);
+  LsaContentPublisher publisher(m_nlsr.getNlsrFace(),
+                                m_nlsr.getKeyChain(),
+                                m_lsaRefreshTime,
+                                content);
+  publisher.publish(interest.getName(),
+                    ndn::security::signingByCertificate(m_nlsr.getDefaultCertName()));
 }
 
 void
@@ -875,58 +958,23 @@
 }
 
 void
-Lsdb::onContent(const ndn::Data& data,
-                const steady_clock::TimePoint& deadline, ndn::Name lsaName,
-                uint64_t seqNo)
-{
-  _LOG_DEBUG("Received data for LSA(name): " << data.getName());
-  if (data.getSignature().hasKeyLocator()) {
-    if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
-      _LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
-    }
-  }
-  m_nlsr.getValidator().validate(data,
-                                 ndn::bind(&Lsdb::onContentValidated, this, _1),
-                                 ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
-                                           deadline, lsaName, seqNo));
-
-}
-
-void
-Lsdb::retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
-                             const steady_clock::TimePoint& deadline, ndn::Name lsaName,
-                             uint64_t seqNo)
-{
-  _LOG_DEBUG("Retrying validation of LSA(name): " << data->getName());
-  if (data->getSignature().hasKeyLocator()) {
-    if (data->getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
-      _LOG_DEBUG("Data signed with: " << data->getSignature().getKeyLocator().getName());
-    }
-  }
-  m_nlsr.getValidator().validate(*data,
-                                 ndn::bind(&Lsdb::onContentValidated, this, _1),
-                                 ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
-                                           deadline, lsaName, seqNo));
-}
-
-void
 Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
 {
   const ndn::Name& dataName = data->getName();
   _LOG_DEBUG("Data validation successful for LSA: " << dataName);
 
-  string chkString("LSA");
+  std::string chkString("LSA");
   int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);
 
   if (lsaPosition >= 0) {
 
     ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
-    originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 4));
+    originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 3));
 
-    uint64_t seqNo = dataName[-2].toNumber();
-    string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
+    uint64_t seqNo = dataName[-1].toNumber();
+    std::string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
 
-    std::string interestedLsType  = dataName[-3].toUri();
+    std::string interestedLsType  = dataName[-2].toUri();
 
     if (interestedLsType == NameLsa::TYPE_STRING) {
       processContentNameLsa(originRouter.append(interestedLsType), seqNo, dataContent);
@@ -944,32 +992,6 @@
 }
 
 void
-Lsdb::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
-                                const std::string& msg,
-                                const steady_clock::TimePoint& deadline, ndn::Name lsaName,
-                                uint64_t seqNo)
-{
-  _LOG_DEBUG("Validation Error: " << msg);
-
-  // Delay re-validation by LSA Interest Lifetime.  When error callback will have an error
-  // code, re-validation should be done only when some keys from certification chain failed
-  // to be fetched.  After that change, delaying will no longer be necessary.
-
-  // Stop retrying if delayed re-validation will be scheduled pass the deadline
-  if (steady_clock::now() + m_nlsr.getConfParameter().getLsaInterestLifetime() < deadline) {
-
-    SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
-
-    if (it != m_highestSeqNo.end() && it->second == seqNo) {
-      _LOG_DEBUG("Scheduling revalidation attempt");
-      m_scheduler.scheduleEvent(m_nlsr.getConfParameter().getLsaInterestLifetime(),
-                                ndn::bind(&Lsdb::retryContentValidation, this, data,
-                                          deadline, lsaName, seqNo));
-    }
-  }
-}
-
-void
 Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
                             uint64_t lsSeqNo, std::string& dataContent)
 {
@@ -1014,24 +1036,6 @@
   }
 }
 
-void
-Lsdb::processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
-                              const ndn::time::steady_clock::TimePoint& deadline, ndn::Name lsaName,
-                              uint64_t seqNo)
-{
-  const ndn::Name& interestName = interest.getName();
-  _LOG_DEBUG("Interest timed out for  LSA: " << interestName);
-
-  if (ndn::time::steady_clock::now() < deadline) {
-
-    SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
-
-    if (it != m_highestSeqNo.end() &&  it->second == seqNo) {
-      expressInterest(interestName, retransmitNo + 1, deadline);
-    }
-  }
-}
-
 ndn::time::system_clock::TimePoint
 Lsdb::getLsaExpirationTimePoint()
 {
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 417c978..eac7770 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2015,  The University of Memphis,
+ * Copyright (c) 2014-2016,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -24,6 +24,7 @@
 
 #include <utility>
 #include <boost/cstdint.hpp>
+
 #include <ndn-cxx/security/key-chain.hpp>
 #include <ndn-cxx/util/time.hpp>
 
@@ -41,19 +42,12 @@
 class Lsdb
 {
 public:
-  Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
-    : m_nlsr(nlsr)
-    , m_scheduler(scheduler)
-    , m_sync(sync)
-    , m_lsaRefreshTime(0)
-    , m_adjLsaBuildInterval(static_cast<uint32_t>(ADJ_LSA_BUILD_INTERVAL_DEFAULT))
-  {
-  }
+  Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync);
 
   bool
   doesLsaExist(const ndn::Name& key, const std::string& lsType);
-  // function related to Name LSDB
 
+  // functions related to Name LSDB
   bool
   buildAndInstallOwnNameLsa();
 
@@ -75,7 +69,7 @@
   const std::list<NameLsa>&
   getNameLsdb();
 
-  //function related to Cor LSDB
+  // functions related to Cor LSDB
   bool
   buildAndInstallOwnCoordinateLsa();
 
@@ -97,8 +91,7 @@
   const std::list<CoordinateLsa>&
   getCoordinateLsdb();
 
-  //function related to Adj LSDB
-
+  // functions related to Adj LSDB
   void
   scheduleAdjLsaBuild();
 
@@ -141,6 +134,13 @@
   void
   setThisRouterPrefix(std::string trp);
 
+  void
+  expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
+                  steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
+
+  void
+  processInterest(const ndn::Name& name, const ndn::Interest& interest);
+
 private:
   bool
   addNameLsa(NameLsa& nlsa);
@@ -187,16 +187,8 @@
   void
   exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
                                 uint64_t seqNo);
-public:
-  void
-  expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
-                  steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
 
   void
-  processInterest(const ndn::Name& name, const ndn::Interest& interest);
-
-private:
-  void
   putLsaData(const ndn::Interest& interest, const std::string& content);
 
   void
@@ -215,32 +207,9 @@
                                   uint64_t seqNo);
 
   void
-  onContent(const ndn::Data& data, const steady_clock::TimePoint& deadline,
-            ndn::Name lsaName, uint64_t seqNo);
-
-  /**
-   * @brief Retry validation after it fails
-   *
-   * Data packet validation can fail either because the packet does not have
-   * valid signature (fatal) or because some of the certificate chain Data packets
-   * failed to be fetched (non-fatal).  Currently, the library does not provide
-   * clear indication (besides plain-text message in error callback) of what is
-   * the reason for failure and we will try to re-validate for as long as it the deadline.
-   */
-  void
-  retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
-                         const steady_clock::TimePoint& deadline, ndn::Name lsaName,
-                         uint64_t seqNo);
-
-  void
   onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
 
   void
-  onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, const std::string& msg,
-                            const steady_clock::TimePoint& deadline, ndn::Name lsaName,
-                            uint64_t seqNo);
-
-  void
   processContentNameLsa(const ndn::Name& lsaKey,
                         uint64_t lsSeqNo, std::string& dataContent);
 
@@ -253,10 +222,37 @@
                               uint64_t lsSeqNo, std::string& dataContent);
 
 PUBLIC_WITH_TESTS_ELSE_PRIVATE:
+  /**
+   * @brief Error callback when SegmentFetcher fails to return an LSA
+   *
+   * In all error cases, a reattempt to fetch the LSA will be made.
+   *
+   * Segment validation can fail either because the packet does not have a
+   * valid signature (fatal) or because some of the certificates in the trust chain
+   * could not be fetched (non-fatal).
+   *
+   * Currently, the library does not provide clear indication (besides a plain-text message
+   * in the error callback) of the reason for the failure nor the segment that failed
+   * to be validated, thus we will continue to try to fetch the LSA until the deadline
+   * is reached.
+   */
   void
-  processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
-                          const steady_clock::TimePoint& deadline, ndn::Name lsaName,
-                          uint64_t seqNo);
+  onFetchLsaError(uint32_t errorCode,
+                  const std::string& msg,
+                  ndn::Name& interestName,
+                  uint32_t retransmitNo,
+                  const ndn::time::steady_clock::TimePoint& deadline,
+                  ndn::Name lsaName,
+                  uint64_t seqNo);
+
+  /**
+   * @brief Success callback when SegmentFetcher returns a valid LSA
+   *
+   * \param The base Interest used to fetch the LSA in the format:
+   *        /<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
+   */
+  void
+  afterFetchLsa(const ndn::ConstBufferPtr& data, ndn::Name& interestName);
 
 private:
   system_clock::TimePoint
diff --git a/src/publisher/segment-publisher.hpp b/src/publisher/segment-publisher.hpp
index 5aefa52..7d959e1 100644
--- a/src/publisher/segment-publisher.hpp
+++ b/src/publisher/segment-publisher.hpp
@@ -68,7 +68,8 @@
   /** \brief Publish data under provided prefix
    */
   void
-  publish(const ndn::Name& prefix)
+  publish(const ndn::Name& prefix,
+          const ndn::security::SigningInfo& signingInfo = ndn::security::KeyChain::DEFAULT_SIGNING_INFO)
   {
     ndn::EncodingBuffer buffer;
     generate(buffer);
@@ -99,7 +100,7 @@
         data->setFinalBlockId(segmentName[-1]);
       }
 
-      publishSegment(data);
+      publishSegment(data, signingInfo);
       ++segmentNo;
     } while (segmentBegin < end);
   }
@@ -112,9 +113,9 @@
 
 private:
   void
-  publishSegment(ndn::shared_ptr<ndn::Data>& data)
+  publishSegment(ndn::shared_ptr<ndn::Data>& data, const ndn::security::SigningInfo& signingInfo)
   {
-    m_keyChain.sign(*data);
+    m_keyChain.sign(*data, signingInfo);
     m_face.put(*data);
   }
 
