diff --git a/model/sync-ccnx-wrapper.cc b/model/sync-ccnx-wrapper.cc
index 0acde7f..b901a43 100644
--- a/model/sync-ccnx-wrapper.cc
+++ b/model/sync-ccnx-wrapper.cc
@@ -45,50 +45,58 @@
 {
   m_running = false;
   m_thread.join();
-  ccn_disconnect(m_handle);
-  ccn_destroy(&m_handle);
-  ccn_charbuf_destroy(&m_keyLoactor);
-  ccn_keystore_destroy(&m_keyStore);
+  ccn_disconnect (m_handle);
+  ccn_destroy (&m_handle);
+  ccn_charbuf_destroy (&m_keyLoactor);
+  ccn_keystore_destroy (&m_keyStore);
 }
 
-void CcnxWrapper::createKeyLocator()
+/// @cond include_hidden
+
+void
+CcnxWrapper::createKeyLocator ()
 {
   m_keyLoactor = ccn_charbuf_create();
-  ccn_charbuf_append_tt(m_keyLoactor, CCN_DTAG_KeyLocator, CCN_DTAG);
-  ccn_charbuf_append_tt(m_keyLoactor, CCN_DTAG_Key, CCN_DTAG);
-  int res = ccn_append_pubkey_blob(m_keyLoactor, ccn_keystore_public_key(m_keyStore));
+  ccn_charbuf_append_tt (m_keyLoactor, CCN_DTAG_KeyLocator, CCN_DTAG);
+  ccn_charbuf_append_tt (m_keyLoactor, CCN_DTAG_Key, CCN_DTAG);
+  int res = ccn_append_pubkey_blob (m_keyLoactor, ccn_keystore_public_key(m_keyStore));
   if (res >= 0)
     {
-      ccn_charbuf_append_closer(m_keyLoactor); /* </Key> */
-      ccn_charbuf_append_closer(m_keyLoactor); /* </KeyLocator> */
+      ccn_charbuf_append_closer (m_keyLoactor); /* </Key> */
+      ccn_charbuf_append_closer (m_keyLoactor); /* </KeyLocator> */
     }
 }
 
-const ccn_pkey* CcnxWrapper::getPrivateKey()
+const ccn_pkey*
+CcnxWrapper::getPrivateKey ()
 {
-  return ccn_keystore_private_key(m_keyStore);
+  return ccn_keystore_private_key (m_keyStore);
 }
 
-const unsigned char* CcnxWrapper::getPublicKeyDigest()
+const unsigned char*
+CcnxWrapper::getPublicKeyDigest ()
 {
   return ccn_keystore_public_key_digest(m_keyStore);
 }
 
-ssize_t CcnxWrapper::getPublicKeyDigestLength()
+ssize_t
+CcnxWrapper::getPublicKeyDigestLength ()
 {
   return ccn_keystore_public_key_digest_length(m_keyStore);
 }
 
-void CcnxWrapper::initKeyStore()
+void
+CcnxWrapper::initKeyStore ()
 {
-  ccn_charbuf *temp = ccn_charbuf_create();
-  m_keyStore = ccn_keystore_create();
-  ccn_charbuf_putf(temp, "%s/.ccnx/.ccnx_keystore", getenv("HOME"));
-  ccn_keystore_init(m_keyStore, ccn_charbuf_as_string(temp), (char*)"Th1s1sn0t8g00dp8ssw0rd.");
-  ccn_charbuf_destroy(&temp);
+  ccn_charbuf *temp = ccn_charbuf_create ();
+  m_keyStore = ccn_keystore_create ();
+  ccn_charbuf_putf (temp, "%s/.ccnx/.ccnx_keystore", getenv("HOME"));
+  ccn_keystore_init (m_keyStore, ccn_charbuf_as_string(temp), (char*)"Th1s1sn0t8g00dp8ssw0rd.");
+  ccn_charbuf_destroy (&temp);
 }
 
-void CcnxWrapper::ccnLoop()
+void
+CcnxWrapper::ccnLoop ()
 {
   pollfd pfds[1];
   int res = ccn_run(m_handle, 0);
@@ -110,7 +118,10 @@
     }
 }
 
-int CcnxWrapper::publishData(string name, string dataBuffer, int freshness)
+/// @endcond
+
+int
+CcnxWrapper::publishData (const string &name, const string &dataBuffer, int freshness)
 {
   ccn_charbuf *pname = ccn_charbuf_create();
   ccn_charbuf *signed_info = ccn_charbuf_create();
@@ -126,27 +137,28 @@
 			 NULL,
 			 m_keyLoactor);
   ccn_encode_ContentObject(content, pname, signed_info,
-			   dataBuffer.c_str(), dataBuffer.length(),
+			   dataBuffer.c_str(), dataBuffer.length (),
 			   NULL, getPrivateKey());
   recursive_mutex::scoped_lock lock(m_mutex);
   ccn_put(m_handle, content->buf, content->length);
 
-  ccn_charbuf_destroy(&pname);
-  ccn_charbuf_destroy(&signed_info);
-  ccn_charbuf_destroy(&content);
+  ccn_charbuf_destroy (&pname);
+  ccn_charbuf_destroy (&signed_info);
+  ccn_charbuf_destroy (&content);
 }
 
 
-static ccn_upcall_res incomingInterest(
-                                       ccn_closure *selfp,
-                                       ccn_upcall_kind kind,
-                                       ccn_upcall_info *info)
+static ccn_upcall_res
+incomingInterest(ccn_closure *selfp,
+                 ccn_upcall_kind kind,
+                 ccn_upcall_info *info)
 {
-  function<void (string)> f = *(function<void (string)> *)selfp->data;
+  CcnxWrapper::InterestCallback *f = static_cast<CcnxWrapper::InterestCallback*> (selfp->data);
 
   switch (kind)
     {
     case CCN_UPCALL_FINAL:
+      delete f;
       delete selfp;
       return CCN_UPCALL_RESULT_OK;
 
@@ -166,20 +178,21 @@
       ccn_name_comp_get(info->interest_ccnb, info->interest_comps, i, (const unsigned char **)&comp, &size);
       interest += comp;
     }
-  f(interest);
+  (*f) (interest);
   return CCN_UPCALL_RESULT_OK;
 }
 
-static ccn_upcall_res incomingData(
-                                   ccn_closure *selfp,
-                                   ccn_upcall_kind kind,
-                                   ccn_upcall_info *info)
+static ccn_upcall_res
+incomingData(ccn_closure *selfp,
+             ccn_upcall_kind kind,
+             ccn_upcall_info *info)
 {
-  function<void (string, string)> f = *(function<void (string, string)> *)selfp->data;
+  CcnxWrapper::DataCallback *f = static_cast<CcnxWrapper::DataCallback*> (selfp->data);
 
   switch (kind)
     {
     case CCN_UPCALL_FINAL:
+      delete f; // this never called in unit tests... 
       delete selfp;
       return CCN_UPCALL_RESULT_OK;
 
@@ -203,35 +216,34 @@
       name += comp; // this will also crash if name doesn't have \0 ending
     }
   // this will crash when content doesn't have \0 ending
-  f(name, (string)pcontent);
+  (*f) (name, (string)pcontent);
   return CCN_UPCALL_RESULT_OK;
 }
 
-int CcnxWrapper::sendInterest(string strInterest, function<void (string, string)> dataCallback)
+int CcnxWrapper::sendInterest (const string &strInterest, const DataCallback &dataCallback)
 {
   ccn_charbuf *pname = ccn_charbuf_create();
   ccn_closure *dataClosure = new ccn_closure;
-  function<void (string, string)> *f = new function<void (string, string)>(dataCallback);
-
-  ccn_name_from_uri(pname, strInterest.c_str());
-  dataClosure->data = f;
+  
+  ccn_name_from_uri (pname, strInterest.c_str());
+  dataClosure->data = new DataCallback (dataCallback); // should be removed when closure is removed
+  
   dataClosure->p = &incomingData;
   recursive_mutex::scoped_lock lock(m_mutex);
-  ccn_express_interest(m_handle, pname, dataClosure, NULL);
+  ccn_express_interest (m_handle, pname, dataClosure, NULL);
 
-  ccn_charbuf_destroy(&pname);
+  ccn_charbuf_destroy (&pname);
 }
 
-int CcnxWrapper::setInterestFilter(string prefix, function<void (string)> interestCallback)
+int CcnxWrapper::setInterestFilter (const string &prefix, const InterestCallback &interestCallback)
 {
   ccn_charbuf *pname = ccn_charbuf_create();
   ccn_closure *interestClosure = new ccn_closure;
-  function<void (string)> *f = new function<void (string)>(interestCallback);
 
-  ccn_name_from_uri(pname, prefix.c_str());
-  interestClosure->data = f;
+  ccn_name_from_uri (pname, prefix.c_str());
+  interestClosure->data = new InterestCallback (interestCallback); // should be removed when closure is removed
   interestClosure->p = &incomingInterest;
-  ccn_set_interest_filter(m_handle, pname, interestClosure);
+  ccn_set_interest_filter (m_handle, pname, interestClosure);
 
   ccn_charbuf_destroy(&pname);
 }
