diff --git a/tools/dump/main.cpp b/tools/dump/main.cpp
index 1ed697c..39723fa 100644
--- a/tools/dump/main.cpp
+++ b/tools/dump/main.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2015,  Regents of the University of California.
+ * Copyright (c) 2014-2016,  Regents of the University of California.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -95,18 +95,14 @@
 
   po::options_description hiddenOptions;
   hiddenOptions.add_options()
-    ("pcap-program", po::value<std::vector<std::string> >());
-  ;
+    ("pcap-program", po::value<std::vector<std::string>>());
 
   po::positional_options_description positionalArguments;
-  positionalArguments
-    .add("pcap-program", -1);
+  positionalArguments.add("pcap-program", -1);
 
   po::options_description allOptions;
-  allOptions
-    .add(visibleOptions)
-    .add(hiddenOptions)
-    ;
+  allOptions.add(visibleOptions)
+            .add(hiddenOptions);
 
   po::variables_map vm;
 
@@ -118,8 +114,8 @@
               vm);
     po::notify(vm);
   }
-  catch (std::exception& e) {
-    std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
+  catch (const po::error& e) {
+    std::cerr << "ERROR: " << e.what() << "\n\n";
     usage(std::cerr, argv[0], visibleOptions);
     return 1;
   }
@@ -130,7 +126,7 @@
   }
 
   if (vm.count("version") > 0) {
-    std::cout << "ndndump " << tools::VERSION << std::endl;
+    std::cout << "ndndump " << tools::VERSION << '\n';
     return 0;
   }
 
@@ -139,8 +135,7 @@
   }
 
   if (vm.count("pcap-program") > 0) {
-    typedef std::vector<std::string> Strings;
-    const Strings& items = vm["pcap-program"].as<Strings>();
+    const auto& items = vm["pcap-program"].as<std::vector<std::string>>();
 
     std::ostringstream os;
     std::copy(items.begin(), items.end(), std::ostream_iterator<std::string>(os, " "));
@@ -148,7 +143,7 @@
   }
 
   if (vm.count("read") > 0 && vm.count("interface") > 0) {
-    std::cerr << "ERROR: Conflicting -r and -i options" << std::endl;
+    std::cerr << "ERROR: Conflicting -r and -i options\n";
     usage(std::cerr, argv[0], visibleOptions);
     return 2;
   }
diff --git a/tools/dump/ndndump.cpp b/tools/dump/ndndump.cpp
index e964c58..95875a9 100644
--- a/tools/dump/ndndump.cpp
+++ b/tools/dump/ndndump.cpp
@@ -64,6 +64,17 @@
 
 const size_t MAX_SNAPLEN = 65535;
 
+Ndndump::Ndndump()
+  : isVerbose(false)
+  , pcapProgram("(ether proto 0x8624) || (tcp port 6363) || (udp port 6363)")
+  // , isSuccinct(false)
+  // , isMatchInverted(false)
+  // , shouldPrintStructure(false)
+  // , isTcpOnly(false)
+  // , isUdpOnly(false)
+{
+}
+
 void
 Ndndump::run()
 {
@@ -71,7 +82,7 @@
     char errbuf[PCAP_ERRBUF_SIZE];
     const char* pcapDevice = pcap_lookupdev(errbuf);
 
-    if (pcapDevice == 0) {
+    if (pcapDevice == nullptr) {
       throw Error(errbuf);
     }
 
@@ -94,14 +105,14 @@
   if (!interface.empty()) {
     char errbuf[PCAP_ERRBUF_SIZE];
     m_pcap = pcap_open_live(interface.c_str(), MAX_SNAPLEN, 0, 1000, errbuf);
-    if (m_pcap == 0) {
+    if (m_pcap == nullptr) {
       throw Error("Cannot open interface " + interface + "(" + errbuf + ")");
     }
   }
   else {
     char errbuf[PCAP_ERRBUF_SIZE];
     m_pcap = pcap_open_offline(inputFile.c_str(), errbuf);
-    if (m_pcap == 0) {
+    if (m_pcap == nullptr) {
       throw Error("Cannot file " + inputFile + " for reading (" + errbuf + ")");
     }
   }
@@ -112,34 +123,32 @@
     }
 
     bpf_program program;
-    int returnValue = pcap_compile(m_pcap, &program, pcapProgram.c_str(), 0, PCAP_NETMASK_UNKNOWN);
+    int res = pcap_compile(m_pcap, &program, pcapProgram.c_str(), 0, PCAP_NETMASK_UNKNOWN);
 
-    if (returnValue < 0) {
+    if (res < 0) {
       throw Error("Cannot parse tcpdump expression '" + pcapProgram +
                   "' (" + pcap_geterr(m_pcap) + ")");
     }
 
-    returnValue = pcap_setfilter(m_pcap, &program);
+    res = pcap_setfilter(m_pcap, &program);
     pcap_freecode(&program);
 
-    if (returnValue < 0) {
+    if (res < 0) {
       throw Error(std::string("pcap_setfilter failed (") + pcap_geterr(m_pcap) + ")");
     }
   }
 
   m_dataLinkType = pcap_datalink(m_pcap);
-  if (m_dataLinkType != DLT_EN10MB &&
-      m_dataLinkType != DLT_PPP)
-    {
-      throw Error("Unsupported pcap format (" + boost::lexical_cast<std::string>(m_dataLinkType));
-    }
+  if (m_dataLinkType != DLT_EN10MB && m_dataLinkType != DLT_PPP) {
+    throw Error("Unsupported pcap format (" + to_string(m_dataLinkType));
+  }
 
   pcap_loop(m_pcap, -1, &Ndndump::onCapturedPacket, reinterpret_cast<uint8_t*>(this));
 }
 
 
 void
-Ndndump::onCapturedPacket(const pcap_pkthdr* header, const uint8_t* packet)
+Ndndump::onCapturedPacket(const pcap_pkthdr* header, const uint8_t* packet) const
 {
   std::ostringstream os;
   printInterceptTime(os, header);
@@ -153,8 +162,8 @@
     return;
   }
 
-  int returnValue = skipAndProcessFrameHeader(frameType, payload, payloadSize, os);
-  if (returnValue < 0) {
+  int res = skipAndProcessFrameHeader(frameType, payload, payloadSize, os);
+  if (res < 0) {
     return;
   }
 
@@ -223,13 +232,13 @@
       std::cout << os.str() << ", " << "UNKNOWN-NETWORK-PACKET" << std::endl;
     }
   }
-  catch (tlv::Error& e) {
+  catch (const tlv::Error& e) {
     std::cerr << e.what() << std::endl;
   }
 }
 
 void
-Ndndump::printInterceptTime(std::ostream& os, const pcap_pkthdr* header)
+Ndndump::printInterceptTime(std::ostream& os, const pcap_pkthdr* header) const
 {
   os << header->ts.tv_sec
      << "."
@@ -251,13 +260,12 @@
 }
 
 int
-Ndndump::skipDataLinkHeaderAndGetFrameType(const uint8_t*& payload, ssize_t& payloadSize)
+Ndndump::skipDataLinkHeaderAndGetFrameType(const uint8_t*& payload, ssize_t& payloadSize) const
 {
   int frameType = 0;
 
   switch (m_dataLinkType) {
-  case DLT_EN10MB: // Ethernet frames can have Ethernet or 802.3 encapsulation
-    {
+    case DLT_EN10MB: { // Ethernet frames can have Ethernet or 802.3 encapsulation
       const ether_header* etherHeader = reinterpret_cast<const ether_header*>(payload);
 
       if (payloadSize < 0) {
@@ -271,16 +279,15 @@
 
       break;
     }
-  case DLT_PPP:
-    {
+    case DLT_PPP: {
       frameType = *payload;
-      payloadSize--;
-      payload++;
+      --payloadSize;
+      ++payload;
 
       if (!(frameType & 1)) {
         frameType = (frameType << 8) | *payload;
-        payloadSize--;
-        payload++;
+        --payloadSize;
+        ++payload;
       }
 
       if (payloadSize < 0) {
@@ -298,78 +305,74 @@
 int
 Ndndump::skipAndProcessFrameHeader(int frameType,
                                    const uint8_t*& payload, ssize_t& payloadSize,
-                                   std::ostream& os)
+                                   std::ostream& os) const
 {
-  switch (frameType)
-    {
-    case /*ETHERTYPE_IP*/0x0800:
-    case DLT_EN10MB: // pcap encapsulation
-      {
-        const ip* ipHeader = reinterpret_cast<const ip*>(payload);
-        size_t ipHeaderSize = IP_HL(ipHeader) * 4;
-        if (ipHeaderSize < 20) {
-          std::cerr << "invalid IP header len " << ipHeaderSize << " bytes" << std::endl;
-          return -1;
-        }
+  switch (frameType) {
+    case 0x0800: // ETHERTYPE_IP
+    case DLT_EN10MB: { // pcap encapsulation
+      const ip* ipHeader = reinterpret_cast<const ip*>(payload);
+      size_t ipHeaderSize = IP_HL(ipHeader) * 4;
+      if (ipHeaderSize < 20) {
+        std::cerr << "invalid IP header len " << ipHeaderSize << " bytes" << std::endl;
+        return -1;
+      }
 
-        os << "From: " << inet_ntoa(ipHeader->ip_src) << ", ";
-        os << "To: "   << inet_ntoa(ipHeader->ip_dst);
+      os << "From: " << inet_ntoa(ipHeader->ip_src) << ", ";
+      os << "To: "   << inet_ntoa(ipHeader->ip_dst);
 
-        payloadSize -= ipHeaderSize;
-        payload += ipHeaderSize;
+      payloadSize -= ipHeaderSize;
+      payload += ipHeaderSize;
 
-        if (payloadSize < 0) {
-          std::cerr << "Invalid pcap IP packet" << std::endl;
-          return -1;
-        }
+      if (payloadSize < 0) {
+        std::cerr << "Invalid pcap IP packet" << std::endl;
+        return -1;
+      }
 
-        switch (ipHeader->ip_p) {
-        case IPPROTO_UDP:
-          {
-            // if (!flags.udp)
-            //   return -1;
+      switch (ipHeader->ip_p) {
+        case IPPROTO_UDP: {
+          // if (!flags.udp)
+          //   return -1;
 
-            payloadSize -= sizeof(udphdr);
-            payload += sizeof(udphdr);
+          payloadSize -= sizeof(udphdr);
+          payload += sizeof(udphdr);
 
-            if (payloadSize < 0) {
-                std::cerr << "Invalid pcap UDP/IP packet" << std::endl;
-                return -1;
-              }
-
-            os << ", Tunnel Type: UDP";
-            break;
+          if (payloadSize < 0) {
+            std::cerr << "Invalid pcap UDP/IP packet" << std::endl;
+            return -1;
           }
-        case IPPROTO_TCP:
-          {
-            // if (!flags.tcp)
-            //   return -1;
 
-            const tcphdr* tcpHeader = reinterpret_cast<const tcphdr*>(payload);
-            size_t tcpHeaderSize = TH_OFF(tcpHeader) * 4;
+          os << ", Tunnel Type: UDP";
+          break;
+        }
+        case IPPROTO_TCP: {
+          // if (!flags.tcp)
+          //   return -1;
 
-            if (tcpHeaderSize < 20) {
-              std::cerr << "Invalid TCP Header len: "<< tcpHeaderSize <<" bytes" << std::endl;
-              return -1;
-            }
+          const tcphdr* tcpHeader = reinterpret_cast<const tcphdr*>(payload);
+          size_t tcpHeaderSize = TH_OFF(tcpHeader) * 4;
 
-            payloadSize -= tcpHeaderSize;
-            payload += tcpHeaderSize;
-
-            if (payloadSize < 0) {
-              std::cerr << "Invalid pcap TCP/IP packet" << std::endl;
-              return -1;
-            }
-
-            os << ", Tunnel Type: TCP";
-            break;
+          if (tcpHeaderSize < 20) {
+            std::cerr << "Invalid TCP Header len: " << tcpHeaderSize <<" bytes" << std::endl;
+            return -1;
           }
+
+          payloadSize -= tcpHeaderSize;
+          payload += tcpHeaderSize;
+
+          if (payloadSize < 0) {
+            std::cerr << "Invalid pcap TCP/IP packet" << std::endl;
+            return -1;
+          }
+
+          os << ", Tunnel Type: TCP";
+          break;
+        }
         default:
           return -1;
-        }
-
-        break;
       }
+
+      break;
+    }
     case /*ETHERTYPE_NDN*/0x7777:
       os << "Tunnel Type: EthernetFrame";
       break;
@@ -381,13 +384,23 @@
       payloadSize -= 2;
       payload += 2;
       break;
-    default:
+    default: // do nothing if it is not a recognized type of a packet
       return -1;
-      break; // do nothing if it is not a recognized type of a packet
-    }
+  }
 
   return 0;
 }
 
+bool
+Ndndump::matchesFilter(const Name& name) const
+{
+  if (nameFilter.empty())
+    return true;
+
+  /// \todo Switch to NDN regular expressions
+
+  return boost::regex_match(name.toUri(), nameFilter);
+}
+
 } // namespace dump
 } // namespace ndn
diff --git a/tools/dump/ndndump.hpp b/tools/dump/ndndump.hpp
index 594406d..6961a73 100644
--- a/tools/dump/ndndump.hpp
+++ b/tools/dump/ndndump.hpp
@@ -60,52 +60,35 @@
     }
   };
 
-  Ndndump()
-    : isVerbose(false)
-    , pcapProgram("(ether proto 0x8624) || (tcp port 6363) || (udp port 6363)")
-    // , isSuccinct(false)
-    // , isMatchInverted(false)
-    // , shouldPrintStructure(false)
-    // , isTcpOnly(false)
-    // , isUdpOnly(false)
-  {
-  }
+  Ndndump();
 
   void
   run();
 
 PUBLIC_WITH_TESTS_ELSE_PRIVATE:
   void
-  onCapturedPacket(const pcap_pkthdr* header, const uint8_t* packet);
+  onCapturedPacket(const pcap_pkthdr* header, const uint8_t* packet) const;
 
 private:
   static void
   onCapturedPacket(uint8_t* userData, const pcap_pkthdr* header, const uint8_t* packet)
   {
-    reinterpret_cast<Ndndump*>(userData)->onCapturedPacket(header, packet);
+    reinterpret_cast<const Ndndump*>(userData)->onCapturedPacket(header, packet);
   }
 
   void
-  printInterceptTime(std::ostream& os, const pcap_pkthdr* header);
+  printInterceptTime(std::ostream& os, const pcap_pkthdr* header) const;
 
   int
-  skipDataLinkHeaderAndGetFrameType(const uint8_t*& payload, ssize_t& payloadSize);
+  skipDataLinkHeaderAndGetFrameType(const uint8_t*& payload, ssize_t& payloadSize) const;
 
   int
   skipAndProcessFrameHeader(int frameType,
                             const uint8_t*& payload, ssize_t& payloadSize,
-                            std::ostream& os);
+                            std::ostream& os) const;
 
   bool
-  matchesFilter(const Name& name)
-  {
-    if (nameFilter.empty())
-      return true;
-
-    /// \todo Switch to NDN regular expressions
-
-    return boost::regex_match(name.toUri(), nameFilter);
-  }
+  matchesFilter(const Name& name) const;
 
 public:
   bool isVerbose;
