diff --git a/src/management/nfd-forwarder-status.hpp b/src/management/nfd-forwarder-status.hpp
index 9ac58c4..90ec7a5 100644
--- a/src/management/nfd-forwarder-status.hpp
+++ b/src/management/nfd-forwarder-status.hpp
@@ -22,10 +22,7 @@
 #ifndef NDN_MANAGEMENT_NFD_FORWARDER_STATUS_HPP
 #define NDN_MANAGEMENT_NFD_FORWARDER_STATUS_HPP
 
-#include "../encoding/tlv-nfd.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/block-helpers.hpp"
-
+#include "../encoding/block.hpp"
 #include "../util/time.hpp"
 
 namespace ndn {
@@ -52,10 +49,7 @@
   ForwarderStatus();
 
   explicit
-  ForwarderStatus(const Block& payload)
-  {
-    this->wireDecode(payload);
-  }
+  ForwarderStatus(const Block& payload);
 
   /** \brief prepend ForwarderStatus as a Content block to the encoder
    *
@@ -87,12 +81,7 @@
   }
 
   ForwarderStatus&
-  setNfdVersion(int nfdVersion)
-  {
-    m_wire.reset();
-    m_nfdVersion = nfdVersion;
-    return *this;
-  }
+  setNfdVersion(int nfdVersion);
 
   const time::system_clock::TimePoint&
   getStartTimestamp() const
@@ -101,12 +90,7 @@
   }
 
   ForwarderStatus&
-  setStartTimestamp(const time::system_clock::TimePoint& startTimestamp)
-  {
-    m_wire.reset();
-    m_startTimestamp = startTimestamp;
-    return *this;
-  }
+  setStartTimestamp(const time::system_clock::TimePoint& startTimestamp);
 
   const time::system_clock::TimePoint&
   getCurrentTimestamp() const
@@ -115,12 +99,7 @@
   }
 
   ForwarderStatus&
-  setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp)
-  {
-    m_wire.reset();
-    m_currentTimestamp = currentTimestamp;
-    return *this;
-  }
+  setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp);
 
   size_t
   getNNameTreeEntries() const
@@ -129,12 +108,7 @@
   }
 
   ForwarderStatus&
-  setNNameTreeEntries(size_t nNameTreeEntries)
-  {
-    m_wire.reset();
-    m_nNameTreeEntries = nNameTreeEntries;
-    return *this;
-  }
+  setNNameTreeEntries(size_t nNameTreeEntries);
 
   size_t
   getNFibEntries() const
@@ -143,12 +117,7 @@
   }
 
   ForwarderStatus&
-  setNFibEntries(size_t nFibEntries)
-  {
-    m_wire.reset();
-    m_nFibEntries = nFibEntries;
-    return *this;
-  }
+  setNFibEntries(size_t nFibEntries);
 
   size_t
   getNPitEntries() const
@@ -157,12 +126,7 @@
   }
 
   ForwarderStatus&
-  setNPitEntries(size_t nPitEntries)
-  {
-    m_wire.reset();
-    m_nPitEntries = nPitEntries;
-    return *this;
-  }
+  setNPitEntries(size_t nPitEntries);
 
   size_t
   getNMeasurementsEntries() const
@@ -171,12 +135,7 @@
   }
 
   ForwarderStatus&
-  setNMeasurementsEntries(size_t nMeasurementsEntries)
-  {
-    m_wire.reset();
-    m_nMeasurementsEntries = nMeasurementsEntries;
-    return *this;
-  }
+  setNMeasurementsEntries(size_t nMeasurementsEntries);
 
   size_t
   getNCsEntries() const
@@ -185,12 +144,7 @@
   }
 
   ForwarderStatus&
-  setNCsEntries(size_t nCsEntries)
-  {
-    m_wire.reset();
-    m_nCsEntries = nCsEntries;
-    return *this;
-  }
+  setNCsEntries(size_t nCsEntries);
 
   uint64_t
   getNInInterests() const
@@ -199,12 +153,7 @@
   }
 
   ForwarderStatus&
-  setNInInterests(uint64_t nInInterests)
-  {
-    m_wire.reset();
-    m_nInInterests = nInInterests;
-    return *this;
-  }
+  setNInInterests(uint64_t nInInterests);
 
   uint64_t
   getNInDatas() const
@@ -213,12 +162,7 @@
   }
 
   ForwarderStatus&
-  setNInDatas(uint64_t nInDatas)
-  {
-    m_wire.reset();
-    m_nInDatas = nInDatas;
-    return *this;
-  }
+  setNInDatas(uint64_t nInDatas);
 
   uint64_t
   getNOutInterests() const
@@ -227,12 +171,7 @@
   }
 
   ForwarderStatus&
-  setNOutInterests(uint64_t nOutInterests)
-  {
-    m_wire.reset();
-    m_nOutInterests = nOutInterests;
-    return *this;
-  }
+  setNOutInterests(uint64_t nOutInterests);
 
   uint64_t
   getNOutDatas() const
@@ -241,12 +180,7 @@
   }
 
   ForwarderStatus&
-  setNOutDatas(uint64_t nOutDatas)
-  {
-    m_wire.reset();
-    m_nOutDatas = nOutDatas;
-    return *this;
-  }
+  setNOutDatas(uint64_t nOutDatas);
 
 private:
   int m_nfdVersion;
@@ -265,182 +199,6 @@
   mutable Block m_wire;
 };
 
-inline
-ForwarderStatus::ForwarderStatus()
-  : m_nfdVersion(0)
-  , m_startTimestamp(time::system_clock::TimePoint::min())
-  , m_currentTimestamp(time::system_clock::TimePoint::min())
-  , m_nNameTreeEntries(0)
-  , m_nFibEntries(0)
-  , m_nPitEntries(0)
-  , m_nMeasurementsEntries(0)
-  , m_nCsEntries(0)
-  , m_nInInterests(0)
-  , m_nInDatas(0)
-  , m_nOutInterests(0)
-  , m_nOutDatas(0)
-{
-}
-
-template<bool T>
-inline size_t
-ForwarderStatus::wireEncode(EncodingImpl<T>& encoder) const
-{
-  size_t totalLength = 0;
-
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutDatas,
-                                                m_nOutDatas);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutInterests,
-                                                m_nOutInterests);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInDatas,
-                                                m_nInDatas);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInInterests,
-                                                m_nInInterests);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NCsEntries,
-                                                m_nCsEntries);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NMeasurementsEntries,
-                                                m_nMeasurementsEntries);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NPitEntries,
-                                                m_nPitEntries);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NFibEntries,
-                                                m_nFibEntries);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NNameTreeEntries,
-                                                m_nNameTreeEntries);
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::CurrentTimestamp,
-                                                time::toUnixTimestamp(m_currentTimestamp).count());
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::StartTimestamp,
-                                                time::toUnixTimestamp(m_startTimestamp).count());
-  totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NfdVersion,
-                                                m_nfdVersion);
-
-  totalLength += encoder.prependVarNumber(totalLength);
-  totalLength += encoder.prependVarNumber(tlv::Content);
-  return totalLength;
-}
-
-inline const Block&
-ForwarderStatus::wireEncode() const
-{
-  if (m_wire.hasWire())
-    return m_wire;
-
-  EncodingEstimator estimator;
-  size_t estimatedSize = wireEncode(estimator);
-
-  EncodingBuffer buffer(estimatedSize, 0);
-  wireEncode(buffer);
-
-  m_wire = buffer.block();
-  return m_wire;
-}
-
-inline void
-ForwarderStatus::wireDecode(const Block& block)
-{
-  if (block.type() != tlv::Content) {
-    throw Error("expecting Content block for Status payload");
-  }
-  m_wire = block;
-  m_wire.parse();
-  Block::element_const_iterator val = m_wire.elements_begin();
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NfdVersion) {
-    m_nfdVersion = static_cast<int>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NfdVersion field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::StartTimestamp) {
-    m_startTimestamp = time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*val)));
-    ++val;
-  }
-  else {
-    throw Error("missing required StartTimestamp field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::CurrentTimestamp) {
-    m_currentTimestamp = time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*val)));
-    ++val;
-  }
-  else {
-    throw Error("missing required CurrentTimestamp field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NNameTreeEntries) {
-    m_nNameTreeEntries = static_cast<size_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NNameTreeEntries field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NFibEntries) {
-    m_nFibEntries = static_cast<size_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NFibEntries field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NPitEntries) {
-    m_nPitEntries = static_cast<size_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NPitEntries field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NMeasurementsEntries) {
-    m_nMeasurementsEntries = static_cast<size_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NMeasurementsEntries field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NCsEntries) {
-    m_nCsEntries = static_cast<size_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NCsEntries field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) {
-    m_nInInterests = static_cast<uint64_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NInInterests field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInDatas) {
-    m_nInDatas = static_cast<uint64_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NInDatas field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutInterests) {
-    m_nOutInterests = static_cast<uint64_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NOutInterests field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutDatas) {
-    m_nOutDatas = static_cast<uint64_t>(readNonNegativeInteger(*val));
-    ++val;
-  }
-  else {
-    throw Error("missing required NOutDatas field");
-  }
-}
-
 } // namespace nfd
 } // namespace ndn
 
