diff --git a/examples/consumer-with-timer.cpp b/examples/consumer-with-timer.cpp
index 83bb858..0f3890c 100644
--- a/examples/consumer-with-timer.cpp
+++ b/examples/consumer-with-timer.cpp
@@ -1,76 +1,95 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (c) 2013-2014 Regents of the University of California.
  * @author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * See COPYING for copyright and distribution information.
+ * BSD License, see COPYING for copyright and distribution information.
  */
 
 // correct way to include NDN-CPP headers
 // #include <ndn-cpp-dev/face.hpp>
+// #include <ndn-cpp-dev/util/scheduler.hpp>
 #include "face.hpp"
 #include "util/scheduler.hpp"
 
+// Enclosing code in ndn simplifies coding (can also use `using namespace ndn`)
+namespace ndn {
+// Additional nested namespace could be used to prevent/limit name contentions
+namespace examples {
+
 void
-onData(ndn::Face &face,
-       const ndn::Interest& interest, ndn::Data& data)
+onData(Face& face,
+       const Interest& interest, Data& data)
 {
   std::cout << "I: " << interest.toUri() << std::endl;
   std::cout << "D: " << data.getName().toUri() << std::endl;
 }
 
 void
-onTimeout(ndn::Face &face,
-          const ndn::Interest& interest)
+onTimeout(Face& face,
+          const Interest& interest)
 {
   std::cout << "Timeout" << std::endl;
 }
 
 void
-delayedInterest(ndn::Face &face)
+delayedInterest(Face& face)
 {
   std::cout << "One more Interest, delayed by the scheduler" << std::endl;
-  
-  ndn::Interest i(ndn::Name("/localhost/testApp/randomData"));
+
+  Interest i(Name("/localhost/testApp/randomData"));
   i.setScope(1);
-  i.setInterestLifetime(ndn::time::milliseconds(1000));
+  i.setInterestLifetime(time::milliseconds(1000));
   i.setMustBeFresh(true);
 
   face.expressInterest(i,
-                       ndn::bind(&onData, boost::ref(face), _1, _2),
-                       ndn::bind(&onTimeout, boost::ref(face), _1));
+                       bind(&onData, boost::ref(face), _1, _2),
+                       bind(&onTimeout, boost::ref(face), _1));
 }
 
-int main()
+int
+main(int argc, char** argv)
 {
   try {
-    // Explicitly create io_service object, which can be shared between
-    // Face and Scheduler
-    ndn::shared_ptr<boost::asio::io_service> io =
-      ndn::make_shared<boost::asio::io_service>();
-    
-    ndn::Interest i(ndn::Name("/localhost/testApp/randomData"));
+    // Explicitly create io_service object, which can be shared between Face and Scheduler
+    shared_ptr<boost::asio::io_service> io = make_shared<boost::asio::io_service>();
+
+    Interest i(Name("/localhost/testApp/randomData"));
     i.setScope(1);
-    i.setInterestLifetime(ndn::time::seconds(1));
+    i.setInterestLifetime(time::seconds(1));
     i.setMustBeFresh(true);
 
-    ndn::Face face(io);
+    // Create face with io_service object
+    Face face(io);
     face.expressInterest(i,
-                          ndn::bind(&onData, boost::ref(face), _1, _2),
-                          ndn::bind(&onTimeout, boost::ref(face), _1));
+                         bind(&onData, boost::ref(face), _1, _2),
+                         bind(&onTimeout, boost::ref(face), _1));
 
 
-    ndn::Scheduler scheduler(*io);
-    scheduler.scheduleEvent(ndn::time::seconds(2),
-                            ndn::bind(&delayedInterest, boost::ref(face)));
-    
+    // Create scheduler object
+    Scheduler scheduler(*io);
+
+    // Schedule a new event
+    scheduler.scheduleEvent(time::seconds(2),
+                            bind(&delayedInterest, boost::ref(face)));
+
+    // io->run() will block until all events finished or io->stop() is called
     io->run();
-    
+
     // Alternatively, a helper face.processEvents() also can be called
     // processEvents will block until the requested data received or timeout occurs
     // face.processEvents();
   }
-  catch(std::exception &e) {
+  catch(std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
   }
   return 0;
 }
+
+} // namespace examples
+} // namespace ndn
+
+int
+main(int argc, char** argv)
+{
+  return ndn::examples::main(argc, argv);
+}
diff --git a/examples/consumer.cpp b/examples/consumer.cpp
index 9ef366a..bb4ab31 100644
--- a/examples/consumer.cpp
+++ b/examples/consumer.cpp
@@ -1,47 +1,63 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (c) 2013-2014 Regents of the University of California.
  * @author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * See COPYING for copyright and distribution information.
+ * BSD License, see COPYING for copyright and distribution information.
  */
 
 // correct way to include NDN-CPP headers
 // #include <ndn-cpp-dev/face.hpp>
 #include "face.hpp"
 
+// Enclosing code in ndn simplifies coding (can also use `using namespace ndn`)
+namespace ndn {
+// Additional nested namespace could be used to prevent/limit name contentions
+namespace examples {
+
 void
-onData(ndn::Face &face,
-       const ndn::Interest& interest, ndn::Data& data)
+onData(Face& face,
+       const Interest& interest, Data& data)
 {
   std::cout << "I: " << interest.toUri() << std::endl;
   std::cout << "D: " << data.getName().toUri() << std::endl;
 }
 
 void
-onTimeout(ndn::Face &face,
-          const ndn::Interest& interest)
+onTimeout(Face& face,
+          const Interest& interest)
 {
   std::cout << "Timeout" << std::endl;
 }
 
-int main()
+int
+main(int argc, char** argv)
 {
   try {
-    ndn::Interest i(ndn::Name("/localhost/testApp/randomData"));
+    Interest i(Name("/localhost/testApp/randomData"));
     i.setScope(1);
-    i.setInterestLifetime(ndn::time::milliseconds(1000));
+    i.setInterestLifetime(time::milliseconds(1000));
     i.setMustBeFresh(true);
 
-    ndn::Face face;
+    Face face;
     face.expressInterest(i,
-                          ndn::bind(onData, boost::ref(face), _1, _2),
-                          ndn::bind(onTimeout, boost::ref(face), _1));
+                         bind(onData, boost::ref(face), _1, _2),
+                         bind(onTimeout, boost::ref(face), _1));
 
     // processEvents will block until the requested data received or timeout occurs
     face.processEvents();
   }
-  catch(std::exception &e) {
+  catch(std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
+    return 1;
   }
   return 0;
 }
+
+} // namespace examples
+} // namespace ndn
+
+int
+main(int argc, char** argv)
+{
+  return ndn::examples::main(argc, argv);
+}
diff --git a/examples/producer.cpp b/examples/producer.cpp
index 1327e94..4defc29 100644
--- a/examples/producer.cpp
+++ b/examples/producer.cpp
@@ -1,8 +1,8 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (c) 2013-2014 Regents of the University of California.
  * @author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * See COPYING for copyright and distribution information.
+ * BSD License, see COPYING for copyright and distribution information.
  */
 
 // correct way to include NDN-CPP headers
@@ -12,61 +12,76 @@
 #include "face.hpp"
 #include "security/key-chain.hpp"
 
-using namespace ndn;
+// Enclosing code in ndn simplifies coding (can also use `using namespace ndn`)
+namespace ndn {
+// Additional nested namespace could be used to prevent/limit name contentions
+namespace examples {
 
 class Producer
 {
 public:
-  Producer()
-  {}
-
   void
   onInterest(const Name& name, const Interest& interest)
   {
     std::cout << "<< I: " << interest << std::endl;
 
-    ndn::Data data(ndn::Name(interest.getName()).append("testApp").appendVersion());
-    data.setFreshnessPeriod(ndn::time::seconds(10));
+    // Create new name, based on Interest's name
+    Name dataName(interest.getName());
+    dataName
+      .append("testApp") // add "testApp" component to Interest name
+      .appendVersion();  // add "version" component (current UNIX timestamp in milliseconds)
 
-    data.setContent((const uint8_t*)"HELLO KITTY", sizeof("HELLO KITTY"));
+    static const std::string content = "HELLO KITTY";
 
-    keyChain_.sign(data);
+    // Create Data packet
+    Data data;
+    data.setName(dataName);
+    data.setFreshnessPeriod(time::seconds(10));
+    data.setContent(Block(content.c_str(), content.size()));
 
+    // Sign Data packet with default identity
+    m_keyChain.sign(data);
+    // m_keyChain.sign(data, <identityName>);
+    // m_keyChain.sign(data, <certificate>);
+
+    // Return Data packet to the requester
     std::cout << ">> D: " << data << std::endl;
-    face_.put(data);
+    m_face.put(data);
   }
 
 
   void
-  onRegisterFailed (const ndn::Name& prefix, const std::string& reason)
+  onRegisterFailed(const Name& prefix, const std::string& reason)
   {
     std::cerr << "ERROR: Failed to register prefix in local hub's daemon (" << reason << ")" << std::endl;
-    face_.shutdown ();
+    m_face.shutdown();
   }
 
   void
-  listen()
+  run()
   {
-    face_.setInterestFilter("/localhost/testApp",
-                            func_lib::bind(&Producer::onInterest, this, _1, _2),
-                            func_lib::bind(&Producer::onRegisterFailed, this, _1, _2));
-    face_.processEvents();
+    m_face.setInterestFilter("/localhost/testApp",
+                             bind(&Producer::onInterest, this, _1, _2),
+                             bind(&Producer::onRegisterFailed, this, _1, _2));
+    m_face.processEvents();
   }
 
 private:
-  ndn::Face face_;
-  KeyChain keyChain_;
-
-  Buffer ndndId_;
+  Face m_face;
+  KeyChain m_keyChain;
 };
 
-int main()
+} // namespace examples
+} // namespace ndn
+
+int
+main(int argc, char** argv)
 {
   try {
-    Producer producer;
-    producer.listen();
+    ndn::examples::Producer producer;
+    producer.run();
   }
-  catch(std::exception &e) {
+  catch (std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
   }
   return 0;
