diff --git a/src/common.hpp b/src/common.hpp
index 3337520..cd6dc18 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -27,7 +27,6 @@
 #ifndef NLSR_COMMON_HPP
 #define NLSR_COMMON_HPP
 
-#include <ndn-cxx/common.hpp>
 #include <ndn-cxx/util/time.hpp>
 #include <ndn-cxx/name.hpp>
 
diff --git a/src/lsa-segment-storage.cpp b/src/lsa-segment-storage.cpp
index dfe92d7..830906d 100644
--- a/src/lsa-segment-storage.cpp
+++ b/src/lsa-segment-storage.cpp
@@ -97,21 +97,8 @@
       NLSR_LOG_TRACE("The received segment is already in the storage.");
     }
 
-    std::string content(reinterpret_cast<const char*>(lsaSegment.getContent().value()),
-                        lsaSegment.getContent().value_size());
-
     ndn::time::seconds expirationTime(LSA_REFRESH_TIME_DEFAULT);
 
-    std::vector<std::string> options;
-    boost::split(options, content, boost::is_any_of("|"));
-
-    try {
-      expirationTime = ndn::time::duration_cast<ndn::time::seconds>
-                       (ndn::time::fromIsoString(options.at(3)) - ndn::time::system_clock::now());
-    } catch (const std::exception& e) {
-      NLSR_LOG_ERROR("Cannot extract expiration time from LSA content: " << e.what());
-    }
-
     // schedule the segment deletion
     scheduleLsaSegmentDeletion(lsaSegmentsKey, expirationTime);
   }
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index b8cda8e..1507a08 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -24,7 +24,6 @@
 #include "logger.hpp"
 #include "lsa-segment-storage.hpp"
 #include "nlsr.hpp"
-#include "publisher/segment-publisher.hpp"
 #include "utility/name-helper.hpp"
 
 #include <ndn-cxx/security/signing-helpers.hpp>
@@ -33,31 +32,6 @@
 
 INIT_LOGGER(Lsdb);
 
-class LsaContentPublisher : public SegmentPublisher<ndn::Face>
-{
-public:
-  LsaContentPublisher(ndn::Face& face,
-                      ndn::KeyChain& keyChain,
-                      const ndn::security::SigningInfo& signingInfo,
-                      const ndn::time::milliseconds& freshnessPeriod,
-                      const std::string& content)
-    : SegmentPublisher(face, keyChain, signingInfo, 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 ndn::time::steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE =
@@ -76,11 +50,12 @@
   , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
   , m_sequencingManager()
   , m_onNewLsaConnection(m_sync.onNewLsa->connect(
-      [this] (const ndn::Name& updateName, const uint64_t& sequenceNumber) {
+      [this] (const ndn::Name& updateName, uint64_t sequenceNumber) {
         ndn::Name lsaInterest{updateName};
         lsaInterest.appendNumber(sequenceNumber);
         expressInterest(lsaInterest, 0);
       }))
+  , m_segmentPublisher(m_nlsr.getNlsrFace(), m_nlsr.getKeyChain())
 {
 }
 
@@ -127,7 +102,7 @@
 Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, const ndn::Name& interestName)
 {
   std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(ndn::Name(interestName));
-  data->setContent(bufferPtr);
+  data->setContent(ndn::Block(bufferPtr));
 
   NLSR_LOG_DEBUG("Received data for LSA(name): " << data->getName());
 
@@ -1050,48 +1025,53 @@
 void
 Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
 {
+  ndn::Name interestName(interest.getName());
+  NLSR_LOG_DEBUG("Interest received for LSA: " << interestName);
+
+  if (interestName[-2].isVersion()) {
+    // Interest for particular segment
+    if (m_segmentPublisher.replyFromStore(interestName)) {
+      NLSR_LOG_TRACE("Reply from SegmentPublisher storage");
+      return;
+    }
+    // Remove version and segment
+    interestName = interestName.getSubName(0, interestName.size() - 2);
+    NLSR_LOG_TRACE("Interest w/o segment and version: " << interestName);
+  }
+
   // increment RCV_LSA_INTEREST
   lsaIncrementSignal(Statistics::PacketType::RCV_LSA_INTEREST);
 
-  const ndn::Name& interestName(interest.getName());
-  NLSR_LOG_DEBUG("Interest received for LSA: " << interestName);
-
   std::string chkString("LSA");
-  int32_t lsaPosition = util::getNameComponentPosition(interest.getName(), chkString);
+  int32_t lsaPosition = util::getNameComponentPosition(interestName, chkString);
 
   // Forms the name of the router that the Interest packet came from.
   ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
   originRouter.append(interestName.getSubName(lsaPosition + 1,
-                                              interest.getName().size() - lsaPosition - 3));
+                                              interestName.size() - lsaPosition - 3));
 
   // if the interest is for this router's LSA
-  if (originRouter == m_nlsr.getConfParameter().getRouterPrefix()) {
+  if (originRouter == m_nlsr.getConfParameter().getRouterPrefix() && lsaPosition >= 0) {
+    uint64_t seqNo = interestName[-1].toNumber();
+    NLSR_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
 
-    if (lsaPosition >= 0) {
+    std::string lsaType = interestName[-2].toUri();
+    Lsa::Type interestedLsType;
+    std::istringstream(lsaType) >> interestedLsType;
 
-      uint64_t seqNo = interestName[-1].toNumber();
-      NLSR_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
-
-      Lsa::Type interestedLsType;
-      std::istringstream(interestName[-2].toUri()) >> interestedLsType;
-
-      if (interestedLsType == Lsa::Type::NAME) {
-        processInterestForNameLsa(interest, originRouter.append(std::to_string(interestedLsType)),
-                                  seqNo);
-      }
-      else if (interestedLsType == Lsa::Type::ADJACENCY) {
-        processInterestForAdjacencyLsa(interest, originRouter.append(std::to_string(interestedLsType)),
-                                       seqNo);
-      }
-      else if (interestedLsType == Lsa::Type::COORDINATE) {
-        processInterestForCoordinateLsa(interest, originRouter.append(std::to_string(interestedLsType)),
-                                        seqNo);
-      }
-      else {
-        NLSR_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
-      }
-      lsaIncrementSignal(Statistics::PacketType::SENT_LSA_DATA);
+    if (interestedLsType == Lsa::Type::NAME) {
+      processInterestForNameLsa(interest, originRouter.append(lsaType), seqNo);
     }
+    else if (interestedLsType == Lsa::Type::ADJACENCY) {
+      processInterestForAdjacencyLsa(interest, originRouter.append(lsaType), seqNo);
+    }
+    else if (interestedLsType == Lsa::Type::COORDINATE) {
+      processInterestForCoordinateLsa(interest, originRouter.append(lsaType), seqNo);
+    }
+    else {
+      NLSR_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
+    }
+    lsaIncrementSignal(Statistics::PacketType::SENT_LSA_DATA);
   }
   else { // else the interest is for other router's lsa, serve from LsaSegmentStorage
     const ndn::Data* lsaSegment = m_lsaStorage.getLsaSegment(interest);
@@ -1100,27 +1080,11 @@
       m_nlsr.getNlsrFace().put(*lsaSegment);
     }
     else {
-      NLSR_LOG_TRACE(interest << "  was not found in this lsa storage.");
+      NLSR_LOG_TRACE(interest << " was not found in this lsa storage.");
     }
   }
 }
 
-  // \brief Sends LSA data.
-  // \param interest The Interest that warranted the data.
-  // \param content The data that the Interest was seeking.
-void
-Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
-{
-  LsaContentPublisher publisher(m_nlsr.getNlsrFace(),
-                                m_nlsr.getKeyChain(),
-                                m_nlsr.getSigningInfo(),
-                                m_lsaRefreshTime,
-                                content);
-  NLSR_LOG_DEBUG("Sending requested data ( " << content << ")  for interest (" << interest
-             << ") to be published and added to face.");
-  publisher.publish(interest.getName());
-}
-
   // \brief Finds and sends a requested name LSA.
   // \param interest The interest that seeks the name LSA.
   // \param lsaKey The LSA that the Interest is seeking.
@@ -1134,17 +1098,15 @@
   // increment RCV_NAME_LSA_INTEREST
   lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_INTEREST);
   NLSR_LOG_DEBUG("nameLsa interest " << interest << " received");
-  NameLsa*  nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
+  NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
   if (nameLsa != nullptr) {
     NLSR_LOG_TRACE("Verifying SeqNo for NameLsa is same as requested.");
     if (nameLsa->getLsSeqNo() == seqNo) {
-      // if requested lsa belongs to this router then sign it and serve it
       std::string content = nameLsa->serialize();
-      putLsaData(interest,content);
-      // else the requested belongs to neighboring routers, so serve the
-      // original data packet corresponding to the lsa
+      m_segmentPublisher.publish(interest.getName(), interest.getName(),
+                                 ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
+                                 m_lsaRefreshTime, m_nlsr.getSigningInfo());
 
-      // increment SENT_NAME_LSA_DATA
       lsaIncrementSignal(Statistics::PacketType::SENT_NAME_LSA_DATA);
     }
     else {
@@ -1170,7 +1132,6 @@
     NLSR_LOG_ERROR("Received interest for an adjacency LSA when hyperbolic routing is enabled");
   }
 
-  // increment RCV_ADJ_LSA_INTEREST
   lsaIncrementSignal(Statistics::PacketType::RCV_ADJ_LSA_INTEREST);
   NLSR_LOG_DEBUG("AdjLsa interest " << interest << " received");
   AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
@@ -1178,8 +1139,10 @@
     NLSR_LOG_TRACE("Verifying SeqNo for AdjLsa is same as requested.");
     if (adjLsa->getLsSeqNo() == seqNo) {
       std::string content = adjLsa->serialize();
-      putLsaData(interest,content);
-      // increment SENT_ADJ_LSA_DATA
+      m_segmentPublisher.publish(interest.getName(), interest.getName(),
+                                 ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
+                                 m_lsaRefreshTime, m_nlsr.getSigningInfo());
+
       lsaIncrementSignal(Statistics::PacketType::SENT_ADJ_LSA_DATA);
     }
     else {
@@ -1205,7 +1168,6 @@
     NLSR_LOG_ERROR("Received Interest for a coordinate LSA when link-state routing is enabled");
   }
 
-  // increment RCV_COORD_LSA_INTEREST
   lsaIncrementSignal(Statistics::PacketType::RCV_COORD_LSA_INTEREST);
   NLSR_LOG_DEBUG("CoordinateLsa interest " << interest << " received");
   CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
@@ -1213,8 +1175,10 @@
     NLSR_LOG_TRACE("Verifying SeqNo for CoordinateLsa is same as requested.");
     if (corLsa->getLsSeqNo() == seqNo) {
       std::string content = corLsa->serialize();
-      putLsaData(interest,content);
-      // increment SENT_COORD_LSA_DATA
+      m_segmentPublisher.publish(interest.getName(), interest.getName(),
+                                 ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
+                                 m_lsaRefreshTime, m_nlsr.getSigningInfo());
+
       lsaIncrementSignal(Statistics::PacketType::SENT_COORD_LSA_DATA);
     }
     else {
@@ -1264,7 +1228,6 @@
       NLSR_LOG_WARN("Received unrecognized LSA Type: " << interestedLsType);
     }
 
-    // increment RCV_LSA_DATA
     lsaIncrementSignal(Statistics::PacketType::RCV_LSA_DATA);
   }
 }
@@ -1273,7 +1236,6 @@
 Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
                             uint64_t lsSeqNo, std::string& dataContent)
 {
-  // increment RCV_NAME_LSA_DATA
   lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_DATA);
   if (isNameLsaNew(lsaKey, lsSeqNo)) {
     NameLsa nameLsa;
@@ -1290,7 +1252,6 @@
 Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
                                  uint64_t lsSeqNo, std::string& dataContent)
 {
-  // increment RCV_ADJ_LSA_DATA
   lsaIncrementSignal(Statistics::PacketType::RCV_ADJ_LSA_DATA);
   if (isAdjLsaNew(lsaKey, lsSeqNo)) {
     AdjLsa adjLsa;
@@ -1307,7 +1268,6 @@
 Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
                                   uint64_t lsSeqNo, std::string& dataContent)
 {
-  // increment RCV_COORD_LSA_DATA
   lsaIncrementSignal(Statistics::PacketType::RCV_COORD_LSA_DATA);
   if (isCoordinateLsaNew(lsaKey, lsSeqNo)) {
     CoordinateLsa corLsa;
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 2ebb952..183f3dc 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -35,6 +35,8 @@
 #include <ndn-cxx/util/time.hpp>
 #include <ndn-cxx/util/segment-fetcher.hpp>
 
+#include <PSync/segment-publisher.hpp>
+
 #include <utility>
 #include <boost/cstdint.hpp>
 
@@ -219,6 +221,12 @@
   expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
                   ndn::time::steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
 
+  /* \brief Process interest which can be either:
+   * 1) Discovery interest from segment fetcher:
+   *    /localhop/<network>/nlsr/LSA/<site>/<router>/<lsaType>/<seqNo>
+   * 2) Interest containing segment number:
+   *    /localhop/<network>/nlsr/LSA/<site>/<router>/<lsaType>/<seqNo>/<version>/<segmentNo>
+  */
   void
   processInterest(const ndn::Name& name, const ndn::Interest& interest);
 
@@ -311,9 +319,6 @@
 private:
 
   void
-  putLsaData(const ndn::Interest& interest, const std::string& content);
-
-  void
   processInterestForNameLsa(const ndn::Interest& interest,
                             const ndn::Name& lsaKey,
                             uint64_t seqNo);
@@ -417,6 +422,7 @@
   ndn::util::signal::ScopedConnection m_onNewLsaConnection;
 
   std::set<std::shared_ptr<ndn::util::SegmentFetcher>> m_fetchers;
+  psync::SegmentPublisher m_segmentPublisher;
 };
 
 } // namespace nlsr
diff --git a/src/publisher/segment-publisher.hpp b/src/publisher/segment-publisher.hpp
deleted file mode 100644
index d80c90e..0000000
--- a/src/publisher/segment-publisher.hpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018,  Regents of the University of California,
- *                           Arizona Board of Regents,
- *                           Colorado State University,
- *                           University Pierre & Marie Curie, Sorbonne University,
- *                           Washington University in St. Louis,
- *                           Beijing Institute of Technology,
- *                           The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
-#define NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
-
-#include <ndn-cxx/encoding/encoding-buffer.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-
-namespace nlsr {
-
-/*! \brief provides a publisher of Status Dataset or other segmented octet stream
-    \sa https://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- */
-template <class FaceBase>
-class SegmentPublisher : boost::noncopyable
-{
-public:
-  SegmentPublisher(FaceBase& face,
-                   ndn::KeyChain& keyChain,
-                   const ndn::security::SigningInfo& signingInfo,
-                   const ndn::time::milliseconds& freshnessPeriod = getDefaultFreshness())
-    : m_face(face)
-    , m_keyChain(keyChain)
-    , m_signingInfo(signingInfo)
-    , m_freshnessPeriod(freshnessPeriod)
-  {
-  }
-
-  virtual
-  ~SegmentPublisher()
-  {
-  }
-
-  /*! \brief Define the max segment size as half the max NDN packet size.
-   */
-  static size_t
-  getMaxSegmentSize()
-  {
-    static const size_t MAX_SEGMENT_SIZE = ndn::MAX_NDN_PACKET_SIZE >> 1;
-    return MAX_SEGMENT_SIZE;
-  }
-
-  static constexpr ndn::time::milliseconds
-  getDefaultFreshness()
-  {
-    return ndn::time::milliseconds(1000);
-  }
-
-  /*! \brief Publish data under the provided prefix
-   *
-   * Processes whatever is provided from SegmentPublisher::generate,
-   * by breaking it into segments of MAX_SEGMENT_SIZE and sending each
-   * one individually. The last segment is distinguished by having the
-   * final block ID set to a timestamp.
-   */
-  void
-  publish(const ndn::Name& prefix)
-  {
-    ndn::EncodingBuffer buffer;
-    generate(buffer);
-
-    const uint8_t* rawBuffer = buffer.buf();
-    const uint8_t* segmentBegin = rawBuffer;
-    const uint8_t* end = rawBuffer + buffer.size();
-
-    ndn::Name segmentPrefix(prefix);
-    segmentPrefix.appendVersion();
-
-    uint64_t segmentNo = 0;
-    do {
-      const uint8_t* segmentEnd = segmentBegin + getMaxSegmentSize();
-      if (segmentEnd > end) {
-        segmentEnd = end;
-      }
-
-      ndn::Name segmentName(segmentPrefix);
-      segmentName.appendSegment(segmentNo);
-
-      std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(segmentName);
-      data->setContent(segmentBegin, segmentEnd - segmentBegin);
-      data->setFreshnessPeriod(m_freshnessPeriod);
-
-      segmentBegin = segmentEnd;
-      if (segmentBegin >= end) {
-        data->setFinalBlock(segmentName[-1]);
-      }
-
-      publishSegment(data);
-      ++segmentNo;
-    } while (segmentBegin < end);
-  }
-
-protected:
-  /*! \brief In a derived class, write the octets into outBuffer.
-   */
-  virtual size_t
-  generate(ndn::EncodingBuffer& outBuffer) = 0;
-
-private:
-  /*! \brief Helper function to sign and put data on a Face.
-   */
-  void
-  publishSegment(std::shared_ptr<ndn::Data>& data)
-  {
-    m_keyChain.sign(*data, m_signingInfo);
-    m_face.put(*data);
-  }
-
-private:
-  FaceBase& m_face;
-  ndn::KeyChain& m_keyChain;
-  const ndn::security::SigningInfo& m_signingInfo;
-  const ndn::time::milliseconds m_freshnessPeriod;
-};
-
-} // namespace nlsr
-
-#endif // NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
