diff --git a/ccnx/sync-app-socket-c.cc b/ccnx/sync-app-socket-c.cc
index 4bdf384..cefd73c 100644
--- a/ccnx/sync-app-socket-c.cc
+++ b/ccnx/sync-app-socket-c.cc
@@ -21,29 +21,83 @@
  */
 
 #include "sync-app-socket.h"
+#include <boost/shared_array.hpp>
 using namespace std;
 using namespace Sync;
 
-class CallbackHolder{
+struct SyncAppSocketStruct;
+struct MissingDataInfoC
+{
+  const char *prefix;
+  int session;
+  int low;
+  int high;
+};
+
+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());
+  CallbackHolder(void (*callback)(const char*, const char*))
+    :m_callback(callback){};
+  
+  void callbackWrapper(const string &name, const string &data) {
+    if (m_callback != NULL)
+      (*m_callback)(name.c_str(), data.c_str());
   }
 };
 
-struct SyncAppSocketStruct;
+class UpdateCallbackHolder {
+private:
+  void (*m_callback)(const struct MissingDataInfoC*, const int, const SyncAppSocketStruct*);
+
+public:
+  UpdateCallbackHolder(void (*callback)(
+        const MissingDataInfoC*, 
+        const int, 
+        const SyncAppSocketStruct*))
+    :m_callback(callback){};
+
+  void callbackWrapper(const vector<MissingDataInfo> &mdi, SyncAppSocket* socket) {
+    boost::shared_array<MissingDataInfoC> mdic(new MissingDataInfoC[mdi.size()]);
+    int i;
+    
+    for (i = 0; i < mdi.size(); i++)
+    {
+      mdic[i].prefix = mdi[i].prefix.c_str();
+      mdic[i].session = mdi[i].low.getSession();
+      mdic[i].low = mdi[i].low.getSeq();
+      mdic[i].high = mdi[i].high.getSeq();
+    }
+    if (m_callback != NULL)
+      (*m_callback)(mdic.get(), i, (const SyncAppSocketStruct*) socket);
+  }
+};
+
+class RemoveCallbackHolder {
+private:
+  void (*m_callback)(const char*);
+
+public:
+  RemoveCallbackHolder(void (*callback)(const char*)):m_callback(callback){};
+  void callbackWrapper(const string &prefix) {
+    if (m_callback != NULL)
+      (*m_callback)(prefix.c_str());
+  }
+};
 
 extern "C"
 SyncAppSocketStruct *
-create_sync_app_socket(const char *prefix, void (*callback)(const char *, const char *)) 
+create_sync_app_socket(const char *prefix, 
+    void (*updatecallback)(const MissingDataInfoC*, const int, const SyncAppSocketStruct*),
+    void (*removecallback)(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);
+  boost::shared_ptr<UpdateCallbackHolder> uh(new UpdateCallbackHolder(updatecallback));
+  boost::shared_ptr<RemoveCallbackHolder> rh(new RemoveCallbackHolder(removecallback));
+  boost::function<void (const vector<MissingDataInfo>&, SyncAppSocket*)> ucb = bind(&UpdateCallbackHolder::callbackWrapper, uh, _1, _2);
+  boost::function<void (const string&)> rcb = bind(&RemoveCallbackHolder::callbackWrapper, rh, _1);
+  SyncAppSocket *sock = new SyncAppSocket(prefix, ucb, rcb);
   return (SyncAppSocketStruct *) sock;
 }
 
@@ -61,14 +115,28 @@
 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);
+  SyncAppSocket *temp = (SyncAppSocket*) sock;
+  return temp->publishString(prefix, session, buf, freshness);
 }
 
 extern "C"
 void
 sync_app_socket_remove(SyncAppSocketStruct *sock, const char *prefix) 
 {
-  SyncAppSocket *temp = (SyncAppSocket *)sock;
+  SyncAppSocket *temp = (SyncAppSocket*) sock;
   temp->remove(prefix);
 }
+
+extern "C"
+void
+sync_app_socket_fetch(SyncAppSocketStruct *sock, const char *prefix, int session, int sequence, 
+    void (*callback)(const char*, const char*), int retry = 0)
+{
+  SyncAppSocket *temp = (SyncAppSocket*) sock;
+  string s(prefix);
+  SeqNo seq(session, sequence);
+  boost::shared_ptr<CallbackHolder> h(new CallbackHolder(callback));
+  boost::function<void (const string&, const string&)> cb = bind(&CallbackHolder::callbackWrapper, h, _1, _2);
+
+  temp->fetchString(s, seq, cb, retry);
+}
