diff --git a/src/encoding/tlv.hpp b/src/encoding/tlv.hpp
index 9cb1a0f..441bc99 100644
--- a/src/encoding/tlv.hpp
+++ b/src/encoding/tlv.hpp
@@ -195,7 +195,7 @@
       if (end - begin < 2)
         return false;
 
-      uint16_t value = *reinterpret_cast<const uint16_t*>(&*begin); // kind of dangerous... but should be efficient
+      uint16_t value = *reinterpret_cast<const uint16_t*>(&*begin);
       begin += 2;
       number = be16toh(value);
     }
@@ -204,7 +204,7 @@
       if (end - begin < 4)
         return false;
 
-      uint32_t value = *reinterpret_cast<const uint32_t*>(&*begin); // kind of dangerous... but should be efficient
+      uint32_t value = *reinterpret_cast<const uint32_t*>(&*begin);
       begin += 4;
       number = be32toh(value);
     }
@@ -227,8 +227,8 @@
 readType(InputIterator& begin, const InputIterator& end, uint32_t& type)
 {
   uint64_t number;
-  bool ok = readVarNumber(begin, end, number);
-  if (number > std::numeric_limits<uint32_t>::max())
+  bool isOk = readVarNumber(begin, end, number);
+  if (!isOk || number > std::numeric_limits<uint32_t>::max())
     {
       return false;
     }
@@ -255,7 +255,7 @@
       if (end - begin < 2)
         throw Error("Insufficient data during TLV processing");
 
-      uint16_t value = *reinterpret_cast<const uint16_t*>(&*begin); // kind of dangerous... but should be efficient
+      uint16_t value = *reinterpret_cast<const uint16_t*>(&*begin);
       begin += 2;
       return be16toh(value);
     }
@@ -264,7 +264,7 @@
       if (end - begin < 4)
         throw Error("Insufficient data during TLV processing");
 
-      uint32_t value = *reinterpret_cast<const uint32_t*>(&*begin); // kind of dangerous... but should be efficient
+      uint32_t value = *reinterpret_cast<const uint32_t*>(&*begin);
       begin += 4;
       return be32toh(value);
     }
@@ -423,7 +423,7 @@
       if (end - begin < 2)
         throw Error("Insufficient data during TLV processing");
 
-      uint16_t value = *reinterpret_cast<const uint16_t*>(&*begin); // kind of dangerous... but should be efficient
+      uint16_t value = *reinterpret_cast<const uint16_t*>(&*begin);
       begin += 2;
       return be16toh(value);
     }
@@ -432,7 +432,7 @@
       if (end - begin < 4)
         throw Error("Insufficient data during TLV processing");
 
-      uint32_t value = *reinterpret_cast<const uint32_t*>(&*begin); // kind of dangerous... but should be efficient
+      uint32_t value = *reinterpret_cast<const uint32_t*>(&*begin);
       begin += 4;
       return be32toh(value);
     }
diff --git a/src/interest.cpp b/src/interest.cpp
index 229e0fb..a49ee1f 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -27,20 +27,24 @@
 bool
 Interest::matchesName(const Name &name) const
 {
+  if (name.size() < m_name.size())
+    return false;
+
   if (!m_name.isPrefixOf(name))
     return false;
 
   if (getMinSuffixComponents() >= 0 &&
     // Add 1 for the implicit digest.
-      !(name.size() + 1 - m_name.size() >= getMinSuffixComponents()))
+      !(name.size() + 1 - m_name.size() >= static_cast<size_t>(getMinSuffixComponents())))
     return false;
 
   if (getMaxSuffixComponents() >= 0 &&
     // Add 1 for the implicit digest.
-      !(name.size() + 1 - m_name.size() <= getMaxSuffixComponents()))
+      !(name.size() + 1 - m_name.size() <= static_cast<size_t>(getMaxSuffixComponents())))
     return false;
 
-  if (!getExclude().empty() && name.size() > m_name.size() &&
+  if (!getExclude().empty() &&
+      name.size() > m_name.size() &&
       getExclude().isExcluded(name[m_name.size()]))
     return false;
 
diff --git a/src/name-component.cpp b/src/name-component.cpp
deleted file mode 100644
index 78f32c9..0000000
--- a/src/name-component.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * @author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * @author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#include "common.hpp"
-
-#include "name-component.hpp"
-
-#include "util/time.hpp"
-#include "util/string-helper.hpp"
-
-namespace ndn {
-namespace name {
-
-Component 
-Component::fromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset)
-{
-  std::string trimmedString(escapedString + beginOffset, escapedString + endOffset);
-  trim(trimmedString);
-  std::string value = unescape(trimmedString);
-        
-  if (value.find_first_not_of(".") == std::string::npos) {
-    // Special case for component of only periods.  
-    if (value.size() <= 2)
-      // Zero, one or two periods is illegal.  Ignore this component.
-      return Component();
-    else
-      // Remove 3 periods.
-      return Component((const uint8_t *)&value[3], value.size() - 3); 
-  }
-  else
-    return Component((const uint8_t *)&value[0], value.size()); 
-}
-
-void
-Component::toEscapedString(std::ostream& result) const
-{
-  const uint8_t *valuePtr = value();
-  size_t valueSize = value_size();
-  
-  bool gotNonDot = false;
-  for (unsigned i = 0; i < valueSize; ++i) {
-    if (valuePtr[i] != 0x2e) {
-      gotNonDot = true;
-      break;
-    }
-  }
-  if (!gotNonDot) {
-    // Special case for component of zero or more periods.  Add 3 periods.
-    result << "...";
-    for (size_t i = 0; i < valueSize; ++i)
-      result << '.';
-  }
-  else {
-    // In case we need to escape, set to upper case hex and save the previous flags.
-    std::ios::fmtflags saveFlags = result.flags(std::ios::hex | std::ios::uppercase);
-    
-    for (size_t i = 0; i < valueSize; ++i) {
-      uint8_t x = valuePtr[i];
-      // Check for 0-9, A-Z, a-z, (+), (-), (.), (_)
-      if ((x >= 0x30 && x <= 0x39) || (x >= 0x41 && x <= 0x5a) ||
-          (x >= 0x61 && x <= 0x7a) || x == 0x2b || x == 0x2d || 
-          x == 0x2e || x == 0x5f)
-        result << x;
-      else {
-        result << '%';
-        if (x < 16)
-          result << '0';
-        result << (unsigned int)x;
-      }
-    }
-    
-    // Restore.
-    result.flags(saveFlags);
-  }  
-}
-
-int
-Component::compare(const Component& other) const
-{
-  // Imitate ndn_Exclude_compareComponents.
-  if (value_size() < other.value_size())
-    return -1;
-  if (value_size() > other.value_size())
-    return 1;
-
-  if (value_size() == 0)
-    return 0;
-  
-  // The components are equal length.  Just do a byte compare.  
-  return std::memcmp(value(), other.value(), value_size());
-}
-
-// const Block &
-// wireEncode() const
-// {
-  
-// }
-
-} // namespace name
-} // namespace ndn
diff --git a/src/name-component.hpp b/src/name-component.hpp
index 238c2be..9ea09c5 100644
--- a/src/name-component.hpp
+++ b/src/name-component.hpp
@@ -13,6 +13,7 @@
 #include "common.hpp"
 #include "encoding/block.hpp"
 #include "encoding/encoding-buffer.hpp"
+#include "util/string-helper.hpp"
 
 namespace ndn {
 namespace name {
@@ -24,101 +25,77 @@
 {
 public:
   /// @brief Error that can be thrown from the block
-  struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
-  
+  struct Error : public std::runtime_error {
+    Error(const std::string& what) : std::runtime_error(what) {}
+  };
+
   /**
    * Create a new Name::Component with a null value.
    */
-  Component()
-    : Block(Tlv::NameComponent)
-  {    
-  }
+  Component();
 
   /**
    * @brief Directly create component from wire block
    *
-   * ATTENTION  wire MUST BE of type Tlv::Component. Any other value would cause an exception
+   * @throws Error if wire.type() is not Tlv::Component
    */
-  Component(const Block& wire)
-    : Block(wire)
-  {
-    if (type() != Tlv::NameComponent)
-      throw Error("Constructing name component from non name component TLV wire block");
-  }
-  
+  Component(const Block& wire);
+
   /**
    * Create a new Name::Component, taking another pointer to the Blob value.
    * @param value A blob with a pointer to an immutable array.  The pointer is copied.
    */
-  Component(const ConstBufferPtr &buffer)
-    : Block (Tlv::NameComponent, buffer)
-  {
-  }
-  
+  Component(const ConstBufferPtr& buffer);
+
   /**
    * Create a new Name::Component, copying the given value.
    * @param value The value byte array.
    */
-  Component(const Buffer& value) 
-    : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(value)))
-  {
-  }
+  Component(const Buffer& value);
 
   /**
    * Create a new Name::Component, copying the given value.
    * @param value Pointer to the value byte array.
    * @param valueLen Length of value.
    */
-  Component(const uint8_t *value, size_t valueLen) 
-    : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(value, valueLen)))
-  {
-  }
+  Component(const uint8_t *value, size_t valueLen);
 
   template<class InputIterator>
-  Component(InputIterator begin, InputIterator end)
-    : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(begin, end)))
-  {
-  }
+  Component(InputIterator begin, InputIterator end);
 
   explicit
-  Component(const char *str)
-    : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(str, ::strlen(str))))
-  {
-  }
+  Component(const char *str);
 
   explicit
-  Component(const std::string& str)
-    : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(str.begin(), str.end())))
-  {
-  }
-  
+  Component(const std::string& str);
+
   /**
    * @brief Fast encoding or block size estimation
    */
   template<bool T>
   size_t
-  wireEncode(EncodingImpl<T> &block) const;
-  
+  wireEncode(EncodingImpl<T>& block) const;
+
   /**
    * Make a Blob value by decoding the escapedString between beginOffset and endOffset according to the NDN URI Scheme.
-   * If the escaped string is "", "." or ".." then return a Blob with a null pointer, 
+   * If the escaped string is "", "." or ".." then return a Blob with a null pointer,
    * which means the component should be skipped in a URI name.
    * @param escapedString The escaped string.  It does not need to be null-terminated because we only scan to endOffset.
    * @param beginOffset The offset in escapedString of the beginning of the portion to decode.
    * @param endOffset The offset in escapedString of the end of the portion to decode.
    * @return The Blob value. If the escapedString is not a valid escaped component, then the Blob is a null pointer.
    */
-  static Component 
+  static Component
   fromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset);
 
   /**
    * Make a Blob value by decoding the escapedString according to the NDN URI Scheme.
-   * If the escaped string is "", "." or ".." then return a Blob with a null pointer, 
+   * If the escaped string is "", "." or ".." then return a Blob with a null pointer,
    * which means the component should be skipped in a URI name.
    * @param escapedString The null-terminated escaped string.
    * @return The Blob value. If the escapedString is not a valid escaped component, then the Blob is a null pointer.
    */
-  static Component 
+  static Component
   fromEscapedString(const char *escapedString)
   {
     return fromEscapedString(escapedString, 0, ::strlen(escapedString));
@@ -126,12 +103,12 @@
 
   /**
    * Make a Blob value by decoding the escapedString according to the NDN URI Scheme.
-   * If the escaped string is "", "." or ".." then return a Blob with a null pointer, 
+   * If the escaped string is "", "." or ".." then return a Blob with a null pointer,
    * which means the component should be skipped in a URI name.
    * @param escapedString The escaped string.
    * @return The Blob value. If the escapedString is not a valid escaped component, then the Blob is a null pointer.
    */
-  static Component 
+  static Component
   fromEscapedString(const std::string& escapedString)
   {
     return fromEscapedString(escapedString.c_str());
@@ -143,9 +120,9 @@
    * @param value the buffer with the value to escape
    * @param result the string stream to write to.
    */
-  void 
+  void
   toEscapedString(std::ostream& result) const;
-  
+
   /**
    * Convert the value by escaping characters according to the NDN URI Scheme.
    * This also adds "..." to a value with zero or more ".".
@@ -171,7 +148,7 @@
   {
     return toEscapedString();
   }
-    
+
   /**
    * @brief Interpret this name component as nonNegativeInteger
    *
@@ -202,7 +179,7 @@
    * @param number The non-negative number
    * @return The component value.
    */
-  static Component 
+  static Component
   fromNumber(uint64_t number);
 
   /**
@@ -228,14 +205,14 @@
   {
     return !hasValue();
   }
-    
+
   /**
    * Check if this is the same component as other.
    * @param other The other Component to compare with.
    * @return true if the components are equal, otherwise false.
    */
   bool
-  operator == (const Component& other) const { return equals(other); }
+  operator==(const Component& other) const { return equals(other); }
 
   /**
    * Check if this is not the same component as other.
@@ -243,8 +220,8 @@
    * @return true if the components are not equal, otherwise false.
    */
   bool
-  operator != (const Component& other) const { return !equals(other); }
-    
+  operator!=(const Component& other) const { return !equals(other); }
+
   /**
    * Compare this to the other Component using NDN canonical ordering.
    * @param other The other Component to compare with.
@@ -255,24 +232,6 @@
    */
   int
   compare(const Component& other) const;
-  
-  /**
-   * Return true if this is less than or equal to the other Component in the NDN canonical ordering.
-   * @param other The other Component to compare with.
-   *
-   * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
-   */
-  bool
-  operator <= (const Component& other) const { return compare(other) <= 0; }
-  
-  /**
-   * Return true if this is less than the other Component in the NDN canonical ordering.
-   * @param other The other Component to compare with.
-   *
-   * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
-   */
-  bool
-  operator < (const Component& other) const { return compare(other) < 0; }
 
   /**
    * Return true if this is less than or equal to the other Component in the NDN canonical ordering.
@@ -281,7 +240,25 @@
    * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
    */
   bool
-  operator >= (const Component& other) const { return compare(other) >= 0; }
+  operator<=(const Component& other) const { return compare(other) <= 0; }
+
+  /**
+   * Return true if this is less than the other Component in the NDN canonical ordering.
+   * @param other The other Component to compare with.
+   *
+   * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
+   */
+  bool
+  operator<(const Component& other) const { return compare(other) < 0; }
+
+  /**
+   * Return true if this is less than or equal to the other Component in the NDN canonical ordering.
+   * @param other The other Component to compare with.
+   *
+   * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
+   */
+  bool
+  operator>=(const Component& other) const { return compare(other) >= 0; }
 
   /**
    * Return true if this is greater than the other Component in the NDN canonical ordering.
@@ -290,21 +267,137 @@
    * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
    */
   bool
-  operator > (const Component& other) const { return compare(other) > 0; }
+  operator>(const Component& other) const { return compare(other) > 0; }
 
-  // 
+  //
   // !!! MUST NOT INCLUDE ANY DATA HERE !!!
   //
   // This class is just a helper and is directly reinterpret_cast'ed from Block
 };
 
-inline std::ostream &
-operator << (std::ostream &os, const Component &component)
+inline std::ostream&
+operator << (std::ostream& os, const Component& component)
 {
   component.toEscapedString(os);
   return os;
 }
 
+inline
+Component::Component()
+  : Block(Tlv::NameComponent)
+{
+}
+
+inline
+Component::Component(const Block& wire)
+  : Block(wire)
+{
+  if (type() != Tlv::NameComponent)
+    throw Error("Constructing name component from non name component TLV wire block");
+}
+
+inline
+Component::Component(const ConstBufferPtr& buffer)
+  : Block (Tlv::NameComponent, buffer)
+{
+}
+
+inline
+Component::Component(const Buffer& value)
+  : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(value)))
+{
+}
+
+inline
+Component::Component(const uint8_t *value, size_t valueLen)
+  : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(value, valueLen)))
+{
+}
+
+template<class InputIterator>
+inline
+Component::Component(InputIterator begin, InputIterator end)
+  : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(begin, end)))
+{
+}
+
+inline
+Component::Component(const char *str)
+  : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(str, ::strlen(str))))
+{
+}
+
+inline
+Component::Component(const std::string& str)
+  : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(str.begin(), str.end())))
+{
+}
+
+
+inline Component
+Component::fromEscapedString(const char* escapedString, size_t beginOffset, size_t endOffset)
+{
+  std::string trimmedString(escapedString + beginOffset, escapedString + endOffset);
+  trim(trimmedString);
+  std::string value = unescape(trimmedString);
+
+  if (value.find_first_not_of(".") == std::string::npos) {
+    // Special case for component of only periods.
+    if (value.size() <= 2)
+      // Zero, one or two periods is illegal.  Ignore this component.
+      return Component();
+    else
+      // Remove 3 periods.
+      return Component((const uint8_t *)&value[3], value.size() - 3);
+  }
+  else
+    return Component((const uint8_t *)&value[0], value.size());
+}
+
+
+inline void
+Component::toEscapedString(std::ostream& result) const
+{
+  const uint8_t *valuePtr = value();
+  size_t valueSize = value_size();
+
+  bool gotNonDot = false;
+  for (unsigned i = 0; i < valueSize; ++i) {
+    if (valuePtr[i] != 0x2e) {
+      gotNonDot = true;
+      break;
+    }
+  }
+  if (!gotNonDot) {
+    // Special case for component of zero or more periods.  Add 3 periods.
+    result << "...";
+    for (size_t i = 0; i < valueSize; ++i)
+      result << '.';
+  }
+  else {
+    // In case we need to escape, set to upper case hex and save the previous flags.
+    std::ios::fmtflags saveFlags = result.flags(std::ios::hex | std::ios::uppercase);
+
+    for (size_t i = 0; i < valueSize; ++i) {
+      uint8_t x = valuePtr[i];
+      // Check for 0-9, A-Z, a-z, (+), (-), (.), (_)
+      if ((x >= 0x30 && x <= 0x39) || (x >= 0x41 && x <= 0x5a) ||
+          (x >= 0x61 && x <= 0x7a) || x == 0x2b || x == 0x2d ||
+          x == 0x2e || x == 0x5f)
+        result << x;
+      else {
+        result << '%';
+        if (x < 16)
+          result << '0';
+        result << (unsigned int)x;
+      }
+    }
+
+    // Restore.
+    result.flags(saveFlags);
+  }
+}
+
 
 inline Component
 Component::fromNumber(uint64_t number)
@@ -334,6 +427,23 @@
   return toNumber();
 }
 
+inline int
+Component::compare(const Component& other) const
+{
+  // Imitate ndn_Exclude_compareComponents.
+  if (value_size() < other.value_size())
+    return -1;
+  if (value_size() > other.value_size())
+    return 1;
+
+  if (value_size() == 0)
+    return 0;
+
+  // The components are equal length.  Just do a byte compare.
+  return std::memcmp(value(), other.value(), value_size());
+}
+
+
 template<bool T>
 inline size_t
 Component::wireEncode(EncodingImpl<T>& block) const
diff --git a/src/name.cpp b/src/name.cpp
deleted file mode 100644
index cb8759b..0000000
--- a/src/name.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * @author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#include "common.hpp"
-
-#include "name.hpp"
-
-#include <algorithm>
-#include <cstring>
-
-#include "util/time.hpp"
-#include "util/string-helper.hpp"
-
-namespace ndn {
-
-void 
-Name::set(const char *uri_cstr) 
-{
-  clear();
-  
-  std::string uri = uri_cstr;
-  trim(uri);
-  if (uri.size() == 0)
-    return;
-
-  size_t iColon = uri.find(':');
-  if (iColon != std::string::npos) {
-    // Make sure the colon came before a '/'.
-    size_t iFirstSlash = uri.find('/');
-    if (iFirstSlash == std::string::npos || iColon < iFirstSlash) {
-      // Omit the leading protocol such as ndn:
-      uri.erase(0, iColon + 1);
-      trim(uri);
-    }
-  }
-    
-  // Trim the leading slash and possibly the authority.
-  if (uri[0] == '/') {
-    if (uri.size() >= 2 && uri[1] == '/') {
-      // Strip the authority following "//".
-      size_t iAfterAuthority = uri.find('/', 2);
-      if (iAfterAuthority == std::string::npos)
-        // Unusual case: there was only an authority.
-        return;
-      else {
-        uri.erase(0, iAfterAuthority + 1);
-        trim(uri);
-      }
-    }
-    else {
-      uri.erase(0, 1);
-      trim(uri);
-    }
-  }
-
-  size_t iComponentStart = 0;
-  
-  // Unescape the components.
-  while (iComponentStart < uri.size()) {
-    size_t iComponentEnd = uri.find("/", iComponentStart);
-    if (iComponentEnd == std::string::npos)
-      iComponentEnd = uri.size();
-    
-    Component component = Component::fromEscapedString(&uri[0], iComponentStart, iComponentEnd);
-    // Ignore illegal components.  This also gets rid of a trailing '/'.
-    if (!component.empty())
-      append(Component(component));
-    
-    iComponentStart = iComponentEnd + 1;
-  }
-}
-
-Name&
-Name::append(const Name& name)
-{
-  if (&name == this)
-    // Copying from this name, so need to make a copy first.
-    return append(Name(name));
-
-  for (size_t i = 0; i < name.size(); ++i)
-    append(name.at(i));
-  
-  return *this;
-}
-
-Name
-Name::getSubName(size_t iStartComponent, size_t nComponents) const
-{
-  Name result;
-  
-  size_t iEnd = iStartComponent + nComponents;
-  for (size_t i = iStartComponent; i < iEnd && i < size(); ++i)
-    result.append(at(i));
-  
-  return result;
-}
-
-Name
-Name::getSubName(size_t iStartComponent) const
-{
-  Name result;
-  
-  for (size_t i = iStartComponent; i < size(); ++i)
-    result.append(at(i));
-  
-  return result;
-}
-
-bool 
-Name::equals(const Name& name) const
-{
-  if (size() != name.size())
-    return false;
-
-  for (size_t i = 0; i < size(); ++i) {
-    if (at(i) != name.at(i))
-      return false;
-  }
-
-  return true;
-}
-
-bool 
-Name::isPrefixOf(const Name& name) const
-{
-  // This name is longer than the name we are checking it against.
-  if (size() > name.size())
-    return false;
-
-  // Check if at least one of given components doesn't match.
-  for (size_t i = 0; i < size(); ++i) {
-    if (at(i) != name.at(i))
-      return false;
-  }
-
-  return true;
-}
-
-
-int
-Name::compare(const Name& other) const
-{
-  for (size_t i = 0; i < size() && i < other.size(); ++i) {
-    int comparison = at(i).compare(other.at(i));
-    if (comparison == 0)
-      // The components at this index are equal, so check the next components.
-      continue;
-    
-    // Otherwise, the result is based on the components at this index.
-    return comparison;
-  }
-  
-  // The components up to min(this.size(), other.size()) are equal, so the shorter name is less.
-  if (size() < other.size())
-    return -1;
-  else if (size() > other.size())
-    return 1;
-  else
-    return 0;
-}
-
-std::ostream&
-operator << (std::ostream& os, const Name& name)
-{
-  if (name.empty())
-    {
-      os << "/";
-    }
-  else
-    {
-      for (Name::const_iterator i = name.begin(); i != name.end(); i++) {
-        os << "/";
-        i->toEscapedString(os);
-      }
-    }
-  
-  return os;
-}
-
-} // namespace ndn
diff --git a/src/name.hpp b/src/name.hpp
index aea084b..5a8dfcf 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -26,7 +26,11 @@
 class Name : public ptr_lib::enable_shared_from_this<Name> {
 public:
   /// @brief Error that can be thrown from the block
-  struct Error : public name::Component::Error { Error(const std::string &what) : name::Component::Error(what) {} };
+  class Error : public name::Component::Error {
+  public:
+    Error(const std::string& what)
+      : name::Component::Error(what) {}
+  };
 
   typedef name::Component Component;
 
@@ -65,7 +69,7 @@
    * @endcode
    */
   explicit
-  Name(const Block &wire)
+  Name(const Block& wire)
   {
     m_nameBlock = wire;
     m_nameBlock.parse();
@@ -94,13 +98,13 @@
    */
   template<bool T>
   size_t
-  wireEncode(EncodingImpl<T> &block) const;
+  wireEncode(EncodingImpl<T>& block) const;
 
-  const Block &
+  const Block&
   wireEncode() const;
 
   void
-  wireDecode(const Block &wire);
+  wireDecode(const Block& wire);
 
   /**
    * @brief Check if already has wire
@@ -130,7 +134,7 @@
    * @return This name so that you can chain calls to append.
    */
   Name&
-  append(const uint8_t *value, size_t valueLength)
+  append(const uint8_t* value, size_t valueLength)
   {
     m_nameBlock.push_back(Component(value, valueLength));
     return *this;
@@ -148,26 +152,15 @@
     return *this;
   }
 
-  // /**
-  //  * Append a new component, copying from value.
-  //  * @return This name so that you can chain calls to append.
-  //  */
-  // Name&
-  // append(const Buffer& value)
-  // {
-  //   m_nameBlock.push_back(value);
-  //   return *this;
-  // }
-
   Name&
-  append(const ConstBufferPtr &value)
+  append(const ConstBufferPtr& value)
   {
     m_nameBlock.push_back(value);
     return *this;
   }
 
   Name&
-  append(const Component &value)
+  append(const Component& value)
   {
     m_nameBlock.push_back(value);
     return *this;
@@ -181,14 +174,14 @@
    * converted from string, each having different outcomes
    */
   Name&
-  append(const char *value)
+  append(const char* value)
   {
     m_nameBlock.push_back(Component(value));
     return *this;
   }
 
   Name&
-  append(const Block &value)
+  append(const Block& value)
   {
     if (value.type() == Tlv::NameComponent)
       m_nameBlock.push_back(value);
@@ -310,12 +303,6 @@
   bool
   isPrefixOf(const Name& name) const;
 
-  bool
-  match(const Name& name) const
-  {
-    return isPrefixOf(name);
-  }
-
   //
   // vector equivalent interface.
   //
@@ -348,7 +335,7 @@
   }
 
   const Component&
-  operator [] (ssize_t i) const
+  operator[](ssize_t i) const
   {
     return get(i);
   }
@@ -364,7 +351,8 @@
   const Component&
   at(ssize_t i) const
   {
-    if ((i >= 0 && i >= size()) || (i < 0 && i < -size()))
+    if ((i >= 0 && static_cast<size_t>(i) >= size()) ||
+        (i < 0  && static_cast<size_t>(-i) > size()))
       throw Error("Requested component does not exist (out of bounds)");
 
     return get(i);
@@ -395,7 +383,7 @@
    * @param component The component of type T.
    */
   template<class T> void
-  push_back(const T &component)
+  push_back(const T& component)
   {
     append(component);
   }
@@ -406,7 +394,7 @@
    * @return true if the names are equal, otherwise false.
    */
   bool
-  operator == (const Name &name) const { return equals(name); }
+  operator==(const Name& name) const { return equals(name); }
 
   /**
    * Check if this name has the same component count and components as the given name.
@@ -414,7 +402,7 @@
    * @return true if the names are not equal, otherwise false.
    */
   bool
-  operator != (const Name &name) const { return !equals(name); }
+  operator!=(const Name& name) const { return !equals(name); }
 
   /**
    * Return true if this is less than or equal to the other Name in the NDN canonical ordering.
@@ -423,7 +411,7 @@
    * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
    */
   bool
-  operator <= (const Name& other) const { return compare(other) <= 0; }
+  operator<=(const Name& other) const { return compare(other) <= 0; }
 
   /**
    * Return true if this is less than the other Name in the NDN canonical ordering.
@@ -432,7 +420,7 @@
    * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
    */
   bool
-  operator < (const Name& other) const { return compare(other) < 0; }
+  operator<(const Name& other) const { return compare(other) < 0; }
 
   /**
    * Return true if this is less than or equal to the other Name in the NDN canonical ordering.
@@ -441,7 +429,7 @@
    * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
    */
   bool
-  operator >= (const Name& other) const { return compare(other) >= 0; }
+  operator>=(const Name& other) const { return compare(other) >= 0; }
 
   /**
    * Return true if this is greater than the other Name in the NDN canonical ordering.
@@ -450,7 +438,7 @@
    * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
    */
   bool
-  operator > (const Name& other) const { return compare(other) > 0; }
+  operator>(const Name& other) const { return compare(other) > 0; }
 
   //
   // Iterator interface to name components.
@@ -498,14 +486,21 @@
   mutable Block m_nameBlock;
 };
 
-std::ostream&
-operator<<(std::ostream& os, const Name& name);
-
-inline Name&
-Name::appendVersion()
+inline std::ostream&
+operator<<(std::ostream& os, const Name& name)
 {
-  appendNumber(time::toUnixTimestamp(time::system_clock::now()).count());
-  return *this;
+  if (name.empty())
+    {
+      os << "/";
+    }
+  else
+    {
+      for (Name::const_iterator i = name.begin(); i != name.end(); i++) {
+        os << "/";
+        i->toEscapedString(os);
+      }
+    }
+  return os;
 }
 
 inline std::string
@@ -526,25 +521,181 @@
   return is;
 }
 
+
+inline void
+Name::set(const char* uri_cstr)
+{
+  clear();
+
+  std::string uri = uri_cstr;
+  trim(uri);
+  if (uri.size() == 0)
+    return;
+
+  size_t iColon = uri.find(':');
+  if (iColon != std::string::npos) {
+    // Make sure the colon came before a '/'.
+    size_t iFirstSlash = uri.find('/');
+    if (iFirstSlash == std::string::npos || iColon < iFirstSlash) {
+      // Omit the leading protocol such as ndn:
+      uri.erase(0, iColon + 1);
+      trim(uri);
+    }
+  }
+
+  // Trim the leading slash and possibly the authority.
+  if (uri[0] == '/') {
+    if (uri.size() >= 2 && uri[1] == '/') {
+      // Strip the authority following "//".
+      size_t iAfterAuthority = uri.find('/', 2);
+      if (iAfterAuthority == std::string::npos)
+        // Unusual case: there was only an authority.
+        return;
+      else {
+        uri.erase(0, iAfterAuthority + 1);
+        trim(uri);
+      }
+    }
+    else {
+      uri.erase(0, 1);
+      trim(uri);
+    }
+  }
+
+  size_t iComponentStart = 0;
+
+  // Unescape the components.
+  while (iComponentStart < uri.size()) {
+    size_t iComponentEnd = uri.find("/", iComponentStart);
+    if (iComponentEnd == std::string::npos)
+      iComponentEnd = uri.size();
+
+    Component component = Component::fromEscapedString(&uri[0], iComponentStart, iComponentEnd);
+    // Ignore illegal components.  This also gets rid of a trailing '/'.
+    if (!component.empty())
+      append(Component(component));
+
+    iComponentStart = iComponentEnd + 1;
+  }
+}
+
+inline Name&
+Name::append(const Name& name)
+{
+  if (&name == this)
+    // Copying from this name, so need to make a copy first.
+    return append(Name(name));
+
+  for (size_t i = 0; i < name.size(); ++i)
+    append(name.at(i));
+
+  return *this;
+}
+
+inline Name&
+Name::appendVersion()
+{
+  appendNumber(time::toUnixTimestamp(time::system_clock::now()).count());
+  return *this;
+}
+
+inline Name
+Name::getSubName(size_t iStartComponent, size_t nComponents) const
+{
+  Name result;
+
+  size_t iEnd = iStartComponent + nComponents;
+  for (size_t i = iStartComponent; i < iEnd && i < size(); ++i)
+    result.append(at(i));
+
+  return result;
+}
+
+inline Name
+Name::getSubName(size_t iStartComponent) const
+{
+  Name result;
+
+  for (size_t i = iStartComponent; i < size(); ++i)
+    result.append(at(i));
+
+  return result;
+}
+
+inline bool
+Name::equals(const Name& name) const
+{
+  if (size() != name.size())
+    return false;
+
+  for (size_t i = 0; i < size(); ++i) {
+    if (at(i) != name.at(i))
+      return false;
+  }
+
+  return true;
+}
+
+inline bool
+Name::isPrefixOf(const Name& name) const
+{
+  // This name is longer than the name we are checking it against.
+  if (size() > name.size())
+    return false;
+
+  // Check if at least one of given components doesn't match.
+  for (size_t i = 0; i < size(); ++i) {
+    if (at(i) != name.at(i))
+      return false;
+  }
+
+  return true;
+}
+
+
+inline int
+Name::compare(const Name& other) const
+{
+  for (size_t i = 0; i < size() && i < other.size(); ++i) {
+    int comparison = at(i).compare(other.at(i));
+    if (comparison == 0)
+      // The components at this index are equal, so check the next components.
+      continue;
+
+    // Otherwise, the result is based on the components at this index.
+    return comparison;
+  }
+
+  // The components up to min(this.size(), other.size()) are equal, so the shorter name is less.
+  if (size() < other.size())
+    return -1;
+  else if (size() > other.size())
+    return 1;
+  else
+    return 0;
+}
+
+
+
 template<bool T>
 inline size_t
 Name::wireEncode(EncodingImpl<T>& blk) const
 {
   size_t total_len = 0;
 
-  for (const_reverse_iterator i = rbegin ();
-       i != rend ();
+  for (const_reverse_iterator i = rbegin();
+       i != rend();
        ++i)
     {
-      total_len += i->wireEncode (blk);
+      total_len += i->wireEncode(blk);
     }
 
-  total_len += blk.prependVarNumber (total_len);
-  total_len += blk.prependVarNumber (Tlv::Name);
+  total_len += blk.prependVarNumber(total_len);
+  total_len += blk.prependVarNumber(Tlv::Name);
   return total_len;
 }
 
-inline const Block &
+inline const Block&
 Name::wireEncode() const
 {
   if (m_nameBlock.hasWire())
@@ -563,7 +714,7 @@
 }
 
 inline void
-Name::wireDecode(const Block &wire)
+Name::wireDecode(const Block& wire)
 {
   if (wire.type() != Tlv::Name)
     throw Tlv::Error("Unexpected TLV type when decoding Name");
diff --git a/src/security/identity-certificate.cpp b/src/security/identity-certificate.cpp
index 5fddbfc..b4d5cb5 100644
--- a/src/security/identity-certificate.cpp
+++ b/src/security/identity-certificate.cpp
@@ -17,9 +17,8 @@
 bool
 IdentityCertificate::isCorrectName(const Name& name)
 {
-  int i = name.size() - 1;
-  
   string idString("ID-CERT");
+  int i = name.size() - 1;
   for (; i >= 0; i--) {
     if(name.get(i).toEscapedString() == idString)
       break;
@@ -28,7 +27,7 @@
   if (i < 0)
     return false;
   
-  int keyIdx = 0;
+  size_t keyIdx = 0;
   string keyString("KEY");
   for (; keyIdx < name.size(); keyIdx++) {
     if(name.get(keyIdx).toEscapedString() == keyString)
@@ -59,11 +58,11 @@
 Name
 IdentityCertificate::certificateNameToPublicKeyName(const Name& certificateName)
 {
-  int i = certificateName.size() - 1;
   string idString("ID-CERT");
   bool foundIdString = false;
-  for (; i >= 0; i--) {
-    if (certificateName.get(i).toEscapedString() == idString)
+  size_t idCertComponentIndex = certificateName.size() - 1;
+  for (; idCertComponentIndex + 1 > 0; --idCertComponentIndex) {
+    if (certificateName.get(idCertComponentIndex).toEscapedString() == idString)
       {
         foundIdString = true;
         break;
@@ -73,11 +72,12 @@
   if(!foundIdString)
     throw Error("Incorrect identity certificate name " + certificateName.toUri());
     
-  Name tmpName = certificateName.getSubName(0, i);    
+  Name tmpName = certificateName.getSubName(0, idCertComponentIndex);
   string keyString("KEY");
   bool foundKeyString = false;
-  for (i = 0; i < tmpName.size(); i++) {
-    if (tmpName.get(i).toEscapedString() == keyString)
+  size_t keyComponentIndex = 0;
+  for (; keyComponentIndex < tmpName.size(); keyComponentIndex++) {
+    if (tmpName.get(keyComponentIndex).toEscapedString() == keyString)
       {
         foundKeyString = true;
         break;
@@ -86,8 +86,11 @@
 
   if(!foundKeyString)
     throw Error("Incorrect identity certificate name " + certificateName.toUri());
-  
-  return tmpName.getSubName(0, i).append(tmpName.getSubName(i + 1, tmpName.size() - i - 1));
+
+  return tmpName
+           .getSubName(0, keyComponentIndex)
+           .append(tmpName.getSubName(keyComponentIndex + 1,
+                                      tmpName.size() - keyComponentIndex - 1));
 }
 
 } // namespace ndn
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index aeb34dd..393355f 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -337,8 +337,8 @@
 
 //   sqlite3_stmt *statement;
 //   sqlite3_prepare_v2(m_database, 
-//                       "INSERT OR REPLACE INTO Certificate (cert_name, cert_issuer, identity_name, key_identifier, not_before, not_after, certificate_data)\
-//                        values (?, ?, ?, ?, datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), ?)",
+//                       "INSERT OR REPLACE INTO Certificate (cert_name, cert_issuer, identity_name, key_identifier, not_before, not_after, certificate_data) "
+//                        "VALUES (?, ?, ?, ?, datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), ?)",
 //                       -1, &statement, 0);
 
 //   _LOG_DEBUG("certName: " << certificateName);
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 82de103..be166e5 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -249,7 +249,7 @@
           const uint8_t* p1 = buffer->buf();
           const uint8_t* p2 = sigValue.value();
 
-          for(int i = 0; i < crypto::SHA256_DIGEST_SIZE; i++)
+          for(size_t i = 0; i < crypto::SHA256_DIGEST_SIZE; i++)
             if(p1[i] != p2[i]) 
               return false;
           return true;
diff --git a/src/util/regex/regex-backref-matcher.hpp b/src/util/regex/regex-backref-matcher.hpp
index 5ae5f35..e2eabe8 100644
--- a/src/util/regex/regex-backref-matcher.hpp
+++ b/src/util/regex/regex-backref-matcher.hpp
@@ -30,9 +30,6 @@
 protected:
   virtual void 
   compile();
-    
-private:
-  int m_refNum;
 };
 
 } // namespace ndn
diff --git a/src/util/regex/regex-component-matcher.hpp b/src/util/regex/regex-component-matcher.hpp
index b102316..50cb8de 100644
--- a/src/util/regex/regex-component-matcher.hpp
+++ b/src/util/regex/regex-component-matcher.hpp
@@ -72,7 +72,7 @@
   m_pseudoMatcher.clear();
   m_pseudoMatcher.push_back(ptr_lib::make_shared<RegexPseudoMatcher>());
 
-  for (int i = 1; i < m_componentRegex.mark_count(); i++)
+  for (size_t i = 1; i < m_componentRegex.mark_count(); i++)
     {
       ptr_lib::shared_ptr<RegexPseudoMatcher> pMatcher = ptr_lib::make_shared<RegexPseudoMatcher>();
       m_pseudoMatcher.push_back(pMatcher);
@@ -102,7 +102,7 @@
       std::string targetStr = name.get(offset).toEscapedString();
       if(boost::regex_match(targetStr, subResult, m_componentRegex))
         {
-          for (int i = 1; i < m_componentRegex.mark_count(); i++)
+          for (size_t i = 1; i < m_componentRegex.mark_count(); i++)
             {
               m_pseudoMatcher[i]->resetMatchResult();
               m_pseudoMatcher[i]->setMatchResult(subResult[i]);
diff --git a/src/util/regex/regex-component-set-matcher.hpp b/src/util/regex/regex-component-set-matcher.hpp
index ffb4c6d..857c59e 100644
--- a/src/util/regex/regex-component-set-matcher.hpp
+++ b/src/util/regex/regex-component-set-matcher.hpp
@@ -107,9 +107,9 @@
 inline void 
 RegexComponentSetMatcher::compileSingleComponent()
 {
-  int end = extractComponent(1);
+  size_t end = extractComponent(1);
 
-  if(m_expr.size() != end)
+  if (m_expr.size() != end)
     {
       throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compileSingleComponent: ")
                                 + m_expr);
diff --git a/src/util/regex/regex-matcher.hpp b/src/util/regex/regex-matcher.hpp
index baa8bf3..0d34311 100644
--- a/src/util/regex/regex-matcher.hpp
+++ b/src/util/regex/regex-matcher.hpp
@@ -66,7 +66,7 @@
 
 private:
   bool 
-  recursiveMatch(const int& mId, const Name& name, const int& offset, const int& len);
+  recursiveMatch(size_t mId, const Name& name, size_t offset, size_t len);
 
 
 protected:
@@ -124,7 +124,7 @@
 }
   
 inline bool 
-RegexMatcher::recursiveMatch(const int& mId, const Name& name, const int& offset, const int& len)
+RegexMatcher::recursiveMatch(size_t mId, const Name& name, size_t offset, size_t len)
 {
   // _LOG_TRACE ("Enter RegexMatcher::recursiveMatch");
 
diff --git a/src/util/regex/regex-pattern-list-matcher.hpp b/src/util/regex/regex-pattern-list-matcher.hpp
index 84b5c46..3ae74f1 100644
--- a/src/util/regex/regex-pattern-list-matcher.hpp
+++ b/src/util/regex/regex-pattern-list-matcher.hpp
@@ -32,10 +32,10 @@
   extractPattern(int index, int* next);
     
   int 
-  extractSubPattern(const char left, const char right, int index);
+  extractSubPattern(const char left, const char right, size_t index);
     
   int 
-  extractRepetition(int index);
+  extractRepetition(size_t index);
 
 private:
 
@@ -121,10 +121,10 @@
 }
   
 inline int 
-RegexPatternListMatcher::extractSubPattern(const char left, const char right, int index)
+RegexPatternListMatcher::extractSubPattern(const char left, const char right, size_t index)
 {
-  int lcount = 1;
-  int rcount = 0;
+  size_t lcount = 1;
+  size_t rcount = 0;
 
   while(lcount > rcount){
 
@@ -143,9 +143,9 @@
 }
 
 inline int 
-RegexPatternListMatcher::extractRepetition(int index)
+RegexPatternListMatcher::extractRepetition(size_t index)
 {
-  int exprSize = m_expr.size();
+  size_t exprSize = m_expr.size();
 
   if(index == exprSize)
     return index;
diff --git a/src/util/regex/regex-top-matcher.cpp b/src/util/regex/regex-top-matcher.cpp
index 38f1a5a..d3b8271 100644
--- a/src/util/regex/regex-top-matcher.cpp
+++ b/src/util/regex/regex-top-matcher.cpp
@@ -95,8 +95,8 @@
   else
     expand = m_expand;
 
-  int offset = 0;
-  while(offset < expand.size())
+  size_t offset = 0;
+  while (offset < expand.size())
     {
       std::string item = getItemFromExpand(expand, offset);
       if(item[0] == '<')
@@ -129,9 +129,9 @@
 }
 
 std::string
-RegexTopMatcher::getItemFromExpand(const std::string& expand, int & offset)
+RegexTopMatcher::getItemFromExpand(const std::string& expand, size_t& offset)
 {
-  int begin = offset;
+  size_t begin = offset;
 
   if(expand[offset] == '\\')
     {
@@ -155,8 +155,8 @@
       if(offset >= expand.size())
         throw RegexMatcher::Error("wrong format of expand string!");
         
-      int left = 1;
-      int right = 0;
+      size_t left = 1;
+      size_t right = 0;
       while(right < left)
         {
           if(expand[offset] == '<')
@@ -196,7 +196,7 @@
 RegexTopMatcher::convertSpecialChar(const std::string& str)
 {
   std::string newStr;
-  for(int i = 0; i < str.size(); i++)
+  for(size_t i = 0; i < str.size(); i++)
     {
       char c = str[i];
       switch(c)
diff --git a/src/util/regex/regex-top-matcher.hpp b/src/util/regex/regex-top-matcher.hpp
index fc4a0df..4d9c01e 100644
--- a/src/util/regex/regex-top-matcher.hpp
+++ b/src/util/regex/regex-top-matcher.hpp
@@ -43,7 +43,7 @@
 
 private:
   std::string
-  getItemFromExpand(const std::string& expand, int & offset);
+  getItemFromExpand(const std::string& expand, size_t& offset);
 
   static std::string
   convertSpecialChar(const std::string& str);
diff --git a/src/util/scheduler.cpp b/src/util/scheduler.cpp
index 377800f..fc6492f 100644
--- a/src/util/scheduler.cpp
+++ b/src/util/scheduler.cpp
@@ -76,8 +76,7 @@
 
 
 Scheduler::Scheduler(boost::asio::io_service& ioService)
-  : m_ioService(ioService)
-  , m_scheduledEvent(m_events.end())
+  : m_scheduledEvent(m_events.end())
   , m_deadlineTimer(ioService)
   , m_isEventExecuting(false)
 {
diff --git a/src/util/scheduler.hpp b/src/util/scheduler.hpp
index b7364ce..cc8bcce 100644
--- a/src/util/scheduler.hpp
+++ b/src/util/scheduler.hpp
@@ -56,8 +56,6 @@
   onEvent(const boost::system::error_code& code);
   
 private:
-  boost::asio::io_service& m_ioService;
-
   struct EventInfo
   {
     EventInfo(const time::nanoseconds& after,
diff --git a/src/util/string-helper.hpp b/src/util/string-helper.hpp
index 14f499e..9e2329c 100644
--- a/src/util/string-helper.hpp
+++ b/src/util/string-helper.hpp
@@ -23,7 +23,7 @@
 inline std::string 
 toHex(const uint8_t* array, size_t arraySize)
 {
-  if (!&array)
+  if (array == 0 || arraySize == 0)
     return "";
   
   std::ostringstream result;
diff --git a/tools/ndncatchunks3.cpp b/tools/ndncatchunks3.cpp
index 7b72614..59a75ad 100644
--- a/tools/ndncatchunks3.cpp
+++ b/tools/ndncatchunks3.cpp
@@ -26,12 +26,12 @@
   Consumer(const std::string& data_name,
            size_t pipe_size, size_t total_seg,
            int scope = -1, bool mustBeFresh = true)
-    : m_data_name (data_name)
-    , m_pipe_size (pipe_size)
-    , m_total_seg (total_seg)
-    , m_next_seg (0)
-    , m_total_size (0)
-    , m_output (false)
+    : m_data_name(data_name)
+    , m_pipe_size(pipe_size)
+    , m_total_seg(total_seg)
+    , m_next_seg(0)
+    , m_total_size(0)
+    , m_output(false)
     , m_scope(scope)
     , m_mustBeFresh(mustBeFresh)
   {
@@ -70,25 +70,25 @@
 {
   try
     {
-      for (int i = 0; i < m_pipe_size; i++)
-        {
+      for (size_t i = 0; i < m_pipe_size; i++)
+	{
           ndn::Interest interest(ndn::Name(m_data_name).appendSegment(m_next_seg++));
-          interest.setInterestLifetime(ndn::time::milliseconds(4000));
-          if (m_scope >= 0)
+	  interest.setInterestLifetime(ndn::time::milliseconds(4000));
+	  if (m_scope >= 0)
             interest.setScope(m_scope);
-          interest.setMustBeFresh(m_mustBeFresh);
+	  interest.setMustBeFresh(m_mustBeFresh);
 
-          m_face.expressInterest (interest,
-                                  ndn::bind(&Consumer::on_data, this, _1, _2),
-                                  ndn::bind(&Consumer::on_timeout, this, _1));
-        }
+	  m_face.expressInterest(interest,
+                                 ndn::bind(&Consumer::on_data, this, _1, _2),
+                                 ndn::bind(&Consumer::on_timeout, this, _1));
+	}
 
       // processEvents will block until the requested data received or timeout occurs
       m_face.processEvents();
     }
   catch (std::exception& e)
     {
-      std::cerr << "ERROR: " << e.what () << std::endl;
+      std::cerr << "ERROR: " << e.what() << std::endl;
     }
 }
 
@@ -103,7 +103,7 @@
       std::cout.write(reinterpret_cast<const char*>(content.value()), content.value_size());
     }
 
-  m_total_size += content.value_size ();
+  m_total_size += content.value_size();
 
   if (name[-1].toSegment() + 1 == m_total_seg)
     {
@@ -119,9 +119,9 @@
       interest.setInterestLifetime(ndn::time::milliseconds(4000));
       interest.setMustBeFresh(m_mustBeFresh);
 
-      m_face.expressInterest (interest,
-                              ndn::bind(&Consumer::on_data, this, _1, _2),
-                              ndn::bind(&Consumer::on_timeout, this, _1));
+      m_face.expressInterest(interest,
+                             ndn::bind(&Consumer::on_data, this, _1, _2),
+                             ndn::bind(&Consumer::on_timeout, this, _1));
     }
 }
 
@@ -153,25 +153,25 @@
   int opt;
   while ((opt = getopt(argc, argv, "op:c:")) != -1)
     {
-      switch (opt)
-        {
+      switch(opt)
+	{
         case 'p':
-          pipe_size = atoi (optarg);
-          if (pipe_size <= 0)
-            pipe_size = 1;
-          std::cerr << "main (): set pipe size = " << pipe_size << std::endl;
-          break;
-        case 'c':
-          total_seg = atoi (optarg);
-          if (total_seg <= 0)
-            total_seg = 1;
-          std::cerr << "main (): set total seg = " << total_seg << std::endl;
-          break;
-        case 'o':
-          output = true;
-          break;
+	  pipe_size = atoi(optarg);
+	  if (pipe_size <= 0)
+	    pipe_size = 1;
+	  std::cerr << "main(): set pipe size = " << pipe_size << std::endl;
+	  break;
+	case 'c':
+	  total_seg = atoi(optarg);
+	  if (total_seg <= 0)
+	    total_seg = 1;
+	  std::cerr << "main(): set total seg = " << total_seg << std::endl;
+	  break;
+	case 'o':
+	  output = true;
+	  break;
         default:
-          return usage(argv[0]);
+	  return usage(argv[0]);
         }
     }
 
@@ -185,12 +185,12 @@
       return usage(argv[0]);
     }
 
-  Consumer consumer (name, pipe_size, total_seg);
+  Consumer consumer(name, pipe_size, total_seg);
 
   if (output)
-    consumer.enable_output ();
+    consumer.enable_output();
 
-  consumer.run ();
+  consumer.run();
 
   return 0;
 }
diff --git a/tools/ndnputchunks3.cpp b/tools/ndnputchunks3.cpp
index 3822ae0..bb6435b 100644
--- a/tools/ndnputchunks3.cpp
+++ b/tools/ndnputchunks3.cpp
@@ -129,7 +129,7 @@
             {
               std::cerr << "ERROR: " << e.what() << std::endl;
               // and keep going
-              sleep (1);
+              sleep(1);
             }
         }
     }
diff --git a/tools/ndnsec-cert-dump.hpp b/tools/ndnsec-cert-dump.hpp
index cbafc61..2adca8d 100644
--- a/tools/ndnsec-cert-dump.hpp
+++ b/tools/ndnsec-cert-dump.hpp
@@ -20,13 +20,13 @@
   bool isKeyName = false;
   bool isIdentityName = false;
   bool isCertName = true;
-  bool isFileName = false;
+  // bool isFileName = false;
   bool isPretty = false;
   bool isStdOut = true;
   bool isRepoOut = false;
   std::string repoHost = "127.0.0.1";
   std::string repoPort = "7376";
-  bool isDnsOut = false;
+  // bool isDnsOut = false;
 
   po::options_description desc("General Usage\n  ndnsec cert-dump [-h] [-p] [-d] [-r [-H repo-host] [-P repor-port] ] [-i|k|f] name\nGeneral options");
   desc.add_options()
@@ -38,7 +38,7 @@
     ("repo-output,r", "optional, if specified, certificate is dumped (published) to repo")
     ("repo-host,H", po::value<std::string>(&repoHost)->default_value("localhost"), "optional, the repo host if repo-output is specified")
     ("repo-port,P", po::value<std::string>(&repoPort)->default_value("7376"), "optional, the repo port if repo-output is specified")
-    ("dns-output,d", "optional, if specified, certificate is dumped (published) to DNS")
+    // ("dns-output,d", "optional, if specified, certificate is dumped (published) to DNS")
     ("name,n", po::value<std::string>(&name), "certificate name, for example, /ndn/edu/ucla/KEY/cs/alice/ksk-1234567890/ID-CERT/%FD%FF%FF%FF%FF%FF%FF%FF")
     ;
 
@@ -75,7 +75,7 @@
   else if (vm.count("file"))
     {
       isCertName = false;
-      isFileName = true;
+      // isFileName = true;
     }    
     
   if (vm.count("pretty"))
@@ -88,7 +88,7 @@
     }
   else if(vm.count("dns-output"))
     {
-      isDnsOut = true;
+      // isDnsOut = true;
       isStdOut = false;
       std::cerr << "Error: DNS output is not supported yet!" << std::endl;
       return 1;
diff --git a/tools/ndnsec-cert-gen.hpp b/tools/ndnsec-cert-gen.hpp
index 8b6e460..363dd57 100644
--- a/tools/ndnsec-cert-gen.hpp
+++ b/tools/ndnsec-cert-gen.hpp
@@ -19,8 +19,6 @@
   using namespace ndn;
   namespace po = boost::program_options;
 
-  typedef boost::posix_time::ptime Time;
-  
   std::string notBeforeStr;
   std::string notAfterStr;
   std::string sName;
@@ -199,7 +197,7 @@
           certificate.setNotAfter(notAfter);
           certificate.setPublicKeyInfo(selfSignedCertificate->getPublicKeyInfo());
           certificate.addSubjectDescription(subDescryptName);
-          for(int i = 0; i < otherSubDescrypt.size(); i++)
+          for (size_t i = 0; i < otherSubDescrypt.size(); i++)
             certificate.addSubjectDescription(otherSubDescrypt[i]);
           certificate.encode();
 
diff --git a/tools/ndnsec-cert-install.hpp b/tools/ndnsec-cert-install.hpp
index 1d3347f..12c036c 100644
--- a/tools/ndnsec-cert-install.hpp
+++ b/tools/ndnsec-cert-install.hpp
@@ -95,7 +95,7 @@
   bool systemDefault = true;
   bool identityDefault = false;
   bool keyDefault = false;
-  bool noDefault = false;
+  // bool noDefault = false;
   bool any = false;
 
   po::options_description desc("General Usage\n  ndnsec cert-install [-h] [-I|K|N] cert-file\nGeneral options");
@@ -148,7 +148,7 @@
     }
   else if (vm.count("no-default"))
     {
-      noDefault = true;
+      // noDefault = true;
       systemDefault = false;
     }
 
diff --git a/tools/ndnsec-delete.hpp b/tools/ndnsec-delete.hpp
index bced204..2536344 100644
--- a/tools/ndnsec-delete.hpp
+++ b/tools/ndnsec-delete.hpp
@@ -16,7 +16,7 @@
   using namespace ndn;
   namespace po = boost::program_options;
 
-  bool deleteId = true;
+  // bool deleteId = true;
   bool deleteKey = false;
   bool deleteCert = false;
   std::string name;
@@ -55,12 +55,12 @@
   if(vm.count("delete_cert"))
     {
       deleteCert = true;
-      deleteId = false;
+      // deleteId = false;
     }
   else if(vm.count("delete_key"))
     {
       deleteKey = true;
-      deleteId = false;
+      // deleteId = false;
     }
   
   try
diff --git a/tools/ndnsec-list.hpp b/tools/ndnsec-list.hpp
index b9724d6..3ebe2ca 100644
--- a/tools/ndnsec-list.hpp
+++ b/tools/ndnsec-list.hpp
@@ -56,11 +56,11 @@
         {
           std::vector<Name> defaultList;
           keyChain.getAllIdentities(defaultList, true);
-          for(int i = 0; i < defaultList.size(); i++)
+          for(size_t i = 0; i < defaultList.size(); i++)
             std::cout << "* " << defaultList[i] << std::endl;
           std::vector<Name> otherList;
           keyChain.getAllIdentities(otherList, false);
-          for(int i = 0; i < otherList.size(); i++)
+          for(size_t i = 0; i < otherList.size(); i++)
             std::cout << "  " << otherList[i] << std::endl;
           return 0;
         }
@@ -68,31 +68,31 @@
         {
           std::vector<Name> defaultIdList;
           keyChain.getAllIdentities(defaultIdList, true);
-          for(int i = 0; i < defaultIdList.size(); i++)
+          for(size_t i = 0; i < defaultIdList.size(); i++)
             {
               std::cout << "* " << defaultIdList[i] << std::endl;
               std::vector<Name> defaultKeyList;
               keyChain.getAllKeyNamesOfIdentity(defaultIdList[i], defaultKeyList, true);
-              for(int j = 0; j < defaultKeyList.size(); j++)
+              for(size_t j = 0; j < defaultKeyList.size(); j++)
                 std::cout << "  +->* " << defaultKeyList[j] << std::endl;
               std::vector<Name> otherKeyList;
               keyChain.getAllKeyNamesOfIdentity(defaultIdList[i], otherKeyList, false);
-              for(int j = 0; j < otherKeyList.size(); j++)
+              for(size_t j = 0; j < otherKeyList.size(); j++)
                 std::cout << "  +->  " << otherKeyList[j] << std::endl;
               std::cout << std::endl;
             }
           std::vector<Name> otherIdList;
           keyChain.getAllIdentities(otherIdList, false);
-          for(int i = 0; i < otherIdList.size(); i++)
+          for(size_t i = 0; i < otherIdList.size(); i++)
             {
               std::cout << "  " << otherIdList[i] << std::endl;
               std::vector<Name> defaultKeyList;
               keyChain.getAllKeyNamesOfIdentity(otherIdList[i], defaultKeyList, true);
-              for(int j = 0; j < defaultKeyList.size(); j++)
+              for(size_t j = 0; j < defaultKeyList.size(); j++)
                 std::cout << "  +->* " << defaultKeyList[j] << std::endl;
               std::vector<Name> otherKeyList;
               keyChain.getAllKeyNamesOfIdentity(otherIdList[i], otherKeyList, false);
-              for(int j = 0; j < otherKeyList.size(); j++)
+              for(size_t j = 0; j < otherKeyList.size(); j++)
                 std::cout << "  +->  " << otherKeyList[j] << std::endl;
               std::cout << std::endl;
             }
@@ -102,35 +102,35 @@
         {
           std::vector<Name> defaultIdList;
           keyChain.getAllIdentities(defaultIdList, true);
-          for(int i = 0; i < defaultIdList.size(); i++)
+          for(size_t i = 0; i < defaultIdList.size(); i++)
             {
               std::cout << "* " << defaultIdList[i] << std::endl;
               std::vector<Name> defaultKeyList;
               keyChain.getAllKeyNamesOfIdentity(defaultIdList[i], defaultKeyList, true);
-              for(int j = 0; j < defaultKeyList.size(); j++)
+              for(size_t j = 0; j < defaultKeyList.size(); j++)
                 {
                   std::cout << "  +->* " << defaultKeyList[j] << std::endl;
                   std::vector<Name> defaultCertList;
                   keyChain.getAllCertificateNamesOfKey(defaultKeyList[j], defaultCertList, true);
-                  for(int k = 0; k < defaultCertList.size(); k++)
+                  for(size_t k = 0; k < defaultCertList.size(); k++)
                     std::cout << "       +->* " << defaultCertList[k] << std::endl;
                   std::vector<Name> otherCertList;
                   keyChain.getAllCertificateNamesOfKey(defaultKeyList[j], otherCertList, false);
-                  for(int k = 0; k < otherCertList.size(); k++)
+                  for(size_t k = 0; k < otherCertList.size(); k++)
                     std::cout << "       +->  " << otherCertList[k] << std::endl;
                 }
               std::vector<Name> otherKeyList;
               keyChain.getAllKeyNamesOfIdentity(defaultIdList[i], otherKeyList, false);
-              for(int j = 0; j < otherKeyList.size(); j++)
+              for(size_t j = 0; j < otherKeyList.size(); j++)
                 {
                   std::cout << "  +->  " << otherKeyList[j] << std::endl;
                   std::vector<Name> defaultCertList;
                   keyChain.getAllCertificateNamesOfKey(otherKeyList[j], defaultCertList, true);
-                  for(int k = 0; k < defaultCertList.size(); k++)
+                  for(size_t k = 0; k < defaultCertList.size(); k++)
                     std::cout << "       +->* " << defaultCertList[k] << std::endl;
                   std::vector<Name> otherCertList;
                   keyChain.getAllCertificateNamesOfKey(otherKeyList[j], otherCertList, false);
-                  for(int k = 0; k < otherCertList.size(); k++)
+                  for(size_t k = 0; k < otherCertList.size(); k++)
                     std::cout << "       +->  " << otherCertList[k] << std::endl;
                 }
             
@@ -138,35 +138,35 @@
             }
           std::vector<Name> otherIdList;
           keyChain.getAllIdentities(otherIdList, false);
-          for(int i = 0; i < otherIdList.size(); i++)
+          for(size_t i = 0; i < otherIdList.size(); i++)
             {
               std::cout << "  " << otherIdList[i] << std::endl;
               std::vector<Name> defaultKeyList;
               keyChain.getAllKeyNamesOfIdentity(otherIdList[i], defaultKeyList, true);
-              for(int j = 0; j < defaultKeyList.size(); j++)
+              for(size_t j = 0; j < defaultKeyList.size(); j++)
                 {
                   std::cout << "  +->* " << defaultKeyList[j] << std::endl;
                   std::vector<Name> defaultCertList;
                   keyChain.getAllCertificateNamesOfKey(defaultKeyList[j], defaultCertList, true);
-                  for(int k = 0; k < defaultCertList.size(); k++)
+                  for(size_t k = 0; k < defaultCertList.size(); k++)
                     std::cout << "       +->* " << defaultCertList[k] << std::endl;
                   std::vector<Name> otherCertList;
                   keyChain.getAllCertificateNamesOfKey(defaultKeyList[j], otherCertList, false);
-                  for(int k = 0; k < otherCertList.size(); k++)
+                  for(size_t k = 0; k < otherCertList.size(); k++)
                     std::cout << "       +->  " << otherCertList[k] << std::endl;
                 }
               std::vector<Name> otherKeyList;
               keyChain.getAllKeyNamesOfIdentity(otherIdList[i], otherKeyList, false);
-              for(int j = 0; j < otherKeyList.size(); j++)
+              for(size_t j = 0; j < otherKeyList.size(); j++)
                 {
                   std::cout << "  +->  " << otherKeyList[j] << std::endl;
                   std::vector<Name> defaultCertList;
                   keyChain.getAllCertificateNamesOfKey(otherKeyList[j], defaultCertList, true);
-                  for(int k = 0; k < defaultCertList.size(); k++)
+                  for(size_t k = 0; k < defaultCertList.size(); k++)
                     std::cout << "       +->* " << defaultCertList[k] << std::endl;
                   std::vector<Name> otherCertList;
                   keyChain.getAllCertificateNamesOfKey(otherKeyList[j], otherCertList, false);
-                  for(int k = 0; k < otherCertList.size(); k++)
+                  for(size_t k = 0; k < otherCertList.size(); k++)
                     std::cout << "       +->  " << otherCertList[k] << std::endl;
                 }
               std::cout << std::endl;
diff --git a/wscript b/wscript
index d23de94..1f99ca5 100644
--- a/wscript
+++ b/wscript
@@ -46,26 +46,34 @@
 
     conf.check_openssl()
 
-    if conf.options.debug:
-        conf.define ('_DEBUG', 1)
-        flags = ['-O0',
-                 '-Wall',
-                 # '-Werror',
-                 '-Wno-unused-variable',
-                 '-g3',
-                 '-Wno-unused-private-field', # only clang supports
-                 '-fcolor-diagnostics',       # only clang supports
-                 '-Qunused-arguments',        # only clang supports
-                 '-Wno-tautological-compare', # suppress warnings from CryptoPP
-                 '-Wno-unused-function',      # another annoying warning from CryptoPP
+    custom_cxxflags = (len(conf.env.CXXFLAGS) > 0)
 
-                 '-Wno-deprecated-declarations',
-                 ]
+    if not custom_cxxflags:
+        if conf.options.debug:
+            conf.define ('_DEBUG', 1)
 
-        conf.add_supported_cxxflags (cxxflags = flags)
-    else:
-        flags = ['-O3', '-g', '-Wno-tautological-compare', '-Wno-unused-function', '-Wno-deprecated-declarations']
-        conf.add_supported_cxxflags (cxxflags = flags)
+            conf.add_supported_cxxflags(cxxflags = [
+                    '-O0', '-g3',
+                    '-Werror',
+                    '-fcolor-diagnostics', # only clang supports
+                ])
+        else:
+            if len(conf.env.CXXFLAGS) == 0:
+                conf.add_supported_cxxflags(cxxflags = ['-O2', '-g'])
+
+        conf.add_supported_cxxflags(cxxflags = [
+                '-Wall',
+
+                # to disable known warnings
+                '-Wno-unused-variable', # cryptopp
+                '-Wno-unused-function',
+                '-Wno-deprecated-declarations',
+            ])
+    elif conf.options.debug:
+        Logs.error("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
+                   % " ".join(conf.env.CXXFLAGS))
+        conf.fatal("Unset CXXFLAGS or remove --debug option to proceed")
+        return 1
 
     if Utils.unversioned_sys_platform () == "darwin":
         conf.check_cxx(framework_name='CoreFoundation', uselib_store='OSX_COREFOUNDATION', mandatory=True)
@@ -95,7 +103,7 @@
         conf.check(msg='Checking for type std::function',
                    type_name="std::function<void()>", header_name="functional", define_name='HAVE_STD_FUNCTION')
         conf.define('HAVE_CXX11', 1)
-        
+
     USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams', 'regex', 'program_options', 'chrono']
     if conf.env['WITH_TESTS']:
         USED_BOOST_LIBS += ['unit_test_framework']
