diff --git a/src/util/command-interest-generator.hpp b/src/util/command-interest-generator.hpp
index 18bc960..8b51cd9 100644
--- a/src/util/command-interest-generator.hpp
+++ b/src/util/command-interest-generator.hpp
@@ -62,7 +62,7 @@
     .append(name::Component::fromNumber(random::generateWord64()));
   interest.setName(commandInterestName);
 
-  if(certificateName.empty())
+  if (certificateName.empty())
     m_keyChain.sign(interest);
   else
     m_keyChain.sign(interest, certificateName);
diff --git a/src/util/crypto.cpp b/src/util/crypto.cpp
index 1621005..d8e803a 100644
--- a/src/util/crypto.cpp
+++ b/src/util/crypto.cpp
@@ -10,17 +10,17 @@
 
 namespace ndn {
 
-void ndn_digestSha256(const uint8_t *data, size_t dataLength, uint8_t *digest)
+void ndn_digestSha256(const uint8_t* data, size_t dataLength, uint8_t* digest)
 {
   try
     {
       using namespace CryptoPP;
-      
+
       CryptoPP::SHA256 hash;
       OBufferStream os;
       StringSource(data, dataLength, true, new HashFilter(hash, new ArraySink(digest, crypto::SHA256_DIGEST_SIZE)));
     }
-  catch(CryptoPP::Exception& e)
+  catch (CryptoPP::Exception& e)
     {
       return;
     }
@@ -30,18 +30,18 @@
 namespace crypto {
 
 ConstBufferPtr
-sha256(const uint8_t *data, size_t dataLength)
+sha256(const uint8_t* data, size_t dataLength)
 {
   try
     {
       using namespace CryptoPP;
-      
+
       SHA256 hash;
       OBufferStream os;
       StringSource(data, dataLength, true, new HashFilter(hash, new FileSink(os)));
       return os.buf();
     }
-  catch(CryptoPP::Exception& e)
+  catch (CryptoPP::Exception& e)
     {
       return ConstBufferPtr();
     }
diff --git a/src/util/crypto.hpp b/src/util/crypto.hpp
index 58555a2..82e769f 100644
--- a/src/util/crypto.hpp
+++ b/src/util/crypto.hpp
@@ -18,7 +18,7 @@
  * @param dataLength The length of data.
  * @param digest A pointer to a buffer of size crypto::SHA256_DIGEST_SIZE to receive the data.
  */
-void ndn_digestSha256(const uint8_t *data, size_t dataLength, uint8_t *digest);
+void ndn_digestSha256(const uint8_t* data, size_t dataLength, uint8_t* digest);
 
 namespace crypto {
 
@@ -33,7 +33,7 @@
  * @return A pointer to a buffer of SHA256_DIGEST.
  */
 ConstBufferPtr
-sha256(const uint8_t *data, size_t dataLength);
+sha256(const uint8_t* data, size_t dataLength);
 
 } // namespace crypto
 
diff --git a/src/util/io.hpp b/src/util/io.hpp
index 6026f06..ff6852b 100644
--- a/src/util/io.hpp
+++ b/src/util/io.hpp
@@ -19,7 +19,15 @@
 namespace ndn {
 namespace io {
 
-struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
+class Error : public std::runtime_error
+{
+public:
+  explicit
+  Error(const std::string& what)
+    : std::runtime_error(what)
+  {
+  }
+};
 
 enum IoEncoding {
   NO_ENCODING,
@@ -27,8 +35,8 @@
   HEX
 };
 
-template<typename T> 
-shared_ptr<T> 
+template<typename T>
+shared_ptr<T>
 load(std::istream& is, IoEncoding encoding = BASE_64)
 {
   typedef typename T::Error TypeError;
@@ -39,54 +47,54 @@
       shared_ptr<T> object = make_shared<T>();
 
       OBufferStream os;
-      
-      switch(encoding)
-	{
-	case NO_ENCODING:
-	  {
-	    FileSource ss(is, true, new FileSink(os));
-	    break;
-	  }
-	case BASE_64:
-	  {
-	    FileSource ss(is, true, new Base64Decoder(new FileSink(os)));
-	    break;
-	  }
-	case HEX:
-	  {
-	    FileSource ss(is, true, new HexDecoder(new FileSink(os)));
-	    break;
-	  }
-	default:
-	  return shared_ptr<T>(); 
-	}
+
+      switch (encoding)
+        {
+        case NO_ENCODING:
+          {
+            FileSource ss(is, true, new FileSink(os));
+            break;
+          }
+        case BASE_64:
+          {
+            FileSource ss(is, true, new Base64Decoder(new FileSink(os)));
+            break;
+          }
+        case HEX:
+          {
+            FileSource ss(is, true, new HexDecoder(new FileSink(os)));
+            break;
+          }
+        default:
+          return shared_ptr<T>();
+        }
 
       object->wireDecode(Block(os.buf()));
       return object;
     }
-  catch(CryptoPP::Exception& e)
+  catch (CryptoPP::Exception& e)
     {
       return shared_ptr<T>();
     }
-  catch(Block::Error& e)
+  catch (Block::Error& e)
     {
       return shared_ptr<T>();
     }
-  catch(TypeError& e)
+  catch (TypeError& e)
     {
       return shared_ptr<T>();
     }
 }
 
-template<typename T> 
-shared_ptr<T> 
+template<typename T>
+shared_ptr<T>
 load(const std::string& file, IoEncoding encoding = BASE_64)
 {
   std::ifstream is(file.c_str());
   return load<T>(is, encoding);
 }
 
-template<typename T> 
+template<typename T>
 void
 save(const T& object, std::ostream& os, IoEncoding encoding = BASE_64)
 {
@@ -96,38 +104,41 @@
       using namespace CryptoPP;
 
       Block block = object.wireEncode();
-      
-      switch(encoding)
-	{
-	case NO_ENCODING:
-	  {
-	    StringSource ss(block.wire(), block.size(), true, new FileSink(os));
-	    break;
-	  }
-	case BASE_64:
-	  {
-	    StringSource ss(block.wire(), block.size(), true, new Base64Encoder(new FileSink(os), true, 64));
-	    break;
-	  }
-	case HEX:
-	  {
-	    StringSource ss(block.wire(), block.size(), true, new HexEncoder(new FileSink(os)));
-	    break;
-	  }
-	default:
-	  return; 
-	}
+
+      switch (encoding)
+        {
+        case NO_ENCODING:
+          {
+            StringSource ss(block.wire(), block.size(), true,
+                            new FileSink(os));
+            break;
+          }
+        case BASE_64:
+          {
+            StringSource ss(block.wire(), block.size(), true,
+                            new Base64Encoder(new FileSink(os), true, 64));
+            break;
+          }
+        case HEX:
+          {
+            StringSource ss(block.wire(), block.size(), true,
+                            new HexEncoder(new FileSink(os)));
+            break;
+          }
+        default:
+          return;
+        }
       return;
     }
-  catch(CryptoPP::Exception& e)
+  catch (CryptoPP::Exception& e)
     {
       throw Error(e.what());
     }
-  catch(Block::Error& e)
+  catch (Block::Error& e)
     {
       throw Error(e.what());
     }
-  catch(TypeError& e)
+  catch (TypeError& e)
     {
       throw Error(e.what());
     }
@@ -145,4 +156,3 @@
 } // namespace ndn
 
 #endif // NDN_UTIL_IO_HPP
-
diff --git a/src/util/regex/regex-backref-matcher.hpp b/src/util/regex/regex-backref-matcher.hpp
index e2eabe8..aa00605 100644
--- a/src/util/regex/regex-backref-matcher.hpp
+++ b/src/util/regex/regex-backref-matcher.hpp
@@ -18,17 +18,17 @@
 {
 public:
   RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);
-    
+
   virtual ~RegexBackrefMatcher(){}
 
-  void 
+  void
   lateCompile()
   {
     compile();
   }
 
 protected:
-  virtual void 
+  virtual void
   compile();
 };
 
@@ -44,11 +44,11 @@
   // compile();
 }
 
-inline void 
+inline void
 RegexBackrefMatcher::compile()
 {
   int lastIndex = m_expr.size() - 1;
-  if('(' == m_expr[0] && ')' == m_expr[lastIndex]){
+  if ('(' == m_expr[0] && ')' == m_expr[lastIndex]){
     // m_backRefManager->pushRef(this);
 
     shared_ptr<RegexMatcher> matcher(new RegexPatternListMatcher(m_expr.substr(1, lastIndex - 1), m_backrefManager));
@@ -63,5 +63,3 @@
 } // namespace ndn
 
 #endif // NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
-
-
diff --git a/src/util/regex/regex-component-matcher.hpp b/src/util/regex/regex-component-matcher.hpp
index 50cb8de..34bcba7 100644
--- a/src/util/regex/regex-component-matcher.hpp
+++ b/src/util/regex/regex-component-matcher.hpp
@@ -25,13 +25,13 @@
    * @param backRefManager The back reference manager
    * @param exact The flag to provide exact match
    */
-  RegexComponentMatcher(const std::string& expr, 
-                        ptr_lib::shared_ptr<RegexBackrefManager> backRefManager, 
+  RegexComponentMatcher(const std::string& expr,
+                        ptr_lib::shared_ptr<RegexBackrefManager> backRefManager,
                         bool exact = true);
-    
+
   virtual ~RegexComponentMatcher() {};
 
-  virtual bool 
+  virtual bool
   match(const Name & name, const int & offset, const int &len = 1);
 
 protected:
@@ -39,20 +39,20 @@
    * @brief Compile the regular expression to generate the more matchers when necessary
    * @returns true if compiling succeeds
    */
-  virtual void 
+  virtual void
   compile();
-    
+
 private:
   bool m_exact;
   boost::regex m_componentRegex;
   std::vector<ptr_lib::shared_ptr<RegexPseudoMatcher> > m_pseudoMatcher;
-    
+
 };
 
 
 inline
-RegexComponentMatcher::RegexComponentMatcher (const std::string& expr, 
-                                              ptr_lib::shared_ptr<RegexBackrefManager> backRefManager, 
+RegexComponentMatcher::RegexComponentMatcher (const std::string& expr,
+                                              ptr_lib::shared_ptr<RegexBackrefManager> backRefManager,
                                               bool exact)
   : RegexMatcher (expr, EXPR_COMPONENT, backRefManager),
     m_exact(exact)
@@ -62,7 +62,7 @@
   // _LOG_TRACE ("Exit RegexComponentMatcher Constructor: ");
 }
 
-inline void 
+inline void
 RegexComponentMatcher::compile ()
 {
   // _LOG_TRACE ("Enter RegexComponentMatcher::compile");
@@ -78,7 +78,7 @@
       m_pseudoMatcher.push_back(pMatcher);
       m_backrefManager->pushRef(ptr_lib::static_pointer_cast<RegexMatcher>(pMatcher));
     }
-    
+
 
   // _LOG_TRACE ("Exit RegexComponentMatcher::compile");
 }
@@ -90,17 +90,17 @@
 
   m_matchResult.clear();
 
-  if("" == m_expr)
+  if ("" == m_expr)
     {
       m_matchResult.push_back(name.get(offset));
       return true;
     }
 
-  if(true == m_exact)
+  if (true == m_exact)
     {
       boost::smatch subResult;
       std::string targetStr = name.get(offset).toEscapedString();
-      if(boost::regex_match(targetStr, subResult, m_componentRegex))
+      if (boost::regex_match(targetStr, subResult, m_componentRegex))
         {
           for (size_t i = 1; i < m_componentRegex.mark_count(); i++)
             {
diff --git a/src/util/regex/regex-component-set-matcher.hpp b/src/util/regex/regex-component-set-matcher.hpp
index 4039388..5aed58f 100644
--- a/src/util/regex/regex-component-set-matcher.hpp
+++ b/src/util/regex/regex-component-set-matcher.hpp
@@ -24,19 +24,19 @@
    * @param exact The flag to provide exact match
    * @param backRefNum The starting back reference number
    */
-  RegexComponentSetMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);    
+  RegexComponentSetMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);
 
   virtual ~RegexComponentSetMatcher();
 
-  virtual bool 
+  virtual bool
   match(const Name& name, const int& offset, const int& len = 1);
 
-protected:    
+protected:
   /**
    * @brief Compile the regular expression to generate the more matchers when necessary
    * @returns true if compiling succeeds
    */
-  virtual void 
+  virtual void
   compile();
 
 private:
@@ -45,7 +45,7 @@
 
   void
   compileSingleComponent();
-    
+
   void
   compileMultipleComponents(const int start, const int lastIndex);
 
@@ -57,7 +57,8 @@
 
 
 inline
-RegexComponentSetMatcher::RegexComponentSetMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager)
+RegexComponentSetMatcher::RegexComponentSetMatcher(const std::string& expr,
+                                                   shared_ptr<RegexBackrefManager> backRefManager)
   : RegexMatcher(expr, EXPR_COMPONENT_SET, backRefManager),
     m_include(true)
 {
@@ -75,20 +76,20 @@
   //   delete *it;
 }
 
-inline void 
+inline void
 RegexComponentSetMatcher::compile()
 {
-  switch(m_expr[0]){
+  switch (m_expr[0]){
   case '<':
     return compileSingleComponent();
   case '[':
     {
       int lastIndex = m_expr.size() - 1;
-      if(']' != m_expr[lastIndex])
+      if (']' != m_expr[lastIndex])
         throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compile(): ")
                                   + " No matched ']' " + m_expr);
-      
-      if('^' == m_expr[1]){
+
+      if ('^' == m_expr[1]){
         m_include = false;
         compileMultipleComponents(2, lastIndex);
       }
@@ -102,52 +103,55 @@
   }
 }
 
-inline void 
+inline void
 RegexComponentSetMatcher::compileSingleComponent()
 {
   size_t end = extractComponent(1);
 
   if (m_expr.size() != end)
     {
-      throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compileSingleComponent: ")
-                                + m_expr);
+      throw RegexMatcher::Error(
+        std::string("Error: RegexComponentSetMatcher.compileSingleComponent: ") + m_expr);
     }
   else
     {
       shared_ptr<RegexComponentMatcher> component =
         make_shared<RegexComponentMatcher>(m_expr.substr(1, end - 2), m_backrefManager);
-      
-      m_components.insert(component);      
+
+      m_components.insert(component);
     }
 }
 
-inline void 
+inline void
 RegexComponentSetMatcher::compileMultipleComponents(const int start, const int lastIndex)
 {
   int index = start;
   int tmp_index = start;
-    
+
   while(index < lastIndex){
-    if('<' != m_expr[index])
-      throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compileMultipleComponents: ")
-                                + "Component expr error " + m_expr);
-      
+    if ('<' != m_expr[index])
+      throw RegexMatcher::Error(
+        std::string("Error: RegexComponentSetMatcher.compileMultipleComponents: ") +
+        "Component expr error " + m_expr);
+
     tmp_index = index + 1;
     index = extractComponent(tmp_index);
 
     shared_ptr<RegexComponentMatcher> component =
-      make_shared<RegexComponentMatcher>(m_expr.substr(tmp_index, index - tmp_index - 1), m_backrefManager);
-    
+      make_shared<RegexComponentMatcher>(m_expr.substr(tmp_index, index - tmp_index - 1),
+                                         m_backrefManager);
+
     m_components.insert(component);
   }
-    
-  if(index != lastIndex)
-    throw RegexMatcher::Error(std::string("Error: RegexComponentSetMatcher.compileMultipleComponents: ")
-                              + "Not sufficient expr to parse " + m_expr);        
+
+  if (index != lastIndex)
+    throw RegexMatcher::Error(
+      std::string("Error: RegexComponentSetMatcher.compileMultipleComponents: ") +
+      "Not sufficient expr to parse " + m_expr);
 }
 
-inline bool 
-RegexComponentSetMatcher::match(const Name & name, const int & offset, const int & len)
+inline bool
+RegexComponentSetMatcher::match(const Name& name, const int& offset, const int& len)
 {
   bool matched = false;
 
@@ -161,13 +165,13 @@
        it != m_components.end();
        ++it)
     {
-      if((*it)->match(name, offset, len))
+      if ((*it)->match(name, offset, len))
         {
           matched = true;
           break;
         }
     }
-    
+
   m_matchResult.clear();
 
   if (m_include ? matched : !matched)
@@ -175,18 +179,18 @@
       m_matchResult.push_back(name.get(offset));
       return true;
     }
-  else 
+  else
     return false;
 }
 
-inline int 
+inline int
 RegexComponentSetMatcher::extractComponent(int index)
 {
   int lcount = 1;
   int rcount = 0;
 
   while(lcount > rcount){
-    switch(m_expr[index]){
+    switch (m_expr[index]){
     case '<':
       lcount++;
       break;
diff --git a/src/util/regex/regex-matcher.hpp b/src/util/regex/regex-matcher.hpp
index 0d34311..d62ab41 100644
--- a/src/util/regex/regex-matcher.hpp
+++ b/src/util/regex/regex-matcher.hpp
@@ -18,7 +18,15 @@
 class RegexMatcher
 {
 public:
-  struct Error : public std::runtime_error { Error(const std::string& what) : std::runtime_error(what) {} };
+  class Error : public std::runtime_error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
+    {
+    }
+  };
 
   enum RegexExprType{
     EXPR_TOP,
@@ -26,52 +34,52 @@
     EXPR_PATTERNLIST,
 
     EXPR_REPEAT_PATTERN,
-      
+
     EXPR_BACKREF,
     EXPR_COMPONENT_SET,
     EXPR_COMPONENT,
 
     EXPR_PSEUDO
-  };    
+  };
 
-  RegexMatcher(const std::string& expr, 
-               const RegexExprType& type,  
+  RegexMatcher(const std::string& expr,
+               const RegexExprType& type,
                shared_ptr<RegexBackrefManager> backrefManager = shared_ptr<RegexBackrefManager>());
 
-  virtual 
+  virtual
   ~RegexMatcher();
 
-  virtual bool 
+  virtual bool
   match(const Name& name, const int& offset, const int& len);
 
   /**
    * @brief get the matched name components
    * @returns the matched name components
    */
-  const std::vector<name::Component>& 
+  const std::vector<name::Component>&
   getMatchResult() const
   { return m_matchResult; }
 
   const std::string&
   getExpr() const
-  { return m_expr; } 
+  { return m_expr; }
 
 protected:
   /**
    * @brief Compile the regular expression to generate the more matchers when necessary
    * @returns true if compiling succeeds
    */
-  virtual void 
+  virtual void
   compile() = 0;
 
 private:
-  bool 
+  bool
   recursiveMatch(size_t mId, const Name& name, size_t offset, size_t len);
 
 
 protected:
   const std::string m_expr;
-  const RegexExprType m_type; 
+  const RegexExprType m_type;
   shared_ptr<RegexBackrefManager> m_backrefManager;
   std::vector<shared_ptr<RegexMatcher> > m_matcherList;
   std::vector<name::Component> m_matchResult;
@@ -84,14 +92,14 @@
 namespace ndn {
 
 inline
-RegexMatcher::RegexMatcher(const std::string& expr, 
-                           const RegexExprType& type,  
-                           shared_ptr<RegexBackrefManager> backrefManager) 
-  : m_expr(expr), 
+RegexMatcher::RegexMatcher(const std::string& expr,
+                           const RegexExprType& type,
+                           shared_ptr<RegexBackrefManager> backrefManager)
+  : m_expr(expr),
     m_type(type),
     m_backrefManager(backrefManager)
 {
-  if(NULL == m_backrefManager)
+  if (NULL == m_backrefManager)
     m_backrefManager = make_shared<RegexBackrefManager>();
 }
 
@@ -100,7 +108,7 @@
 {
 }
 
-inline bool 
+inline bool
 RegexMatcher::match (const Name& name, const int& offset, const int& len)
 {
   // _LOG_TRACE ("Enter RegexMatcher::match");
@@ -108,7 +116,7 @@
 
   m_matchResult.clear();
 
-  if(recursiveMatch(0, name, offset, len))
+  if (recursiveMatch(0, name, offset, len))
     {
       for(int i = offset; i < offset + len ; i++)
         m_matchResult.push_back(name.get(i));
@@ -122,23 +130,23 @@
   // _LOG_TRACE ("Exit RegexMatcher::match");
   return result;
 }
-  
-inline bool 
+
+inline bool
 RegexMatcher::recursiveMatch(size_t mId, const Name& name, size_t offset, size_t len)
 {
   // _LOG_TRACE ("Enter RegexMatcher::recursiveMatch");
 
   int tried = len;
 
-  if(mId >= m_matcherList.size())
+  if (mId >= m_matcherList.size())
     return (len != 0 ? false : true);
-    
+
   shared_ptr<RegexMatcher> matcher = m_matcherList[mId];
 
   while(tried >= 0)
     {
-      if(matcher->match(name, offset, tried) && recursiveMatch(mId + 1, name, offset + tried, len - tried))
-        return true;      
+      if (matcher->match(name, offset, tried) && recursiveMatch(mId + 1, name, offset + tried, len - tried))
+        return true;
       tried--;
     }
 
diff --git a/src/util/regex/regex-pattern-list-matcher.hpp b/src/util/regex/regex-pattern-list-matcher.hpp
index 3ae74f1..12e3c68 100644
--- a/src/util/regex/regex-pattern-list-matcher.hpp
+++ b/src/util/regex/regex-pattern-list-matcher.hpp
@@ -20,21 +20,21 @@
 {
 public:
   RegexPatternListMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);
-    
+
   virtual ~RegexPatternListMatcher(){};
 
-protected:    
-  virtual void 
+protected:
+  virtual void
   compile();
 
 private:
-  bool 
+  bool
   extractPattern(int index, int* next);
-    
-  int 
+
+  int
   extractSubPattern(const char left, const char right, size_t index);
-    
-  int 
+
+  int
   extractRepetition(size_t index);
 
 private:
@@ -53,38 +53,38 @@
 {
   compile();
 }
-  
-inline void 
+
+inline void
 RegexPatternListMatcher::compile()
 {
   const int len = m_expr.size();
   int index = 0;
   int subHead = index;
-    
+
   while(index < len){
     subHead = index;
 
-    if(!extractPattern(subHead, &index))
+    if (!extractPattern(subHead, &index))
       throw RegexMatcher::Error("RegexPatternListMatcher compile: cannot compile");
   }
 }
 
-inline bool 
+inline bool
 RegexPatternListMatcher::extractPattern(int index, int* next)
 {
   // std::string errMsg = "Error: RegexPatternListMatcher.ExtractSubPattern(): ";
-    
+
   const int start = index;
   int end = index;
   int indicator = index;
 
-  switch(m_expr[index]){
+  switch (m_expr[index]){
   case '(':
     index++;
     index = extractSubPattern('(', ')', index);
     indicator = index;
     end = extractRepetition(index);
-    if(indicator == end){
+    if (indicator == end){
       shared_ptr<RegexMatcher> matcher = make_shared<RegexBackrefMatcher>(m_expr.substr(start, end - start), m_backrefManager);
       m_backrefManager->pushRef(matcher);
       boost::dynamic_pointer_cast<RegexBackrefMatcher>(matcher)->lateCompile();
@@ -94,7 +94,7 @@
     else
       m_matcherList.push_back(make_shared<RegexRepeatMatcher>(m_expr.substr(start, end - start), m_backrefManager, indicator - start));
     break;
-      
+
   case '<':
     index++;
     index = extractSubPattern ('<', '>', index);
@@ -119,8 +119,8 @@
 
   return true;
 }
-  
-inline int 
+
+inline int
 RegexPatternListMatcher::extractSubPattern(const char left, const char right, size_t index)
 {
   size_t lcount = 1;
@@ -128,13 +128,13 @@
 
   while(lcount > rcount){
 
-    if(index >= m_expr.size())
+    if (index >= m_expr.size())
       throw RegexMatcher::Error("Error: parenthesis mismatch");
 
-    if(left == m_expr[index])
+    if (left == m_expr[index])
       lcount++;
 
-    if(right == m_expr[index])
+    if (right == m_expr[index])
       rcount++;
 
     index++;
@@ -142,25 +142,25 @@
   return index;
 }
 
-inline int 
+inline int
 RegexPatternListMatcher::extractRepetition(size_t index)
 {
   size_t exprSize = m_expr.size();
 
-  if(index == exprSize)
+  if (index == exprSize)
     return index;
-    
-  if(('+' == m_expr[index] || '?' == m_expr[index] || '*' == m_expr[index])){
+
+  if (('+' == m_expr[index] || '?' == m_expr[index] || '*' == m_expr[index])){
     return ++index;
   }
-    
-  if('{' == m_expr[index]){
+
+  if ('{' == m_expr[index]){
     while('}' != m_expr[index]){
       index++;
-      if(index == exprSize)
+      if (index == exprSize)
         break;
     }
-    if(index == exprSize)
+    if (index == exprSize)
       throw RegexMatcher::Error(std::string("Error: RegexPatternListMatcher.ExtractRepetition(): ")
                                 + "Missing right brace bracket");
     else
diff --git a/src/util/regex/regex-repeat-matcher.hpp b/src/util/regex/regex-repeat-matcher.hpp
index fb42042..5eefbd1 100644
--- a/src/util/regex/regex-repeat-matcher.hpp
+++ b/src/util/regex/regex-repeat-matcher.hpp
@@ -20,10 +20,10 @@
 {
 public:
   RegexRepeatMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager, int indicator);
-    
+
   virtual ~RegexRepeatMatcher(){}
 
-  virtual bool 
+  virtual bool
   match(const Name& name, const int& offset, const int& len);
 
 protected:
@@ -31,19 +31,19 @@
    * @brief Compile the regular expression to generate the more matchers when necessary
    * @returns true if compiling succeeds
    */
-  virtual void 
+  virtual void
   compile();
 
 private:
-  bool 
+  bool
   parseRepetition();
 
-  bool 
+  bool
   recursiveMatch (int repeat,
-                  const Name & name,
-                  const int & offset,
-                  const int &len);
-  
+                  const Name& name,
+                  const int& offset,
+                  const int&len);
+
 private:
   int m_indicator;
   int m_repeatMin;
@@ -67,14 +67,14 @@
   // _LOG_TRACE ("Exit RegexRepeatMatcher Constructor");
 }
 
-inline void 
+inline void
 RegexRepeatMatcher::compile()
 {
   // _LOG_TRACE ("Enter RegexRepeatMatcher::compile");
-    
+
   shared_ptr<RegexMatcher> matcher;
 
-  if('(' == m_expr[0]){
+  if ('(' == m_expr[0]){
     matcher = make_shared<RegexBackrefMatcher>(m_expr.substr(0, m_indicator), m_backrefManager);
     m_backrefManager->pushRef(matcher);
     boost::dynamic_pointer_cast<RegexBackrefMatcher>(matcher)->lateCompile();
@@ -83,40 +83,40 @@
     matcher = make_shared<RegexComponentSetMatcher>(m_expr.substr(0, m_indicator), m_backrefManager);
   }
   m_matcherList.push_back(matcher);
-      
+
   parseRepetition();
 
   // _LOG_TRACE ("Exit RegexRepeatMatcher::compile");
 
 }
 
-inline bool 
+inline bool
 RegexRepeatMatcher::parseRepetition()
 {
   // _LOG_DEBUG ("Enter RegexRepeatMatcher::ParseRepetition()" << m_expr << " indicator: " << m_indicator);
-    
+
   int exprSize = m_expr.size();
   int intMax = std::numeric_limits<int>::max();
-    
-  if(exprSize == m_indicator){
+
+  if (exprSize == m_indicator){
     m_repeatMin = 1;
     m_repeatMax = 1;
 
     return true;
   }
   else{
-    if(exprSize == (m_indicator + 1)){
-      if('?' == m_expr[m_indicator]){
+    if (exprSize == (m_indicator + 1)){
+      if ('?' == m_expr[m_indicator]){
         m_repeatMin = 0;
         m_repeatMax = 1;
         return true;
       }
-      if('+' == m_expr[m_indicator]){
+      if ('+' == m_expr[m_indicator]){
         m_repeatMin = 1;
         m_repeatMax = intMax;
         return true;
       }
-      if('*' == m_expr[m_indicator]){
+      if ('*' == m_expr[m_indicator]){
         m_repeatMin = 0;
         m_repeatMax = intMax;
         return true;
@@ -128,36 +128,36 @@
       int min = 0;
       int max = 0;
 
-      if(boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,[0-9]+\\}"))){
+      if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,[0-9]+\\}"))){
         int separator = repeatStruct.find_first_of(',', 0);
         min = atoi(repeatStruct.substr(1, separator - 1).c_str());
         max = atoi(repeatStruct.substr(separator + 1, rsSize - separator - 2).c_str());
       }
-      else if(boost::regex_match(repeatStruct, boost::regex("\\{,[0-9]+\\}"))){
+      else if (boost::regex_match(repeatStruct, boost::regex("\\{,[0-9]+\\}"))){
         int separator = repeatStruct.find_first_of(',', 0);
         min = 0;
         max = atoi(repeatStruct.substr(separator + 1, rsSize - separator - 2).c_str());
       }
-      else if(boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,\\}"))){
+      else if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+,\\}"))){
         int separator = repeatStruct.find_first_of(',', 0);
         min = atoi(repeatStruct.substr(1, separator).c_str());
         max = intMax;
       }
-      else if(boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+\\}"))){
+      else if (boost::regex_match(repeatStruct, boost::regex("\\{[0-9]+\\}"))){
         min = atoi(repeatStruct.substr(1, rsSize - 1).c_str());
         max = min;
       }
       else
         throw RegexMatcher::Error(std::string("Error: RegexRepeatMatcher.ParseRepetition(): ")
                                   + "Unrecognized format "+ m_expr);
-        
-      if(min > intMax || max > intMax || min > max)
+
+      if (min > intMax || max > intMax || min > max)
         throw RegexMatcher::Error(std::string("Error: RegexRepeatMatcher.ParseRepetition(): ")
                                   + "Wrong number " + m_expr);
-          
+
       m_repeatMin = min;
       m_repeatMax = max;
-        
+
       return true;
     }
   }
@@ -165,7 +165,7 @@
 }
 
 inline bool
-RegexRepeatMatcher::match(const Name & name, const int & offset, const int & len)
+RegexRepeatMatcher::match(const Name& name, const int& offset, const int& len)
 {
   // _LOG_TRACE ("Enter RegexRepeatMatcher::match");
 
@@ -185,8 +185,8 @@
     return false;
 }
 
-inline bool 
-RegexRepeatMatcher::recursiveMatch(int repeat, const Name & name, const int & offset, const int & len)
+inline bool
+RegexRepeatMatcher::recursiveMatch(int repeat, const Name& name, const int& offset, const int& len)
 {
   // _LOG_TRACE ("Enter RegexRepeatMatcher::recursiveMatch");
 
@@ -213,7 +213,7 @@
       // _LOG_DEBUG("Match Succeed: No more components && reach m_repeatMin");
       return true;
     }
-    
+
   while(tried >= 0)
     {
       // _LOG_DEBUG("Attempt tried: " << tried);
diff --git a/src/util/regex/regex-top-matcher.cpp b/src/util/regex/regex-top-matcher.cpp
index d3b8271..78cb389 100644
--- a/src/util/regex/regex-top-matcher.cpp
+++ b/src/util/regex/regex-top-matcher.cpp
@@ -27,19 +27,19 @@
   // delete m_backRefManager;
 }
 
-void 
+void
 RegexTopMatcher::compile()
 {
   std::string errMsg = "Error: RegexTopMatcher.Compile(): ";
 
   std::string expr = m_expr;
 
-  if('$' != expr[expr.size() - 1])
+  if ('$' != expr[expr.size() - 1])
     expr = expr + "<.*>*";
   else
     expr = expr.substr(0, expr.size()-1);
 
-  if('^' != expr[0])
+  if ('^' != expr[0])
     m_secondaryMatcher = make_shared<RegexPatternListMatcher>(boost::cref("<.*>*" + expr),
                                                               boost::cref(m_secondaryBackRefManager));
   else
@@ -49,14 +49,14 @@
                                                           boost::cref(m_primaryBackRefManager));
 }
 
-bool 
-RegexTopMatcher::match(const Name & name)
+bool
+RegexTopMatcher::match(const Name& name)
 {
   m_secondaryUsed = false;
 
   m_matchResult.clear();
 
-  if(m_primaryMatcher->match(name, 0, name.size()))
+  if (m_primaryMatcher->match(name, 0, name.size()))
     {
       m_matchResult = m_primaryMatcher->getMatchResult();
       return true;
@@ -72,25 +72,25 @@
       return false;
     }
 }
-  
-bool 
-RegexTopMatcher::match (const Name & name, const int & offset, const int & len)
+
+bool
+RegexTopMatcher::match (const Name& name, const int& offset, const int& len)
 {
   return match(name);
 }
 
-Name 
+Name
 RegexTopMatcher::expand (const std::string& expandStr)
 {
   Name result;
-    
+
   shared_ptr<RegexBackrefManager> backRefManager = (m_secondaryUsed ? m_secondaryBackRefManager : m_primaryBackRefManager);
-    
+
   int backRefNum = backRefManager->size();
 
   std::string expand;
-    
-  if(expandStr != "")
+
+  if (expandStr != "")
     expand = expandStr;
   else
     expand = m_expand;
@@ -99,22 +99,22 @@
   while (offset < expand.size())
     {
       std::string item = getItemFromExpand(expand, offset);
-      if(item[0] == '<')
+      if (item[0] == '<')
         {
           result.append(item.substr(1, item.size() - 2));
         }
-      if(item[0] == '\\')
+      if (item[0] == '\\')
         {
 
           int index = atoi(item.substr(1, item.size() - 1).c_str());
 
-          if(0 == index){
+          if (0 == index){
             std::vector<name::Component>::iterator it = m_matchResult.begin();
             std::vector<name::Component>::iterator end = m_matchResult.end();
             for(; it != end; it++)
               result.append (*it);
           }
-          else if(index <= backRefNum)
+          else if (index <= backRefNum)
             {
               std::vector<name::Component>::const_iterator it = backRefManager->getBackRef (index - 1)->getMatchResult ().begin();
               std::vector<name::Component>::const_iterator end = backRefManager->getBackRef (index - 1)->getMatchResult ().end();
@@ -123,7 +123,7 @@
             }
           else
             throw RegexMatcher::Error("Exceed the range of back reference!");
-        }   
+        }
     }
   return result;
 }
@@ -133,38 +133,38 @@
 {
   size_t begin = offset;
 
-  if(expand[offset] == '\\')
+  if (expand[offset] == '\\')
     {
       offset++;
-      if(offset >= expand.size())
+      if (offset >= expand.size())
         throw RegexMatcher::Error("wrong format of expand string!");
 
       while(expand[offset] <= '9' and expand[offset] >= '0'){
         offset++;
-        if(offset > expand.size())
+        if (offset > expand.size())
           throw RegexMatcher::Error("wrong format of expand string!");
       }
-      if(offset > begin + 1)
+      if (offset > begin + 1)
         return expand.substr(begin, offset - begin);
       else
         throw RegexMatcher::Error("wrong format of expand string!");
     }
-  else if(expand[offset] == '<')
+  else if (expand[offset] == '<')
     {
       offset++;
-      if(offset >= expand.size())
+      if (offset >= expand.size())
         throw RegexMatcher::Error("wrong format of expand string!");
-        
+
       size_t left = 1;
       size_t right = 0;
       while(right < left)
         {
-          if(expand[offset] == '<')
+          if (expand[offset] == '<')
             left++;
-          if(expand[offset] == '>')
-            right++;            
+          if (expand[offset] == '>')
+            right++;
           offset++;
-          if(offset >= expand.size())
+          if (offset >= expand.size())
             throw RegexMatcher::Error("wrong format of expand string!");
         }
       return expand.substr(begin, offset - begin);
@@ -178,7 +178,7 @@
 {
   Name::const_iterator it = name.begin();
   std::string regexStr("^");
-    
+
   for(; it != name.end(); it++)
     {
       regexStr.append("<");
@@ -186,7 +186,7 @@
       regexStr.append(">");
     }
 
-  if(hasAnchor)
+  if (hasAnchor)
     regexStr.append("$");
 
   return make_shared<RegexTopMatcher>(boost::cref(regexStr));
@@ -199,7 +199,7 @@
   for(size_t i = 0; i < str.size(); i++)
     {
       char c = str[i];
-      switch(c)
+      switch (c)
         {
         case '.':
         case '[':
diff --git a/src/util/string-helper.hpp b/src/util/string-helper.hpp
index 9e2329c..7059f0a 100644
--- a/src/util/string-helper.hpp
+++ b/src/util/string-helper.hpp
@@ -13,19 +13,19 @@
 
 namespace ndn {
 
-static const char *WHITESPACE_CHARS = " \n\r\t";
+static const char* WHITESPACE_CHARS = " \n\r\t";
 
 /**
  * Return the hex representation of the bytes in array.
  * @param array The array of bytes.
  * @return Hex string.
  */
-inline std::string 
+inline std::string
 toHex(const uint8_t* array, size_t arraySize)
 {
   if (array == 0 || arraySize == 0)
     return "";
-  
+
   std::ostringstream result;
   result.flags(std::ios::hex | std::ios::uppercase);
   for (size_t i = 0; i < arraySize; ++i) {
@@ -42,7 +42,7 @@
  * Modify str in place to erase whitespace on the left.
  * @param str
  */
-inline void 
+inline void
 trimLeft(std::string& str)
 {
   size_t found = str.find_first_not_of(WHITESPACE_CHARS);
@@ -52,14 +52,14 @@
   }
   else
     // All whitespace
-    str.clear();    
+    str.clear();
 }
 
 /**
  * Modify str in place to erase whitespace on the right.
  * @param str
  */
-inline void 
+inline void
 trimRight(std::string& str)
 {
   size_t found = str.find_last_not_of(WHITESPACE_CHARS);
@@ -76,7 +76,7 @@
  * Modify str in place to erase whitespace on the left and right.
  * @param str
  */
-inline void 
+inline void
 trim(std::string& str)
 {
   trimLeft(str);
@@ -86,9 +86,9 @@
 /**
  * Convert the hex character to an integer from 0 to 15, or -1 if not a hex character.
  * @param c
- * @return 
+ * @return
  */
-inline int 
+inline int
 fromHexChar(uint8_t c)
 {
   if (c >= '0' && c <= '9')
@@ -105,22 +105,22 @@
  * Return a copy of str, converting each escaped "%XX" to the char value.
  * @param str
  */
-inline std::string 
+inline std::string
 unescape(const std::string& str)
 {
   std::ostringstream result;
-  
+
   for (size_t i = 0; i < str.size(); ++i) {
     if (str[i] == '%' && i + 2 < str.size()) {
       int hi = fromHexChar(str[i + 1]);
       int lo = fromHexChar(str[i + 2]);
-      
+
       if (hi < 0 || lo < 0)
         // Invalid hex characters, so just keep the escaped string.
         result << str[i] << str[i + 1] << str[i + 2];
       else
         result << (uint8_t)(16 * hi + lo);
-      
+
       // Skip ahead past the escaped value.
       i += 2;
     }
@@ -128,7 +128,7 @@
       // Just copy through.
       result << str[i];
   }
-  
+
   return result.str();
 }
 
