diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 07ec2f0..a734c13 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -37,10 +37,10 @@
     }
 }
 
-Block::Block(const ConstBufferPtr &wire,
+Block::Block(const ConstBufferPtr& wire,
              uint32_t type,
-             const Buffer::const_iterator &begin, const Buffer::const_iterator &end,
-             const Buffer::const_iterator &valueBegin, const Buffer::const_iterator &valueEnd)
+             const Buffer::const_iterator& begin, const Buffer::const_iterator& end,
+             const Buffer::const_iterator& valueBegin, const Buffer::const_iterator& valueEnd)
   : m_buffer(wire)
   , m_type(type)
   , m_begin(begin)
@@ -51,7 +51,7 @@
 {
 }
 
-Block::Block(const ConstBufferPtr &buffer)
+Block::Block(const ConstBufferPtr& buffer)
   : m_buffer(buffer)
   , m_begin(m_buffer->begin())
   , m_end(m_buffer->end())
@@ -69,8 +69,8 @@
     }
 }
 
-Block::Block(const ConstBufferPtr &buffer,
-             const Buffer::const_iterator &begin, const Buffer::const_iterator &end,
+Block::Block(const ConstBufferPtr& buffer,
+             const Buffer::const_iterator& begin, const Buffer::const_iterator& end,
              bool verifyLength/* = true*/)
   : m_buffer(buffer)
   , m_begin(begin)
@@ -99,7 +99,8 @@
   m_type = Tlv::readType(tmp_begin, tmp_end);
   uint64_t length = Tlv::readVarNumber(tmp_begin, tmp_end);
 
-  // We may still have some problem here, if some exception happens in this constructor, we may completely lose all the bytes extracted from the stream.
+  // We may still have some problem here, if some exception happens in this constructor,
+  // we may completely lose all the bytes extracted from the stream.
 
   OBufferStream os;
   size_t headerLength = Tlv::writeVarNumber(os, m_type);
@@ -109,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");
@@ -129,10 +130,10 @@
 }
 
 
-Block::Block(const uint8_t *buffer, size_t maxlength)
+Block::Block(const uint8_t* buffer, size_t maxlength)
 {
-  const uint8_t * tmp_begin = buffer;
-  const uint8_t * tmp_end   = buffer + maxlength;
+  const uint8_t*  tmp_begin = buffer;
+  const uint8_t*  tmp_end   = buffer + maxlength;
 
   m_type = Tlv::readType(tmp_begin, tmp_end);
   uint64_t length = Tlv::readVarNumber(tmp_begin, tmp_end);
@@ -142,7 +143,7 @@
       throw Tlv::Error("Not enough data in the buffer to fully parse TLV");
     }
 
-  m_buffer = ptr_lib::make_shared<Buffer> (buffer, (tmp_begin - buffer) + length);
+  m_buffer = ptr_lib::make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
 
   m_begin = m_buffer->begin();
   m_end = m_buffer->end();
@@ -152,12 +153,12 @@
   m_value_end   = m_buffer->end();
 }
 
-Block::Block(const void *bufferX, size_t maxlength)
+Block::Block(const void* bufferX, size_t maxlength)
 {
-  const uint8_t * buffer = reinterpret_cast<const uint8_t*>(bufferX);
+  const uint8_t* buffer = reinterpret_cast<const uint8_t*>(bufferX);
 
-  const uint8_t * tmp_begin = buffer;
-  const uint8_t * tmp_end   = buffer + maxlength;
+  const uint8_t* tmp_begin = buffer;
+  const uint8_t* tmp_end   = buffer + maxlength;
 
   m_type = Tlv::readType(tmp_begin, tmp_end);
   uint64_t length = Tlv::readVarNumber(tmp_begin, tmp_end);
@@ -167,7 +168,7 @@
       throw Tlv::Error("Not enough data in the buffer to fully parse TLV");
     }
 
-  m_buffer = ptr_lib::make_shared<Buffer> (buffer, (tmp_begin - buffer) + length);
+  m_buffer = ptr_lib::make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
 
   m_begin = m_buffer->begin();
   m_end = m_buffer->end();
@@ -182,7 +183,7 @@
 {
 }
 
-Block::Block(uint32_t type, const ConstBufferPtr &value)
+Block::Block(uint32_t type, const ConstBufferPtr& value)
   : m_buffer(value)
   , m_type(type)
   , m_begin(m_buffer->end())
@@ -193,7 +194,7 @@
   m_size = Tlv::sizeOfVarNumber(m_type) + Tlv::sizeOfVarNumber(value_size()) + value_size();
 }
 
-Block::Block(uint32_t type, const Block &value)
+Block::Block(uint32_t type, const Block& value)
   : m_buffer(value.m_buffer)
   , m_type(type)
   , m_begin(m_buffer->end())
@@ -210,13 +211,13 @@
   Buffer::const_iterator tempBegin = wire->begin() + offset;
 
   uint32_t type;
-  bool ok = Tlv::readType(tempBegin, wire->end(), type);
-  if (!ok)
+  bool isOk = Tlv::readType(tempBegin, wire->end(), type);
+  if (!isOk)
     return false;
 
   uint64_t length;
-  ok = Tlv::readVarNumber(tempBegin, wire->end(), length);
-  if (!ok)
+  isOk = Tlv::readVarNumber(tempBegin, wire->end(), length);
+  if (!isOk)
     return false;
 
   if (length > static_cast<uint64_t>(wire->end() - tempBegin))
@@ -238,13 +239,13 @@
   const uint8_t* tempEnd = buffer + maxSize;
 
   uint32_t type;
-  bool ok = Tlv::readType(tempBegin, tempEnd, type);
-  if (!ok)
+  bool isOk = Tlv::readType(tempBegin, tempEnd, type);
+  if (!isOk)
     return false;
 
   uint64_t length;
-  ok = Tlv::readVarNumber(tempBegin, tempEnd, length);
-  if (!ok)
+  isOk = Tlv::readVarNumber(tempBegin, tempEnd, length);
+  if (!isOk)
     return false;
 
   if (length > static_cast<uint64_t>(tempEnd - tempBegin))
@@ -263,11 +264,11 @@
 void
 Block::parse() const
 {
-  if (!m_subBlocks.empty() || value_size()==0)
+  if (!m_subBlocks.empty() || value_size() == 0)
     return;
 
-  Buffer::const_iterator begin = value_begin(),
-    end = value_end();
+  Buffer::const_iterator begin = value_begin();
+  Buffer::const_iterator end = value_end();
 
   while (begin != end)
     {
@@ -350,7 +351,7 @@
 Block
 Block::blockFromValue() const
 {
-  if (value_size()==0)
+  if (value_size() == 0)
     throw Error("Underlying value buffer is empty");
 
   Buffer::const_iterator begin = value_begin(),
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index a2507b5..09bc93d 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -31,9 +31,14 @@
   typedef element_container::const_iterator  element_const_iterator;
 
   /// @brief Error that can be thrown from the block
-  struct Error : public std::runtime_error
+  class Error : public std::runtime_error
   {
-    Error(const std::string& what) : std::runtime_error(what) {}
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
+    {
+    }
   };
 
   /**
@@ -49,6 +54,8 @@
 
   /**
    * @brief A helper version of a constructor to create Block from the raw buffer (type and value-length parsing)
+   *
+   * This constructor provides ability of implicit conversion from ConstBufferPtr to Block
    */
   Block(const ConstBufferPtr& buffer);
 
@@ -72,6 +79,7 @@
   /*
    * @brief A helper version of a constructor to create Block from the stream.
    */
+  explicit
   Block(std::istream& is);
 
   /**
@@ -132,31 +140,31 @@
   /**
    * @brief Check if the Block is empty
    */
-  inline bool
+  bool
   empty() const;
 
   /**
    * @brief Check if the Block has fully encoded wire
    */
-  inline bool
+  bool
   hasWire() const;
 
   /**
    * @brief Check if the Block has value block (no type and length are encoded)
    */
-  inline bool
+  bool
   hasValue() const;
 
   /**
    * @brief Reset wire buffer of the element
    */
-  inline void
+  void
   reset();
 
   /**
    * @brief Reset wire buffer but keep sub elements (if any)
    */
-  inline void
+  void
   resetWire();
 
   /**
@@ -174,70 +182,67 @@
   void
   encode();
 
-  inline uint32_t
+  uint32_t
   type() const;
 
   /**
    * @brief Get the first subelement of the requested type
    */
-  inline const Block&
+  const Block&
   get(uint32_t type) const;
 
-  inline element_const_iterator
+  element_const_iterator
   find(uint32_t type) const;
 
-  inline void
+  void
   remove(uint32_t type);
 
-  inline element_iterator
+  element_iterator
   erase(element_iterator position);
 
-  inline element_iterator
+  element_iterator
   erase(element_iterator first, element_iterator last);
 
-  inline void
+  void
   push_back(const Block& element);
 
-  inline Buffer::const_iterator
+  Buffer::const_iterator
   begin() const;
 
-  inline Buffer::const_iterator
+  Buffer::const_iterator
   end() const;
 
-  inline const uint8_t*
+  const uint8_t*
   wire() const;
 
-  inline size_t
+  size_t
   size() const;
 
-  // inline const uint8_t*
-  // buf() const;
-
-  inline Buffer::const_iterator
+  Buffer::const_iterator
   value_begin() const;
 
-  inline Buffer::const_iterator
+  Buffer::const_iterator
   value_end() const;
 
-  inline const uint8_t*
+  const uint8_t*
   value() const;
 
-  inline size_t
+  size_t
   value_size() const;
 
   /**
    * @brief Get all subelements
    */
-  inline const element_container&
-  elements () const;
+  const element_container&
+  elements() const;
 
-  inline element_const_iterator
+  element_const_iterator
   elements_begin() const;
 
-  inline element_const_iterator
+  element_const_iterator
   elements_end() const;
 
-  inline size_t
+  size_t
   elements_size() const;
 
   Block
@@ -289,7 +294,7 @@
   m_subBlocks.clear(); // remove all parsed subelements
 
   m_type = std::numeric_limits<uint32_t>::max();
-  m_begin = m_end = m_value_begin = m_value_end = Buffer::const_iterator(); // not really necessary, but for safety
+  m_begin = m_end = m_value_begin = m_value_end = Buffer::const_iterator();
 }
 
 inline void
@@ -299,7 +304,7 @@
   // keep subblocks
 
   // keep type
-  m_begin = m_end = m_value_begin = m_value_end = Buffer::const_iterator(); // not really necessary, but for safety
+  m_begin = m_end = m_value_begin = m_value_end = Buffer::const_iterator();
 }
 
 inline uint32_t
@@ -311,27 +316,28 @@
 inline const Block&
 Block::get(uint32_t type) const
 {
-  for (element_const_iterator i = m_subBlocks.begin ();
+  for (element_const_iterator i = m_subBlocks.begin();
        i != m_subBlocks.end();
        i++)
     {
-      if (i->type () == type)
+      if (i->type() == type)
         {
           return *i;
         }
     }
 
-  throw Error("(Block::get) Requested a non-existed type [" + boost::lexical_cast<std::string>(type) + "] from Block");
+  throw Error("(Block::get) Requested a non-existed type [" +
+              boost::lexical_cast<std::string>(type) + "] from Block");
 }
 
 inline Block::element_const_iterator
 Block::find(uint32_t type) const
 {
-  for (element_const_iterator i = m_subBlocks.begin ();
+  for (element_const_iterator i = m_subBlocks.begin();
        i != m_subBlocks.end();
        i++)
     {
-      if (i->type () == type)
+      if (i->type() == type)
         {
           return i;
         }
@@ -446,7 +452,7 @@
 }
 
 inline const Block::element_container&
-Block::elements () const
+Block::elements() const
 {
   return m_subBlocks;
 }
diff --git a/src/encoding/buffer.hpp b/src/encoding/buffer.hpp
index 398817f..a97edc1 100644
--- a/src/encoding/buffer.hpp
+++ b/src/encoding/buffer.hpp
@@ -31,7 +31,7 @@
   /**
    * @brief Creates an empty buffer
    */
-  Buffer ()
+  Buffer()
   {
   }
 
@@ -39,8 +39,9 @@
    * @brief Creates a buffer with pre-allocated size
    * @param size size of the buffer to be allocated
    */
-  Buffer (size_t size)
-    : std::vector<uint8_t> (size, 0)
+  explicit
+  Buffer(size_t size)
+    : std::vector<uint8_t>(size, 0)
   {
   }
 
@@ -49,8 +50,9 @@
    * @param buf const pointer to buffer
    * @param length length of the buffer to copy
    */
-  Buffer (const void *buf, size_t length)
-    : std::vector<uint8_t> (reinterpret_cast<const uint8_t*> (buf), reinterpret_cast<const uint8_t*> (buf) + 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)
   {
   }
 
@@ -63,27 +65,27 @@
    * @param last  iterator to an element immediately following the last element to copy
    */
   template <class InputIterator>
-  Buffer (InputIterator first, InputIterator last)
-    : std::vector<uint8_t> (first, last)
+  Buffer(InputIterator first, InputIterator last)
+    : std::vector<uint8_t>(first, last)
   {
   }
   
   /**
    * @brief Get pointer to the first byte of the buffer
    */
-  inline uint8_t*
-  get ()
+  uint8_t*
+  get()
   {
-    return &front ();
+    return &front();
   }
 
   /**
    * @brief Get pointer to the first byte of the buffer (alternative version)
    */
-  inline uint8_t*
-  buf ()
+  uint8_t*
+  buf()
   {
-    return &front ();
+    return &front();
   }
 
   /**
@@ -91,28 +93,28 @@
    * it (reinterpret_cast) to the requested type T
    */
   template<class T>
-  inline T*
-  get ()
+  T*
+  get()
   {
-    return reinterpret_cast<T *>(&front ());
+    return reinterpret_cast<T*>(&front());
   }
 
   /**
    * @brief Get pointer to the first byte of the buffer (alternative version)
    */
-  inline const uint8_t*
-  buf () const
+  const uint8_t*
+  buf() const
   {
-    return &front ();
+    return &front();
   }
 
   /**
    * @brief Get const pointer to the first byte of the buffer
    */
-  inline const uint8_t*
-  get () const
+  const uint8_t*
+  get() const
   {
-    return &front ();
+    return &front();
   }
 
   /**
@@ -120,10 +122,10 @@
    * it (reinterpret_cast) to the requested type T
    */
   template<class T>
-  inline const T*
-  get () const
+  const T*
+  get() const
   {
-    return reinterpret_cast<const T *>(&front ());
+    return reinterpret_cast<const T*>(&front());
   }  
 };
 
@@ -131,20 +133,21 @@
 namespace iostreams
 {
 
-class buffer_append_device {
+class buffer_append_device
+{
 public:
-  typedef char  char_type;
-  typedef boost::iostreams::sink_tag       category;
+  typedef char char_type;
+  typedef boost::iostreams::sink_tag category;
   
-  buffer_append_device (Buffer& container)
-  : m_container (container)
+  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));
+    std::copy(s, s+n, std::back_inserter(m_container));
     return n;
   }
   
@@ -158,8 +161,9 @@
 /**
  * Class implementing interface similar to ostringstream, but to construct ndn::Buffer
  *
- * The benefit of using stream interface is that it provides automatic buffering of written data
- * and eliminates (or reduces) overhead of resizing the underlying buffer when writing small pieces of data.
+ * The benefit of using stream interface is that it provides automatic buffering of
+ * written data and eliminates (or reduces) overhead of resizing the underlying buffer
+ * when writing small pieces of data.
  *
  * Usage example:
  * @code
@@ -174,20 +178,20 @@
   /**
    * Default constructor
    */
-  OBufferStream ()
-    : m_buffer (ptr_lib::make_shared<Buffer> ())
-    , m_device (*m_buffer)
+  OBufferStream()
+    : m_buffer(ptr_lib::make_shared<Buffer>())
+    , m_device(*m_buffer)
   {
-    open (m_device);
+    open(m_device);
   }
 
   /**
    * Flush written data to the stream and return shared pointer to the underlying buffer
    */
   ptr_lib::shared_ptr<Buffer>
-  buf ()
+  buf()
   {
-    flush ();
+    flush();
     return m_buffer;
   }
 
diff --git a/src/encoding/tlv.hpp b/src/encoding/tlv.hpp
index 2ef008c..9cb1a0f 100644
--- a/src/encoding/tlv.hpp
+++ b/src/encoding/tlv.hpp
@@ -22,7 +22,15 @@
  */
 namespace Tlv {
 
-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 {
   Interest      = 5,
@@ -31,7 +39,7 @@
   NameComponent = 8,
   Selectors     = 9,
   Nonce         = 10,
-  Scope         = 11,
+  Scope         = 11, // deprecated
   InterestLifetime          = 12,
   MinSuffixComponents       = 13,
   MaxSuffixComponents       = 14,
@@ -79,7 +87,7 @@
  */
 template<class InputIterator>
 inline bool
-readVarNumber(InputIterator &begin, const InputIterator &end, uint64_t& number);
+readVarNumber(InputIterator& begin, const InputIterator& end, uint64_t& number);
 
 /**
  * @brief Read TLV Type
@@ -95,7 +103,7 @@
  */
 template<class InputIterator>
 inline bool
-readType(InputIterator &begin, const InputIterator &end, uint32_t& type);
+readType(InputIterator& begin, const InputIterator& end, uint32_t& type);
 
 
 /**
@@ -107,7 +115,7 @@
  */
 template<class InputIterator>
 inline uint64_t
-readVarNumber(InputIterator &begin, const InputIterator &end);
+readVarNumber(InputIterator& begin, const InputIterator& end);
 
 /**
  * @brief Read TLV Type
@@ -119,7 +127,7 @@
  */
 template<class InputIterator>
 inline uint32_t
-readType(InputIterator &begin, const InputIterator &end);
+readType(InputIterator& begin, const InputIterator& end);
 
 /**
  * @brief Get number of bytes necessary to hold value of VAR-NUMBER
@@ -131,7 +139,7 @@
  * @brief Write VAR-NUMBER to the specified stream
  */
 inline size_t
-writeVarNumber(std::ostream &os, uint64_t varNumber);
+writeVarNumber(std::ostream& os, uint64_t varNumber);
 
 /**
  * @brief Read nonNegativeInteger in NDN-TLV encoding
@@ -145,7 +153,7 @@
  */
 template<class InputIterator>
 inline uint64_t
-readNonNegativeInteger(size_t size, InputIterator &begin, const InputIterator &end);
+readNonNegativeInteger(size_t size, InputIterator& begin, const InputIterator& end);
 
 /**
  * @brief Get number of bytes necessary to hold value of nonNegativeInteger
@@ -157,7 +165,7 @@
  * @brief Write nonNegativeInteger to the specified stream
  */
 inline size_t
-writeNonNegativeInteger(std::ostream &os, uint64_t varNumber);
+writeNonNegativeInteger(std::ostream& os, uint64_t varNumber);
 
 /////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////
@@ -171,18 +179,18 @@
 
 template<class InputIterator>
 inline bool
-readVarNumber(InputIterator &begin, const InputIterator &end, uint64_t& number)
+readVarNumber(InputIterator& begin, const InputIterator& end, uint64_t& number)
 {
   if (begin == end)
     return false;
 
-  uint8_t value = *begin;
+  uint8_t firstOctet = *begin;
   ++begin;
-  if (value < 253)
+  if (firstOctet < 253)
     {
-      number = value;
+      number = firstOctet;
     }
-  else if (value == 253)
+  else if (firstOctet == 253)
     {
       if (end - begin < 2)
         return false;
@@ -191,7 +199,7 @@
       begin += 2;
       number = be16toh(value);
     }
-  else if (value == 254)
+  else if (firstOctet == 254)
     {
       if (end - begin < 4)
         return false;
@@ -200,7 +208,7 @@
       begin += 4;
       number = be32toh(value);
     }
-  else // if (value == 255)
+  else // if (firstOctet == 255)
     {
       if (end - begin < 8)
         return false;
@@ -216,7 +224,7 @@
 
 template<class InputIterator>
 inline bool
-readType(InputIterator &begin, const InputIterator &end, uint32_t& type)
+readType(InputIterator& begin, const InputIterator& end, uint32_t& type)
 {
   uint64_t number;
   bool ok = readVarNumber(begin, end, number);
@@ -225,24 +233,24 @@
       return false;
     }
 
-  type = static_cast<uint64_t> (number);
+  type = static_cast<uint64_t>(number);
   return true;
 }
 
 template<class InputIterator>
 inline uint64_t
-readVarNumber(InputIterator &begin, const InputIterator &end)
+readVarNumber(InputIterator& begin, const InputIterator& end)
 {
   if (begin == end)
     throw Error("Empty buffer during TLV processing");
 
-  uint8_t value = *begin;
+  uint8_t firstOctet = *begin;
   ++begin;
-  if (value < 253)
+  if (firstOctet < 253)
     {
-      return value;
+      return firstOctet;
     }
-  else if (value == 253)
+  else if (firstOctet == 253)
     {
       if (end - begin < 2)
         throw Error("Insufficient data during TLV processing");
@@ -251,7 +259,7 @@
       begin += 2;
       return be16toh(value);
     }
-  else if (value == 254)
+  else if (firstOctet == 254)
     {
       if (end - begin < 4)
         throw Error("Insufficient data during TLV processing");
@@ -260,7 +268,7 @@
       begin += 4;
       return be32toh(value);
     }
-  else // if (value == 255)
+  else // if (firstOctet == 255)
     {
       if (end - begin < 8)
         throw Error("Insufficient data during TLV processing");
@@ -274,19 +282,19 @@
 
 template<>
 inline uint64_t
-readVarNumber<std::istream_iterator<uint8_t> >(std::istream_iterator<uint8_t> &begin,
-                                               const std::istream_iterator<uint8_t> &end)
+readVarNumber<std::istream_iterator<uint8_t> >(std::istream_iterator<uint8_t>& begin,
+                                               const std::istream_iterator<uint8_t>& end)
 {
   if (begin == end)
     throw Error("Empty buffer during TLV processing");
 
-  uint8_t value = *begin;
+  uint8_t firstOctet = *begin;
   ++begin;
-  if (value < 253)
+  if (firstOctet < 253)
     {
-      return value;
+      return firstOctet;
     }
-  else if (value == 253)
+  else if (firstOctet == 253)
     {
       uint8_t buffer[2];
       int count = 0;
@@ -303,7 +311,7 @@
       uint16_t value = *reinterpret_cast<const uint16_t*>(buffer);
       return be16toh(value);
     }
-  else if (value == 254)
+  else if (firstOctet == 254)
     {
       uint8_t buffer[4];
       int count = 0;
@@ -320,7 +328,7 @@
       uint32_t value = *reinterpret_cast<const uint32_t*>(buffer);
       return be32toh(value);
     }
-  else // if (value == 255)
+  else // if (firstOctet == 255)
     {
       uint8_t buffer[8];
       int count = 0;
@@ -341,15 +349,15 @@
 
 template<class InputIterator>
 inline uint32_t
-readType(InputIterator &begin, const InputIterator &end)
+readType(InputIterator& begin, const InputIterator& end)
 {
-  uint64_t type   = readVarNumber(begin, end);
+  uint64_t type = readVarNumber(begin, end);
   if (type > std::numeric_limits<uint32_t>::max())
     {
       throw Error("TLV type code exceeds allowed maximum");
     }
 
-  return static_cast<uint32_t> (type);
+  return static_cast<uint32_t>(type);
 }
 
 size_t
@@ -370,7 +378,7 @@
 }
 
 inline size_t
-writeVarNumber(std::ostream &os, uint64_t varNumber)
+writeVarNumber(std::ostream& os, uint64_t varNumber)
 {
   if (varNumber < 253) {
     os.put(static_cast<uint8_t> (varNumber));
@@ -379,26 +387,26 @@
   else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
     os.put(253);
     uint16_t value = htobe16(static_cast<uint16_t> (varNumber));
-    os.write(reinterpret_cast<const char*> (&value), 2);
+    os.write(reinterpret_cast<const char*>(&value), 2);
     return 3;
   }
   else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
     os.put(254);
     uint32_t value = htobe32(static_cast<uint32_t> (varNumber));
-    os.write(reinterpret_cast<const char*> (&value), 4);
+    os.write(reinterpret_cast<const char*>(&value), 4);
     return 5;
   }
   else {
     os.put(255);
     uint64_t value = htobe64(varNumber);
-    os.write(reinterpret_cast<const char*> (&value), 8);
+    os.write(reinterpret_cast<const char*>(&value), 8);
     return 9;
   }
 }
 
 template<class InputIterator>
 inline uint64_t
-readNonNegativeInteger(size_t size, InputIterator &begin, const InputIterator &end)
+readNonNegativeInteger(size_t size, InputIterator& begin, const InputIterator& end)
 {
   switch (size) {
   case 1:
@@ -444,13 +452,13 @@
 template<>
 inline uint64_t
 readNonNegativeInteger<std::istream_iterator<uint8_t> >(size_t size,
-                                                        std::istream_iterator<uint8_t> &begin,
-                                                        const std::istream_iterator<uint8_t> &end)
+                                                        std::istream_iterator<uint8_t>& begin,
+                                                        const std::istream_iterator<uint8_t>& end)
 {
   switch (size) {
   case 1:
     {
-      if(begin == end)
+      if (begin == end)
         throw Error("Insufficient data during TLV processing");
 
       uint8_t value = *begin;
@@ -462,7 +470,7 @@
       uint8_t buffer[2];
       int count = 0;
 
-      while(begin != end && count < 2){
+      while (begin != end && count < 2) {
         buffer[count] = *begin;
         begin++;
         count++;
@@ -479,7 +487,7 @@
       uint8_t buffer[4];
       int count = 0;
 
-      while(begin != end && count < 4){
+      while (begin != end && count < 4) {
         buffer[count] = *begin;
         begin++;
         count++;
@@ -496,7 +504,7 @@
       uint8_t buffer[8];
       int count = 0;
 
-      while(begin != end && count < 8){
+      while (begin != end && count < 8){
         buffer[count] = *begin;
         begin++;
         count++;
@@ -531,7 +539,7 @@
 
 
 inline size_t
-writeNonNegativeInteger(std::ostream &os, uint64_t varNumber)
+writeNonNegativeInteger(std::ostream& os, uint64_t varNumber)
 {
   if (varNumber < 253) {
     os.put(static_cast<uint8_t> (varNumber));
@@ -539,23 +547,24 @@
   }
   else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
     uint16_t value = htobe16(static_cast<uint16_t> (varNumber));
-    os.write(reinterpret_cast<const char*> (&value), 2);
+    os.write(reinterpret_cast<const char*>(&value), 2);
     return 2;
   }
   else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
     uint32_t value = htobe32(static_cast<uint32_t> (varNumber));
-    os.write(reinterpret_cast<const char*> (&value), 4);
+    os.write(reinterpret_cast<const char*>(&value), 4);
     return 4;
   }
   else {
     uint64_t value = htobe64(varNumber);
-    os.write(reinterpret_cast<const char*> (&value), 8);
+    os.write(reinterpret_cast<const char*>(&value), 8);
     return 8;
   }
 }
 
 
-} // namespace tlv
+} // namespace Tlv
+
 } // namespace ndn
 
 #endif // NDN_TLV_HPP
