diff --git a/model/sync-app-data-fetch.cc b/model/sync-app-data-fetch.cc
deleted file mode 100644
index 5cfabce..0000000
--- a/model/sync-app-data-fetch.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "sync-app-data-fetch.h"
-#include "sync-log.h"
-
-using namespace std;
-using namespace boost;
-
-namespace Sync
-{
-
-INIT_LOGGER ("AppDataFetch");
-
-void
-AppDataFetch::onUpdate (const std::string &prefix, const SeqNo &newSeq, const SeqNo &oldSeq)
-{
-  _LOG_FUNCTION (this << ", " << prefix << ", " << newSeq << ", " << oldSeq);
-  
-  // sequence number logic here
-  uint32_t start = 0;
-  if (oldSeq.isValid () && oldSeq.getSession() == newSeq.getSession())
-    {
-      start = oldSeq.getSeq () + 1;
-    }
-  uint32_t end = newSeq.getSeq ();
-
-  //
-  // add logic for wrap around
-  //
-
-  for (uint32_t i = start; i <= end; i++)
-    {
-      ostringstream interestName;
-      interestName << prefix << "/" << newSeq.getSession () << "/" << i;
-      m_ccnxHandle->sendInterest (interestName.str (), m_dataCallback);
-    }
-}
-
-void
-AppDataFetch::onRemove (const std::string &prefix)
-{
-  _LOG_FUNCTION (this << ", " << prefix);
-  
-  // I guess this should be somewhere in app
-}
-
-}
diff --git a/model/sync-app-data-fetch.h b/model/sync-app-data-fetch.h
deleted file mode 100644
index 1e42860..0000000
--- a/model/sync-app-data-fetch.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SYNC_APP_DATA_FETCH_H
-#define SYNC_APP_DATA_FETCH_H
-
-#include "sync-ccnx-wrapper.h"
-#include "sync-seq-no.h"
-
-namespace Sync {
-
-/**
- * \ingroup sync
- * @brief fetch application data, by default it will try to fetch every piece
- * of data
- */
-class AppDataFetch
-{
-public:
-  /**
-   * @brief Constructor
-   * @param ccnxHandle handle for CCNx
-   * @param dataCallback the callback function to process data
-   */
-  AppDataFetch (CcnxWrapperPtr ccnxHandle,
-                CcnxWrapper::DataCallback dataCallback)
-    : m_ccnxHandle (ccnxHandle)
-    , m_dataCallback (dataCallback)
-  { }
-
-  /**
-   * @brief Set data callback
-   * @param dataCallback the callback function to process data
-   */
-  void
-  setDataCallback(CcnxWrapper::DataCallback dataCallback)
-  {
-    m_dataCallback = dataCallback;
-  }
-
-  /**
-   * @brief Fired from SyncLogic when new data is available
-   *
-   * @param prefix the prefix for the data
-   * @param newSeq old session ID/sequence number
-   * @param oldSeq new session ID/sequence number
-   */
-  void
-  onUpdate (const std::string &prefix, const SeqNo &newSeq, const SeqNo &oldSeq);
-
-  /**
-   * @brief Fired from SyncLogic when data is removed
-   *
-   * @param prefix the prefix for the data
-   */
-  void
-  onRemove (const std::string &prefix);
-  
-private:
-  CcnxWrapperPtr m_ccnxHandle;
-  CcnxWrapper::DataCallback m_dataCallback;
-};
-
-
-} // Sync
-
-#endif // SYNC_APP_DATA_FETCH_H
diff --git a/model/sync-app-data-publish.cc b/model/sync-app-data-publish.cc
deleted file mode 100644
index e7bee97..0000000
--- a/model/sync-app-data-publish.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "sync-app-data-publish.h"
-#include <boost/throw_exception.hpp>
-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 Sync
-{
-
-
-string
-AppDataPublish::getRecentData (const string &prefix, uint32_t session)
-{
-  if (m_recentData.find(make_pair(prefix, session)) != m_recentData.end())
-    return m_recentData[make_pair(prefix, session)];
-  else
-    return "";
-}
-
-uint32_t
-AppDataPublish::getNextSeq (const string &prefix, uint32_t session)
-{
-  SequenceLog::iterator i = m_sequenceLog.find (prefix);
-
-  if (i != m_sequenceLog.end ())
-    {
-      Seq s = i->second;
-      if (s.session == session)
-        return s.seq;
-    }
-  return 0;
-}
-
-uint32_t
-AppDataPublish::publishData (const string &name, uint32_t session, const string &dataBuffer, int freshness)
-{
-  uint32_t seq = getNextSeq (name, session);
-
-  ostringstream contentNameWithSeqno;
-  contentNameWithSeqno << name << "/" << session << "/" << seq;
-
-  m_ccnxHandle->publishData (contentNameWithSeqno.str (), dataBuffer, freshness);
-
-  Seq s;
-  s.session = session;
-  s.seq = seq + 1;
-  m_sequenceLog[name] = s;
-
-  unordered_map<pair<string, uint32_t>, string>::iterator it = m_recentData.find(make_pair(name, session));
-   if (it != m_recentData.end()) 
-     m_recentData.erase(it);
-   m_recentData.insert(make_pair(make_pair(name, session), dataBuffer));
-
-  return seq;
-}
-
-} // Sync
diff --git a/model/sync-app-data-publish.h b/model/sync-app-data-publish.h
deleted file mode 100644
index ec95a60..0000000
--- a/model/sync-app-data-publish.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SYNC_APP_DATA_PUBLISH_H
-#define SYNC_APP_DATA_PUBLISH_H
-
-#include <boost/unordered_map.hpp>
-#include "sync-seq-no.h"
-#include "sync-ccnx-wrapper.h"
-#include <utility>
-#include <map>
-
-namespace Sync {
-
-struct Seq
-{
-  uint32_t session;
-  uint32_t seq;
-};
-
-struct GetSeqException : virtual boost::exception, virtual std::exception { };
-
-/**
- * \ingroup sync
- * @brief publishes application data using incrementing sequence number (for
- * each sequence namber and keeps track of most recently published data for
- * each name prefix
- */
-class AppDataPublish
-{
-public:
-  AppDataPublish (CcnxWrapperPtr ccnxHandle)
-  : m_ccnxHandle (ccnxHandle)
-  { }
-
-  /**
-   * @brief get the name (including sequence number) and the content
-   * (unencoded, just XML stanza) of the most recent published data
-   *
-   * @param prefix the name prefix to look for
-   * @param session session
-   * @return the pair of name and content
-   */
-  std::string
-  getRecentData (const std::string &prefix, uint32_t session);
-
-  /**
-   * @brief get the most recent sequence number for a name prefix
-   * @param prefix the name prefix to look for
-   * @param session session
-   */
-  uint32_t
-  getNextSeq (const std::string &prefix, uint32_t session);
-
-  /**
-   * @brief publish data for a name prefix, updates the corresponding
-   * sequence number and recent data
-   *
-   * @param name data prefix
-   * @param session session to which data is published
-   * @param dataBuffer the data itself
-   * @param freshness the freshness for the data object
-   * @return published sequence number, will throw an exception if something wrong happened
-   */
-  uint32_t publishData (const std::string &name, uint32_t session, const std::string &dataBuffer, int freshness);
-
-private:
-  typedef boost::unordered_map<std::string, Seq> SequenceLog;
-  typedef boost::unordered_map<std::pair<std::string, uint32_t>, std::string> RecentData;
-  
-  CcnxWrapperPtr m_ccnxHandle;
-  SequenceLog m_sequenceLog;
-  RecentData m_recentData;
-};
-
-} // Sync
-
-#endif // SYNC_APP_DATA_PUBLISH_H
diff --git a/model/sync-app-socket-c.cc b/model/sync-app-socket-c.cc
deleted file mode 100644
index 4bdf384..0000000
--- a/model/sync-app-socket-c.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "sync-app-socket.h"
-using namespace std;
-using namespace Sync;
-
-class CallbackHolder{
-private:
-  void (*m_callback)(const char *, const char *);
-
-public:
-  CallbackHolder(void (*callback)(const char*, const char*)):m_callback(callback){};
-  void callbackWrapper(string name, string data) {
-    m_callback(name.c_str(), data.c_str());
-  }
-};
-
-struct SyncAppSocketStruct;
-
-extern "C"
-SyncAppSocketStruct *
-create_sync_app_socket(const char *prefix, void (*callback)(const char *, const char *)) 
-{
-  CallbackHolder *holder = new CallbackHolder(callback);
-  boost::function<void (string, string)> cb = bind(&CallbackHolder::callbackWrapper, holder, _1, _2);
-  SyncAppSocket *sock = new SyncAppSocket(prefix, cb);
-  return (SyncAppSocketStruct *) sock;
-}
-
-extern "C"
-void
-delete_sync_app_socket(SyncAppSocketStruct **sock) {
-  SyncAppSocket *temp = *((SyncAppSocket **)sock);
-  delete temp;
-  temp = NULL;
-}
-
-// assume char *buf ends with '\0', or otherwise it's going to crash;
-// should fix this "feature"
-extern "C" 
-int
-sync_app_socket_publish(SyncAppSocketStruct *sock, const char *prefix, int session, const char *buf, int freshness) 
-{
-  SyncAppSocket *temp = (SyncAppSocket *)sock;
-  return temp->publish(prefix, session, buf, freshness);
-}
-
-extern "C"
-void
-sync_app_socket_remove(SyncAppSocketStruct *sock, const char *prefix) 
-{
-  SyncAppSocket *temp = (SyncAppSocket *)sock;
-  temp->remove(prefix);
-}
diff --git a/model/sync-app-socket.cc b/model/sync-app-socket.cc
deleted file mode 100644
index 848a6d0..0000000
--- a/model/sync-app-socket.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "sync-app-socket.h"
-
-using namespace std;
-using namespace boost;
-
-namespace Sync
-{
-
-SyncAppSocket::SyncAppSocket (const string &syncPrefix, CcnxWrapper::DataCallback dataCallback)
-	: m_appHandle (new CcnxWrapper())
-  , m_fetcher (m_appHandle, dataCallback)
-  , m_publisher (m_appHandle)
-  , m_syncLogic (syncPrefix,
-                 bind (&AppDataFetch::onUpdate, m_fetcher, _1, _2, _3),
-                 bind (&AppDataFetch::onRemove, m_fetcher, _1))
-{
-}
-
-SyncAppSocket::~SyncAppSocket()
-{
-}
-
-bool SyncAppSocket::publish (const string &prefix, uint32_t session, const string &dataBuffer, int freshness)
-{
-  uint32_t sequence = m_publisher.publishData (prefix, session, dataBuffer, freshness);
-  m_syncLogic.addLocalNames (prefix, session, sequence);
-}
-
-}
diff --git a/model/sync-app-socket.h b/model/sync-app-socket.h
deleted file mode 100644
index d17857c..0000000
--- a/model/sync-app-socket.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SYNC_APP_SOCKET_H
-#define SYNC_APP_SOCKET_H
-
-#include "sync-logic.h"
-#include "sync-app-data-fetch.h"
-#include "sync-app-data-publish.h"
-#include <boost/function.hpp>
-
-namespace Sync {
-
-/**
- * \ingroup sync
- * @brief A simple interface to interact with client code
- */
-class SyncAppSocket
-{
-public:
-  /**
-   * @brief the constructor for SyncAppSocket; the parameter syncPrefix
-   * should be passed to the constructor of m_syncAppWrapper; the other
-   * parameter should be passed to the constructor of m_fetcher; furthermore,
-   * the fetch function of m_fetcher should be a second paramter passed to
-   * the constructor of m_syncAppWrapper, so that m_syncAppWrapper can tell
-   * m_fetcher to fetch the actual app data after it learns the names
-   *
-   * @param syncPrefix the name prefix for Sync Interest
-   * @param dataCallback the callback to process data
-   */
-  SyncAppSocket (const std::string &syncPrefix, CcnxWrapper::DataCallback dataCallback);
-  ~SyncAppSocket ();
-
-  /**
-   * @brief publish data from local client and tell SyncLogic to update
-   * the sync tree by adding the local names
-   *
-   * @param prefix the name prefix for the data
-   * @param session session to which data is published
-   * @param dataBuffer the data itself
-   * @param freshness the freshness time for the data (in seconds)
-   */
-  bool publish (const std::string &prefix, uint32_t session, const std::string &dataBuffer, int freshness);
-
-  /**
-   * @brief delete a participant's subtree from the sync tree; SyncLogic will do the work
-   * this is just a wrapper
-   *
-   * @param prefix the prefix for the participant
-   */
-  void remove (const std::string &prefix) {m_syncLogic.remove(prefix);}
-
-private:
-  CcnxWrapperPtr m_appHandle;
-
-  AppDataFetch   m_fetcher;
-  AppDataPublish m_publisher;
-  SyncLogic      m_syncLogic;
-};
-
-} // Sync
-
-#endif // SYNC_APP_SOCKET_H
diff --git a/model/sync-ccnx-wrapper.cc b/model/sync-ccnx-wrapper.cc
deleted file mode 100644
index ea0f876..0000000
--- a/model/sync-ccnx-wrapper.cc
+++ /dev/null
@@ -1,336 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "sync-ccnx-wrapper.h"
-#include "sync-log.h"
-#include <poll.h>
-#include <boost/throw_exception.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-
-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;
-
-INIT_LOGGER ("CcnxWrapper");
-
-namespace Sync {
-
-#ifdef _DEBUG_WRAPPER_      
-CcnxWrapper::CcnxWrapper(char c)
-#else
-CcnxWrapper::CcnxWrapper()
-#endif
-  : m_handle (0)
-  , m_keyStore (0)
-  , m_keyLoactor (0)
-  , m_running (true)
-{
-#ifdef _DEBUG_WRAPPER_      
-  m_c = c;
-#endif
-  m_handle = ccn_create ();
-  initKeyStore ();
-  createKeyLocator ();
-  if (ccn_connect(m_handle, NULL) < 0)
-    BOOST_THROW_EXCEPTION (CcnxOperationException() << errmsg_info_str("connection to ccnd failed"));
-  m_thread = thread (&CcnxWrapper::ccnLoop, this);
-}
-
-CcnxWrapper::~CcnxWrapper()
-{
-  // std::cout << "CcnxWrapper::~CcnxWrapper()" << std::endl;
-  {
-    recursive_mutex::scoped_lock lock(m_mutex);
-    m_running = false;
-  }
-  
-  m_thread.join ();
-  ccn_disconnect (m_handle);
-  ccn_destroy (&m_handle);
-  ccn_charbuf_destroy (&m_keyLoactor);
-  ccn_keystore_destroy (&m_keyStore);
-}
-
-/// @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));
-  if (res >= 0)
-    {
-      ccn_charbuf_append_closer (m_keyLoactor); /* </Key> */
-      ccn_charbuf_append_closer (m_keyLoactor); /* </KeyLocator> */
-    }
-}
-
-const ccn_pkey*
-CcnxWrapper::getPrivateKey ()
-{
-  return ccn_keystore_private_key (m_keyStore);
-}
-
-const unsigned char*
-CcnxWrapper::getPublicKeyDigest ()
-{
-  return ccn_keystore_public_key_digest(m_keyStore);
-}
-
-ssize_t
-CcnxWrapper::getPublicKeyDigestLength ()
-{
-  return ccn_keystore_public_key_digest_length(m_keyStore);
-}
-
-void
-CcnxWrapper::initKeyStore ()
-{
-  m_keyStore = ccn_keystore_create ();
-  string keyStoreFile = string(getenv("HOME")) + string("/.ccnx/.ccnx_keystore");
-  if (ccn_keystore_init (m_keyStore, (char *)keyStoreFile.c_str(), (char*)"Th1s1sn0t8g00dp8ssw0rd.") < 0)
-    BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str(keyStoreFile.c_str()));
-}
-
-void
-CcnxWrapper::ccnLoop ()
-{
-  _LOG_FUNCTION (this);
-
-  while (m_running)
-    {
-#ifdef _DEBUG_WRAPPER_      
-      std::cout << m_c << flush;
-#endif
-      int res = 0;
-      {
-        recursive_mutex::scoped_lock lock (m_mutex);
-        res = ccn_run (m_handle, 0);
-
-      }
-
-      if (!m_running) break;
-      
-      if (res < 0)
-        BOOST_THROW_EXCEPTION (CcnxOperationException()
-                               << errmsg_info_str("ccn_run returned error"));
-
-
-      pollfd pfds[1];
-      {
-        recursive_mutex::scoped_lock 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 (CcnxOperationException() << errmsg_info_str("ccnd socket failed (probably ccnd got stopped)"));
-        }
-    }
-}
-
-/// @endcond
-
-int
-CcnxWrapper::publishData (const string &name, const string &dataBuffer, int freshness)
-{
-  recursive_mutex::scoped_lock lock(m_mutex);
-  if (!m_running)
-    return -1;
-  
-  // cout << "Publish: " << name << endl;
-  ccn_charbuf *pname = ccn_charbuf_create();
-  ccn_charbuf *signed_info = ccn_charbuf_create();
-  ccn_charbuf *content = ccn_charbuf_create();
-
-  ccn_name_from_uri(pname, name.c_str());
-  ccn_signed_info_create(signed_info,
-			 getPublicKeyDigest(),
-			 getPublicKeyDigestLength(),
-			 NULL,
-			 CCN_CONTENT_DATA,
-			 freshness,
-			 NULL,
-			 m_keyLoactor);
-  if(ccn_encode_ContentObject(content, pname, signed_info,
-			   dataBuffer.c_str(), dataBuffer.length (),
-			   NULL, getPrivateKey()) < 0)
-    BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("encode content failed"));
-
-  if (ccn_put(m_handle, content->buf, content->length) < 0)
-    BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("ccnput failed"));
-
-  ccn_charbuf_destroy (&pname);
-  ccn_charbuf_destroy (&signed_info);
-  ccn_charbuf_destroy (&content);
-  return 0;
-}
-
-
-static ccn_upcall_res
-incomingInterest(ccn_closure *selfp,
-                 ccn_upcall_kind kind,
-                 ccn_upcall_info *info)
-{
-  CcnxWrapper::InterestCallback *f = static_cast<CcnxWrapper::InterestCallback*> (selfp->data);
-
-  switch (kind)
-    {
-    case CCN_UPCALL_FINAL: // effective in unit tests
-      delete f;
-      delete selfp;
-      return CCN_UPCALL_RESULT_OK;
-
-    case CCN_UPCALL_INTEREST:
-      break;
-
-    default:
-      return CCN_UPCALL_RESULT_OK;
-    }
-
-  string interest;
-  for (int i = 0; i < info->interest_comps->n - 1; i++)
-    {
-      char *comp;
-      size_t size;
-      interest += "/";
-      ccn_name_comp_get(info->interest_ccnb, info->interest_comps, i, (const unsigned char **)&comp, &size);
-      string compStr(comp, size);
-      interest += compStr;
-    }
-  (*f) (interest);
-  return CCN_UPCALL_RESULT_OK;
-}
-
-static ccn_upcall_res
-incomingData(ccn_closure *selfp,
-             ccn_upcall_kind kind,
-             ccn_upcall_info *info)
-{
-  CcnxWrapper::DataCallback *f = static_cast<CcnxWrapper::DataCallback*> (selfp->data);
-
-  switch (kind)
-    {
-    case CCN_UPCALL_FINAL:  // effecitve in unit tests
-      delete f;
-      delete selfp;
-      return CCN_UPCALL_RESULT_OK;
-
-    case CCN_UPCALL_CONTENT:
-      break;
-
-    default:
-      return CCN_UPCALL_RESULT_OK;
-    }
-
-  char *pcontent;
-  size_t len;
-  if (ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E], info->pco, (const unsigned char **)&pcontent, &len) < 0)
-    BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("decode ContentObject failed"));
-  string content(pcontent, len);
-
-  string name;
-  for (int i = 0; i < info->content_comps->n - 1; i++)
-    {
-      char *comp;
-      size_t size;
-      name += "/";
-      ccn_name_comp_get(info->content_ccnb, info->content_comps, i, (const unsigned char **)&comp, &size);
-      string compStr(comp, size);
-      name += compStr;
-    }
-  (*f) (name, content);
-  return CCN_UPCALL_RESULT_OK;
-}
-
-int CcnxWrapper::sendInterest (const string &strInterest, const DataCallback &dataCallback)
-{
-  recursive_mutex::scoped_lock lock(m_mutex);
-  if (!m_running)
-    return -1;
-  
-  // std::cout << "Send interests for " << strInterest << std::endl;
-  ccn_charbuf *pname = ccn_charbuf_create();
-  ccn_closure *dataClosure = new ccn_closure;
-
-  ccn_name_from_uri (pname, strInterest.c_str());
-  dataClosure->data = new DataCallback (dataCallback); // should be removed when closure is removed
-
-  dataClosure->p = &incomingData;
-  if (ccn_express_interest (m_handle, pname, dataClosure, NULL) < 0)
-    BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("express interest failed"));
-
-  ccn_charbuf_destroy (&pname);
-  return 0;
-}
-
-int CcnxWrapper::setInterestFilter (const string &prefix, const InterestCallback &interestCallback)
-{
-  recursive_mutex::scoped_lock lock(m_mutex);
-  if (!m_running)
-    return -1;
-
-  ccn_charbuf *pname = ccn_charbuf_create();
-  ccn_closure *interestClosure = new ccn_closure;
-
-  ccn_name_from_uri (pname, prefix.c_str());
-  interestClosure->data = new InterestCallback (interestCallback); // should be removed when closure is removed
-  interestClosure->p = &incomingInterest;
-  int ret = ccn_set_interest_filter (m_handle, pname, interestClosure);
-  if (ret < 0)
-    {
-      BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("set interest filter failed") << errmsg_info_int (ret));
-    }
-
-  ccn_charbuf_destroy(&pname);
-}
-
-void
-CcnxWrapper::clearInterestFilter (const std::string &prefix)
-{
-  recursive_mutex::scoped_lock lock(m_mutex);
-  if (!m_running)
-    return;
-
-  std::cout << "clearInterestFilter" << std::endl;
-  ccn_charbuf *pname = ccn_charbuf_create();
-
-  ccn_name_from_uri (pname, prefix.c_str());
-  int ret = ccn_set_interest_filter (m_handle, pname, 0);
-  if (ret < 0)
-    {
-      BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("set interest filter failed") << errmsg_info_int (ret));
-    }
-
-  ccn_charbuf_destroy(&pname);
-}
-
-}
diff --git a/model/sync-ccnx-wrapper.h b/model/sync-ccnx-wrapper.h
deleted file mode 100644
index 0ccbec4..0000000
--- a/model/sync-ccnx-wrapper.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SYNC_CCNX_WRAPPER_H
-#define SYNC_CCNX_WRAPPER_H
-
-extern "C" {
-#include <ccn/ccn.h>
-#include <ccn/charbuf.h>
-#include <ccn/keystore.h>
-#include <ccn/uri.h>
-#include <ccn/bloom.h>
-#include <ccn/signing.h>
-}
-
-#include <boost/exception/all.hpp>
-#include <boost/thread/recursive_mutex.hpp>
-#include <boost/thread/thread.hpp>
-#include <boost/function.hpp>
-#include <string>
-
-/**
- * \defgroup sync SYNC protocol
- *
- * Implementation of SYNC protocol
- */
-namespace Sync {
-
-struct CcnxOperationException : virtual boost::exception, virtual std::exception { };
-/**
- * \ingroup sync
- * @brief A wrapper for ccnx library; clients of this code do not need to deal
- * with ccnx library
- */
-class CcnxWrapper {
-public:
-  typedef boost::function<void (std::string, std::string)> DataCallback;
-  typedef boost::function<void (std::string)> InterestCallback;
-  
-  /**
-   * @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
-   *
-   */
-#ifdef _DEBUG_WRAPPER_      
-  CcnxWrapper(char c='.');
-  char m_c;
-#else
-  CcnxWrapper();
-#endif  
-  ~CcnxWrapper();
-
-  /**
-   * @brief send Interest; need to grab lock m_mutex first
-   *
-   * @param strInterest the Interest name
-   * @param dataCallback the callback function to deal with the returned data
-   * @return the return code of ccn_express_interest
-   */
-  int
-  sendInterest (const std::string &strInterest, const DataCallback &dataCallback);
-
-  /**
-   * @brief set Interest filter (specify what interest you want to receive)
-   *
-   * @param prefix the prefix of Interest
-   * @param interestCallback the callback function to deal with the returned data
-   * @return the return code of ccn_set_interest_filter
-   */
-  int
-  setInterestFilter (const std::string &prefix, const InterestCallback &interestCallback);
-
-  /**
-   * @brief clear Interest filter
-   * @param prefix the prefix of Interest
-   */
-  void
-  clearInterestFilter (const std::string &prefix);
-
-  /**
-   * @brief publish data and put it to local ccn content store; need to grab
-   * lock m_mutex first
-   *
-   * @param name the name for the data object
-   * @param dataBuffer the data to be published
-   * @param freshness the freshness time for the data object
-   * @return code generated by ccnx library calls, >0 if success
-   */
-  int
-  publishData (const std::string &name, const std::string &dataBuffer, int freshness);
-
-private:
-  /// @cond include_hidden 
-  void
-  createKeyLocator ();
-
-  void
-  initKeyStore ();
-
-  const ccn_pkey *
-  getPrivateKey ();
-
-  const unsigned char *
-  getPublicKeyDigest ();
-
-  ssize_t
-  getPublicKeyDigestLength ();
-
-  void
-  ccnLoop ();
-  /// @endcond
-private:
-  ccn* m_handle;
-  ccn_keystore *m_keyStore;
-  ccn_charbuf *m_keyLoactor;
-  // to lock, use "boost::recursive_mutex::scoped_lock scoped_lock(mutex);
-  boost::recursive_mutex m_mutex;
-  boost::thread m_thread;
-  bool m_running;
-};
-
-typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;
-
-} // Sync
-
-#endif // SYNC_CCNX_WRAPPER_H
diff --git a/model/sync-diff-state-container.h b/model/sync-diff-state-container.h
index 6e98aa4..2ae7c59 100644
--- a/model/sync-diff-state-container.h
+++ b/model/sync-diff-state-container.h
@@ -33,36 +33,16 @@
 #include <boost/multi_index/hashed_index.hpp>
 #include <boost/multi_index/sequenced_index.hpp>
 // #include <boost/multi_index/random_access_index.hpp>
-// #include <boost/multi_index/member.hpp>
+#include <boost/multi_index/member.hpp>
 #include <boost/multi_index/mem_fun.hpp>
 
 namespace mi = boost::multi_index;
 
 namespace Sync {
 
-struct DigestPtrHash : public std::unary_function<Digest, std::size_t>
-{
-  std::size_t
-  operator() (DigestConstPtr digest) const
-  {
-    // std::cout << "digest->getHash: " << digest->getHash () << " (" << *digest << ")" << std::endl;
-    return digest->getHash ();
-  }
-};
-
-struct DigestPtrEqual : public std::unary_function<Digest, std::size_t>
-{
-  bool
-  operator() (DigestConstPtr digest1, DigestConstPtr digest2) const
-  {
-    // std::cout << boost::cref(*digest1) << " == " << boost::cref(*digest2) << " : " << (*digest1 == *digest2) << std::endl;
-    return *digest1 == *digest2;
-  }
-};
-
-
 /// @cond include_hidden 
 struct sequenced { };
+struct timed { };
 /// @endcond
 
 /**
diff --git a/model/sync-digest.h b/model/sync-digest.h
index 8982019..97d2fd4 100644
--- a/model/sync-digest.h
+++ b/model/sync-digest.h
@@ -173,6 +173,26 @@
 //   return *this;
 // }
 
+struct DigestPtrHash : public std::unary_function<Digest, std::size_t>
+{
+  std::size_t
+  operator() (DigestConstPtr digest) const
+  {
+    // std::cout << "digest->getHash: " << digest->getHash () << " (" << *digest << ")" << std::endl;
+    return digest->getHash ();
+  }
+};
+
+struct DigestPtrEqual : public std::unary_function<Digest, std::size_t>
+{
+  bool
+  operator() (DigestConstPtr digest1, DigestConstPtr digest2) const
+  {
+    // std::cout << boost::cref(*digest1) << " == " << boost::cref(*digest2) << " : " << (*digest1 == *digest2) << std::endl;
+    return *digest1 == *digest2;
+  }
+};
+
 
 } // Sync
 
diff --git a/model/sync-app-socket-c.h b/model/sync-event.h
similarity index 61%
rename from model/sync-app-socket-c.h
rename to model/sync-event.h
index 53ffab1..7808947 100644
--- a/model/sync-app-socket-c.h
+++ b/model/sync-event.h
@@ -20,20 +20,16 @@
  *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
-#ifndef SYNC_APP_SOCKET_C_H
-#define SYNC_APP_SOCKET_C_H
+#ifndef SYNC_EVENT_H
+#define SYNC_EVENT_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-  typedef struct SyncAppSocketStruct SyncAppSocketStruct;
+#include <boost/function.hpp>
 
-  SyncAppSocketStruct *create_sync_app_socket(const char *prefix, void (*callback)(const char *, const char *));
-  void delete_sync_app_socket(SyncAppSocketStruct **sock);
-  int sync_app_socket_publish(SyncAppSocketStruct *sock, const char *prefix, int session, const char *buf, int freshness);
-  void sync_app_socket_remove(SyncAppSocketStruct *sock, const char *prefix);
-#ifdef __cplusplus
-}
-#endif
+namespace Sync
+{
 
-#endif // SYNC_APP_SOCKET_C_H
+typedef boost::function< void ( ) > Event;
+
+} // Sync
+
+#endif // SYNC_EVENT_H
diff --git a/model/sync-full-state.h b/model/sync-full-state.h
index cff1306..c39ec4f 100644
--- a/model/sync-full-state.h
+++ b/model/sync-full-state.h
@@ -37,6 +37,11 @@
 
 namespace Sync {
 
+class FullState;
+typedef boost::shared_ptr<FullState> FullStatePtr;
+typedef boost::shared_ptr<FullState> FullStateConstPtr;
+
+
 /**
  * \ingroup sync
  * @brief Cumulative SYNC state
diff --git a/model/sync-interest-container.h b/model/sync-interest-container.h
new file mode 100644
index 0000000..b998b18
--- /dev/null
+++ b/model/sync-interest-container.h
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012 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>
+ *         Chaoyi Bian <bcy@pku.edu.cn>
+ *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef SYNC_INTEREST_CONTAINER_H
+#define SYNC_INTEREST_CONTAINER_H
+
+#include "sync-digest.h"
+
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/tag.hpp>
+// #include <boost/multi_index/ordered_index.hpp>
+// #include <boost/multi_index/composite_key.hpp>
+#include <boost/multi_index/hashed_index.hpp>
+#include <boost/multi_index/sequenced_index.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+// #include <boost/multi_index/random_access_index.hpp>
+#include <boost/multi_index/member.hpp>
+#include <boost/multi_index/mem_fun.hpp>
+
+namespace mi = boost::multi_index;
+
+namespace Sync {
+
+struct Interest
+{
+  Interest (DigestConstPtr digest, const std::string &name, bool unknown=false)
+  : m_digest (digest)
+  , m_name (name)
+  , m_time (TIME_NOW)
+  , m_unknown (unknown)
+  {
+  }
+  
+  DigestConstPtr m_digest;
+  std::string    m_name;
+  TimeAbsolute   m_time;
+  bool           m_unknown;
+};
+
+/// @cond include_hidden 
+struct named { };
+struct hashed;
+struct timed;
+/// @endcond
+
+/**
+ * \ingroup sync
+ * @brief Container for interests (application PIT)
+ */
+struct InterestContainer : public mi::multi_index_container<
+  Interest,
+  mi::indexed_by<
+    mi::hashed_unique<
+      mi::tag<named>,
+      BOOST_MULTI_INDEX_MEMBER(Interest, std::string, m_name)
+    >
+    ,
+    
+    mi::hashed_non_unique<
+      mi::tag<hashed>,
+      BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest),
+      DigestPtrHash,
+      DigestPtrEqual
+      >
+    ,
+    
+    mi::ordered_non_unique<
+      mi::tag<timed>,
+      BOOST_MULTI_INDEX_MEMBER(Interest, TimeAbsolute, m_time)
+      >
+    >
+  >
+{
+};
+
+} // Sync
+
+#endif // SYNC_INTEREST_CONTAINER_H
diff --git a/model/sync-interest-table.cc b/model/sync-interest-table.cc
index 7b9ed35..a05dba3 100644
--- a/model/sync-interest-table.cc
+++ b/model/sync-interest-table.cc
@@ -30,9 +30,10 @@
 namespace Sync
 {
 
-SyncInterestTable::SyncInterestTable ()
+SyncInterestTable::SyncInterestTable (TimeDuration lifetime)
+  : m_entryLifetime (lifetime)
 {
-  m_scheduler.schedule (posix_time::seconds (4),
+  m_scheduler.schedule (TIME_SECONDS (m_checkPeriod),
                         bind (&SyncInterestTable::expireInterests, this),
                         0);
 }
@@ -41,33 +42,36 @@
 {
 }
 
-vector<string>
-SyncInterestTable::fetchAll ()
+Interest
+SyncInterestTable::pop ()
 {
   expireInterests ();
   recursive_mutex::scoped_lock lock (m_mutex);
-  
-  vector<string> entries;
-  for (unordered_map<string, time_t>::iterator it = m_table.begin();
-       it != m_table.end();
-       ++it)
-    {
-      entries.push_back(it->first);
-    }
-  m_table.clear ();
 
-  return entries;
+  if (m_table.size () == 0)
+    BOOST_THROW_EXCEPTION (Error::InterestTableIsEmpty ());
+
+  Interest ret = *m_table.begin ();
+  m_table.erase (m_table.begin ());
+
+  return ret;
 }
 
 bool
-SyncInterestTable::insert(const string &interest)
+SyncInterestTable::insert (DigestConstPtr digest, const string &name, bool unknownState/*=false*/)
 {
+  bool existent = false;
+  
   recursive_mutex::scoped_lock lock (m_mutex);
-  TableContainer::iterator it = m_table.find (interest);
+  InterestContainer::index<named>::type::iterator it = m_table.get<named> ().find (name);
   if (it != m_table.end())
-    m_table.erase(it);
-  time_t currentTime = time(0);
-  m_table.insert (make_pair(interest, currentTime));
+    {
+      existent = true;
+      m_table.erase (it);
+    }
+  m_table.insert (Interest (digest, name, unknownState));
+
+  return existent;
 }
 
 uint32_t
@@ -78,42 +82,56 @@
 }
 
 bool
-SyncInterestTable::remove (const std::string &interest)
+SyncInterestTable::remove (const string &name)
 {
   recursive_mutex::scoped_lock lock (m_mutex);
-  TableContainer::iterator item = m_table.find (interest);
-  if (item != m_table.end ())
+
+  InterestContainer::index<named>::type::iterator item = m_table.get<named> ().find (name);
+  if (item != m_table.get<named> ().end ())
     {
-      m_table.erase (item);
+      m_table.get<named> ().erase (name);
+      return true;
+    }
+
+  return false;
+}
+
+bool
+SyncInterestTable::remove (DigestConstPtr digest)
+{
+  recursive_mutex::scoped_lock lock (m_mutex);
+  InterestContainer::index<hashed>::type::iterator item = m_table.get<hashed> ().find (digest);
+  if (item != m_table.get<hashed> ().end ())
+    {
+      m_table.get<hashed> ().erase (digest); // erase all records associated with the digest
       return true;
     }
   return false;
 }
 
-
 void SyncInterestTable::expireInterests ()
 { 
   recursive_mutex::scoped_lock lock (m_mutex);
 
   uint32_t count = 0;
-  time_t currentTime = time(0);
-  TableContainer::iterator it = m_table.begin (); 
-  while (it != m_table.end())
+  TimeAbsolute expireTime = TIME_NOW - m_entryLifetime;
+  
+  while (m_table.size () > 0)
     {
-    time_t timestamp = it->second;
-    _LOG_DEBUG ("expireInterests (): " << timestamp << ", " << currentTime);
-    if (currentTime - timestamp > m_checkPeriod)
-      {
-        it = m_table.erase (it);
-        count ++;
-      }
-    else
-      ++it;
+      InterestContainer::index<timed>::type::iterator item = m_table.get<timed> ().begin ();
+      
+      if (item->m_time < expireTime)
+        {
+          m_table.get<timed> ().erase (item);
+          count ++;
+        }
+      else
+        break;
   }
 
   _LOG_DEBUG ("expireInterests (): expired " << count);
   
-  m_scheduler.schedule (posix_time::seconds (4),
+  m_scheduler.schedule (TIME_SECONDS (m_checkPeriod),
                         bind (&SyncInterestTable::expireInterests, this),
                         0);
 }
diff --git a/model/sync-interest-table.h b/model/sync-interest-table.h
index 16119eb..824d1f9 100644
--- a/model/sync-interest-table.h
+++ b/model/sync-interest-table.h
@@ -22,17 +22,19 @@
 
 #ifndef SYNC_INTEREST_TABLE_H
 #define SYNC_INTEREST_TABLE_H
+
 #include <string>
 #include <vector>
-#include <boost/unordered_map.hpp>
-#include <boost/unordered_set.hpp>
 #include <boost/thread/recursive_mutex.hpp>
 #include <boost/thread/thread.hpp>
 #include <ctime>
 #include "sync-scheduler.h"
+#include "sync-digest.h"
+#include "sync-interest-container.h"
 
 namespace Sync {
 
+
 /**
  * \ingroup sync
  * @brief A table to keep unanswered Sync Interest
@@ -42,7 +44,7 @@
 class SyncInterestTable
 {
 public:
-  SyncInterestTable ();
+  SyncInterestTable (TimeDuration lifetime);
   ~SyncInterestTable ();
 
   /**
@@ -50,19 +52,25 @@
    * timestamp
    */
   bool
-  insert (const std::string &interest);
+  insert (DigestConstPtr interest, const std::string &name, bool unknownState=false);
 
   /**
-   * @brief Remove interest (e.g., when it was satisfied)
+   * @brief Remove interest by digest (e.g., when it was satisfied)
    */
   bool
-  remove (const std::string &interest);
+  remove (DigestConstPtr interest);
 
   /**
-   * @brief fetch all Interests and clear the table
+   * @brief Remove interest by name (e.g., when it was satisfied)
    */
-  std::vector<std::string>
-  fetchAll ();
+  bool
+  remove (const std::string &name);
+  
+  /**
+   * @brief pop a non-expired Interest from PIT
+   */
+  Interest
+  pop ();
 
   uint32_t
   size () const;
@@ -75,15 +83,20 @@
   expireInterests ();
 
 private:
-  typedef boost::unordered_map<std::string, time_t> TableContainer;
-  
-  static const int m_checkPeriod = 4;
-  TableContainer m_table; // pit entries
+  static const int m_checkPeriod = 4; // seconds
+
+  TimeDuration m_entryLifetime;
+  InterestContainer m_table;
 
   Scheduler m_scheduler;
   mutable boost::recursive_mutex m_mutex;
 };
 
+namespace Error {
+struct InterestTableIsEmpty : virtual boost::exception, virtual std::exception { };
+}
+
+
 } // Sync
 
 #endif // SYNC_INTEREST_TABLE_H
diff --git a/model/sync-log.cc b/model/sync-log.cc
deleted file mode 100644
index e80bfc8..0000000
--- a/model/sync-log.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "sync-log.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/model/sync-log.h b/model/sync-log.h
deleted file mode 100644
index 9ab4843..0000000
--- a/model/sync-log.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SYNC_LOG_H
-#define SYNC_LOG_H
-
-#ifdef HAVE_LOG4CXX
-
-#include <log4cxx/logger.h>
-
-#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__ << "()");
-
-void
-INIT_LOGGERS ();
-
-#else
-
-#define INIT_LOGGER(name)
-#define _LOG_FUNCTION(x)
-#define _LOG_FUNCTION_NOARGS
-#define _LOG_TRACE(x)
-#define INIT_LOGGERS(x)
-
-#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 << endl;
-
-#else
-#define _LOG_DEBUG(x)
-#endif
-
-#endif // HAVE_LOG4CXX
-
-#endif // SYNC_LOG_H
diff --git a/model/sync-logic-event-container.h b/model/sync-logic-event-container.h
deleted file mode 100644
index 65c8ab2..0000000
--- a/model/sync-logic-event-container.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SYNC_LOGIC_EVENT_CONTAINER_H
-#define SYNC_LOGIC_EVENT_CONTAINER_H
-
-#include <boost/function.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-
-#include <boost/multi_index_container.hpp>
-// #include <boost/multi_index/tag.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-// #include <boost/multi_index/composite_key.hpp>
-// #include <boost/multi_index/hashed_index.hpp>
-// #include <boost/multi_index/random_access_index.hpp>
-#include <boost/multi_index/member.hpp>
-// #include <boost/multi_index/mem_fun.hpp>
-
-namespace mi = boost::multi_index;
-
-namespace Sync
-{
-
-typedef boost::function< void ( ) > Event;
-
-struct LogicEvent
-{
-  LogicEvent (const boost::system_time &_time, Event _event, uint32_t _label)
-    : time (_time)
-    , event (_event)
-    , lbl (_label)
-  { }
-  
-  boost::system_time time;
-  Event event;
-  uint32_t lbl;
-};
-
-/// @cond include_hidden
-struct byLabel { } ;
-/// @endcond
-
-/**
- * \ingroup sync
- * @brief ???
- */
-struct EventsContainer : public mi::multi_index_container<
-  LogicEvent,
-  mi::indexed_by<
-
-    mi::ordered_non_unique<
-      mi::member<LogicEvent, boost::system_time, &LogicEvent::time>
-      >,
-
-    mi::ordered_non_unique<
-      mi::tag<byLabel>,
-      mi::member<LogicEvent, uint32_t, &LogicEvent::lbl>
-      >
-    >
-  >
-{
-};
-
-} // Sync
-
-#endif // SYNC_LOGIC_EVENT_CONTAINER_H
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 6d56764..3bae752 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -20,6 +20,11 @@
  *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
+#ifdef NS3_MODULE
+#include <ns3/ccnx-pit.h>
+#include <ns3/ccnx.h>
+#endif
+
 #include "sync-logic.h"
 #include "sync-diff-leaf.h"
 #include "sync-full-leaf.h"
@@ -28,7 +33,6 @@
 #include <boost/make_shared.hpp>
 #include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
 #include <vector>
 
 using namespace std;
@@ -36,103 +40,190 @@
 
 INIT_LOGGER ("SyncLogic");
 
+#ifdef NS3_MODULE
+#define GET_RANDOM(var) var.GetValue ()
+#else
+#define GET_RANDOM(var) var ()
+#endif
+
+#define TIME_SECONDS_WITH_JITTER(sec) \
+  (TIME_SECONDS (sec) + TIME_MILLISECONDS (GET_RANDOM (m_reexpressionJitter)))
+
+#define TIME_MILLISECONDS_WITH_JITTER(ms) \
+  (TIME_MILLISECONDS (ms) + TIME_MILLISECONDS (GET_RANDOM (m_reexpressionJitter)))
+
+
 namespace Sync
 {
 
 SyncLogic::SyncLogic (const std::string &syncPrefix,
                       LogicUpdateCallback onUpdate,
                       LogicRemoveCallback onRemove)
-  : m_syncPrefix (syncPrefix)
+  : m_state (new FullState)
+  , m_syncInterestTable (TIME_SECONDS (m_syncInterestReexpress))
+  , m_syncPrefix (syncPrefix)
   , m_onUpdate (onUpdate)
   , m_onRemove (onRemove)
   , m_ccnxHandle(new CcnxWrapper())
+  , m_recoveryRetransmissionInterval (m_defaultRecoveryRetransmitInterval)
+#ifndef NS3_MODULE
   , m_randomGenerator (static_cast<unsigned int> (std::time (0)))
-  , m_rangeUniformRandom (m_randomGenerator, uniform_int<> (20,80))
-{
-#ifdef _DEBUG
-#ifdef HAVE_LOG4CXX
-  // _LOG_FUNCTION (syncPrefix);
-  static int id = 0;
-  staticModuleLogger = log4cxx::Logger::getLogger ("SyncLogic." + lexical_cast<string> (id));
-  id ++;
+  , m_rangeUniformRandom (m_randomGenerator, uniform_int<> (200,1000))
+  , m_reexpressionJitter (m_randomGenerator, uniform_int<> (100,500))
+#else
+  , m_rangeUniformRandom (200,1000)
+  , m_reexpressionJitter (10,500)
 #endif
-#endif
+{ 
+#ifndef NS3_MODULE
+  // In NS3 module these functions are moved to StartApplication method
   
   m_ccnxHandle->setInterestFilter (m_syncPrefix,
                                    bind (&SyncLogic::respondSyncInterest, this, _1));
 
-  m_scheduler.schedule (posix_time::seconds (0),
+  m_scheduler.schedule (TIME_SECONDS (0), // no need to add jitter
                         bind (&SyncLogic::sendSyncInterest, this),
                         REEXPRESSING_INTEREST);
+#endif
 }
 
 SyncLogic::~SyncLogic ()
 {
-  // _LOG_FUNCTION (this);
-  // cout << "SyncLogic::~SyncLogic ()" << endl;
-
   m_ccnxHandle.reset ();
 }
 
+#ifdef NS3_MODULE
 void
-SyncLogic::respondSyncInterest (const string &interest)
+SyncLogic::StartApplication ()
 {
-  _LOG_TRACE ("<< I " << interest);
-  //cout << "Respond Sync Interest" << endl;
-  string hash = interest.substr(interest.find_last_of("/") + 1);
-  // cout << "Received Sync Interest: " << hash << endl;
-  
-  DigestPtr digest = make_shared<Digest> ();
-  try
-    {
-      istringstream is (hash);
-      is >> *digest;
-    }
-  catch (Error::DigestCalculationError &e)
-    {
-      // log error. ignoring it for now, later we should log it
-      return;
-    }
+  m_ccnxHandle->SetNode (GetNode ());
+  m_ccnxHandle->StartApplication ();
 
-  processSyncInterest (digest, interest, false);
+  m_ccnxHandle->setInterestFilter (m_syncPrefix,
+                                   bind (&SyncLogic::respondSyncInterest, this, _1));
+
+  m_scheduler.schedule (TIME_SECONDS (0), // need to send first interests at exactly the same time
+                        bind (&SyncLogic::sendSyncInterest, this),
+                        REEXPRESSING_INTEREST);
 }
 
 void
-SyncLogic::processSyncInterest (DigestConstPtr digest, const std::string &interestName, bool timedProcessing/*=false*/)
+SyncLogic::StopApplication ()
+{
+  m_ccnxHandle->clearInterestFilter (m_syncPrefix);
+  m_ccnxHandle->StopApplication ();
+  m_scheduler.cancel (REEXPRESSING_INTEREST);
+  m_scheduler.cancel (DELAYED_INTEREST_PROCESSING);
+}
+#endif
+
+/**
+ * Two types of intersts
+ *
+ * Normal name:    .../<hash>  
+ * Recovery name:  .../recovery/<hash>
+ */
+boost::tuple<DigestConstPtr, std::string>
+SyncLogic::convertNameToDigestAndType (const std::string &name)
+{
+  BOOST_ASSERT (name.find (m_syncPrefix) == 0);
+
+  string hash = name.substr (m_syncPrefix.size (), name.size ()-m_syncPrefix.size ());
+  if (hash[0] == '/')
+    hash = hash.substr (1, hash.size ()-1);
+  string interestType = "normal";
+
+  size_t pos = hash.find ('/');
+  if (pos != string::npos)
+    {
+      interestType = hash.substr (0, pos);
+      hash         = hash.substr (pos + 1);
+    }
+
+  _LOG_TRACE (hash << ", " << interestType);
+
+  DigestPtr digest = make_shared<Digest> ();
+  istringstream is (hash);
+  is >> *digest;
+
+  return make_tuple (digest, interestType);
+}
+
+void
+SyncLogic::respondSyncInterest (const string &name)
+{
+  try
+    {
+      _LOG_TRACE ("<< I " << name);
+
+      DigestConstPtr digest;
+      string type;
+      tie (digest, type) = convertNameToDigestAndType (name);
+
+      if (type == "normal") // kind of ineffective...
+        {
+          processSyncInterest (name, digest);
+        }
+      else if (type == "recovery") 
+        {
+          processSyncRecoveryInterest (name, digest);
+        }
+    }
+  catch (Error::DigestCalculationError &e)
+    {
+      _LOG_TRACE ("Something fishy happened...");
+      // log error. ignoring it for now, later we should log it
+      return ;
+    }
+}
+
+void
+SyncLogic::respondSyncData (const std::string &name, const std::string &dataBuffer)
+{
+  try
+    {
+      _LOG_TRACE ("<< D " << name);
+  
+      DigestConstPtr digest;
+      string type;
+      tie (digest, type) = convertNameToDigestAndType (name);
+
+      if (type == "normal")
+        {
+          processSyncData (name, digest, dataBuffer);
+        }
+      else
+        {
+          // timer is always restarted when we schedule recovery
+          m_scheduler.cancel (REEXPRESSING_RECOVERY_INTEREST);
+          processSyncData (name, digest, dataBuffer);
+        }
+    }
+  catch (Error::DigestCalculationError &e)
+    {
+      _LOG_TRACE ("Something fishy happened...");
+      // log error. ignoring it for now, later we should log it
+      return;
+    }
+}
+
+
+void
+SyncLogic::processSyncInterest (const std::string &name, DigestConstPtr digest, bool timedProcessing/*=false*/)
 {
   recursive_mutex::scoped_lock lock (m_stateMutex);
 
   // Special case when state is not empty and we have received request with zero-root digest
-  if (digest->isZero () && !m_state.getDigest()->isZero ())
+  if (digest->isZero () && !m_state->getDigest()->isZero ())
     {
-      _LOG_TRACE (">> D " << interestName << "/state" << " (zero)");
-
-      m_syncInterestTable.remove (interestName + "/state");
-      m_ccnxHandle->publishData (interestName + "/state",
-                                 lexical_cast<string> (m_state),
-                                 m_syncResponseFreshness);
-      if (m_outstandingInterest == interestName)
-        {
-          m_scheduler.schedule (posix_time::seconds (0),
-                                bind (&SyncLogic::sendSyncInterest, this),
-                                REEXPRESSING_INTEREST);
-        }
+      sendSyncData (name, digest, m_state);
       return;
     }
 
-  if (*m_state.getDigest() == *digest)
+  if (*m_state->getDigest() == *digest)
     {
-      // cout << interestName << "\n";
-      if (digest->isZero ())
-        {
-          _LOG_TRACE ("processSyncInterest (): Digest is zero, adding /state to PIT");
-          m_syncInterestTable.insert (interestName + "/state");
-        }
-      else
-        {
-          _LOG_TRACE ("processSyncInterest (): Same state. Adding to PIT");
-          m_syncInterestTable.insert (interestName);
-        }
+      _LOG_TRACE ("processSyncInterest (): Same state. Adding to PIT");
+      m_syncInterestTable.insert (digest, name, false);
       return;
     }
   
@@ -141,82 +232,67 @@
   if (stateInDiffLog != m_log.end ())
   {
     DiffStateConstPtr stateDiff = (*stateInDiffLog)->diff ();
-    // string state = lexical_cast<string> (*stateDiff);
-    // erase_all (state, "\n");
-    // _LOG_TRACE (">> D " << interestName << ", state: " << state);
-    // _LOG_DEBUG ("Log size: " << m_log.size ());
 
-    // BOOST_FOREACH (DiffStateConstPtr ds, m_log.get<sequenced> ())
-    //   {
-    //     string state = lexical_cast<string> (*ds);
-    //     erase_all (state, "\n");
-    //     _LOG_DEBUG ("   " << state << ", " << *ds->getDigest ());
-    //   }
-
-    m_syncInterestTable.remove (interestName);
-    m_ccnxHandle->publishData (interestName,
-                               lexical_cast<string> (*stateDiff),
-                               m_syncResponseFreshness);
-    if (m_outstandingInterest == interestName)
-      {
-        m_scheduler.schedule (posix_time::seconds (0),
-                              bind (&SyncLogic::sendSyncInterest, this),
-                              REEXPRESSING_INTEREST);
-      }
+    sendSyncData (name, digest, stateDiff);
     return;
   }
 
   if (!timedProcessing)
     {
-      m_scheduler.schedule (posix_time::milliseconds (m_rangeUniformRandom ()) /*from 20 to 100ms*/,
-                            bind (&SyncLogic::processSyncInterest, this, digest, interestName, true),
+      bool exists = m_syncInterestTable.insert (digest, name, true);
+      if (exists) // somebody else replied, so restart random-game timer
+        {
+          _LOG_DEBUG ("Unknown digest, but somebody may have already replied, so restart our timer");
+          m_scheduler.cancel (DELAYED_INTEREST_PROCESSING);
+        }
+
+      uint32_t waitDelay = GET_RANDOM (m_rangeUniformRandom);      
+      _LOG_DEBUG ("Digest is not in the log. Schedule processing after small delay: " << waitDelay << "ms");
+
+      m_scheduler.schedule (TIME_MILLISECONDS (waitDelay),
+                            bind (&SyncLogic::processSyncInterest, this, name, digest, true),
                             DELAYED_INTEREST_PROCESSING);
-      
     }
   else
     {
-      _LOG_TRACE (">> D " << interestName << "/state" << " (timed processing)");
-
-      m_syncInterestTable.remove (interestName + "/state");
-      m_ccnxHandle->publishData (interestName + "/state",
-                                 lexical_cast<string> (m_state),
-                                 m_syncResponseFreshness);
-
-      if (m_outstandingInterest == interestName)
-        {
-          m_scheduler.schedule (posix_time::seconds (0),
-                                bind (&SyncLogic::sendSyncInterest, this),
-                                REEXPRESSING_INTEREST);
-        }
+      _LOG_TRACE ("                                                      (timed processing)");
+      
+      m_recoveryRetransmissionInterval = m_defaultRecoveryRetransmitInterval;
+      sendSyncRecoveryInterests (digest);
     }
 }
 
 void
-SyncLogic::processSyncData (const string &name, const string &dataBuffer)
+SyncLogic::processSyncData (const std::string &name, DigestConstPtr digest, const string &dataBuffer)
 {
-  _LOG_TRACE ("<< D " << name);
   DiffStatePtr diffLog = make_shared<DiffState> ();
+  bool ownInterestSatisfied = false;
   
   try
     {
       recursive_mutex::scoped_lock lock (m_stateMutex);
-      
-      string last = name.substr(name.find_last_of("/") + 1);
-      istringstream ss (dataBuffer);
 
-      if (last == "state")
+      m_syncInterestTable.remove (name); // Remove satisfied interest from PIT
+
+      ownInterestSatisfied = (name == m_outstandingInterestName);
+
+      DiffState diff;
+      istringstream ss (dataBuffer);
+      ss >> diff;
+      BOOST_FOREACH (LeafConstPtr leaf, diff.getLeaves().get<ordered>())
         {
-          FullState full;
-          ss >> full;
-          BOOST_FOREACH (LeafConstPtr leaf, full.getLeaves()) // order doesn't matter
+          DiffLeafConstPtr diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
+          BOOST_ASSERT (diffLeaf != 0);
+
+          NameInfoConstPtr info = diffLeaf->getInfo();
+          if (diffLeaf->getOperation() == UPDATE)
             {
-              NameInfoConstPtr info = leaf->getInfo ();
-              SeqNo seq = leaf->getSeq ();
+              SeqNo seq = diffLeaf->getSeq();
 
               bool inserted = false;
               bool updated = false;
               SeqNo oldSeq;
-              tie (inserted, updated, oldSeq) = m_state.update (info, seq);
+              tie (inserted, updated, oldSeq) = m_state->update (info, seq);
 
               if (inserted || updated)
                 {
@@ -224,44 +300,17 @@
                   m_onUpdate (info->toString (), seq, oldSeq);
                 }
             }
-        }
-      else
-        {
-          DiffState diff;
-          ss >> diff;
-          BOOST_FOREACH (LeafConstPtr leaf, diff.getLeaves().get<ordered>())
+          else if (diffLeaf->getOperation() == REMOVE)
             {
-              DiffLeafConstPtr diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
-              BOOST_ASSERT (diffLeaf != 0);
-
-              NameInfoConstPtr info = diffLeaf->getInfo();
-              if (diffLeaf->getOperation() == UPDATE)
+              if (m_state->remove (info))
                 {
-                  SeqNo seq = diffLeaf->getSeq();
-
-                  bool inserted = false;
-                  bool updated = false;
-                  SeqNo oldSeq;
-                  tie (inserted, updated, oldSeq) = m_state.update (info, seq);
-
-                  if (inserted || updated)
-                    {
-                      diffLog->update (info, seq);
-                      m_onUpdate (info->toString (), seq, oldSeq);
-                    }
+                  diffLog->remove (info);
+                  m_onRemove (info->toString ());
                 }
-              else if (diffLeaf->getOperation() == REMOVE)
-                {
-                  if (m_state.remove (info))
-                    {
-                      diffLog->remove (info);
-                      m_onRemove (info->toString ());
-                    }
-                }
-              else
-                {
-                  BOOST_ASSERT (false); // just in case
-                }
+            }
+          else
+            {
+              BOOST_ASSERT (false); // just in case
             }
         }
 
@@ -269,75 +318,95 @@
     }
   catch (Error::SyncXmlDecodingFailure &e)
     {
+      _LOG_TRACE ("Something really fishy happened during state decoding " <<
+                  diagnostic_information (e));
       diffLog.reset ();
       // don't do anything
     }
 
-  // if state has changed, then it is safe to express a new interest
-  if (diffLog->getLeaves ().size () > 0)
+  if ((diffLog != 0 && diffLog->getLeaves ().size () > 0) ||
+      ownInterestSatisfied)
     {
-      m_scheduler.schedule (posix_time::seconds (0),
-                            bind (&SyncLogic::sendSyncInterest, this),
-                            REEXPRESSING_INTEREST);
-    }
-  else
-    {
-      // should not reexpress the same interest. Need at least wait for data lifetime
-      // Otherwise we will get immediate reply from the local daemon and there will be 100% utilization
+      // Do it only if everything went fine and state changed
+
+      // this is kind of wrong
+      // satisfyPendingSyncInterests (diffLog); // if there are interests in PIT, there is a point to satisfy them using new state
+  
+      // if state has changed, then it is safe to express a new interest
       m_scheduler.cancel (REEXPRESSING_INTEREST);
-      // m_scheduler.schedule (posix_time::seconds (0),
-      m_scheduler.schedule (posix_time::seconds (m_syncResponseFreshness) + posix_time::milliseconds (1),
+      m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (0),
                             bind (&SyncLogic::sendSyncInterest, this),
                             REEXPRESSING_INTEREST);
     }
 }
 
 void
-SyncLogic::satisfyPendingSyncInterests (DiffStatePtr diffLog)
+SyncLogic::processSyncRecoveryInterest (const std::string &name, DigestConstPtr digest)
 {
-  vector<string> pis = m_syncInterestTable.fetchAll ();
-  if (pis.size () > 0)
+  recursive_mutex::scoped_lock lock (m_stateMutex);
+  
+  DiffStateContainer::iterator stateInDiffLog = m_log.find (digest);
+
+  if (stateInDiffLog == m_log.end ())
     {
-      stringstream ss;
-      ss << *diffLog;
-      bool satisfiedOwnInterest = false;
-      
-      for (vector<string>::iterator ii = pis.begin(); ii != pis.end(); ++ii)
-        {
-          _LOG_TRACE (">> D " << *ii);
-          m_ccnxHandle->publishData (*ii, ss.str(), m_syncResponseFreshness);
+      _LOG_TRACE ("Could not find " << *digest << " in digest log");
+      return;
+    }
 
-          {
-            recursive_mutex::scoped_lock lock (m_stateMutex);
-            // _LOG_DEBUG (*ii << " == " << m_outstandingInterest << " = " << (*ii == m_outstandingInterest));
-            satisfiedOwnInterest = satisfiedOwnInterest || (*ii == m_outstandingInterest) || (*ii == (m_outstandingInterest + "/state"));
-          }
-        }
+  sendSyncData (name, digest, m_state);
+}
 
-      if (satisfiedOwnInterest)
+void
+SyncLogic::satisfyPendingSyncInterests (DiffStateConstPtr diffLog)
+{
+  DiffStatePtr fullStateLog = make_shared<DiffState> ();
+  {
+    recursive_mutex::scoped_lock lock (m_stateMutex);
+    BOOST_FOREACH (LeafConstPtr leaf, m_state->getLeaves ()/*.get<timed> ()*/)
+      {
+        fullStateLog->update (leaf->getInfo (), leaf->getSeq ());
+        /// @todo Impose limit on how many state info should be send out
+      }
+  }
+  
+  try
+    {
+      uint32_t counter = 0;
+      while (m_syncInterestTable.size () > 0)
         {
-          _LOG_DEBUG ("Have satisfied our own interest. Scheduling interest reexpression");
-          // we need to reexpress interest only if we satisfied our own interest
-          m_scheduler.schedule (posix_time::milliseconds (0),
-                                bind (&SyncLogic::sendSyncInterest, this),
-                                REEXPRESSING_INTEREST);
+          Interest interest = m_syncInterestTable.pop ();
+
+          if (!interest.m_unknown)
+            {
+              _LOG_TRACE (">> D " << interest.m_name);
+              sendSyncData (interest.m_name, interest.m_digest, diffLog);
+            }
+          else
+            {
+              _LOG_TRACE (">> D (unknown)" << interest.m_name);
+              sendSyncData (interest.m_name, interest.m_digest, fullStateLog);
+            }
+          counter ++;
         }
+      _LOG_DEBUG ("Satisfied " << counter << " pending interests");
+    }
+  catch (Error::InterestTableIsEmpty &e)
+    {
+      // ok. not really an error
     }
 }
 
 void
 SyncLogic::insertToDiffLog (DiffStatePtr diffLog) 
 {
-  //cout << "Process Pending Interests" <<endl;
-  diffLog->setDigest (m_state.getDigest());  
+  diffLog->setDigest (m_state->getDigest());  
   if (m_log.size () > 0)
     {
       m_log.get<sequenced> ().front ()->setNext (diffLog);
     }
-  m_log.erase (m_state.getDigest()); // remove diff state with the same digest.  next pointers are still valid
+  m_log.erase (m_state->getDigest()); // remove diff state with the same digest.  next pointers are still valid
   /// @todo Optimization
   m_log.get<sequenced> ().push_front (diffLog);
-  // _LOG_DEBUG (*diffLog->getDigest () << " " << m_log.size ());
 }
 
 void
@@ -349,10 +418,12 @@
     recursive_mutex::scoped_lock lock (m_stateMutex);
     NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix);
 
-    SeqNo seqN (session, seq);
-    m_state.update(info, seqN);
+    _LOG_DEBUG ("addLocalNames (): old state " << *m_state->getDigest ());
 
-    _LOG_DEBUG ("addLocalNames (): new state " << *m_state.getDigest ());
+    SeqNo seqN (session, seq);
+    m_state->update(info, seqN);
+
+    _LOG_DEBUG ("addLocalNames (): new state " << *m_state->getDigest ());
     
     diff = make_shared<DiffState>();
     diff->update(info, seqN);
@@ -370,7 +441,7 @@
   {
     recursive_mutex::scoped_lock lock (m_stateMutex);
     NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix);
-    m_state.remove(info);	
+    m_state->remove(info);	
 
     diff = make_shared<DiffState>();
     diff->remove(info);
@@ -387,23 +458,71 @@
   ostringstream os;
 
   {
-    // cout << "Sending Sync Interest" << endl;
     recursive_mutex::scoped_lock lock (m_stateMutex);
 
-    os << m_syncPrefix << "/" << *m_state.getDigest();
-
+    os << m_syncPrefix << "/" << *m_state->getDigest();
+    m_outstandingInterestName = os.str ();
     _LOG_TRACE (">> I " << os.str ());
-
-    m_outstandingInterest = os.str ();
   }
-  
-  m_ccnxHandle->sendInterest (os.str (),
-                              bind (&SyncLogic::processSyncData, this, _1, _2));
 
   m_scheduler.cancel (REEXPRESSING_INTEREST);
-  m_scheduler.schedule (posix_time::seconds (4),
+  m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (m_syncInterestReexpress),
                         bind (&SyncLogic::sendSyncInterest, this),
                         REEXPRESSING_INTEREST);
+  
+  m_ccnxHandle->sendInterest (os.str (),
+                              bind (&SyncLogic::respondSyncData, this, _1, _2));
 }
 
+void
+SyncLogic::sendSyncRecoveryInterests (DigestConstPtr digest)
+{
+  ostringstream os;
+  os << m_syncPrefix << "/recovery/" << *digest;
+  _LOG_TRACE (">> I " << os.str ());
+
+  TimeDuration nextRetransmission = TIME_MILLISECONDS_WITH_JITTER (m_recoveryRetransmissionInterval);
+  m_recoveryRetransmissionInterval <<= 1;
+    
+  m_scheduler.cancel (REEXPRESSING_RECOVERY_INTEREST);
+  if (m_recoveryRetransmissionInterval < 100*1000) // <100 seconds
+    {
+      m_scheduler.schedule (nextRetransmission,
+                            bind (&SyncLogic::sendSyncRecoveryInterests, this, digest),
+                            REEXPRESSING_RECOVERY_INTEREST);
+    }
+
+  m_ccnxHandle->sendInterest (os.str (),
+                              bind (&SyncLogic::respondSyncData, this, _1, _2));
+}
+
+
+void
+SyncLogic::sendSyncData (const std::string &name, DigestConstPtr digest, StateConstPtr state)
+{
+  _LOG_TRACE (">> D " << name);
+  // sending
+  m_ccnxHandle->publishData (name,
+                             lexical_cast<string> (*state),
+                             m_syncResponseFreshness); // in NS-3 it doesn't have any effect... yet
+
+  // checking if our own interest got satisfied
+  bool satisfiedOwnInterest = false;
+  {
+    recursive_mutex::scoped_lock lock (m_stateMutex);
+    satisfiedOwnInterest = (m_outstandingInterestName == name);
+  }
+  
+  if (satisfiedOwnInterest)
+    {
+      _LOG_TRACE ("Satisfied our own Interest. Re-expressing (hopefully with a new digest)");
+      
+      m_scheduler.cancel (REEXPRESSING_INTEREST);
+      m_scheduler.schedule (TIME_SECONDS_WITH_JITTER (0),
+                            bind (&SyncLogic::sendSyncInterest, this),
+                            REEXPRESSING_INTEREST);
+    }
+}
+
+
 }
diff --git a/model/sync-logic.h b/model/sync-logic.h
index ad0a208..e205fc0 100644
--- a/model/sync-logic.h
+++ b/model/sync-logic.h
@@ -43,6 +43,11 @@
 #endif
 #endif
 
+#ifdef NS3_MODULE
+#include <ns3/application.h>
+#include <ns3/random-variable.h>
+#endif
+
 namespace Sync {
 
 /**
@@ -51,6 +56,9 @@
  * interests and data)
  */
 class SyncLogic
+#ifdef NS3_MODULE
+  : public ns3::Application
+#endif
 {
 public:
   typedef boost::function< void ( const std::string &/*prefix*/, const SeqNo &/*newSeq*/, const SeqNo &/*oldSeq*/ ) > LogicUpdateCallback;
@@ -86,7 +94,7 @@
    * @param name the data name
    * @param dataBuffer the sync data
    */
-  void processSyncData (const std::string &name, const std::string &dataBuffer);
+  void respondSyncData (const std::string &name, const std::string &dataBuffer);
 
   /**
    * @brief remove a participant's subtree from the sync tree
@@ -98,29 +106,54 @@
   Scheduler &
   getScheduler () { return m_scheduler; }
 #endif
+
+#ifdef NS3_MODULE
+public:
+  virtual void StartApplication ();
+  virtual void StopApplication ();
+#endif
   
 private:
   void
   delayedChecksLoop ();
 
   void
-  processSyncInterest (DigestConstPtr digest, const std::string &interestname, bool timedProcessing=false);
+  processSyncInterest (const std::string &name,
+                       DigestConstPtr digest, bool timedProcessing=false);
+
+  void
+  processSyncData (const std::string &name,
+                   DigestConstPtr digest, const std::string &dataBuffer);
   
   void
-  sendSyncInterest ();
-
+  processSyncRecoveryInterest (const std::string &name,
+                               DigestConstPtr digest);
+  
   void 
   insertToDiffLog (DiffStatePtr diff);
 
   void
-  satisfyPendingSyncInterests (DiffStatePtr diff);
+  satisfyPendingSyncInterests (DiffStateConstPtr diff);
 
+  boost::tuple<DigestConstPtr, std::string>
+  convertNameToDigestAndType (const std::string &name);
+
+  void
+  sendSyncInterest ();
+
+  void
+  sendSyncRecoveryInterests (DigestConstPtr digest);
+
+  void
+  sendSyncData (const std::string &name,
+                DigestConstPtr digest, StateConstPtr state);
+  
 private:
-  FullState m_state;
+  FullStatePtr m_state;
   DiffStateContainer m_log;
   boost::recursive_mutex m_stateMutex;
 
-  std::string m_outstandingInterest;
+  std::string m_outstandingInterestName;
   SyncInterestTable m_syncInterestTable;
 
   std::string m_syncPrefix;
@@ -130,22 +163,34 @@
 
   Scheduler m_scheduler;
 
+#ifndef NS3_MODULE
   boost::mt19937 m_randomGenerator;
   boost::variate_generator<boost::mt19937&, boost::uniform_int<> > m_rangeUniformRandom;
-  
-  static const int m_syncResponseFreshness = 2;
+  boost::variate_generator<boost::mt19937&, boost::uniform_int<> > m_reexpressionJitter;
+#else
+  ns3::UniformVariable m_rangeUniformRandom;
+  ns3::UniformVariable m_reexpressionJitter;
+#endif
 
+  static const int m_unknownDigestStoreTime = 10; // seconds
+#ifdef NS3_MODULE
+  static const int m_syncResponseFreshness = 100; // milliseconds
+  static const int m_syncInterestReexpress = 10; // seconds
+  // don't forget to adjust value in SyncCcnxWrapper
+#else
+  static const int m_syncResponseFreshness = 2000;
+  static const int m_syncInterestReexpress = 4;
+#endif
+
+  static const int m_defaultRecoveryRetransmitInterval = 200; // milliseconds
+  uint32_t m_recoveryRetransmissionInterval; // milliseconds
+  
   enum EventLabels
     {
       DELAYED_INTEREST_PROCESSING = 1,
-      REEXPRESSING_INTEREST = 2
+      REEXPRESSING_INTEREST = 2,
+      REEXPRESSING_RECOVERY_INTEREST = 3
     };
-
-#ifdef _DEBUG
-#ifdef HAVE_LOG4CXX
-  log4cxx::LoggerPtr staticModuleLogger;
-#endif
-#endif  
 };
 
 
diff --git a/model/sync-ns3-name-info.cc b/model/sync-ns3-name-info.cc
deleted file mode 100644
index b46d1f6..0000000
--- a/model/sync-ns3-name-info.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef STANDALONE
-
-#include "sync-ns3-name-info.h"
-#include "ns3/ccnx-name-components.h"
-
-#include <boost/foreach.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/make_shared.hpp>
-#include <utility>
-
-using namespace std;
-using namespace boost;
-
-namespace Sync {
-
-
-NameInfoConstPtr
-Ns3NameInfo::FindOrCreate (ns3::Ptr<const ns3::CcnxNameComponents> name)
-{
-  string key = lexical_cast<string> (*name);
-
-  NameMap::iterator item = m_names.find (key);
-  if (item == m_names.end ())
-    {
-      NameInfoPtr value = NameInfoPtr (new Ns3NameInfo (name));
-      pair<NameMap::iterator,bool> inserted =
-        m_names.insert (make_pair (key, value));
-      BOOST_ASSERT (inserted.second); // previous call has to insert value
-      item = inserted.first;
-    }
-
-  return item->second;
-}
-
-Ns3NameInfo::Ns3NameInfo (ns3::Ptr<const ns3::CcnxNameComponents> name)
-  : m_name (name)
-{
-  m_id = m_ids ++; // set ID for a newly inserted element
-  m_digest << *name;
-  m_digest.getHash (); // finalize digest
-}
-
-string
-Ns3NameInfo::toString () const
-{
-  return lexical_cast<std::string> (*m_name);
-}
-
-bool
-Ns3NameInfo::operator == (const NameInfo &info) const
-{
-  try
-    {
-      return *m_name == *dynamic_cast<const Ns3NameInfo&> (info).m_name;
-    }
-  catch (...)
-    {
-      return false;
-    }
-}
-
-Digest &
-operator << (Digest &digest, const ns3::CcnxNameComponents &name)
-{
-  BOOST_FOREACH (const std::string &component, name.GetComponents ())
-    {
-      Digest subhash;
-      subhash << component;
-      subhash.getHash (); // finalize hash
-
-      digest << subhash;
-    }
-
-  return digest;
-}
-
-
-} // Sync
-
-#endif
-
diff --git a/model/sync-ns3-name-info.h b/model/sync-ns3-name-info.h
deleted file mode 100644
index 9363665..0000000
--- a/model/sync-ns3-name-info.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef STANDALONE
-
-#ifndef SYNC_CCNX_NAME_INFO_H
-#define SYNC_CCNX_NAME_INFO_H
-
-#include "sync-name-info.h"
-#include "ns3/ptr.h"
-#include "ns3/ccnx-name-components.h"
-
-namespace Sync {
-
-class Ns3NameInfo : public NameInfo
-{
-public:
-  /**
-   * @brief Lookup existing or create new NameInfo object
-   * @param name routable prefix
-   */
-  static NameInfoConstPtr
-  FindOrCreate (ns3::Ptr<const ns3::CcnxNameComponents> name);
-
-  virtual ~Ns3NameInfo () { };
-  
-  // from NameInfo
-  virtual bool
-  operator == (const NameInfo &info) const;
-
-  virtual std::string
-  toString () const;
-
-private:
-  // implementing a singleton pattern. 
-  /**
-   * @brief Disabled default constructor. NameInfo object should be created through FindOrCreate static call.
-   */
-
-  /**
-   * @brief Disabled default
-   */
-  Ns3NameInfo () {}
-  Ns3NameInfo& operator = (const Ns3NameInfo &info) { return *this; }
-  Ns3NameInfo (ns3::Ptr<const ns3::CcnxNameComponents> name);
-  
-  ns3::Ptr<const ns3::CcnxNameComponents> m_name;
-};
-
-Digest &
-operator << (Digest &, const ns3::CcnxNameComponents &name);
-
-} // Sync
-
-#endif // SYNC_CCNX_NAME_INFO_H
-
-#endif // STANDALONE
diff --git a/model/sync-scheduler.cc b/model/sync-scheduler.cc
deleted file mode 100644
index 4f9e082..0000000
--- a/model/sync-scheduler.cc
+++ /dev/null
@@ -1,143 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "sync-scheduler.h"
-#include "sync-log.h"
-
-using namespace boost;
-using namespace std;
-
-INIT_LOGGER ("Scheduler");
-
-namespace Sync {
-
-Scheduler::Scheduler ()
-  : m_threadRunning (true)
-{
-  m_thread = thread (&Scheduler::threadLoop, this);
-}
-
-Scheduler::~Scheduler ()
-{
-  m_threadRunning = false;
-  // cout << "Requested stop" << this_thread::get_id () << endl;
-  m_thread.interrupt ();
-  m_thread.join ();
-}
-
-void
-Scheduler::threadLoop ()
-{
-  _LOG_FUNCTION (this);
-  while (m_threadRunning)
-    {
-      try
-        {
-	  boost::system_time nextTime;
-          {
-            unique_lock<mutex> lock (m_eventsMutex);
-            while (m_threadRunning && m_events.size () == 0)
-              {
-                m_eventsCondition.wait (lock);
-                // cout << "Got something" << endl;
-              }
-
-            if (m_events.size () == 0) continue;
-
-	    nextTime = m_events.begin ()->time;
-          }
-
-	  if (nextTime > get_system_time ())
-	    {
-	      this_thread::sleep (nextTime - get_system_time ());
-
-	      // sleeping
-
-	      if (nextTime > get_system_time ())
-                {
-                  // cout << "expected here" << endl;
-                  continue; // something changes, try again
-                }
-	    }
-
-	  if (!m_threadRunning) continue;
-
-	  Event event;
-	  
-	  {
-	    lock_guard<mutex> lock (m_eventsMutex);
-
-	    if (m_events.size () == 0)
-              {
-                // cout << "Here" << endl;
-                continue;
-              }
-	    
-	    event = m_events.begin ()->event;
-	    m_events.erase (m_events.begin ());
-	  }
-
-	  event (); // calling the event outside the locked mutex
-        }
-      catch (thread_interrupted &e)
-        {
-          // cout << "interrupted: " << this_thread::get_id () << endl;
-          // do nothing
-        }
-    }
-  // cout << "Exited...\n";  
-}
-
-
-void
-Scheduler::schedule (const boost::system_time &abstime, Event event, uint32_t label)
-{
-  {
-    lock_guard<mutex> lock (m_eventsMutex);
-    m_events.insert (LogicEvent (abstime, event, label));
-  }
-  m_eventsCondition.notify_one ();
-  m_thread.interrupt (); // interrupt sleep, if currently sleeping
-}
-
-void
-Scheduler::schedule (const boost::posix_time::time_duration &reltime, Event event, uint32_t label)
-{
-  // cout << reltime << endl;
-  schedule (boost::get_system_time () + reltime, event, label);
-}
-
-void
-Scheduler::cancel (uint32_t label)
-{
-  {
-    // cout << "Canceling label " << label << " size: " << m_events.size () << endl;
-    lock_guard<mutex> lock (m_eventsMutex);
-    m_events.get<byLabel> ().erase (label);
-    // cout << "Canceled label " << label << " size: " << m_events.size () << endl;
-  }
-  m_eventsCondition.notify_one ();
-  m_thread.interrupt (); // interrupt sleep, if currently sleeping
-}
-
-
-} // Sync
diff --git a/model/sync-scheduler.h b/model/sync-scheduler.h
deleted file mode 100644
index 10ef210..0000000
--- a/model/sync-scheduler.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 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>
- *         Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SYNC_SCHEDULER_H
-#define SYNC_SCHEDULER_H
-
-#include <boost/thread/thread.hpp>
-#include <boost/thread/mutex.hpp>
-
-#include "sync-logic-event-container.h"
-
-namespace Sync {
-
-/**
- * @ingroup sync
- * @brief General purpose event scheduler
- *
- * This class internally runs a thread and events can be scheduled by specifying an absolute or relative time of the event
- */
-class Scheduler
-{
-public:
-  /**
-   * @brief Default constructor. Thread will be created
-   */
-  Scheduler ();
-  /**
-   * @brief Destructor. Thread will be nicely stopped
-   */
-  ~Scheduler ();
-
-  /**
-   * @brief Schedule an event at absolute time 'abstime'
-   * @param abstime Absolute time
-   * @param event function to be called at the time
-   * @param label Label for the event
-   */
-  void
-  schedule (const boost::system_time &abstime, Event event, uint32_t label);
-
-  /**
-   * @brief Schedule an event at relative time 'reltime'
-   * @param reltime Relative time
-   * @param event function to be called at the time
-   * @param label Label for the event
-   */
-  void
-  schedule (const boost::posix_time::time_duration &reltime, Event event, uint32_t label); 
-
-  /**
-   * @brief Cancel all events for the label
-   * @param label Label of the event that needs to be cancelled
-   */
-  void
-  cancel (uint32_t label);
-
-#ifdef _DEBUG
-  size_t
-  getEventsSize ()
-  {
-    boost::lock_guard<boost::mutex> lock (m_eventsMutex);
-    return m_events.size ();
-  }
-#endif
-  
-private:
-  void
-  threadLoop ();
-    
-private:
-  EventsContainer m_events;
-  boost::condition_variable m_eventsCondition;
-  boost::mutex  m_eventsMutex;
-
-  boost::thread m_thread;
-  bool          m_threadRunning;
-};
-  
-}
-
-#endif // SYNC_SCHEDULER_H
diff --git a/model/sync-state.h b/model/sync-state.h
index faaad02..826e84d 100644
--- a/model/sync-state.h
+++ b/model/sync-state.h
@@ -34,6 +34,10 @@
  */
 namespace Sync {
 
+class State;
+typedef boost::shared_ptr<State> StatePtr;
+typedef boost::shared_ptr<State> StateConstPtr;
+
 /**
  * \ingroup sync
  * @brief Container for state leaves and definition of the abstract interface to work with State objects
