Changing Closure API. No need for so many pointers...
diff --git a/ccnx/ccnx-closure.cpp b/ccnx/ccnx-closure.cpp
index bc9b244..a96bbbe 100644
--- a/ccnx/ccnx-closure.cpp
+++ b/ccnx/ccnx-closure.cpp
@@ -1,54 +1,63 @@
+/* -*- 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 "ccnx-closure.h"
 
 namespace Ccnx {
 
 Closure::Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback)
-              : m_timeoutCallback(NULL), m_dataCallback(NULL)
+  : m_timeoutCallback (timeoutCallback)
+  , m_dataCallback (dataCallback)
 {
-  m_timeoutCallback = new TimeoutCallback (timeoutCallback);
-  m_dataCallback = new DataCallback (dataCallback);
-}
-
-Closure::Closure(const Closure &other)
-            : m_timeoutCallback(NULL), m_dataCallback(NULL)
-{
-  m_timeoutCallback = new TimeoutCallback(*(other.m_timeoutCallback));
-  m_dataCallback = new DataCallback(*(other.m_dataCallback));
 }
 
 Closure::~Closure ()
 {
-  delete m_dataCallback;
-  delete m_timeoutCallback;
-  m_dataCallback = NULL;
-  m_timeoutCallback = NULL;
 }
 
 Closure::TimeoutCallbackReturnValue
 Closure::runTimeoutCallback(const Name &interest)
 {
-  if ((*m_timeoutCallback).empty())
-  {
-    return RESULT_OK;
-  }
+  if (m_timeoutCallback.empty ())
+    {
+      return RESULT_OK;
+    }
 
-  return (*m_timeoutCallback)(interest);
+  return m_timeoutCallback (interest);
 }
 
 
 void
 Closure::runDataCallback(const Name &name, const Bytes &content)
 {
-  if (m_dataCallback != NULL) {
-    (*m_dataCallback)(name, content);
-  }
+  if (!m_dataCallback.empty ())
+    {
+      m_dataCallback (name, content);
+    }
 }
 
 Closure *
-Closure::dup() const
+Closure::dup () const
 {
-  Closure *closure = new Closure(*this);
-  return closure;
+  return new Closure (*this);
 }
 
 } // Ccnx
diff --git a/ccnx/ccnx-closure.h b/ccnx/ccnx-closure.h
index 1bcaa06..39fbc16 100644
--- a/ccnx/ccnx-closure.h
+++ b/ccnx/ccnx-closure.h
@@ -1,11 +1,30 @@
+/* -*- 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 CCNX_CLOSURE_H
 #define CCNX_CLOSURE_H
 
 #include "ccnx-common.h"
 #include "ccnx-name.h"
 
-using namespace std;
-
 namespace Ccnx {
 
 class Closure
@@ -22,10 +41,11 @@
   typedef boost::function<TimeoutCallbackReturnValue (const Name &)> TimeoutCallback;
 
   Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback = TimeoutCallback());
-  Closure(const Closure &other);
   virtual ~Closure();
+
   virtual void
   runDataCallback(const Name &name, const Bytes &content);
+
   virtual TimeoutCallbackReturnValue
   runTimeoutCallback(const Name &interest);
 
@@ -33,8 +53,8 @@
   dup() const;
 
 protected:
-  TimeoutCallback *m_timeoutCallback;
-  DataCallback *m_dataCallback;
+  TimeoutCallback m_timeoutCallback;
+  DataCallback m_dataCallback;
 };
 
 } // Ccnx
diff --git a/ccnx/ccnx-tunnel.cpp b/ccnx/ccnx-tunnel.cpp
index 0808663..6bf117f 100644
--- a/ccnx/ccnx-tunnel.cpp
+++ b/ccnx/ccnx-tunnel.cpp
@@ -1,3 +1,24 @@
+/* -*- 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 "ccnx-tunnel.h"
 #include "ccnx-pco.h"
 
@@ -28,12 +49,13 @@
 }
 
 int
-CcnxTunnel::sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors)
+CcnxTunnel::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
 {
   Name tunneledInterest = queryRoutableName(interest);
-  Closure *cp = new TunnelClosure(closure, this, interest);
-  CcnxWrapper::sendInterest(tunneledInterest, cp, selectors);
-  delete cp;
+
+  CcnxWrapper::sendInterest(tunneledInterest,
+                            TunnelClosure(closure, *this, interest),
+                            selectors);
 
   return 0;
 }
@@ -118,33 +140,30 @@
   m_rit.erase(prefix);
 }
 
-TunnelClosure::TunnelClosure(const DataCallback &dataCallback, CcnxTunnel *tunnel, const Name &originalInterest, const TimeoutCallback &timeoutCallback)
-                  : Closure(dataCallback, timeoutCallback)
-                  , m_tunnel(tunnel)
-                  , m_originalInterest(originalInterest)
+TunnelClosure::TunnelClosure(const DataCallback &dataCallback, CcnxTunnel &tunnel,
+                             const Name &originalInterest, const TimeoutCallback &timeoutCallback)
+  : Closure(dataCallback, timeoutCallback)
+  , m_tunnel(tunnel)
+  , m_originalInterest(originalInterest)
 {
 }
 
-TunnelClosure::TunnelClosure(const Closure *closure, CcnxTunnel *tunnel, const Name &originalInterest)
-                 : Closure(*closure)
-                 , m_tunnel(tunnel)
+TunnelClosure::TunnelClosure(const Closure &closure, CcnxTunnel &tunnel, const Name &originalInterest)
+  : Closure(closure)
+  , m_tunnel(tunnel)
 {
 }
 
 Closure *
 TunnelClosure::dup() const
 {
-  Closure *closure = new TunnelClosure(*m_dataCallback, m_tunnel, m_originalInterest, *m_timeoutCallback);
-  return closure;
+  return new TunnelClosure (*this);
 }
 
 void
 TunnelClosure::runDataCallback(const Name &name, const Bytes &content)
 {
-  if (m_tunnel != NULL)
-  {
-    m_tunnel->handleTunneledData(name, content, (*m_dataCallback));
-  }
+  m_tunnel.handleTunneledData(name, content, m_dataCallback);
 }
 
 Closure::TimeoutCallbackReturnValue
diff --git a/ccnx/ccnx-tunnel.h b/ccnx/ccnx-tunnel.h
index 05f981a..ce56775 100644
--- a/ccnx/ccnx-tunnel.h
+++ b/ccnx/ccnx-tunnel.h
@@ -1,8 +1,27 @@
+/* -*- 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 CCNX_TUNNEL_H
 #define CCNX_TUNNEL_H
 
-#include <boost/variant.hpp>
-
 #include "ccnx-common.h"
 #include "ccnx-wrapper.h"
 #include "ccnx-name.h"
@@ -16,8 +35,6 @@
 #endif // __GNUC__ version
 #endif // __GNUC__
 
-using namespace std;
-
 // Eventually, Sync::CcnxWrapper should be moved to this namespace.
 // It has nothing to do with Sync.
 namespace Ccnx
@@ -26,8 +43,8 @@
 class CcnxTunnel : public CcnxWrapper
 {
 public:
-  typedef multimap<Name, InterestCallback> RegisteredInterestTable;
-  typedef multimap<Name, InterestCallback>::iterator RitIter;
+  typedef std::multimap<Name, InterestCallback> RegisteredInterestTable;
+  typedef std::multimap<Name, InterestCallback>::iterator RitIter;
 
 
   CcnxTunnel();
@@ -41,7 +58,7 @@
   publishContentObject(const Name &name, const Bytes &contentObject, int freshness);
 
   virtual int
-  sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors = Selectors());
+  sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors = Selectors());
 
 
   // prefix is topology-independent
@@ -89,9 +106,10 @@
 class TunnelClosure : public Closure
 {
 public:
-  TunnelClosure(const DataCallback &dataCallback, CcnxTunnel *tunnel, const Name &originalInterest, const TimeoutCallback &timeoutCallback = TimeoutCallback());
+  TunnelClosure(const DataCallback &dataCallback, CcnxTunnel &tunnel,
+                const Name &originalInterest, const TimeoutCallback &timeoutCallback = TimeoutCallback());
 
-  TunnelClosure(const Closure *closure, CcnxTunnel *tunnel, const Name &originalInterest);
+  TunnelClosure(const Closure &closure, CcnxTunnel &tunnel, const Name &originalInterest);
 
   virtual void
   runDataCallback(const Name &name, const Bytes &content) _OVERRIDE;
@@ -100,10 +118,10 @@
   runTimeoutCallback(const Name &interest) _OVERRIDE;
 
   virtual Closure *
-  dup() const _OVERRIDE;
+  dup() const;
 
 private:
-  CcnxTunnel *m_tunnel;
+  CcnxTunnel &m_tunnel;
   Name m_originalInterest;
 };
 
diff --git a/ccnx/ccnx-wrapper.cpp b/ccnx/ccnx-wrapper.cpp
index b014a07..fcaf224 100644
--- a/ccnx/ccnx-wrapper.cpp
+++ b/ccnx/ccnx-wrapper.cpp
@@ -284,7 +284,7 @@
   return CCN_UPCALL_RESULT_OK;
 }
 
-int CcnxWrapper::sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors)
+int CcnxWrapper::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
 {
   UniqueRecLock lock(m_mutex);
   if (!m_running || !m_connected)
@@ -294,7 +294,7 @@
   ccn_charbuf *pname = namePtr->getBuf();
   ccn_closure *dataClosure = new ccn_closure;
 
-  Closure *myClosure = closure->dup();
+  Closure *myClosure = closure.dup();
   dataClosure->data = (void *)myClosure;
 
   dataClosure->p = &incomingData;
diff --git a/ccnx/ccnx-wrapper.h b/ccnx/ccnx-wrapper.h
index baa22b1..2e66a2d 100644
--- a/ccnx/ccnx-wrapper.h
+++ b/ccnx/ccnx-wrapper.h
@@ -38,7 +38,7 @@
   clearInterestFilter (const Name &prefix);
 
   virtual int
-  sendInterest (const Name &interest, const Closure *closure, const Selectors &selector = Selectors());
+  sendInterest (const Name &interest, const Closure &closure, const Selectors &selector = Selectors());
 
   virtual int
   publishData (const Name &name, const unsigned char *buf, size_t len, int freshness);