Making CcnxWrapper a singleton
diff --git a/ccnx/sync-app-socket.cc b/ccnx/sync-app-socket.cc
index b3ed61b..3da5402 100644
--- a/ccnx/sync-app-socket.cc
+++ b/ccnx/sync-app-socket.cc
@@ -29,7 +29,7 @@
 {
 
 SyncAppSocket::SyncAppSocket (const string &syncPrefix, NewDataCallback dataCallback, RemoveCallback rmCallback )
-	: m_ccnxHandle (new CcnxWrapper())
+  : m_ccnxHandle (CcnxWrapper::Create ())
   , m_newDataCallback(dataCallback)
   , m_syncLogic (syncPrefix,
                  bind(&SyncAppSocket::passCallback, this, _1),
diff --git a/ccnx/sync-ccnx-wrapper.cc b/ccnx/sync-ccnx-wrapper.cc
index d0a6376..3e2ebc1 100644
--- a/ccnx/sync-ccnx-wrapper.cc
+++ b/ccnx/sync-ccnx-wrapper.cc
@@ -49,7 +49,6 @@
 #ifdef _DEBUG_WRAPPER_      
   m_c = c;
 #endif
-  m_handle = ccn_create();
   connectCcnd();
   initKeyStore ();
   createKeyLocator ();
@@ -59,7 +58,12 @@
 void
 CcnxWrapper::connectCcnd()
 {
-  ccn_disconnect (m_handle);
+  if (m_handle != 0) {
+    ccn_disconnect (m_handle);
+    ccn_destroy (&m_handle);
+  }
+  
+  m_handle = ccn_create ();
   _LOG_DEBUG("<<< connecting to ccnd");
   if (ccn_connect(m_handle, NULL) < 0)
   {
@@ -70,6 +74,7 @@
   {
     for (map<std::string, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
     {
+      // clearInterestFilter(it->first);
       setInterestFilter(it->first, it->second);
       _LOG_DEBUG("<<< registering interest filter for: " << it->first);
     }
diff --git a/include/sync-ccnx-wrapper.h b/include/sync-ccnx-wrapper.h
index d68cdc1..879bc81 100644
--- a/include/sync-ccnx-wrapper.h
+++ b/include/sync-ccnx-wrapper.h
@@ -58,7 +58,17 @@
   typedef boost::function<void (std::string, std::string)> StringDataCallback;
   typedef boost::function<void (std::string, const char *buf, size_t len)> RawDataCallback;
   typedef boost::function<void (std::string)> InterestCallback;
+
+
+  static
+  CcnxWrapper *
+  Create ()
+  {
+    static CcnxWrapper *wrapper = new CcnxWrapper ();
+    return wrapper;
+  }
   
+private:
   /**
    * @brief initialize the wrapper; a lot of things needs to be done. 1) init
    * keystore 2) init keylocator 3) start a thread to hold a loop of ccn_run
@@ -69,7 +79,8 @@
   char m_c;
 #else
   CcnxWrapper();
-#endif  
+#endif
+public:
   ~CcnxWrapper();
 
   /**
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index ed90655..5280c93 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -65,7 +65,7 @@
   , m_syncPrefix (syncPrefix)
   , m_onUpdate (onUpdate)
   , m_onRemove (onRemove)
-  , m_ccnxHandle(new CcnxWrapper())
+  , m_ccnxHandle(CcnxWrapper::Create ())
   , m_recoveryRetransmissionInterval (m_defaultRecoveryRetransmitInterval)
 #ifndef NS3_MODULE
   , m_randomGenerator (static_cast<unsigned int> (std::time (0)))