Doxygen-related changes and minor code modifications
diff --git a/model/sync-ccnx-wrapper.cc b/model/sync-ccnx-wrapper.cc
index a4aea2e..0acde7f 100644
--- a/model/sync-ccnx-wrapper.cc
+++ b/model/sync-ccnx-wrapper.cc
@@ -53,12 +53,10 @@
 
 void CcnxWrapper::createKeyLocator()
 {
-  int res;
-
   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);
-  res = ccn_append_pubkey_blob(m_keyLoactor, ccn_keystore_public_key(m_keyStore));
+  int res = ccn_append_pubkey_blob(m_keyLoactor, ccn_keystore_public_key(m_keyStore));
   if (res >= 0)
     {
       ccn_charbuf_append_closer(m_keyLoactor); /* </Key> */
@@ -202,8 +200,9 @@
       size_t size;
       name += "/";
       ccn_name_comp_get(info->content_ccnb, info->content_comps, i, (const unsigned char **)&comp, &size);
-      name += comp;
+      name += comp; // this will also crash if name doesn't have \0 ending
     }
+  // this will crash when content doesn't have \0 ending
   f(name, (string)pcontent);
   return CCN_UPCALL_RESULT_OK;
 }
diff --git a/model/sync-ccnx-wrapper.h b/model/sync-ccnx-wrapper.h
index c7f2336..00b5cd5 100644
--- a/model/sync-ccnx-wrapper.h
+++ b/model/sync-ccnx-wrapper.h
@@ -95,6 +95,7 @@
   publishData(std::string name, std::string dataBuffer, int freshness);
 
 private:
+  /// @cond include_hidden 
   void
   createKeyLocator ();
 
@@ -112,7 +113,7 @@
 
   void
   ccnLoop ();
-
+  /// @endcond
 private:
   ccn* m_handle;
   ccn_keystore *m_keyStore;
@@ -123,6 +124,8 @@
   bool m_running;
 };
 
+typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;
+
 } // Sync
 
 #endif // SYNC_CCNX_WRAPPER_H
diff --git a/model/sync-diff-leaf.cc b/model/sync-diff-leaf.cc
index 0790ec7..d2b7d7f 100644
--- a/model/sync-diff-leaf.cc
+++ b/model/sync-diff-leaf.cc
@@ -24,6 +24,8 @@
 #include <boost/throw_exception.hpp>
 typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info; 
 
+using namespace Sync::Error;
+
 namespace Sync {
 
 DiffLeaf::DiffLeaf (NameInfoConstPtr info, const SeqNo &seq)
diff --git a/model/sync-diff-leaf.h b/model/sync-diff-leaf.h
index a4b6538..1e3143a 100644
--- a/model/sync-diff-leaf.h
+++ b/model/sync-diff-leaf.h
@@ -81,7 +81,9 @@
 std::istream &
 operator >> (std::istream &is, Operation &op);
 
+namespace Error {
 struct SyncDiffLeafOperationParseError : virtual boost::exception, virtual std::exception { };
+} // Error
 
 } // Sync
 
diff --git a/model/sync-diff-state-container.h b/model/sync-diff-state-container.h
index 8983ceb..56cb95c 100644
--- a/model/sync-diff-state-container.h
+++ b/model/sync-diff-state-container.h
@@ -23,8 +23,6 @@
 #ifndef SYNC_DIFF_STATE_CONTAINER_H
 #define SYNC_DIFF_STATE_CONTAINER_H
 
-namespace Sync {
-
 #include "sync-diff-state.h"
 
 #include <boost/multi_index_container.hpp>
@@ -39,6 +37,8 @@
 
 namespace mi = boost::multi_index;
 
+namespace Sync {
+
 // struct DigestHash : public std::unary_function<Digest, std::size_t>
 // {
 //   std::size_t
@@ -48,13 +48,15 @@
 //   }
 // };
 
+/// @cond include_hidden 
 struct sequenced { };
- 
+/// @endcond
+
 /**
  * \ingroup sync
  * @brief Container for differential states
  */
-struct LeafContainer : public mi::multi_index_container<
+struct DiffStateContainer : public mi::multi_index_container<
     DiffStatePtr,
     // mi::indexed_by<
     //   // For fast access to elements using DiffState hashes
@@ -66,7 +68,7 @@
 
   // sequenced index to access older/newer element (like in list)
       mi::indexed_by<
-        mi::sequenced<mi::tag<seqenced> >
+        mi::sequenced<mi::tag<sequenced> >
     >
    >
 {
diff --git a/model/sync-digest.cc b/model/sync-digest.cc
index d8dda5c..9b1c536 100644
--- a/model/sync-digest.cc
+++ b/model/sync-digest.cc
@@ -88,7 +88,7 @@
     if ((unsigned)ch < 128)
       value = lookup_table [(unsigned)ch];
     if (value == -1)
-      BOOST_THROW_EXCEPTION (Sync::DigestCalculationError () << errmsg_info_int ((int)ch));
+      BOOST_THROW_EXCEPTION (Sync::Error::DigestCalculationError () << errmsg_info_int ((int)ch));
     
     return value;
   }
@@ -139,7 +139,7 @@
 
   int ok = EVP_DigestInit_ex (m_context, HASH_FUNCTION (), 0);
   if (!ok)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("EVP_DigestInit_ex returned error")
                            << errmsg_info_int (ok));
 }
@@ -155,7 +155,7 @@
   int ok = EVP_DigestFinal_ex (m_context,
 			       m_buffer, &m_hashLength);
   if (!ok)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("EVP_DigestFinal_ex returned error")
                            << errmsg_info_int (ok));
 }
@@ -167,7 +167,7 @@
     finalize ();
 
   if (sizeof (std::size_t) > m_hashLength)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("Hash length is less than size_t")
                            << errmsg_info_int (m_hashLength));
   
@@ -180,15 +180,15 @@
 Digest::operator == (const Digest &digest) const
 {
   if (m_buffer == 0)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("Digest1 is empty"));
 
   if (digest.m_buffer == 0)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("Digest2 is empty"));
 
   if (m_hashLength != digest.m_hashLength)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("Digest lengths are not the same")
                            << errmsg_info_int (m_hashLength)
                            << errmsg_info_int (digest.m_hashLength));
@@ -204,12 +204,12 @@
   
   // cannot update Digest when it has been finalized
   if (m_buffer != 0)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("Digest has been already finalized"));
 
   bool ok = EVP_DigestUpdate (m_context, buffer, size);
   if (!ok)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("EVP_DigestUpdate returned error")
                            << errmsg_info_int (ok));
 }
@@ -219,7 +219,7 @@
 Digest::operator << (const Digest &src)
 {
   if (src.m_buffer == 0) 
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("Digest has not been yet finalized"));
 
   update (src.m_buffer, src.m_hashLength);
@@ -248,7 +248,7 @@
   is >> str; // read string first
 
   if (str.size () == 0)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("Input is empty"));
   
   // uint8_t padding = (3 - str.size () % 3) % 3;
@@ -256,7 +256,7 @@
 
   // only empty digest object can be used for reading
   if (digest.m_buffer != 0)
-    BOOST_THROW_EXCEPTION (DigestCalculationError ()
+    BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
                            << errmsg_info_str ("Digest has been already finalized"));
 
   digest.m_buffer = new uint8_t [EVP_MAX_MD_SIZE];
diff --git a/model/sync-digest.h b/model/sync-digest.h
index 04e6d13..528180d 100644
--- a/model/sync-digest.h
+++ b/model/sync-digest.h
@@ -130,7 +130,9 @@
   uint32_t m_hashLength;
 };
 
+namespace Error {
 struct DigestCalculationError : virtual boost::exception, virtual std::exception { };
+}
 
 typedef boost::shared_ptr<Digest> DigestPtr;
 typedef boost::shared_ptr<const Digest> DigestConstPtr;
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index a565003..f3c6aa2 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -28,33 +28,36 @@
 namespace Sync
 {
 
-SyncLogic::SyncLogic(string syncPrefix,
-			       function<void (string, uint32_t, uint32_t)> fetch,
-			       shared_ptr<CcnxWrapper> ccnxHandle)
+SyncLogic::SyncLogic (const string &syncPrefix,
+                      SyncCallback fetch,
+                      CcnxWrapperPtr ccnxHandle)
+  : m_syncPrefix (syncPrefix)
+  , m_fetch (fetch)
+  , m_ccnxHandle (ccnxHandle)
 {
-  m_syncPrefix = syncPrefix;
-  m_fetch = fetch;
-  m_ccnxHandle = ccnxHandle;
 }
 
-SyncLogic::~SyncLogic()
+SyncLogic::~SyncLogic ()
 {
 
 }
 
-void SyncLogic::processSyncData(string name, string dataBuffer)
+void
+SyncLogic::processSyncData (const string &name, const string &dataBuffer)
 {
 
 }
 
-void SyncLogic::addLocalNames(string prefix, uint32_t session, uint32_t seq)
+void
+SyncLogic::addLocalNames (const string &prefix, uint32_t session, uint32_t seq)
 {
   NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix);
   SeqNo seqN(session, seq);
   m_state.update(info, seqN);
 }
 
-void SyncLogic::respondSyncInterest(string interest)
+void
+SyncLogic::respondSyncInterest (const string &interest)
 {
   string hash = interest.substr(interest.find_last_of("/") + 1);
 
@@ -64,7 +67,8 @@
 
 }
 
-void SyncLogic::sendSyncInterest()
+void
+SyncLogic::sendSyncInterest ()
 {
   function<void (string, string)> f = bind(&SyncLogic::processSyncData, this, _1, _2);
   stringstream os;
@@ -74,7 +78,7 @@
   os << digest;
   string name;
   os >> name;
-  m_ccnxHandle->sendInterest(name, f);
+  m_ccnxHandle->sendInterest (name, f);
 }
 
-}
\ No newline at end of file
+}
diff --git a/model/sync-logic.h b/model/sync-logic.h
index 98adf17..62bf485 100644
--- a/model/sync-logic.h
+++ b/model/sync-logic.h
@@ -17,7 +17,7 @@
  *
  * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
  *         卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
- *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
 #ifndef SYNC_LOGIC_H
@@ -30,6 +30,8 @@
 #include "sync-full-state.h"
 #include "sync-std-name-info.h"
 
+#include "sync-diff-state-container.h"
+
 namespace Sync {
 
 /**
@@ -40,42 +42,46 @@
 class SyncLogic
 {
 public:
-	/**
-	 * @brief constructor for this class;
-	 * @param syncPrefix the name prefix to use for the Sync Interest
-	 * @param fetch the fetch function, which will be called to actually fetch
-	 * the app data when new remote names are learned
-	 */
-	SyncLogic(std::string syncPrefix, boost::function<void (std::string,
-	uint32_t, uint32_t)> fetch, boost::shared_ptr<CcnxWrapper> ccnxHandle);
+  typedef boost::function<void (const std::string &,uint32_t, uint32_t)> SyncCallback;
+  
+  /**
+   * @brief constructor for this class;
+   * @param syncPrefix the name prefix to use for the Sync Interest
+   * @param fetch the fetch function, which will be called to actually fetch
+   * the app data when new remote names are learned
+   */
+  SyncLogic (const std::string &syncPrefix, SyncCallback fetch, CcnxWrapperPtr ccnxHandle);
 
-	~SyncLogic();
-	/**
-	 * a wrapper for the same func in SyncApp
-	 */
-	void addLocalNames(std::string prefix, uint32_t session, uint32_t seq);
+  ~SyncLogic ();
+  
+  /**
+   * a wrapper for the same func in SyncApp
+   */
+  void addLocalNames (const std::string &prefix, uint32_t session, uint32_t seq);
 
-	/**
-	 * @brief respond to the Sync Interest; a lot of logic needs to go in here
-	 * @param interest the Sync Interest in string format
-	 */
-	void respondSyncInterest(std::string interest);
+  /**
+   * @brief respond to the Sync Interest; a lot of logic needs to go in here
+   * @param interest the Sync Interest in string format
+   */
+  void respondSyncInterest (const std::string &interest);
 
-	/**
-	 * @brief process the fetched sync data
-	 * @param dataBuffer the sync data
-	 */
-	void processSyncData(std::string name, std::string dataBuffer);
+  /**
+   * @brief process the fetched sync data
+   * @param dataBuffer the sync data
+   */
+  void processSyncData (const std::string &name, const std::string &dataBuffer);
 
 private:
-	void sendSyncInterest();
+  void sendSyncInterest ();
 
 private:
-	boost::shared_ptr<CcnxWrapper> m_ccnxHandle;
-	FullState m_state;
-	boost::function<void (std::string, uint32_t, uint32_t)> m_fetch;
-	SyncInterestTable m_syncInterestTable;
-	std::string m_syncPrefix;
+  FullState m_state;
+  DiffStateContainer m_log;  
+  SyncInterestTable m_syncInterestTable;
+
+  std::string m_syncPrefix;
+  SyncCallback m_fetch;
+  CcnxWrapperPtr m_ccnxHandle;
 };
 
 
diff --git a/model/sync-state-leaf-container.h b/model/sync-state-leaf-container.h
index 2c7e8b9..98adb1b 100644
--- a/model/sync-state-leaf-container.h
+++ b/model/sync-state-leaf-container.h
@@ -48,8 +48,10 @@
   }
 };
 
+/// @cond include_hidden 
 struct hashed { };
 struct ordered { };
+/// @endcond
 
 /**
  * \ingroup sync
diff --git a/model/sync-state-manager.cc b/model/sync-state-manager.cc
deleted file mode 100644
index 2680859..0000000
--- a/model/sync-state-manager.cc
+++ /dev/null
@@ -1,21 +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>
- */
diff --git a/model/sync-state-manager.h b/model/sync-state-manager.h
deleted file mode 100644
index cbd0b49..0000000
--- a/model/sync-state-manager.h
+++ /dev/null
@@ -1,42 +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_STATE_MANAGER_H
-#define SYNC_STATE_MANAGER_H
-
-#include "sync-diff-state-container.h"
-
-namespace Sync {
-
-class StateManager
-{
-public:
-private:
-  FullState m_state;
-  FullState m_localState;
-  DiffStateContainer m_log;  
-};
-
-
-} // Sync
-
-#endif // SYNC_STATE_MANAGER_H
diff --git a/model/sync-state.cc b/model/sync-state.cc
index 5e09655..4befe62 100644
--- a/model/sync-state.cc
+++ b/model/sync-state.cc
@@ -38,6 +38,8 @@
 
 typedef error_info<struct tag_errmsg, string> info_str; 
 
+using namespace Sync::Error;
+
 namespace Sync {
 
 #ifdef _DEBUG
diff --git a/model/sync-state.h b/model/sync-state.h
index 26ea5f4..7c0b98e 100644
--- a/model/sync-state.h
+++ b/model/sync-state.h
@@ -88,10 +88,12 @@
 std::istream &
 operator >> (std::istream &in, State &state);
 
+namespace Error {
 /**
  * @brief Will be thrown when XML cannot be properly decoded to State
  */
 struct SyncXmlDecodingFailure : virtual boost::exception, virtual std::exception { };
+}
 
 } // Sync