API change for closure. Return ParsedContentObject, not just content

Fixed bug in test/test-sync-core.cc: there should have been two independent schedulers
diff --git a/ccnx/ccnx-closure.cpp b/ccnx/ccnx-closure.cpp
index a96bbbe..312af6d 100644
--- a/ccnx/ccnx-closure.cpp
+++ b/ccnx/ccnx-closure.cpp
@@ -46,7 +46,7 @@
 
 
 void
-Closure::runDataCallback(const Name &name, const Bytes &content)
+Closure::runDataCallback(const Name &name, PcoPtr content)
 {
   if (!m_dataCallback.empty ())
     {
diff --git a/ccnx/ccnx-closure.h b/ccnx/ccnx-closure.h
index 39fbc16..343d8be 100644
--- a/ccnx/ccnx-closure.h
+++ b/ccnx/ccnx-closure.h
@@ -27,10 +27,13 @@
 
 namespace Ccnx {
 
+class ParsedContentObject;
+typedef boost::shared_ptr<ParsedContentObject> PcoPtr;
+
 class Closure
 {
 public:
-  typedef boost::function<void (const Name &, const Bytes &)> DataCallback;
+  typedef boost::function<void (const Name &, PcoPtr pco)> DataCallback;
 
   typedef enum
   {
@@ -44,7 +47,7 @@
   virtual ~Closure();
 
   virtual void
-  runDataCallback(const Name &name, const Bytes &content);
+  runDataCallback(const Name &name, Ccnx::PcoPtr pco);
 
   virtual TimeoutCallbackReturnValue
   runTimeoutCallback(const Name &interest);
diff --git a/ccnx/ccnx-pco.cpp b/ccnx/ccnx-pco.cpp
index 8c2fd3f..2c4e351 100644
--- a/ccnx/ccnx-pco.cpp
+++ b/ccnx/ccnx-pco.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-pco.h"
 
 namespace Ccnx {
@@ -5,13 +26,14 @@
 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(data, len, &m_pco, m_comps);
+  int res = ccn_parse_ContentObject(head (m_bytes), len, &m_pco, m_comps);
   if (res < 0)
   {
     boost::throw_exception(MisformedContentObjectException());
   }
-  readRaw(m_bytes, data, len);
 }
 
 ParsedContentObject::ParsedContentObject(const unsigned char *data, size_t len)
@@ -43,13 +65,13 @@
 {
   const unsigned char *content;
   size_t len;
-  Bytes bytes;
   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(MisformedContentObjectException());
   }
 
+  Bytes bytes;
   readRaw(bytes, content, len);
   return bytes;
 }
diff --git a/ccnx/ccnx-pco.h b/ccnx/ccnx-pco.h
index 0c52c7a..cecc763 100644
--- a/ccnx/ccnx-pco.h
+++ b/ccnx/ccnx-pco.h
@@ -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>
+ */
+
 #ifndef CCNX_CONTENT_OBJECT_H
 #define CCNX_CONTENT_OBJECT_H
 
@@ -5,16 +26,15 @@
 #include "ccnx-common.h"
 #include "ccnx-name.h"
 
-using namespace std;
-
 namespace Ccnx {
 
-struct MisformedContentObjectException : virtual boost::exception, virtual exception { };
+struct MisformedContentObjectException : virtual boost::exception, virtual std::exception { };
 
 class ParsedContentObject
 {
 public:
   ParsedContentObject(const unsigned char *data, size_t len);
+  ParsedContentObject(const unsigned char *data, const ccn_parsed_ContentObject &pco);
   ParsedContentObject(const Bytes &bytes);
   ParsedContentObject(const ParsedContentObject &other);
   virtual ~ParsedContentObject();
@@ -24,7 +44,7 @@
 
   BytesPtr
   contentPtr() const;
-  
+
   Name
   name() const;
 
diff --git a/ccnx/ccnx-wrapper.cpp b/ccnx/ccnx-wrapper.cpp
index fcaf224..7f2e567 100644
--- a/ccnx/ccnx-wrapper.cpp
+++ b/ccnx/ccnx-wrapper.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-wrapper.h"
 extern "C" {
 #include <ccn/fetch.h>
@@ -6,6 +27,7 @@
 #include <boost/throw_exception.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/random.hpp>
+#include <boost/make_shared.hpp>
 #include <sstream>
 
 typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
@@ -265,21 +287,23 @@
       return CCN_UPCALL_RESULT_OK;
     }
 
-  const unsigned char *pcontent;
-  size_t len;
-  if (ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E], info->pco, &pcontent, &len) < 0)
-  {
-    // BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("decode ContentObject failed"));
-  }
+  PcoPtr pco = make_shared<ParsedContentObject> (info->content_ccnb, info->pco->offset[CCN_PCO_E]);
 
-  Name name(info->content_ccnb, info->content_comps);
+  // const unsigned char *pcontent;
+  // size_t len;
+  // if (ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E], info->pco, &pcontent, &len) < 0)
+  // {
+  //   // BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("decode ContentObject failed"));
+  // }
 
-  Bytes content;
-  // copy content and do processing on the copy
-  // otherwise the pointed memory may have been changed during the processing
-  readRaw(content, pcontent, len);
+  // Name name(info->content_ccnb, info->content_comps);
 
-  cp->runDataCallback(name, content);
+  // Bytes content;
+  // // copy content and do processing on the copy
+  // // otherwise the pointed memory may have been changed during the processing
+  // readRaw(content, pcontent, len);
+
+  cp->runDataCallback (pco->name (), pco);
 
   return CCN_UPCALL_RESULT_OK;
 }
diff --git a/ccnx/ccnx-wrapper.h b/ccnx/ccnx-wrapper.h
index 938b890..cfd030b 100644
--- a/ccnx/ccnx-wrapper.h
+++ b/ccnx/ccnx-wrapper.h
@@ -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>
+ */
+
 #ifndef CCNX_WRAPPER_H
 #define CCNX_WRAPPER_H
 
@@ -9,12 +30,11 @@
 #include "ccnx-name.h"
 #include "ccnx-selectors.h"
 #include "ccnx-closure.h"
-
-using namespace std;
+#include "ccnx-pco.h"
 
 namespace Ccnx {
 
-struct CcnxOperationException : virtual boost::exception, virtual exception { };
+struct CcnxOperationException : virtual boost::exception, virtual std::exception { };
 
 class CcnxWrapper
 {
diff --git a/ccnx/ccnx-tunnel.cpp b/disabled/ccnx-tunnel.cpp
similarity index 100%
rename from ccnx/ccnx-tunnel.cpp
rename to disabled/ccnx-tunnel.cpp
diff --git a/ccnx/ccnx-tunnel.h b/disabled/ccnx-tunnel.h
similarity index 100%
rename from ccnx/ccnx-tunnel.h
rename to disabled/ccnx-tunnel.h
diff --git a/test/test-ccnx-tunnel.cc b/disabled/test-ccnx-tunnel.cc
similarity index 100%
rename from test/test-ccnx-tunnel.cc
rename to disabled/test-ccnx-tunnel.cc
diff --git a/src/fetch-manager.cc b/src/fetch-manager.cc
index cb94992..7df2687 100644
--- a/src/fetch-manager.cc
+++ b/src/fetch-manager.cc
@@ -103,7 +103,7 @@
 
 void
 FetchManager::DidDataSegmentFetched (Fetcher &fetcher, uint32_t seqno, const Ccnx::Name &basename,
-                                     const Ccnx::Name &name, const Bytes &data)
+                                     const Ccnx::Name &name, Ccnx::PcoPtr data)
 {
   // do something
 }
diff --git a/src/fetch-manager.h b/src/fetch-manager.h
index 496d0fd..cfceef5 100644
--- a/src/fetch-manager.h
+++ b/src/fetch-manager.h
@@ -30,7 +30,6 @@
 #include "scheduler.h"
 
 #include "ccnx-wrapper.h"
-#include "ccnx-tunnel.h"
 #include "sync-log.h"
 
 #include "fetcher.h"
@@ -60,7 +59,7 @@
   // Fetch Events
   void
   DidDataSegmentFetched (Fetcher &fetcher, uint32_t seqno, const Ccnx::Name &basename,
-                         const Ccnx::Name &name, const Ccnx::Bytes &data);
+                         const Ccnx::Name &name, Ccnx::PcoPtr data);
 
   void
   DidNoDataTimeout (Fetcher &fetcher);
diff --git a/src/fetcher.cc b/src/fetcher.cc
index edbabb4..f009819 100644
--- a/src/fetcher.cc
+++ b/src/fetcher.cc
@@ -99,15 +99,15 @@
 }
 
 void
-Fetcher::OnData (uint32_t seqno, const Ccnx::Name &name, const Ccnx::Bytes &content)
+Fetcher::OnData (uint32_t seqno, const Ccnx::Name &name, PcoPtr data)
 {
   if (m_forwardingHint == Name ())
-    m_onDataSegment (*this, seqno, m_name, name, content);
+    m_onDataSegment (*this, seqno, m_name, name, data);
   else
     {
       try {
-        ParsedContentObject pco (content);
-        m_onDataSegment (*this, seqno, m_name, pco.name (), pco.content ());
+        PcoPtr pco = make_shared<ParsedContentObject> (*data->contentPtr ());
+        m_onDataSegment (*this, seqno, m_name, pco->name (), pco);
       }
       catch (MisformedContentObjectException &e)
         {
diff --git a/src/fetcher.h b/src/fetcher.h
index 271db52..12ad67f 100644
--- a/src/fetcher.h
+++ b/src/fetcher.h
@@ -35,7 +35,7 @@
 {
 public:
   typedef boost::function<void (Fetcher &, uint32_t /*requested seqno*/, const Ccnx::Name & /*requested base name*/,
-                                const Ccnx::Name & /*actual name*/, const Ccnx::Bytes &)> OnDataSegmentCallback;
+                                const Ccnx::Name & /*actual name*/, Ccnx::PcoPtr /*content object*/)> OnDataSegmentCallback;
   typedef boost::function<void (Fetcher &)> OnFetchCompleteCallback;
   typedef boost::function<void (Fetcher &)> OnFetchFailedCallback;
 
@@ -62,7 +62,7 @@
   FillPipeline ();
 
   void
-  OnData (uint32_t seqno, const Ccnx::Name &name, const Ccnx::Bytes &);
+  OnData (uint32_t seqno, const Ccnx::Name &name, Ccnx::PcoPtr data);
 
   Ccnx::Closure::TimeoutCallbackReturnValue
   OnTimeout (uint32_t seqno, const Ccnx::Name &name);
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 14f4110..9861c44 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -32,7 +32,7 @@
 static void
 printMsg(SyncStateMsgPtr &msg)
 {
-  cout << " ===== start Msg ======" << endl;
+  cerr << " ===== start Msg ======" << endl;
   int size = msg->state_size();
   if (size > 0)
   {
@@ -43,17 +43,17 @@
       string strName = state.name();
       string strLocator = state.locator();
       sqlite3_int64 seq = state.seq();
-      cout << "Name: " << Name((const unsigned char *)strName.c_str(), strName.size());
-      cout << ", Locator: " << Name((const unsigned char *)strLocator.c_str(), strLocator.size());
-      cout << ", seq: " << seq << endl;
+      cerr << "Name: " << Name((const unsigned char *)strName.c_str(), strName.size());
+      cerr << ", Locator: " << Name((const unsigned char *)strLocator.c_str(), strLocator.size());
+      cerr << ", seq: " << seq << endl;
       index ++;
     }
   }
   else
   {
-    cout << "Msg size 0" << endl;
+    cerr << "Msg size 0" << endl;
   }
-  cout << " ++++++++ end Msg  ++++++++ \n\n" << endl;
+  cerr << " ++++++++ end Msg  ++++++++ \n\n" << endl;
 }
 
 SyncCore::SyncCore(SyncLogPtr syncLog, const Name &userName, const Name &localPrefix, const Name &syncPrefix, const StateMsgCallback &callback, const CcnxWrapperPtr &handle, const SchedulerPtr &scheduler)
@@ -128,7 +128,7 @@
   Bytes syncData;
   msgToBytes(msg, syncData);
   m_handle->publishData(syncName, syncData, FRESHNESS);
-  cout << m_log->GetLocalName () << " publishes: " << *oldHash << endl;
+  cerr << m_log->GetLocalName () << " publishes: " << *oldHash << endl;
   printMsg(msg);
 
   // no hurry in sending out new Sync Interest; if others send the new Sync Interest first, no problem, we know the new root hash already;
@@ -172,7 +172,7 @@
     assert(msg->state_size() > 0);
     int size = msg->state_size();
     int index = 0;
-    cout << "Reply recover interest with: " << endl;
+    cerr << "Reply recover interest with: " << endl;
     while (index < size)
     {
       SyncState state = msg->state(index);
@@ -194,7 +194,7 @@
     Bytes syncData;
     msgToBytes(msg, syncData);
     m_handle->publishData(name, syncData, FRESHNESS);
-    cout << m_log->GetLocalName () << " publishes " << hash << endl;
+    cerr << m_log->GetLocalName () << " publishes " << hash << endl;
     printMsg(msg);
   }
   else
@@ -211,29 +211,29 @@
   if (*hash == *m_rootHash)
   {
     // we have the same hash; nothing needs to be done
-    cout << "same as root hash: " << *hash << endl;
+    cerr << "same as root hash: " << *hash << endl;
     return;
   }
   else if (m_log->LookupSyncLog(*hash) > 0)
   {
     // we know something more
-    cout << "found hash in sync log" << endl;
+    cerr << "found hash in sync log" << endl;
     SyncStateMsgPtr msg = m_log->FindStateDifferences(*hash, *m_rootHash);
 
     Bytes syncData;
     msgToBytes(msg, syncData);
     m_handle->publishData(name, syncData, FRESHNESS);
-    cout << m_log->GetLocalName () << " publishes: " << *hash << endl;
+    cerr << m_log->GetLocalName () << " publishes: " << *hash << endl;
     printMsg(msg);
   }
   else
   {
     // we don't recognize the hash, send recover Interest if still don't know the hash after a randomized wait period
     ostringstream ss;
-    ss << *hash;
+    ss << "r-" << *hash;
     double wait = m_recoverWaitGenerator->nextInterval();
-    cout << m_log->GetLocalName () << ", rootHash: " << *m_rootHash << ", hash: " << *hash << endl;
-    cout << "recover task scheduled after wait: " << wait << endl;
+    cerr << m_log->GetLocalName () << ", rootHash: " << *m_rootHash << ", hash: " << *hash << endl;
+    cerr << "recover task scheduled after wait: " << wait << endl;
     TaskPtr task(new OneTimeTask(boost::bind(&SyncCore::recover, this, hash), ss.str(), m_scheduler, wait));
     m_scheduler->addTask(task);
 
@@ -259,18 +259,18 @@
 }
 
 void
-SyncCore::handleRecoverData(const Name &name, const Bytes &content)
+SyncCore::handleRecoverData(const Name &name, PcoPtr content)
 {
   //cout << "handle recover data" << endl;
-  handleStateData(content);
+  handleStateData(*content->contentPtr ());
   sendSyncInterest();
 }
 
 void
-SyncCore::handleSyncData(const Name &name, const Bytes &content)
+SyncCore::handleSyncData(const Name &name, PcoPtr content)
 {
   // suppress recover in interest - data out of order case
-  handleStateData(content);
+  handleStateData(*content->contentPtr ());
 
   // resume outstanding sync interest
   sendSyncInterest();
@@ -288,7 +288,7 @@
     return;
   }
 
-  cout << m_log->GetLocalName () << " receives Msg " << endl;
+  cerr << m_log->GetLocalName () << " receives Msg " << endl;
   printMsg (msg);
   int size = msg->state_size();
   int index = 0;
@@ -311,12 +311,12 @@
         m_log->UpdateLocator(deviceName, locatorName);
         // WriteLock lock(m_ypMutex);
         // m_yp[deviceName] = locatorName;
-        cout << "self: " << m_log->GetLocalName () << ", device: " << deviceName << " < == > " << locatorName << endl;
+        cerr << "self: " << m_log->GetLocalName () << ", device: " << deviceName << " < == > " << locatorName << endl;
       }
     }
     else
     {
-      cout << "nani" << endl;
+      cerr << "nani" << endl;
       deregister(deviceName);
     }
     index++;
@@ -339,7 +339,7 @@
 {
   Name syncInterest = constructSyncName(m_rootHash);
   m_handle->sendInterest(syncInterest, m_syncClosure);
-  cout << m_log->GetLocalName () << " send SYNC interest: " << *m_rootHash << endl;
+  cerr << m_log->GetLocalName () << " send SYNC interest: " << *m_rootHash << endl;
 }
 
 void
@@ -347,7 +347,7 @@
 {
   if (!(*hash == *m_rootHash) && m_log->LookupSyncLog(*hash) <= 0)
   {
-    cout << m_log->GetLocalName () << ", Recover for: " << *hash << endl;
+    cerr << m_log->GetLocalName () << ", Recover for: " << *hash << endl;
     // unfortunately we still don't recognize this hash
     Bytes bytes;
     readRaw(bytes, (const unsigned char *)hash->GetHash(), hash->GetHashBytes());
@@ -356,7 +356,7 @@
     // append the unknown hash
     recoverInterest.appendComp(bytes);
     m_handle->sendInterest(recoverInterest, m_recoverClosure);
-    cout << m_log->GetLocalName () << " send RECOVER Interest: " << *hash << endl;
+    cerr << m_log->GetLocalName () << " send RECOVER Interest: " << *hash << endl;
   }
   else
   {
diff --git a/src/sync-core.h b/src/sync-core.h
index 7d46ccb..f77b133 100644
--- a/src/sync-core.h
+++ b/src/sync-core.h
@@ -72,10 +72,10 @@
   handleInterest(const Name &name);
 
   void
-  handleSyncData(const Name &name, const Bytes &content);
+  handleSyncData(const Name &name, Ccnx::PcoPtr content);
 
   void
-  handleRecoverData(const Name &name, const Bytes &content);
+  handleRecoverData(const Name &name, Ccnx::PcoPtr content);
 
   Closure::TimeoutCallbackReturnValue
   handleSyncInterestTimeout(const Name &name);
diff --git a/test/test-ccnx-wrapper.cc b/test/test-ccnx-wrapper.cc
index b64f513..d5188de 100644
--- a/test/test-ccnx-wrapper.cc
+++ b/test/test-ccnx-wrapper.cc
@@ -31,9 +31,10 @@
   c2->publishData(name, (const unsigned char*)content.c_str(), content.size(), 5);
 }
 
-void dataCallback(const Name &name, const Bytes &content)
+void dataCallback(const Name &name, Ccnx::PcoPtr pco)
 {
-  string msg((const char*)&content[0], content.size());
+  BytesPtr content = pco->contentPtr ();
+  string msg(reinterpret_cast<const char *> (head (*content)), content->size());
   g_dataCallback_counter ++;
   BOOST_CHECK_EQUAL(name, msg);
 }
diff --git a/test/test-fetch-manager.cc b/test/test-fetch-manager.cc
index 55c85df..276fe0c 100644
--- a/test/test-fetch-manager.cc
+++ b/test/test-fetch-manager.cc
@@ -50,15 +50,17 @@
 
   void
   onData (Fetcher &fetcher, uint32_t seqno, const Ccnx::Name &basename,
-          const Ccnx::Name &name, const Ccnx::Bytes &data)
+          const Ccnx::Name &name, Ccnx::PcoPtr pco)
   {
     recvData.insert (seqno);
     differentNames.insert (basename);
     segmentNames.insert (name);
 
-    if (data.size () == sizeof(int))
+    BytesPtr data = pco->contentPtr ();
+
+    if (data->size () == sizeof(int))
       {
-        recvContent.insert (*reinterpret_cast<const int*> (head(data)));
+        recvContent.insert (*reinterpret_cast<const int*> (head(*data)));
       }
 
     // cout << "<<< " << basename << ", " << name << ", " << seqno << endl;
diff --git a/test/test-sync-core.cc b/test/test-sync-core.cc
index 2caa99b..b8316c1 100644
--- a/test/test-sync-core.cc
+++ b/test/test-sync-core.cc
@@ -3,9 +3,11 @@
 
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
+#include <boost/make_shared.hpp>
 
 using namespace std;
 using namespace Ccnx;
+using namespace boost;
 using namespace boost::filesystem;
 
 BOOST_AUTO_TEST_SUITE(SyncCoreTests)
@@ -55,16 +57,17 @@
   SyncLogPtr log1(new SyncLog(dir1, user1.toString()));
   SyncLogPtr log2(new SyncLog(dir2, user2.toString()));
 
-  SchedulerPtr scheduler(new Scheduler());
+  // should not have used the same scheduler...
+  SchedulerPtr scheduler1 = make_shared<Scheduler> ();
+  SchedulerPtr scheduler2 = make_shared<Scheduler> ();
 
-
-  SyncCore *core1 = new SyncCore(log1, user1, loc1, syncPrefix, bind(callback, _1), c1, scheduler);
+  SyncCore *core1 = new SyncCore(log1, user1, loc1, syncPrefix, bind(callback, _1), c1, scheduler1);
   usleep(10000);
-  SyncCore *core2 = new SyncCore(log2, user2, loc2, syncPrefix, bind(callback, _1), c2, scheduler);
+  SyncCore *core2 = new SyncCore(log2, user2, loc2, syncPrefix, bind(callback, _1), c2, scheduler2);
   usleep(1000000);
   checkRoots(core1->root(), core2->root());
 
-  cout << "\n\n\n\n\n\n----------\n";
+  // cout << "\n\n\n\n\n\n----------\n";
   core1->updateLocalState(1);
   usleep(100000);
   checkRoots(core1->root(), core2->root());
@@ -84,11 +87,11 @@
   BOOST_CHECK_EQUAL(log1->LookupLocator (user2), loc2);
 
   // simple simultaneous data generation
-  cout << "\n\n\n\n\n\n----------Simultaneous\n";
+  // cout << "\n\n\n\n\n\n----------Simultaneous\n";
   core1->updateLocalState(11);
   usleep(100);
   core2->updateLocalState(15);
-  usleep(1000000);
+  usleep(2000000);
   checkRoots(core1->root(), core2->root());
   BOOST_CHECK_EQUAL(core1->seq(user2), 15);
   BOOST_CHECK_EQUAL(core2->seq(user1), 11);