diff --git a/src/transport/stream-transport-impl.hpp b/src/transport/stream-transport-impl.hpp
new file mode 100644
index 0000000..963293e
--- /dev/null
+++ b/src/transport/stream-transport-impl.hpp
@@ -0,0 +1,274 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 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.
+ */
+
+#ifndef NDN_TRANSPORT_STREAM_TRANSPORT_IMPL_HPP
+#define NDN_TRANSPORT_STREAM_TRANSPORT_IMPL_HPP
+
+#include "transport.hpp"
+
+#include <boost/asio.hpp>
+#include <list>
+
+namespace ndn {
+
+/** \brief implementation detail of a Boost.Asio-based stream-oriented transport
+ *  \tparam BaseTransport a subclass of Transport
+ *  \tparam Protocol a Boost.Asio stream-oriented protocol, including boost::asio::ip::tcp
+ *                   and boost::asio::local::stream_protocol
+ */
+template<typename BaseTransport, typename Protocol>
+class StreamTransportImpl
+{
+public:
+  typedef StreamTransportImpl<BaseTransport,Protocol> Impl;
+  typedef std::list<Block> BlockSequence;
+  typedef std::list<BlockSequence> TransmissionQueue;
+
+  StreamTransportImpl(BaseTransport& transport, boost::asio::io_service& ioService)
+    : m_transport(transport)
+    , m_socket(ioService)
+    , m_inputBufferSize(0)
+    , m_isConnecting(false)
+    , m_connectTimer(ioService)
+  {
+  }
+
+  void
+  connect(const typename Protocol::endpoint& endpoint)
+  {
+    if (!m_isConnecting) {
+      m_isConnecting = true;
+
+      // Wait at most 4 seconds to connect
+      /// @todo Decide whether this number should be configurable
+      m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
+      m_connectTimer.async_wait(bind(&Impl::connectTimeoutHandler, this, _1));
+
+      m_socket.open();
+      m_socket.async_connect(endpoint, bind(&Impl::connectHandler, this, _1));
+    }
+  }
+
+  void
+  close()
+  {
+    m_isConnecting = false;
+
+    boost::system::error_code error; // to silently ignore all errors
+    m_connectTimer.cancel(error);
+    m_socket.cancel(error);
+    m_socket.close(error);
+
+    m_transport.m_isConnected = false;
+    m_transport.m_isReceiving = false;
+    m_transmissionQueue.clear();
+  }
+
+  void
+  pause()
+  {
+    if (m_isConnecting)
+      return;
+
+    if (m_transport.m_isReceiving) {
+      m_transport.m_isReceiving = false;
+      m_socket.cancel();
+    }
+  }
+
+  void
+  resume()
+  {
+    if (m_isConnecting)
+      return;
+
+    if (!m_transport.m_isReceiving) {
+      m_transport.m_isReceiving = true;
+      m_inputBufferSize = 0;
+      m_socket.async_receive(boost::asio::buffer(m_inputBuffer, MAX_NDN_PACKET_SIZE), 0,
+                             bind(&Impl::handleAsyncReceive, this, _1, _2));
+    }
+  }
+
+  void
+  send(const Block& wire)
+  {
+    BlockSequence sequence;
+    sequence.push_back(wire);
+    send(std::move(sequence));
+  }
+
+  void
+  send(const Block& header, const Block& payload)
+  {
+    BlockSequence sequence;
+    sequence.push_back(header);
+    sequence.push_back(payload);
+    send(std::move(sequence));
+  }
+
+protected:
+  void
+  connectHandler(const boost::system::error_code& error)
+  {
+    m_isConnecting = false;
+    m_connectTimer.cancel();
+
+    if (!error) {
+      resume();
+      m_transport.m_isConnected = true;
+
+      if (!m_transmissionQueue.empty()) {
+        boost::asio::async_write(m_socket, *m_transmissionQueue.begin(),
+                                 bind(&Impl::handleAsyncWrite, this, _1,
+                                      m_transmissionQueue.begin()));
+      }
+    }
+    else {
+      m_transport.m_isConnected = false;
+      m_transport.close();
+      BOOST_THROW_EXCEPTION(Transport::Error(error, "error while connecting to the forwarder"));
+    }
+  }
+
+  void
+  connectTimeoutHandler(const boost::system::error_code& error)
+  {
+    if (error) // e.g., cancelled timer
+      return;
+
+    m_transport.close();
+    BOOST_THROW_EXCEPTION(Transport::Error(error, "error while connecting to the forwarder"));
+  }
+
+  void
+  send(BlockSequence&& sequence)
+  {
+    m_transmissionQueue.emplace_back(sequence);
+
+    if (m_transport.m_isConnected && m_transmissionQueue.size() == 1) {
+      boost::asio::async_write(m_socket, *m_transmissionQueue.begin(),
+                               bind(&Impl::handleAsyncWrite, this, _1,
+                                    m_transmissionQueue.begin()));
+    }
+
+    // if not connected or there is transmission in progress (m_transmissionQueue.size() > 1),
+    // next write will be scheduled either in connectHandler or in asyncWriteHandler
+  }
+
+  void
+  handleAsyncWrite(const boost::system::error_code& error, TransmissionQueue::iterator queueItem)
+  {
+    if (error) {
+      if (error == boost::system::errc::operation_canceled) {
+        // async receive has been explicitly cancelled (e.g., socket close)
+        return;
+      }
+
+      m_transport.close();
+      BOOST_THROW_EXCEPTION(Transport::Error(error, "error while sending data to socket"));
+    }
+
+    if (!m_transport.m_isConnected) {
+      return; // queue has been already cleared
+    }
+
+    m_transmissionQueue.erase(queueItem);
+
+    if (!m_transmissionQueue.empty()) {
+      boost::asio::async_write(m_socket, *m_transmissionQueue.begin(),
+                               bind(&Impl::handleAsyncWrite, this, _1,
+                                    m_transmissionQueue.begin()));
+    }
+  }
+
+  void
+  handleAsyncReceive(const boost::system::error_code& error, std::size_t nBytesRecvd)
+  {
+    if (error) {
+      if (error == boost::system::errc::operation_canceled) {
+        // async receive has been explicitly cancelled (e.g., socket close)
+        return;
+      }
+
+      m_transport.close();
+      BOOST_THROW_EXCEPTION(Transport::Error(error, "error while receiving data from socket"));
+    }
+
+    m_inputBufferSize += nBytesRecvd;
+    // do magic
+
+    std::size_t offset = 0;
+    bool hasProcessedSome = processAllReceived(m_inputBuffer, offset, m_inputBufferSize);
+    if (!hasProcessedSome && m_inputBufferSize == MAX_NDN_PACKET_SIZE && offset == 0) {
+      m_transport.close();
+      BOOST_THROW_EXCEPTION(Transport::Error(boost::system::error_code(),
+                                             "input buffer full, but a valid TLV cannot be "
+                                             "decoded"));
+    }
+
+    if (offset > 0) {
+      if (offset != m_inputBufferSize) {
+        std::copy(m_inputBuffer + offset, m_inputBuffer + m_inputBufferSize, m_inputBuffer);
+        m_inputBufferSize -= offset;
+      }
+      else {
+        m_inputBufferSize = 0;
+      }
+    }
+
+    m_socket.async_receive(boost::asio::buffer(m_inputBuffer + m_inputBufferSize,
+                                               MAX_NDN_PACKET_SIZE - m_inputBufferSize), 0,
+                           bind(&Impl::handleAsyncReceive, this, _1, _2));
+  }
+
+  bool
+  processAllReceived(uint8_t* buffer, size_t& offset, size_t nBytesAvailable)
+  {
+    while (offset < nBytesAvailable) {
+      bool isOk = false;
+      Block element;
+      std::tie(isOk, element) = Block::fromBuffer(buffer + offset, nBytesAvailable - offset);
+      if (!isOk)
+        return false;
+
+      m_transport.receive(element);
+      offset += element.size();
+    }
+    return true;
+  }
+
+protected:
+  BaseTransport& m_transport;
+
+  typename Protocol::socket m_socket;
+  uint8_t m_inputBuffer[MAX_NDN_PACKET_SIZE];
+  size_t m_inputBufferSize;
+
+  TransmissionQueue m_transmissionQueue;
+  bool m_isConnecting;
+
+  boost::asio::deadline_timer m_connectTimer;
+};
+
+} // namespace ndn
+
+#endif // NDN_TRANSPORT_STREAM_TRANSPORT_IMPL_HPP
diff --git a/src/transport/stream-transport-with-resolver-impl.hpp b/src/transport/stream-transport-with-resolver-impl.hpp
new file mode 100644
index 0000000..1fa3351
--- /dev/null
+++ b/src/transport/stream-transport-with-resolver-impl.hpp
@@ -0,0 +1,88 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 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.
+ */
+
+#ifndef NDN_TRANSPORT_STREAM_TRANSPORT_WITH_RESOLVER_IMPL_HPP
+#define NDN_TRANSPORT_STREAM_TRANSPORT_WITH_RESOLVER_IMPL_HPP
+
+#include "stream-transport-impl.hpp"
+
+namespace ndn {
+
+/** \brief implementation detail of a Boost.Asio-based stream-oriented transport
+ *         with resolver support
+ */
+template<typename BaseTransport, typename Protocol>
+class StreamTransportWithResolverImpl : public StreamTransportImpl<BaseTransport, Protocol>
+{
+public:
+  typedef StreamTransportWithResolverImpl<BaseTransport,Protocol> Impl;
+
+  StreamTransportWithResolverImpl(BaseTransport& transport, boost::asio::io_service& ioService)
+    : StreamTransportImpl<BaseTransport, Protocol>(transport, ioService)
+  {
+  }
+
+  void
+  connect(const typename Protocol::resolver::query& query)
+  {
+    if (this->m_isConnecting) {
+      return;
+    }
+
+    this->m_isConnecting = true;
+
+    // Wait at most 4 seconds to connect
+    /// @todo Decide whether this number should be configurable
+    this->m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
+    this->m_connectTimer.async_wait(bind(&Impl::connectTimeoutHandler, this, _1));
+
+    // typename boost::asio::ip::basic_resolver< Protocol > resolver;
+    auto resolver = make_shared<typename Protocol::resolver>(ref(this->m_socket.get_io_service()));
+    resolver->async_resolve(query, bind(&Impl::resolveHandler, this, _1, _2, resolver));
+  }
+
+protected:
+  void
+  resolveHandler(const boost::system::error_code& error,
+                 typename Protocol::resolver::iterator endpoint,
+                 const shared_ptr<typename Protocol::resolver>&)
+  {
+    if (error) {
+      if (error == boost::system::errc::operation_canceled)
+        return;
+
+      BOOST_THROW_EXCEPTION(Transport::Error(error, "Error during resolution of host or port"));
+    }
+
+    typename Protocol::resolver::iterator end;
+    if (endpoint == end) {
+      this->m_transport.close();
+      BOOST_THROW_EXCEPTION(Transport::Error(error, "Unable to resolve because host or port"));
+    }
+
+    this->m_socket.async_connect(*endpoint, bind(&Impl::connectHandler, this, _1));
+  }
+};
+
+
+} // namespace ndn
+
+#endif // NDN_TRANSPORT_STREAM_TRANSPORT_WITH_RESOLVER_IMPL_HPP
diff --git a/src/transport/stream-transport.hpp b/src/transport/stream-transport.hpp
deleted file mode 100644
index a0c7ca3..0000000
--- a/src/transport/stream-transport.hpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 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.
- */
-
-#ifndef NDN_TRANSPORT_STREAM_TRANSPORT_HPP
-#define NDN_TRANSPORT_STREAM_TRANSPORT_HPP
-
-#include "transport.hpp"
-
-#include <boost/asio.hpp>
-#include <list>
-
-namespace ndn {
-
-template<class BaseTransport, class Protocol>
-class StreamTransportImpl
-{
-public:
-  typedef StreamTransportImpl<BaseTransport,Protocol> Impl;
-
-  typedef std::list<Block> BlockSequence;
-  typedef std::list<BlockSequence> TransmissionQueue;
-
-  StreamTransportImpl(BaseTransport& transport, boost::asio::io_service& ioService)
-    : m_transport(transport)
-    , m_socket(ioService)
-    , m_inputBufferSize(0)
-    , m_connectionInProgress(false)
-    , m_connectTimer(ioService)
-  {
-  }
-
-  void
-  connectHandler(const boost::system::error_code& error)
-  {
-    m_connectionInProgress = false;
-    m_connectTimer.cancel();
-
-    if (!error)
-      {
-        resume();
-        m_transport.m_isConnected = true;
-
-        if (!m_transmissionQueue.empty()) {
-          boost::asio::async_write(m_socket, *m_transmissionQueue.begin(),
-                                   bind(&Impl::handleAsyncWrite, this, _1,
-                                        m_transmissionQueue.begin()));
-        }
-      }
-    else
-      {
-        // may need to throw exception
-        m_transport.m_isConnected = false;
-        m_transport.close();
-        BOOST_THROW_EXCEPTION(Transport::Error(error, "error while connecting to the forwarder"));
-      }
-  }
-
-  void
-  connectTimeoutHandler(const boost::system::error_code& error)
-  {
-    if (error) // e.g., cancelled timer
-      return;
-
-    m_transport.close();
-    BOOST_THROW_EXCEPTION(Transport::Error(error, "error while connecting to the forwarder"));
-  }
-
-  void
-  connect(const typename Protocol::endpoint& endpoint)
-  {
-    if (!m_connectionInProgress) {
-      m_connectionInProgress = true;
-
-      // Wait at most 4 seconds to connect
-      /// @todo Decide whether this number should be configurable
-      m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
-      m_connectTimer.async_wait(bind(&Impl::connectTimeoutHandler, this, _1));
-
-      m_socket.open();
-      m_socket.async_connect(endpoint,
-                             bind(&Impl::connectHandler, this, _1));
-    }
-  }
-
-  void
-  close()
-  {
-    m_connectionInProgress = false;
-
-    boost::system::error_code error; // to silently ignore all errors
-    m_connectTimer.cancel(error);
-    m_socket.cancel(error);
-    m_socket.close(error);
-
-    m_transport.m_isConnected = false;
-    m_transport.m_isExpectingData = false;
-    m_transmissionQueue.clear();
-  }
-
-  void
-  pause()
-  {
-    if (m_connectionInProgress)
-      return;
-
-    if (m_transport.m_isExpectingData)
-      {
-        m_transport.m_isExpectingData = false;
-        m_socket.cancel();
-      }
-  }
-
-  /**
-   * @warning Must not be called directly or indirectly from within handleAsyncReceive invocation
-   */
-  void
-  resume()
-  {
-    if (m_connectionInProgress)
-      return;
-
-    if (!m_transport.m_isExpectingData)
-      {
-        m_transport.m_isExpectingData = true;
-        m_inputBufferSize = 0;
-        m_socket.async_receive(boost::asio::buffer(m_inputBuffer, MAX_NDN_PACKET_SIZE), 0,
-                               bind(&Impl::handleAsyncReceive, this, _1, _2));
-      }
-  }
-
-  void
-  send(const Block& wire)
-  {
-    BlockSequence sequence;
-    sequence.push_back(wire);
-    m_transmissionQueue.push_back(sequence);
-
-    if (m_transport.m_isConnected && m_transmissionQueue.size() == 1) {
-      boost::asio::async_write(m_socket, *m_transmissionQueue.begin(),
-                               bind(&Impl::handleAsyncWrite, this, _1,
-                                    m_transmissionQueue.begin()));
-    }
-
-    // if not connected or there is transmission in progress (m_transmissionQueue.size() > 1),
-    // next write will be scheduled either in connectHandler or in asyncWriteHandler
-  }
-
-  void
-  send(const Block& header, const Block& payload)
-  {
-    BlockSequence sequence;
-    sequence.push_back(header);
-    sequence.push_back(payload);
-    m_transmissionQueue.push_back(sequence);
-
-    if (m_transport.m_isConnected && m_transmissionQueue.size() == 1) {
-      boost::asio::async_write(m_socket, *m_transmissionQueue.begin(),
-                               bind(&Impl::handleAsyncWrite, this, _1,
-                                    m_transmissionQueue.begin()));
-    }
-
-    // if not connected or there is transmission in progress (m_transmissionQueue.size() > 1),
-    // next write will be scheduled either in connectHandler or in asyncWriteHandler
-  }
-
-  void
-  handleAsyncWrite(const boost::system::error_code& error,
-                   TransmissionQueue::iterator queueItem)
-  {
-    if (error)
-      {
-        if (error == boost::system::errc::operation_canceled) {
-          // async receive has been explicitly cancelled (e.g., socket close)
-          return;
-        }
-
-        m_transport.close();
-        BOOST_THROW_EXCEPTION(Transport::Error(error, "error while sending data to socket"));
-      }
-
-    if (!m_transport.m_isConnected) {
-      return; // queue has been already cleared
-    }
-
-    m_transmissionQueue.erase(queueItem);
-
-    if (!m_transmissionQueue.empty()) {
-      boost::asio::async_write(m_socket, *m_transmissionQueue.begin(),
-                               bind(&Impl::handleAsyncWrite, this, _1,
-                                    m_transmissionQueue.begin()));
-    }
-  }
-
-  bool
-  processAll(uint8_t* buffer, size_t& offset, size_t nBytesAvailable)
-  {
-    while (offset < nBytesAvailable) {
-      bool isOk = false;
-      Block element;
-      std::tie(isOk, element) = Block::fromBuffer(buffer + offset, nBytesAvailable - offset);
-      if (!isOk)
-        return false;
-
-      m_transport.receive(element);
-      offset += element.size();
-    }
-    return true;
-  }
-
-  void
-  handleAsyncReceive(const boost::system::error_code& error, std::size_t nBytesRecvd)
-  {
-    if (error)
-      {
-        if (error == boost::system::errc::operation_canceled) {
-          // async receive has been explicitly cancelled (e.g., socket close)
-          return;
-        }
-
-        m_transport.close();
-        BOOST_THROW_EXCEPTION(Transport::Error(error, "error while receiving data from socket"));
-      }
-
-    m_inputBufferSize += nBytesRecvd;
-    // do magic
-
-    std::size_t offset = 0;
-    bool hasProcessedSome = processAll(m_inputBuffer, offset, m_inputBufferSize);
-    if (!hasProcessedSome && m_inputBufferSize == MAX_NDN_PACKET_SIZE && offset == 0)
-      {
-        m_transport.close();
-        BOOST_THROW_EXCEPTION(Transport::Error(boost::system::error_code(),
-                                               "input buffer full, but a valid TLV cannot be "
-                                               "decoded"));
-      }
-
-    if (offset > 0)
-      {
-        if (offset != m_inputBufferSize)
-          {
-            std::copy(m_inputBuffer + offset, m_inputBuffer + m_inputBufferSize,
-                      m_inputBuffer);
-            m_inputBufferSize -= offset;
-          }
-        else
-          {
-            m_inputBufferSize = 0;
-          }
-      }
-
-    m_socket.async_receive(boost::asio::buffer(m_inputBuffer + m_inputBufferSize,
-                                               MAX_NDN_PACKET_SIZE - m_inputBufferSize), 0,
-                           bind(&Impl::handleAsyncReceive, this, _1, _2));
-  }
-
-protected:
-  BaseTransport& m_transport;
-
-  typename Protocol::socket m_socket;
-  uint8_t m_inputBuffer[MAX_NDN_PACKET_SIZE];
-  size_t m_inputBufferSize;
-
-  TransmissionQueue m_transmissionQueue;
-  bool m_connectionInProgress;
-
-  boost::asio::deadline_timer m_connectTimer;
-};
-
-
-template<class BaseTransport, class Protocol>
-class StreamTransportWithResolverImpl : public StreamTransportImpl<BaseTransport, Protocol>
-{
-public:
-  typedef StreamTransportWithResolverImpl<BaseTransport,Protocol> Impl;
-
-  StreamTransportWithResolverImpl(BaseTransport& transport, boost::asio::io_service& ioService)
-    : StreamTransportImpl<BaseTransport, Protocol>(transport, ioService)
-  {
-  }
-
-  void
-  resolveHandler(const boost::system::error_code& error,
-                 typename Protocol::resolver::iterator endpoint,
-                 const shared_ptr<typename Protocol::resolver>&)
-  {
-    if (error)
-      {
-        if (error == boost::system::errc::operation_canceled)
-          return;
-
-        BOOST_THROW_EXCEPTION(Transport::Error(error, "Error during resolution of host or port"));
-      }
-
-    typename Protocol::resolver::iterator end;
-    if (endpoint == end)
-      {
-        this->m_transport.close();
-        BOOST_THROW_EXCEPTION(Transport::Error(error, "Unable to resolve because host or port"));
-      }
-
-    this->m_socket.async_connect(*endpoint,
-                                 bind(&Impl::connectHandler, this, _1));
-  }
-
-  void
-  connect(const typename Protocol::resolver::query& query)
-  {
-    if (!this->m_connectionInProgress) {
-      this->m_connectionInProgress = true;
-
-      // Wait at most 4 seconds to connect
-      /// @todo Decide whether this number should be configurable
-      this->m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
-      this->m_connectTimer.async_wait(bind(&Impl::connectTimeoutHandler, this, _1));
-
-      // typename boost::asio::ip::basic_resolver< Protocol > resolver;
-      shared_ptr<typename Protocol::resolver> resolver =
-        make_shared<typename Protocol::resolver>(ref(this->m_socket.get_io_service()));
-
-      resolver->async_resolve(query, bind(&Impl::resolveHandler, this, _1, _2, resolver));
-    }
-  }
-};
-
-
-} // namespace ndn
-
-#endif // NDN_TRANSPORT_STREAM_TRANSPORT_HPP
diff --git a/src/transport/tcp-transport.cpp b/src/transport/tcp-transport.cpp
index 20952ab..343ddd2 100644
--- a/src/transport/tcp-transport.cpp
+++ b/src/transport/tcp-transport.cpp
@@ -19,10 +19,8 @@
  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
  */
 
-#include "common.hpp"
-
 #include "tcp-transport.hpp"
-#include "stream-transport.hpp"
+#include "stream-transport-with-resolver-impl.hpp"
 #include "util/face-uri.hpp"
 
 namespace ndn {
@@ -33,9 +31,7 @@
 {
 }
 
-TcpTransport::~TcpTransport()
-{
-}
+TcpTransport::~TcpTransport() = default;
 
 shared_ptr<TcpTransport>
 TcpTransport::create(const std::string& uri)
@@ -81,7 +77,7 @@
 TcpTransport::connect(boost::asio::io_service& ioService,
                       const ReceiveCallback& receiveCallback)
 {
-  if (!static_cast<bool>(m_impl)) {
+  if (m_impl == nullptr) {
     Transport::connect(ioService, receiveCallback);
 
     m_impl = make_shared<Impl>(ref(*this), ref(ioService));
@@ -94,21 +90,21 @@
 void
 TcpTransport::send(const Block& wire)
 {
-  BOOST_ASSERT(static_cast<bool>(m_impl));
+  BOOST_ASSERT(m_impl != nullptr);
   m_impl->send(wire);
 }
 
 void
 TcpTransport::send(const Block& header, const Block& payload)
 {
-  BOOST_ASSERT(static_cast<bool>(m_impl));
+  BOOST_ASSERT(m_impl != nullptr);
   m_impl->send(header, payload);
 }
 
 void
 TcpTransport::close()
 {
-  BOOST_ASSERT(static_cast<bool>(m_impl));
+  BOOST_ASSERT(m_impl != nullptr);
   m_impl->close();
   m_impl.reset();
 }
@@ -116,7 +112,7 @@
 void
 TcpTransport::pause()
 {
-  if (static_cast<bool>(m_impl)) {
+  if (m_impl != nullptr) {
     m_impl->pause();
   }
 }
@@ -124,7 +120,7 @@
 void
 TcpTransport::resume()
 {
-  BOOST_ASSERT(static_cast<bool>(m_impl));
+  BOOST_ASSERT(m_impl != nullptr);
   m_impl->resume();
 }
 
diff --git a/src/transport/tcp-transport.hpp b/src/transport/tcp-transport.hpp
index b0b5124..eb7878b 100644
--- a/src/transport/tcp-transport.hpp
+++ b/src/transport/tcp-transport.hpp
@@ -22,56 +22,61 @@
 #ifndef NDN_TRANSPORT_TCP_TRANSPORT_HPP
 #define NDN_TRANSPORT_TCP_TRANSPORT_HPP
 
-#include "../common.hpp"
 #include "transport.hpp"
 #include "../util/config-file.hpp"
 
-
-// forward declaration
-namespace boost { namespace asio { namespace ip { class tcp; } } }
+namespace boost {
+namespace asio {
+namespace ip {
+class tcp;
+} // namespace ip
+} // namespace asio
+} // namespace boost
 
 namespace ndn {
 
-// forward declaration
-template<class T, class U> class StreamTransportImpl;
-template<class T, class U> class StreamTransportWithResolverImpl;
+template<typename BaseTransport, typename Protocol>
+class StreamTransportImpl;
 
+template<typename BaseTransport, typename Protocol>
+class StreamTransportWithResolverImpl;
+
+/** \brief a transport using TCP socket
+ */
 class TcpTransport : public Transport
 {
 public:
+  explicit
   TcpTransport(const std::string& host, const std::string& port = "6363");
+
   ~TcpTransport();
 
-  // from Transport
   virtual void
   connect(boost::asio::io_service& ioService,
-          const ReceiveCallback& receiveCallback);
+          const ReceiveCallback& receiveCallback) override;
 
   virtual void
-  close();
+  close() override;
 
   virtual void
-  pause();
+  pause() override;
 
   virtual void
-  resume();
+  resume() override;
 
   virtual void
-  send(const Block& wire);
+  send(const Block& wire) override;
 
   virtual void
-  send(const Block& header, const Block& payload);
+  send(const Block& header, const Block& payload) override;
 
-  /**
-   * @brief Create transport with parameters defined in URI
-   *
-   * @throws Transport::Error if incorrect URI or unsupported protocol is specified
+  /** \brief Create transport with parameters defined in URI
+   *  \throw Transport::Error incorrect URI or unsupported protocol is specified
    */
   static shared_ptr<TcpTransport>
   create(const std::string& uri);
 
 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
-
   static std::pair<std::string, std::string>
   getSocketHostAndPortFromUri(const std::string& uri);
 
@@ -82,7 +87,7 @@
   typedef StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp> Impl;
   friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
   friend class StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
-  shared_ptr< Impl > m_impl;
+  shared_ptr<Impl> m_impl;
 };
 
 } // namespace ndn
diff --git a/src/transport/transport.cpp b/src/transport/transport.cpp
new file mode 100644
index 0000000..0ea5bee
--- /dev/null
+++ b/src/transport/transport.cpp
@@ -0,0 +1,53 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 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 "transport.hpp"
+
+namespace ndn {
+
+Transport::Error::Error(const boost::system::error_code& code, const std::string& msg)
+  : std::runtime_error(msg + (code.value() ? " (" + code.category().message(code.value()) + ")" : ""))
+{
+}
+
+Transport::Error::Error(const std::string& msg)
+  : std::runtime_error(msg)
+{
+}
+
+Transport::Transport()
+  : m_ioService(nullptr)
+  , m_isConnected(false)
+  , m_isReceiving(false)
+{
+}
+
+void
+Transport::connect(boost::asio::io_service& ioService,
+                   const ReceiveCallback& receiveCallback)
+{
+  BOOST_ASSERT(receiveCallback != nullptr);
+
+  m_ioService = &ioService;
+  m_receiveCallback = receiveCallback;
+}
+
+} // namespace ndn
diff --git a/src/transport/transport.hpp b/src/transport/transport.hpp
index 1095f14..f656802 100644
--- a/src/transport/transport.hpp
+++ b/src/transport/transport.hpp
@@ -27,7 +27,6 @@
 
 #include <boost/system/error_code.hpp>
 
-// forward declaration
 namespace boost {
 namespace asio {
 class io_service;
@@ -36,123 +35,105 @@
 
 namespace ndn {
 
+/** \brief provides TLV-block delivery service
+ */
 class Transport : noncopyable
 {
 public:
   class Error : public std::runtime_error
   {
   public:
-    inline Error(const boost::system::error_code& code, const std::string& msg);
-    inline Error(const std::string& msg);
+    Error(const boost::system::error_code& code, const std::string& msg);
+
+    explicit
+    Error(const std::string& msg);
   };
 
-  typedef function<void (const Block& wire)> ReceiveCallback;
-  typedef function<void ()> ErrorCallback;
+  typedef function<void(const Block& wire)> ReceiveCallback;
+  typedef function<void()> ErrorCallback;
 
-  inline
   Transport();
 
-  inline virtual
-  ~Transport();
+  virtual
+  ~Transport() = default;
 
-  /**
-   * @brief Connect transport
-   *
-   * @throws boost::system::system_error if connection cannot be established
+  /** \brief asynchronously open the connection
+   *  \param ioService io_service to create socket on
+   *  \param receiveCallback callback function when a TLV block is received; must not be empty
+   *  \throw boost::system::system_error connection cannot be established
    */
-  inline virtual void
-  connect(boost::asio::io_service& io_service,
-          const ReceiveCallback& receiveCallback);
+  virtual void
+  connect(boost::asio::io_service& ioService, const ReceiveCallback& receiveCallback);
 
-  /**
-   * @brief Close the connection.
+  /** \brief Close the connection.
    */
   virtual void
   close() = 0;
 
-  /**
-   * @brief Send block of data from @p wire through the transport
-   *
-   * @param wire A block of data to send
+  /** \brief send a TLV block through the transport
    */
   virtual void
   send(const Block& wire) = 0;
 
-  /**
-   * @brief Alternative version of sending data, applying scatter/gather I/O concept
+  /** \brief send two memory blocks through the transport
    *
-   * Two non-consecutive memory blocks will be send out together, e.g., as part of the
-   * same message in datagram-oriented transports.
+   *  Scatter/gather API is utilized to send two non-consecutive memory blocks together
+   *  (as part of the same message in datagram-oriented transports).
    */
   virtual void
   send(const Block& header, const Block& payload) = 0;
 
+  /** \brief pause the transport
+   *  \post receiveCallback will not be invoked
+   *  \note This operation has no effect if transport has been paused,
+   *        or when connection is being established.
+   */
   virtual void
   pause() = 0;
 
+  /** \brief resume the transport
+   *  \post receiveCallback will be invoked
+   *  \note This operation has no effect if transport is not paused,
+   *        or when connection is being established.
+   */
   virtual void
   resume() = 0;
 
-  inline bool
-  isConnected();
+  /** \retval true connection has been established
+   *  \retval false connection is not yet established or has been closed
+   */
+  bool
+  isConnected() const;
 
-  inline bool
-  isExpectingData();
+  /** \retval true incoming packets are expected, receiveCallback will be invoked
+   *  \retval false incoming packets are not expected, receiveCallback will not be invoked
+   */
+  bool
+  isReceiving() const;
 
 protected:
-  inline void
+  /** \brief invoke the receive callback
+   */
+  void
   receive(const Block& wire);
 
 protected:
   boost::asio::io_service* m_ioService;
   bool m_isConnected;
-  bool m_isExpectingData;
+  bool m_isReceiving;
   ReceiveCallback m_receiveCallback;
 };
 
-inline
-Transport::Transport()
-  : m_ioService(0)
-  , m_isConnected(false)
-  , m_isExpectingData(false)
-{
-}
-
-inline
-Transport::Error::Error(const boost::system::error_code& code, const std::string& msg)
-  : std::runtime_error(msg + (code.value() ? " (" + code.category().message(code.value()) + ")" : ""))
-{
-}
-
-inline
-Transport::Error::Error(const std::string& msg)
-  : std::runtime_error(msg)
-{
-}
-
-inline
-Transport::~Transport()
-{
-}
-
-inline void
-Transport::connect(boost::asio::io_service& ioService,
-                   const ReceiveCallback& receiveCallback)
-{
-  m_ioService = &ioService;
-  m_receiveCallback = receiveCallback;
-}
-
 inline bool
-Transport::isConnected()
+Transport::isConnected() const
 {
   return m_isConnected;
 }
 
 inline bool
-Transport::isExpectingData()
+Transport::isReceiving() const
 {
-  return m_isExpectingData;
+  return m_isReceiving;
 }
 
 inline void
diff --git a/src/transport/unix-transport.cpp b/src/transport/unix-transport.cpp
index 0c63960..f2e44aa 100644
--- a/src/transport/unix-transport.cpp
+++ b/src/transport/unix-transport.cpp
@@ -19,10 +19,8 @@
  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
  */
 
-#include "common.hpp"
-
 #include "unix-transport.hpp"
-#include "stream-transport.hpp"
+#include "stream-transport-impl.hpp"
 
 #include "../face.hpp"
 #include "util/face-uri.hpp"
@@ -77,7 +75,7 @@
 UnixTransport::connect(boost::asio::io_service& ioService,
                        const ReceiveCallback& receiveCallback)
 {
-  if (!static_cast<bool>(m_impl)) {
+  if (m_impl == nullptr) {
     Transport::connect(ioService, receiveCallback);
 
     m_impl = make_shared<Impl>(ref(*this), ref(ioService));
@@ -89,21 +87,21 @@
 void
 UnixTransport::send(const Block& wire)
 {
-  BOOST_ASSERT(static_cast<bool>(m_impl));
+  BOOST_ASSERT(m_impl != nullptr);
   m_impl->send(wire);
 }
 
 void
 UnixTransport::send(const Block& header, const Block& payload)
 {
-  BOOST_ASSERT(static_cast<bool>(m_impl));
+  BOOST_ASSERT(m_impl != nullptr);
   m_impl->send(header, payload);
 }
 
 void
 UnixTransport::close()
 {
-  BOOST_ASSERT(static_cast<bool>(m_impl));
+  BOOST_ASSERT(m_impl != nullptr);
   m_impl->close();
   m_impl.reset();
 }
@@ -111,7 +109,7 @@
 void
 UnixTransport::pause()
 {
-  if (static_cast<bool>(m_impl)) {
+  if (m_impl != nullptr) {
     m_impl->pause();
   }
 }
@@ -119,7 +117,7 @@
 void
 UnixTransport::resume()
 {
-  BOOST_ASSERT(static_cast<bool>(m_impl));
+  BOOST_ASSERT(m_impl != nullptr);
   m_impl->resume();
 }
 
diff --git a/src/transport/unix-transport.hpp b/src/transport/unix-transport.hpp
index 6d16c26..99d8688 100644
--- a/src/transport/unix-transport.hpp
+++ b/src/transport/unix-transport.hpp
@@ -22,63 +22,58 @@
 #ifndef NDN_TRANSPORT_UNIX_TRANSPORT_HPP
 #define NDN_TRANSPORT_UNIX_TRANSPORT_HPP
 
-#include "../common.hpp"
 #include "transport.hpp"
 #include "../util/config-file.hpp"
 
-// forward declaration
-namespace boost { namespace asio { namespace local { class stream_protocol; } } }
+namespace boost {
+namespace asio {
+namespace local {
+class stream_protocol;
+} // namespace local
+} // namespace asio
+} // namespace boost
 
 namespace ndn {
 
-// forward declaration
-template<class T, class U>
+template<typename BaseTransport, typename Protocol>
 class StreamTransportImpl;
 
+/** \brief a transport using Unix stream socket
+ */
 class UnixTransport : public Transport
 {
 public:
-
-  /**
-   * Create Unix transport based on the socket specified
-   * in a well-known configuration file or fallback to /var/run/nfd.sock
-   *
-   * @throws Throws UnixTransport::Error on failure to parse a discovered configuration file
-   */
+  explicit
   UnixTransport(const std::string& unixSocket);
 
   ~UnixTransport();
 
-  // from Transport
   virtual void
   connect(boost::asio::io_service& ioService,
-          const ReceiveCallback& receiveCallback);
+          const ReceiveCallback& receiveCallback) override;
 
   virtual void
-  close();
+  close() override;
 
   virtual void
-  pause();
+  pause() override;
 
   virtual void
-  resume();
+  resume() override;
 
   virtual void
-  send(const Block& wire);
+  send(const Block& wire) override;
 
   virtual void
-  send(const Block& header, const Block& payload);
+  send(const Block& header, const Block& payload) override;
 
-  /**
-   * @brief Create transport with parameters defined in URI
-   *
-   * @throws Transport::Error if incorrect URI or unsupported protocol is specified
+  /** \brief Create transport with parameters defined in URI
+   *  \throw Transport::Error if incorrect URI or unsupported protocol is specified
    */
   static shared_ptr<UnixTransport>
   create(const std::string& uri);
 
 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
-
   static std::string
   getSocketNameFromUri(const std::string& uri);
 
@@ -87,7 +82,7 @@
 
   typedef StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol> Impl;
   friend class StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol>;
-  shared_ptr< Impl > m_impl;
+  shared_ptr<Impl> m_impl;
 };
 
 } // namespace ndn
