Small checkpoint
diff --git a/ccnx/ccnx-common.h b/ccnx/ccnx-common.h
index 1824025..96f60ff 100644
--- a/ccnx/ccnx-common.h
+++ b/ccnx/ccnx-common.h
@@ -40,10 +40,9 @@
 #include <utility>
 #include <string.h>
 
-using namespace std;
 namespace Ccnx {
-typedef vector<unsigned char> Bytes;
-typedef vector<string>Comps;
+typedef std::vector<unsigned char> Bytes;
+typedef std::vector<std::string>Comps;
 
 typedef boost::shared_ptr<Bytes> BytesPtr;
 
diff --git a/ccnx/ccnx-name.cpp b/ccnx/ccnx-name.cpp
index cf6a475..cc34c23 100644
--- a/ccnx/ccnx-name.cpp
+++ b/ccnx/ccnx-name.cpp
@@ -24,8 +24,9 @@
 #include <ctype.h>
 #include <boost/algorithm/string/join.hpp>
 
+using namespace std;
+
 namespace Ccnx{
-CcnxCharbufPtr CcnxCharbuf::Null;
 
 void
 CcnxCharbuf::init(ccn_charbuf *buf)
diff --git a/ccnx/ccnx-name.h b/ccnx/ccnx-name.h
index ff93a7d..72f790a 100644
--- a/ccnx/ccnx-name.h
+++ b/ccnx/ccnx-name.h
@@ -47,8 +47,6 @@
   const ccn_charbuf *
   getBuf() const { return m_buf; }
 
-  static CcnxCharbufPtr Null;
-
   const unsigned char *
   buf () const
   { return m_buf->buf; }
@@ -66,14 +64,14 @@
 
 
 struct NameException:
-  virtual boost::exception, virtual exception {};
+    virtual boost::exception, virtual std::exception {};
 
 class Name
 {
 public:
   Name();
-  Name(const string &name);
-  Name(const vector<Bytes> &comps);
+  Name(const std::string &name);
+  Name(const std::vector<Bytes> &comps);
   Name(const Name &other);
   Name(const unsigned char *data, const ccn_indexbuf *comps);
   Name (const unsigned char *buf, const size_t length);
@@ -93,7 +91,7 @@
   appendComp(const Bytes &comp);
 
   Name &
-  appendComp(const string &compStr);
+  appendComp(const std::string &compStr);
 
   Name &
   appendComp(const void *buf, size_t size);
@@ -121,39 +119,45 @@
   Bytes
   getComp(int index) const;
 
-  // return string format of the comp
+  // return std::string format of the comp
   // if all characters are printable, simply returns the string
   // if not, print the bytes in hex string format
-  string
+  std::string
   getCompAsString(int index) const;
 
   uint64_t
   getCompAsInt (int index) const;
 
+  inline std::string
+  getCompFromBackAsString(int index) const;
+
+  inline uint64_t
+  getCompFromBackAsInt (int index) const;
+
   Name
   getPartialName(int start, int n = -1) const;
 
-  string
+  std::string
   toString() const;
 
   Name &
   operator=(const Name &other);
 
   bool
-  operator==(const string &str) const;
+  operator==(const std::string &str) const;
 
   bool
-  operator!=(const string &str) const;
+  operator!=(const std::string &str) const;
 
   friend Name
   operator+(const Name &n1, const Name &n2);
 
 private:
-  vector<Bytes> m_comps;
+  std::vector<Bytes> m_comps;
 };
 
-ostream&
-operator <<(ostream &os, const Name &name);
+std::ostream&
+operator <<(std::ostream &os, const Name &name);
 
 bool
 operator ==(const Name &n1, const Name &n2);
@@ -165,6 +169,18 @@
 operator <(const Name &n1, const Name &n2);
 
 
+std::string
+Name::getCompFromBackAsString(int index) const
+{
+  return getCompAsString (m_comps.size () - 1 - index);
+}
+
+uint64_t
+Name::getCompFromBackAsInt (int index) const
+{
+  return getCompAsInt (m_comps.size () - 1 - index);
+}
+
 
 } // Ccnx
 #endif
diff --git a/ccnx/ccnx-pco.h b/ccnx/ccnx-pco.h
index cecc763..cdb2a7e 100644
--- a/ccnx/ccnx-pco.h
+++ b/ccnx/ccnx-pco.h
@@ -48,6 +48,9 @@
   Name
   name() const;
 
+  inline const Bytes &
+  buf () const;
+
 private:
   void
   init(const unsigned char *data, size_t len);
@@ -58,6 +61,13 @@
   Bytes m_bytes;
 };
 
+const Bytes &
+ParsedContentObject::buf () const
+{
+  return m_bytes;
+}
+
+
 typedef boost::shared_ptr<ParsedContentObject> PcoPtr;
 
 }
diff --git a/ccnx/ccnx-selectors.cpp b/ccnx/ccnx-selectors.cpp
index 001c1b7..b349cc1 100644
--- a/ccnx/ccnx-selectors.cpp
+++ b/ccnx/ccnx-selectors.cpp
@@ -2,6 +2,8 @@
 #include "ccnx-common.h"
 #include <boost/lexical_cast.hpp>
 
+using namespace std;
+
 namespace Ccnx {
 
 Selectors::Selectors()
@@ -53,7 +55,7 @@
 {
   if (isEmpty())
   {
-    return CcnxCharbuf::Null;
+    return CcnxCharbufPtr ();
   }
   CcnxCharbufPtr ptr(new CcnxCharbuf());
   ccn_charbuf *cbuf = ptr->getBuf();
diff --git a/ccnx/ccnx-selectors.h b/ccnx/ccnx-selectors.h
index 420f33e..56e29b5 100644
--- a/ccnx/ccnx-selectors.h
+++ b/ccnx/ccnx-selectors.h
@@ -27,7 +27,7 @@
 namespace Ccnx {
 
 struct InterestSelectorException:
-  virtual boost::exception, virtual exception {};
+    virtual boost::exception, virtual std::exception {};
 
 class Selectors
 {
diff --git a/ccnx/ccnx-wrapper.cpp b/ccnx/ccnx-wrapper.cpp
index 7f2e567..a8c06a3 100644
--- a/ccnx/ccnx-wrapper.cpp
+++ b/ccnx/ccnx-wrapper.cpp
@@ -325,7 +325,7 @@
 
   CcnxCharbufPtr selectorsPtr = selectors.toCcnxCharbuf();
   ccn_charbuf *templ = NULL;
-  if (selectorsPtr != CcnxCharbuf::Null)
+  if (selectorsPtr)
   {
     templ = selectorsPtr->getBuf();
   }
diff --git a/ccnx/ccnx-wrapper.h b/ccnx/ccnx-wrapper.h
index cfd030b..c1c9b9b 100644
--- a/ccnx/ccnx-wrapper.h
+++ b/ccnx/ccnx-wrapper.h
@@ -94,7 +94,7 @@
   boost::thread m_thread;
   bool m_running;
   bool m_connected;
-  map<Name, InterestCallback> m_registeredInterests;
+  std::map<Name, InterestCallback> m_registeredInterests;
 };
 
 typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;
diff --git a/src/action-log.cc b/src/action-log.cc
index ed09796..6254e1e 100644
--- a/src/action-log.cc
+++ b/src/action-log.cc
@@ -427,6 +427,84 @@
 }
 
 void
+ActionLog::AddRemoteAction (const Ccnx::Name &deviceName, sqlite3_int64 seqno, Ccnx::PcoPtr actionPco)
+{
+  if (!actionPco)
+    {
+      BOOST_THROW_EXCEPTION (Error::ActionLog () << errmsg_info_str ("actionPco is not valid"));
+    }
+  ActionItemPtr action = deserializeMsg<ActionItem> (actionPco->content ());
+
+  if (!action)
+    {
+      BOOST_THROW_EXCEPTION (Error::ActionLog () << errmsg_info_str ("action cannot be decoded"));
+    }
+
+  sqlite3_stmt *stmt;
+  int res = sqlite3_prepare_v2 (m_db, "INSERT INTO ActionLog "
+                                "(device_name, seq_no, action, filename, version, action_timestamp, "
+                                "file_hash, file_atime, file_mtime, file_ctime, file_chmod, file_seg_num, "
+                                "parent_device_name, parent_seq_no, "
+                                "action_name, action_content_object) "
+                                "VALUES (?, ?, ?, ?, ?, datetime(?, 'unixepoch'),"
+                                "        ?, datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), ?,?, "
+                                "        ?, ?, "
+                                "        ?, ?);", -1, &stmt, 0);
+
+  CcnxCharbufPtr device_name = deviceName.toCcnxCharbuf ();
+  sqlite3_bind_blob  (stmt, 1, device_name->buf (), device_name->length (), SQLITE_STATIC);
+  sqlite3_bind_int64 (stmt, 2, seqno);
+
+  sqlite3_bind_int   (stmt, 3, action->action ());
+  sqlite3_bind_text  (stmt, 4, action->filename ().c_str (), action->filename ().size (), SQLITE_STATIC);
+  sqlite3_bind_int64 (stmt, 5, action->version ());
+  sqlite3_bind_int64 (stmt, 6, action->timestamp ());
+
+  if (action->action () == ActionItem::UPDATE)
+    {
+      sqlite3_bind_blob  (stmt, 7, action->file_hash ().c_str (), action->file_hash ().size (), SQLITE_STATIC);
+
+      // sqlite3_bind_int64 (stmt, 8, atime); // NULL
+      sqlite3_bind_int64 (stmt, 9, action->mtime ());
+      // sqlite3_bind_int64 (stmt, 10, ctime); // NULL
+
+      sqlite3_bind_int   (stmt, 11, action->mode ());
+      sqlite3_bind_int   (stmt, 12, action->seg_num ());
+    }
+
+  if (action->has_parent_device_name ())
+    {
+      sqlite3_bind_blob (stmt, 13, action->parent_device_name ().c_str (), action->parent_device_name ().size (), SQLITE_TRANSIENT);
+      sqlite3_bind_int64 (stmt, 14, action->parent_seq_no ());
+    }
+
+  Name actionName = Name (deviceName)("action")(m_sharedFolderName)(seqno);
+  CcnxCharbufPtr namePtr = actionName.toCcnxCharbuf ();
+
+  sqlite3_bind_blob (stmt, 15, namePtr->buf (), namePtr->length (), SQLITE_STATIC);
+  sqlite3_bind_blob (stmt, 16, head (actionPco->buf ()), actionPco->buf ().size (), SQLITE_STATIC);
+  sqlite3_step (stmt);
+
+  // if action needs to be applied to file state, the trigger will take care of it
+
+  _LOG_DEBUG_COND (sqlite3_errcode (m_db) != SQLITE_OK && sqlite3_errcode (m_db) != SQLITE_ROW, sqlite3_errmsg (m_db));
+
+  sqlite3_finalize (stmt);
+}
+
+void
+ActionLog::AddRemoteAction (Ccnx::PcoPtr actionPco)
+{
+  Name name = actionPco->name ();
+  // <device_name>/"action"/<shared_folder_name_one_component>/<seqno>
+
+}
+
+///////////////////////////////////////////////////////////////////////////////////
+// SHOULD BE MOVED TO SEPARATE FILESTATE CLASS "EVENTUALLY"
+///////////////////////////////////////////////////////////////////////////////////
+
+void
 ActionLog::apply_action_xFun (sqlite3_context *context, int argc, sqlite3_value **argv)
 {
   ActionLog *the = reinterpret_cast<ActionLog*> (sqlite3_user_data (context));
diff --git a/src/action-log.h b/src/action-log.h
index 27d0869..4123713 100644
--- a/src/action-log.h
+++ b/src/action-log.h
@@ -41,6 +41,9 @@
              SyncLogPtr syncLog,
              const std::string &sharedFolder);
 
+  //////////////////////////
+  // Local operations     //
+  //////////////////////////
   void
   AddLocalActionUpdate (const std::string &filename,
                         const Hash &hash,
@@ -57,6 +60,25 @@
   bool
   KnownFileState(const std::string &filename, const Hash &hash);
 
+  //////////////////////////
+  // Remote operations    //
+  //////////////////////////
+
+  void
+  AddRemoteAction (const Ccnx::Name &deviceName, sqlite3_int64 seqno, Ccnx::PcoPtr actionPco);
+
+  /**
+   * @brief Add remote action using just action's parsed content object
+   *
+   * This function extracts device name and sequence number from the content object's and calls the overloaded method
+   */
+  void
+  AddRemoteAction (Ccnx::PcoPtr actionPco);
+
+  ///////////////////////////
+  // General operations    //
+  ///////////////////////////
+
   Ccnx::PcoPtr
   LookupActionPco (const Ccnx::Name &deviceName, sqlite3_int64 seqno);
 
@@ -69,6 +91,8 @@
   ActionItemPtr
   LookupAction (const Ccnx::Name &actionName);
 
+
+
 public:
   // for test purposes
   sqlite3_int64
@@ -88,4 +112,9 @@
   std::string m_sharedFolderName;
 };
 
+namespace Error {
+struct ActionLog : virtual boost::exception, virtual std::exception { };
+}
+
+
 #endif // ACTION_LOG_H