diff --git a/src/sync-intro-certificate.cc b/src/sync-intro-certificate.cc
index 13f4cad..f335933 100644
--- a/src/sync-intro-certificate.cc
+++ b/src/sync-intro-certificate.cc
@@ -10,8 +10,6 @@
 
 #include "sync-intro-certificate.h"
 
-#include <boost/date_time/posix_time/posix_time.hpp>
-
 using namespace ndn;
 using namespace std;
 using namespace boost;
@@ -27,11 +25,12 @@
 					    const MillisecondsSince1970& notAfter,
 					    const PublicKey& key,
 					    const IntroType& introType)
-  : m_keyName(keyName)
+  : m_nameSpace(nameSpace)
+  , m_keyName(keyName)
   , m_introType(introType)
 {
   Name certificateName = nameSpace;
-  certificateName.append("WOT").append(keyName).append("INTRO-CERT").append(signerName);
+  certificateName.append("WOT").append(keyName.wireEncode()).append("INTRO-CERT").append(signerName.wireEncode());
   switch(introType)
     {
     case PRODUCER:
@@ -43,10 +42,7 @@
     default:
       throw Error("Wrong Introduction Type!");
     }
-
-  posix_time::time_duration now = posix_time::microsec_clock::universal_time () - posix_time::ptime(gregorian::date (1970, boost::gregorian::Jan, 1));
-  uint64_t version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244));
-  certificateName.appendVersion(version);
+  certificateName.appendVersion();
  
   Data::setName(certificateName);
   setNotBefore(notBefore);
@@ -60,12 +56,13 @@
 					    const IdentityCertificate& identityCertificate,
 					    const Name& signerName,
 					    const IntroType& introType)
-  : m_introType(introType)
+  : m_nameSpace(nameSpace)
+  , m_introType(introType)
 {
   m_keyName = identityCertificate.getPublicKeyName();
 
   Name certificateName = nameSpace;
-  certificateName.append("WOT").append(m_keyName).append("INTRO-CERT").append(signerName);
+  certificateName.append("WOT").append(m_keyName.wireEncode()).append("INTRO-CERT").append(signerName.wireEncode());
   switch(introType)
     {
     case PRODUCER:
@@ -77,11 +74,9 @@
     default:
       throw Error("Wrong Introduction Type!");
     }
-  posix_time::time_duration now = posix_time::microsec_clock::universal_time () - posix_time::ptime(gregorian::date (1970, boost::gregorian::Jan, 1));
-  uint64_t version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244));
-  certificateName.appendVersion(version);
+  certificateName.appendVersion();
  
-  setName(certificateName);
+  Data::setName(certificateName);
   setNotBefore(identityCertificate.getNotBefore());
   setNotAfter(identityCertificate.getNotAfter());
   setPublicKeyInfo(identityCertificate.getPublicKeyInfo());
@@ -90,48 +85,11 @@
   
 SyncIntroCertificate::SyncIntroCertificate (const Data& data)
   : Certificate(data)
-{
-  Name certificateName = getName();
-  int i = 0;
-  int keyNameStart = 0;
-  int keyNameEnd = 0;
-  for(; i < certificateName.size(); i++)
-    {
-      if(certificateName.get(i).toEscapedString() == string("WOT"))
-	{
-	  keyNameStart = i + 1;
-	  break;
-	}
-    }
-  
-  if(i >= certificateName.size())
-    throw Error("Wrong SyncIntroCertificate Name!");
-    
-  for(; i< certificateName.size(); i++)
-    {
-      if(certificateName.get(i).toEscapedString() == string("INTRO-CERT"))
-	{
-	  keyNameEnd = i;
-	  break;
-	}
-    }
-
-  if(i >= certificateName.size())
-    throw Error("Wrong SyncIntroCertificate Name!");
-
-  m_keyName = certificateName.getSubName(keyNameStart, keyNameEnd - keyNameStart);
-
-  string typeComponent = certificateName.get(certificateName.size() - 2).toEscapedString();
-  if(typeComponent == string("PRODUCER"))
-    m_introType = PRODUCER;
-  else if(typeComponent == string("INTRODUCER"))
-    m_introType = INTRODUCER;
-  else
-    throw Error("Wrong SyncIntroCertificate Name!");
-}
+{ setName(getName()); }
 
 SyncIntroCertificate::SyncIntroCertificate (const SyncIntroCertificate& chronosIntroCertificate)
   : Certificate(chronosIntroCertificate)
+  , m_nameSpace(chronosIntroCertificate.m_nameSpace)
   , m_keyName(chronosIntroCertificate.m_keyName)
   , m_introType(chronosIntroCertificate.m_introType)
 {}
@@ -139,43 +97,29 @@
 Data &
 SyncIntroCertificate::setName (const Name& certificateName)
 {
-  int i = 0;
-  int keyNameStart = 0;
-  int keyNameEnd = 0;
-  for(; i < certificateName.size(); i++)
-    {
-      if(certificateName.get(i).toEscapedString() == string("WOT"))
-	{
-	  keyNameStart = i + 1;
-	  break;
-	}
-    }
-    
-  if(i >= certificateName.size())
-    throw Error("Wrong SyncIntroCertificate Name!");
-  
-  for(; i< certificateName.size(); i++)
-    {
-      if(certificateName.get(i).toEscapedString() == string("INTRO-CERT"))
-	{
-	  keyNameEnd = i;
-	  break;
-	}
-    }
+  int nameLength = certificateName.size();
 
-  if(i >= certificateName.size())
+  if(nameLength < 6)
     throw Error("Wrong SyncIntroCertificate Name!");
 
-  m_keyName = certificateName.getSubName(keyNameStart, keyNameEnd - keyNameStart);
+  m_nameSpace = certificateName.getPrefix(-6);
 
-  string typeComponent = certificateName.get(certificateName.size() - 2).toEscapedString();
-  if(typeComponent == string("PRODUCER"))
+  if(!certificateName.get(-6).equals("WOT"))
+    throw Error("Wrong SyncIntroCertificate Name!");
+
+  m_keyName.wireDecode(Block(certificateName.get(-5).getValue().buf(), 
+                             certificateName.get(-5).getValue().size()));
+
+  if(!certificateName.get(-4).equals("INTRO-CERT"))
+    throw Error("Wrong SyncIntroCertificate Name!");
+
+  if(certificateName.get(-2).equals("PRODUCER"))
     m_introType = PRODUCER;
-  else if(typeComponent == string("INTRODUCER"))
+  else if(certificateName.get(-2).equals("INTRODUCER"))
     m_introType = INTRODUCER;
   else
     throw Error("Wrong SyncIntroCertificate Name!");
-    
+
   return *this;
 }
 
@@ -183,38 +127,20 @@
 SyncIntroCertificate::isSyncIntroCertificate(const Certificate& certificate)
 {
   const Name& certificateName = certificate.getName();
-  string introType = certificateName.get(certificateName.size() - 2).toEscapedString();
-  if(introType != string("PRODUCER") && introType != string("INTRODUCER"))
+
+  int nameLength = certificateName.size();
+
+  if(nameLength < 6)
     return false;
 
-  int i = 0;
-  bool findWot = false;
-  bool findIntroCert = false;
-  for(; i < certificateName.size(); i++)
-    {
-      if(certificateName.get(i).toEscapedString() == string("WOT"))
-	{
-	  findWot = true;
-	  break;
-	}
-    }
-    
-  if(!findWot)
+  if(!certificateName.get(-6).equals("WOT"))
     return false;
-  
-  for(; i < certificateName.size(); i++)
-    {
-      if(certificateName.get(i).toEscapedString() == string("INTRO-CERT"))
-	{
-	  findIntroCert = true;
-	  break;
-	}
-    }
-  if(!findIntroCert)
+
+  if(!certificateName.get(-4).equals("INTRO-CERT"))
     return false;
-  
-  if(i < certificateName.size() - 2)
-    return true;
-  
-  return false;    
+
+  if(!certificateName.get(-2).equals("PRODUCER") && !certificateName.get(-2).equals("INTRODUCER"))
+    return false;
+
+  return true;
 }
diff --git a/src/sync-intro-certificate.h b/src/sync-intro-certificate.h
index 7d0faa4..c9560ec 100644
--- a/src/sync-intro-certificate.h
+++ b/src/sync-intro-certificate.h
@@ -52,20 +52,34 @@
   ndn::Data&
   setName (const ndn::Name& name);
   
-  inline virtual ndn::Name 
-  getPublicKeyName () const
-  { return m_keyName; }
+  inline const ndn::Name &
+  getPublicKeyName() const;
   
   inline IntroType
-  getIntroType()
-  { return m_introType; }
+  getIntroType();
 
+  inline const ndn::Name &
+  getNameSpace() const;
+  
   static bool
   isSyncIntroCertificate(const ndn::Certificate& certificate);
 
 protected:
+  ndn::Name m_nameSpace;
   ndn::Name m_keyName;
   IntroType m_introType;
 };
 
+SyncIntroCertificate::IntroType
+SyncIntroCertificate::getIntroType()
+{ return m_introType; }
+
+const ndn::Name &
+SyncIntroCertificate::getPublicKeyName () const
+{ return m_keyName; }
+
+const ndn::Name &
+SyncIntroCertificate::getNameSpace() const
+{ return m_nameSpace; }
+
 #endif
