diff --git a/src/logger.hpp b/src/logger.hpp
index 25847a4..0ed35b3 100644
--- a/src/logger.hpp
+++ b/src/logger.hpp
@@ -1,8 +1,19 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2014 University of Arizona.
+ * Copyright (C) 2014-2015  University of Arizona.
  *
- * GNU 3.0 License, see the LICENSE file for more information
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
  */
@@ -10,8 +21,10 @@
 #ifndef NTG_LOGGER_HPP
 #define NTG_LOGGER_HPP
 
-#include <string>
+#include <cstdlib>
 #include <fstream>
+#include <string>
+
 #include <boost/filesystem.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 
@@ -46,7 +59,7 @@
   void
   log(const std::string& logLine, bool printTime, bool printToConsole)
   {
-    if( m_logLocation.length() > 0 )
+    if (m_logLocation.length() > 0)
       {
         if (printTime)
           m_logFile << getTimestamp() << " - ";
@@ -70,11 +83,12 @@
   void
   initializeLog(const std::string& instanceId)
   {
-    char* variableValue = std::getenv("NDN_TRAFFIC_LOGFOLDER");
-    std::string logFilename;
+    const char* envVar = std::getenv("NDN_TRAFFIC_LOGFOLDER");
     m_logLocation = "";
-    if (variableValue != NULL)
-      m_logLocation = variableValue;
+    if (envVar != nullptr)
+      m_logLocation = envVar;
+
+    std::string logFilename;
     if (boost::filesystem::exists(boost::filesystem::path(m_logLocation)))
       {
         if (boost::filesystem::is_directory(boost::filesystem::path(m_logLocation)))
diff --git a/src/ndn-traffic-client.cpp b/src/ndn-traffic-client.cpp
index 2e1b910..379ae96 100644
--- a/src/ndn-traffic-client.cpp
+++ b/src/ndn-traffic-client.cpp
@@ -1,21 +1,33 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2014 University of Arizona.
+ * Copyright (C) 2014-2015  University of Arizona.
  *
- * GNU 3.0 License, see the LICENSE file for more information
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
  */
 
+#include <cctype>
+#include <cstdlib>
 #include <fstream>
-#include <sstream>
 #include <string>
+#include <unistd.h>
 #include <vector>
 
 #include <boost/asio.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/noncopyable.hpp>
 
 #include <ndn-cxx/exclude.hpp>
@@ -29,11 +41,11 @@
 class NdnTrafficClient : boost::noncopyable
 {
 public:
-
   explicit
-  NdnTrafficClient(char* programName)
+  NdnTrafficClient(const char* programName)
     : m_programName(programName)
     , m_logger("NdnTrafficClient")
+    , m_instanceId(std::to_string(std::rand()))
     , m_hasError(false)
     , m_hasQuietLogging(false)
     , m_interestInterval(getDefaultInterestInterval())
@@ -46,7 +58,6 @@
     , m_maximumInterestRoundTripTime(0)
     , m_totalInterestRoundTripTime(0)
   {
-    m_instanceId = boost::lexical_cast<std::string>(std::rand());
   }
 
   class InterestTrafficConfiguration
@@ -74,7 +85,7 @@
     {
     }
 
-    time::milliseconds
+    static time::milliseconds
     getDefaultInterestLifetime()
     {
       return time::milliseconds(-1);
@@ -83,81 +94,74 @@
     void
     printTrafficConfiguration(Logger& logger)
     {
-      std::string detail = "";
+      std::string detail;
+
       if (m_trafficPercentage > 0)
-        detail += "TrafficPercentage=" +
-          boost::lexical_cast<std::string>(m_trafficPercentage) + ", ";
-      if (m_name != "")
+        detail += "TrafficPercentage=" + std::to_string(m_trafficPercentage) + ", ";
+      if (!m_name.empty())
         detail += "Name=" + m_name + ", ";
       if (m_nameAppendBytes > 0)
-        detail += "NameAppendBytes=" + boost::lexical_cast<std::string>(m_nameAppendBytes) + ", ";
+        detail += "NameAppendBytes=" + std::to_string(m_nameAppendBytes) + ", ";
       if (m_nameAppendSequenceNumber > 0)
-        detail += "NameAppendSequenceNumber=" +
-          boost::lexical_cast<std::string>(m_nameAppendSequenceNumber) + ", ";
+        detail += "NameAppendSequenceNumber=" + std::to_string(m_nameAppendSequenceNumber) + ", ";
       if (m_minSuffixComponents >= 0)
-        detail += "MinSuffixComponents=" +
-          boost::lexical_cast<std::string>(m_minSuffixComponents) + ", ";
+        detail += "MinSuffixComponents=" + std::to_string(m_minSuffixComponents) + ", ";
       if (m_maxSuffixComponents >= 0)
-        detail += "MaxSuffixComponents=" +
-          boost::lexical_cast<std::string>(m_maxSuffixComponents) + ", ";
-      if (m_excludeBefore != "")
+        detail += "MaxSuffixComponents=" + std::to_string(m_maxSuffixComponents) + ", ";
+      if (!m_excludeBefore.empty())
         detail += "ExcludeBefore=" + m_excludeBefore + ", ";
-      if (m_excludeAfter != "")
+      if (!m_excludeAfter.empty())
         detail += "ExcludeAfter=" + m_excludeAfter + ", ";
       if (m_excludeBeforeBytes > 0)
-        detail += "ExcludeBeforeBytes=" +
-          boost::lexical_cast<std::string>(m_excludeBeforeBytes) + ", ";
+        detail += "ExcludeBeforeBytes=" + std::to_string(m_excludeBeforeBytes) + ", ";
       if (m_excludeAfterBytes > 0)
-        detail += "ExcludeAfterBytes=" +
-          boost::lexical_cast<std::string>(m_excludeAfterBytes) + ", ";
+        detail += "ExcludeAfterBytes=" + std::to_string(m_excludeAfterBytes) + ", ";
       if (m_childSelector >= 0)
-        detail += "ChildSelector=" +
-          boost::lexical_cast<std::string>(m_childSelector) + ", ";
+        detail += "ChildSelector=" + std::to_string(m_childSelector) + ", ";
       if (m_mustBeFresh >= 0)
-        detail += "MustBeFresh=" +
-          boost::lexical_cast<std::string>(m_mustBeFresh) + ", ";
+        detail += "MustBeFresh=" + std::to_string(m_mustBeFresh) + ", ";
       if (m_nonceDuplicationPercentage > 0)
         detail += "NonceDuplicationPercentage=" +
-          boost::lexical_cast<std::string>(m_nonceDuplicationPercentage) + ", ";
+                  std::to_string(m_nonceDuplicationPercentage) + ", ";
       if (m_scope >= 0)
-        detail += "Scope="+boost::lexical_cast<std::string>(m_scope) + ", ";
+        detail += "Scope=" + std::to_string(m_scope) + ", ";
       if (m_interestLifetime >= time::milliseconds(0))
-        detail += "InterestLifetime=" +
-          boost::lexical_cast<std::string>(m_interestLifetime.count()) + ", ";
-      if (m_expectedContent != "")
+        detail += "InterestLifetime=" + std::to_string(m_interestLifetime.count()) + ", ";
+      if (!m_expectedContent.empty())
         detail += "ExpectedContent=" + m_expectedContent + ", ";
       if (detail.length() >= 2)
-        detail = detail.substr(0, detail.length() - 2); //Removing suffix ", "
+        detail = detail.substr(0, detail.length() - 2); // Removing suffix ", "
+
       logger.log(detail, false, false);
     }
 
     bool
-    extractParameterValue(const std::string& detail,
-                          std::string& parameter,
-                          std::string& value)
+    extractParameterValue(const std::string& detail, std::string& parameter, std::string& value)
     {
       std::string allowedCharacters = ":/+._-%";
+      std::size_t i = 0;
+
       parameter = "";
       value = "";
-      int i = 0;
-      while (detail[i] != '=' && i < detail.length())
-        {
-          parameter += detail[i];
-          i++;
-        }
+      while (detail[i] != '=' && i < detail.length()) {
+        parameter += detail[i];
+        i++;
+      }
       if (i == detail.length())
         return false;
+
       i++;
       while ((std::isalnum(detail[i]) ||
-             allowedCharacters.find(detail[i]) != std::string::npos) &&
-             i < detail.length())
-        {
-          value += detail[i];
-          i++;
-        }
-      if (parameter == "" || value == "")
+              allowedCharacters.find(detail[i]) != std::string::npos) &&
+             i < detail.length()) {
+        value += detail[i];
+        i++;
+      }
+
+      if (parameter.empty() || value.empty())
         return false;
-      return true;
+      else
+        return true;
     }
 
     bool
@@ -167,44 +171,44 @@
       if (extractParameterValue(detail, parameter, value))
         {
           if (parameter == "TrafficPercentage")
-            m_trafficPercentage = boost::lexical_cast<int>(value);
+            m_trafficPercentage = std::stoi(value);
           else if (parameter == "Name")
             m_name = value;
           else if (parameter == "NameAppendBytes")
-            m_nameAppendBytes = boost::lexical_cast<int>(value);
+            m_nameAppendBytes = std::stoi(value);
           else if (parameter == "NameAppendSequenceNumber")
-            m_nameAppendSequenceNumber = boost::lexical_cast<int>(value);
+            m_nameAppendSequenceNumber = std::stoi(value);
           else if (parameter == "MinSuffixComponents")
-            m_minSuffixComponents = boost::lexical_cast<int>(value);
+            m_minSuffixComponents = std::stoi(value);
           else if (parameter == "MaxSuffixComponents")
-            m_maxSuffixComponents = boost::lexical_cast<int>(value);
+            m_maxSuffixComponents = std::stoi(value);
           else if (parameter == "ExcludeBefore")
             m_excludeBefore = value;
           else if (parameter == "ExcludeAfter")
             m_excludeAfter = value;
           else if (parameter == "ExcludeBeforeBytes")
-            m_excludeBeforeBytes = boost::lexical_cast<int>(value);
+            m_excludeBeforeBytes = std::stoi(value);
           else if (parameter == "ExcludeAfterBytes")
-            m_excludeAfterBytes = boost::lexical_cast<int>(value);
+            m_excludeAfterBytes = std::stoi(value);
           else if (parameter == "ChildSelector")
-            m_childSelector = boost::lexical_cast<int>(value);
+            m_childSelector = std::stoi(value);
           else if (parameter == "MustBeFresh")
-            m_mustBeFresh = boost::lexical_cast<int>(value);
+            m_mustBeFresh = std::stoi(value);
           else if (parameter == "NonceDuplicationPercentage")
-            m_nonceDuplicationPercentage = boost::lexical_cast<int>(value);
+            m_nonceDuplicationPercentage = std::stoi(value);
           else if (parameter == "Scope")
-            m_scope = boost::lexical_cast<int>(value);
+            m_scope = std::stoi(value);
           else if (parameter == "InterestLifetime")
-            m_interestLifetime = time::milliseconds(boost::lexical_cast<int>(value));
+            m_interestLifetime = time::milliseconds(std::stoi(value));
           else if (parameter == "ExpectedContent")
             m_expectedContent = value;
           else
-            logger.log("Line " + boost::lexical_cast<std::string>(lineNumber) +
+            logger.log("Line " + std::to_string(lineNumber) +
                        " \t- Invalid Parameter='" + parameter + "'", false, true);
         }
       else
         {
-          logger.log("Line " + boost::lexical_cast<std::string>(lineNumber) +
+          logger.log("Line " + std::to_string(lineNumber) +
                      " \t- Improper Traffic Configuration Line- " + detail, false, true);
           return false;
         }
@@ -217,6 +221,7 @@
       return true;
     }
 
+  private:
     int m_trafficPercentage;
     std::string m_name;
     int m_nameAppendBytes;
@@ -243,6 +248,8 @@
 
     int m_nContentInconsistencies;
     std::string m_expectedContent;
+
+    friend class NdnTrafficClient;
   }; // class InterestTrafficConfiguration
 
   bool
@@ -252,21 +259,25 @@
   }
 
   void
-  usage()
+  usage() const
   {
-    std::cout << "\nUsage: " << m_programName << " [options] <Traffic_Configuration_File>\n"
-      "Generate Interest Traffic as per provided Traffic Configuration File\n"
-      "Interests are continuously generated unless a total number is specified.\n"
-      "Set environment variable NDN_TRAFFIC_LOGFOLDER for redirecting output to a log.\n"
-      "  [-i interval] - set interest generation interval in milliseconds (default "
+    std::cout << "Usage:\n"
+              << "  " << m_programName << " [options] <Traffic_Configuration_File>\n"
+              << "\n"
+              << "Generate Interest traffic as per provided Traffic Configuration File.\n"
+              << "Interests are continuously generated unless a total number is specified.\n"
+              << "Set environment variable NDN_TRAFFIC_LOGFOLDER to redirect output to a log file.\n"
+              << "\n"
+              << "Options:\n"
+              << "  [-i interval] - set interest generation interval in milliseconds (default "
               << getDefaultInterestInterval() << ")\n"
-      "  [-c count]    - set total number of interests to be generated\n"
-      "  [-q]          - quiet logging - no interest generation/data reception messages\n"
-      "  [-h]          - print help and exit\n\n";
-    exit(1);
+              << "  [-c count]    - set total number of interests to be generated\n"
+              << "  [-q]          - quiet mode: no interest reception/data generation logging\n"
+              << "  [-h]          - print this help text and exit\n";
+    exit(EXIT_FAILURE);
   }
 
-  time::milliseconds
+  static time::milliseconds
   getDefaultInterestInterval()
   {
     return time::milliseconds(1000);
@@ -304,13 +315,12 @@
   signalHandler()
   {
     logStatistics();
+
     m_logger.shutdownLogger();
     m_face.shutdown();
     m_ioService.stop();
-    if (m_hasError)
-      exit(1);
-    else
-      exit(0);
+
+    exit(m_hasError ? EXIT_FAILURE : EXIT_SUCCESS);
   }
 
   void
@@ -318,18 +328,19 @@
   {
     m_logger.log("\n\n== Interest Traffic Report ==\n", false, true);
     m_logger.log("Total Traffic Pattern Types = " +
-      boost::lexical_cast<std::string>(static_cast<int>(m_trafficPatterns.size())), false, true);
+      std::to_string(m_trafficPatterns.size()), false, true);
     m_logger.log("Total Interests Sent        = " +
-      boost::lexical_cast<std::string>(m_nInterestsSent), false, true);
+      std::to_string(m_nInterestsSent), false, true);
     m_logger.log("Total Responses Received    = " +
-      boost::lexical_cast<std::string>(m_nInterestsReceived), false, true);
+      std::to_string(m_nInterestsReceived), false, true);
+
     double loss = 0;
     if (m_nInterestsSent > 0)
       loss = (m_nInterestsSent - m_nInterestsReceived) * 100.0 / m_nInterestsSent;
-    m_logger.log("Total Interest Loss         = " +
-      boost::lexical_cast<std::string>(loss) + "%", false, true);
+    m_logger.log("Total Interest Loss         = " + std::to_string(loss) + "%", false, true);
     if (m_nContentInconsistencies != 0 || m_nInterestsSent != m_nInterestsReceived)
       m_hasError = true;
+
     double average = 0;
     double inconsistency = 0;
     if (m_nInterestsReceived > 0)
@@ -338,23 +349,21 @@
         inconsistency = m_nContentInconsistencies * 100.0 / m_nInterestsReceived;
       }
     m_logger.log("Total Data Inconsistency    = " +
-      boost::lexical_cast<std::string>(inconsistency) + "%", false, true);
+      std::to_string(inconsistency) + "%", false, true);
     m_logger.log("Total Round Trip Time       = " +
-      boost::lexical_cast<std::string>(m_totalInterestRoundTripTime) + "ms", false, true);
+      std::to_string(m_totalInterestRoundTripTime) + "ms", false, true);
     m_logger.log("Average Round Trip Time     = " +
-      boost::lexical_cast<std::string>(average) + "ms\n", false, true);
+      std::to_string(average) + "ms\n", false, true);
 
-    for (int patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
+    for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
       {
         m_logger.log("Traffic Pattern Type #" +
-          boost::lexical_cast<std::string>(patternId + 1), false, true);
+          std::to_string(patternId + 1), false, true);
         m_trafficPatterns[patternId].printTrafficConfiguration(m_logger);
         m_logger.log("Total Interests Sent        = " +
-          boost::lexical_cast<std::string>(
-            m_trafficPatterns[patternId].m_nInterestsSent), false, true);
+          std::to_string(m_trafficPatterns[patternId].m_nInterestsSent), false, true);
         m_logger.log("Total Responses Received    = " +
-          boost::lexical_cast<std::string>(
-            m_trafficPatterns[patternId].m_nInterestsReceived), false, true);
+          std::to_string(m_trafficPatterns[patternId].m_nInterestsReceived), false, true);
         loss = 0;
         if (m_trafficPatterns[patternId].m_nInterestsSent > 0)
           {
@@ -363,8 +372,7 @@
             loss *= 100.0;
             loss /= m_trafficPatterns[patternId].m_nInterestsSent;
           }
-        m_logger.log("Total Interest Loss         = " +
-          boost::lexical_cast<std::string>(loss) + "%", false, true);
+        m_logger.log("Total Interest Loss         = " + std::to_string(loss) + "%", false, true);
         average = 0;
         inconsistency = 0;
         if (m_trafficPatterns[patternId].m_nInterestsReceived > 0)
@@ -372,16 +380,15 @@
             average = (m_trafficPatterns[patternId].m_totalInterestRoundTripTime /
                        m_trafficPatterns[patternId].m_nInterestsReceived);
             inconsistency = m_trafficPatterns[patternId].m_nContentInconsistencies;
-            inconsistency =
-              inconsistency * 100.0 / m_trafficPatterns[patternId].m_nInterestsReceived;
+            inconsistency *= 100.0 / m_trafficPatterns[patternId].m_nInterestsReceived;
           }
         m_logger.log("Total Data Inconsistency    = " +
-          boost::lexical_cast<std::string>(inconsistency) + "%", false, true);
+          std::to_string(inconsistency) + "%", false, true);
         m_logger.log("Total Round Trip Time       = " +
-          boost::lexical_cast<std::string>(
-            m_trafficPatterns[patternId].m_totalInterestRoundTripTime) + "ms", false, true);
+          std::to_string(m_trafficPatterns[patternId].m_totalInterestRoundTripTime) +
+          "ms", false, true);
         m_logger.log("Average Round Trip Time     = " +
-          boost::lexical_cast<std::string>(average) + "ms\n", false, true);
+          std::to_string(average) + "ms\n", false, true);
       }
   }
 
@@ -397,10 +404,10 @@
     std::string patternLine;
     std::ifstream patternFile;
     m_logger.log("Analyzing Traffic Configuration File: " + m_configurationFile, true, true);
+
     patternFile.open(m_configurationFile.c_str());
     if (patternFile.is_open())
       {
-        int patternId = 0;
         int lineNumber = 0;
         while (getline(patternFile, patternLine))
           {
@@ -409,7 +416,6 @@
               {
                 InterestTrafficConfiguration interestData;
                 bool shouldSkipLine = false;
-                patternId++;
                 if (interestData.processConfigurationDetail(patternLine, m_logger, lineNumber))
                   {
                     while (getline(patternFile, patternLine) && std::isalpha(patternLine[0]))
@@ -439,13 +445,13 @@
             m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper- " +
                          m_configurationFile, false, true);
             m_logger.shutdownLogger();
-            exit(1);
+            exit(EXIT_FAILURE);
           }
         m_logger.log("Traffic Configuration File Processing Completed\n", true, false);
-        for (patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
+        for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
           {
             m_logger.log("Traffic Pattern Type #" +
-              boost::lexical_cast<std::string>(patternId + 1), false, false);
+                         std::to_string(patternId + 1), false, false);
             m_trafficPatterns[patternId].printTrafficConfiguration(m_logger);
             m_logger.log("", false, false);
           }
@@ -455,7 +461,7 @@
         m_logger.log("ERROR - Unable To Open Traffic Configuration File: " +
                      m_configurationFile, false, true);
         m_logger.shutdownLogger();
-        exit(1);
+        exit(EXIT_FAILURE);
       }
   }
 
@@ -473,7 +479,7 @@
             m_logger.log("ERROR - Traffic Configuration File Is Not A Regular File: " +
                          m_configurationFile, false, true);
             m_logger.shutdownLogger();
-            exit(1);
+            exit(EXIT_FAILURE);
           }
       }
     else
@@ -481,7 +487,7 @@
         m_logger.log("ERROR - Traffic Configuration File Does Not Exist: " +
                      m_configurationFile, false, true);
         m_logger.shutdownLogger();
-        exit(1);
+        exit(EXIT_FAILURE);
       }
   }
 
@@ -510,10 +516,10 @@
   }
 
   static std::string
-  getRandomByteString(int randomSize)
+  getRandomByteString(std::size_t randomSize)
   {
     std::string randomString;
-    for (int i = 0; i < randomSize; i++)
+    for (std::size_t i = 0; i < randomSize; i++)
       randomString += static_cast<char>(std::rand() % 128);
     return randomString;
   }
@@ -526,15 +532,14 @@
          int patternId,
          time::steady_clock::TimePoint sentTime)
   {
-    std::string logLine =
-      "Data Received      - PatternType=" + boost::lexical_cast<std::string>(patternId+1);
-    logLine += ", GlobalID=" + boost::lexical_cast<std::string>(globalReference);
-    logLine += ", LocalID=" + boost::lexical_cast<std::string>(localReference);
+    std::string logLine = "Data Received      - PatternType=" + std::to_string(patternId + 1);
+    logLine += ", GlobalID=" + std::to_string(globalReference);
+    logLine += ", LocalID=" + std::to_string(localReference);
     logLine += ", Name=" + interest.getName().toUri();
 
     m_nInterestsReceived++;
     m_trafficPatterns[patternId].m_nInterestsReceived++;
-    if (m_trafficPatterns[patternId].m_expectedContent != "")
+    if (!m_trafficPatterns[patternId].m_expectedContent.empty())
       {
         std::string receivedContent = reinterpret_cast<const char*>(data.getContent().value());
         int receivedContentLength = data.getContent().value_size();
@@ -578,10 +583,9 @@
             int localReference,
             int patternId)
   {
-    std::string logLine = "Interest Timed Out - PatternType=" +
-      boost::lexical_cast<std::string>(patternId + 1);
-    logLine += ", GlobalID=" + boost::lexical_cast<std::string>(globalReference);
-    logLine += ", LocalID=" + boost::lexical_cast<std::string>(localReference);
+    std::string logLine = "Interest Timed Out - PatternType=" + std::to_string(patternId + 1);
+    logLine += ", GlobalID=" + std::to_string(globalReference);
+    logLine += ", LocalID=" + std::to_string(localReference);
     logLine += ", Name=" + interest.getName().toUri();
     m_logger.log(logLine, true, false);
     if (m_nMaximumInterests >= 0 && globalReference == m_nMaximumInterests)
@@ -594,13 +598,13 @@
   }
 
   void
-  generateTraffic(boost::asio::deadline_timer* deadlineTimer)
+  generateTraffic(boost::asio::deadline_timer* timer)
   {
     if (m_nMaximumInterests < 0 || m_nInterestsSent < m_nMaximumInterests)
       {
         int trafficKey = std::rand() % 100;
         int cumulativePercentage = 0;
-        int patternId;
+        std::size_t patternId;
         for (patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
           {
             cumulativePercentage += m_trafficPatterns[patternId].m_trafficPercentage;
@@ -613,10 +617,10 @@
                 if (m_trafficPatterns[patternId].m_nameAppendSequenceNumber >= 0)
                   {
                     interestName.append(
-                      boost::lexical_cast<std::string>(
-                        m_trafficPatterns[patternId].m_nameAppendSequenceNumber));
+                      std::to_string(m_trafficPatterns[patternId].m_nameAppendSequenceNumber));
                     m_trafficPatterns[patternId].m_nameAppendSequenceNumber++;
                   }
+
                 Interest interest(interestName);
                 if (m_trafficPatterns[patternId].m_minSuffixComponents >= 0)
                   interest.setMinSuffixComponents(
@@ -624,9 +628,10 @@
                 if (m_trafficPatterns[patternId].m_maxSuffixComponents >= 0)
                   interest.setMaxSuffixComponents(
                     m_trafficPatterns[patternId].m_maxSuffixComponents);
+
                 Exclude exclude;
-                if (m_trafficPatterns[patternId].m_excludeBefore != "" &&
-                    m_trafficPatterns[patternId].m_excludeAfter != "")
+                if (!m_trafficPatterns[patternId].m_excludeBefore.empty() &&
+                    !m_trafficPatterns[patternId].m_excludeAfter.empty())
                   {
                     exclude.excludeRange(
                       name::Component(
@@ -634,13 +639,13 @@
                       name::Component(m_trafficPatterns[patternId].m_excludeBefore));
                     interest.setExclude(exclude);
                   }
-                else if (m_trafficPatterns[patternId].m_excludeBefore != "")
+                else if (!m_trafficPatterns[patternId].m_excludeBefore.empty())
                   {
                     exclude.excludeBefore(
                       name::Component(m_trafficPatterns[patternId].m_excludeBefore));
                     interest.setExclude(exclude);
                   }
-                else if (m_trafficPatterns[patternId].m_excludeAfter != "")
+                else if (!m_trafficPatterns[patternId].m_excludeAfter.empty())
                   {
                     exclude.excludeAfter(
                       name::Component(m_trafficPatterns[patternId].m_excludeAfter));
@@ -711,34 +716,32 @@
                                               this, _1, m_nInterestsSent,
                                               m_trafficPatterns[patternId].m_nInterestsSent,
                                               patternId));
-                  std::string logLine = "";
-                  logLine += "Sending Interest   - PatternType=" +
-                    boost::lexical_cast<std::string>(patternId+1);
-                  logLine += ", GlobalID=" + boost::lexical_cast<std::string>(m_nInterestsSent);
-                  logLine += ", LocalID=" + boost::lexical_cast<std::string>(
-                    m_trafficPatterns[patternId].m_nInterestsSent);
-                  logLine += ", Name="+interest.getName().toUri();
-                  if (!m_hasQuietLogging)
+
+                  if (!m_hasQuietLogging) {
+                    std::string logLine =
+                      "Sending Interest   - PatternType=" + std::to_string(patternId + 1) +
+                      ", GlobalID=" + std::to_string(m_nInterestsSent) +
+                      ", LocalID=" +
+                      std::to_string(m_trafficPatterns[patternId].m_nInterestsSent) +
+                      ", Name=" + interest.getName().toUri();
                     m_logger.log(logLine, true, false);
-                  deadlineTimer->expires_at(deadlineTimer->expires_at() +
-                                            boost::posix_time::millisec(
-                                              m_interestInterval.count()));
-                  deadlineTimer->async_wait(bind(&NdnTrafficClient::generateTraffic,
-                                                 this, deadlineTimer));
+                  }
+
+                  timer->expires_at(timer->expires_at() +
+                                    boost::posix_time::millisec(m_interestInterval.count()));
+                  timer->async_wait(bind(&NdnTrafficClient::generateTraffic, this, timer));
                 }
-                catch (std::exception& e) {
-                  m_logger.log("ERROR: " + static_cast<std::string>(e.what()), true, true);
+                catch (const std::exception& e) {
+                  m_logger.log("ERROR: " + std::string(e.what()), true, true);
                 }
                 break;
               }
           }
         if (patternId == m_trafficPatterns.size())
           {
-            deadlineTimer->expires_at(deadlineTimer->expires_at() +
-                                      boost::posix_time::millisec(
-                                        m_interestInterval.count()));
-            deadlineTimer->async_wait(bind(&NdnTrafficClient::generateTraffic,
-                                           this, deadlineTimer));
+            timer->expires_at(timer->expires_at() +
+                              boost::posix_time::millisec(m_interestInterval.count()));
+            timer->async_wait(bind(&NdnTrafficClient::generateTraffic, this, timer));
           }
       }
   }
@@ -758,16 +761,15 @@
         return;
       }
 
-    boost::asio::deadline_timer deadlineTimer(
-      m_ioService,
+    boost::asio::deadline_timer deadlineTimer(m_ioService,
       boost::posix_time::millisec(m_interestInterval.count()));
-    deadlineTimer.async_wait(bind(&NdnTrafficClient::generateTraffic,
-                                  this, &deadlineTimer));
+    deadlineTimer.async_wait(bind(&NdnTrafficClient::generateTraffic, this, &deadlineTimer));
+
     try {
       m_face.processEvents();
     }
-    catch(std::exception& e) {
-      m_logger.log("ERROR: " + static_cast<std::string>(e.what()), true, true);
+    catch (const std::exception& e) {
+      m_logger.log("ERROR: " + std::string(e.what()), true, true);
       m_logger.shutdownLogger();
       m_hasError = true;
       m_ioService.stop();
@@ -775,7 +777,6 @@
   }
 
 private:
-
   std::string m_programName;
   Logger m_logger;
   std::string m_instanceId;
@@ -797,7 +798,6 @@
   double m_minimumInterestRoundTripTime;
   double m_maximumInterestRoundTripTime;
   double m_totalInterestRoundTripTime;
-
 };
 
 } // namespace ndn
@@ -805,25 +805,26 @@
 int
 main(int argc, char* argv[])
 {
-  std::srand(std::time(0));
-  ndn::NdnTrafficClient ndnTrafficClient (argv[0]);
+  std::srand(std::time(nullptr));
+
+  ndn::NdnTrafficClient client(argv[0]);
   int option;
   while ((option = getopt(argc, argv, "hqi:c:")) != -1) {
     switch (option) {
     case 'h':
-      ndnTrafficClient.usage();
+      client.usage();
       break;
     case 'i':
-      ndnTrafficClient.setInterestInterval(atoi(optarg));
+      client.setInterestInterval(atoi(optarg));
       break;
     case 'c':
-      ndnTrafficClient.setMaximumInterests(atoi(optarg));
+      client.setMaximumInterests(atoi(optarg));
       break;
     case 'q':
-      ndnTrafficClient.setQuietLogging();
+      client.setQuietLogging();
       break;
     default:
-      ndnTrafficClient.usage();
+      client.usage();
       break;
     }
   }
@@ -831,14 +832,11 @@
   argc -= optind;
   argv += optind;
 
-  if (argv[0] == 0)
-    ndnTrafficClient.usage();
+  if (!argc)
+    client.usage();
 
-  ndnTrafficClient.setConfigurationFile(argv[0]);
-  ndnTrafficClient.run();
+  client.setConfigurationFile(argv[0]);
+  client.run();
 
-  if (ndnTrafficClient.hasError())
-    return 1;
-  else
-    return 0;
+  return client.hasError() ? EXIT_FAILURE : EXIT_SUCCESS;
 }
diff --git a/src/ndn-traffic-server.cpp b/src/ndn-traffic-server.cpp
index 2c78dba..9351f75 100644
--- a/src/ndn-traffic-server.cpp
+++ b/src/ndn-traffic-server.cpp
@@ -1,17 +1,33 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2014 University of Arizona.
+ * Copyright (C) 2014-2015  University of Arizona.
  *
- * GNU 3.0 License, see the LICENSE file for more information
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
  */
 
-#include <sstream>
+#include <cctype>
+#include <cstdlib>
+#include <fstream>
+#include <string>
+#include <unistd.h>
+#include <vector>
 
-#include <boost/asio.hpp>
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/signal_set.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/noncopyable.hpp>
 
 #include <ndn-cxx/face.hpp>
@@ -24,9 +40,8 @@
 class NdnTrafficServer : boost::noncopyable
 {
 public:
-
   explicit
-  NdnTrafficServer(char* programName)
+  NdnTrafficServer(const char* programName)
     : m_logger("NdnTrafficServer")
     , m_programName(programName)
     , m_hasError(false)
@@ -35,9 +50,9 @@
     , m_nMaximumInterests(-1)
     , m_nInterestsReceived(0)
     , m_contentDelay(time::milliseconds(-1))
+    , m_instanceId(std::to_string(std::rand()))
     , m_face(m_ioService)
   {
-    m_instanceId = boost::lexical_cast<std::string>(std::rand());
   }
 
   class DataTrafficConfiguration
@@ -55,54 +70,54 @@
     void
     printTrafficConfiguration(Logger& logger)
     {
-      std::string detail = "";
-      if (m_name != "")
+      std::string detail;
+
+      if (!m_name.empty())
         detail += "Name=" + m_name + ", ";
       if (m_contentType >= 0)
-        detail += "ContentType=" + boost::lexical_cast<std::string>(m_contentType) + ", ";
+        detail += "ContentType=" + std::to_string(m_contentType) + ", ";
       if (m_freshnessPeriod >= time::milliseconds(0))
         detail += "FreshnessPeriod=" +
-          boost::lexical_cast<std::string>(static_cast<int>(m_freshnessPeriod.count())) + ", ";
+                  std::to_string(static_cast<int>(m_freshnessPeriod.count())) + ", ";
       if (m_contentBytes >= 0)
-        detail += "ContentBytes=" + boost::lexical_cast<std::string>(m_contentBytes) + ", ";
+        detail += "ContentBytes=" + std::to_string(m_contentBytes) + ", ";
       if (m_contentDelay >= time::milliseconds(0))
-        detail += "ContentDelay=" +
-          boost::lexical_cast<std::string>(m_contentDelay.count()) + ", ";
-      if (m_content != "")
+        detail += "ContentDelay=" + std::to_string(m_contentDelay.count()) + ", ";
+      if (!m_content.empty())
         detail += "Content=" + m_content + ", ";
       if (detail.length() >= 2)
         detail = detail.substr(0, detail.length() - 2);
+
       logger.log(detail, false, false);
     }
 
-
     bool
-    extractParameterValue(const std::string& detail,
-                          std::string& parameter,
-                          std::string& value)
+    extractParameterValue(const std::string& detail, std::string& parameter, std::string& value)
     {
       std::string allowedCharacters = ":/+._-%";
+      std::size_t i = 0;
+
       parameter = "";
       value = "";
-      int i = 0;
-      while (detail[i] != '=' && i < detail.length())
-        {
-          parameter += detail[i];
-          i++;
-        }
+      while (detail[i] != '=' && i < detail.length()) {
+        parameter += detail[i];
+        i++;
+      }
       if (i == detail.length())
         return false;
+
       i++;
       while ((std::isalnum(detail[i]) ||
               allowedCharacters.find(detail[i]) != std::string::npos) &&
-              i < detail.length())
-        {
-          value += detail[i];
-          i++;
-        }
-      if(parameter == "" || value == "")
+             i < detail.length()) {
+        value += detail[i];
+        i++;
+      }
+
+      if (parameter.empty() || value.empty())
         return false;
-      return true;
+      else
+        return true;
     }
 
     bool
@@ -116,22 +131,22 @@
           if (parameter == "Name")
             m_name = value;
           else if (parameter == "ContentType")
-            m_contentType = boost::lexical_cast<int>(value);
+            m_contentType = std::stoi(value);
           else if (parameter == "FreshnessPeriod")
-            m_freshnessPeriod = time::milliseconds(boost::lexical_cast<int>(value));
+            m_freshnessPeriod = time::milliseconds(std::stoi(value));
           else if (parameter == "ContentDelay")
-            m_contentDelay = time::milliseconds(boost::lexical_cast<int>(value));
+            m_contentDelay = time::milliseconds(std::stoi(value));
           else if (parameter == "ContentBytes")
-            m_contentBytes = boost::lexical_cast<int>(value);
+            m_contentBytes = std::stoi(value);
           else if (parameter == "Content")
             m_content = value;
           else
-            logger.log("Line " + boost::lexical_cast<std::string>(lineNumber) +
+            logger.log("Line " + std::to_string(lineNumber) +
                        " \t- Invalid Parameter='" + parameter + "'", false, true);
         }
       else
         {
-          logger.log("Line " + boost::lexical_cast<std::string>(lineNumber) +
+          logger.log("Line " + std::to_string(lineNumber) +
             " \t- Improper Traffic Configuration Line - " + detail, false, true);
           return false;
         }
@@ -144,6 +159,7 @@
       return true;
     }
 
+  private:
     std::string m_name;
     int m_contentType;
     time::milliseconds m_freshnessPeriod;
@@ -152,22 +168,25 @@
     std::string m_content;
     int m_nInterestsReceived;
 
+    friend class NdnTrafficServer;
   };
 
   void
-  usage()
+  usage() const
   {
-
-    std::cout << "\nUsage: " << m_programName << " [options] <Traffic_Configuration_File>\n"
-      "Respond to Interest as per provided Traffic Configuration File\n"
-      "Multiple Prefixes can be configured for handling.\n"
-      "Set environment variable NDN_TRAFFIC_LOGFOLDER for redirecting output to a log.\n"
-      "  [-d interval] - set delay before responding to interest in milliseconds\n"
-      "  [-c count]    - specify maximum number of interests to be satisfied\n"
-      "  [-q]          - quiet logging - no interest reception/data generation messages\n"
-      "  [-h]          - print help and exit\n\n";
-    exit(1);
-
+    std::cout << "Usage:\n"
+              << "  " << m_programName << " [options] <Traffic_Configuration_File>\n"
+              << "\n"
+              << "Respond to Interests as per provided Traffic Configuration File.\n"
+              << "Multiple prefixes can be configured for handling.\n"
+              << "Set environment variable NDN_TRAFFIC_LOGFOLDER to redirect output to a log file.\n"
+              << "\n"
+              << "Options:\n"
+              << "  [-d interval] - set delay before responding to interest, in milliseconds\n"
+              << "  [-c count]    - specify maximum number of interests to be satisfied\n"
+              << "  [-q]          - quiet mode: no interest reception/data generation logging\n"
+              << "  [-h]          - print this help text and exit\n";
+    exit(EXIT_FAILURE);
   }
 
   void
@@ -193,7 +212,7 @@
   }
 
   void
-  setConfigurationFile(char* configurationFile)
+  setConfigurationFile(const char* configurationFile)
   {
     m_configurationFile = configurationFile;
   }
@@ -208,13 +227,12 @@
   signalHandler()
   {
     logStatistics();
+
     m_logger.shutdownLogger();
     m_face.shutdown();
     m_ioService.stop();
-    if (m_hasError)
-      exit(1);
-    else
-      exit(0);
+
+    exit(m_hasError ? EXIT_FAILURE : EXIT_SUCCESS);
   }
 
   void
@@ -222,19 +240,19 @@
   {
     m_logger.log("\n\n== Interest Traffic Report ==\n", false, true);
     m_logger.log("Total Traffic Pattern Types = " +
-      boost::lexical_cast<std::string>(m_trafficPatterns.size()), false, true);
+                 std::to_string(m_trafficPatterns.size()), false, true);
     m_logger.log("Total Interests Received    = " +
-      boost::lexical_cast<std::string>(m_nInterestsReceived), false, true);
+                 std::to_string(m_nInterestsReceived), false, true);
+
     if (m_nInterestsReceived < m_nMaximumInterests)
       m_hasError = true;
-    for (int patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
+
+    for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
       {
-        m_logger.log("\nTraffic Pattern Type #" +
-          boost::lexical_cast<std::string>(patternId + 1), false, true);
+        m_logger.log("\nTraffic Pattern Type #" + std::to_string(patternId + 1), false, true);
         m_trafficPatterns[patternId].printTrafficConfiguration(m_logger);
-        m_logger.log("Total Interests Received    = " +
-          boost::lexical_cast<std::string>(
-            m_trafficPatterns[patternId].m_nInterestsReceived) + "\n", false, true);
+        m_logger.log("Total Interests Received    = " + std::to_string(
+                       m_trafficPatterns[patternId].m_nInterestsReceived) + "\n", false, true);
       }
   }
 
@@ -250,10 +268,10 @@
     std::string patternLine;
     std::ifstream patternFile;
     m_logger.log("Analyzing Traffic Configuration File: " + m_configurationFile, true, true);
+
     patternFile.open(m_configurationFile.c_str());
     if (patternFile.is_open())
       {
-        int patternId = 0;
         int lineNumber = 0;
         while (getline(patternFile, patternLine))
           {
@@ -262,15 +280,12 @@
               {
                 DataTrafficConfiguration dataData;
                 bool shouldSkipLine = false;
-                patternId++;
                 if (dataData.processConfigurationDetail(patternLine, m_logger, lineNumber))
                   {
                     while (getline(patternFile, patternLine) && std::isalpha(patternLine[0]))
                       {
                         lineNumber++;
-                        if (!dataData.processConfigurationDetail(patternLine,
-                                                                 m_logger,
-                                                                 lineNumber))
+                        if (!dataData.processConfigurationDetail(patternLine, m_logger, lineNumber))
                           {
                             shouldSkipLine = true;
                             break;
@@ -288,18 +303,20 @@
               }
           }
         patternFile.close();
+
         if (!checkTrafficPatternCorrectness())
           {
-            m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper- " +
+            m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper - " +
                          m_configurationFile, false, true);
             m_logger.shutdownLogger();
-            exit(1);
+            exit(EXIT_FAILURE);
           }
+
         m_logger.log("Traffic Configuration File Processing Completed\n", true, false);
-        for (patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
+        for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
           {
             m_logger.log("Traffic Pattern Type #" +
-              boost::lexical_cast<std::string>(patternId + 1), false, false);
+                         std::to_string(patternId + 1), false, false);
             m_trafficPatterns[patternId].printTrafficConfiguration(m_logger);
             m_logger.log("", false, false);
           }
@@ -309,7 +326,7 @@
         m_logger.log("ERROR - Unable To Open Traffic Configuration File: " +
           m_configurationFile, false, true);
         m_logger.shutdownLogger();
-        exit(1);
+        exit(EXIT_FAILURE);
       }
   }
 
@@ -327,7 +344,7 @@
             m_logger.log("ERROR - Traffic Configuration File Is Not A Regular File: " +
               m_configurationFile, false, true);
             m_logger.shutdownLogger();
-            exit(1);
+            exit(EXIT_FAILURE);
           }
       }
     else
@@ -335,15 +352,15 @@
         m_logger.log("ERROR - Traffic Configuration File Does Not Exist: " +
           m_configurationFile, false, true);
         m_logger.shutdownLogger();
-        exit(1);
+        exit(EXIT_FAILURE);
       }
   }
 
   static std::string
-  getRandomByteString(int randomSize)
+  getRandomByteString(std::size_t randomSize)
   {
     std::string randomString;
-    for (int i = 0; i < randomSize; i++)
+    for (std::size_t i = 0; i < randomSize; i++)
       randomString += static_cast<char>(std::rand() % 128);
     return randomString;
   }
@@ -361,24 +378,26 @@
         if (m_trafficPatterns[patternId].m_freshnessPeriod >= time::milliseconds(0))
           data.setFreshnessPeriod(m_trafficPatterns[patternId].m_freshnessPeriod);
 
-        std::string content = "";
+        std::string content;
         if (m_trafficPatterns[patternId].m_contentBytes >= 0)
           content = getRandomByteString(m_trafficPatterns[patternId].m_contentBytes);
-        if (m_trafficPatterns[patternId].m_content != "")
+        if (!m_trafficPatterns[patternId].m_content.empty())
           content = m_trafficPatterns[patternId].m_content;
 
         data.setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.length());
         m_keyChain.sign(data);
         m_nInterestsReceived++;
         m_trafficPatterns[patternId].m_nInterestsReceived++;
-        std::string logLine = "Interest Received          - PatternType=" +
-          boost::lexical_cast<std::string>(patternId + 1);
-        logLine += ", GlobalID=" + boost::lexical_cast<std::string>(m_nInterestsReceived);
-        logLine += ", LocalID=" +
-          boost::lexical_cast<std::string>(m_trafficPatterns[patternId].m_nInterestsReceived);
-        logLine += ", Name=" + m_trafficPatterns[patternId].m_name;
-        if (!m_hasQuietLogging)
+
+        if (!m_hasQuietLogging) {
+          std::string logLine =
+            "Interest Received          - PatternType=" + std::to_string(patternId + 1) +
+            ", GlobalID=" + std::to_string(m_nInterestsReceived) +
+            ", LocalID=" + std::to_string(m_trafficPatterns[patternId].m_nInterestsReceived) +
+            ", Name=" + m_trafficPatterns[patternId].m_name;
           m_logger.log(logLine, true, false);
+        }
+
         if (m_trafficPatterns[patternId].m_contentDelay > time::milliseconds(-1))
           usleep(m_trafficPatterns[patternId].m_contentDelay.count() * 1000);
         if (m_contentDelay > time::milliseconds(-1))
@@ -397,11 +416,11 @@
   void
   onRegisterFailed(const ndn::Name& prefix, const std::string& reason, int patternId)
   {
-    std::string logLine = "";
-    logLine += "Prefix Registration Failed - PatternType=" +
-      boost::lexical_cast<std::string>(patternId + 1);
+    std::string logLine;
+    logLine += "Prefix Registration Failed - PatternType=" + std::to_string(patternId + 1);
     logLine += ", Name=" + m_trafficPatterns[patternId].m_name;
     m_logger.log(logLine, true, true);
+
     m_nRegistrationsFailed++;
     if (m_nRegistrationsFailed == m_trafficPatterns.size())
       {
@@ -415,6 +434,7 @@
   {
     boost::asio::signal_set signalSet(m_ioService, SIGINT, SIGTERM);
     signalSet.async_wait(bind(&NdnTrafficServer::signalHandler, this));
+
     m_logger.initializeLog(m_instanceId);
     initializeTrafficConfiguration();
     if (m_nMaximumInterests == 0)
@@ -424,22 +444,16 @@
         return;
       }
 
-    for (int patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
-      {
-        m_face.setInterestFilter(m_trafficPatterns[patternId].m_name,
-                                 bind(&NdnTrafficServer::onInterest,
-                                      this, _1, _2,
-                                      patternId),
-                                 bind(&NdnTrafficServer::onRegisterFailed,
-                                      this, _1, _2,
-                                      patternId));
-      }
+    for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
+      m_face.setInterestFilter(m_trafficPatterns[patternId].m_name,
+                               bind(&NdnTrafficServer::onInterest, this, _1, _2, patternId),
+                               bind(&NdnTrafficServer::onRegisterFailed, this, _1, _2, patternId));
 
     try {
       m_face.processEvents();
     }
-    catch (std::exception& e) {
-      m_logger.log("ERROR: " + static_cast<std::string>(e.what()), true, true);
+    catch (const std::exception& e) {
+      m_logger.log("ERROR: " + std::string(e.what()), true, true);
       m_logger.shutdownLogger();
       m_hasError = true;
       m_ioService.stop();
@@ -452,7 +466,7 @@
   std::string m_programName;
   bool m_hasError;
   bool m_hasQuietLogging;
-  int m_nRegistrationsFailed;
+  std::size_t m_nRegistrationsFailed;
   int m_nMaximumInterests;
   int m_nInterestsReceived;
   time::milliseconds m_contentDelay;
@@ -469,25 +483,26 @@
 int
 main(int argc, char* argv[])
 {
-  std::srand(std::time(0));
-  ndn::NdnTrafficServer ndnTrafficServer(argv[0]);
+  std::srand(std::time(nullptr));
+
+  ndn::NdnTrafficServer server(argv[0]);
   int option;
   while ((option = getopt(argc, argv, "hqc:d:")) != -1) {
     switch (option) {
     case 'h':
-      ndnTrafficServer.usage();
+      server.usage();
       break;
     case 'c':
-      ndnTrafficServer.setMaximumInterests(atoi(optarg));
+      server.setMaximumInterests(atoi(optarg));
       break;
     case 'd':
-      ndnTrafficServer.setContentDelay(atoi(optarg));
+      server.setContentDelay(atoi(optarg));
       break;
     case 'q':
-      ndnTrafficServer.setQuietLogging();
+      server.setQuietLogging();
       break;
     default:
-      ndnTrafficServer.usage();
+      server.usage();
       break;
     }
   }
@@ -495,14 +510,11 @@
   argc -= optind;
   argv += optind;
 
-  if (argv[0] == 0)
-    ndnTrafficServer.usage();
+  if (!argc)
+    server.usage();
 
-  ndnTrafficServer.setConfigurationFile(argv[0]);
-  ndnTrafficServer.run();
+  server.setConfigurationFile(argv[0]);
+  server.run();
 
-  if (ndnTrafficServer.hasError())
-    return 1;
-  else
-    return 0;
+  return server.hasError() ? EXIT_FAILURE : EXIT_SUCCESS;
 }
