diff --git a/src/management/nfd-channel-status.cpp b/src/management/nfd-channel-status.cpp
new file mode 100644
index 0000000..771b8d3
--- /dev/null
+++ b/src/management/nfd-channel-status.cpp
@@ -0,0 +1,109 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "nfd-channel-status.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
+
+namespace ndn {
+namespace nfd {
+
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<ChannelStatus>));
+BOOST_CONCEPT_ASSERT((WireEncodable<ChannelStatus>));
+BOOST_CONCEPT_ASSERT((WireDecodable<ChannelStatus>));
+static_assert(std::is_base_of<tlv::Error, ChannelStatus::Error>::value,
+              "ChannelStatus::Error must inherit from tlv::Error");
+
+ChannelStatus::ChannelStatus()
+{
+}
+
+ChannelStatus::ChannelStatus(const Block& payload)
+{
+  this->wireDecode(payload);
+}
+
+template<bool T>
+size_t
+ChannelStatus::wireEncode(EncodingImpl<T>& encoder) const
+{
+  size_t totalLength = 0;
+
+  totalLength += prependByteArrayBlock(encoder, tlv::nfd::LocalUri,
+                 reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size());
+
+  totalLength += encoder.prependVarNumber(totalLength);
+  totalLength += encoder.prependVarNumber(tlv::nfd::ChannelStatus);
+  return totalLength;
+}
+
+template size_t
+ChannelStatus::wireEncode<true>(EncodingImpl<true>& block) const;
+
+template size_t
+ChannelStatus::wireEncode<false>(EncodingImpl<false>& block) const;
+
+const Block&
+ChannelStatus::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;
+}
+
+void
+ChannelStatus::wireDecode(const Block& block)
+{
+  if (block.type() != tlv::nfd::ChannelStatus) {
+    throw Error("expecting ChannelStatus block");
+  }
+  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::LocalUri) {
+    m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
+    ++val;
+  }
+  else {
+    throw Error("missing required LocalUri field");
+  }
+}
+
+ChannelStatus&
+ChannelStatus::setLocalUri(const std::string localUri)
+{
+  m_wire.reset();
+  m_localUri = localUri;
+  return *this;
+}
+
+} // namespace nfd
+} // namespace ndn
diff --git a/src/management/nfd-channel-status.hpp b/src/management/nfd-channel-status.hpp
index 78a2066..4bb2707 100644
--- a/src/management/nfd-channel-status.hpp
+++ b/src/management/nfd-channel-status.hpp
@@ -22,11 +22,7 @@
 #ifndef NDN_MANAGEMENT_NFD_CHANNEL_STATUS_HPP
 #define NDN_MANAGEMENT_NFD_CHANNEL_STATUS_HPP
 
-#include "../encoding/tlv-nfd.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/block-helpers.hpp"
-
-#include "../util/time.hpp"
+#include "../encoding/block.hpp"
 
 namespace ndn {
 namespace nfd {
@@ -49,15 +45,10 @@
     }
   };
 
-  ChannelStatus()
-  {
-  }
+  ChannelStatus();
 
   explicit
-  ChannelStatus(const Block& payload)
-  {
-    this->wireDecode(payload);
-  }
+  ChannelStatus(const Block& payload);
 
   template<bool T>
   size_t
@@ -77,12 +68,7 @@
   }
 
   ChannelStatus&
-  setLocalUri(const std::string localUri)
-  {
-    m_wire.reset();
-    m_localUri = localUri;
-    return *this;
-  }
+  setLocalUri(const std::string localUri);
 
 private:
   std::string m_localUri;
@@ -90,56 +76,6 @@
   mutable Block m_wire;
 };
 
-
-template<bool T>
-inline size_t
-ChannelStatus::wireEncode(EncodingImpl<T>& encoder) const
-{
-  size_t totalLength = 0;
-
-  totalLength += prependByteArrayBlock(encoder, tlv::nfd::LocalUri,
-                 reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size());
-
-  totalLength += encoder.prependVarNumber(totalLength);
-  totalLength += encoder.prependVarNumber(tlv::nfd::ChannelStatus);
-  return totalLength;
-}
-
-inline const Block&
-ChannelStatus::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
-ChannelStatus::wireDecode(const Block& block)
-{
-  if (block.type() != tlv::nfd::ChannelStatus) {
-    throw Error("expecting ChannelStatus block");
-  }
-  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::LocalUri) {
-    m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
-    ++val;
-  }
-  else {
-    throw Error("missing required LocalUri field");
-  }
-}
-
 } // namespace nfd
 } // namespace ndn
 
diff --git a/src/management/nfd-control-parameters.cpp b/src/management/nfd-control-parameters.cpp
index 257dcb6..773d65a 100644
--- a/src/management/nfd-control-parameters.cpp
+++ b/src/management/nfd-control-parameters.cpp
@@ -20,10 +20,19 @@
  */
 
 #include "nfd-control-parameters.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
 
 namespace ndn {
 namespace nfd {
 
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<ControlParameters>));
+BOOST_CONCEPT_ASSERT((WireEncodable<ControlParameters>));
+BOOST_CONCEPT_ASSERT((WireDecodable<ControlParameters>));
+static_assert(std::is_base_of<tlv::Error, ControlParameters::Error>::value,
+              "ControlParameters::Error must inherit from tlv::Error");
+
 ControlParameters::ControlParameters()
   : m_hasFields(CONTROL_PARAMETER_UBOUND)
 {
diff --git a/src/management/nfd-control-parameters.hpp b/src/management/nfd-control-parameters.hpp
index 61381cb..faa7c3a 100644
--- a/src/management/nfd-control-parameters.hpp
+++ b/src/management/nfd-control-parameters.hpp
@@ -22,9 +22,8 @@
 #ifndef NDN_MANAGEMENT_NFD_CONTROL_PARAMETERS_HPP
 #define NDN_MANAGEMENT_NFD_CONTROL_PARAMETERS_HPP
 
+#include "../encoding/nfd-constants.hpp"
 #include "../name.hpp"
-#include "../encoding/tlv-nfd.hpp"
-#include "../encoding/block-helpers.hpp"
 #include "../util/time.hpp"
 
 namespace ndn {
diff --git a/src/management/nfd-control-response.cpp b/src/management/nfd-control-response.cpp
index 568dace..6de873f 100644
--- a/src/management/nfd-control-response.cpp
+++ b/src/management/nfd-control-response.cpp
@@ -20,10 +20,19 @@
  */
 
 #include "nfd-control-response.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
 
 namespace ndn {
 namespace nfd {
 
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<ControlResponse>));
+BOOST_CONCEPT_ASSERT((WireEncodable<ControlResponse>));
+BOOST_CONCEPT_ASSERT((WireDecodable<ControlResponse>));
+static_assert(std::is_base_of<tlv::Error, ControlResponse::Error>::value,
+              "ControlResponse::Error must inherit from tlv::Error");
+
 ControlResponse::ControlResponse()
   : m_code(200)
 {
diff --git a/src/management/nfd-control-response.hpp b/src/management/nfd-control-response.hpp
index 2ad94e5..42ffd3d 100644
--- a/src/management/nfd-control-response.hpp
+++ b/src/management/nfd-control-response.hpp
@@ -23,8 +23,6 @@
 #define NDN_MANAGEMENT_CONTROL_RESPONSE_HPP
 
 #include "../encoding/block.hpp"
-#include "../encoding/block-helpers.hpp"
-#include "../encoding/tlv-nfd.hpp"
 
 namespace ndn {
 namespace nfd {
diff --git a/src/management/nfd-face-event-notification.cpp b/src/management/nfd-face-event-notification.cpp
index d459de4..18b12d1 100644
--- a/src/management/nfd-face-event-notification.cpp
+++ b/src/management/nfd-face-event-notification.cpp
@@ -20,12 +20,21 @@
  */
 
 #include "nfd-face-event-notification.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
 
 namespace ndn {
 namespace nfd {
+
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<FaceEventNotification>));
+BOOST_CONCEPT_ASSERT((WireEncodable<FaceEventNotification>));
+BOOST_CONCEPT_ASSERT((WireDecodable<FaceEventNotification>));
+static_assert(std::is_base_of<tlv::Error, FaceEventNotification::Error>::value,
+              "FaceEventNotification::Error must inherit from tlv::Error");
+
 FaceEventNotification::FaceEventNotification()
-  : FaceTraits()
-  , m_kind(static_cast<FaceEventKind>(0))
+  : m_kind(static_cast<FaceEventKind>(0))
 {
 }
 
diff --git a/src/management/nfd-face-event-notification.hpp b/src/management/nfd-face-event-notification.hpp
index 94870d9..f101f25 100644
--- a/src/management/nfd-face-event-notification.hpp
+++ b/src/management/nfd-face-event-notification.hpp
@@ -22,8 +22,8 @@
 #ifndef NDN_MANAGEMENT_NFD_FACE_EVENT_NOTIFICATION_HPP
 #define NDN_MANAGEMENT_NFD_FACE_EVENT_NOTIFICATION_HPP
 
-// This include must be kept as the first one, to ensure nfd-face-flags.hpp compiles on its own.
 #include "nfd-face-traits.hpp"
+#include "../encoding/block.hpp"
 
 namespace ndn {
 namespace nfd {
diff --git a/src/management/nfd-face-query-filter.cpp b/src/management/nfd-face-query-filter.cpp
index 39c5240..d0ca150 100644
--- a/src/management/nfd-face-query-filter.cpp
+++ b/src/management/nfd-face-query-filter.cpp
@@ -20,10 +20,19 @@
  */
 
 #include "nfd-face-query-filter.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
 
 namespace ndn {
 namespace nfd {
 
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<FaceQueryFilter>));
+BOOST_CONCEPT_ASSERT((WireEncodable<FaceQueryFilter>));
+BOOST_CONCEPT_ASSERT((WireDecodable<FaceQueryFilter>));
+static_assert(std::is_base_of<tlv::Error, FaceQueryFilter::Error>::value,
+              "FaceQueryFilter::Error must inherit from tlv::Error");
+
 FaceQueryFilter::FaceQueryFilter()
   : m_hasFaceId(false)
   , m_hasUriScheme(false)
diff --git a/src/management/nfd-face-query-filter.hpp b/src/management/nfd-face-query-filter.hpp
index 5de02fe..5833d1f 100644
--- a/src/management/nfd-face-query-filter.hpp
+++ b/src/management/nfd-face-query-filter.hpp
@@ -22,7 +22,8 @@
 #ifndef NDN_MANAGEMENT_NFD_FACE_QUERY_FILTER_HPP
 #define NDN_MANAGEMENT_NFD_FACE_QUERY_FILTER_HPP
 
-#include "nfd-face-traits.hpp"
+#include "../encoding/block.hpp"
+#include "../encoding/nfd-constants.hpp"
 
 namespace ndn {
 namespace nfd {
diff --git a/src/management/nfd-face-status.cpp b/src/management/nfd-face-status.cpp
index 17145bd..8a08825 100644
--- a/src/management/nfd-face-status.cpp
+++ b/src/management/nfd-face-status.cpp
@@ -20,13 +20,21 @@
  */
 
 #include "nfd-face-status.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
 
 namespace ndn {
 namespace nfd {
 
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<FaceStatus>));
+BOOST_CONCEPT_ASSERT((WireEncodable<FaceStatus>));
+BOOST_CONCEPT_ASSERT((WireDecodable<FaceStatus>));
+static_assert(std::is_base_of<tlv::Error, FaceStatus::Error>::value,
+              "FaceStatus::Error must inherit from tlv::Error");
+
 FaceStatus::FaceStatus()
-  : FaceTraits()
-  , m_hasExpirationPeriod(false)
+  : m_hasExpirationPeriod(false)
   , m_nInInterests(0)
   , m_nInDatas(0)
   , m_nOutInterests(0)
diff --git a/src/management/nfd-face-status.hpp b/src/management/nfd-face-status.hpp
index 237b3f1..5b70ce2 100644
--- a/src/management/nfd-face-status.hpp
+++ b/src/management/nfd-face-status.hpp
@@ -22,9 +22,8 @@
 #ifndef NDN_MANAGEMENT_NFD_FACE_STATUS_HPP
 #define NDN_MANAGEMENT_NFD_FACE_STATUS_HPP
 
-// This include must be kept as the first one, to ensure nfd-face-flags.hpp compiles on its own.
-#include "nfd-face-traits.hpp"
-
+#include "nfd-face-traits.hpp" // include this first, to ensure it compiles on its own.
+#include "../encoding/block.hpp"
 #include "../util/time.hpp"
 
 namespace ndn {
diff --git a/src/management/nfd-face-traits.cpp b/src/management/nfd-face-traits.cpp
deleted file mode 100644
index 5556046..0000000
--- a/src/management/nfd-face-traits.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2014 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library 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 Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#include "nfd-face-traits.hpp"
-
-namespace ndn {
-namespace nfd {
-
-std::ostream&
-operator<<(std::ostream& os, FaceScope faceScope)
-{
-  switch (faceScope) {
-  case FACE_SCOPE_NON_LOCAL:
-    os << "non-local";
-    break;
-  case FACE_SCOPE_LOCAL:
-    os << "local";
-    break;
-  default:
-    os << "unknown";
-    break;
-  }
-  return os;
-}
-
-std::ostream&
-operator<<(std::ostream& os, FacePersistency facePersistency)
-{
-  switch (facePersistency) {
-  case FACE_PERSISTENCY_PERSISTENT:
-    os << "persistent";
-    break;
-  case FACE_PERSISTENCY_ON_DEMAND:
-    os << "on-demand";
-    break;
-  case FACE_PERSISTENCY_PERMANENT:
-    os << "permanent";
-    break;
-  default:
-    os << "unknown";
-    break;
-  }
-  return os;
-}
-
-std::ostream&
-operator<<(std::ostream& os, LinkType linkType)
-{
-  switch (linkType) {
-  case LINK_TYPE_POINT_TO_POINT:
-    os << "point-to-point";
-    break;
-  case LINK_TYPE_MULTI_ACCESS:
-    os << "multi-access";
-    break;
-  default:
-    os << "unknown";
-    break;
-  }
-  return os;
-}
-
-} // namespace nfd
-} // namespace ndn
diff --git a/src/management/nfd-face-traits.hpp b/src/management/nfd-face-traits.hpp
index 0160af1..f473d8a 100644
--- a/src/management/nfd-face-traits.hpp
+++ b/src/management/nfd-face-traits.hpp
@@ -23,63 +23,10 @@
 #define NDN_MANAGEMENT_NFD_FACE_TRAITS_HPP
 
 #include "../encoding/tlv-nfd.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/block-helpers.hpp"
 
 namespace ndn {
 namespace nfd {
 
-/**
- * \ingroup management
- * \brief provides additional information about a faceScope
- */
-enum FaceScope {
-  /** \brief face is non-local
-   */
-  FACE_SCOPE_NON_LOCAL = 0,
-  /** \brief face is local
-   */
-  FACE_SCOPE_LOCAL = 1
-};
-
-std::ostream&
-operator<<(std::ostream& os, FaceScope faceScope);
-
-/**
- * \ingroup management
- * \brief provides additional information about a facePersistency
- */
-enum FacePersistency {
-  /** \brief face is persistent
-   */
-  FACE_PERSISTENCY_PERSISTENT = 0,
-  /** \brief face is on-demand
-   */
-  FACE_PERSISTENCY_ON_DEMAND = 1,
-  /** \brief face is permanent
-   */
-  FACE_PERSISTENCY_PERMANENT = 2
-};
-
-std::ostream&
-operator<<(std::ostream& os, FacePersistency facePersistency);
-
-/**
- * \ingroup management
- * \brief provides additional information about a linkType
- */
-enum LinkType {
-  /** \brief link is point-to-point
-   */
-  LINK_TYPE_POINT_TO_POINT = 0,
-  /** \brief link is multi-access
-   */
-  LINK_TYPE_MULTI_ACCESS = 1
-};
-
-std::ostream&
-operator<<(std::ostream& os, LinkType linkType);
-
 /** \ingroup management
  *  \brief providers getters and setters of face information fields
  *  \tparam C the concrete class; it must provide .wireReset() method
diff --git a/src/management/nfd-fib-entry.cpp b/src/management/nfd-fib-entry.cpp
new file mode 100644
index 0000000..73b5f42
--- /dev/null
+++ b/src/management/nfd-fib-entry.cpp
@@ -0,0 +1,268 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "nfd-fib-entry.hpp"
+#include <sstream>
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
+
+namespace ndn {
+namespace nfd {
+
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<NextHopRecord>));
+BOOST_CONCEPT_ASSERT((WireEncodable<NextHopRecord>));
+BOOST_CONCEPT_ASSERT((WireDecodable<NextHopRecord>));
+static_assert(std::is_base_of<tlv::Error, NextHopRecord::Error>::value,
+              "NextHopRecord::Error must inherit from tlv::Error");
+
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<FibEntry>));
+BOOST_CONCEPT_ASSERT((WireEncodable<FibEntry>));
+BOOST_CONCEPT_ASSERT((WireDecodable<FibEntry>));
+static_assert(std::is_base_of<tlv::Error, FibEntry::Error>::value,
+              "FibEntry::Error must inherit from tlv::Error");
+
+// NextHopRecord := NEXT-HOP-RECORD TLV-LENGTH
+//                    FaceId
+//                    Cost
+
+NextHopRecord::NextHopRecord()
+  : m_faceId(std::numeric_limits<uint64_t>::max())
+  , m_cost(0)
+{
+}
+
+NextHopRecord::NextHopRecord(const Block& block)
+{
+  this->wireDecode(block);
+}
+
+NextHopRecord&
+NextHopRecord::setFaceId(uint64_t faceId)
+{
+  m_faceId = faceId;
+  m_wire.reset();
+  return *this;
+}
+
+NextHopRecord&
+NextHopRecord::setCost(uint64_t cost)
+{
+  m_cost = cost;
+  m_wire.reset();
+  return *this;
+}
+
+template<bool T>
+size_t
+NextHopRecord::wireEncode(EncodingImpl<T>& block) const
+{
+  size_t totalLength = 0;
+  totalLength += prependNonNegativeIntegerBlock(block,
+                                                ndn::tlv::nfd::Cost,
+                                                m_cost);
+
+  totalLength += prependNonNegativeIntegerBlock(block,
+                                                ndn::tlv::nfd::FaceId,
+                                                m_faceId);
+
+  totalLength += block.prependVarNumber(totalLength);
+  totalLength += block.prependVarNumber(ndn::tlv::nfd::NextHopRecord);
+  return totalLength;
+}
+
+template size_t
+NextHopRecord::wireEncode<true>(EncodingImpl<true>& block) const;
+
+template size_t
+NextHopRecord::wireEncode<false>(EncodingImpl<false>& block) const;
+
+const Block&
+NextHopRecord::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;
+}
+
+void
+NextHopRecord::wireDecode(const Block& wire)
+{
+  m_faceId = std::numeric_limits<uint64_t>::max();
+  m_cost = 0;
+
+  m_wire = wire;
+
+  if (m_wire.type() != tlv::nfd::NextHopRecord) {
+    std::stringstream error;
+    error << "Requested decoding of NextHopRecord, but Block is of a different type: #"
+          << m_wire.type();
+    throw Error(error.str());
+  }
+  m_wire.parse();
+
+  Block::element_const_iterator val = m_wire.elements_begin();
+  if (val == m_wire.elements_end()) {
+    throw Error("Unexpected end of NextHopRecord");
+  }
+  else if (val->type() != tlv::nfd::FaceId) {
+    std::stringstream error;
+    error << "Expected FaceId, but Block is of a different type: #"
+          << val->type();
+    throw Error(error.str());
+  }
+  m_faceId = readNonNegativeInteger(*val);
+  ++val;
+
+  if (val == m_wire.elements_end()) {
+    throw Error("Unexpected end of NextHopRecord");
+  }
+  else if (val->type() != tlv::nfd::Cost) {
+    std::stringstream error;
+    error << "Expected Cost, but Block is of a different type: #"
+          << m_wire.type();
+    throw Error(error.str());
+  }
+  m_cost = readNonNegativeInteger(*val);
+}
+
+// FibEntry      := FIB-ENTRY-TYPE TLV-LENGTH
+//                    Name
+//                    NextHopRecord*
+
+FibEntry::FibEntry()
+{
+}
+
+FibEntry::FibEntry(const Block& block)
+{
+  this->wireDecode(block);
+}
+
+FibEntry&
+FibEntry::setPrefix(const Name& prefix)
+{
+  m_prefix = prefix;
+  m_wire.reset();
+  return *this;
+}
+
+FibEntry&
+FibEntry::addNextHopRecord(const NextHopRecord& nextHopRecord)
+{
+  m_nextHopRecords.push_back(nextHopRecord);
+  m_wire.reset();
+  return *this;
+}
+
+template<bool T>
+size_t
+FibEntry::wireEncode(EncodingImpl<T>& block) const
+{
+  size_t totalLength = 0;
+
+  for (auto i = m_nextHopRecords.rbegin(); i != m_nextHopRecords.rend(); ++i) {
+    totalLength += i->wireEncode(block);
+  }
+
+  totalLength += m_prefix.wireEncode(block);
+  totalLength += block.prependVarNumber(totalLength);
+  totalLength += block.prependVarNumber(tlv::nfd::FibEntry);
+
+  return totalLength;
+}
+
+template size_t
+FibEntry::wireEncode<true>(EncodingImpl<true>& block) const;
+
+template size_t
+FibEntry::wireEncode<false>(EncodingImpl<false>& block) const;
+
+const Block&
+FibEntry::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;
+}
+
+void
+FibEntry::wireDecode(const Block& wire)
+{
+  m_prefix.clear();
+  m_nextHopRecords.clear();
+
+  m_wire = wire;
+
+  if (m_wire.type() != tlv::nfd::FibEntry) {
+    std::stringstream error;
+    error << "Requested decoding of FibEntry, but Block is of a different type: #"
+          << m_wire.type();
+    throw Error(error.str());
+  }
+
+  m_wire.parse();
+
+  Block::element_const_iterator val = m_wire.elements_begin();
+  if (val == m_wire.elements_end()) {
+    throw Error("Unexpected end of FibEntry");
+  }
+  else if (val->type() != tlv::Name) {
+    std::stringstream error;
+    error << "Expected Name, but Block is of a different type: #"
+          << val->type();
+    throw Error(error.str());
+  }
+  m_prefix.wireDecode(*val);
+  ++val;
+
+  for (; val != m_wire.elements_end(); ++val) {
+    if (val->type() != tlv::nfd::NextHopRecord) {
+      std::stringstream error;
+      error << "Expected NextHopRecords, but Block is of a different type: #"
+            << val->type();
+      throw Error(error.str());
+    }
+    m_nextHopRecords.push_back(NextHopRecord(*val));
+  }
+}
+
+} // namespace nfd
+} // namespace ndn
diff --git a/src/management/nfd-fib-entry.hpp b/src/management/nfd-fib-entry.hpp
index 015beba..0e7bb59 100644
--- a/src/management/nfd-fib-entry.hpp
+++ b/src/management/nfd-fib-entry.hpp
@@ -23,23 +23,13 @@
 #define NDN_MANAGEMENT_NFD_FIB_ENTRY_HPP
 
 #include "../encoding/block.hpp"
-#include "../encoding/block-helpers.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/tlv-nfd.hpp"
 #include "../name.hpp"
-
 #include <list>
-#include <sstream>
 
 namespace ndn {
 namespace nfd {
 
-// NextHopRecord := NEXT-HOP-RECORD TLV-LENGTH
-//                    FaceId
-//                    Cost
-
-/**
- * @ingroup management
+/** @ingroup management
  */
 class NextHopRecord
 {
@@ -47,20 +37,17 @@
   class Error : public tlv::Error
   {
   public:
-    Error(const std::string& what) : tlv::Error(what) {}
+    explicit
+    Error(const std::string& what)
+      : tlv::Error(what)
+    {
+    }
   };
 
-  NextHopRecord()
-    : m_faceId(std::numeric_limits<uint64_t>::max())
-    , m_cost(0)
-  {
-  }
+  NextHopRecord();
 
   explicit
-  NextHopRecord(const Block& block)
-  {
-    wireDecode(block);
-  }
+  NextHopRecord(const Block& block);
 
   uint64_t
   getFaceId() const
@@ -69,12 +56,7 @@
   }
 
   NextHopRecord&
-  setFaceId(uint64_t faceId)
-  {
-    m_faceId = faceId;
-    m_wire.reset();
-    return *this;
-  }
+  setFaceId(uint64_t faceId);
 
   uint64_t
   getCost() const
@@ -83,95 +65,17 @@
   }
 
   NextHopRecord&
-  setCost(uint64_t cost)
-  {
-    m_cost = cost;
-    m_wire.reset();
-    return *this;
-  }
+  setCost(uint64_t cost);
 
   template<bool T>
   size_t
-  wireEncode(EncodingImpl<T>& block) const
-  {
-    size_t totalLength = 0;
-    totalLength += prependNonNegativeIntegerBlock(block,
-                                                  ndn::tlv::nfd::Cost,
-                                                  m_cost);
-
-    totalLength += prependNonNegativeIntegerBlock(block,
-                                                  ndn::tlv::nfd::FaceId,
-                                                  m_faceId);
-
-    totalLength += block.prependVarNumber(totalLength);
-    totalLength += block.prependVarNumber(ndn::tlv::nfd::NextHopRecord);
-    return totalLength;
-  }
+  wireEncode(EncodingImpl<T>& block) const;
 
   const Block&
-  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;
-  }
+  wireEncode() const;
 
   void
-  wireDecode(const Block& wire)
-  {
-    m_faceId = std::numeric_limits<uint64_t>::max();
-    m_cost = 0;
-
-    m_wire = wire;
-
-    if (m_wire.type() != tlv::nfd::NextHopRecord)
-      {
-        std::stringstream error;
-        error << "Requested decoding of NextHopRecord, but Block is of a different type: #"
-              << m_wire.type();
-        throw Error(error.str());
-      }
-    m_wire.parse();
-
-    Block::element_const_iterator val = m_wire.elements_begin();
-    if (val == m_wire.elements_end())
-      {
-        throw Error("Unexpected end of NextHopRecord");
-      }
-    else if (val->type() != tlv::nfd::FaceId)
-      {
-        std::stringstream error;
-        error << "Expected FaceId, but Block is of a different type: #"
-              << val->type();
-        throw Error(error.str());
-      }
-    m_faceId = readNonNegativeInteger(*val);
-    ++val;
-
-    if (val == m_wire.elements_end())
-      {
-        throw Error("Unexpected end of NextHopRecord");
-      }
-    else if (val->type() != tlv::nfd::Cost)
-      {
-        std::stringstream error;
-        error << "Expected Cost, but Block is of a different type: #"
-              << m_wire.type();
-        throw Error(error.str());
-      }
-    m_cost = readNonNegativeInteger(*val);
-  }
-
+  wireDecode(const Block& wire);
 
 private:
   uint64_t m_faceId;
@@ -180,34 +84,25 @@
   mutable Block m_wire;
 };
 
-
-// FibEntry      := FIB-ENTRY-TYPE TLV-LENGTH
-//                    Name
-//                    NextHopRecord*
-
-/**
- * @ingroup management
+/** @ingroup management
  */
 class FibEntry
 {
 public:
-    class Error : public tlv::Error
-    {
-    public:
-      Error(const std::string& what) : tlv::Error(what)
-      {
-      }
-    };
-
-  FibEntry()
+  class Error : public tlv::Error
   {
-  }
+  public:
+    explicit
+    Error(const std::string& what)
+      : tlv::Error(what)
+    {
+    }
+  };
+
+  FibEntry();
 
   explicit
-  FibEntry(const Block& block)
-  {
-    wireDecode(block);
-  }
+  FibEntry(const Block& block);
 
   const Name&
   getPrefix() const
@@ -216,12 +111,7 @@
   }
 
   FibEntry&
-  setPrefix(const Name& prefix)
-  {
-    m_prefix = prefix;
-    m_wire.reset();
-    return *this;
-  }
+  setPrefix(const Name& prefix);
 
   const std::list<NextHopRecord>&
   getNextHopRecords() const
@@ -230,12 +120,7 @@
   }
 
   FibEntry&
-  addNextHopRecord(const NextHopRecord& nextHopRecord)
-  {
-    m_nextHopRecords.push_back(nextHopRecord);
-    m_wire.reset();
-    return *this;
-  }
+  addNextHopRecord(const NextHopRecord& nextHopRecord);
 
   template<typename T>
   FibEntry&
@@ -249,88 +134,13 @@
 
   template<bool T>
   size_t
-  wireEncode(EncodingImpl<T>& block) const
-  {
-    size_t totalLength = 0;
-
-    for (std::list<NextHopRecord>::const_reverse_iterator i = m_nextHopRecords.rbegin();
-         i != m_nextHopRecords.rend();
-         ++i)
-      {
-        totalLength += i->wireEncode(block);
-      }
-
-    totalLength += m_prefix.wireEncode(block);
-    totalLength += block.prependVarNumber(totalLength);
-    totalLength += block.prependVarNumber(tlv::nfd::FibEntry);
-
-    return totalLength;
-  }
+  wireEncode(EncodingImpl<T>& block) const;
 
   const Block&
-  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;
-  }
+  wireEncode() const;
 
   void
-  wireDecode(const Block& wire)
-  {
-    m_prefix.clear();
-    m_nextHopRecords.clear();
-
-    m_wire = wire;
-
-    if (m_wire.type() != tlv::nfd::FibEntry)
-      {
-        std::stringstream error;
-        error << "Requested decoding of FibEntry, but Block is of a different type: #"
-              << m_wire.type();
-        throw Error(error.str());
-      }
-
-    m_wire.parse();
-
-    Block::element_const_iterator val = m_wire.elements_begin();
-    if (val == m_wire.elements_end())
-      {
-        throw Error("Unexpected end of FibEntry");
-      }
-    else if (val->type() != tlv::Name)
-      {
-        std::stringstream error;
-        error << "Expected Name, but Block is of a different type: #"
-              << val->type();
-        throw Error(error.str());
-      }
-    m_prefix.wireDecode(*val);
-    ++val;
-
-    for (; val != m_wire.elements_end(); ++val)
-      {
-        if (val->type() != tlv::nfd::NextHopRecord)
-          {
-            std::stringstream error;
-            error << "Expected NextHopRecords, but Block is of a different type: #"
-                  << val->type();
-            throw Error(error.str());
-          }
-        m_nextHopRecords.push_back(NextHopRecord(*val));
-      }
-  }
+  wireDecode(const Block& wire);
 
 private:
   Name m_prefix;
diff --git a/src/management/nfd-forwarder-status.cpp b/src/management/nfd-forwarder-status.cpp
new file mode 100644
index 0000000..457c673
--- /dev/null
+++ b/src/management/nfd-forwarder-status.cpp
@@ -0,0 +1,319 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "nfd-forwarder-status.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
+
+namespace ndn {
+namespace nfd {
+
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<ForwarderStatus>));
+BOOST_CONCEPT_ASSERT((WireEncodable<ForwarderStatus>));
+BOOST_CONCEPT_ASSERT((WireDecodable<ForwarderStatus>));
+static_assert(std::is_base_of<tlv::Error, ForwarderStatus::Error>::value,
+              "ForwarderStatus::Error must inherit from tlv::Error");
+
+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)
+{
+}
+
+ForwarderStatus::ForwarderStatus(const Block& payload)
+{
+  this->wireDecode(payload);
+}
+
+template<bool T>
+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;
+}
+
+template size_t
+ForwarderStatus::wireEncode<true>(EncodingImpl<true>& block) const;
+
+template size_t
+ForwarderStatus::wireEncode<false>(EncodingImpl<false>& block) const;
+
+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;
+}
+
+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");
+  }
+}
+
+ForwarderStatus&
+ForwarderStatus::setNfdVersion(int nfdVersion)
+{
+  m_wire.reset();
+  m_nfdVersion = nfdVersion;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setStartTimestamp(const time::system_clock::TimePoint& startTimestamp)
+{
+  m_wire.reset();
+  m_startTimestamp = startTimestamp;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp)
+{
+  m_wire.reset();
+  m_currentTimestamp = currentTimestamp;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNNameTreeEntries(size_t nNameTreeEntries)
+{
+  m_wire.reset();
+  m_nNameTreeEntries = nNameTreeEntries;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNFibEntries(size_t nFibEntries)
+{
+  m_wire.reset();
+  m_nFibEntries = nFibEntries;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNPitEntries(size_t nPitEntries)
+{
+  m_wire.reset();
+  m_nPitEntries = nPitEntries;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNMeasurementsEntries(size_t nMeasurementsEntries)
+{
+  m_wire.reset();
+  m_nMeasurementsEntries = nMeasurementsEntries;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNCsEntries(size_t nCsEntries)
+{
+  m_wire.reset();
+  m_nCsEntries = nCsEntries;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNInInterests(uint64_t nInInterests)
+{
+  m_wire.reset();
+  m_nInInterests = nInInterests;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNInDatas(uint64_t nInDatas)
+{
+  m_wire.reset();
+  m_nInDatas = nInDatas;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNOutInterests(uint64_t nOutInterests)
+{
+  m_wire.reset();
+  m_nOutInterests = nOutInterests;
+  return *this;
+}
+
+ForwarderStatus&
+ForwarderStatus::setNOutDatas(uint64_t nOutDatas)
+{
+  m_wire.reset();
+  m_nOutDatas = nOutDatas;
+  return *this;
+}
+
+} // namespace nfd
+} // namespace ndn
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
 
diff --git a/src/management/nfd-rib-entry.cpp b/src/management/nfd-rib-entry.cpp
index f97fa66..9fc7fd9 100644
--- a/src/management/nfd-rib-entry.cpp
+++ b/src/management/nfd-rib-entry.cpp
@@ -20,12 +20,25 @@
  */
 
 #include "nfd-rib-entry.hpp"
-
-#include "management/nfd-control-command.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
 
 namespace ndn {
 namespace nfd {
 
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Route>));
+BOOST_CONCEPT_ASSERT((WireEncodable<Route>));
+BOOST_CONCEPT_ASSERT((WireDecodable<Route>));
+static_assert(std::is_base_of<tlv::Error, Route::Error>::value,
+              "Route::Error must inherit from tlv::Error");
+
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<RibEntry>));
+BOOST_CONCEPT_ASSERT((WireEncodable<RibEntry>));
+BOOST_CONCEPT_ASSERT((WireDecodable<RibEntry>));
+static_assert(std::is_base_of<tlv::Error, RibEntry::Error>::value,
+              "RibEntry::Error must inherit from tlv::Error");
+
 const time::milliseconds Route::INFINITE_EXPIRATION_PERIOD(time::milliseconds::max());
 
 Route::Route()
diff --git a/src/management/nfd-rib-entry.hpp b/src/management/nfd-rib-entry.hpp
index dcdfe50..8fa1704 100644
--- a/src/management/nfd-rib-entry.hpp
+++ b/src/management/nfd-rib-entry.hpp
@@ -22,11 +22,7 @@
 #ifndef NDN_MANAGEMENT_NFD_RIB_ENTRY_HPP
 #define NDN_MANAGEMENT_NFD_RIB_ENTRY_HPP
 
-#include "nfd-rib-flags.hpp"
-
-#include "../encoding/block.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/tlv-nfd.hpp"
+#include "nfd-rib-flags.hpp" // include this first, to ensure it compiles on its own.
 #include "../name.hpp"
 #include "../util/time.hpp"
 
@@ -89,6 +85,9 @@
     return m_origin;
   }
 
+  /** @brief set Origin
+   *  @param origin a code defined in ndn::nfd::RouteOrigin
+   */
   Route&
   setOrigin(uint64_t origin)
   {
@@ -117,6 +116,9 @@
     return m_flags;
   }
 
+  /** @brief set route inheritance flags
+   *  @param flags a bitwise OR'ed code from ndn::nfd::RouteFlags
+   */
   Route&
   setFlags(uint64_t flags)
   {
diff --git a/src/management/nfd-rib-flags.hpp b/src/management/nfd-rib-flags.hpp
index 73feaa7..07e36d1 100644
--- a/src/management/nfd-rib-flags.hpp
+++ b/src/management/nfd-rib-flags.hpp
@@ -22,22 +22,13 @@
 #ifndef NDN_MANAGEMENT_NFD_RIB_FLAGS_HPP
 #define NDN_MANAGEMENT_NFD_RIB_FLAGS_HPP
 
+#include "../encoding/nfd-constants.hpp"
+
 namespace ndn {
 namespace nfd {
 
 /**
  * \ingroup management
- * \brief provides additional information about a RIB entry
- */
-enum RibFlags {
-  RIB_CHILD_INHERIT = 1,
-  RIB_CAPTURE = 2
-  // RIB_? = 4
-  // RIB_? = 8
-};
-
-/**
- * \ingroup management
  * \brief implements getters to each RIB flag
  *
  * \tparam T class containing a RibFlags field and implements
@@ -50,13 +41,13 @@
   bool
   isChildInherit() const
   {
-    return static_cast<const T*>(this)->getFlags() & RIB_CHILD_INHERIT;
+    return static_cast<const T*>(this)->getFlags() & ROUTE_FLAG_CHILD_INHERIT;
   }
 
   bool
   isRibCapture() const
   {
-    return static_cast<const T*>(this)->getFlags() & RIB_CAPTURE;
+    return static_cast<const T*>(this)->getFlags() & ROUTE_FLAG_CAPTURE;
   }
 };
 
diff --git a/src/management/nfd-strategy-choice.cpp b/src/management/nfd-strategy-choice.cpp
new file mode 100644
index 0000000..9296954
--- /dev/null
+++ b/src/management/nfd-strategy-choice.cpp
@@ -0,0 +1,131 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "nfd-strategy-choice.hpp"
+#include "encoding/tlv-nfd.hpp"
+#include "encoding/block-helpers.hpp"
+#include "util/concepts.hpp"
+
+namespace ndn {
+namespace nfd {
+
+//BOOST_CONCEPT_ASSERT((boost::EqualityComparable<StrategyChoice>));
+BOOST_CONCEPT_ASSERT((WireEncodable<StrategyChoice>));
+BOOST_CONCEPT_ASSERT((WireDecodable<StrategyChoice>));
+static_assert(std::is_base_of<tlv::Error, StrategyChoice::Error>::value,
+              "StrategyChoice::Error must inherit from tlv::Error");
+
+StrategyChoice::StrategyChoice()
+{
+}
+
+StrategyChoice::StrategyChoice(const Block& payload)
+{
+  this->wireDecode(payload);
+}
+
+template<bool T>
+size_t
+StrategyChoice::wireEncode(EncodingImpl<T>& encoder) const
+{
+  size_t totalLength = 0;
+
+  totalLength += prependNestedBlock(encoder, tlv::nfd::Strategy, m_strategy);
+  totalLength += m_name.wireEncode(encoder);
+
+  totalLength += encoder.prependVarNumber(totalLength);
+  totalLength += encoder.prependVarNumber(tlv::nfd::StrategyChoice);
+  return totalLength;
+}
+
+template size_t
+StrategyChoice::wireEncode<true>(EncodingImpl<true>& block) const;
+
+template size_t
+StrategyChoice::wireEncode<false>(EncodingImpl<false>& block) const;
+
+const Block&
+StrategyChoice::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;
+}
+
+void
+StrategyChoice::wireDecode(const Block& block)
+{
+  if (block.type() != tlv::nfd::StrategyChoice) {
+    throw Error("expecting StrategyChoice block");
+  }
+  m_wire = block;
+  m_wire.parse();
+  Block::element_const_iterator val = m_wire.elements_begin();
+
+  if (val != m_wire.elements_end() && val->type() == tlv::Name) {
+    m_name.wireDecode(*val);
+    ++val;
+  }
+  else {
+    throw Error("missing required Name field");
+  }
+
+  if (val != m_wire.elements_end() && val->type() == tlv::nfd::Strategy) {
+    val->parse();
+    if (val->elements().empty()) {
+      throw Error("expecting Strategy/Name");
+    }
+    else {
+      m_strategy.wireDecode(*val->elements_begin());
+    }
+    ++val;
+  }
+  else {
+    throw Error("missing required Strategy field");
+  }
+}
+
+StrategyChoice&
+StrategyChoice::setName(const Name& name)
+{
+  m_wire.reset();
+  m_name = name;
+  return *this;
+}
+
+StrategyChoice&
+StrategyChoice::setStrategy(const Name& strategy)
+{
+  m_wire.reset();
+  m_strategy = strategy;
+  return *this;
+}
+
+} // namespace nfd
+} // namespace ndn
diff --git a/src/management/nfd-strategy-choice.hpp b/src/management/nfd-strategy-choice.hpp
index 2d9bbd5..6fc2f18 100644
--- a/src/management/nfd-strategy-choice.hpp
+++ b/src/management/nfd-strategy-choice.hpp
@@ -22,9 +22,7 @@
 #ifndef NDN_MANAGEMENT_NFD_STRATEGY_CHOICE_HPP
 #define NDN_MANAGEMENT_NFD_STRATEGY_CHOICE_HPP
 
-#include "../encoding/tlv-nfd.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/block-helpers.hpp"
+#include "../encoding/block.hpp"
 #include "../name.hpp"
 
 namespace ndn {
@@ -48,15 +46,10 @@
     }
   };
 
-  StrategyChoice()
-  {
-  }
+  StrategyChoice();
 
   explicit
-  StrategyChoice(const Block& payload)
-  {
-    this->wireDecode(payload);
-  }
+  StrategyChoice(const Block& payload);
 
   template<bool T>
   size_t
@@ -76,12 +69,7 @@
   }
 
   StrategyChoice&
-  setName(const Name& name)
-  {
-    m_wire.reset();
-    m_name = name;
-    return *this;
-  }
+  setName(const Name& name);
 
   const Name&
   getStrategy() const
@@ -90,12 +78,7 @@
   }
 
   StrategyChoice&
-  setStrategy(const Name& strategy)
-  {
-    m_wire.reset();
-    m_strategy = strategy;
-    return *this;
-  }
+  setStrategy(const Name& strategy);
 
 private:
   Name m_name; // namespace
@@ -104,70 +87,6 @@
   mutable Block m_wire;
 };
 
-
-template<bool T>
-inline size_t
-StrategyChoice::wireEncode(EncodingImpl<T>& encoder) const
-{
-  size_t totalLength = 0;
-
-  totalLength += prependNestedBlock(encoder, tlv::nfd::Strategy, m_strategy);
-  totalLength += m_name.wireEncode(encoder);
-
-  totalLength += encoder.prependVarNumber(totalLength);
-  totalLength += encoder.prependVarNumber(tlv::nfd::StrategyChoice);
-  return totalLength;
-}
-
-inline const Block&
-StrategyChoice::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
-StrategyChoice::wireDecode(const Block& block)
-{
-  if (block.type() != tlv::nfd::StrategyChoice) {
-    throw Error("expecting StrategyChoice block");
-  }
-  m_wire = block;
-  m_wire.parse();
-  Block::element_const_iterator val = m_wire.elements_begin();
-
-  if (val != m_wire.elements_end() && val->type() == tlv::Name) {
-    m_name.wireDecode(*val);
-    ++val;
-  }
-  else {
-    throw Error("missing required Name field");
-  }
-
-  if (val != m_wire.elements_end() && val->type() == tlv::nfd::Strategy) {
-    val->parse();
-    if (val->elements().empty()) {
-      throw Error("expecting Strategy/Name");
-    }
-    else {
-      m_strategy.wireDecode(*val->elements_begin());
-    }
-    ++val;
-  }
-  else {
-    throw Error("missing required Strategy field");
-  }
-}
-
 } // namespace nfd
 } // namespace ndn
 
