diff --git a/daemon/face/datagram-face.hpp b/daemon/face/datagram-face.hpp
index 886a8b3..adbf9e6 100644
--- a/daemon/face/datagram-face.hpp
+++ b/daemon/face/datagram-face.hpp
@@ -215,8 +215,9 @@
   NFD_LOG_FACE_TRACE("Received: " << nBytesReceived << " bytes");
   this->getMutableCounters().getNInBytes() += nBytesReceived;
 
+  bool isOk = false;
   Block element;
-  bool isOk = Block::fromBuffer(buffer, nBytesReceived, element);
+  std::tie(isOk, element) = Block::fromBuffer(buffer, nBytesReceived);
   if (!isOk)
     {
       NFD_LOG_FACE_WARN("Failed to parse incoming packet");
diff --git a/daemon/face/ethernet-face.cpp b/daemon/face/ethernet-face.cpp
index 8bd2c7b..d2cd9a1 100644
--- a/daemon/face/ethernet-face.cpp
+++ b/daemon/face/ethernet-face.cpp
@@ -381,8 +381,9 @@
   length -= ethernet::HDR_LEN;
 
   /// \todo Reserve space in front and at the back of the underlying buffer
+  bool isOk = false;
   Block fragment;
-  bool isOk = Block::fromBuffer(packet, length, fragment);
+  std::tie(isOk, fragment) = Block::fromBuffer(packet, length);
   if (!isOk)
     {
       NFD_LOG_FACE_WARN("Block received from " << sourceAddress.toString()
diff --git a/daemon/face/stream-face.hpp b/daemon/face/stream-face.hpp
index fb51afd..fa743de 100644
--- a/daemon/face/stream-face.hpp
+++ b/daemon/face/stream-face.hpp
@@ -268,22 +268,21 @@
 
   bool isOk = true;
   Block element;
-  while (m_inputBufferSize - offset > 0)
-    {
-      isOk = Block::fromBuffer(m_inputBuffer + offset, m_inputBufferSize - offset, element);
-      if (!isOk)
-        break;
+  while (m_inputBufferSize - offset > 0) {
+    std::tie(isOk, element) = Block::fromBuffer(m_inputBuffer + offset, m_inputBufferSize - offset);
+    if (!isOk)
+      break;
 
-      offset += element.size();
+    offset += element.size();
 
-      BOOST_ASSERT(offset <= m_inputBufferSize);
+    BOOST_ASSERT(offset <= m_inputBufferSize);
 
-      if (!this->decodeAndDispatchInput(element))
-        {
-          NFD_LOG_FACE_WARN("Received unrecognized TLV block of type " << element.type());
-          // ignore unknown packet and proceed
-        }
+    if (!this->decodeAndDispatchInput(element)) {
+      NFD_LOG_FACE_WARN("Received unrecognized TLV block of type " << element.type());
+      // ignore unknown packet and proceed
     }
+  }
+
   if (!isOk && m_inputBufferSize == ndn::MAX_NDN_PACKET_SIZE && offset == 0)
     {
       NFD_LOG_FACE_WARN("Failed to parse incoming packet or packet too large to process");
diff --git a/daemon/face/websocket-face.cpp b/daemon/face/websocket-face.cpp
index 27a8f57..007e800 100644
--- a/daemon/face/websocket-face.cpp
+++ b/daemon/face/websocket-face.cpp
@@ -115,9 +115,10 @@
   this->getMutableCounters().getNInBytes() += msg.size();
 
   // Try to parse message data
+  bool isOk = false;
   Block element;
-  bool isOk = Block::fromBuffer(reinterpret_cast<const uint8_t*>(msg.c_str()),
-                                msg.size(), element);
+  std::tie(isOk, element) = Block::fromBuffer(reinterpret_cast<const uint8_t*>(msg.c_str()),
+                                              msg.size());
   if (!isOk)
     {
       NFD_LOG_FACE_WARN("Received block is invalid or too large to process");
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index fa2c318..2b79a53 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -853,20 +853,20 @@
   size_t offset = 0;
   FaceIdSet activeFaces;
 
-  while (offset < buf->size())
-    {
-      if (!Block::fromBuffer(buf, offset, block))
-        {
-          std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
-          break;
-        }
-
-      offset += block.size();
-
-      ndn::nfd::FaceStatus status(block);
-      activeFaces.insert(status.getFaceId());
+  while (offset < buf->size()) {
+    bool isOk = false;
+    std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+    if (!isOk) {
+      std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
+      break;
     }
 
+    offset += block.size();
+
+    ndn::nfd::FaceStatus status(block);
+    activeFaces.insert(status.getFaceId());
+  }
+
   // Look for face IDs that were registered but not active to find missed
   // face destroyed events
   for (FaceIdSet::iterator it = m_registeredFaces.begin(); it != m_registeredFaces.end(); ++it)
diff --git a/tests/daemon/face/websocket.t.cpp b/tests/daemon/face/websocket.t.cpp
index 75d552e..8e30517 100644
--- a/tests/daemon/face/websocket.t.cpp
+++ b/tests/daemon/face/websocket.t.cpp
@@ -144,11 +144,11 @@
   client1_onMessage(websocketpp::connection_hdl hdl,
                     websocketpp::config::asio_client::message_type::ptr msg)
   {
-    bool isOk = true;
+    bool isOk = false;
     Block element;
     const std::string& payload = msg->get_payload();
-    isOk = Block::fromBuffer(reinterpret_cast<const uint8_t*>(payload.c_str()),
-                             payload.size(), element);
+    std::tie(isOk, element) = Block::fromBuffer(reinterpret_cast<const uint8_t*>(payload.c_str()),
+                                                payload.size());
     if (isOk)
       {
         try {
diff --git a/tools/ndn-autoconfig/multicast-discovery.cpp b/tools/ndn-autoconfig/multicast-discovery.cpp
index 59db21f..ae3e72d 100644
--- a/tools/ndn-autoconfig/multicast-discovery.cpp
+++ b/tools/ndn-autoconfig/multicast-discovery.cpp
@@ -63,13 +63,13 @@
 
   size_t offset = 0;
   while (offset < buffer->size()) {
+    bool isOk = false;
     Block block;
-    bool ok = Block::fromBuffer(buffer, offset, block);
-    if (!ok)
-      {
-        std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
-        break;
-      }
+    std::tie(isOk, block) = Block::fromBuffer(buffer, offset);
+    if (!isOk) {
+      std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
+      break;
+    }
 
     offset += block.size();
 
diff --git a/tools/nfd-autoreg.cpp b/tools/nfd-autoreg.cpp
index c6de1f5..6cc3288 100644
--- a/tools/nfd-autoreg.cpp
+++ b/tools/nfd-autoreg.cpp
@@ -284,22 +284,21 @@
     std::vector<uint64_t> multicastFaces;
 
     size_t offset = 0;
-    while (offset < buf->size())
-      {
-        Block block;
-        bool ok = Block::fromBuffer(buf, offset, block);
-        if (!ok)
-          {
-            std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
-            break;
-          }
-
-        offset += block.size();
-
-        nfd::FaceStatus faceStatus(block);
-        registerPrefixesIfNeeded(faceStatus.getFaceId(), FaceUri(faceStatus.getRemoteUri()),
-                                 faceStatus.getFacePersistency());
+    while (offset < buf->size()) {
+      bool isOk = false;
+      Block block;
+      std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+      if (!isOk) {
+        std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
+        break;
       }
+
+      offset += block.size();
+
+      nfd::FaceStatus faceStatus(block);
+      registerPrefixesIfNeeded(faceStatus.getFaceId(), FaceUri(faceStatus.getRemoteUri()),
+                               faceStatus.getFacePersistency());
+    }
   }
 
   int
diff --git a/tools/nfd-status.cpp b/tools/nfd-status.cpp
index 42a35be..9824d64 100644
--- a/tools/nfd-status.cpp
+++ b/tools/nfd-status.cpp
@@ -1,12 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014,  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
+ * Copyright (c) 2014-2015,  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.
@@ -287,55 +287,51 @@
   afterFetchedChannelStatusInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<channels>";
+    if (m_isOutputXml) {
+      std::cout << "<channels>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::ChannelStatus channelStatus(block);
+        nfd::ChannelStatus channelStatus(block);
 
-            std::cout << "<channel>";
-
-            std::string localUri(channelStatus.getLocalUri());
-            escapeSpecialCharacters(&localUri);
-            std::cout << "<localUri>" << localUri << "</localUri>";
-            std::cout << "</channel>";
-          }
-        std::cout << "</channels>";
+        std::cout << "<channel>";
+        std::string localUri(channelStatus.getLocalUri());
+        escapeSpecialCharacters(&localUri);
+        std::cout << "<localUri>" << localUri << "</localUri>";
+        std::cout << "</channel>";
       }
-    else
-      {
-        std::cout << "Channels:" << std::endl;
 
+      std::cout << "</channels>";
+    }
+    else {
+      std::cout << "Channels:" << std::endl;
+
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode ChannelStatus TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::ChannelStatus channelStatus(block);
-            std::cout << "  " << channelStatus.getLocalUri() << std::endl;
-          }
-       }
+        nfd::ChannelStatus channelStatus(block);
+        std::cout << "  " << channelStatus.getLocalUri() << std::endl;
+      }
+    }
 
     runNextStep();
   }
@@ -362,117 +358,113 @@
   afterFetchedFaceStatusInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<faces>";
+    if (m_isOutputXml) {
+      std::cout << "<faces>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::FaceStatus faceStatus(block);
+        nfd::FaceStatus faceStatus(block);
 
-            std::cout << "<face>";
-            std::cout << "<faceId>" << faceStatus.getFaceId() << "</faceId>";
+        std::cout << "<face>";
+        std::cout << "<faceId>" << faceStatus.getFaceId() << "</faceId>";
 
-            std::string remoteUri(faceStatus.getRemoteUri());
-            escapeSpecialCharacters(&remoteUri);
-            std::cout << "<remoteUri>" << remoteUri << "</remoteUri>";
+        std::string remoteUri(faceStatus.getRemoteUri());
+        escapeSpecialCharacters(&remoteUri);
+        std::cout << "<remoteUri>" << remoteUri << "</remoteUri>";
 
-            std::string localUri(faceStatus.getLocalUri());
-            escapeSpecialCharacters(&localUri);
-            std::cout << "<localUri>" << localUri << "</localUri>";
+        std::string localUri(faceStatus.getLocalUri());
+        escapeSpecialCharacters(&localUri);
+        std::cout << "<localUri>" << localUri << "</localUri>";
 
-            if (faceStatus.hasExpirationPeriod()) {
-              std::cout << "<expirationPeriod>PT"
-                        << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
-                             .count() << "S"
-                        << "</expirationPeriod>";
-            }
+        if (faceStatus.hasExpirationPeriod()) {
+          std::cout << "<expirationPeriod>PT"
+                    << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
+                       .count() << "S"
+                    << "</expirationPeriod>";
+        }
 
-            std::cout << "<faceScope>" << faceStatus.getFaceScope()
-                      << "</faceScope>";
-            std::cout << "<facePersistency>" << faceStatus.getFacePersistency()
-                      << "</facePersistency>";
-            std::cout << "<linkType>" << faceStatus.getLinkType()
-                      << "</linkType>";
+        std::cout << "<faceScope>" << faceStatus.getFaceScope()
+                  << "</faceScope>";
+        std::cout << "<facePersistency>" << faceStatus.getFacePersistency()
+                  << "</facePersistency>";
+        std::cout << "<linkType>" << faceStatus.getLinkType()
+                  << "</linkType>";
 
-            std::cout << "<packetCounters>";
-            std::cout << "<incomingPackets>";
-            std::cout << "<nInterests>"       << faceStatus.getNInInterests()
-                      << "</nInterests>";
-            std::cout << "<nDatas>"           << faceStatus.getNInDatas()
-                      << "</nDatas>";
-            std::cout << "</incomingPackets>";
-            std::cout << "<outgoingPackets>";
-            std::cout << "<nInterests>"       << faceStatus.getNOutInterests()
-                      << "</nInterests>";
-            std::cout << "<nDatas>"           << faceStatus.getNOutDatas()
-                      << "</nDatas>";
-            std::cout << "</outgoingPackets>";
-            std::cout << "</packetCounters>";
+        std::cout << "<packetCounters>";
+        std::cout << "<incomingPackets>";
+        std::cout << "<nInterests>"       << faceStatus.getNInInterests()
+                  << "</nInterests>";
+        std::cout << "<nDatas>"           << faceStatus.getNInDatas()
+                  << "</nDatas>";
+        std::cout << "</incomingPackets>";
+        std::cout << "<outgoingPackets>";
+        std::cout << "<nInterests>"       << faceStatus.getNOutInterests()
+                  << "</nInterests>";
+        std::cout << "<nDatas>"           << faceStatus.getNOutDatas()
+                  << "</nDatas>";
+        std::cout << "</outgoingPackets>";
+        std::cout << "</packetCounters>";
 
-            std::cout << "<byteCounters>";
-            std::cout << "<incomingBytes>"    << faceStatus.getNInBytes()
-                      << "</incomingBytes>";
-            std::cout << "<outgoingBytes>"    << faceStatus.getNOutBytes()
-                      << "</outgoingBytes>";
-            std::cout << "</byteCounters>";
+        std::cout << "<byteCounters>";
+        std::cout << "<incomingBytes>"    << faceStatus.getNInBytes()
+                  << "</incomingBytes>";
+        std::cout << "<outgoingBytes>"    << faceStatus.getNOutBytes()
+                  << "</outgoingBytes>";
+        std::cout << "</byteCounters>";
 
-            std::cout << "</face>";
-          }
-        std::cout << "</faces>";
+        std::cout << "</face>";
       }
-    else
-      {
-        std::cout << "Faces:" << std::endl;
+      std::cout << "</faces>";
+    }
+    else {
+      std::cout << "Faces:" << std::endl;
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::FaceStatus faceStatus(block);
+        nfd::FaceStatus faceStatus(block);
 
-            std::cout << "  faceid=" << faceStatus.getFaceId()
-                      << " remote=" << faceStatus.getRemoteUri()
-                      << " local=" << faceStatus.getLocalUri();
-            if (faceStatus.hasExpirationPeriod()) {
-              std::cout  << " expires="
-                         << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
-                              .count() << "s";
-            }
-            std::cout << " counters={"
-                      << "in={" << faceStatus.getNInInterests() << "i "
-                      << faceStatus.getNInDatas() << "d "
-                      << faceStatus.getNInBytes() << "B}"
-                      << " out={" << faceStatus.getNOutInterests() << "i "
-                      << faceStatus.getNOutDatas() << "d "
-                      << faceStatus.getNOutBytes() << "B}"
-                      << "}";
-            std::cout << " " << faceStatus.getFaceScope()
-                      << " " << faceStatus.getFacePersistency()
-                      << " " << faceStatus.getLinkType();
-            std::cout << std::endl;
-          }
-       }
+        std::cout << "  faceid=" << faceStatus.getFaceId()
+                  << " remote=" << faceStatus.getRemoteUri()
+                  << " local=" << faceStatus.getLocalUri();
+        if (faceStatus.hasExpirationPeriod()) {
+          std::cout  << " expires="
+                     << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
+                        .count() << "s";
+        }
+        std::cout << " counters={"
+                  << "in={" << faceStatus.getNInInterests() << "i "
+                  << faceStatus.getNInDatas() << "d "
+                  << faceStatus.getNInBytes() << "B}"
+                  << " out={" << faceStatus.getNOutInterests() << "i "
+                  << faceStatus.getNOutDatas() << "d "
+                  << faceStatus.getNOutBytes() << "B}"
+                  << "}";
+        std::cout << " " << faceStatus.getFaceScope()
+                  << " " << faceStatus.getFacePersistency()
+                  << " " << faceStatus.getLinkType();
+        std::cout << std::endl;
+      }
+    }
 
     runNextStep();
   }
@@ -498,77 +490,69 @@
   afterFetchedFibEnumerationInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<fib>";
+    if (m_isOutputXml) {
+      std::cout << "<fib>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode FibEntry TLV";
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode FibEntry TLV";
+          break;
+        }
+        offset += block.size();
 
-            nfd::FibEntry fibEntry(block);
+        nfd::FibEntry fibEntry(block);
 
-            std::cout << "<fibEntry>";
-            std::string prefix(fibEntry.getPrefix().toUri());
-            escapeSpecialCharacters(&prefix);
-            std::cout << "<prefix>" << prefix << "</prefix>";
-            std::cout << "<nextHops>";
-            for (std::list<nfd::NextHopRecord>::const_iterator
-                   nextHop = fibEntry.getNextHopRecords().begin();
-                 nextHop != fibEntry.getNextHopRecords().end();
-                 ++nextHop)
-              {
-                std::cout << "<nextHop>" ;
-                std::cout << "<faceId>"  << nextHop->getFaceId() << "</faceId>";
-                std::cout << "<cost>"    << nextHop->getCost()   << "</cost>";
-                std::cout << "</nextHop>";
-              }
-            std::cout << "</nextHops>";
-            std::cout << "</fibEntry>";
-          }
-
-        std::cout << "</fib>";
+        std::cout << "<fibEntry>";
+        std::string prefix(fibEntry.getPrefix().toUri());
+        escapeSpecialCharacters(&prefix);
+        std::cout << "<prefix>" << prefix << "</prefix>";
+        std::cout << "<nextHops>";
+        for (const nfd::NextHopRecord& nextHop : fibEntry.getNextHopRecords()) {
+          std::cout << "<nextHop>" ;
+          std::cout << "<faceId>"  << nextHop.getFaceId() << "</faceId>";
+          std::cout << "<cost>"    << nextHop.getCost()   << "</cost>";
+          std::cout << "</nextHop>";
+        }
+        std::cout << "</nextHops>";
+        std::cout << "</fibEntry>";
       }
-    else
-      {
-        std::cout << "FIB:" << std::endl;
 
+      std::cout << "</fib>";
+    }
+    else {
+      std::cout << "FIB:" << std::endl;
+
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode FibEntry TLV" << std::endl;
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode FibEntry TLV" << std::endl;
+          break;
+        }
+        offset += block.size();
 
-            nfd::FibEntry fibEntry(block);
+        nfd::FibEntry fibEntry(block);
 
-            std::cout << "  " << fibEntry.getPrefix() << " nexthops={";
-            for (std::list<nfd::NextHopRecord>::const_iterator
-                   nextHop = fibEntry.getNextHopRecords().begin();
-                 nextHop != fibEntry.getNextHopRecords().end();
-                 ++nextHop)
-              {
-                if (nextHop != fibEntry.getNextHopRecords().begin())
-                  std::cout << ", ";
-                std::cout << "faceid=" << nextHop->getFaceId()
-                          << " (cost=" << nextHop->getCost() << ")";
-              }
-            std::cout << "}" << std::endl;
-          }
+        std::cout << "  " << fibEntry.getPrefix() << " nexthops={";
+        bool isFirst = true;
+        for (const nfd::NextHopRecord& nextHop : fibEntry.getNextHopRecords()) {
+          if (isFirst)
+            isFirst = false;
+          else
+            std::cout << ", ";
+
+          std::cout << "faceid=" << nextHop.getFaceId()
+                    << " (cost=" << nextHop.getCost() << ")";
+        }
+        std::cout << "}" << std::endl;
       }
+    }
 
     runNextStep();
   }
@@ -594,63 +578,59 @@
   afterFetchedStrategyChoiceInformationInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<strategyChoices>";
+    if (m_isOutputXml) {
+      std::cout << "<strategyChoices>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode StrategyChoice TLV";
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode StrategyChoice TLV";
+          break;
+        }
+        offset += block.size();
 
-            nfd::StrategyChoice strategyChoice(block);
+        nfd::StrategyChoice strategyChoice(block);
 
-            std::cout << "<strategyChoice>";
+        std::cout << "<strategyChoice>";
 
-            std::string name(strategyChoice.getName().toUri());
-            escapeSpecialCharacters(&name);
-            std::cout << "<namespace>" << name << "</namespace>";
-            std::cout << "<strategy>";
+        std::string name(strategyChoice.getName().toUri());
+        escapeSpecialCharacters(&name);
+        std::cout << "<namespace>" << name << "</namespace>";
+        std::cout << "<strategy>";
 
-            std::string strategy(strategyChoice.getStrategy().toUri());
-            escapeSpecialCharacters(&strategy);
+        std::string strategy(strategyChoice.getStrategy().toUri());
+        escapeSpecialCharacters(&strategy);
 
-            std::cout << "<name>" << strategy << "</name>";
-            std::cout << "</strategy>";
-            std::cout << "</strategyChoice>";
-          }
-
-        std::cout << "</strategyChoices>";
+        std::cout << "<name>" << strategy << "</name>";
+        std::cout << "</strategy>";
+        std::cout << "</strategyChoice>";
       }
-    else
-      {
-        std::cout << "Strategy choices:" << std::endl;
 
+      std::cout << "</strategyChoices>";
+    }
+    else {
+      std::cout << "Strategy choices:" << std::endl;
+
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode StrategyChoice TLV" << std::endl;
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode StrategyChoice TLV" << std::endl;
+          break;
+        }
+        offset += block.size();
 
-            nfd::StrategyChoice strategyChoice(block);
+        nfd::StrategyChoice strategyChoice(block);
 
-            std::cout << "  " << strategyChoice.getName()
-                      << " strategy=" << strategyChoice.getStrategy() << std::endl;
-          }
+        std::cout << "  " << strategyChoice.getName()
+                  << " strategy=" << strategyChoice.getStrategy() << std::endl;
       }
+    }
 
     runNextStep();
   }
@@ -674,106 +654,98 @@
   afterFetchedRibStatusInformation()
   {
     ConstBufferPtr buf = m_buffer->buf();
-    if (m_isOutputXml)
-      {
-        std::cout << "<rib>";
+    if (m_isOutputXml) {
+      std::cout << "<rib>";
 
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode RibEntry TLV";
-                break;
-              }
-            offset += block.size();
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode RibEntry TLV";
+          break;
+        }
+        offset += block.size();
 
-            nfd::RibEntry ribEntry(block);
+        nfd::RibEntry ribEntry(block);
 
-            std::cout << "<ribEntry>";
-            std::string prefix(ribEntry.getName().toUri());
-            escapeSpecialCharacters(&prefix);
-            std::cout << "<prefix>" << prefix << "</prefix>";
-            std::cout << "<routes>";
-            for (std::list<nfd::Route>::const_iterator
-                   nextRoute = ribEntry.begin();
-                 nextRoute != ribEntry.end();
-                 ++nextRoute)
-              {
-                std::cout << "<route>" ;
-                std::cout << "<faceId>"  << nextRoute->getFaceId() << "</faceId>";
-                std::cout << "<origin>"  << nextRoute->getOrigin() << "</origin>";
-                std::cout << "<cost>"    << nextRoute->getCost()   << "</cost>";
+        std::cout << "<ribEntry>";
+        std::string prefix(ribEntry.getName().toUri());
+        escapeSpecialCharacters(&prefix);
+        std::cout << "<prefix>" << prefix << "</prefix>";
+        std::cout << "<routes>";
+        for (const nfd::Route& nextRoute : ribEntry) {
+          std::cout << "<route>" ;
+          std::cout << "<faceId>"  << nextRoute.getFaceId() << "</faceId>";
+          std::cout << "<origin>"  << nextRoute.getOrigin() << "</origin>";
+          std::cout << "<cost>"    << nextRoute.getCost()   << "</cost>";
 
-                std::cout << "<flags>";
-                if (nextRoute->isChildInherit())
-                  std::cout << "<childInherit/>";
-                if (nextRoute->isRibCapture())
-                  std::cout << "<ribCapture/>";
-                std::cout << "</flags>";
+          std::cout << "<flags>";
+          if (nextRoute.isChildInherit())
+            std::cout << "<childInherit/>";
+          if (nextRoute.isRibCapture())
+            std::cout << "<ribCapture/>";
+          std::cout << "</flags>";
 
-                if (!nextRoute->hasInfiniteExpirationPeriod()) {
-                  std::cout << "<expirationPeriod>PT"
-                            << time::duration_cast<time::seconds>(nextRoute->getExpirationPeriod())
-                                 .count() << "S"
-                            << "</expirationPeriod>";
-                }
-                std::cout << "</route>";
-              }
-            std::cout << "</routes>";
-            std::cout << "</ribEntry>";
+          if (!nextRoute.hasInfiniteExpirationPeriod()) {
+            std::cout << "<expirationPeriod>PT"
+                      << time::duration_cast<time::seconds>(nextRoute.getExpirationPeriod())
+                         .count() << "S"
+                      << "</expirationPeriod>";
           }
-
-        std::cout << "</rib>";
+          std::cout << "</route>";
+        }
+        std::cout << "</routes>";
+        std::cout << "</ribEntry>";
       }
-    else
-      {
-        std::cout << "RIB:" << std::endl;
 
+      std::cout << "</rib>";
+    }
+    else {
+      std::cout << "RIB:" << std::endl;
+
+      size_t offset = 0;
+      while (offset < buf->size()) {
+        bool isOk = false;
         Block block;
-        size_t offset = 0;
-        while (offset < buf->size())
-          {
-            bool ok = Block::fromBuffer(buf, offset, block);
-            if (!ok)
-              {
-                std::cerr << "ERROR: cannot decode RibEntry TLV" << std::endl;
-                break;
-              }
+        std::tie(isOk, block) = Block::fromBuffer(buf, offset);
+        if (!isOk) {
+          std::cerr << "ERROR: cannot decode RibEntry TLV" << std::endl;
+          break;
+        }
 
-            offset += block.size();
+        offset += block.size();
 
-            nfd::RibEntry ribEntry(block);
+        nfd::RibEntry ribEntry(block);
 
-            std::cout << "  " << ribEntry.getName().toUri() << " route={";
-            for (std::list<nfd::Route>::const_iterator
-                   nextRoute = ribEntry.begin();
-                 nextRoute != ribEntry.end();
-                 ++nextRoute)
-              {
-                if (nextRoute != ribEntry.begin())
-                  std::cout << ", ";
-                std::cout << "faceid="   << nextRoute->getFaceId()
-                          << " (origin="  << nextRoute->getOrigin()
-                          << " cost="    << nextRoute->getCost();
-                if (!nextRoute->hasInfiniteExpirationPeriod()) {
-                  std::cout << " expires="
-                            << time::duration_cast<time::seconds>(nextRoute->getExpirationPeriod())
-                               .count() << "s";
-                }
+        std::cout << "  " << ribEntry.getName().toUri() << " route={";
+        bool isFirst = true;
+        for (const nfd::Route& nextRoute : ribEntry) {
+          if (isFirst)
+            isFirst = false;
+          else
+            std::cout << ", ";
 
-                if (nextRoute->isChildInherit())
-                  std::cout << " ChildInherit";
-                if (nextRoute->isRibCapture())
-                  std::cout << " RibCapture";
-
-                std::cout << ")";
-              }
-            std::cout << "}" << std::endl;
+          std::cout << "faceid="   << nextRoute.getFaceId()
+                    << " (origin="  << nextRoute.getOrigin()
+                    << " cost="    << nextRoute.getCost();
+          if (!nextRoute.hasInfiniteExpirationPeriod()) {
+            std::cout << " expires="
+                      << time::duration_cast<time::seconds>(nextRoute.getExpirationPeriod())
+                         .count() << "s";
           }
-       }
+
+          if (nextRoute.isChildInherit())
+            std::cout << " ChildInherit";
+          if (nextRoute.isRibCapture())
+            std::cout << " RibCapture";
+
+          std::cout << ")";
+        }
+        std::cout << "}" << std::endl;
+      }
+    }
 
     runNextStep();
   }
diff --git a/tools/nfdc.cpp b/tools/nfdc.cpp
index 02fe28a..207d3ee 100644
--- a/tools/nfdc.cpp
+++ b/tools/nfdc.cpp
@@ -178,10 +178,11 @@
                                     const ndn::util::FaceUri& canonicalUri)
 {
   size_t offset = 0;
+  bool isOk = false;
   ndn::Block block;
-  bool ok = ndn::Block::fromBuffer(data, offset, block);
+  std::tie(isOk, block) = ndn::Block::fromBuffer(data, offset);
 
-  if (!ok) {
+  if (!isOk) {
     if (m_allowCreate) {
       startFaceCreate(canonicalUri);
     }
