diff --git a/disabled/cert.cc b/disabled/cert.cc
deleted file mode 100644
index b8a170e..0000000
--- a/disabled/cert.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-#include "cert.h"
-
-#include <tinyxml.h>
-#include <boost/lexical_cast.hpp>
-
-#include "logging.h"
-
-INIT_LOGGER ("ndn.Cert");
-
-using namespace std;
-
-namespace ndn {
-
-Cert::Cert()
-    : m_pkey(0)
-    , m_meta("", "",  0, 0)
-{
-}
-
-Cert::Cert(const PcoPtr &keyObject, const PcoPtr &metaObject = PcoPtr())
-    : m_pkey(0)
-    , m_meta("", "", 0, 0)
-{
-  m_name = keyObject->name();
-  m_rawKeyBytes = keyObject->content();
-  m_keyHash = *(Hash::FromBytes(m_rawKeyBytes));
-  m_pkey = ccn_d2i_pubkey(head(m_rawKeyBytes), m_rawKeyBytes.size());
-  updateMeta(metaObject);
-}
-
-Cert::~Cert()
-{
-  if (m_pkey != 0)
-  {
-    ccn_pubkey_free(m_pkey);
-    m_pkey = 0;
-  }
-}
-
-void
-Cert::updateMeta(const PcoPtr &metaObject)
-{
-  if (metaObject)
-  {
-    Bytes xml = metaObject->content();
-    // just make sure it's null terminated as it's required by TiXmlDocument::parse
-    xml.push_back('\0');
-    TiXmlDocument doc;
-    doc.Parse((const char *)(head(xml)));
-    if (!doc.Error())
-    {
-      TiXmlElement *root = doc.RootElement();
-      for (TiXmlElement *child = root->FirstChildElement(); child; child = child->NextSiblingElement())
-      {
-        string elemName = child->Value();
-        string text = child->GetText();
-        if (elemName == "Name")
-        {
-          m_meta.realworldID = text;
-          _LOG_TRACE("Name = " << text);
-        }
-        else if (elemName == "Affiliation")
-        {
-          m_meta.affiliation = text;
-          _LOG_TRACE("Affiliation = " << text);
-        }
-        else if (elemName == "Valid_to")
-        {
-          m_meta.validTo = boost::lexical_cast<time_t>(text);
-          _LOG_TRACE("Valid_to = " << text);
-        }
-        else if (elemName == "Valid_from")
-        {
-          // this is not included in the key meta yet
-          // but it should eventually be there
-        }
-        else
-        {
-          // ignore known stuff
-        }
-      }
-    }
-    else
-    {
-      _LOG_ERROR("Cannot parse meta info:" << std::string((const char *)head(xml), xml.size()));
-    }
-  }
-}
-
-Cert::VALIDITY
-Cert::validity()
-{
-  if (m_meta.validFrom == 0 && m_meta.validTo == 0)
-  {
-    return OTHER;
-  }
-
-  time_t now = time(NULL);
-  if (now < m_meta.validFrom)
-  {
-    return NOT_YET_VALID;
-  }
-
-  if (now >= m_meta.validTo)
-  {
-    return EXPIRED;
-  }
-
-  return WITHIN_VALID_TIME_SPAN;
-}
-
-} // ndn
diff --git a/disabled/cert.h b/disabled/cert.h
deleted file mode 100644
index 00f432d..0000000
--- a/disabled/cert.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_CERT_H
-#define NDN_CERT_H
-
-#include "ndn.cxx/common.h"
-#include "ndn.cxx/name.h"
-#include "ndn.cxx/pco.h"
-#include "ndn.cxx/hash.h"
-#include <boost/shared_ptr.hpp>
-
-namespace ndn {
-
-class Cert
-{
-public:
-  enum VALIDITY
-  {
-    NOT_YET_VALID,
-    WITHIN_VALID_TIME_SPAN,
-    EXPIRED,
-    OTHER
-  };
-
-  Cert();
-  Cert(const PcoPtr &keyObject, const PcoPtr &metaObject);
-  ~Cert();
-
-  void
-  updateMeta(const PcoPtr &metaObject);
-
-  Name
-  name() { return m_name; }
-
-  Bytes
-  rawKeyBytes() { return m_rawKeyBytes; }
-
-  Hash
-  keyDigest() { return m_keyHash; }
-
-  std::string
-  realworldID() { return m_meta.realworldID; }
-
-  std::string
-  affilication() { return m_meta.affiliation; }
-
-  ccn_pkey *
-  pkey() { return m_pkey; }
-
-  VALIDITY
-  validity();
-
-private:
-  struct Meta
-  {
-    Meta(std::string id, std::string affi, time_t from, time_t to)
-      : realworldID(id)
-      , affiliation(affi)
-      , validFrom(from)
-      , validTo(to)
-    {
-    }
-    std::string realworldID;
-    std::string affiliation;
-    time_t validFrom;
-    time_t validTo;
-  };
-
-  Name m_name;
-  Hash m_keyHash; // publisherPublicKeyHash
-  Bytes m_rawKeyBytes;
-  ccn_pkey *m_pkey;
-  Meta m_meta;
-};
-
-typedef boost::shared_ptr<Cert> CertPtr;
-
-}
-
-#endif // NDN_CERT_H
diff --git a/disabled/charbuf.cc b/disabled/charbuf.cc
deleted file mode 100644
index 12425f6..0000000
--- a/disabled/charbuf.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "charbuf.h"
-
-using namespace std;
-
-namespace ndn {
-
-void
-Charbuf::init(ccn_charbuf *buf)
-{
-  if (buf != NULL)
-  {
-    m_buf = ccn_charbuf_create();
-    ccn_charbuf_reserve(m_buf, buf->length);
-    memcpy(m_buf->buf, buf->buf, buf->length);
-    m_buf->length = buf->length;
-  }
-}
-
-Charbuf::Charbuf()
-            : m_buf(NULL)
-{
-  m_buf = ccn_charbuf_create();
-}
-
-Charbuf::Charbuf(ccn_charbuf *buf)
-            : m_buf(NULL)
-{
-  init(buf);
-}
-
-Charbuf::Charbuf(const Charbuf &other)
-            : m_buf (NULL)
-{
-  init(other.m_buf);
-}
-
-Charbuf::Charbuf(const void *buf, size_t length)
-{
-  m_buf = ccn_charbuf_create ();
-  ccn_charbuf_reserve (m_buf, length);
-  memcpy (m_buf->buf, buf, length);
-  m_buf->length = length;
-}
-
-Charbuf::~Charbuf()
-{
-  ccn_charbuf_destroy (&m_buf);
-}
-
-namespace iostreams
-{
-
-charbuf_append_device::charbuf_append_device (Charbuf& cnt)
-  : container (cnt)
-{
-}
-
-std::streamsize
-charbuf_append_device::write (const char_type* s, std::streamsize n)
-{
-  ccn_charbuf_append (container.getBuf (), s, n);
-  return n;
-}
-
-} // iostreams
-
-} // ndn
diff --git a/disabled/charbuf.h b/disabled/charbuf.h
deleted file mode 100644
index ce3ddef..0000000
--- a/disabled/charbuf.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_NDN_CHARBUF_H
-#define NDN_NDN_CHARBUF_H
-
-#include "ndn.cxx/common.h"
-#include <boost/shared_ptr.hpp>
-#include <boost/iostreams/detail/ios.hpp>
-#include <boost/iostreams/categories.hpp>
-#include <boost/iostreams/stream.hpp>
-
-namespace ndn {
-
-class Charbuf;
-typedef boost::shared_ptr<Charbuf> CharbufPtr;
-
-//  This class is mostly used in Wrapper; users should not be directly using this class
-// The main purpose of this class to is avoid manually create and destroy charbuf everytime
-class Charbuf
-{
-public:
-  Charbuf();
-  Charbuf(ccn_charbuf *buf);
-  Charbuf(const Charbuf &other);
-  Charbuf(const void *buf, size_t length);
-  ~Charbuf();
-
-  // expose internal data structure, use with caution!!
-  ccn_charbuf *
-  getBuf() { return m_buf; }
-
-  const ccn_charbuf *
-  getBuf() const { return m_buf; }
-
-  const unsigned char *
-  buf () const
-  { return m_buf->buf; }
-
-  size_t
-  length () const
-  { return m_buf->length; }
-
-private:
-  void init(ccn_charbuf *buf);
-
-protected:
-  ccn_charbuf *m_buf;
-};
-
-namespace iostreams
-{
-
-class charbuf_append_device {
-public:
-  typedef char  char_type;
-  typedef boost::iostreams::sink_tag       category;
-  
-  charbuf_append_device (Charbuf& cnt);
-  
-  std::streamsize
-  write(const char_type* s, std::streamsize n);
-protected:
-  Charbuf& container;
-};
-
-} // iostreams
-
-struct charbuf_stream : public boost::iostreams::stream<iostreams::charbuf_append_device>
-{
-  charbuf_stream ()
-    : m_device (m_buf)
-  {
-    open (m_device);
-  }
-
-  Charbuf &
-  buf ()
-  {
-    flush ();
-    return m_buf;
-  }
-
-private:
-  Charbuf m_buf;
-  iostreams::charbuf_append_device m_device;
-};
-
-} // ndn
-
-#endif // NDN_NDN_CHARBUF_H
diff --git a/disabled/closure.cc b/disabled/closure.cc
deleted file mode 100644
index a45ef2a..0000000
--- a/disabled/closure.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "closure.h"
-
-namespace ndn {
-
-Closure::Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback)
-  : m_timeoutCallback (timeoutCallback)
-  , m_dataCallback (dataCallback)
-{
-}
-
-Closure::~Closure ()
-{
-}
-
-void
-Closure::runTimeoutCallback(Name interest, const Closure &closure, InterestPtr origInterest)
-{
-  if (!m_timeoutCallback.empty ())
-    {
-      m_timeoutCallback (interest, closure, origInterest);
-    }
-}
-
-
-void
-Closure::runDataCallback(Name name, PcoPtr content)
-{
-  if (!m_dataCallback.empty ())
-    {
-      m_dataCallback (name, content);
-    }
-}
-
-} // ndn
diff --git a/disabled/closure.h b/disabled/closure.h
deleted file mode 100644
index dbcba79..0000000
--- a/disabled/closure.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_CLOSURE_H
-#define NDN_CLOSURE_H
-
-#include "ndn.cxx/common.h"
-#include "ndn.cxx/fields/name.h"
-#include "ndn.cxx/interest.h"
-
-namespace ndn {
-
-class ParsedContentObject;
-typedef boost::shared_ptr<ParsedContentObject> PcoPtr;
-
-class Closure
-{
-public:
-  typedef boost::function<void (Name, PcoPtr pco)> DataCallback;
-
-  typedef boost::function<void (Name, const Closure &, InterestPtr)> TimeoutCallback;
-
-  Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback = TimeoutCallback());
-  virtual ~Closure();
-
-  virtual void
-  runDataCallback(Name name, ndn::PcoPtr pco);
-
-  virtual void
-  runTimeoutCallback(Name interest, const Closure &closure, InterestPtr originalInterest);
-
-  virtual Closure *
-  dup () const { return new Closure (*this); }
-
-public:
-  TimeoutCallback m_timeoutCallback;
-  DataCallback m_dataCallback;
-};
-
-} // ndn
-
-#endif
diff --git a/disabled/discovery.cc b/disabled/discovery.cc
deleted file mode 100644
index 273402a..0000000
--- a/disabled/discovery.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "discovery.h"
-
-#include "scheduler/scheduler.h"
-#include "scheduler/simple-interval-generator.h"
-#include "scheduler/task.h"
-#include "scheduler/periodic-task.h"
-
-#include <sstream>
-#include <boost/make_shared.hpp>
-#include <boost/bind.hpp>
-
-using namespace std;
-
-namespace ndn
-{
-
-namespace discovery
-{
-
-const string
-TaggedFunction::CHAR_SET = string("abcdefghijklmnopqtrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
-
-TaggedFunction::TaggedFunction(const Callback &callback, const string &tag)
-                   : m_callback(callback)
-                   , m_tag(tag)
-{
-}
-
-string
-TaggedFunction::GetRandomTag()
-{
-  //boost::random::random_device rng;
-  boost::random::uniform_int_distribution<> dist(0, CHAR_SET.size() - 1);
-  ostringstream oss;
-  for (int i = 0; i < DEFAULT_TAG_SIZE; i++)
-  {
-    //oss << CHAR_SET[dist(rng)];
-  }
-  return oss.str();
-}
-
-void
-TaggedFunction::operator()(const Name &name)
-{
-  if (!m_callback.empty())
-  {
-    m_callback(name);
-  }
-}
-
-} // namespace discovery
-
-const double
-Discovery::INTERVAL = 15.0;
-
-Discovery *
-Discovery::instance = NULL;
-
-boost::mutex
-Discovery::mutex;
-
-Discovery::Discovery()
-              : m_scheduler(new Scheduler())
-              , m_localPrefix("/")
-{
-  m_scheduler->start();
-
-  Scheduler::scheduleOneTimeTask (m_scheduler, 0,
-                                  boost::bind(&Discovery::poll, this), "Initial-Local-Prefix-Check");
-  Scheduler::schedulePeriodicTask (m_scheduler,
-                                   boost::make_shared<SimpleIntervalGenerator>(INTERVAL),
-                                   boost::bind(&Discovery::poll, this), "Local-Prefix-Check");
-}
-
-Discovery::~Discovery()
-{
-  m_scheduler->shutdown();
-}
-
-void
-Discovery::addCallback(const discovery::TaggedFunction &callback)
-{
-  m_callbacks.push_back(callback);
-}
-
-int
-Discovery::deleteCallback(const discovery::TaggedFunction &callback)
-{
-  List::iterator it = m_callbacks.begin();
-  while (it != m_callbacks.end())
-  {
-    if ((*it) == callback)
-    {
-      it = m_callbacks.erase(it);
-    }
-    else
-    {
-      ++it;
-    }
-  }
-  return m_callbacks.size();
-}
-
-void
-Discovery::poll()
-{
-  Name localPrefix = Wrapper::getLocalPrefix();
-  if (localPrefix != m_localPrefix)
-  {
-    Lock lock(mutex);
-    for (List::iterator it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
-    {
-      (*it)(localPrefix);
-    }
-    m_localPrefix = localPrefix;
-  }
-}
-
-void
-Discovery::registerCallback(const discovery::TaggedFunction &callback)
-{
-  Lock lock(mutex);
-  if (instance == NULL)
-  {
-    instance = new Discovery();
-  }
-
-  instance->addCallback(callback);
-}
-
-void
-Discovery::deregisterCallback(const discovery::TaggedFunction &callback)
-{
-  Lock lock(mutex);
-  if (instance == NULL)
-  {
-    cerr << "Discovery::deregisterCallback called without instance" << endl;
-  }
-  else
-  {
-    int size = instance->deleteCallback(callback);
-    if (size == 0)
-    {
-      delete instance;
-      instance = NULL;
-    }
-  }
-}
-
-}
-
diff --git a/disabled/discovery.h b/disabled/discovery.h
deleted file mode 100644
index 1dc684d..0000000
--- a/disabled/discovery.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_DISCOVERY_H
-#define NDN_DISCOVERY_H
-
-#include "ndn.cxx/wrapper.h"
-#include "ndn.cxx/common.h"
-#include "ndn.cxx/name.h"
-
-#include <boost/shared_ptr.hpp>
-#include <boost/function.hpp>
-#include <boost/random/random_device.hpp>
-#include <boost/random/uniform_int_distribution.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/locks.hpp>
-#include <list>
-
-class Scheduler;
-typedef boost::shared_ptr<Scheduler> SchedulerPtr;
-
-namespace ndn
-{
-
-class Discovery;
-typedef boost::shared_ptr<Discovery> DiscoveryPtr;
-
-namespace discovery
-{
-
-class TaggedFunction
-{
-public:
-  typedef boost::function<void (const Name &)> Callback;
-  TaggedFunction(const Callback &callback, const std::string &tag = GetRandomTag());
-  ~TaggedFunction(){};
-
-  bool
-  operator==(const TaggedFunction &other) { return m_tag == other.m_tag; }
-
-  void
-  operator()(const Name &name);
-
-private:
-  static const std::string CHAR_SET;
-  static const int DEFAULT_TAG_SIZE = 32;
-
-  static std::string
-  GetRandomTag();
-
-private:
-  Callback m_callback;
-  std::string m_tag;
-};
-
-}
-
-class Discovery
-{
-public:
-  const static double INTERVAL;
-  // Add a callback to be invoked when local prefix changes
-  // you must remember to deregister the callback
-  // otherwise you may have undefined behavior if the callback is
-  // bind to a member function of an object and the object is deleted
-  static void
-  registerCallback(const discovery::TaggedFunction &callback);
-
-  // remember to call this before you quit
-  static void
-  deregisterCallback(const discovery::TaggedFunction &callback);
-
-private:
-  Discovery();
-  ~Discovery();
-
-  void
-  poll();
-
-  void
-  addCallback(const discovery::TaggedFunction &callback);
-
-  int
-  deleteCallback(const discovery::TaggedFunction &callback);
-
-private:
-  typedef boost::mutex Mutex;
-  typedef boost::unique_lock<Mutex> Lock;
-  typedef std::list<discovery::TaggedFunction> List;
-
-  static Discovery *instance;
-  static Mutex mutex;
-  List m_callbacks;
-  SchedulerPtr m_scheduler;
-  Name m_localPrefix;
-};
-
-} // ndn
-
-#endif // NDN_DISCOVERY_H
diff --git a/disabled/pco.cc b/disabled/pco.cc
deleted file mode 100644
index f039b54..0000000
--- a/disabled/pco.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "pco.h"
-
-namespace ndn {
-
-void
-ParsedContentObject::init(const unsigned char *data, size_t len)
-{
-  readRaw(m_bytes, data, len);
-
-  m_comps = ccn_indexbuf_create();
-  int res = ccn_parse_ContentObject(head (m_bytes), len, &m_pco, m_comps);
-  if (res < 0)
-  {
-    boost::throw_exception(Error::MisformedContentObject());
-  }
-
-}
-
-ParsedContentObject::ParsedContentObject(const unsigned char *data, size_t len, bool verified)
-            : m_comps(NULL)
-            , m_verified(verified)
-{
-  init(data, len);
-}
-
-ParsedContentObject::ParsedContentObject(const Bytes &bytes, bool verified)
-            : m_comps(NULL)
-            , m_verified(verified)
-{
-  init(head(bytes), bytes.size());
-}
-
-ParsedContentObject::ParsedContentObject(const ParsedContentObject &other, bool verified)
-            : m_comps(NULL)
-            , m_verified(verified)
-{
-  init(head(other.m_bytes), other.m_bytes.size());
-}
-
-ParsedContentObject::~ParsedContentObject()
-{
-  ccn_indexbuf_destroy(&m_comps);
-  m_comps = NULL;
-}
-
-Bytes
-ParsedContentObject::content() const
-{
-  const unsigned char *content;
-  size_t len;
-  int res = ccn_content_get_value(head(m_bytes), m_pco.offset[CCN_PCO_E], &m_pco, &content, &len);
-  if (res < 0)
-  {
-    boost::throw_exception(Error::MisformedContentObject());
-  }
-
-  Bytes bytes;
-  readRaw(bytes, content, len);
-  return bytes;
-}
-
-BytesPtr
-ParsedContentObject::contentPtr() const
-{
-  const unsigned char *content;
-  size_t len;
-  int res = ccn_content_get_value(head(m_bytes), m_pco.offset[CCN_PCO_E], &m_pco, &content, &len);
-  if (res < 0)
-  {
-    boost::throw_exception(Error::MisformedContentObject());
-  }
-
-  return readRawPtr (content, len);
-}
-
-Name
-ParsedContentObject::name() const
-{
-  return Name(head(m_bytes), m_comps);
-}
-
-Name
-ParsedContentObject::keyName() const
-{
-  if (m_pco.offset[CCN_PCO_E_KeyName_Name] > m_pco.offset[CCN_PCO_B_KeyName_Name])
-  {
-    CharbufPtr ptr = boost::make_shared<Charbuf>();
-    ccn_charbuf_append(ptr->getBuf(), head(m_bytes) + m_pco.offset[CCN_PCO_B_KeyName_Name], m_pco.offset[CCN_PCO_E_KeyName_Name] - m_pco.offset[CCN_PCO_B_KeyName_Name]);
-
-    return Name(*ptr);
-  }
-  else
-  {
-    return Name();
-  }
-}
-
-HashPtr
-ParsedContentObject::publisherPublicKeyDigest() const
-{
-  const unsigned char *buf = NULL;
-  size_t size = 0;
-  ccn_ref_tagged_BLOB(CCN_DTAG_PublisherPublicKeyDigest, head(m_bytes), m_pco.offset[CCN_PCO_B_PublisherPublicKeyDigest], m_pco.offset[CCN_PCO_E_PublisherPublicKeyDigest], &buf, &size);
-
-  return boost::make_shared<Hash>(buf, size);
-}
-
-ParsedContentObject::Type
-ParsedContentObject::type() const
-{
-  switch (m_pco.type)
-  {
-  case CCN_CONTENT_DATA: return DATA;
-  case CCN_CONTENT_KEY: return KEY;
-  default: break;
-  }
-  return OTHER;
-}
-
-// void
-// ParsedContentObject::verifySignature(const CertPtr &cert)
-// {
-//   m_verified = (ccn_verify_signature(head(m_bytes), m_pco.offset[CCN_PCO_E], &m_pco, cert->pkey()) == 1);
-// }
-
-}
diff --git a/disabled/pco.h b/disabled/pco.h
deleted file mode 100644
index 6931022..0000000
--- a/disabled/pco.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_CONTENT_OBJECT_H
-#define NDN_CONTENT_OBJECT_H
-
-#include "ndn.cxx/wrapper.h"
-#include "ndn.cxx/common.h"
-#include "ndn.cxx/fields/name.h"
-#include "ndn.cxx/helpers/hash.h"
-
-namespace ndn {
-
-// class Cert;
-// typedef boost::shared_ptr<Cert> CertPtr;
-
-class ParsedContentObject
-{
-public:
-  enum Type
-  {
-    DATA,
-    KEY,
-    OTHER
-  };
-  ParsedContentObject(const unsigned char *data, size_t len, bool verified = false);
-  ParsedContentObject(const unsigned char *data, const ccn_parsed_ContentObject &pco, bool verified = false);
-  ParsedContentObject(const Bytes &bytes, bool verified = false);
-  ParsedContentObject(const ParsedContentObject &other, bool verified = false);
-  virtual ~ParsedContentObject();
-
-  Bytes
-  content() const;
-
-  BytesPtr
-  contentPtr() const;
-
-  Name
-  name() const;
-
-  Name
-  keyName() const;
-
-  HashPtr
-  publisherPublicKeyDigest() const;
-
-  Type
-  type() const;
-
-  inline const Bytes &
-  buf () const;
-
-  bool
-  verified() const { return m_verified; }
-
-  // void
-  // verifySignature(const CertPtr &cert);
-
-  const unsigned char *
-  msg() const { return head(m_bytes); }
-
-  const ccn_parsed_ContentObject *
-  pco() const { return &m_pco; }
-
-private:
-  void
-  init(const unsigned char *data, size_t len);
-
-protected:
-  ccn_parsed_ContentObject m_pco;
-  ccn_indexbuf *m_comps;
-  Bytes m_bytes;
-  bool m_verified;
-  bool m_integrityChecked;
-};
-
-typedef boost::shared_ptr<ParsedContentObject> PcoPtr;
-
-namespace Error {
-struct MisformedContentObject : virtual boost::exception, virtual std::exception { };
-}
-
-const Bytes &
-ParsedContentObject::buf () const
-{
-  return m_bytes;
-}
-
-
-}
-
-#endif // NDN_CONTENT_OBJECT_H
diff --git a/disabled/verifier.cc b/disabled/verifier.cc
deleted file mode 100644
index 99599bd..0000000
--- a/disabled/verifier.cc
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "verifier.h"
-#include "ndn.cxx/wrapper.h"
-#include "logging.h"
-
-INIT_LOGGER ("ndn.Verifier");
-namespace ndn {
-
-static const size_t ROOT_KEY_DIGEST_LEN = 32;  // SHA-256
-static const unsigned char ROOT_KEY_DIGEST[ROOT_KEY_DIGEST_LEN] = {0xa7, 0xd9, 0x8b, 0x81, 0xde, 0x13, 0xfc,
-0x56, 0xc5, 0xa6, 0x92, 0xb4, 0x44, 0x93, 0x6e, 0x56, 0x70, 0x9d, 0x52, 0x6f, 0x70,
-0xed, 0x39, 0xef, 0xb5, 0xe2, 0x3, 0x29, 0xa5, 0x53, 0x3e, 0x68};
-
-Verifier::Verifier(Wrapper *ccnx)
-         : m_ccnx(ccnx)
-         , m_rootKeyDigest(ROOT_KEY_DIGEST, ROOT_KEY_DIGEST_LEN)
-{
-}
-
-Verifier::~Verifier()
-{
-}
-
-bool
-Verifier::verify(PcoPtr pco, double maxWait)
-{
-  _LOG_TRACE("Verifying content [" << pco->name() << "]");
-  HashPtr publisherPublicKeyDigest = pco->publisherPublicKeyDigest();
-
-  {
-    UniqueRecLock lock(m_cacheLock);
-    CertCache::iterator it = m_certCache.find(*publisherPublicKeyDigest);
-    if (it != m_certCache.end())
-    {
-      CertPtr cert = it->second;
-      if (cert->validity() == Cert::WITHIN_VALID_TIME_SPAN)
-      {
-        pco->verifySignature(cert);
-        return pco->verified();
-      }
-      else
-      {
-        // delete the invalid cert cache
-        m_certCache.erase(it);
-      }
-    }
-  }
-
-  // keyName is the name specified in key locator, i.e. without version and segment
-  Name keyName = pco->keyName();
-  int keyNameSize = keyName.size();
-
-  if (keyNameSize < 2)
-  {
-    _LOG_ERROR("Key name is empty or has too few components.");
-    return false;
-  }
-
-  // for keys, we have to make sure key name is strictly prefix of the content name
-  if (pco->type() == ParsedContentObject::KEY)
-  {
-    Name contentName = pco->name();
-    // when checking for prefix, do not include the hash in the key name (which is the last component)
-    Name keyNamePrefix = keyName.getPrefix (keyNameSize - 1);
-    if (keyNamePrefix.size() >= contentName.size() || contentName.getPrefix (keyNamePrefix.size()) != keyNamePrefix)
-    {
-      _LOG_ERROR("Key name prefix [" << keyNamePrefix << "] is not the prefix of content name [" << contentName << "]");
-      return false;
-    }
-  }
-  else
-  {
-    // for now, user can assign any data using his key
-  }
-
-  Name metaName;
-  metaName
-    .append (keyName.getPrefix (keyNameSize - 1))
-    .append ("info")
-    .append (keyName.getSubName (keyNameSize - 1));
-
-  Interest interest;
-  interest.setChildSelector (Interest::CHILD_RIGHT)
-    .setInterestLifetime(maxWait);
-
-  PcoPtr keyObject = m_ccnx->get(Interest (interest).setName (keyName), maxWait);
-  PcoPtr metaObject = m_ccnx->get(Interest (interest).setName (metaName), maxWait);
-  if (!keyObject || !metaObject )
-  {
-    _LOG_ERROR("can not fetch key or meta");
-    return false;
-  }
-
-  HashPtr publisherKeyHashInKeyObject = keyObject->publisherPublicKeyDigest();
-  HashPtr publisherKeyHashInMetaObject = metaObject->publisherPublicKeyDigest();
-
-  // make sure key and meta are signed using the same key
-  if (publisherKeyHashInKeyObject->IsZero() || ! (*publisherKeyHashInKeyObject == *publisherKeyHashInMetaObject))
-  {
-    _LOG_ERROR("Key and Meta not signed by the same publisher");
-    return false;
-  }
-
-  CertPtr cert = boost::make_shared<Cert>(keyObject, metaObject);
-  if (cert->validity() != Cert::WITHIN_VALID_TIME_SPAN)
-  {
-    _LOG_ERROR("Certificate is not valid, validity status is : " << cert->validity());
-    return false;
-  }
-
-  // check pco is actually signed by this key (i.e. we don't trust the publisherPublicKeyDigest given by ccnx c lib)
-  if (! (*pco->publisherPublicKeyDigest() == cert->keyDigest()))
-  {
-    _LOG_ERROR("key digest does not match the publisher public key digest of the content object");
-    return false;
-  }
-
-  // now we only need to make sure the key is trustworthy
-  if (cert->keyDigest() == m_rootKeyDigest)
-  {
-    // the key is the root key
-    // do nothing now
-  }
-  else
-  {
-    // can not verify key or can not verify meta
-    if (!verify(keyObject, maxWait) || !verify(metaObject, maxWait))
-    {
-      _LOG_ERROR("Can not verify key or meta");
-      return false;
-    }
-  }
-
-  // ok, keyObject verified, because metaObject is signed by the same parent key and integrity checked
-  // so metaObject is also verified
-  {
-    UniqueRecLock lock(m_cacheLock);
-    m_certCache.insert(std::make_pair(cert->keyDigest(), cert));
-  }
-
-  pco->verifySignature(cert);
-  if (pco->verified())
-  {
-    _LOG_TRACE("[" << pco->name() << "] VERIFIED.");
-  }
-  else
-  {
-    _LOG_ERROR("[" << pco->name() << "] CANNOT BE VERIFIED.");
-  }
-  return pco->verified();
-}
-
-} // ndn
diff --git a/disabled/verifier.h b/disabled/verifier.h
deleted file mode 100644
index 0065d87..0000000
--- a/disabled/verifier.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_VERIFIER_H
-#define NDN_VERIFIER_H
-
-#include "ndn.cxx/common.h"
-#include "ndn.cxx/name.h"
-#include "ndn.cxx/cert.h"
-#include "ndn.cxx/pco.h"
-#include <map>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/recursive_mutex.hpp>
-#include <boost/thread/thread.hpp>
-
-namespace ndn {
-
-class Wrapper;
-
-class Verifier
-{
-public:
-  Verifier(Wrapper *ccnx);
-  ~Verifier();
-
-  bool verify(PcoPtr pco, double maxWait);
-
-private:
-
-private:
-  Wrapper *m_ccnx;
-  Hash m_rootKeyDigest;
-  typedef std::map<Hash, CertPtr> CertCache;
-  CertCache m_certCache;
-  typedef boost::recursive_mutex RecLock;
-  typedef boost::unique_lock<RecLock> UniqueRecLock;
-  RecLock m_cacheLock;
-};
-
-} // ndn
-
-#endif // NDN_VERIFIER_H
diff --git a/disabled/wrapper-tests.cc b/disabled/wrapper-tests.cc
deleted file mode 100644
index c69ca54..0000000
--- a/disabled/wrapper-tests.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-
-#include "ndn.cxx.h"
-#include <unistd.h>
-#include <fstream>
-
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/make_shared.hpp>
-
-#include "logging.h"
-
-using namespace ndn;
-using namespace std;
-using namespace boost;
-
-BOOST_AUTO_TEST_SUITE(WrapperTests)
-
-WrapperPtr c1;
-WrapperPtr c2;
-int g_timeout_counter = 0;
-int g_dataCallback_counter = 0;
-
-void publish1(InterestPtr interest)
-{
-  string content = interest->getName ().toUri();
-  c1->publishData(interest->getName (), (const unsigned char*)content.c_str(), content.size(), 5);
-}
-
-void publish2(InterestPtr interest)
-{
-  string content = interest->getName ().toUri();
-  c2->publishData(interest->getName (), (const unsigned char*)content.c_str(), content.size(), 5);
-}
-
-void dataCallback(const Name &name, ndn::PcoPtr pco)
-{
-  cout << " in data callback" << endl;
-  BytesPtr content = pco->contentPtr ();
-  string msg(reinterpret_cast<const char *> (head (*content)), content->size());
-  g_dataCallback_counter ++;
-  BOOST_CHECK_EQUAL(name, msg);
-}
-
-void encapCallback(const Name &name, ndn::PcoPtr pco)
-{
-  cout << " in encap data callback" << endl;
-  BOOST_CHECK(!c1->verify(pco));
-  cout << "++++++++++++++++++ Outer content couldn't be verified, which is expected." << endl;
-  PcoPtr npco = make_shared<ParsedContentObject> (*(pco->contentPtr()));
-  g_dataCallback_counter ++;
-  BOOST_CHECK(npco);
-  BOOST_CHECK(c1->verify(npco));
-}
-
-void
-timeout(const Name &name, const Closure &closure, InterestPtr origInterest)
-{
-  g_timeout_counter ++;
-}
-
-void
-setup()
-{
-  if (!c1)
-  {
-    c1 = make_shared<Wrapper> ();
-  }
-  if (!c2)
-  {
-    c2 = make_shared<Wrapper> ();
-  }
-}
-
-void
-teardown()
-{
-  if (c1)
-  {
-    c1.reset();
-  }
-  if (c2)
-  {
-    c2.reset();
-  }
-}
-
-
-BOOST_AUTO_TEST_CASE (Basic)
-{
-  INIT_LOGGERS ();
-  
-  setup();
-  Name prefix1("/c1");
-  Name prefix2("/c2");
-
-  c1->setInterestFilter(prefix1, bind(publish1, _1));
-  usleep(100000);
-  c2->setInterestFilter(prefix2, bind(publish2, _1));
-
-  Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1, _2, _3));
-
-  c1->sendInterest(Name("/c2/hi"), closure);
-  usleep(100000);
-  c2->sendInterest(Name("/c1/hi"), closure);
-  sleep(1);
-  BOOST_CHECK_EQUAL(g_dataCallback_counter, 2);
-  
-  // reset
-  g_dataCallback_counter = 0;
-  g_timeout_counter = 0;
-
-  teardown();
-}
-
-BOOST_AUTO_TEST_CASE (Selector)
-{
-  setup();
-  Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1, _2, _3));
-
-  Interest interest;
-  interest
-    .setInterestLifetime(1)
-    .setChildSelector (Interest::CHILD_RIGHT);
-
-  string n1 = "/random/01";
-  c1->sendInterest (Interest (interest).setName (Name(n1)), closure);
-  sleep(2);
-  c2->publishData(Name(n1), (const unsigned char *)n1.c_str(), n1.size(), 1);
-  usleep(100000);
-  BOOST_CHECK_EQUAL(g_timeout_counter, 1);
-  BOOST_CHECK_EQUAL(g_dataCallback_counter, 0);
-
-  string n2 = "/random/02";
-  interest.setInterestLifetime(2);
-  c1->sendInterest(Interest (interest).setName (Name(n2)), closure);
-  sleep(1);
-  c2->publishData(Name(n2), (const unsigned char *)n2.c_str(), n2.size(), 1);
-  usleep(100000);
-  BOOST_CHECK_EQUAL(g_timeout_counter, 1);
-  BOOST_CHECK_EQUAL(g_dataCallback_counter, 1);
-
-  // reset
-  g_dataCallback_counter = 0;
-  g_timeout_counter = 0;
-
-  teardown();
-
-}
-
-void
-reexpress(const Name &name, const Closure &closure, InterestPtr origInterest)
-{
-  g_timeout_counter ++;
-  c1->sendInterest (*origInterest, closure);
-}
-
-BOOST_AUTO_TEST_CASE (Timeout)
-{
-  setup();
-  g_dataCallback_counter = 0;
-  g_timeout_counter = 0;
-  Closure closure (bind(dataCallback, _1, _2), bind(reexpress, _1, _2, _3));
-
-  string n1 = "/random/04";
-
-  Interest interest;
-  interest
-    .setInterestLifetime(1)
-    .setName (n1);
-
-  c1->sendInterest(interest, closure);
-  usleep(3500000);
-  c2->publishData(Name(n1), (const unsigned char *)n1.c_str(), n1.size(), 1);
-  usleep(100000);
-  BOOST_CHECK_EQUAL(g_dataCallback_counter, 1);
-  BOOST_CHECK_EQUAL(g_timeout_counter, 3);
-  teardown();
-}
-
-BOOST_AUTO_TEST_CASE (Unsigned)
-{
-  setup();
-  string n1 = "/xxxxxx/unsigned/001";
-  Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1, _2, _3));
-
-  g_dataCallback_counter = 0;
-  c1->sendInterest(Name(n1), closure);
-  usleep(100000);
-  c2->publishUnsignedData(Name(n1), (const unsigned char *)n1.c_str(), n1.size(), 1);
-  usleep(100000);
-  BOOST_CHECK_EQUAL(g_dataCallback_counter, 1);
-
-  string n2 = "/xxxxxx/signed/001";
-  Bytes content = c1->createContentObject(Name(n1), (const unsigned char *)n2.c_str(), n2.size(), 1);
-
-  c1->publishUnsignedData(Name(n2), head(content), content.size(), 1);
-  Closure encapClosure(bind(encapCallback, _1, _2), bind(timeout, _1, _2, _3));
-  c2->sendInterest(Name(n2), encapClosure);
-  usleep(4000000);
-  BOOST_CHECK_EQUAL(g_dataCallback_counter, 2);
-  teardown();
-}
-
-
- /*
- BOOST_AUTO_TEST_CASE (ndnWrapperUnsigningTest)
- {
-   setup();
-   Bytes data;
-   data.resize(1024);
-   for (int i = 0; i < 1024; i++)
-   {
-     data[i] = 'm';
-   }
-
-   Name name("/unsigningtest");
-
-   posix_time::ptime start = posix_time::second_clock::local_time();
-   for (uint64_t i = 0; i < 100000; i++)
-   {
-     Name n = name;
-     n.appendComp(i);
-     c1->publishUnsignedData(n, data, 10);
-   }
-   posix_time::ptime end = posix_time::second_clock::local_time();
-
-   posix_time::time_duration duration = end - start;
-
-   cout << "Publishing 100000 1K size content objects costs " <<duration.total_milliseconds() << " milliseconds" << endl;
-   cout << "Average time to publish one content object is " << (double) duration.total_milliseconds() / 100000.0 << " milliseconds" << endl;
-    teardown();
- }
- */
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/disabled/wrapper.cc b/disabled/wrapper.cc
deleted file mode 100644
index 4ef079e..0000000
--- a/disabled/wrapper.cc
+++ /dev/null
@@ -1,791 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "wrapper.h"
-
-extern "C" {
-#include <ccn/fetch.h>
-}
-#include <poll.h>
-#include <boost/throw_exception.hpp>
-#include <boost/random.hpp>
-#include <boost/make_shared.hpp>
-#include <boost/algorithm/string.hpp>
-
-#include <sstream>
-
-// #include "ndn.cxx/verifier.h"
-#include "executor/executor.h"
-
-#include "logging.h"
-#include "ndn.cxx/wire/ccnb.h"
-
-
-INIT_LOGGER ("ndn.Wrapper");
-
-typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
-typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
-
-using namespace std;
-using namespace boost;
-
-namespace ndn {
-
-// hack to enable fake signatures
-// min length for signature field is 16, as defined in ccn_buf_decoder.c:728
-const int DEFAULT_SIGNATURE_SIZE = 16;
-
-// Although ccn_buf_decoder.c:745 defines minimum length 16, something else is checking and only 32-byte fake value is accepted by ccnd
-const int PUBLISHER_KEY_SIZE = 32;
-
-static int
-ccn_encode_garbage_Signature(struct ccn_charbuf *buf)
-{
-    int res = 0;
-
-    res |= ccn_charbuf_append_tt(buf, CCN_DTAG_Signature, CCN_DTAG);
-
-    // Let's cheat more.  Default signing algorithm in ccnd is SHA256, so we just need add 32 bytes of garbage
-    static char garbage [DEFAULT_SIGNATURE_SIZE];
-
-    // digest and witness fields are optional, so use default ones
-
-    res |= ccn_charbuf_append_tt(buf, CCN_DTAG_SignatureBits, CCN_DTAG);
-    res |= ccn_charbuf_append_tt(buf, DEFAULT_SIGNATURE_SIZE, CCN_BLOB);
-    res |= ccn_charbuf_append(buf, garbage, DEFAULT_SIGNATURE_SIZE);
-    res |= ccn_charbuf_append_closer(buf);
-
-    res |= ccn_charbuf_append_closer(buf);
-
-    return(res == 0 ? 0 : -1);
-}
-
-static int
-ccn_pack_unsigned_ContentObject(struct ccn_charbuf *buf,
-                                const struct ccn_charbuf *Name,
-                                const struct ccn_charbuf *SignedInfo,
-                                const void *data,
-                                size_t size)
-{
-    int res = 0;
-    struct ccn_charbuf *content_header;
-    size_t closer_start;
-
-    content_header = ccn_charbuf_create();
-    res |= ccn_charbuf_append_tt(content_header, CCN_DTAG_Content, CCN_DTAG);
-    if (size != 0)
-        res |= ccn_charbuf_append_tt(content_header, size, CCN_BLOB);
-    closer_start = content_header->length;
-    res |= ccn_charbuf_append_closer(content_header);
-    if (res < 0)
-        return(-1);
-
-    res |= ccn_charbuf_append_tt(buf, CCN_DTAG_ContentObject, CCN_DTAG);
-
-    res |= ccn_encode_garbage_Signature(buf);
-
-    res |= ccn_charbuf_append_charbuf(buf, Name);
-    res |= ccn_charbuf_append_charbuf(buf, SignedInfo);
-    res |= ccnb_append_tagged_blob(buf, CCN_DTAG_Content, data, size);
-    res |= ccn_charbuf_append_closer(buf);
-
-    ccn_charbuf_destroy(&content_header);
-    return(res == 0 ? 0 : -1);
-}
-
-Wrapper::Wrapper()
-  : m_handle (0)
-  , m_running (true)
-  , m_connected (false)
-  , m_executor (new Executor(1))
-  // , m_verifier(new Verifier(this))
-{
-  start ();
-}
-
-void
-Wrapper::connectCcnd()
-{
-  if (m_handle != 0) {
-    ccn_disconnect (m_handle);
-    //ccn_destroy (&m_handle);
-  }
-  else
-    {
-      m_handle = ccn_create ();
-    }
-
-  UniqueRecLock lock(m_mutex);
-  if (ccn_connect(m_handle, NULL) < 0)
-  {
-    BOOST_THROW_EXCEPTION (Error::ndnOperation() << errmsg_info_str("connection to ccnd failed"));
-  }
-  m_connected = true;
-
-  if (!m_registeredInterests.empty())
-  {
-   for (map<Name, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
-    {
-      clearInterestFilter(it->first, false);
-      setInterestFilter(it->first, it->second, false);
-    }
-  }
-}
-
-Wrapper::~Wrapper()
-{
-  shutdown ();
-  // if (m_verifier != 0)
-  // {
-  //   delete m_verifier;
-  //   m_verifier = 0;
-  // }
-}
-
-void
-Wrapper::start () // called automatically in constructor
-{
-  connectCcnd();
-  m_thread = thread (&Wrapper::ccnLoop, this);
-  m_executor->start();
-}
-
-void
-Wrapper::shutdown () // called in destructor, but can called manually
-{
-  m_executor->shutdown();
-
-  {
-    UniqueRecLock lock(m_mutex);
-    m_running = false;
-  }
-
-  _LOG_DEBUG ("+++++++++SHUTDOWN+++++++");
-  if (m_connected)
-    {
-      m_thread.join ();
-
-      ccn_disconnect (m_handle);
-      //ccn_destroy (&m_handle);
-      m_connected = false;
-    }
-}
-
-void
-Wrapper::ccnLoop ()
-{
-  static boost::mt19937 randomGenerator (static_cast<unsigned int> (std::time (0)));
-  static boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rangeUniformRandom (randomGenerator, uniform_int<> (0,1000));
-
-  while (m_running)
-    {
-      try
-        {
-          int res = 0;
-          {
-            UniqueRecLock lock(m_mutex);
-            res = ccn_run (m_handle, 0);
-          }
-
-          if (!m_running) break;
-
-          if (res < 0) {
-            _LOG_ERROR ("ccn_run returned negative status: " << res);
-
-            BOOST_THROW_EXCEPTION (Error::ndnOperation()
-                                   << errmsg_info_str("ccn_run returned error"));
-          }
-
-
-          pollfd pfds[1];
-          {
-            UniqueRecLock lock(m_mutex);
-
-            pfds[0].fd = ccn_get_connection_fd (m_handle);
-            pfds[0].events = POLLIN;
-            if (ccn_output_is_pending (m_handle))
-              pfds[0].events |= POLLOUT;
-          }
-
-          int ret = poll (pfds, 1, 1);
-          if (ret < 0)
-            {
-              BOOST_THROW_EXCEPTION (Error::ndnOperation() << errmsg_info_str("ccnd socket failed (probably ccnd got stopped)"));
-            }
-        }
-        catch (Error::ndnOperation &e)
-        {
-          m_connected = false;
-          // probably ccnd has been stopped
-          // try reconnect with sleep
-          int interval = 1;
-          int maxInterval = 32;
-          while (m_running)
-          {
-            try
-            {
-              this_thread::sleep (boost::get_system_time () +  time::Seconds (interval) + time::Milliseconds (rangeUniformRandom ()));
-
-              connectCcnd ();
-              _LOG_DEBUG("reconnect to ccnd succeeded");
-              break;
-            }
-            catch (Error::ndnOperation &e)
-            {
-              this_thread::sleep (boost::get_system_time () +  time::Seconds (interval) + time::Milliseconds (rangeUniformRandom ()));
-
-              // do exponential backup for reconnect interval
-              if (interval < maxInterval)
-              {
-                interval *= 2;
-              }
-            }
-          }
-        }
-        catch (const std::exception &exc)
-          {
-            // catch anything thrown within try block that derives from std::exception
-            std::cerr << exc.what();
-          }
-        catch (...)
-          {
-            cout << "UNKNOWN EXCEPTION !!!" << endl;
-          }
-     }
-}
-
-Bytes
-Wrapper::createContentObject(const Name  &name, const void *buf, size_t len, int freshness, const Name &keyNameParam)
-{
-  {
-    UniqueRecLock lock(m_mutex);
-    if (!m_running || !m_connected)
-      {
-        _LOG_TRACE ("<< not running or connected");
-        return Bytes ();
-      }
-  }
-
-  ccn_charbuf *content = ccn_charbuf_create();
-
-  struct ccn_signing_params sp = CCN_SIGNING_PARAMS_INIT;
-  sp.freshness = freshness;
-
-  Name keyName;
-
-  if (keyNameParam.size() == 0)
-  {
-    // use default key name
-    CharbufPtr defaultKeyNamePtr = boost::make_shared<Charbuf>();
-    ccn_get_public_key_and_name(m_handle, &sp, NULL, NULL, defaultKeyNamePtr->getBuf());
-    keyName = Name(*defaultKeyNamePtr);
-
-    _LOG_DEBUG ("DEFAULT KEY NAME: " << keyName);
-  }
-  else
-  {
-    keyName = keyNameParam;
-  }
-
-  if (sp.template_ccnb == NULL)
-  {
-    sp.template_ccnb = ccn_charbuf_create();
-    ccn_charbuf_append_tt(sp.template_ccnb, CCN_DTAG_SignedInfo, CCN_DTAG);
-  }
-  // no idea what the following 3 lines do, but it was there
-  else if (sp.template_ccnb->length > 0) {
-      sp.template_ccnb->length--;
-  }
-  ccn_charbuf_append_tt(sp.template_ccnb, CCN_DTAG_KeyLocator, CCN_DTAG);
-  ccn_charbuf_append_tt(sp.template_ccnb, CCN_DTAG_KeyName, CCN_DTAG);
-
-  charbuf_stream keyStream;
-  wire::Ccnb::appendName (keyStream, keyName);
-  
-  ccn_charbuf_append(sp.template_ccnb, keyStream.buf ().getBuf ()->buf, keyStream.buf ().getBuf ()->length);
-  ccn_charbuf_append_closer(sp.template_ccnb); // </KeyName>
-  ccn_charbuf_append_closer(sp.template_ccnb); // </KeyLocator>
-  sp.sp_flags |= CCN_SP_TEMPL_KEY_LOCATOR;
-  ccn_charbuf_append_closer(sp.template_ccnb); // </SignedInfo>
-
-  charbuf_stream nameStream;
-  wire::Ccnb::appendName (nameStream, name);
-  
-  if (ccn_sign_content(m_handle, content, nameStream.buf ().getBuf (), &sp, buf, len) != 0)
-  {
-    BOOST_THROW_EXCEPTION(Error::ndnOperation() << errmsg_info_str("sign content failed"));
-  }
-
-  Bytes bytes;
-  readRaw(bytes, content->buf, content->length);
-
-  ccn_charbuf_destroy (&content);
-  if (sp.template_ccnb != NULL)
-  {
-    ccn_charbuf_destroy (&sp.template_ccnb);
-  }
-
-  return bytes;
-}
-
-int
-Wrapper::putToCcnd (const Bytes &contentObject)
-{
-  _LOG_TRACE (">> putToCcnd");
-  UniqueRecLock lock(m_mutex);
-  if (!m_running || !m_connected)
-    {
-      _LOG_TRACE ("<< not running or connected");
-      return -1;
-    }
-
-
-  if (ccn_put(m_handle, head(contentObject), contentObject.size()) < 0)
-  {
-    _LOG_ERROR ("ccn_put failed");
-    // BOOST_THROW_EXCEPTION(Error::ndnOperation() << errmsg_info_str("ccnput failed"));
-  }
-  else
-    {
-      _LOG_DEBUG ("<< putToCcnd");
-    }
-
-  return 0;
-}
-
-int
-Wrapper::publishData (const Name &name, const unsigned char *buf, size_t len, int freshness, const Name &keyName)
-{
-  _LOG_TRACE ("publishData: " << name);
-  Bytes co = createContentObject(name, buf, len, freshness, keyName);
-  return putToCcnd(co);
-}
-
-int
-Wrapper::publishUnsignedData(const Name &name, const unsigned char *buf, size_t len, int freshness)
-{
-  _LOG_TRACE ("publishUnsignedData: " << name);
-  {
-    UniqueRecLock lock(m_mutex);
-    if (!m_running || !m_connected)
-      {
-        _LOG_TRACE ("<< not running or connected");
-        return -1;
-      }
-  }
-
-  ccn_charbuf *content = ccn_charbuf_create();
-  ccn_charbuf *signed_info = ccn_charbuf_create();
-
-  static char fakeKey[PUBLISHER_KEY_SIZE];
-
-  int res = ccn_signed_info_create(signed_info,
-                                   fakeKey, PUBLISHER_KEY_SIZE,
-                                   NULL,
-                                   CCN_CONTENT_DATA,
-                                   freshness,
-                                   NULL,
-                                   NULL  // ccnd is happy with absent key locator and key itself... ha ha
-                                   );
-
-  charbuf_stream nameStream;
-  wire::Ccnb::appendName (nameStream, name);
-
-  ccn_pack_unsigned_ContentObject(content, nameStream.buf ().getBuf (), signed_info, buf, len);
-
-  Bytes bytes;
-  readRaw(bytes, content->buf, content->length);
-
-  ccn_charbuf_destroy (&content);
-  ccn_charbuf_destroy (&signed_info);
-
-  return putToCcnd (bytes);
-}
-
-
-static void
-deleterInInterestTuple (tuple<Wrapper::InterestCallback *, ExecutorPtr> *tuple)
-{
-  delete tuple->get<0> ();
-  delete tuple;
-}
-
-static ccn_upcall_res
-incomingInterest(ccn_closure *selfp,
-                 ccn_upcall_kind kind,
-                 ccn_upcall_info *info)
-{
-  Wrapper::InterestCallback *f;
-  ExecutorPtr executor;
-  tuple<Wrapper::InterestCallback *, ExecutorPtr> *realData = reinterpret_cast< tuple<Wrapper::InterestCallback *, ExecutorPtr>* > (selfp->data);
-  tie (f, executor) = *realData;
-
-  switch (kind)
-    {
-    case CCN_UPCALL_FINAL: // effective in unit tests
-      // delete closure;
-      executor->execute (bind (deleterInInterestTuple, realData));
-
-      delete selfp;
-      _LOG_TRACE ("<< incomingInterest with CCN_UPCALL_FINAL");
-      return CCN_UPCALL_RESULT_OK;
-
-    case CCN_UPCALL_INTEREST:
-      _LOG_TRACE (">> incomingInterest upcall: " << Name(info->interest_ccnb, info->interest_comps));
-      break;
-
-    default:
-      _LOG_TRACE ("<< incomingInterest with CCN_UPCALL_RESULT_OK: " << Name(info->interest_ccnb, info->interest_comps));
-      return CCN_UPCALL_RESULT_OK;
-    }
-
-  InterestPtr interest = make_shared<Interest> (info->pi);
-  interest->setName (Name (info->interest_ccnb, info->interest_comps));
-
-  executor->execute (bind (*f, interest));
-  // this will be run in executor
-  // (*f) (interest);
-  // closure->runInterestCallback(interest);
-
-  return CCN_UPCALL_RESULT_OK;
-}
-
-static void
-deleterInDataTuple (tuple<Closure *, ExecutorPtr, InterestPtr> *tuple)
-{
-  delete tuple->get<0> ();
-  delete tuple;
-}
-
-static ccn_upcall_res
-incomingData(ccn_closure *selfp,
-             ccn_upcall_kind kind,
-             ccn_upcall_info *info)
-{
-  // Closure *cp = static_cast<Closure *> (selfp->data);
-  Closure *cp;
-  ExecutorPtr executor;
-  InterestPtr interest;
-  tuple<Closure *, ExecutorPtr, InterestPtr> *realData = reinterpret_cast< tuple<Closure*, ExecutorPtr, InterestPtr>* > (selfp->data);
-  tie (cp, executor, interest) = *realData;
-
-  switch (kind)
-    {
-    case CCN_UPCALL_FINAL:  // effecitve in unit tests
-      executor->execute (bind (deleterInDataTuple, realData));
-
-      cp = NULL;
-      delete selfp;
-      _LOG_TRACE ("<< incomingData with CCN_UPCALL_FINAL");
-      return CCN_UPCALL_RESULT_OK;
-
-    case CCN_UPCALL_CONTENT:
-      _LOG_TRACE (">> incomingData content upcall: " << Name (info->content_ccnb, info->content_comps));
-      break;
-
-    // this is the case where the intentionally unsigned packets coming (in Encapsulation case)
-    case CCN_UPCALL_CONTENT_BAD:
-      _LOG_TRACE (">> incomingData content bad upcall: " << Name (info->content_ccnb, info->content_comps));
-      break;
-
-    // always ask ccnd to try to fetch the key
-    case CCN_UPCALL_CONTENT_UNVERIFIED:
-      _LOG_TRACE (">> incomingData content unverified upcall: " << Name (info->content_ccnb, info->content_comps));
-      break;
-
-    case CCN_UPCALL_INTEREST_TIMED_OUT: {
-      if (cp != NULL)
-      {
-        Name interestName (info->interest_ccnb, info->interest_comps);
-        _LOG_TRACE ("<< incomingData timeout: " << Name (info->interest_ccnb, info->interest_comps));
-        executor->execute (bind (&Closure::runTimeoutCallback, cp, interestName, *cp, interest));
-      }
-      else
-        {
-          _LOG_TRACE ("<< incomingData timeout, but callback is not set...: " << Name (info->interest_ccnb, info->interest_comps));
-        }
-      return CCN_UPCALL_RESULT_OK;
-    }
-
-    default:
-      _LOG_TRACE(">> unknown upcall type");
-      return CCN_UPCALL_RESULT_OK;
-    }
-
-  PcoPtr pco = make_shared<ParsedContentObject> (info->content_ccnb, info->pco->offset[CCN_PCO_E]);
-
-  // this will be run in executor
-  executor->execute (bind (&Closure::runDataCallback, cp, pco->name (), pco));
-  _LOG_TRACE (">> incomingData");
-
-  return CCN_UPCALL_RESULT_OK;
-}
-
-int Wrapper::sendInterest (const Interest &interest, const Closure &closure)
-{
-  _LOG_TRACE (">> sendInterest: " << interest.getName ());
-  {
-    UniqueRecLock lock(m_mutex);
-    if (!m_running || !m_connected)
-      {
-        _LOG_ERROR ("<< sendInterest: not running or connected");
-        return -1;
-      }
-  }
-
-  ccn_closure *dataClosure = new ccn_closure;
-
-  // Closure *myClosure = new ExecutorClosure(closure, m_executor);
-  Closure *myClosure = closure.dup ();
-  dataClosure->data = new tuple<Closure*, ExecutorPtr, InterestPtr> (myClosure, m_executor, make_shared<Interest> (interest));
-
-  dataClosure->p = &incomingData;
-
-  UniqueRecLock lock(m_mutex);
-
-  charbuf_stream nameStream;
-  wire::Ccnb::appendName (nameStream, interest.getName ());
-
-  charbuf_stream interestStream;
-  wire::Ccnb::appendInterest (interestStream, interest);
-
-  if (ccn_express_interest (m_handle, nameStream.buf ().getBuf (),
-                            dataClosure,
-                            interestStream.buf ().getBuf ()
-                            ) < 0)
-  {
-    _LOG_ERROR ("<< sendInterest: ccn_express_interest FAILED!!!");
-  }
-
-  return 0;
-}
-
-int Wrapper::setInterestFilter (const Name &prefix, const InterestCallback &interestCallback, bool record/* = true*/)
-{
-  _LOG_TRACE (">> setInterestFilter");
-  UniqueRecLock lock(m_mutex);
-  if (!m_running || !m_connected)
-  {
-    return -1;
-  }
-
-  ccn_closure *interestClosure = new ccn_closure;
-
-  // interestClosure->data = new ExecutorInterestClosure(interestCallback, m_executor);
-
-  interestClosure->data = new tuple<Wrapper::InterestCallback *, ExecutorPtr> (new InterestCallback (interestCallback), m_executor); // should be removed when closure is removed
-  interestClosure->p = &incomingInterest;
-
-  charbuf_stream prefixStream;
-  wire::Ccnb::appendName (prefixStream, prefix);
-
-  int ret = ccn_set_interest_filter (m_handle, prefixStream.buf ().getBuf (), interestClosure);
-  if (ret < 0)
-  {
-    _LOG_ERROR ("<< setInterestFilter: ccn_set_interest_filter FAILED");
-  }
-
-  if (record)
-    {
-      m_registeredInterests.insert(pair<Name, InterestCallback>(prefix, interestCallback));
-    }
-
-  _LOG_TRACE ("<< setInterestFilter");
-
-  return ret;
-}
-
-void
-Wrapper::clearInterestFilter (const Name &prefix, bool record/* = true*/)
-{
-  _LOG_TRACE (">> clearInterestFilter");
-  UniqueRecLock lock(m_mutex);
-  if (!m_running || !m_connected)
-    return;
-
-  charbuf_stream prefixStream;
-  wire::Ccnb::appendName (prefixStream, prefix);
-
-  int ret = ccn_set_interest_filter (m_handle, prefixStream.buf ().getBuf (), 0);
-  if (ret < 0)
-  {
-  }
-
-  if (record)
-    {
-      m_registeredInterests.erase(prefix);
-    }
-
-  _LOG_TRACE ("<< clearInterestFilter");
-}
-
-Name
-Wrapper::getLocalPrefix ()
-{
-  struct ccn * tmp_handle = ccn_create ();
-  int res = ccn_connect (tmp_handle, NULL);
-  if (res < 0)
-    {
-      return Name();
-    }
-
-  string retval = "";
-
-  struct ccn_charbuf *templ = ccn_charbuf_create();
-  ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
-  ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
-  ccn_charbuf_append_closer(templ); /* </Name> */
-  // XXX - use pubid if possible
-  ccn_charbuf_append_tt(templ, CCN_DTAG_MaxSuffixComponents, CCN_DTAG);
-  ccnb_append_number(templ, 1);
-  ccn_charbuf_append_closer(templ); /* </MaxSuffixComponents> */
-  ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", 2);
-  ccn_charbuf_append_closer(templ); /* </Interest> */
-
-  struct ccn_charbuf *name = ccn_charbuf_create ();
-  res = ccn_name_from_uri (name, "/local/ndn/prefix");
-  if (res < 0) {
-  }
-  else
-    {
-      struct ccn_fetch *fetch = ccn_fetch_new (tmp_handle);
-
-      struct ccn_fetch_stream *stream = ccn_fetch_open (fetch, name, "/local/ndn/prefix",
-                                                        NULL, 4, CCN_V_HIGHEST, 0);
-      if (stream == NULL) {
-      }
-      else
-        {
-          ostringstream os;
-
-          int counter = 0;
-          char buf[256];
-          while (true) {
-            res = ccn_fetch_read (stream, buf, sizeof(buf));
-
-            if (res == 0) {
-              break;
-            }
-
-            if (res > 0) {
-              os << string(buf, res);
-            } else if (res == CCN_FETCH_READ_NONE) {
-              if (counter < 2)
-                {
-                  ccn_run(tmp_handle, 1000);
-                  counter ++;
-                }
-              else
-                {
-                  break;
-                }
-            } else if (res == CCN_FETCH_READ_END) {
-              break;
-            } else if (res == CCN_FETCH_READ_TIMEOUT) {
-              break;
-            } else {
-              break;
-            }
-          }
-          retval = os.str ();
-          stream = ccn_fetch_close(stream);
-        }
-      fetch = ccn_fetch_destroy(fetch);
-    }
-
-  ccn_charbuf_destroy (&name);
-
-  ccn_disconnect (tmp_handle);
-  ccn_destroy (&tmp_handle);
-
-  boost::algorithm::trim(retval);
-  return Name(retval);
-}
-
-bool
-Wrapper::verify(PcoPtr &pco, double maxWait)
-{
-  return true; // totally fake
-  // return m_verifier->verify(pco, maxWait);
-}
-
-/// @cond include_hidden
-// This is needed just for get function implementation
-struct GetState
-{
-  GetState (double maxWait)
-  {
-    double intPart, fraction;
-    fraction = modf (std::abs(maxWait), &intPart);
-
-    m_maxWait = time::Now ()
-      + time::Seconds (intPart)
-      + time::Microseconds (fraction * 1000000);
-  }
-
-  PcoPtr
-  WaitForResult ()
-  {
-    //_LOG_TRACE("GetState::WaitForResult start");
-    boost::unique_lock<boost::mutex> lock (m_mutex);
-    m_cond.timed_wait (lock, m_maxWait);
-    //_LOG_TRACE("GetState::WaitForResult finish");
-
-    return m_retval;
-  }
-
-  void
-  DataCallback (Name name, PcoPtr pco)
-  {
-    //_LOG_TRACE("GetState::DataCallback, Name [" << name << "]");
-    boost::unique_lock<boost::mutex> lock (m_mutex);
-    m_retval = pco;
-    m_cond.notify_one ();
-  }
-
-  void
-  TimeoutCallback (Name name)
-  {
-    boost::unique_lock<boost::mutex> lock (m_mutex);
-    m_cond.notify_one ();
-  }
-
-private:
-  Time m_maxWait;
-
-  boost::mutex m_mutex;
-  boost::condition_variable    m_cond;
-
-  PcoPtr  m_retval;
-};
-/// @endcond
-
-PcoPtr
-Wrapper::get(const Interest &interest, double maxWait/* = 4.0*/)
-{
-  _LOG_TRACE (">> get: " << interest.getName ());
-  {
-    UniqueRecLock lock(m_mutex);
-    if (!m_running || !m_connected)
-      {
-        _LOG_ERROR ("<< get: not running or connected");
-        return PcoPtr ();
-      }
-  }
-
-  GetState state (maxWait);
-  this->sendInterest (interest, Closure (boost::bind (&GetState::DataCallback, &state, _1, _2),
-                                         boost::bind (&GetState::TimeoutCallback, &state, _1)));
-  return state.WaitForResult ();
-}
-
-}
diff --git a/disabled/wrapper.h b/disabled/wrapper.h
deleted file mode 100644
index 517a832..0000000
--- a/disabled/wrapper.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_WRAPPER_H
-#define NDN_WRAPPER_H
-
-#include <boost/thread/locks.hpp>
-#include <boost/thread/recursive_mutex.hpp>
-#include <boost/thread/thread.hpp>
-
-#include "ndn.cxx/common.h"
-#include "ndn.cxx/fields/name.h"
-#include "ndn.cxx/interest.h"
-#include "ndn.cxx/closure.h"
-#include "ndn.cxx/pco.h"
-
-class Executor;
-typedef boost::shared_ptr<Executor> ExecutorPtr;
-
-namespace ndn {
-
-class Verifier;
-class Wrapper
-{
-public:
-  const static int MAX_FRESHNESS = 2147; // max value for ccnx
-  const static int DEFAULT_FRESHNESS = 60;
-  typedef boost::function<void (InterestPtr)> InterestCallback;
-
-  Wrapper();
-  ~Wrapper();
-
-  void
-  start (); // called automatically in constructor
-
-  /**
-   * @brief Because of uncertainty with executor, in some case it is necessary to call shutdown explicitly (see test-server-and-fetch.cc)
-   */
-  void
-  shutdown (); // called in destructor, but can called manually
-
-  int
-  setInterestFilter (const Name &prefix, const InterestCallback &interestCallback, bool record = true);
-
-  void
-  clearInterestFilter (const Name &prefix, bool record = true);
-
-  int
-  sendInterest (const Interest &interest, const Closure &closure);
-
-  int
-  publishData (const Name &name, const unsigned char *buf, size_t len, int freshness = DEFAULT_FRESHNESS, const Name &keyName=Name());
-
-  inline int
-  publishData (const Name &name, const Bytes &content, int freshness = DEFAULT_FRESHNESS, const Name &keyName=Name());
-
-  inline int
-  publishData (const Name &name, const std::string &content, int freshness = DEFAULT_FRESHNESS, const Name &keyName=Name());
-
-  int
-  publishUnsignedData(const Name &name, const unsigned char *buf, size_t len, int freshness = DEFAULT_FRESHNESS);
-
-  inline int
-  publishUnsignedData(const Name &name, const Bytes &content, int freshness = DEFAULT_FRESHNESS);
-
-  inline int
-  publishUnsignedData(const Name &name, const std::string &content, int freshness = DEFAULT_FRESHNESS);
-
-  static Name
-  getLocalPrefix ();
-
-  Bytes
-  createContentObject(const Name &name, const void *buf, size_t len, int freshness = DEFAULT_FRESHNESS, const Name &keyNameParam=Name());
-
-  int
-  putToCcnd (const Bytes &contentObject);
-
-  bool
-  verify(PcoPtr &pco, double maxWait = 1 /*seconds*/);
-
-  PcoPtr
-  get (const Interest &interest, double maxWait = 4.0/*seconds*/);
-
-private:
-  Wrapper(const Wrapper &other) {}
-
-protected:
-  void
-  connectCcnd();
-
-  /// @cond include_hidden
-  void
-  ccnLoop ();
-
-  /// @endcond
-
-protected:
-  typedef boost::shared_mutex Lock;
-  typedef boost::unique_lock<Lock> WriteLock;
-  typedef boost::shared_lock<Lock> ReadLock;
-
-  typedef boost::recursive_mutex RecLock;
-  typedef boost::unique_lock<RecLock> UniqueRecLock;
-
-  ccn* m_handle;
-  RecLock m_mutex;
-  boost::thread m_thread;
-  bool m_running;
-  bool m_connected;
-  std::map<Name, InterestCallback> m_registeredInterests;
-  ExecutorPtr m_executor;
-  Verifier *m_verifier;
-};
-
-typedef boost::shared_ptr<Wrapper> WrapperPtr;
-
-/**
- * @brief Namespace holding all exceptions that can be fired by the library
- */
-namespace Error
-{
-struct ndnOperation : boost::exception, std::exception { };
-}
-
-inline int
-Wrapper::publishData (const Name &name, const Bytes &content, int freshness, const Name &keyName)
-{
-  return publishData(name, head(content), content.size(), freshness, keyName);
-}
-
-inline int
-Wrapper::publishData (const Name &name, const std::string &content, int freshness, const Name &keyName)
-{
-  return publishData(name, reinterpret_cast<const unsigned char *> (content.c_str ()), content.size (), freshness, keyName);
-}
-
-inline int
-Wrapper::publishUnsignedData(const Name &name, const Bytes &content, int freshness)
-{
-  return publishUnsignedData(name, head(content), content.size(), freshness);
-}
-
-inline int
-Wrapper::publishUnsignedData(const Name &name, const std::string &content, int freshness)
-{
-  return publishUnsignedData(name, reinterpret_cast<const unsigned char *> (content.c_str ()), content.size (), freshness);
-}
-
-
-} // ndn
-
-#endif
diff --git a/example/.gitignore b/example/.gitignore
deleted file mode 100644
index 8ed876c..0000000
--- a/example/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build/
-.waf*
diff --git a/example/client.cc b/example/client.cc
deleted file mode 100644
index 279d260..0000000
--- a/example/client.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include <ndn.cxx.h>
-#include <iostream>
-
-using namespace std;
-
-const char *FILENAME = NULL;
-ndn::Name InterestBaseName;
-
-// create a global handler
-ndn::Wrapper handler;
-
-void OnData (ndn::Name name, ndn::PcoPtr pco);
-void OnTimeout (ndn::Name name, const ndn::Closure &closure, ndn::InterestPtr origInterest);
-
-void OnData (ndn::Name name, ndn::PcoPtr pco)
-{
-  ndn::BytesPtr content = pco->contentPtr ();
-  cout << string ((char*)ndn::head (*content), content->size ());
-
-  int seqnum = ndn::Name::asSeqNum (*name.rbegin ());
-  if (seqnum >= 10)
-    {
-      return;
-    }
-
-  cerr << ">> C++ " << ndn::Name (InterestBaseName).appendSeqNum (seqnum + 1) << endl; // a shortcut to construct name
-  handler.sendInterest (ndn::Interest ()
-                        .setName (ndn::Name (InterestBaseName).appendSeqNum (seqnum + 1))
-                        .setScope (ndn::Interest::SCOPE_LOCAL_HOST),
-                        ndn::Closure (OnData, OnTimeout));
-}
-
-void OnTimeout (ndn::Name name, const ndn::Closure &closure, ndn::InterestPtr origInterest)
-{
-  // re-express interest
-  handler.sendInterest (*origInterest, closure);
-}
-
-int
-main (int argc, char **argv)
-{
-  if (argc < 2)
-    {
-      std::cerr << "You have to specify filename as an argument" << std::endl;
-      return -1;
-    }
-  
-  // this code does not check for most of the bad conditions
-  FILENAME = argv[1];
-
-  InterestBaseName = ndn::Name ("/my-local-prefix/simple-fetch/file");
-  InterestBaseName.append (FILENAME);
-
-  cerr << ">> C++ " << ndn::Name (InterestBaseName).appendSeqNum (0) << endl;
-  handler.sendInterest (ndn::Interest ()
-                        .setName (ndn::Name (InterestBaseName).appendSeqNum (0))
-                        .setScope (ndn::Interest::SCOPE_LOCAL_HOST),
-                        ndn::Closure (OnData, OnTimeout));
-
-  sleep (3);
-  return 0;
-}
diff --git a/example/server.cc b/example/server.cc
deleted file mode 100644
index 1a62f20..0000000
--- a/example/server.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include <ndn.cxx.h>
-#include <iostream>
-
-using namespace std;
-
-ndn::Name InterestBaseName;
-
-// create a global handler
-ndn::Wrapper handler;
-
-void OnInterest (ndn::InterestPtr interest)
-{
-  cerr << interest->getName () << endl;
-  
-  static int COUNTER = 0;
-
-  ostringstream os;
-  os << "C++ LINE #" << (COUNTER++) << endl;
-  
-  handler.publishData (interest->getName (), os.str (), 5);
-}
-
-int
-main (int argc, char **argv)
-{
-  InterestBaseName = ndn::Name ("ccnx:/my-local-prefix/simple-fetch/file");
-
-  handler.setInterestFilter (InterestBaseName, OnInterest);
-  
-  while (true)
-    {
-      sleep (1);
-    }
-  return 0;
-}
diff --git a/example/waf b/example/waf
deleted file mode 100755
index f26d925..0000000
--- a/example/waf
+++ /dev/null
Binary files differ
diff --git a/example/wscript b/example/wscript
deleted file mode 100644
index c617d47..0000000
--- a/example/wscript
+++ /dev/null
@@ -1,66 +0,0 @@
-# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-VERSION='0.1'
-APPNAME='test-project'
-
-from waflib import Build, Logs, Utils, Task, TaskGen, Configure
-
-def options(opt):
-    opt.load('compiler_c compiler_cxx boost ccnx')
-
-def configure(conf):
-    conf.load("compiler_c compiler_cxx ccnx")
-
-    conf.add_supported_cxxflags (cxxflags = ['-O0',
-                                             '-Wall',
-                                             '-Wno-unused-variable',
-                                             '-g3',
-                                             '-Wno-unused-private-field',
-                                             '-fcolor-diagnostics',
-                                             '-Qunused-arguments'
-                                             ])
-
-    if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
-        libcrypto = conf.check_cc(lib='crypto',
-                                  header_name='openssl/crypto.h',
-                                  define_name='HAVE_SSL',
-                                  uselib_store='SSL')
-    else:
-        conf.define ("HAVE_SSL", 1)
-    if not conf.get_define ("HAVE_SSL"):
-        conf.fatal ("Cannot find SSL libraries")
-
-    conf.check_ccnx (path=conf.options.ccnx_dir)
-    conf.check_cfg(package='libndn.cxx', args=['--cflags', '--libs'], uselib_store='CCNXCPP', mandatory=True)
-
-    conf.load('boost')
-    conf.check_boost(lib='system test iostreams filesystem thread')
-
-def build (bld):
-    bld (
-        features = ["cxx", "cxxprogram"],
-        target = "client",
-        source = "client.cc",
-        use = 'BOOST BOOST_THREAD CCNX CCNXCPP',
-        )
-
-    bld (
-        features = ["cxx", "cxxprogram"],
-        target = "server",
-        source = "server.cc",
-        use = 'BOOST BOOST_THREAD CCNX CCNXCPP',
-        )
-
-@Configure.conf
-def add_supported_cxxflags(self, cxxflags):
-    """
-    Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
-    """
-    self.start_msg('Checking allowed flags for c++ compiler')
-
-    supportedFlags = []
-    for flag in cxxflags:
-        if self.check_cxx (cxxflags=[flag], mandatory=False):
-            supportedFlags += [flag]
-
-    self.end_msg (' '.join (supportedFlags))
-    self.env.CXXFLAGS += supportedFlags
diff --git a/executor/executor.cc b/executor/executor.cc
deleted file mode 100644
index 87b5760..0000000
--- a/executor/executor.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "executor.h"
-#include "logging.h"
-
-INIT_LOGGER("Executor")
-
-using namespace std;
-using namespace boost;
-
-Executor::Executor (int poolSize)
-  : m_needStop (true)
-  , m_poolSize (poolSize)
-{
-}
-
-Executor::~Executor()
-{
-  _LOG_DEBUG ("Enter destructor");
-  shutdown ();
-  _LOG_DEBUG ("Exit destructor");
-}
-
-void
-Executor::start ()
-{
-  if (m_needStop)
-    {
-      m_needStop = false;
-      for (int i = 0; i < m_poolSize; i++)
-        {
-          m_group.create_thread (bind(&Executor::run, this));
-        }
-    }
-}
-
-void
-Executor::shutdown ()
-{
-  if (!m_needStop)
-    {
-      m_needStop = true;
-      _LOG_DEBUG ("Iterrupting all");
-      m_group.interrupt_all ();
-      _LOG_DEBUG ("Join all");
-      m_group.join_all ();
-    }
-}
-
-
-void
-Executor::execute(const Job &job)
-{
-  _LOG_DEBUG ("Add to job queue");
-
-  Lock lock(m_mutex);
-  bool queueWasEmpty = m_queue.empty ();
-  m_queue.push_back(job);
-
-  // notify working threads if the queue was empty
-  if (queueWasEmpty)
-  {
-    m_cond.notify_one ();
-  }
-}
-
-int
-Executor::poolSize()
-{
-  return m_group.size();
-}
-
-int
-Executor::jobQueueSize()
-{
-  Lock lock(m_mutex);
-  return m_queue.size();
-}
-
-void
-Executor::run ()
-{
-  _LOG_DEBUG ("Start thread");
-
-  while(!m_needStop)
-  {
-    Job job = waitForJob();
-
-    _LOG_DEBUG (">>> enter job");
-    job (); // even if job is "null", nothing bad will happen
-    _LOG_DEBUG ("<<< exit job");
-  }
-
-  _LOG_DEBUG ("Executor thread finished");
-}
-
-Executor::Job
-Executor::waitForJob()
-{
-  Lock lock(m_mutex);
-
-  // wait until job queue is not empty
-  while (m_queue.empty())
-  {
-    _LOG_DEBUG ("Unlocking mutex for wait");
-    m_cond.wait(lock);
-    _LOG_DEBUG ("Re-locking mutex after wait");
-  }
-
-  _LOG_DEBUG ("Got signal on condition");
-
-  Job job;
-  if (!m_queue.empty ()) // this is not always guaranteed, especially after interruption from destructor
-    {
-      job = m_queue.front();
-      m_queue.pop_front();
-    }
-  return job;
-}
diff --git a/executor/executor.h b/executor/executor.h
deleted file mode 100644
index dd9eac3..0000000
--- a/executor/executor.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef EXECUTOR_H
-#define EXECUTOR_H
-
-#include <boost/function.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/thread.hpp>
-#include <deque>
-
-/* A very simple executor to execute submitted tasks immediately or
- * in the future (depending on whether there is idle thread)
- * A fixed number of threads are created for executing tasks;
- * The policy is FIFO
- * No cancellation of submitted tasks
- */
-
-class Executor
-{
-public:
-  typedef boost::function<void ()> Job;
-
-  Executor(int poolSize);
-  ~Executor();
-
-  // execute the job immediately or sometime in the future
-  void
-  execute(const Job &job);
-
-  int
-  poolSize();
-
-// only for test
-  int
-  jobQueueSize();
-
-  void
-  start ();
-
-  void
-  shutdown ();
-
-private:
-  void
-  run();
-
-  Job
-  waitForJob();
-
-private:
-  typedef std::deque<Job> JobQueue;
-  typedef boost::mutex Mutex;
-  typedef boost::unique_lock<Mutex> Lock;
-  typedef boost::condition_variable Cond;
-  typedef boost::thread Thread;
-  typedef boost::thread_group ThreadGroup;
-  JobQueue m_queue;
-  Mutex m_mutex;
-  Cond m_cond;
-  ThreadGroup m_group;
-
-  volatile bool m_needStop;
-  int m_poolSize;
-};
-
-typedef boost::shared_ptr<Executor> ExecutorPtr;
-#endif // EXECUTOR_H
diff --git a/logging.cc b/logging.cc
deleted file mode 100644
index 04fb6c3..0000000
--- a/logging.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- *         Zhenkai Zhu <zhenkai@cs.ucla.edu>
- */
-
-#include "logging.h"
-
-#ifdef HAVE_LOG4CXX
-
-#include <log4cxx/logger.h>
-#include <log4cxx/basicconfigurator.h>
-#include <log4cxx/consoleappender.h>
-#include <log4cxx/patternlayout.h>
-#include <log4cxx/level.h>
-#include <log4cxx/propertyconfigurator.h>
-#include <log4cxx/defaultconfigurator.h>
-#include <log4cxx/helpers/exception.h>
-using namespace log4cxx;
-using namespace log4cxx::helpers;
-
-#include <unistd.h>
-
-void
-INIT_LOGGERS ()
-{
-  static bool configured = false;
-
-  if (configured) return;
-
-  if (access ("log4cxx.properties", R_OK)==0)
-    PropertyConfigurator::configureAndWatch ("log4cxx.properties");
-  else
-    {
-      PatternLayoutPtr   layout   (new PatternLayout ("%d{HH:mm:ss} %p %c{1} - %m%n"));
-      ConsoleAppenderPtr appender (new ConsoleAppender (layout));
-
-      BasicConfigurator::configure( appender );
-      Logger::getRootLogger()->setLevel (log4cxx::Level::getInfo ());
-    }
-
-  configured = true;
-}
-
-#endif
diff --git a/logging.h b/logging.h
deleted file mode 100644
index 2aa3344..0000000
--- a/logging.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- *         Zhenkai Zhu <zhenkai@cs.ucla.edu>
- */
-
-#ifndef LOGGING_H
-#define LOGGING_H
-
-#include "config.h"
-
-#ifdef HAVE_LOG4CXX
-
-#include <log4cxx/logger.h>
-
-#define MEMBER_LOGGER                           \
-  static log4cxx::LoggerPtr staticModuleLogger;
-
-#define INIT_MEMBER_LOGGER(className,name)          \
-  log4cxx::LoggerPtr className::staticModuleLogger =  log4cxx::Logger::getLogger (name);
-
-#define INIT_LOGGER(name) \
-  static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name);
-
-#define _LOG_DEBUG(x) \
-  LOG4CXX_DEBUG(staticModuleLogger, x);
-
-#define _LOG_TRACE(x) \
-  LOG4CXX_TRACE(staticModuleLogger, x);
-
-#define _LOG_FUNCTION(x) \
-  LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")");
-
-#define _LOG_FUNCTION_NOARGS \
-  LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()");
-
-#define _LOG_ERROR(x) \
-  LOG4CXX_ERROR(staticModuleLogger, x);
-
-#define _LOG_ERROR_COND(cond,x) \
-  if (cond) { _LOG_ERROR(x) }
-
-#define _LOG_DEBUG_COND(cond,x) \
-  if (cond) { _LOG_DEBUG(x) }
-
-void
-INIT_LOGGERS ();
-
-#else // else HAVE_LOG4CXX
-
-#define INIT_LOGGER(name)
-#define _LOG_FUNCTION(x)
-#define _LOG_FUNCTION_NOARGS
-#define _LOG_TRACE(x)
-#define INIT_LOGGERS(x)
-#define _LOG_ERROR(x)
-#define _LOG_ERROR_COND(cond,x)
-#define _LOG_DEBUG_COND(cond,x)
-
-#define MEMBER_LOGGER
-#define INIT_MEMBER_LOGGER(className,name)
-
-#ifdef _DEBUG
-
-#include <boost/thread/thread.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <iostream>
-
-#define _LOG_DEBUG(x) \
-  std::clog << boost::get_system_time () << " " << boost::this_thread::get_id () << " " << x << std::endl;
-
-#else
-#define _LOG_DEBUG(x)
-#endif
-
-#endif // HAVE_LOG4CXX
-
-#endif // LOGGING_H
diff --git a/ndn-cpp.h b/ndn-cpp.h
deleted file mode 100644
index 72a1db9..0000000
--- a/ndn-cpp.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_CXX_ALL_H
-#define NDN_CXX_ALL_H
-
-#include <ndn.cxx/common.h>
-#include <ndn.cxx/wrapper.h>
-
-#include <ndn.cxx/interest.h>
-#include <ndn.cxx/pco.h>
-
-#include <ndn.cxx/closure.h>
-
-// #include <ndn.cxx/cert.h>
-// #include <ndn.cxx/charbuf.h>
-// #include <ndn.cxx/discovery.h>
-// #include <ndn.cxx/verifier.h>
-
-#endif
diff --git a/ndn-cpp/error.h b/ndn-cpp/error.h
deleted file mode 100644
index d6379c6..0000000
--- a/ndn-cpp/error.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-/**
- * @file error.h
- * @brief This file defines basic elements for the library reporting
- *
- * The library throws a number of exceptions.
- * In general, the following example shows how to print out diagnostic information
- * when one of the exceptions is thrown
- * @code
- *     try
- *       {
- *         ... operations with ndn::Name
- *       }
- *     catch (boost::exception &e)
- *       {
- *         std::cerr << boost::diagnostic_information (e) << std::endl;
- *       }
- * @endcode
- */
-
-#ifndef NDN_ERROR_H
-#define NDN_ERROR_H
-
-#include <boost/exception/all.hpp>
-
-namespace ndn
-{
-namespace error
-{
-
-struct Error           : public virtual boost::exception, public virtual std::exception {}; ///< @brief Some error with error reporting engine
-struct Uri             : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with URI processing
-struct StringTransform : public virtual boost::exception, public virtual std::exception {};
-struct Name            : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with Name
-namespace name {
-struct Component       : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with name::Component
-}
-struct Exclude         : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with Exclude
-struct KeyLocator      : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with KeyLocator
-namespace wire {
-struct Ccnb            : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with wire::Ccnb encoding
-}
-struct Keychain        : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with security::Keychain
-
-// Diagnostic information fields
-
-/**
- * @brief Free-formatted text message explaining the error
- *
- * @code
- * ...
- * catch (boost::exception &e)
- * {
- *     if (const std::string *error = boost::get_error_info<error::msg> (e))
- *          ...
- * }
- * @endcode
- *
- * @see get_msg
- */
-typedef boost::error_info<struct tag_msg, std::string> msg;
-
-/**
- * @brief Helper method to get error message from the exception
- *
- * Method assumes that message is present, if not, an exception will be thrown
- */
-inline const std::string &
-get_msg (boost::exception &e)
-{
-  const std::string *error = boost::get_error_info<msg> (e);
-  if (error == 0)
-    BOOST_THROW_EXCEPTION (Error ());
-  return *error;
-}
-
-/**
- * @brief Report of the position of the error (error-specific meaning)
- *
- * @code
- * ...
- * catch (boost::exception &e)
- * {
- *     if (const int *error = boost::get_error_info<error::pos> (e))
- *          ...
- * }
- * @endcode
- *
- * @see get_pos
- */
-typedef boost::error_info<struct tag_pos, int> pos;
-
-/**
- * @brief Helper method to get position of the error from the exception
- *
- * Method assumes that position is present, if not, an exception will be thrown
- */
-inline int
-get_pos (boost::exception &e)
-{
-  const int *position = boost::get_error_info<pos> (e);
-  if (position == 0)
-    BOOST_THROW_EXCEPTION (Error ());
-  return *position;
-}
-
-} // error
-} // ndn
-
-#endif // NDN_ERROR_H
diff --git a/ndn-cpp/face.cc b/ndn-cpp/face.cc
deleted file mode 100644
index 455f283..0000000
--- a/ndn-cpp/face.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "face.h"
-
-namespace ndn {
-
-Face::sent_interest
-Face::sendInterest (Ptr<const Interest> interest, const SatisfiedInterestCallback &dataCallback)
-{
-  // magic to be done in child class
-
-  sent_interest item = m_sentInterests.find_exact (interest->getName ());
-  if (item == m_sentInterests.end ())
-    {
-      std::pair<sent_interest, bool> insertRes =
-        m_sentInterests.insert (interest->getName (), Ptr<sent_interest_container::payload_traits::payload_type>::Create ());
-
-      item = insertRes.first;
-    }
-  item->payload ()->push_back (dataCallback);
-
-  return item;
-}
-
-void
-Face::clearInterest (Face::sent_interest interest)
-{
-  m_sentInterests.erase (interest);
-}
-  
-Face::registered_prefix
-Face::setInterestFilter (Ptr<const Name> prefix, const ExpectedInterestCallback &interestCallback)
-{
-  // magic to be done in child class
-  
-  registered_prefix item = m_registeredPrefixes.find_exact (*prefix);
-  if (item == m_registeredPrefixes.end ())
-    {
-      std::pair<registered_prefix, bool> insertRes =
-        m_registeredPrefixes.insert (*prefix, Ptr<registered_prefix_container::payload_traits::payload_type>::Create ());
-
-      item = insertRes.first;
-    }
-  item->payload ()->push_back (interestCallback);
-
-  return item;
-}
-
-void
-Face::clearInterestFilter (const Name &prefix)
-{
-  registered_prefix item = m_registeredPrefixes.find_exact (prefix);
-  if (item == m_registeredPrefixes.end ())
-    return;
-
-  clearInterestFilter (item);
-}
-
-void
-Face::clearInterestFilter (Face::registered_prefix filter)
-{
-  m_registeredPrefixes.erase (filter);
-}
-
-} // ndn
-
-// void
-// CcnxWrapper::OnInterest (const Ptr<const ndn::Interest> &interest, Ptr<Packet> packet)
-// {
-//   ndn::App::OnInterest (interest, packet);
-
-//   // the app cannot set several filters for the same prefix
-//   CcnxFilterEntryContainer<InterestCallback>::iterator entry = m_interestCallbacks.longest_prefix_match (interest->GetName ());
-//   if (entry == m_interestCallbacks.end ())
-//     {
-//       _LOG_DEBUG ("No Interest callback set");
-//       return;
-//     }
-  
-//   entry->payload ()->m_callback (lexical_cast<string> (interest->GetName ()));  
-// }
-
-// void
-// CcnxWrapper::OnContentObject (const Ptr<const ndn::ContentObject> &contentObject,
-//                               Ptr<Packet> payload)
-// {
-//   ndn::App::OnContentObject (contentObject, payload);
-//   NS_LOG_DEBUG ("<< D " << contentObject->GetName ());
-
-//   CcnxFilterEntryContainer<RawDataCallback>::iterator entry = m_dataCallbacks.longest_prefix_match (contentObject->GetName ());
-//   if (entry == m_dataCallbacks.end ())
-//     {
-//       _LOG_DEBUG ("No Data callback set");
-//       return;
-//     }
-
-//   while (entry != m_dataCallbacks.end ())
-//     {
-//       ostringstream content;
-//       payload->CopyData (&content, payload->GetSize ());
-  
-//       entry->payload ()->m_callback (lexical_cast<string> (contentObject->GetName ()), content.str ().c_str (), content.str ().size ());
-  
-//       m_dataCallbacks.erase (entry);
-
-//       entry = m_dataCallbacks.longest_prefix_match (contentObject->GetName ());
-//     }
-// }
-
-// }
diff --git a/ndn-cpp/face.h b/ndn-cpp/face.h
deleted file mode 100644
index 38a618c..0000000
--- a/ndn-cpp/face.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_CXX_H
-#define NDN_CXX_H
-
-#include "ndn-cpp/common.h"
-#include "ndn-cpp/fields/name.h"
-#include "ndn-cpp/interest.h"
-#include "ndn-cpp/data.h"
-
-#include "trie/trie-with-policy.h"
-#include "trie/policies/counting-policy.h"
-
-#include <list>
-
-namespace ndn {
-
-template<class Callback>
-struct CallbackTable :
-    public trie::trie_with_policy< Name,
-                                   trie::ptr_payload_traits< std::list<Callback> >,
-                                   trie::counting_policy_traits >
-{
-};
-
-
-class Face
-{
-public:
-  typedef boost::function<void (Ptr<Data> incomingData, Ptr<const Interest> satisfiedInterest)> SatisfiedInterestCallback;
-  typedef boost::function<void (Ptr<Interest> incomingInterest, Ptr<const Name> registeredPrefix)> ExpectedInterestCallback;
-
-  // some internal definitions
-  typedef CallbackTable< SatisfiedInterestCallback > sent_interest_container;
-  typedef CallbackTable< ExpectedInterestCallback >  registered_prefix_container;
-
-  typedef sent_interest_container::iterator sent_interest;
-  typedef registered_prefix_container::iterator registered_prefix;
-  
-  sent_interest
-  sendInterest (Ptr<const Interest> interest, const SatisfiedInterestCallback &dataCallback);
-
-  void
-  clearInterest (sent_interest interest);
-  
-  registered_prefix
-  setInterestFilter (Ptr<const Name> prefix, const ExpectedInterestCallback &interestCallback);
-
-  void
-  clearInterestFilter (const Name &prefix);
-
-  void
-  clearInterestFilter (registered_prefix filter);
-  
-private:
-  sent_interest_container m_sentInterests;
-  registered_prefix_container m_registeredPrefixes;
-};
-
-} // ndn
-
-#endif // NDN_CXX_H
diff --git a/ndn-cpp/fields/blob.h b/ndn-cpp/fields/blob.h
deleted file mode 100644
index d81d039..0000000
--- a/ndn-cpp/fields/blob.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_BLOB_H
-#define NDN_BLOB_H
-
-#include <vector>
-#include <cstddef>
-#include <boost/shared_ptr.hpp>
-
-namespace ndn {
-
-/**
- * @brief Class representing a general-use binary blob
- */
-class Blob : public std::vector<char>
-{
-public:
-  /**
-   * @brief Creates an empty blob
-   */
-  Blob ()
-  {
-  }
-
-  Blob (const void *buf, size_t length)
-    : std::vector<char> (reinterpret_cast<const char*> (buf), reinterpret_cast<const char*> (buf) + length)
-  {
-  }
-  
-  /**
-   * @brief Get pointer to the first byte of the binary blob
-   */
-  inline char*
-  buf ()
-  {
-    return &front ();
-  }
-
-  /**
-   * @brief Get const pointer to the first byte of the binary blob
-   */
-  inline const char*
-  buf () const
-  {
-    return &front ();
-  }
-};
-
-} // ndn
-
-#endif // NDN_BLOB_H
diff --git a/ndn-cpp/fields/content.cc b/ndn-cpp/fields/content.cc
deleted file mode 100644
index 0216bd2..0000000
--- a/ndn-cpp/fields/content.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "content.h"
-#include "ndn-cpp/error.h"
-
-namespace ndn
-{
-
-const name::Component Content::noFinalBlock = name::Component ();
-const TimeInterval Content::noFreshness;
-const TimeInterval Content::maxFreshness = time::Seconds (2147);
-
-Content::Content ()
-{
-}
-
-Content::Content (const void *buffer, size_t size,
-                  const Time &timestamp,
-                  Type type/* = DATA*/,
-                  const TimeInterval &freshness/* = maxFreshness*/,
-                  const name::Component &finalBlock/* = noFinalBlock*/)
-  : m_timestamp (timestamp)
-  , m_type (type)
-  , m_freshness (freshness)
-  , m_finalBlockId (finalBlock)
-
-  , m_content (buffer, size)
-{
-}
-
-Content::Content (const void *buffer, size_t size,
-                  Type type/* = DATA*/,
-                  const TimeInterval &freshness/* = maxFreshness*/,
-                  const name::Component &finalBlock/* = noFinalBlock*/)
-  : m_timestamp (time::Now ())
-  , m_type (type)
-  , m_freshness (freshness)
-  , m_finalBlockId (finalBlock)
-
-  , m_content (buffer, size)
-{
-}
-
-
-} // ndn
diff --git a/ndn-cpp/fields/content.h b/ndn-cpp/fields/content.h
deleted file mode 100644
index 752f24c..0000000
--- a/ndn-cpp/fields/content.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_CONTENT_H
-#define NDN_CONTENT_H
-
-#include "ndn-cpp/common.h"
-#include "ndn-cpp/fields/blob.h"
-#include "ndn-cpp/fields/name-component.h"
-
-namespace ndn {
-
-/**
- * @brief Class providing an interface to work with content NDN data packets
- *
- * Content of data packets consists of two parts: information about content
- * (timestamp, freshness, type, etc.) and raw content itself
- *
- * @code
- * Content ::= ContentInfo
- *             ContentData
- *
- * ContentInfo ::= Timestamp
- *                 Type?
- *                 Freshness?
- *                 FinalBlockID?
- * @endcode
- */
-class Content
-{
-public:
-  /**
-   * @brief Enum of content types
-   */
-  enum Type
-    {
-      DATA = 0, ///< @brief No semantics is defined for the content
-      ENCR,     ///< @brief Indicate that the content is encrypted
-      GONE,     ///< @brief ?
-      KEY,      ///< @brief Content is a key object
-      LINK,     ///< @brief Content contains a LINK object
-      NACK      ///< @brief Negative acknowledgment by the content producer, indicating that there is no data with the requested name
-    };
-
-  /**
-   * @brief Create an empty content
-   */
-  Content ();
-
-  /**
-   * @brief Create a content from a memory buffer
-   * @param buffer pointer to first byte of the memory buffer
-   * @param size size of the memory buffer
-   * @param timestamp content generation timestamp
-   * @param type type of content (default is Content::DATA)
-   * @param freshness amount of time the content is considered "fresh" (default is 2147 seconds, maximum possible value for CCNx)
-   * @param finalBlock name of the final DATA
-   *
-   * Use the other version of the constructor, if timestamp needs to be automatically generated
-   */
-  Content (const void *buffer, size_t size,
-           const Time &timestamp,
-           Type type = DATA,
-           const TimeInterval &freshness = maxFreshness,
-           const name::Component &finalBlock = noFinalBlock);
-
-  /**
-   * @brief Create a content from a memory buffer
-   * @param buffer pointer to first byte of the memory buffer
-   * @param size size of the memory buffer
-   * @param type type of content (default is Content::DATA)
-   * @param freshness amount of time the content is considered "fresh" (default is 2147 seconds, maximum possible value for CCNx)
-   * @param finalBlock name of the final DATA
-   *
-   * This method automatically sets timestamp of the created content to the current time (UTC clock)
-   */
-  Content (const void *buffer, size_t size,
-           Type type = DATA,
-           const TimeInterval &freshness = maxFreshness,
-           const name::Component &finalBlock = noFinalBlock);
-
-  /**
-   * @brief Get content timestamp (const reference)
-   */
-  inline const Time &
-  getTimestamp () const;
-
-  /**
-   * @brief Get content timestamp (reference)
-   */
-  inline Time &
-  getTimestamp ();
-
-  /**
-   * @brief Set content timestamp
-   * @param timestamp content timestamp (default is empty ptime object)
-   *
-   * If parameter is omitted, then the current time (UTC clock) is used
-   */
-  inline void
-  setTimeStamp (const Time &timestamp = Time ());
-
-  /**
-   * @brief Get type of content
-   */
-  inline Type
-  getType () const;
-
-  /**
-   * @brief Set type of content
-   * @param type content type @see Content::Type
-   */
-  inline void
-  setType (Type type);
-
-  /**
-   * @brief Get content freshness (const reference)
-   */
-  inline const TimeInterval &
-  getFreshness () const;
-
-  /**
-   * @brief Get content freshness (reference)
-   */
-  inline TimeInterval &
-  getFreshness ();
-
-  /**
-   * @brief Set content freshness
-   * @param freshness content freshness (default value is Content::maxFreshness = 2147 seconds)
-   */
-  inline void
-  setFreshness (const TimeInterval &freshness = maxFreshness);
-
-  /**
-   * @brief Get final block ID of the content (const reference)
-   */
-  inline const name::Component &
-  getFinalBlockId () const;
-
-  /**
-   * @brief Get final block ID of the content (reference)
-   */
-  inline name::Component &
-  getFinalBlockId ();
-
-  /**
-   * @brief Set final block ID of the content
-   * @param finalBlock component name of the final block
-   */
-  inline void
-  setFinalBlockId (const name::Component &finalBlock);
-
-  /**
-   * @brief Get const reference to content bits
-   */
-  inline const Blob &
-  getContent () const;
-
-  /**
-   * @brief Get reference to content bits
-   */
-  inline Blob &
-  getContent ();
-
-  /**
-   * @brief Set content bits from blob
-   * @param content blob that holds content bits
-   *
-   * In certain cases, getContent ().swap (content); is more appropriate,
-   * since it would avoid object copying
-   */
-  inline void
-  setContent (const Blob &content);
-
-  /**
-   * @brief Set content bits from memory buffer
-   * @param buf pointer to first byte of memory buffer
-   * @param length size of memory buffer
-   */
-  inline void
-  setContent (const void *buf, size_t length);
-
-public:
-  static const name::Component noFinalBlock; ///< @brief Not a final block == name::Component ()
-  static const TimeInterval noFreshness; ///< @brief Minimum freshness == seconds (0)
-  static const TimeInterval maxFreshness; ///< @brief Maximum freshnes == seconds (2147)
-
-private:
-  // ContentInfo
-  Time m_timestamp;
-  Type m_type;
-  TimeInterval m_freshness;
-  name::Component m_finalBlockId;
-
-  // ContentData
-  Blob m_content;
-};
-
-inline const Time &
-Content::getTimestamp () const
-{
-  return m_timestamp;
-}
-
-inline Time &
-Content::getTimestamp ()
-{
-  return m_timestamp;
-}
-
-inline void
-Content::setTimeStamp (const Time &timestamp/* = Time ()*/)
-{
-  if (timestamp != Time ())
-    {
-      m_timestamp = timestamp;
-    }
-  else
-    {
-      m_timestamp = time::Now ();
-    }
-}
-
-inline Content::Type
-Content::getType () const
-{
-  return m_type;
-}
-
-inline void
-Content::setType (Content::Type type)
-{
-  m_type = type;
-}
-
-inline const TimeInterval &
-Content::getFreshness () const
-{
-  return m_freshness;
-}
-
-inline TimeInterval &
-Content::getFreshness ()
-{
-  return m_freshness;
-}
-
-inline void
-Content::setFreshness (const TimeInterval &freshness/* = Content::maxFreshness*/)
-{
-  m_freshness = freshness;
-}
-
-inline const name::Component &
-Content::getFinalBlockId () const
-{
-  return m_finalBlockId;
-}
-
-inline name::Component &
-Content::getFinalBlockId ()
-{
-  return m_finalBlockId;
-}
-
-inline void
-Content::setFinalBlockId (const name::Component &finalBlock)
-{
-  m_finalBlockId = finalBlock;
-}
-
-inline const Blob &
-Content::getContent () const
-{
-  return m_content;
-}
-
-inline Blob &
-Content::getContent ()
-{
-  return m_content;
-}
-
-inline void
-Content::setContent (const Blob &content)
-{
-  m_content = content;
-}
-
-inline void
-Content::setContent (const void *buf, size_t length)
-{
-  Blob (buf, length).swap (m_content);
-}
-
-} // ndn
-
-#endif // NDN_SIGNATURE_H
diff --git a/ndn-cpp/fields/exclude.cc b/ndn-cpp/fields/exclude.cc
deleted file mode 100644
index b637c01..0000000
--- a/ndn-cpp/fields/exclude.cc
+++ /dev/null
@@ -1,168 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "exclude.h"
-
-#include "ndn-cpp/error.h"
-
-namespace ndn
-{
-
-Exclude::Exclude ()
-{
-}
-
-// example: ANY /b /d ANY /f
-//
-// ordered in map as:
-//
-// /f (false); /d (true); /b (false); / (true)
-//
-// lower_bound (/)  -> / (true) <-- excluded (equal)
-// lower_bound (/a) -> / (true) <-- excluded (any)
-// lower_bound (/b) -> /b (false) <--- excluded (equal)
-// lower_bound (/c) -> /b (false) <--- not excluded (not equal and no ANY)
-// lower_bound (/d) -> /d (true) <- excluded
-// lower_bound (/e) -> /d (true) <- excluded
-bool
-Exclude::isExcluded (const name::Component &comp) const
-{
-  const_iterator lowerBound = m_exclude.lower_bound (comp);
-  if (lowerBound == end ())
-    return false;
-
-  if (lowerBound->second)
-    return true;
-  else
-    return lowerBound->first == comp;
-
-  return false;
-}
-
-Exclude &
-Exclude::excludeOne (const name::Component &comp)
-{
-  if (!isExcluded (comp))
-    {
-      m_exclude.insert (std::make_pair (comp, false));
-    }
-  return *this;
-}
-
-
-// example: ANY /b0 /d0 ANY /f0
-//
-// ordered in map as:
-//
-// /f0 (false); /d0 (true); /b0 (false); / (true)
-//
-// lower_bound (/)  -> / (true) <-- excluded (equal)
-// lower_bound (/a0) -> / (true) <-- excluded (any)
-// lower_bound (/b0) -> /b0 (false) <--- excluded (equal)
-// lower_bound (/c0) -> /b0 (false) <--- not excluded (not equal and no ANY)
-// lower_bound (/d0) -> /d0 (true) <- excluded
-// lower_bound (/e0) -> /d0 (true) <- excluded
-
-
-// examples with desired outcomes
-// excludeRange (/, /f0) ->  ANY /f0
-//                          /f0 (false); / (true)
-// excludeRange (/, /f1) ->  ANY /f1
-//                          /f1 (false); / (true)
-// excludeRange (/a0, /e0) ->  ANY /f0
-//                          /f0 (false); / (true)
-// excludeRange (/a0, /e0) ->  ANY /f0
-//                          /f0 (false); / (true)
-
-// excludeRange (/b1, /c0) ->  ANY /b0 /b1 ANY /c0 /d0 ANY /f0
-//                          /f0 (false); /d0 (true); /c0 (false); /b1 (true); /b0 (false); / (true)
-
-Exclude &
-Exclude::excludeRange (const name::Component &from, const name::Component &to)
-{
-  if (from >= to)
-    {
-      BOOST_THROW_EXCEPTION (error::Exclude ()
-                             << error::msg ("Invalid exclude range (for single name exclude use Exclude::excludeOne)")
-                             << error::msg (from.toUri ())
-                             << error::msg (to.toUri ()));
-    }
-
-  iterator newFrom = m_exclude.lower_bound (from);
-  if (newFrom == end () || !newFrom->second /*without ANY*/)
-    {
-      std::pair<iterator, bool> fromResult = m_exclude.insert (std::make_pair (from, true));
-      newFrom = fromResult.first;
-      if (!fromResult.second)
-        {
-          // this means that the lower bound is equal to the item itself. So, just update ANY flag
-          newFrom->second = true;
-        }
-    }
-  // else
-  // nothing special if start of the range already exists with ANY flag set
-
-  iterator newTo = m_exclude.lower_bound (to); // !newTo cannot be end ()
-  if (newTo == newFrom || !newTo->second)
-    {
-      std::pair<iterator, bool> toResult = m_exclude.insert (std::make_pair (to, false));
-      newTo = toResult.first;
-      ++ newTo;
-    }
-  else
-    {
-      // nothing to do really
-    }
-
-  m_exclude.erase (newTo, newFrom); // remove any intermediate node, since all of the are excluded
-
-  return *this;
-}
-
-Exclude &
-Exclude::excludeAfter (const name::Component &from)
-{
-  iterator newFrom = m_exclude.lower_bound (from);
-  if (newFrom == end () || !newFrom->second /*without ANY*/)
-    {
-      std::pair<iterator, bool> fromResult = m_exclude.insert (std::make_pair (from, true));
-      newFrom = fromResult.first;
-      if (!fromResult.second)
-        {
-          // this means that the lower bound is equal to the item itself. So, just update ANY flag
-          newFrom->second = true;
-        }
-    }
-  // else
-  // nothing special if start of the range already exists with ANY flag set
-
-  if (newFrom != m_exclude.begin ())
-    {
-      m_exclude.erase (m_exclude.begin (), newFrom); // remove any intermediate node, since all of the are excluded
-    }
-
-  return *this;
-}
-
-
-std::ostream&
-operator << (std::ostream &os, const Exclude &exclude)
-{
-  for (Exclude::const_reverse_iterator i = exclude.rbegin (); i != exclude.rend (); i++)
-    {
-      os << i->first.toUri () << " ";
-      if (i->second)
-        os << "----> ";
-    }
-  return os;
-}
-
-
-} // ndn
diff --git a/ndn-cpp/fields/exclude.h b/ndn-cpp/fields/exclude.h
deleted file mode 100644
index 265a809..0000000
--- a/ndn-cpp/fields/exclude.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_EXCLUDE_H
-#define NDN_EXCLUDE_H
-
-#include "ndn-cpp/fields/name-component.h"
-
-#include <map>
-
-namespace ndn {
-
-/**
- * @brief Class to represent Exclude component in NDN interests
- */
-class Exclude
-{
-public:
-  typedef std::map< name::Component, bool /*any*/, std::greater<name::Component> > exclude_type;
-
-  typedef exclude_type::iterator iterator;
-  typedef exclude_type::const_iterator const_iterator;
-  typedef exclude_type::reverse_iterator reverse_iterator;
-  typedef exclude_type::const_reverse_iterator const_reverse_iterator;
-
-  /**
-   * @brief Default constructor an empty exclude
-   */
-  Exclude ();
-
-  /**
-   * @brief Check if name component is excluded
-   * @param comp Name component to check against exclude filter
-   */
-  bool
-  isExcluded (const name::Component &comp) const;
-
-  /**
-   * @brief Exclude specific name component
-   * @param comp component to exclude
-   * @returns *this to allow chaining
-   */
-  Exclude &
-  excludeOne (const name::Component &comp);
-
-  /**
-   * @brief Exclude components from range [from, to]
-   * @param from first element of the range
-   * @param to last element of the range
-   * @returns *this to allow chaining
-   */
-  Exclude &
-  excludeRange (const name::Component &from, const name::Component &to);
-
-  /**
-   * @brief Exclude all components from range [/, to]
-   * @param to last element of the range
-   * @returns *this to allow chaining
-   */
-  inline Exclude &
-  excludeBefore (const name::Component &to);
-
-  /**
-   * @brief Exclude all components from range [from, +Inf]
-   * @param to last element of the range
-   * @returns *this to allow chaining
-   */
-  Exclude &
-  excludeAfter (const name::Component &from);
-
-  /**
-   * @brief Method to directly append exclude element
-   * @param name excluded name component
-   * @param any  flag indicating if there is a postfix ANY component after the name
-   *
-   * This method is used during conversion from wire format of exclude filter
-   *
-   * If there is an error with ranges (e.g., order of components is wrong) an exception is thrown
-   */
-  void
-  appendExclude (const name::Component &name, bool any);
-
-  /**
-   * @brief Get number of exclude terms
-   */
-  inline size_t
-  size () const;
-
-  /**
-   * @brief Get begin iterator of the exclude terms
-   */
-  inline const_iterator
-  begin () const;
-
-  /**
-   * @brief Get end iterator of the exclude terms
-   */
-  inline const_iterator
-  end () const;
-
-  /**
-   * @brief Get begin iterator of the exclude terms
-   */
-  inline const_reverse_iterator
-  rbegin () const;
-
-  /**
-   * @brief Get end iterator of the exclude terms
-   */
-  inline const_reverse_iterator
-  rend () const;
-
-private:
-  Exclude &
-  excludeRange (iterator fromLowerBound, iterator toLowerBound);
-
-private:
-  exclude_type m_exclude;
-};
-
-std::ostream&
-operator << (std::ostream &os, const Exclude &name);
-
-inline Exclude &
-Exclude::excludeBefore (const name::Component &to)
-{
-  return excludeRange (name::Component (), to);
-}
-
-inline size_t
-Exclude::size () const
-{
-  return m_exclude.size ();
-}
-
-inline Exclude::const_iterator
-Exclude::begin () const
-{
-  return m_exclude.begin ();
-}
-
-inline Exclude::const_iterator
-Exclude::end () const
-{
-  return m_exclude.end ();
-}
-
-inline Exclude::const_reverse_iterator
-Exclude::rbegin () const
-{
-  return m_exclude.rbegin ();
-}
-
-inline Exclude::const_reverse_iterator
-Exclude::rend () const
-{
-  return m_exclude.rend ();
-}
-
-} // ndn
-
-#endif // NDN_EXCLUDE_H
diff --git a/ndn-cpp/fields/key-locator.cc b/ndn-cpp/fields/key-locator.cc
deleted file mode 100644
index 84fd60c..0000000
--- a/ndn-cpp/fields/key-locator.cc
+++ /dev/null
@@ -1,200 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "key-locator.h"
-#include "ndn-cpp/error.h"
-
-namespace ndn {
-
-KeyLocator::KeyLocator ()
-  : m_type (NOTSET)
-  , m_data (0)
-{
-}
-
-KeyLocator::KeyLocator (const KeyLocator &keyLocator)
-  : m_type (keyLocator.getType ())
-  , m_data (0)
-{
-  switch (m_type)
-    {
-    case NOTSET:
-      break;
-    case KEY:
-      m_data = new Blob (keyLocator.getKey ());
-      break;
-    case CERTIFICATE:
-      m_data = new Blob (keyLocator.getCertificate ());
-      break;
-    case KEYNAME:
-      m_data = new Name (keyLocator.getKeyName ());
-      break;
-    }
-}
-
-KeyLocator::~KeyLocator ()
-{
-  deleteData ();
-}
-
-KeyLocator &
-KeyLocator::operator = (const KeyLocator &keyLocator)
-{
-  if (this == &keyLocator)
-    return *this;
-
-  deleteData ();
-  m_type = keyLocator.getType ();
-  
-  switch (m_type)
-    {
-    case NOTSET:
-      break;
-    case KEY:
-      m_data = new Blob (keyLocator.getKey ());
-      break;
-    case CERTIFICATE:
-      m_data = new Blob (keyLocator.getCertificate ());
-      break;
-    case KEYNAME:
-      m_data = new Name (keyLocator.getKeyName ());
-      break;
-    }
-
-  return *this;
-}
-
-void
-KeyLocator::deleteData ()
-{
-  switch (m_type)
-    {
-    case NOTSET: // nothing to clean up
-      break;
-    case KEY:
-      delete reinterpret_cast<Blob*> (m_data);
-      break;
-    case CERTIFICATE:
-      delete reinterpret_cast<Blob*> (m_data);
-      break;
-    case KEYNAME:
-      delete reinterpret_cast<Name*> (m_data);
-      break;
-    }
-}
-
-void
-KeyLocator::setType (KeyLocator::Type type)
-{
-  if (m_type == type)
-    return;
-
-  deleteData ();
-  m_type = type;
-  
-  switch (m_type)
-    {
-    case NOTSET:
-      m_data = 0;
-    case KEY:
-      m_data = new Blob;
-      break;
-    case CERTIFICATE:
-      m_data = new Blob;
-      break;
-    case KEYNAME:
-      m_data = new Name;
-      break;
-    }
-}
-
-const Blob &
-KeyLocator::getKey () const
-{
-  if (m_type != KEY)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("getKey called, but KeyLocator is not of type KeyLocator::KEY"));
-  return *reinterpret_cast<const Blob*> (m_data);
-}
-
-Blob &
-KeyLocator::getKey ()
-{
-  if (m_type != KEY)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("getKey called, but KeyLocator is not of type KeyLocator::KEY"));
-  return *reinterpret_cast<Blob*> (m_data);
-}
-
-void
-KeyLocator::setKey (const Blob &key)
-{
-  if (m_type != KEY)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("setKey called, but KeyLocator is not of type KeyLocator::KEY"));
-  *reinterpret_cast<Blob*> (m_data) = key;
-}
-
-const Blob &
-KeyLocator::getCertificate () const
-{
-  if (m_type != CERTIFICATE)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("getCertificate called, but KeyLocator is not of type KeyLocator::CERTIFICATE"));
-  return *reinterpret_cast<const Blob*> (m_data);
-}
-
-Blob &
-KeyLocator::getCertificate ()
-{
-  if (m_type != CERTIFICATE)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("getCertificate called, but KeyLocator is not of type KeyLocator::CERTIFICATE"));
-  return *reinterpret_cast<Blob*> (m_data);
-}
-
-void
-KeyLocator::setCertificate (const Blob &certificate)
-{
-  if (m_type != CERTIFICATE)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("setCertificate called, but KeyLocator is not of type KeyLocator::CERTIFICATE"));
-  *reinterpret_cast<Blob*> (m_data) = certificate;
-}
-
-const Name &
-KeyLocator::getKeyName () const
-{
-  if (m_type != KEYNAME)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("getKeyName called, but KeyLocator is not of type KeyLocator::KEYNAME"));
-  return *reinterpret_cast<const Name*> (m_data);
-}
-
-Name &
-KeyLocator::getKeyName ()
-{
-  if (m_type != KEYNAME)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("getKeyName called, but KeyLocator is not of type KeyLocator::KEYNAME"));
-  return *reinterpret_cast<Name*> (m_data);
-}
-
-
-void
-KeyLocator::setKeyName (const Name &name)
-{
-  if (m_type != KEYNAME)
-    BOOST_THROW_EXCEPTION (error::KeyLocator ()
-                           << error::msg ("setKeyName called, but KeyLocator is not of type KeyLocator::KEYNAME"));
-  *reinterpret_cast<Name*> (m_data) = name;
-}
-
-}
diff --git a/ndn-cpp/fields/key-locator.h b/ndn-cpp/fields/key-locator.h
deleted file mode 100644
index cf1c6ea..0000000
--- a/ndn-cpp/fields/key-locator.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_KEY_LOCATOR_H
-#define NDN_KEY_LOCATOR_H
-
-#include "ndn-cpp/fields/blob.h"
-#include "ndn-cpp/fields/name.h"
-
-namespace ndn {
-
-/**
- * @brief Class providing an interface to work with key locators in NDN data packets
- */
-class KeyLocator
-{
-public:
-  /**
-   * @brief Key locator type
-   *
-   * Key locator can be only of the defined types, i.e., it cannot contain key bits and key name
-   */
-  enum Type
-    {
-      NOTSET=-1,   ///< @brief Unset key locator type, any attempt to use KeyLocator of NOTSET type will cause an exception
-      KEY,         ///< @brief Key locator contains key bits
-      CERTIFICATE, ///< @brief Key locator contains certificate bits
-      KEYNAME      ///< @brief key locator contains name of the key
-    };
-
-  /**
-   * @brief Default constructor
-   */
-  KeyLocator ();
-
-  /**
-   * @brief Copy constructor
-   */
-  KeyLocator (const KeyLocator &keyLocator);
-  
-  /**
-   * @brief Destructor
-   */
-  ~KeyLocator ();
-
-  /**
-   * @brief Copy operator
-   */
-  KeyLocator &
-  operator = (const KeyLocator &keyLocator);
-  
-  /**
-   * @brief Set type of the key locator
-   * @param type key locator type, @see Type
-   *
-   * If type of the key locator changes, setType will delete any previously allocated
-   * data, allocate appropriate type and store it in m_data
-   */
-  void
-  setType (Type type);
-
-  /**
-   * @brief Get type of the key locator
-   */
-  inline Type
-  getType () const;
-
-  /**
-   * @brief Get const reference to key bits, associated with key locator
-   *
-   * If key locator type is not KEY, then an exception will be thrown
-   */
-  const Blob &
-  getKey () const;
-
-  /**
-   * @brief Get reference to key bits, associated with key locator
-   *
-   * If key locator type is not KEY, then an exception will be thrown
-   */
-  Blob &
-  getKey ();
-
-  /**
-   * @brief Set key bits, associated with key locator
-   * @param key const reference to key bits
-   *
-   * If key locator type is not KEY, then an exception will be thrown
-   */
-  void
-  setKey (const Blob &key);
-
-  /**
-   * @brief Get const reference to certificated bits, associated with key locator
-   *
-   * If key locator type is not CERTIFICATE, then an exception will be thrown
-   */
-  const Blob &
-  getCertificate () const;
-
-  /**
-   * @brief Get reference to certificated bits, associated with key locator
-   *
-   * If key locator type is not CERTIFICATE, then an exception will be thrown
-   */
-  Blob &
-  getCertificate ();
-
-  /**
-   * @brief Set certificated bits, associated with key locator
-   * @param certificate const reference to certificate bits
-   *
-   * If key locator type is not CERTIFICATE, then an exception will be thrown
-   */
-  void
-  setCertificate (const Blob &certificate);
-
-  /**
-   * @brief Get const reference to key name, associated with key locator
-   *
-   * If key locator type is not KEYNAME, then an exception will be thrown
-   */
-  const Name &
-  getKeyName () const;
-
-  /**
-   * @brief Get reference to key name, associated with key locator
-   *
-   * If key locator type is not KEYNAME, then an exception will be thrown
-   */
-  Name &
-  getKeyName ();
-
-  /**
-   * @brief Set key name, associated with key locator
-   * @param name const reference to key name
-   *
-   * If key locator type is not KEYNAME, then an exception will be thrown
-   */
-  void
-  setKeyName (const Name &name);
-
-private:
-  void
-  deleteData ();
-  
-private:
-  Type m_type;
-  void *m_data;
-};
-
-inline KeyLocator::Type
-KeyLocator::getType () const
-{
-  return m_type;
-}
-
-
-} // ndn
-
-#endif // NDN_KEY_LOCATOR_H
diff --git a/ndn-cpp/fields/signature-sha256-with-rsa.cc b/ndn-cpp/fields/signature-sha256-with-rsa.cc
deleted file mode 100644
index c9c89ed..0000000
--- a/ndn-cpp/fields/signature-sha256-with-rsa.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "signature-sha256-with-rsa.h"
-#include "../encoding/base.h"
-
-namespace ndn {
-namespace signature {
-
-const std::string Sha256WithRsa::s_oid = "2.16.840.1.101.3.4.2.1";
-
-Sha256WithRsa::~Sha256WithRsa ()
-{
-}
-
-void
-Sha256WithRsa::doubleDispatch (std::ostream &os, wire::Base &wire, void *userData) const
-{
-  wire.appendSignature (os, *this, userData);
-}
-
-} // signature
-} // ndn
diff --git a/ndn-cpp/fields/signature-sha256-with-rsa.h b/ndn-cpp/fields/signature-sha256-with-rsa.h
deleted file mode 100644
index be6766b..0000000
--- a/ndn-cpp/fields/signature-sha256-with-rsa.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_SIGNATURE_SHA256_WITH_RSA_H
-#define NDN_SIGNATURE_SHA256_WITH_RSA_H
-
-#include "signature.h"
-
-#include "ndn-cpp/fields/blob.h"
-#include "ndn-cpp/fields/key-locator.h"
-
-#include <string>
-
-namespace ndn {
-
-namespace signature {
-
-/**
- * @brief Class providing operations to work with SHA256withRSA (OID: "2.16.840.1.101.3.4.2.1")
- */
-class Sha256WithRsa : public virtual Signature
-{
-public:
-  /**
-   * @brief Virtual destructor
-   */
-  virtual
-  ~Sha256WithRsa ();
-
-  /**
-   * @brief Get OID of the signature algorithm
-   */
-  inline const std::string &
-  getDigestAlgorithm () const;
-
-  /**
-   * @brief Get reference to signature bits
-   */
-  inline Blob &
-  getSignatureBits ();
-
-  /**
-   * @brief Get const reference to signature bits
-   */
-  inline const Blob &
-  getSignatureBits () const;
-
-  /**
-   * @brief Set signature bits
-   */
-  inline void
-  setSignatureBits (const Blob &signatureBits);
-
-  /**
-   * @brief Get reference to publisher key digest bits
-   */
-  inline Blob &
-  getPublisherKeyDigest ();
-
-  /**
-   * @brief Get const reference to publisher key digest bits
-   */
-  inline const Blob &
-  getPublisherKeyDigest () const;
-
-  /**
-   * @brief Set publisher key digest bits
-   */
-  inline void
-  setPublisherKeyDigest (const Blob &publisherKeyDigest);
-
-  /**
-   * @brief Get reference to key locator object
-   */
-  inline KeyLocator &
-  getKeyLocator ();
-
-  /**
-   * @brief Get const reference to key locator object
-   */
-  inline const KeyLocator &
-  getKeyLocator () const;
-
-  /**
-   * @brief Set key locator object
-   */
-  inline void
-  setKeyLocator (const KeyLocator &keyLocator);
-
-  // from Signature
-  virtual void
-  doubleDispatch (std::ostream &os, wire::Base &wire, void *userData) const;
-
-private:
-  static const std::string s_oid;
-
-  Blob m_signatureBits;
-  Blob m_publisherKeyDigest;
-  KeyLocator m_keyLocator;
-};
-
-const std::string &
-Sha256WithRsa::getDigestAlgorithm () const
-{
-  return s_oid;
-}
-
-inline Blob &
-Sha256WithRsa::getSignatureBits ()
-{
-  return m_signatureBits;
-}
-
-inline const Blob &
-Sha256WithRsa::getSignatureBits () const
-{
-  return m_signatureBits;
-}
-
-inline void
-Sha256WithRsa::setSignatureBits (const Blob &signatureBits)
-{
-  m_signatureBits = signatureBits;
-}
-
-inline Blob &
-Sha256WithRsa::getPublisherKeyDigest ()
-{
-  return m_publisherKeyDigest;
-}
-
-inline const Blob &
-Sha256WithRsa::getPublisherKeyDigest () const
-{
-  return m_publisherKeyDigest;
-}
-
-inline void
-Sha256WithRsa::setPublisherKeyDigest (const Blob &publisherKeyDigest)
-{
-  m_publisherKeyDigest = publisherKeyDigest;
-}
-
-inline KeyLocator &
-Sha256WithRsa::getKeyLocator ()
-{
-  return m_keyLocator;
-}
-
-inline const KeyLocator &
-Sha256WithRsa::getKeyLocator () const
-{
-  return m_keyLocator;
-}
-
-inline void
-Sha256WithRsa::setKeyLocator (const KeyLocator &keyLocator)
-{
-  m_keyLocator = keyLocator;
-}
-
-} // signature
-} // ndn
-
-#endif // NDN_EXCLUDE_H
diff --git a/ndn-cpp/fields/signature.cc b/ndn-cpp/fields/signature.cc
deleted file mode 100644
index 4c7a3a5..0000000
--- a/ndn-cpp/fields/signature.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "signature.h"
-#include "ndn-cpp/error.h"
-
-namespace ndn
-{
-
-
-} // ndn
diff --git a/ndn-cpp/fields/signature.h b/ndn-cpp/fields/signature.h
deleted file mode 100644
index 65afc04..0000000
--- a/ndn-cpp/fields/signature.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_SIGNATURE_H
-#define NDN_SIGNATURE_H
-
-#include <iostream>
-#include <boost/shared_ptr.hpp>
-
-namespace ndn {
-
-namespace wire { class Base; }
-
-/**
- * @brief Pure virtual class providing an interface to work with signatures for NDN data packets
- */
-class Signature
-{
-public:
-  /**
-   * @brief Virtual destructor
-   */
-  virtual
-  ~Signature () { }
-
-  /**
-   * @brief A double dispatch pattern to call the right wireFormatter method to format signature
-   * @param os reference to output stream
-   * @param wireFormatter a reference to a wireFormatter object
-   * @param userData any user-specific data
-   */
-  virtual void
-  doubleDispatch (std::ostream &os, wire::Base &wireFormatter, void *userData) const = 0;
-};
-
-} // ndn
-
-#endif // NDN_SIGNATURE_H
diff --git a/ndn-cpp/fields/signed-blob.h b/ndn-cpp/fields/signed-blob.h
deleted file mode 100644
index b8cb39f..0000000
--- a/ndn-cpp/fields/signed-blob.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_SIGNED_BLOB_H
-#define NDN_SIGNED_BLOB_H
-
-#include "blob.h"
-
-namespace ndn {
-
-/**
- * @brief Class representing a blob, which has a signed portion (e.g., bytes of DATA packet)
- */
-class SignedBlob : public Blob
-{
-public:
-  /**
-   * @brief Set signed portion of the blob
-   * @param offset An offset from the beginning of the blob
-   * @param size Size of the signed portion of the blob
-   */
-  inline void
-  setSignedPortion (size_t offset, size_t size);
-  
-  /**
-   * @brief Get begin iterator to a signed portion of the blob
-   */
-  inline const_iterator
-  signed_begin () const;
-
-  /**
-   * @brief Get end iterator of a signed portion of the blob
-   */
-  inline const_iterator
-  signed_end () const;
-
-  /**
-   * @brief Get pointer to a first byte of the signed blob
-   */
-  inline const char*
-  signed_buf () const;
-
-  /**
-   * @brief Get size of the signed blob
-   */
-  inline size_t
-  signed_size () const;
-
-private:
-  const_iterator m_signedBegin;
-  const_iterator m_signedEnd;
-};
-
-
-inline void
-SignedBlob::setSignedPortion (size_t offset, size_t size)
-{
-  m_signedBegin = begin () + offset;
-  m_signedEnd = begin () + offset + size;
-}
-  
-inline SignedBlob::const_iterator
-SignedBlob::signed_begin () const
-{
-  return m_signedBegin;
-}
-
-inline SignedBlob::const_iterator
-SignedBlob::signed_end () const
-{
-  return m_signedEnd;
-}
-
-inline const char*
-SignedBlob::signed_buf () const
-{
-  return &*m_signedBegin;
-}
-
-inline size_t
-SignedBlob::signed_size () const
-{
-  return m_signedEnd - m_signedBegin;
-}
-
-} // ndn
-
-#endif // NDN_SIGNED_BLOB_H
diff --git a/ndn-cpp/helpers/hash.cc b/ndn-cpp/helpers/hash.cc
deleted file mode 100644
index aa98784..0000000
--- a/ndn-cpp/helpers/hash.cc
+++ /dev/null
@@ -1,130 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- *         Zhenkai Zhu <zhenkai@cs.ucla.edu>
- */
-
-#include "hash.h"
-#include "ndn-cpp/helpers/uri.h"
-
-#include <boost/lexical_cast.hpp>
-#include <openssl/evp.h>
-#include <fstream>
-
-using namespace boost;
-using namespace std;
-
-// Other options: VP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_sha256, EVP_dss, EVP_dss1, EVP_mdc2, EVP_ripemd160
-#define HASH_FUNCTION EVP_sha256
-
-namespace ndn
-{
-
-std::ostream &
-operator << (std::ostream &os, const Hash &hash)
-{
-  if (hash.m_length == 0)
-    return os;
-
-  ostreambuf_iterator<char> out_it (os); // ostream iterator
-  // need to encode to base64
-  copy (detail::string_from_binary (reinterpret_cast<const char*> (hash.m_buf)),
-        detail::string_from_binary (reinterpret_cast<const char*> (hash.m_buf+hash.m_length)),
-        out_it);
-
-  return os;
-}
-
-std::string
-Hash::shortHash () const
-{
-  return lexical_cast<string> (*this).substr (0, 10);
-}
-
-
-unsigned char Hash::_origin = 0;
-ptr_lib::shared_ptr<Hash> Hash::Origin(new Hash(&Hash::_origin, sizeof(unsigned char)));
-
-ptr_lib::shared_ptr<Hash>
-Hash::FromString (const std::string &hashInTextEncoding)
-{
-  ptr_lib::shared_ptr<Hash> retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
-
-  if (hashInTextEncoding.size () == 0)
-    {
-      return retval;
-    }
-
-  if (hashInTextEncoding.size () > EVP_MAX_MD_SIZE * 2)
-    {
-      cerr << "Input hash is too long. Returning an empty hash" << endl;
-      return retval;
-    }
-
-  retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
-
-  unsigned char *end = copy (detail::string_to_binary (hashInTextEncoding.begin ()),
-                             detail::string_to_binary (hashInTextEncoding.end ()),
-                             retval->m_buf);
-
-  retval->m_length = end - retval->m_buf;
-
-  return retval;
-}
-
-ptr_lib::shared_ptr<Hash>
-Hash::FromFileContent (const char *filename)
-{
-  ptr_lib::shared_ptr<Hash> retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
-  retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
-
-  EVP_MD_CTX *hash_context = EVP_MD_CTX_create ();
-  EVP_DigestInit_ex (hash_context, HASH_FUNCTION (), 0);
-
-  ifstream iff (filename, std::ios::in | std::ios::binary);
-  while (iff.good ())
-    {
-      char buf[1024];
-      iff.read (buf, 1024);
-      EVP_DigestUpdate (hash_context, buf, iff.gcount ());
-    }
-
-  retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
-
-  EVP_DigestFinal_ex (hash_context,
-                      retval->m_buf, &retval->m_length);
-
-  EVP_MD_CTX_destroy (hash_context);
-
-  return retval;
-}
-
-ptr_lib::shared_ptr<Hash>
-Hash::FromBytes (const ndn::Bytes &bytes)
-{
-  ptr_lib::shared_ptr<Hash> retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
-  retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
-
-  EVP_MD_CTX *hash_context = EVP_MD_CTX_create ();
-  EVP_DigestInit_ex (hash_context, HASH_FUNCTION (), 0);
-
-  // not sure whether it's bad to do so if bytes.size is huge
-  EVP_DigestUpdate(hash_context, ndn::head(bytes), bytes.size());
-
-  retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
-
-  EVP_DigestFinal_ex (hash_context,
-                      retval->m_buf, &retval->m_length);
-
-  EVP_MD_CTX_destroy (hash_context);
-
-  return retval;
-}
-
-} // ndn
diff --git a/ndn-cpp/helpers/hash.h b/ndn-cpp/helpers/hash.h
deleted file mode 100644
index b5d96aa..0000000
--- a/ndn-cpp/helpers/hash.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- *         Zhenkai Zhu <zhenkai@cs.ucla.edu>
- */
-
-#ifndef NDN_HASH_H
-#define NDN_HASH_H
-
-#include <string.h>
-#include <iostream>
-#include <boost/shared_ptr.hpp>
-#include <boost/exception/all.hpp>
-
-#include "ndn-cpp/common.h"
-
-namespace ndn
-{
-class Hash
-{
-public:
-  static unsigned char _origin;
-  static ptr_lib::shared_ptr<Hash> Origin;
-
-  Hash ()
-    : m_buf(0)
-    , m_length(0)
-  {
-  }
-
-  Hash (const void *buf, unsigned int length)
-    : m_length (length)
-  {
-    if (m_length != 0)
-      {
-        m_buf = new unsigned char [length];
-        memcpy (m_buf, buf, length);
-      }
-  }
-
-  Hash (const Hash &otherHash)
-  : m_length (otherHash.m_length)
-  {
-    if (m_length != 0)
-      {
-        m_buf = new unsigned char [m_length];
-        memcpy (m_buf, otherHash.m_buf, otherHash.m_length);
-      }
-  }
-
-  static ptr_lib::shared_ptr<Hash>
-  FromString (const std::string &hashInTextEncoding);
-
-  static ptr_lib::shared_ptr<Hash>
-  FromFileContent (const char *fileName);
-
-  static ptr_lib::shared_ptr<Hash>
-  FromBytes (const ndn::Bytes &bytes);
-
-  ~Hash ()
-  {
-    if (m_length != 0)
-      delete [] m_buf;
-  }
-
-  Hash &
-  operator = (const Hash &otherHash)
-  {
-    if (m_length != 0)
-      delete [] m_buf;
-
-    m_length = otherHash.m_length;
-    if (m_length != 0)
-      {
-        m_buf = new unsigned char [m_length];
-        memcpy (m_buf, otherHash.m_buf, otherHash.m_length);
-      }
-    return *this;
-  }
-
-  bool
-  IsZero () const
-  {
-    return m_length == 0 ||
-      (m_length == 1 && m_buf[0] == 0);
-  }
-
-  bool
-  operator == (const Hash &otherHash) const
-  {
-    if (m_length != otherHash.m_length)
-      return false;
-
-    return memcmp (m_buf, otherHash.m_buf, m_length) == 0;
-  }
-
-  bool operator < (const Hash &otherHash) const
-  {
-    if (m_length < otherHash.m_length)
-      return true;
-
-    if (m_length > otherHash.m_length)
-      return false;
-
-    for (unsigned int i = 0; i < m_length; i++)
-      {
-        if (m_buf [i] < otherHash.m_buf [i])
-          return true;
-
-        if (m_buf [i] > otherHash.m_buf [i])
-          return false;
-
-        // if equal, continue
-      }
-
-    return false;
-  }
-
-  const void *
-  GetHash () const
-  {
-    return m_buf;
-  }
-
-  unsigned int
-  GetHashBytes () const
-  {
-    return m_length;
-  }
-
-  std::string
-  shortHash () const;
-
-private:
-  unsigned char *m_buf;
-  unsigned int m_length;
-
-  friend std::ostream &
-  operator << (std::ostream &os, const Hash &digest);
-};
-
-namespace Error {
-struct HashConversion : virtual boost::exception, virtual std::exception { };
-}
-
-
-std::ostream &
-operator << (std::ostream &os, const Hash &digest);
-
-}
-
-#endif // NDN_HASH_H
diff --git a/ndn-cpp/helpers/uri.h b/ndn-cpp/helpers/uri.h
deleted file mode 100644
index 3fbda7c..0000000
--- a/ndn-cpp/helpers/uri.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_DETAIL_URI_H
-#define NDN_DETAIL_URI_H
-
-#include "ndn-cpp/error.h"
-
-#include <boost/archive/iterators/transform_width.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-
-namespace ndn
-{
-
-namespace detail
-{
-
-static const bool ESCAPE_CHARACTER [256] = {
-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 26
-  1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 53
-  0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 107
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, // 134
-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 161
-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 188
-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 215
-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 242
-  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 255
-};
-
-/// @cond include_hidden
-template<class CharType>
-struct hex_from_4_bit
-{
-  typedef CharType result_type;
-  CharType operator () (CharType ch) const
-  {
-    const char lookup_table [16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-    // cout << "New character: " << (int) ch << " (" << (char) ch << ")" << "\n";
-    BOOST_ASSERT (ch < 16);
-    return lookup_table[static_cast<size_t>(ch)];
-  }
-};
-
-typedef boost::transform_iterator<hex_from_4_bit<std::string::const_iterator::value_type>,
-                                  boost::archive::iterators::transform_width<std::string::const_iterator, 4, 8, std::string::const_iterator::value_type> > string_from_binary;
-
-
-
-template<class CharType>
-struct hex_to_4_bit
-{
-  typedef CharType result_type;
-  CharType operator () (CharType ch) const
-  {
-    const signed char lookup_table [] = {
-      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-      0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
-      -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-      -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
-    };
-
-    signed char value = -1;
-    if ((unsigned)ch < 128)
-      value = lookup_table [(unsigned)ch];
-    if (value == -1)
-      boost::throw_exception (error::StringTransform ());
-
-    return value;
-  }
-};
-
-typedef boost::archive::iterators::transform_width<boost::transform_iterator<hex_to_4_bit<std::string::const_iterator::value_type>, std::string::const_iterator>, 8, 4> string_to_binary;
-/// @endcond
-
-} // detail
-
-/**
- * @brief A helper class to convert to/from URI
- */
-class Uri
-{
-public:
-  template<class Iterator1, class Iterator2>
-  inline static void
-  fromEscaped (Iterator1 begin, Iterator1 end, Iterator2 inserter)
-  {
-    Iterator1 i = begin;
-    while (i != end)
-      {
-        if (*i == '%')
-          {
-            try
-              {
-                ++i;
-                Iterator1 j = i;
-                advance (i, 2);
-              
-                std::copy (detail::string_to_binary (j), detail::string_to_binary (i), inserter);
-              }
-            catch (ndn::error::StringTransform &e)
-              {
-                BOOST_THROW_EXCEPTION (error::Uri ()
-                                       << error::pos (std::distance (i, begin)));
-              }
-          }
-        else if (!detail::ESCAPE_CHARACTER[static_cast<unsigned char> (*i)])
-          {
-            *inserter = *i;
-            ++inserter; ++i;
-          }
-        else
-          {
-            BOOST_THROW_EXCEPTION (error::Uri ()
-                                   << error::pos (std::distance (i, begin)));
-          }
-      }
-  }
-
-  template<class Iterator1, class Iterator2>
-  inline static void
-  toEscaped (Iterator1 begin, Iterator1 end, Iterator2 inserter)
-  {
-    const char lookup_table [16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-    
-    for (Iterator1 i = begin; i != end; i++)
-      {
-        if (detail::ESCAPE_CHARACTER[static_cast<unsigned char> (*i)])
-          {
-            *inserter = '%';         ++inserter;
-            *inserter = lookup_table [(*i >> 4) & 0x0F]; ++inserter;
-            *inserter = lookup_table [(*i & 0x0F)];      ++inserter;
-          }
-        else
-          {
-            *inserter = *i; ++inserter;
-          }
-      }
-  }
-};
-
-} // ndn
-
-#endif // NDN_DETAIL_URI_H
diff --git a/platforms/osx/keychain-osx.h b/platforms/osx/keychain-osx.h
deleted file mode 100644
index 7399e05..0000000
--- a/platforms/osx/keychain-osx.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_KEYCHAIN_OSX_H
-#define NDN_KEYCHAIN_OSX_H
-
-#include "ndn.cxx/security/keychain.h"
-
-namespace ndn {
-namespace keychain {
-
-class OSX : public Keychain
-{
-public:
-  OSX ();
-
-  virtual
-  ~OSX ();
-
-  virtual void
-  generateKeyPair (const Name &keyName);
-
-  virtual void
-  deleteKeyPair (const Name &keyName);
-
-  virtual void
-  deletePublicKey (const Name &keyName);
-
-  virtual Ptr<Blob>
-  getPublicKey (const Name &publicKeyName);
-
-private:
-  void *m_private;
-};
-
-} // keychain
-} // ndn
-
-#endif // NDN_KEYCHAIN_OSX_H
diff --git a/platforms/osx/keychain-osx.mm b/platforms/osx/keychain-osx.mm
deleted file mode 100644
index 15b9a0d..0000000
--- a/platforms/osx/keychain-osx.mm
+++ /dev/null
@@ -1,245 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "keychain-osx.h"
-#include "ndn.cxx/error.h"
-#include "logging.h"
-
-#include <Foundation/Foundation.h>
-#include <AppKit/AppKit.h>
-#include <Security/Security.h>
-
-INIT_LOGGER ("Keychain.OSX");
-
-namespace ndn {
-
-namespace keychain {
-class OSX_Private
-{
-public:
-  static void
-  LogHumanError (OSStatus res, const std::string &errMsgStr)
-  {
-    CFStringRef errMsgPtr = SecCopyErrorMessageString (res, NULL);
-    char errMsg[1024];
-    CFStringGetCString (errMsgPtr, errMsg, 1024, kCFStringEncodingUTF8);
-    _LOG_DEBUG ("Open status: " << errMsg);
-
-    BOOST_THROW_EXCEPTION (error::Keychain ()
-                           << error::msg (errMsgStr)
-                           << error::msg (errMsg));
-  }
-
-  SecKeychainRef m_keychain;
-  SecKeychainRef m_origDefaultKeychain;
-  static const std::string s_keychainPath;
-};
-
-const std::string OSX_Private::s_keychainPath = "~/Library/Keychains/NDN.keychain";
-} // keychain
-
-
-
-keychain::OSX::OSX ()
-{
-  m_private = new OSX_Private ();
-  OSX_Private *self = reinterpret_cast<OSX_Private*> (m_private);
-
-  // AuthorizationRef authRef;
-  // AuthorizationItem right = { "system.keychain.modify", 0, NULL, 0 };
-  // AuthorizationRights rightSet = { 1, &right };
-
-  // /* Create authorization to access the system.keychain */
-  // OSStatus res1 = AuthorizationCreate(&rightSet, kAuthorizationEmptyEnvironment,
-  //                              kAuthorizationFlagExtendRights | kAuthorizationFlagInteractionAllowed, &authRef);
-  // _LOG_DEBUG ("Auth status: " << res1);
-
-  SecKeychainSetUserInteractionAllowed (true);
-
-  OSStatus res = SecKeychainCreate (OSX_Private::s_keychainPath.c_str (),
-                                    0, NULL, true, NULL,
-                                    &self->m_keychain);
-  _LOG_DEBUG ("Create status: " << res);
-
-  if (res == errSecDuplicateKeychain)
-    {
-      res = SecKeychainOpen (OSX_Private::s_keychainPath.c_str (),
-                             &self->m_keychain);
-      _LOG_DEBUG ("Open status: " << res);
-    }
-
-  if (res != errSecSuccess)
-    OSX_Private::LogHumanError (res, "Cannot open or create OSX Keychain");
-
-  // res = SecKeychainUnlock (self->m_keychain, 0, NULL, false);
-  // _LOG_DEBUG ("Unlock status: " << res);
-
-  SecKeychainCopyDefault (&self->m_origDefaultKeychain);
-  SecKeychainSetDefault (self->m_keychain);
-}
-
-keychain::OSX::~OSX ()
-{
-  OSX_Private *self = reinterpret_cast<OSX_Private*> (m_private);
-
-  SecKeychainSetDefault (self->m_origDefaultKeychain);
-
-  CFRelease (self->m_keychain);
-  CFRelease (self->m_origDefaultKeychain);
-  delete self;
-}
-
-void
-keychain::OSX::generateKeyPair (const Name &keyName)
-{
-  const void *	keys[] = {
-    kSecAttrLabel,
-    kSecAttrIsPermanent,
-    kSecAttrKeyType,
-    kSecAttrKeySizeInBits,
-    kSecAttrApplicationTag
-  };
-
-  std::string uri = keyName.toUri ();
-  CFStringRef label = CFStringCreateWithCString (NULL, uri.c_str (), kCFStringEncodingUTF8);
-  CFDataRef tag = CFDataCreate (NULL, reinterpret_cast<const unsigned char *> (uri.c_str ()), uri.size ());
-  
-  int keySize = 2048;
-  const void *	values[] = {
-    label,
-    kCFBooleanTrue,
-    kSecAttrKeyTypeRSA,
-    CFNumberCreate (NULL, kCFNumberIntType, &keySize),
-    tag
-  };
-
-  CFDictionaryRef dict = CFDictionaryCreate (NULL,
-                                             keys, values,
-                                             sizeof(keys) / sizeof(*keys),
-                                             NULL, NULL);
-
-  SecKeyRef publicKey, privateKey;
-
-  OSStatus res = SecKeyGeneratePair (dict, &publicKey, &privateKey);
-  _LOG_DEBUG ("GeneratePair stats: " << res);
-
-  if (res != errSecSuccess)
-    OSX_Private::LogHumanError (res, "Cannot generate public/private key pair");
-
-  CFRelease (publicKey);
-  CFRelease (privateKey);
-}
-
-void
-keychain::OSX::deleteKeyPair (const Name &keyName)
-{
-  const void *	keys[] = {
-    kSecClass,
-    kSecAttrApplicationTag
-  };
-
-  std::string uri = keyName.toUri ();
-  CFDataRef tag = CFDataCreate (NULL, reinterpret_cast<const unsigned char *> (uri.c_str ()), uri.size ());
-
-  const void *	values[] = {
-    kSecClassKey,
-    tag
-  };
-
-  CFDictionaryRef dict = CFDictionaryCreate (NULL,
-                                             keys, values,
-                                             sizeof(keys) / sizeof(*keys),
-                                             NULL, NULL);
-
-  OSStatus res = errSecSuccess;
-  while (res == errSecSuccess)
-    {
-      res = SecItemDelete (dict);
-      _LOG_DEBUG ("SecItemDelete status: " << res);
-    }
-
-  if (res != errSecItemNotFound)
-    OSX_Private::LogHumanError (res, "Error while deleting key " + keyName.toUri ());
-}
-
-void
-keychain::OSX::deletePublicKey (const Name &keyName)
-{
-  const void *	keys[] = {
-    kSecClass,
-    kSecAttrKeyClass,
-    kSecAttrApplicationTag
-  };
-
-  std::string uri = keyName.toUri ();
-  CFDataRef tag = CFDataCreate (NULL, reinterpret_cast<const unsigned char *> (uri.c_str ()), uri.size ());
-
-  const void *	values[] = {
-    kSecClassKey,
-    kSecAttrKeyClassPublic,
-    tag
-  };
-
-  CFDictionaryRef dict = CFDictionaryCreate (NULL,
-                                             keys, values,
-                                             sizeof(keys) / sizeof(*keys),
-                                             NULL, NULL);
-
-  OSStatus res = errSecSuccess;
-  while (res == errSecSuccess)
-    {
-      res = SecItemDelete (dict);
-      _LOG_DEBUG ("SecItemDelete status: " << res);
-    }
-
-  if (res != errSecItemNotFound)
-    OSX_Private::LogHumanError (res, "Error while deleting public key " + keyName.toUri ());
-}
-
-Ptr<Blob>
-keychain::OSX::getPublicKey (const Name &publicKeyName)
-{
-  const void *	keys[] = {
-    kSecClass,
-    kSecAttrKeyType,
-    kSecAttrKeyClass,
-    kSecAttrApplicationTag,
-    kSecReturnData
-  };
-
-  std::string uri = publicKeyName.toUri ();
-  CFDataRef tag = CFDataCreate (NULL, reinterpret_cast<const unsigned char *> (uri.c_str ()), uri.size ());
-
-  const void *	values[] = {
-    kSecClassKey,
-    kSecAttrKeyTypeRSA,
-    kSecAttrKeyClassPublic,
-    tag,
-    [NSNumber numberWithBool:YES]
-  };
-
-  CFDictionaryRef query = CFDictionaryCreate (NULL,
-                                              keys, values,
-                                              sizeof(keys) / sizeof(*keys),
-                                              NULL, NULL);
-
-  NSData* publicKey;
-  OSStatus res = SecItemCopyMatching (query, (CFTypeRef *)(&publicKey));
-  if (res != errSecSuccess)
-    OSX_Private::LogHumanError (res, "Cannot find public key " + publicKeyName.toUri ());
-
-  Ptr<Blob> retval (new Blob ([publicKey bytes], [publicKey length]));
-  _LOG_DEBUG ("Key size: " << [publicKey length]);
-  return retval;
-}
-
-/// @todo Release data structures after use
-
-} // ndn
diff --git a/scheduler/interval-generator.h b/scheduler/interval-generator.h
deleted file mode 100644
index e480ecc..0000000
--- a/scheduler/interval-generator.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef INTERVAL_GENERATOR_H
-#define INTERVAL_GENERATOR_H
-
-#include <boost/shared_ptr.hpp>
-
-using namespace std;
-
-class IntervalGenerator;
-typedef boost::shared_ptr<IntervalGenerator> IntervalGeneratorPtr;
-
-class IntervalGenerator
-{
-public:
-  virtual ~IntervalGenerator () { }
-  
-  virtual double
-  nextInterval() = 0;
-};
-
-
-#endif // INTERVAL_GENERATOR_H
diff --git a/scheduler/one-time-task.cc b/scheduler/one-time-task.cc
deleted file mode 100644
index b3082af..0000000
--- a/scheduler/one-time-task.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "one-time-task.h"
-#include "scheduler.h"
-
-OneTimeTask::OneTimeTask(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler, double delay)
-            : Task(callback, tag, scheduler)
-{
-  setTv(delay);
-}
-
-void
-OneTimeTask::run()
-{
-  if (!m_invoked)
-  {
-    m_callback();
-    m_invoked = true;
-    deregisterSelf();
-  }
-}
-
-void
-OneTimeTask::deregisterSelf()
-{
-  m_scheduler->deleteTask(m_tag);
-}
-
-void
-OneTimeTask::reset()
-{
-  m_invoked = false;
-}
diff --git a/scheduler/one-time-task.h b/scheduler/one-time-task.h
deleted file mode 100644
index 744ca90..0000000
--- a/scheduler/one-time-task.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef ONE_TIME_TASK_H
-#define ONE_TIME_TASK_H
-
-#include "task.h"
-
-class OneTimeTask : public Task
-{
-public:
-  OneTimeTask(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler, double delay);
-  virtual ~OneTimeTask(){}
-
-  // invoke callback and mark self as invoked and deregister self from scheduler
-  virtual void
-  run() _OVERRIDE;
-
-  // after reset, the task is marked as un-invoked and can be add to scheduler again, with same delay
-  // if not invoked yet, no effect
-  virtual void
-  reset() _OVERRIDE;
-
-private:
-  // this is to deregister itself from scheduler automatically after invoke
-  void
-  deregisterSelf();
-};
-
-
-#endif // EVENT_SCHEDULER_H
diff --git a/scheduler/periodic-task.cc b/scheduler/periodic-task.cc
deleted file mode 100644
index 110c4df..0000000
--- a/scheduler/periodic-task.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "periodic-task.h"
-#include "logging.h"
-#include <utility>
-
-INIT_LOGGER ("Scheduler.PeriodicTask");
-
-PeriodicTask::PeriodicTask(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler,
-                           IntervalGeneratorPtr generator)
-  : Task(callback, tag, scheduler)
-  , m_generator(generator)
-{
-}
-
-void
-PeriodicTask::run()
-{
-  if (!m_invoked)
-  {
-    m_invoked = true;
-    m_callback();
-
-    if (m_invoked)
-      {
-        // m_invoked getting back if it is rescheduled inside the callback
-        m_scheduler->rescheduleTask(m_tag);
-      }
-  }
-}
-
-void
-PeriodicTask::reset()
-{
-  m_invoked = false;
-  double interval = m_generator->nextInterval();
-  setTv(interval);
-}
diff --git a/scheduler/periodic-task.h b/scheduler/periodic-task.h
deleted file mode 100644
index 303dca4..0000000
--- a/scheduler/periodic-task.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef PERIODIC_TASK_H
-#define PERIODIC_TASK_H
-
-#include "task.h"
-#include "scheduler.h"
-#include "interval-generator.h"
-
-class PeriodicTask : public Task
-{
-public:
-  // generator is needed only when this is a periodic task
-  // two simple generators implementation (SimpleIntervalGenerator and RandomIntervalGenerator) are provided;
-  // if user needs more complex pattern in the intervals between calls, extend class IntervalGenerator
-  PeriodicTask(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler, IntervalGeneratorPtr generator);
-  virtual ~PeriodicTask(){}
-
-  // invoke callback, reset self and ask scheduler to schedule self with the next delay interval
-  virtual void
-  run() _OVERRIDE;
-
-  // set the next delay and mark as un-invoke
-  virtual void
-  reset() _OVERRIDE;
-
-private:
-  IntervalGeneratorPtr m_generator;
-};
-
-#endif // PERIODIC_TASK_H
diff --git a/scheduler/random-interval-generator.h b/scheduler/random-interval-generator.h
deleted file mode 100644
index 476578c..0000000
--- a/scheduler/random-interval-generator.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef RANDOM_INTERVAL_GENERATOR_H
-#define RANDOM_INTERVAL_GENERATOR_H
-
-#include "interval-generator.h"
-
-#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/uniform_real.hpp>
-#include <boost/random/variate_generator.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-
-// generates intervals with uniform distribution
-class RandomIntervalGenerator : public IntervalGenerator
-{
-public:
-  typedef enum
-  {
-    UP = 1,
-    DOWN = 2,
-    EVEN = 3
-  } Direction;
-
-public:
-  // percent is random-range/interval; e.g. if interval is 10 and you wish the random-range to be 2
-  // e.g. 9 ~ 11, percent = 0.2
-  // direction shifts the random range; e.g. in the above example, UP would produce a range of
-  // 10 ~ 12, DOWN of 8 ~ 10, and EVEN of 9 ~ 11
-  RandomIntervalGenerator(double interval, double percent, Direction direction = EVEN)
-  // : m_rng(time(NULL))
-    : m_rng (static_cast<int> (boost::posix_time::microsec_clock::local_time().time_of_day ().total_nanoseconds ()))
-  , m_dist(0.0, fractional(percent))
-  , m_random(m_rng, m_dist)
-  , m_direction(direction)
-  , m_percent(percent)
-  , m_interval(interval)
-  { }
-
-  virtual ~RandomIntervalGenerator(){}
-
-  virtual double
-  nextInterval() _OVERRIDE
-  {
-    double percent = m_random();
-    double interval = m_interval;
-    switch (m_direction)
-      {
-      case UP: interval = m_interval * (1.0 + percent); break;
-      case DOWN: interval = m_interval * (1.0 - percent); break;
-      case EVEN: interval = m_interval * (1.0 - m_percent/2.0 + percent); break;
-      default: break;
-      }
-
-    return interval;
-  }
-
-private:
-  inline double fractional(double x) { double dummy; return abs(modf(x, &dummy)); }
-
-private:
-  typedef boost::mt19937 RNG_TYPE;
-  RNG_TYPE m_rng;
-  boost::uniform_real<> m_dist;
-  boost::variate_generator<RNG_TYPE &, boost::uniform_real<> > m_random;
-  Direction m_direction;
-  double m_percent;
-  double m_interval;
-
-};
-#endif // RANDOM_INTERVAL_GENERATOR_H
diff --git a/scheduler/scheduler-all.h b/scheduler/scheduler-all.h
deleted file mode 100644
index 388a74c..0000000
--- a/scheduler/scheduler-all.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SCHEDULE_ALL_H
-#define SCHEDULE_ALL_H
-
-#include "scheduler/interval-generator.h"
-#include "scheduler/one-time-task.h"
-#include "scheduler/periodic-task.h"
-#include "scheduler/random-interval-generator.h"
-#include "scheduler/scheduler.h"
-#include "scheduler/simple-interval-generator.h"
-#include "scheduler/task.h"
-
-#endif
diff --git a/scheduler/scheduler.cc b/scheduler/scheduler.cc
deleted file mode 100644
index 02ac0c0..0000000
--- a/scheduler/scheduler.cc
+++ /dev/null
@@ -1,338 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "scheduler.h"
-#include "one-time-task.h"
-#include "periodic-task.h"
-#include "logging.h"
-
-#include <utility>
-#include <boost/make_shared.hpp>
-
-INIT_LOGGER ("Scheduler");
-
-using namespace std;
-using namespace boost;
-
-#define EVLOOP_NO_EXIT_ON_EMPTY 0x04
-
-static void
-dummyCallback(evutil_socket_t fd, short what, void *arg)
-{
-  // 1 year later, that was a long run for the app
-  // let's wait for another year
-  timeval tv;
-  tv.tv_sec = 365 * 24 * 3600;
-  tv.tv_usec = 0;
-  event *ev = *(event **)arg;
-  int res = evtimer_add(ev, &tv);
-}
-
-// IntervalGeneratorPtr
-// IntervalGenerator:: Null;
-
-void errorCallback(int err)
-{
-  _LOG_ERROR ("Fatal error: " << err);
-}
-
-Scheduler::Scheduler()
-  : m_running(false)
-  , m_executor(1)
-{
-  event_set_fatal_callback(errorCallback);
-  evthread_use_pthreads();
-  m_base = event_base_new();
-
-  // This is a hack to prevent event_base_loop from exiting;
-  // the flag EVLOOP_NO_EXIT_ON_EMPTY is somehow ignored, at least on Mac OS X
-  // it's going to be scheduled to 10 years later
-  timeval tv;
-  tv.tv_sec = 365 * 24 * 3600;
-  tv.tv_usec = 0;
-  m_ev = evtimer_new(m_base, dummyCallback, &m_ev);
-  int res = evtimer_add(m_ev, &tv);
-  if (res < 0)
-  {
-    _LOG_ERROR("heck");
-  }
-}
-
-Scheduler::~Scheduler()
-{
-  shutdown ();
-  evtimer_del(m_ev);
-  event_free(m_ev);
-  event_base_free(m_base);
-}
-
-void
-Scheduler::eventLoop()
-{
-  while(true)
-  {
-    if (event_base_loop(m_base, EVLOOP_NO_EXIT_ON_EMPTY) < 0)
-    {
-      _LOG_DEBUG ("scheduler loop break error");
-    }
-    else
-    {
-      _LOG_DEBUG ("scheduler loop break normal");
-    }
-
-    {
-      ScopedLock lock(m_mutex);
-      if (!m_running)
-        {
-          _LOG_DEBUG ("scheduler loop break normal");
-          break;
-        }
-    }
-
-    // just to prevent craziness in CPU usage which supposedly should not happen
-    // after adding the dummy event
-    usleep(1000);
-  }
-}
-
-void
-Scheduler::execute(Executor::Job job)
-{
-  m_executor.execute(job);
-}
-
-void
-Scheduler::start()
-{
-  ScopedLock lock(m_mutex);
-  if (!m_running)
-  {
-    m_thread = boost::thread(&Scheduler::eventLoop, this);
-    m_executor.start();
-    m_running = true;
-  }
-}
-
-void
-Scheduler::shutdown()
-{
-  bool breakAndWait = false;
-  {
-    ScopedLock lock (m_mutex);
-    if (m_running)
-      {
-        m_running = false;
-        breakAndWait = true;
-      }
-  }
-
-  if (breakAndWait)
-    {
-      event_base_loopbreak(m_base);
-      m_executor.shutdown();
-      m_thread.join();
-    }
-}
-
-TaskPtr
-Scheduler::scheduleOneTimeTask (SchedulerPtr scheduler, double delay,
-                                const Task::Callback &callback, const Task::Tag &tag)
-{
-  TaskPtr task = make_shared<OneTimeTask> (callback, tag, scheduler, delay);
-  if (scheduler->addTask (task))
-    return task;
-  else
-    return TaskPtr ();
-}
-
-TaskPtr
-Scheduler::schedulePeriodicTask (SchedulerPtr scheduler, IntervalGeneratorPtr delayGenerator,
-                                 const Task::Callback &callback, const Task::Tag &tag)
-{
-  TaskPtr task = make_shared<PeriodicTask> (callback, tag, scheduler, delayGenerator);
-
-  if (scheduler->addTask (task))
-    return task;
-  else
-    return TaskPtr ();
-}
-
-bool
-Scheduler::addTask(TaskPtr newTask, bool reset/* = true*/)
-{
-  if (addToMap(newTask))
-  {
-    if (reset)
-      {
-        newTask->reset();
-      }
-    int res = evtimer_add(newTask->ev(), newTask->tv());
-    if (res < 0)
-    {
-      _LOG_ERROR ("evtimer_add failed for " << newTask->tag());
-    }
-    return true;
-  }
-  else
-  {
-    _LOG_ERROR ("fail to add task: " << newTask->tag());
-  }
-
-  return false;
-}
-
-void
-Scheduler::deleteTask(TaskPtr task)
-{
-  deleteTask (task->tag ());
-}
-
-void
-Scheduler::rescheduleTask(TaskPtr task)
-{
-  ScopedLock lock(m_mutex);
-  TaskMapIt it = m_taskMap.find(task->tag());
-  if (it != m_taskMap.end())
-  {
-    TaskPtr task = it->second;
-    task->reset();
-    int res = evtimer_add(task->ev(), task->tv());
-    if (res < 0)
-    {
-      _LOG_ERROR ("evtimer_add failed for " << task->tag());
-    }
-  }
-  else
-  {
-    addTask(task);
-  }
-}
-
-void
-Scheduler::rescheduleTask(const Task::Tag &tag)
-{
-  ScopedLock lock(m_mutex);
-  TaskMapIt it = m_taskMap.find(tag);
-  if (it != m_taskMap.end())
-  {
-    TaskPtr task = it->second;
-    task->reset();
-    int res = evtimer_add(task->ev(), task->tv());
-    if (res < 0)
-    {
-      cout << "evtimer_add failed for " << task->tag() << endl;
-    }
-  }
-}
-
-void
-Scheduler::rescheduleTaskAt (const Task::Tag &tag, double time)
-{
-  ScopedLock lock(m_mutex);
-  TaskMapIt it = m_taskMap.find (tag);
-  if (it != m_taskMap.end())
-  {
-    TaskPtr task = it->second;
-    task->reset();
-    task->setTv (time);
-
-    int res = evtimer_add(task->ev(), task->tv());
-    if (res < 0)
-    {
-      _LOG_ERROR ("evtimer_add failed for " << task->tag());
-    }
-  }
-  else
-    {
-      _LOG_ERROR ("Task for tag " << tag << " not found");
-    }
-}
-
-void
-Scheduler::rescheduleTaskAt (TaskPtr task, double time)
-{
-  ScopedLock lock(m_mutex);
-  TaskMapIt it = m_taskMap.find(task->tag());
-  if (it != m_taskMap.end())
-  {
-    TaskPtr task = it->second;
-    task->reset();
-    task->setTv (time);
-
-    int res = evtimer_add(task->ev(), task->tv());
-    if (res < 0)
-    {
-      _LOG_ERROR ("evtimer_add failed for " << task->tag());
-    }
-  }
-  else
-  {
-    task->setTv (time); // force different time
-    addTask (task, false);
-  }
-}
-
-
-bool
-Scheduler::addToMap(TaskPtr task)
-{
-  ScopedLock lock(m_mutex);
-  if (m_taskMap.find(task->tag()) == m_taskMap.end())
-  {
-    m_taskMap.insert(make_pair(task->tag(), task));
-    return true;
-  }
-  return false;
-}
-
-void
-Scheduler::deleteTask(const Task::Tag &tag)
-{
-  ScopedLock lock(m_mutex);
-  TaskMapIt it = m_taskMap.find(tag);
-  if (it != m_taskMap.end())
-  {
-    TaskPtr task = it->second;
-    evtimer_del(task->ev());
-    m_taskMap.erase(it);
-  }
-}
-
-void
-Scheduler::deleteTask(const Task::TaskMatcher &matcher)
-{
-  ScopedLock lock(m_mutex);
-  TaskMapIt it = m_taskMap.begin();
-  while(it != m_taskMap.end())
-  {
-    TaskPtr task = it->second;
-    if (matcher(task))
-    {
-      evtimer_del(task->ev());
-      // Use post increment; map.erase invalidate the iterator that is beening erased,
-      // but does not invalidate other iterators. This seems to be the convention to
-      // erase something from C++ STL map while traversing.
-      m_taskMap.erase(it++);
-    }
-    else
-    {
-      ++it;
-    }
-  }
-}
-
-int
-Scheduler::size()
-{
-  ScopedLock lock(m_mutex);
-  return m_taskMap.size();
-}
diff --git a/scheduler/scheduler.h b/scheduler/scheduler.h
deleted file mode 100644
index ffac5d2..0000000
--- a/scheduler/scheduler.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SCHEDULER_H
-#define SCHEDULER_H
-
-#include <event2/event.h>
-#include <event2/thread.h>
-#include <event2/event-config.h>
-#include <event2/util.h>
-
-#include <boost/function.hpp>
-#include <boost/shared_ptr.hpp>
-
-#include <boost/exception/all.hpp>
-#include <boost/thread/recursive_mutex.hpp>
-#include <boost/thread/thread.hpp>
-#include <math.h>
-#include <map>
-#include <sys/time.h>
-
-#include "scheduler/task.h"
-#include "scheduler/interval-generator.h"
-#include "executor/executor.h"
-
-class Scheduler;
-typedef boost::shared_ptr<Scheduler> SchedulerPtr;
-
-/**
- * @brief Scheduler class
- */
-class Scheduler
-{
-public:
-  Scheduler();
-  virtual ~Scheduler();
-
-  // start event scheduling
-  virtual void
-  start();
-
-  // stop event scheduling
-  virtual void
-  shutdown();
-
-  // helper method to schedule one-time task
-  static TaskPtr
-  scheduleOneTimeTask (SchedulerPtr scheduler, double delay, const Task::Callback &callback, const Task::Tag &tag);
-
-  // helper method to schedule periodic task
-  static TaskPtr
-  schedulePeriodicTask (SchedulerPtr scheduler, IntervalGeneratorPtr delayGenerator,
-                        const Task::Callback &callback, const Task::Tag &tag);
-
-  // if task with the same tag exists, the task is not added and return false
-  virtual bool
-  addTask(TaskPtr task, bool reset = true);
-
-  // delete task by task->tag, regardless of whether it's invoked or not
-  virtual void
-  deleteTask(TaskPtr task);
-
-  // delete task by tag, regardless of whether it's invoked or not
-  // if no task is found, no effect
-  virtual void
-  deleteTask(const Task::Tag &tag);
-
-  // delete tasks by matcher, regardless of whether it's invoked or not
-  // this is flexiable in that you can use any form of criteria in finding tasks to delete
-  // but keep in mind this is a linear scan
-
-  // if no task is found, no effect
-  virtual void
-  deleteTask(const Task::TaskMatcher &matcher);
-
-  // task must already have been added to the scheduler, otherwise this method has no effect
-  // this is usually used by PeriodicTask
-  virtual void
-  rescheduleTask(const Task::Tag &tag);
-
-  // if the task is not pending, it will be added to the schedule queue
-  // if the task is pending, the delay is changed to the passed in delay
-  // e.g. if at second 0 task A with delay 5 is originally going to run at second 5 and
-  // rescheduleTask(A) is called at second 4, A will be reschedule to run
-  // at second 9
-  virtual void
-  rescheduleTask(TaskPtr task);
-
-  virtual void
-  rescheduleTaskAt (const Task::Tag &tag, double time);
-
-  virtual void
-  rescheduleTaskAt (TaskPtr task, double time);
-
-  void
-  execute(Executor::Job);
-
-  void
-  eventLoop();
-
-  event_base *
-  base() { return m_base; }
-
-  // used in test
-  int
-  size();
-
-protected:
-  bool
-  addToMap(TaskPtr task);
-
-protected:
-  typedef std::map<Task::Tag, TaskPtr> TaskMap;
-  typedef std::map<Task::Tag, TaskPtr>::iterator TaskMapIt;
-  typedef boost::recursive_mutex Mutex;
-  typedef boost::unique_lock<Mutex> ScopedLock;
-
-  TaskMap m_taskMap;
-  Mutex m_mutex;
-  volatile bool m_running;
-  event_base *m_base;
-  event *m_ev;
-  boost::thread m_thread;
-  Executor m_executor;
-};
-
-struct SchedulerException : virtual boost::exception, virtual std::exception { };
-
-#endif // SCHEDULER_H
diff --git a/scheduler/simple-interval-generator.h b/scheduler/simple-interval-generator.h
deleted file mode 100644
index c7a9e77..0000000
--- a/scheduler/simple-interval-generator.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SIMPLE_INTERVAL_GENERATOR_H
-#define SIMPLE_INTERVAL_GENERATOR_H
-
-#include "interval-generator.h"
-
-class SimpleIntervalGenerator : public IntervalGenerator
-{
-public:
-  SimpleIntervalGenerator(double interval) : m_interval (interval) {}
-  virtual ~SimpleIntervalGenerator() {}
-  
-  virtual double
-  nextInterval() _OVERRIDE { return m_interval; }
-
-private:
-  double m_interval;
-};
-
-#endif // SIMPLE_INTERVAL_GENERATOR_H
diff --git a/scheduler/task.cc b/scheduler/task.cc
deleted file mode 100644
index fa73490..0000000
--- a/scheduler/task.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "task.h"
-#include "scheduler.h"
-
-static void
-eventCallback(evutil_socket_t fd, short what, void *arg)
-{
-  Task *task = static_cast<Task *>(arg);
-  task->execute();
-  task = NULL;
-}
-
-Task::Task(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler)
-     : m_callback(callback)
-     , m_tag(tag)
-     , m_scheduler(scheduler)
-     , m_invoked(false)
-     , m_event(NULL)
-     , m_tv(NULL)
-{
-  m_event = evtimer_new(scheduler->base(), eventCallback, this);
-  m_tv = new timeval;
-}
-
-Task::~Task()
-{
-  if (m_event != NULL)
-  {
-    event_free(m_event);
-    m_event = NULL;
-  }
-
-  if (m_tv != NULL)
-  {
-    delete m_tv;
-    m_tv = NULL;
-  }
-}
-
-void
-Task::setTv(double delay)
-{
-  // Alex: when using abs function, i would recommend use it with std:: prefix, otherwise
-  // the standard one may be used, which converts everything to INT, making a lot of problems
-  double intPart, fraction;
-  fraction = modf(std::abs(delay), &intPart);
-
-  m_tv->tv_sec = static_cast<int>(intPart);
-  m_tv->tv_usec = static_cast<int>((fraction * 1000000));
-}
-
-void
-Task::execute()
-{
-  // m_scheduler->execute(boost::bind(&Task::run, this));
-
-  // using a shared_ptr of this to ensure that when invoked from executor
-  // the task object still exists
-  // otherwise, it could be the case that the run() is to be executed, but before it
-  // could finish, the TaskPtr gets deleted from scheduler and the task object
-  // gets destroyed, causing crash
-  m_scheduler->execute(boost::bind(&Task::run, shared_from_this()));
-}
diff --git a/scheduler/task.h b/scheduler/task.h
deleted file mode 100644
index bd14296..0000000
--- a/scheduler/task.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
- *                     Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef TASK_H
-#define TASK_H
-
-#define _OVERRIDE
-#ifdef __GNUC__
-#if __GNUC_MAJOR >= 4 && __GNUC_MINOR__ >= 7
-  #undef _OVERRIDE
-  #define _OVERRIDE override
-#endif // __GNUC__ version
-#endif // __GNUC__
-
-#include <boost/function.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
-#include <sys/time.h>
-
-//////////////////////////////////////////////////
-// forward declarations
-class Task;
-typedef boost::shared_ptr<Task> TaskPtr;
-
-class Scheduler;
-typedef boost::shared_ptr<Scheduler> SchedulerPtr;
-
-struct event;
-//////////////////////////////////////////////////
-
-
-/**
- * @brief Base class for a task
- */
-class Task : public boost::enable_shared_from_this<Task>
-{
-public:
-  // callback of this task
-  typedef boost::function<void ()> Callback;
-  // tag identifies this task, should be unique
-  typedef std::string Tag;
-  // used to match tasks
-  typedef boost::function<bool (const TaskPtr &task)> TaskMatcher;
-
-  // Task is associated with Schedulers due to the requirement that libevent event is associated with an libevent event_base
-  Task(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler);
-  virtual ~Task();
-
-  virtual void
-  run() = 0;
-
-  Tag
-  tag() { return m_tag; }
-
-  event *
-  ev() { return m_event; }
-
-  timeval *
-  tv() { return m_tv; }
-
-  // Task needs to be resetted after the callback is invoked if it is to be schedule again; just for safety
-  // it's called by scheduler automatically when addTask or rescheduleTask is called;
-  // Tasks should do preparation work here (e.g. set up new delay, etc. )
-  virtual void
-  reset() = 0;
-
-  // set delay
-  // This overrides whatever delay kept in m_tv
-  void
-  setTv(double delay);
-
-  void
-  execute();
-
-protected:
-  Callback m_callback;
-  Tag m_tag;
-  SchedulerPtr m_scheduler;
-  bool m_invoked;
-  event *m_event;
-  timeval *m_tv;
-};
-
-
-#endif // TASK_H
