diff --git a/src/encoding/block-helpers.hpp b/src/encoding/block-helpers.hpp
index c3ae196..e29a20c 100644
--- a/src/encoding/block-helpers.hpp
+++ b/src/encoding/block-helpers.hpp
@@ -25,7 +25,7 @@
 }
 
 inline uint64_t
-readNonNegativeInteger(const Block &block)
+readNonNegativeInteger(const Block& block)
 {
   Buffer::const_iterator begin = block.value_begin();
   return Tlv::readNonNegativeInteger(block.value_size(), begin, block.value_end());
@@ -41,7 +41,7 @@
 }
 
 inline Block
-dataBlock(uint32_t type, const char *data, size_t dataSize)
+dataBlock(uint32_t type, const char* data, size_t dataSize)
 {
   OBufferStream os;
   Tlv::writeVarNumber(os, type);
@@ -52,7 +52,7 @@
 }
 
 inline Block
-dataBlock(uint32_t type, const unsigned char *data, size_t dataSize)
+dataBlock(uint32_t type, const unsigned char* data, size_t dataSize)
 {
   return dataBlock(type, reinterpret_cast<const char*>(data), dataSize);
 }
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index a734c13..9c91aa8 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -110,7 +110,7 @@
   buf[0] = *tmp_begin;
   is.read(buf+1, length-1);
 
-  if(length != static_cast<uint64_t>(is.gcount()) + 1)
+  if (length != static_cast<uint64_t>(is.gcount()) + 1)
     {
       delete [] buf;
       throw Tlv::Error("Not enough data in the buffer to fully parse TLV");
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index eef9b3d..388bac5 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -385,7 +385,7 @@
 
 
 inline void
-Block::push_back(const Block &element)
+Block::push_back(const Block& element)
 {
   resetWire();
   m_subBlocks.push_back(element);
diff --git a/src/encoding/buffer.hpp b/src/encoding/buffer.hpp
index a97edc1..0b9c327 100644
--- a/src/encoding/buffer.hpp
+++ b/src/encoding/buffer.hpp
@@ -50,7 +50,7 @@
    * @param buf const pointer to buffer
    * @param length length of the buffer to copy
    */
-  Buffer(const void *buf, size_t length)
+  Buffer(const void* buf, size_t length)
     : std::vector<uint8_t>(reinterpret_cast<const uint8_t*>(buf),
                            reinterpret_cast<const uint8_t*>(buf) + length)
   {
@@ -69,7 +69,7 @@
     : std::vector<uint8_t>(first, last)
   {
   }
-  
+
   /**
    * @brief Get pointer to the first byte of the buffer
    */
@@ -126,7 +126,7 @@
   get() const
   {
     return reinterpret_cast<const T*>(&front());
-  }  
+  }
 };
 
 /// @cond include_hidden
@@ -138,19 +138,19 @@
 public:
   typedef char char_type;
   typedef boost::iostreams::sink_tag category;
-  
+
   buffer_append_device(Buffer& container)
   : m_container(container)
   {
   }
-  
+
   std::streamsize
   write(const char_type* s, std::streamsize n)
   {
     std::copy(s, s+n, std::back_inserter(m_container));
     return n;
   }
-  
+
 protected:
   Buffer& m_container;
 };
diff --git a/src/encoding/cryptopp/asn_ext.cpp b/src/encoding/cryptopp/asn_ext.cpp
index 7741314..052226a 100644
--- a/src/encoding/cryptopp/asn_ext.cpp
+++ b/src/encoding/cryptopp/asn_ext.cpp
@@ -17,7 +17,8 @@
 namespace ndn {
 
 size_t
-DEREncodeGeneralTime(CryptoPP::BufferedTransformation &bt, const time::system_clock::TimePoint& time)
+DEREncodeGeneralTime(CryptoPP::BufferedTransformation& bt,
+                     const time::system_clock::TimePoint& time)
 {
   std::string str = time::toIsoString(time);
   // For example, 20131226T232254
@@ -32,7 +33,8 @@
 }
 
 void
-BERDecodeTime(CryptoPP::BufferedTransformation &bt, time::system_clock::TimePoint& time)
+BERDecodeTime(CryptoPP::BufferedTransformation& bt,
+              time::system_clock::TimePoint& time)
 {
   byte b;
   if (!bt.Get(b) || (b != GENERALIZED_TIME && b != UTC_TIME))
@@ -48,14 +50,14 @@
 
   std::string str;
   str.assign (time_str.begin(), time_str.end());
-  
+
   if (b == UTC_TIME) {
     if (boost::lexical_cast<int>(str.substr(0,2)) < 50)
       str = "20" + str;
     else
       str = "19" + str;
   }
- 
+
   time = time::fromIsoString(str.substr(0, 8) + "T" + str.substr(8, 6));
 }
 
diff --git a/src/encoding/cryptopp/asn_ext.hpp b/src/encoding/cryptopp/asn_ext.hpp
index 9140ed9..5d726dc 100644
--- a/src/encoding/cryptopp/asn_ext.hpp
+++ b/src/encoding/cryptopp/asn_ext.hpp
@@ -15,17 +15,28 @@
 
 namespace ndn {
 
-namespace Asn {
-struct Error : public std::runtime_error { Error(const std::string& what) : std::runtime_error(what) {} };
-}
+namespace asn {
+
+class Error : public std::runtime_error
+{
+public:
+  explicit
+  Error(const std::string& what)
+    : std::runtime_error(what)
+  {
+  }
+};
+
+} // namespace asn
 
 size_t
-DEREncodeGeneralTime(CryptoPP::BufferedTransformation& bt, const time::system_clock::TimePoint& time);
+DEREncodeGeneralTime(CryptoPP::BufferedTransformation& bt,
+                     const time::system_clock::TimePoint& time);
 
 void
-BERDecodeTime(CryptoPP::BufferedTransformation& bt, time::system_clock::TimePoint& time);
+BERDecodeTime(CryptoPP::BufferedTransformation& bt,
+              time::system_clock::TimePoint& time);
 
 } // namespace ndn
 
 #endif // NDN_ASN_EXT_HPP
-
diff --git a/src/encoding/encoding-buffer.hpp b/src/encoding/encoding-buffer.hpp
index 4251fa9..78b1628 100644
--- a/src/encoding/encoding-buffer.hpp
+++ b/src/encoding/encoding-buffer.hpp
@@ -12,10 +12,6 @@
 
 #include "../common.hpp"
 
-#include <list>
-#include <exception>
-#include <algorithm>
-
 #include "buffer.hpp"
 #include "tlv.hpp"
 #include "block.hpp"
@@ -48,11 +44,11 @@
    * The caller should make sure that that reserveFromBack does not exceed totalReserve,
    * otherwise behavior is undefined.
    */
-  EncodingImpl (size_t totalReserve = 8800,
-                size_t reserveFromBack = 400)
-    : m_buffer (new Buffer (totalReserve))
+  EncodingImpl(size_t totalReserve = 8800,
+               size_t reserveFromBack = 400)
+    : m_buffer(new Buffer(totalReserve))
   {
-    m_begin = m_end = m_buffer->end () - (reserveFromBack < totalReserve ? reserveFromBack : 0);
+    m_begin = m_end = m_buffer->end() - (reserveFromBack < totalReserve ? reserveFromBack : 0);
   }
 
   /**
@@ -66,24 +62,24 @@
    * after sign operation.
    */
   explicit
-  EncodingImpl (const Block& block)
+  EncodingImpl(const Block& block)
     : m_buffer(const_pointer_cast<Buffer>(block.m_buffer))
     , m_begin(m_buffer->begin() + (block.begin() - m_buffer->begin()))
     , m_end(m_buffer->begin()   + (block.end()   - m_buffer->begin()))
   {
   }
-  
-  inline size_t
-  size () const;
 
   inline size_t
-  capacity () const;
+  size() const;
+
+  inline size_t
+  capacity() const;
 
   inline uint8_t*
-  buf ();
+  buf();
 
   inline const uint8_t*
-  buf () const;
+  buf() const;
 
   /**
    * @brief Create Block from the underlying EncodingBuffer
@@ -93,59 +89,59 @@
    *                     length in the Block, otherwise ignored
    */
   inline Block
-  block (bool verifyLength = true) const;
+  block(bool verifyLength = true) const;
 
   inline void
-  resize (size_t sz, bool addInFront);
+  resize(size_t size, bool addInFront);
 
   inline Buffer::iterator
-  begin ();
+  begin();
 
   inline Buffer::iterator
-  end ();
+  end();
 
   inline Buffer::const_iterator
-  begin () const;
+  begin() const;
 
   inline Buffer::const_iterator
-  end () const;
+  end() const;
 
   inline size_t
-  prependByte (uint8_t val);
+  prependByte(uint8_t value);
 
   inline size_t
-  prependByteArray (const uint8_t *arr, size_t len);
+  prependByteArray(const uint8_t* array, size_t length);
 
   inline size_t
-  prependNonNegativeInteger (uint64_t varNumber);
+  prependNonNegativeInteger(uint64_t varNumber);
 
   inline size_t
-  prependVarNumber (uint64_t varNumber);
+  prependVarNumber(uint64_t varNumber);
 
   inline size_t
-  appendByte (uint8_t val);
+  appendByte(uint8_t value);
 
   inline size_t
-  appendByteArray (const uint8_t *arr, size_t len);
+  appendByteArray(const uint8_t* array, size_t length);
 
   inline size_t
-  appendNonNegativeInteger (uint64_t varNumber);
+  appendNonNegativeInteger(uint64_t varNumber);
 
   inline size_t
-  appendVarNumber (uint64_t varNumber);
+  appendVarNumber(uint64_t varNumber);
 
   // inline void
-  // removeByteFromFront ();
+  // removeByteFromFront();
 
   // inline void
-  // removeByteFromEnd ();
+  // removeByteFromEnd();
 
   // inline void
-  // removeVarNumberFromFront (uint64_t varNumber);
+  // removeVarNumberFromFront(uint64_t varNumber);
 
   // inline void
-  // removeVarNumberFromBack (uint64_t varNumber);
-  
+  // removeVarNumberFromBack(uint64_t varNumber);
+
 private:
   BufferPtr m_buffer;
 
@@ -165,34 +161,34 @@
 class EncodingImpl<encoding::Estimator>
 {
 public:
-  EncodingImpl (size_t totalReserve = 8800,
-                size_t reserveFromBack = 400)
+  EncodingImpl(size_t totalReserve = 8800,
+               size_t reserveFromBack = 400)
   {
   }
 
   inline size_t
-  prependByte (uint8_t val);
+  prependByte(uint8_t value);
 
   inline size_t
-  prependByteArray (const uint8_t *arr, size_t len);
+  prependByteArray(const uint8_t* array, size_t length);
 
   inline size_t
-  prependNonNegativeInteger (uint64_t varNumber);
+  prependNonNegativeInteger(uint64_t varNumber);
 
   inline size_t
-  prependVarNumber (uint64_t varNumber);
+  prependVarNumber(uint64_t varNumber);
 
   inline size_t
-  appendByte (uint8_t val);
+  appendByte(uint8_t value);
 
   inline size_t
-  appendByteArray (const uint8_t *arr, size_t len);
+  appendByteArray(const uint8_t* array, size_t length);
 
   inline size_t
-  appendNonNegativeInteger (uint64_t varNumber);
+  appendNonNegativeInteger(uint64_t varNumber);
 
   inline size_t
-  appendVarNumber (uint64_t varNumber);
+  appendVarNumber(uint64_t varNumber);
 };
 
 
@@ -201,31 +197,31 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 inline size_t
-EncodingImpl<encoding::Buffer>::size () const
+EncodingImpl<encoding::Buffer>::size() const
 {
   return m_end - m_begin;
 }
 
 inline size_t
-EncodingImpl<encoding::Buffer>::capacity () const
+EncodingImpl<encoding::Buffer>::capacity() const
 {
-  return m_buffer->size ();
+  return m_buffer->size();
 }
 
 inline uint8_t*
-EncodingImpl<encoding::Buffer>::buf ()
+EncodingImpl<encoding::Buffer>::buf()
 {
   return &(*m_begin);
 }
 
 inline const uint8_t*
-EncodingImpl<encoding::Buffer>::buf () const
+EncodingImpl<encoding::Buffer>::buf() const
 {
   return &(*m_begin);
 }
 
 inline Block
-EncodingImpl<encoding::Buffer>::block (bool verifyLength/* = true*/) const
+EncodingImpl<encoding::Buffer>::block(bool verifyLength/* = true*/) const
 {
   return Block(m_buffer,
                m_begin, m_end,
@@ -233,56 +229,56 @@
 }
 
 inline void
-EncodingImpl<encoding::Buffer>::resize (size_t sz, bool addInFront)
+EncodingImpl<encoding::Buffer>::resize(size_t size, bool addInFront)
 {
   if (addInFront)
     {
-      size_t diff_end = m_buffer->end () - m_end;
-      size_t diff_begin = m_buffer->end () - m_begin;
+      size_t diff_end = m_buffer->end() - m_end;
+      size_t diff_begin = m_buffer->end() - m_begin;
 
-      Buffer* buf = new Buffer (sz);
-      std::copy_backward (m_buffer->begin (), m_buffer->end (), buf->end ());
+      Buffer* buf = new Buffer(size);
+      std::copy_backward(m_buffer->begin(), m_buffer->end(), buf->end());
 
-      m_buffer.reset (buf);
+      m_buffer.reset(buf);
 
-      m_end = m_buffer->end () - diff_end;
-      m_begin = m_buffer->end () - diff_begin;
+      m_end = m_buffer->end() - diff_end;
+      m_begin = m_buffer->end() - diff_begin;
     }
   else
     {
-      size_t diff_end = m_end - m_buffer->begin ();
-      size_t diff_begin = m_begin - m_buffer->begin ();
+      size_t diff_end = m_end - m_buffer->begin();
+      size_t diff_begin = m_begin - m_buffer->begin();
 
-      Buffer* buf = new Buffer (sz);
-      std::copy (m_buffer->begin (), m_buffer->end (), buf->begin ());
+      Buffer* buf = new Buffer(size);
+      std::copy(m_buffer->begin(), m_buffer->end(), buf->begin());
 
-      m_buffer.reset (buf);
+      m_buffer.reset(buf);
 
-      m_end = m_buffer->begin () + diff_end;
-      m_begin = m_buffer->begin () + diff_begin;      
+      m_end = m_buffer->begin() + diff_end;
+      m_begin = m_buffer->begin() + diff_begin;
     }
 }
 
 inline Buffer::iterator
-EncodingImpl<encoding::Buffer>::begin ()
+EncodingImpl<encoding::Buffer>::begin()
 {
   return m_begin;
 }
 
 inline Buffer::iterator
-EncodingImpl<encoding::Buffer>::end ()
+EncodingImpl<encoding::Buffer>::end()
 {
   return m_end;
 }
 
 inline Buffer::const_iterator
-EncodingImpl<encoding::Buffer>::begin () const
+EncodingImpl<encoding::Buffer>::begin() const
 {
   return m_begin;
 }
 
 inline Buffer::const_iterator
-EncodingImpl<encoding::Buffer>::end () const
+EncodingImpl<encoding::Buffer>::end() const
 {
   return m_end;
 }
@@ -293,69 +289,69 @@
 //////////////////////////////////////////////////////////
 
 inline size_t
-EncodingImpl<encoding::Buffer>::prependByte (uint8_t val)
+EncodingImpl<encoding::Buffer>::prependByte(uint8_t value)
 {
-  if (m_begin == m_buffer->begin ())
-    resize (m_buffer->size () * 2, true);
+  if (m_begin == m_buffer->begin())
+    resize(m_buffer->size() * 2, true);
 
   m_begin--;
-  *m_begin = val;
+  *m_begin = value;
   return 1;
 }
 
 inline size_t
-EncodingImpl<encoding::Estimator>::prependByte (uint8_t val)
+EncodingImpl<encoding::Estimator>::prependByte(uint8_t value)
 {
   return 1;
 }
 
 inline size_t
-EncodingImpl<encoding::Buffer>::prependByteArray (const uint8_t *arr, size_t len)
+EncodingImpl<encoding::Buffer>::prependByteArray(const uint8_t* array, size_t length)
 {
-  if ((m_buffer->begin () + len) > m_begin)
-    resize (m_buffer->size () * 2 + len, true);
+  if ((m_buffer->begin() + length) > m_begin)
+    resize(m_buffer->size() * 2 + length, true);
 
-  m_begin -= len;
-  std::copy (arr, arr + len, m_begin);
-  return len;
+  m_begin -= length;
+  std::copy(array, array + length, m_begin);
+  return length;
 }
 
 inline size_t
-EncodingImpl<encoding::Estimator>::prependByteArray (const uint8_t *arr, size_t len)
+EncodingImpl<encoding::Estimator>::prependByteArray(const uint8_t* array, size_t length)
 {
-  return len;
+  return length;
 }
 
 inline size_t
-EncodingImpl<encoding::Buffer>::prependNonNegativeInteger (uint64_t varNumber)
+EncodingImpl<encoding::Buffer>::prependNonNegativeInteger(uint64_t varNumber)
 {
   if (varNumber <= std::numeric_limits<uint8_t>::max()) {
-    return prependByte (static_cast<uint8_t> (varNumber));
+    return prependByte(static_cast<uint8_t>(varNumber));
   }
-  else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {
-    uint16_t value = htobe16 (static_cast<uint16_t> (varNumber));
-    return prependByteArray (reinterpret_cast<const uint8_t*> (&value), 2);
+  else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
+    uint16_t value = htobe16(static_cast<uint16_t>(varNumber));
+    return prependByteArray(reinterpret_cast<const uint8_t*>(&value), 2);
   }
-  else if (varNumber <= std::numeric_limits<uint32_t>::max ()) {
-    uint32_t value = htobe32 (static_cast<uint32_t> (varNumber));
-    return prependByteArray (reinterpret_cast<const uint8_t*> (&value), 4);
+  else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
+    uint32_t value = htobe32(static_cast<uint32_t>(varNumber));
+    return prependByteArray(reinterpret_cast<const uint8_t*>(&value), 4);
   }
   else {
-    uint64_t value = htobe64 (varNumber);
-    return prependByteArray (reinterpret_cast<const uint8_t*> (&value), 8);
+    uint64_t value = htobe64(varNumber);
+    return prependByteArray(reinterpret_cast<const uint8_t*>(&value), 8);
   }
 }
 
 inline size_t
-EncodingImpl<encoding::Estimator>::prependNonNegativeInteger (uint64_t varNumber)
+EncodingImpl<encoding::Estimator>::prependNonNegativeInteger(uint64_t varNumber)
 {
   if (varNumber <= std::numeric_limits<uint8_t>::max()) {
     return 1;
   }
-  else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {
+  else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
     return 2;
   }
-  else if (varNumber <= std::numeric_limits<uint32_t>::max ()) {
+  else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
     return 4;
   }
   else {
@@ -364,42 +360,42 @@
 }
 
 inline size_t
-EncodingImpl<encoding::Buffer>::prependVarNumber (uint64_t varNumber)
+EncodingImpl<encoding::Buffer>::prependVarNumber(uint64_t varNumber)
 {
   if (varNumber < 253) {
-    prependByte (static_cast<uint8_t> (varNumber));
+    prependByte(static_cast<uint8_t>(varNumber));
     return 1;
   }
-  else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {
-    uint16_t value = htobe16 (static_cast<uint16_t> (varNumber));
-    prependByteArray (reinterpret_cast<const uint8_t*> (&value), 2);
-    prependByte (253);
+  else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
+    uint16_t value = htobe16(static_cast<uint16_t>(varNumber));
+    prependByteArray(reinterpret_cast<const uint8_t*>(&value), 2);
+    prependByte(253);
     return 3;
   }
-  else if (varNumber <= std::numeric_limits<uint32_t>::max ()) {
-    uint32_t value = htobe32 (static_cast<uint32_t> (varNumber));
-    prependByteArray (reinterpret_cast<const uint8_t*> (&value), 4);
-    prependByte (254);
+  else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
+    uint32_t value = htobe32(static_cast<uint32_t>(varNumber));
+    prependByteArray(reinterpret_cast<const uint8_t*>(&value), 4);
+    prependByte(254);
     return 5;
   }
   else {
-    uint64_t value = htobe64 (varNumber);
-    prependByteArray (reinterpret_cast<const uint8_t*> (&value), 8);
-    prependByte (255);
+    uint64_t value = htobe64(varNumber);
+    prependByteArray(reinterpret_cast<const uint8_t*>(&value), 8);
+    prependByte(255);
     return 9;
   }
 }
 
 inline size_t
-EncodingImpl<encoding::Estimator>::prependVarNumber (uint64_t varNumber)
+EncodingImpl<encoding::Estimator>::prependVarNumber(uint64_t varNumber)
 {
   if (varNumber < 253) {
     return 1;
   }
-  else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {
+  else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
     return 3;
   }
-  else if (varNumber <= std::numeric_limits<uint32_t>::max ()) {
+  else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
     return 5;
   }
   else {
@@ -412,94 +408,94 @@
 /////////////////////////////////////////////////////////
 
 inline size_t
-EncodingImpl<encoding::Buffer>::appendByte (uint8_t val)
+EncodingImpl<encoding::Buffer>::appendByte(uint8_t value)
 {
-  if (m_end == m_buffer->end ())
-    resize (m_buffer->size () * 2, false);
+  if (m_end == m_buffer->end())
+    resize(m_buffer->size() * 2, false);
 
-  *m_end = val;
+  *m_end = value;
   m_end++;
   return 1;
 }
 
 inline size_t
-EncodingImpl<encoding::Estimator>::appendByte (uint8_t val)
+EncodingImpl<encoding::Estimator>::appendByte(uint8_t value)
 {
   return 1;
 }
 
 inline size_t
-EncodingImpl<encoding::Buffer>::appendByteArray (const uint8_t *arr, size_t len)
+EncodingImpl<encoding::Buffer>::appendByteArray(const uint8_t* array, size_t length)
 {
-  if ((m_end + len) > m_buffer->end ())
-    resize (m_buffer->size () * 2 + len, false);
+  if ((m_end + length) > m_buffer->end())
+    resize(m_buffer->size() * 2 + length, false);
 
-  std::copy (arr, arr + len, m_end);
-  m_end += len;
-  return len;
+  std::copy(array, array + length, m_end);
+  m_end += length;
+  return length;
 }
 
 inline size_t
-EncodingImpl<encoding::Estimator>::appendByteArray (const uint8_t *arr, size_t len)
+EncodingImpl<encoding::Estimator>::appendByteArray(const uint8_t* array, size_t length)
 {
-  return prependByteArray(arr, len);
+  return prependByteArray(array, length);
 }
 
 inline size_t
-EncodingImpl<encoding::Buffer>::appendNonNegativeInteger (uint64_t varNumber)
+EncodingImpl<encoding::Buffer>::appendNonNegativeInteger(uint64_t varNumber)
 {
-  if (varNumber <= std::numeric_limits<uint8_t>::max ()) {
-    return appendByte (static_cast<uint8_t> (varNumber));
+  if (varNumber <= std::numeric_limits<uint8_t>::max()) {
+    return appendByte(static_cast<uint8_t>(varNumber));
   }
-  else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {
-    uint16_t value = htobe16 (static_cast<uint16_t> (varNumber));
-    return appendByteArray (reinterpret_cast<const uint8_t*> (&value), 2);
+  else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
+    uint16_t value = htobe16(static_cast<uint16_t>(varNumber));
+    return appendByteArray(reinterpret_cast<const uint8_t*>(&value), 2);
   }
-  else if (varNumber <= std::numeric_limits<uint32_t>::max ()) {
-    uint32_t value = htobe32 (static_cast<uint32_t> (varNumber));
-    return appendByteArray (reinterpret_cast<const uint8_t*> (&value), 4);
+  else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
+    uint32_t value = htobe32(static_cast<uint32_t>(varNumber));
+    return appendByteArray(reinterpret_cast<const uint8_t*>(&value), 4);
   }
   else {
-    uint64_t value = htobe64 (varNumber);
-    return appendByteArray (reinterpret_cast<const uint8_t*> (&value), 8);
+    uint64_t value = htobe64(varNumber);
+    return appendByteArray(reinterpret_cast<const uint8_t*>(&value), 8);
   }
 }
 
 inline size_t
-EncodingImpl<encoding::Estimator>::appendNonNegativeInteger (uint64_t varNumber)
+EncodingImpl<encoding::Estimator>::appendNonNegativeInteger(uint64_t varNumber)
 {
   return prependNonNegativeInteger(varNumber);
 }
 
 inline size_t
-EncodingImpl<encoding::Buffer>::appendVarNumber (uint64_t varNumber)
+EncodingImpl<encoding::Buffer>::appendVarNumber(uint64_t varNumber)
 {
   if (varNumber < 253) {
-    appendByte (static_cast<uint8_t> (varNumber));
+    appendByte(static_cast<uint8_t>(varNumber));
     return 1;
   }
-  else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {
-    appendByte (253);
-    uint16_t value = htobe16 (static_cast<uint16_t> (varNumber));
-    appendByteArray (reinterpret_cast<const uint8_t*> (&value), 2);
+  else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
+    appendByte(253);
+    uint16_t value = htobe16(static_cast<uint16_t>(varNumber));
+    appendByteArray(reinterpret_cast<const uint8_t*>(&value), 2);
     return 3;
   }
-  else if (varNumber <= std::numeric_limits<uint32_t>::max ()) {
-    appendByte (254);
-    uint32_t value = htobe32 (static_cast<uint32_t> (varNumber));
-    appendByteArray (reinterpret_cast<const uint8_t*> (&value), 4);
+  else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
+    appendByte(254);
+    uint32_t value = htobe32(static_cast<uint32_t>(varNumber));
+    appendByteArray(reinterpret_cast<const uint8_t*>(&value), 4);
     return 5;
   }
   else {
-    appendByte (255);
-    uint64_t value = htobe64 (varNumber);
-    appendByteArray (reinterpret_cast<const uint8_t*> (&value), 8);
+    appendByte(255);
+    uint64_t value = htobe64(varNumber);
+    appendByteArray(reinterpret_cast<const uint8_t*>(&value), 8);
     return 9;
   }
 }
 
 inline size_t
-EncodingImpl<encoding::Estimator>::appendVarNumber (uint64_t varNumber)
+EncodingImpl<encoding::Estimator>::appendVarNumber(uint64_t varNumber)
 {
   return prependVarNumber(varNumber);
 }
@@ -508,56 +504,57 @@
 
 template<bool P>
 inline size_t
-prependNonNegativeIntegerBlock(EncodingImpl<P>& blk, uint32_t type, uint64_t number)
+prependNonNegativeIntegerBlock(EncodingImpl<P>& encoder, uint32_t type, uint64_t number)
 {
-  size_t var_len = blk.prependNonNegativeInteger(number);
-  size_t total_len = var_len;
-  total_len += blk.prependVarNumber(var_len);
-  total_len += blk.prependVarNumber(type);
+  size_t valueLength = encoder.prependNonNegativeInteger(number);
+  size_t totalLength = valueLength;
+  totalLength += encoder.prependVarNumber(valueLength);
+  totalLength += encoder.prependVarNumber(type);
 
-  return total_len;
+  return totalLength;
 }
 
 template<bool P>
 inline size_t
-prependByteArrayBlock(EncodingImpl<P>& blk, uint32_t type, const uint8_t* array, size_t arraySize)
+prependByteArrayBlock(EncodingImpl<P>& encoder, uint32_t type,
+                      const uint8_t* array, size_t arraySize)
 {
-  size_t var_len = blk.prependByteArray(array, arraySize);
-  size_t total_len = var_len;
-  total_len += blk.prependVarNumber(var_len);
-  total_len += blk.prependVarNumber(type);
+  size_t valueLength = encoder.prependByteArray(array, arraySize);
+  size_t totalLength = valueLength;
+  totalLength += encoder.prependVarNumber(valueLength);
+  totalLength += encoder.prependVarNumber(type);
 
-  return total_len;
+  return totalLength;
 }
 
 template<bool P>
 inline size_t
-prependBooleanBlock(EncodingImpl<P>& blk, uint32_t type)
+prependBooleanBlock(EncodingImpl<P>& encoder, uint32_t type)
 {
-  size_t total_len = blk.prependVarNumber(0);
-  total_len += blk.prependVarNumber(type);
+  size_t totalLength = encoder.prependVarNumber(0);
+  totalLength += encoder.prependVarNumber(type);
 
-  return total_len;
+  return totalLength;
 }
 
 
 template<bool P, class U>
 inline size_t
-prependNestedBlock(EncodingImpl<P>& blk, uint32_t type, const U& nestedBlock)
+prependNestedBlock(EncodingImpl<P>& encoder, uint32_t type, const U& nestedBlock)
 {
-  size_t var_len = nestedBlock.wireEncode(blk);
-  size_t total_len = var_len;
-  total_len += blk.prependVarNumber(var_len);
-  total_len += blk.prependVarNumber(type);
+  size_t valueLength = nestedBlock.wireEncode(encoder);
+  size_t totalLength = valueLength;
+  totalLength += encoder.prependVarNumber(valueLength);
+  totalLength += encoder.prependVarNumber(type);
 
-  return total_len;
+  return totalLength;
 }
 
 template<bool P>
 inline size_t
-prependBlock(EncodingImpl<P>& blk, const Block& block)
+prependBlock(EncodingImpl<P>& encoder, const Block& block)
 {
-  return blk.prependByteArray(block.wire(), block.size());
+  return encoder.prependByteArray(block.wire(), block.size());
 }
 
 
diff --git a/src/encoding/oid.cpp b/src/encoding/oid.cpp
index 5f36473..cff98cd 100644
--- a/src/encoding/oid.cpp
+++ b/src/encoding/oid.cpp
@@ -16,7 +16,7 @@
 
 namespace ndn {
 
-OID::OID(const char *oid)
+OID::OID(const char* oid)
 {
   construct(oid);
 }
@@ -27,21 +27,21 @@
 }
 
 void
-OID::construct(const std::string &oid)
+OID::construct(const std::string& oid)
 {
   string str = oid + ".";
 
   size_t pos = 0;
   size_t ppos = 0;
 
-  while(string::npos != pos){
+  while (string::npos != pos) {
     ppos = pos;
 
     pos = str.find_first_of('.', pos);
-    if(pos == string::npos)
+    if (pos == string::npos)
       break;
 
-    oid_.push_back(atoi(str.substr(ppos, pos - ppos).c_str()));
+    m_oid.push_back(atoi(str.substr(ppos, pos - ppos).c_str()));
 
     pos++;
   }
@@ -50,54 +50,53 @@
 string OID::toString() const
 {
   ostringstream convert;
-  
-  vector<int>::const_iterator it = oid_.begin();
-  for(; it < oid_.end(); it++){
-    if(it != oid_.begin())
+
+  for (vector<int>::const_iterator it = m_oid.begin(); it != m_oid.end(); ++it) {
+    if (it != m_oid.begin())
       convert << ".";
     convert << *it;
   }
-  
+
   return convert.str();
 }
 
 bool
 OID::equal(const OID& oid) const
 {
-  vector<int>::const_iterator i = oid_.begin();
-  vector<int>::const_iterator j = oid.oid_.begin();
-    
-  for (; i != oid_.end () && j != oid.oid_.end (); i++, j++) {
-    if(*i != *j)
+  vector<int>::const_iterator i = m_oid.begin();
+  vector<int>::const_iterator j = oid.m_oid.begin();
+
+  for (; i != m_oid.end () && j != oid.m_oid.end (); i++, j++) {
+    if (*i != *j)
       return false;
   }
 
-  if (i == oid_.end () && j == oid.oid_.end ())
+  if (i == m_oid.end () && j == oid.m_oid.end ())
     return true;
   else
     return false;
 }
 
 inline void
-EncodeValue(BufferedTransformation &bt, word32 v)
+EncodeValue(BufferedTransformation& bt, word32 v)
 {
-  for (unsigned int i=RoundUpToMultipleOf(STDMAX(7U,BitPrecision(v)), 7U)-7; i != 0; i-=7)
+  for (unsigned int i = RoundUpToMultipleOf(STDMAX(7U,BitPrecision(v)), 7U) - 7; i != 0; i -= 7)
     bt.Put((byte)(0x80 | ((v >> i) & 0x7f)));
   bt.Put((byte)(v & 0x7f));
 }
 
 inline size_t
-DecodeValue(BufferedTransformation &bt, word32 &v)
+DecodeValue(BufferedTransformation& bt, word32& v)
 {
-  byte b;
-  size_t i=0;
   v = 0;
+  size_t i = 0;
   while (true)
     {
+      byte b;
       if (!bt.Get(b))
         BERDecodeError();
       i++;
-      if (v >> (8*sizeof(v)-7))	// v about to overflow
+      if (v >> (8*sizeof(v) - 7)) // v about to overflow
         BERDecodeError();
       v <<= 7;
       v += b & 0x7f;
@@ -107,20 +106,22 @@
 }
 
 void
-OID::encode(CryptoPP::BufferedTransformation &out) const
+OID::encode(CryptoPP::BufferedTransformation& out) const
 {
-  assert(oid_.size() >= 2);
+  BOOST_ASSERT(m_oid.size() >= 2);
+
   ByteQueue temp;
-  temp.Put(byte(oid_[0] * 40 + oid_[1]));
-  for (size_t i=2; i<oid_.size(); i++)
-    EncodeValue(temp, oid_[i]);
+  temp.Put(byte(m_oid[0] * 40 + m_oid[1]));
+  for (size_t i = 2; i < m_oid.size(); i++)
+    EncodeValue(temp, m_oid[i]);
+
   out.Put(OBJECT_IDENTIFIER);
   DERLengthEncode(out, temp.CurrentSize());
   temp.TransferTo(out);
 }
 
 void
-OID::decode(CryptoPP::BufferedTransformation &in)
+OID::decode(CryptoPP::BufferedTransformation& in)
 {
   byte b;
   if (!in.Get(b) || b != OBJECT_IDENTIFIER)
@@ -132,11 +133,11 @@
 
   if (!in.Get(b))
     BERDecodeError();
-	
+
   length--;
-  oid_.resize(2);
-  oid_[0] = b / 40;
-  oid_[1] = b % 40;
+  m_oid.resize(2);
+  m_oid[0] = b / 40;
+  m_oid[1] = b % 40;
 
   while (length > 0)
     {
@@ -144,9 +145,9 @@
       size_t valueLen = DecodeValue(in, v);
       if (valueLen > length)
         BERDecodeError();
-      oid_.push_back(v);
+      m_oid.push_back(v);
       length -= valueLen;
     }
 }
 
-}
+} // namespace ndn
diff --git a/src/encoding/oid.hpp b/src/encoding/oid.hpp
index 308da8e..e7b1beb 100644
--- a/src/encoding/oid.hpp
+++ b/src/encoding/oid.hpp
@@ -17,31 +17,31 @@
 
 class OID {
 public:
-  OID () 
+  OID ()
   {
   }
-    
-  OID(const char *oid);
+
+  OID(const char* oid);
 
   OID(const std::string& oid);
 
   OID(const std::vector<int>& oid)
-  : oid_(oid)
+    : m_oid(oid)
   {
   }
 
-  const std::vector<int> &
+  const std::vector<int>&
   getIntegerList() const
   {
-    return oid_;
+    return m_oid;
   }
 
   void
   setIntegerList(const std::vector<int>& value){
-    oid_ = value;
+    m_oid = value;
   }
 
-  std::string 
+  std::string
   toString() const;
 
   bool operator == (const OID& oid) const
@@ -55,21 +55,21 @@
   }
 
   void
-  encode(CryptoPP::BufferedTransformation &out) const;
+  encode(CryptoPP::BufferedTransformation& out) const;
 
   void
-  decode(CryptoPP::BufferedTransformation &in);
+  decode(CryptoPP::BufferedTransformation& in);
 
 
 private:
   void
-  construct(const std::string &value);
-  
+  construct(const std::string& value);
+
   bool
   equal(const OID& oid) const;
 
 private:
-  std::vector<int> oid_;
+  std::vector<int> m_oid;
 };
 
 }
