diff --git a/src/sync-socket.cc b/src/sync-socket.cc
index f5e378f..b18f64c 100644
--- a/src/sync-socket.cc
+++ b/src/sync-socket.cc
@@ -37,11 +37,11 @@
                         const Name& dataPrefix,
                         uint64_t dataSession,
                         bool withRoutingPrefix,
-                        const Name& routingPrefix, 
+                        const Name& routingPrefix,
                         shared_ptr<Face> face,
                         const IdentityCertificate& myCertificate,
                         shared_ptr<SecRuleRelative> dataRule,
-                        NewDataCallback dataCallback, 
+                        NewDataCallback dataCallback,
                         RemoveCallback rmCallback )
   : m_dataPrefix(dataPrefix)
   , m_dataSession(dataSession)
@@ -61,9 +61,9 @@
   if(static_cast<bool>(dataRule))
     {
       m_withSecurity = true;
-      m_syncValidator = shared_ptr<Validator>(new SyncValidator(syncPrefix, 
-                                                                m_myCertificate, 
-                                                                m_face, 
+      m_syncValidator = shared_ptr<Validator>(new SyncValidator(syncPrefix,
+                                                                m_myCertificate,
+                                                                *m_face,
                                                                 bind(&SyncSocket::publishData, this, _1, _2, _3, true),
                                                                 dataRule));
     }
@@ -73,7 +73,7 @@
       m_syncValidator = shared_ptr<Validator>(new ValidatorNull());
     }
 
-  
+
   m_syncLogic = shared_ptr<SyncLogic>(new SyncLogic(syncPrefix,
                                                     myCertificate,
                                                     m_syncValidator,
@@ -93,7 +93,7 @@
   data->setContent(reinterpret_cast<const uint8_t*>(buf), len);
   data->setFreshnessPeriod(time::milliseconds(1000*freshness));
 
-  m_ioService->post(bind(&SyncSocket::publishDataInternal, this, 
+  m_ioService->post(bind(&SyncSocket::publishDataInternal, this,
                          data, isCert));
 }
 
@@ -136,7 +136,7 @@
   m_syncLogic->addLocalNames (dataPrefix, m_dataSession, sequence); // If DNS works, we should use pure m_dataprefix rather than the one with routing prefix.
 }
 
-void 
+void
 SyncSocket::fetchData(const Name& prefix, const SeqNo& seq, const OnDataValidated& dataCallback, int retry)
 {
   Name interestName = prefix;
@@ -145,8 +145,8 @@
   ndn::Interest interest(interestName);
   interest.setMustBeFresh(true);
 
-  m_face->expressInterest(interest, 
-                          bind(&SyncSocket::onData, this, _1, _2, dataCallback), 
+  m_face->expressInterest(interest,
+                          bind(&SyncSocket::onData, this, _1, _2, dataCallback),
                           bind(&SyncSocket::onDataTimeout, this, _1, retry, dataCallback));
 
 }
@@ -198,12 +198,12 @@
                                    _1,
                                    _2,
                                    dataCallback),
-                              bind(&SyncSocket::onDataTimeout, 
+                              bind(&SyncSocket::onDataTimeout,
                                    this,
                                    _1,
                                    retry - 1,
                                    dataCallback));
-                              
+
     }
   else
     _LOG_DEBUG("interest eventually time out!");
@@ -214,10 +214,10 @@
                             size_t interestNameSize,
                             const OnDataValidated& onValidated)
 {
-  if(data->getName().size() > interestNameSize 
+  if(data->getName().size() > interestNameSize
      && data->getName().get(interestNameSize).toEscapedString() == "INTRO-CERT")
     {
-      if(!m_withSecurity) 
+      if(!m_withSecurity)
         return;
 
       Data rawData;
diff --git a/src/sync-validator.cc b/src/sync-validator.cc
index f2c05bb..69e9232 100644
--- a/src/sync-validator.cc
+++ b/src/sync-validator.cc
@@ -26,10 +26,10 @@
 
 SyncValidator::SyncValidator(const Name& prefix,
                              const IdentityCertificate& anchor,
-                             shared_ptr<Face> face,
+                             Face& face,
                              const PublishCertCallback& publishCertCallback,
                              shared_ptr<SecRuleRelative> rule,
-                             shared_ptr<CertificateCache> certificateCache, 
+                             shared_ptr<CertificateCache> certificateCache,
                              const int stepLimit)
   : Validator(face)
   , m_prefix(prefix)
@@ -39,16 +39,13 @@
   , m_publishCertCallback(publishCertCallback)
   , m_dataRule(rule)
 {
-  if(!static_cast<bool>(face))
-    throw Error("Face is not set!");
-
   if(!static_cast<bool>(m_certificateCache))
-    m_certificateCache = make_shared<CertificateCacheTtl>(m_face->ioService());
+    m_certificateCache = make_shared<CertificateCacheTtl>(m_face.ioService());
 
   Name certPrefix = prefix;
   certPrefix.append("CHRONOS-INTRO-CERT");
-  m_prefixId = m_face->setInterestFilter(certPrefix, 
-                                         bind(&SyncValidator::onCertInterest, this, _1, _2), 
+  m_prefixId = m_face.setInterestFilter(certPrefix,
+                                         bind(&SyncValidator::onCertInterest, this, _1, _2),
                                          bind(&SyncValidator::onCertRegisterFailed, this, _1, _2));
 
   setAnchor(m_anchor);
@@ -83,7 +80,7 @@
             {
               // Check the nodes introduced by the trusted node.
               Edges::const_iterator edgeIt = m_introCerts.find(*eeIt);
-              if(edgeIt != m_introCerts.end() 
+              if(edgeIt != m_introCerts.end()
                  && m_trustedNodes.find(edgeIt->second.getIntroduceeCertName()) == m_trustedNodes.end()
                  && verifySignature(edgeIt->second, publicKey))
                 {
@@ -98,14 +95,14 @@
 }
 
 void
-SyncValidator::checkPolicy (const Data& data, 
-                            int stepCount, 
-                            const OnDataValidated& onValidated, 
+SyncValidator::checkPolicy (const Data& data,
+                            int stepCount,
+                            const OnDataValidated& onValidated,
                             const OnDataValidationFailed& onValidationFailed,
                             std::vector<shared_ptr<ValidationRequest> >& nextSteps)
 {
   if(m_stepLimit == stepCount)
-    return onValidationFailed(data.shared_from_this(), 
+    return onValidationFailed(data.shared_from_this(),
                               "Maximum steps of validation reached: " + data.getName().toUri());
 
   if(m_prefix.isPrefixOf(data.getName()) || (static_cast<bool>(m_dataRule) && m_dataRule->satisfy(data)))
@@ -121,25 +118,25 @@
               if(verifySignature(data, sig, it->second))
                 return onValidated(data.shared_from_this());
               else
-                return onValidationFailed(data.shared_from_this(), 
+                return onValidationFailed(data.shared_from_this(),
                                           "Cannot verify signature: " + data.getName().toUri());
             }
           else
             {
-              _LOG_DEBUG("I am: " << m_anchor.getName().get(0).toEscapedString() << " for " << data.getName()); 
+              _LOG_DEBUG("I am: " << m_anchor.getName().get(0).toEscapedString() << " for " << data.getName());
 
               Name interestName = m_prefix;
               interestName.append("CHRONOS-INTRO-CERT").append(keyLocatorName.wireEncode());
               Interest interest(interestName);
               interest.setInterestLifetime(time::milliseconds(500));
 
-              OnDataValidated onKeyValidated = bind(&SyncValidator::onCertificateValidated, this, 
+              OnDataValidated onKeyValidated = bind(&SyncValidator::onCertificateValidated, this,
                                                     _1, data.shared_from_this(), onValidated, onValidationFailed);
-              
-              OnDataValidationFailed onKeyValidationFailed = bind(&SyncValidator::onCertificateValidationFailed, this, 
-                                                                  _1, _2, data.shared_from_this(), onValidationFailed);              
 
-              shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(interest, 
+              OnDataValidationFailed onKeyValidationFailed = bind(&SyncValidator::onCertificateValidationFailed, this,
+                                                                  _1, _2, data.shared_from_this(), onValidationFailed);
+
+              shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(interest,
                                                                                       onKeyValidated,
                                                                                       onKeyValidationFailed,
                                                                                       1,
@@ -151,7 +148,7 @@
         }
       catch(SignatureSha256WithRsa::Error& e)
         {
-          return onValidationFailed(data.shared_from_this(), 
+          return onValidationFailed(data.shared_from_this(),
                                     "Not SignatureSha256WithRsa signature: " + std::string(e.what()));
         }
       catch(KeyLocator::Error& e)
@@ -166,9 +163,9 @@
 }
 
 void
-SyncValidator::checkPolicy (const Interest& interest, 
-                            int stepCount, 
-                            const OnInterestValidated& onValidated, 
+SyncValidator::checkPolicy (const Interest& interest,
+                            int stepCount,
+                            const OnInterestValidated& onValidated,
                             const OnInterestValidationFailed& onValidationFailed,
                             std::vector<shared_ptr<ValidationRequest> >& nextSteps)
 {
@@ -176,33 +173,33 @@
 }
 
 void
-SyncValidator::onCertificateValidated(const shared_ptr<const Data>& signCertificate, 
-                                      const shared_ptr<const Data>& data, 
-                                      const OnDataValidated& onValidated, 
+SyncValidator::onCertificateValidated(const shared_ptr<const Data>& signCertificate,
+                                      const shared_ptr<const Data>& data,
+                                      const OnDataValidated& onValidated,
                                       const OnDataValidationFailed& onValidationFailed)
 {
   try
     {
       IntroCertificate introCert(*signCertificate);
       addParticipant(introCert);
-      
+
       if(verifySignature(*data, introCert.getIntroduceeCert().getPublicKeyInfo()))
         return onValidated(data);
       else
-        return onValidationFailed(data, 
+        return onValidationFailed(data,
                                   "Cannot verify signature: " + data->getName().toUri());
     }
   catch(IntroCertificate::Error& e)
     {
-      return onValidationFailed(data, 
+      return onValidationFailed(data,
                                 "Intro cert decoding error: " + std::string(e.what()));
     }
 }
 
 void
-SyncValidator::onCertificateValidationFailed(const shared_ptr<const Data>& signCertificate, 
+SyncValidator::onCertificateValidationFailed(const shared_ptr<const Data>& signCertificate,
                                              const std::string& failureInfo,
-                                             const shared_ptr<const Data>& data, 
+                                             const shared_ptr<const Data>& data,
                                              const OnDataValidationFailed& onValidationFailed)
 {
   onValidationFailed(data, failureInfo);
@@ -211,13 +208,13 @@
 void
 SyncValidator::onCertInterest(const Name& prefix, const Interest& interest)
 {
-  Name name = interest.getName(); 
+  Name name = interest.getName();
   Edges::const_iterator it = m_introCerts.begin();
   for(; it != m_introCerts.end(); it++)
     {
       if(name.isPrefixOf(it->first))
         {
-          m_face->put(it->second);
+          m_face.put(it->second);
           return;
         }
     }
diff --git a/src/sync-validator.h b/src/sync-validator.h
index 00c92c8..65f14a3 100644
--- a/src/sync-validator.h
+++ b/src/sync-validator.h
@@ -32,16 +32,16 @@
 
   SyncValidator(const ndn::Name& prefix,
                 const ndn::IdentityCertificate& anchor,
-                ndn::shared_ptr<ndn::Face> face,
+                ndn::Face& face,
                 const PublishCertCallback& publishCertCallback,
                 ndn::shared_ptr<ndn::SecRuleRelative> rule = DefaultDataRule,
-                ndn::shared_ptr<ndn::CertificateCache> certificateCache = DefaultCertificateCache, 
+                ndn::shared_ptr<ndn::CertificateCache> certificateCache = DefaultCertificateCache,
                 const int stepLimit = 10);
 
   virtual
   ~SyncValidator()
   {
-    m_face->unsetInterestFilter(m_prefixId);
+    m_face.unsetInterestFilter(m_prefixId);
   }
 
   /**
@@ -50,7 +50,7 @@
    * The anchor should be the participant's own certificate.
    * This anchor node is the origin of the derived trust graph.
    * Once the new anchor is set, derive the TrustNode set.
-   * 
+   *
    * @param anchor.
    */
   inline void
@@ -58,7 +58,7 @@
 
   /**
    * @brief Add a node into the trust graph.
-   * 
+   *
    * The method also create an edge from trust anchor to the node.
    *
    * @param introducee.
@@ -90,39 +90,39 @@
     return (m_trustedNodes.find(certName.getPrefix(-1)) != m_trustedNodes.end());
   }
 #endif //_DEBUG
-  
+
 protected:
   /***********************
    * From ndn::Validator *
    ***********************/
   virtual void
-  checkPolicy (const ndn::Data& data, 
-               int stepCount, 
-               const ndn::OnDataValidated& onValidated, 
+  checkPolicy (const ndn::Data& data,
+               int stepCount,
+               const ndn::OnDataValidated& onValidated,
                const ndn::OnDataValidationFailed& onValidationFailed,
                std::vector<ndn::shared_ptr<ndn::ValidationRequest> >& nextSteps);
 
   virtual void
-  checkPolicy (const ndn::Interest& interest, 
-               int stepCount, 
-               const ndn::OnInterestValidated& onValidated, 
+  checkPolicy (const ndn::Interest& interest,
+               int stepCount,
+               const ndn::OnInterestValidated& onValidated,
                const ndn::OnInterestValidationFailed& onValidationFailed,
                std::vector<ndn::shared_ptr<ndn::ValidationRequest> >& nextSteps);
 private:
   void
   deriveTrustNodes();
 
-  
+
   void
-  onCertificateValidated(const ndn::shared_ptr<const ndn::Data>& signCertificate, 
-                         const ndn::shared_ptr<const ndn::Data>& data, 
-                         const ndn::OnDataValidated& onValidated, 
+  onCertificateValidated(const ndn::shared_ptr<const ndn::Data>& signCertificate,
+                         const ndn::shared_ptr<const ndn::Data>& data,
+                         const ndn::OnDataValidated& onValidated,
                          const ndn::OnDataValidationFailed& onValidationFailed);
-  
+
   void
   onCertificateValidationFailed(const ndn::shared_ptr<const ndn::Data>& signCertificate,
                                 const std::string& failureInfo,
-                                const ndn::shared_ptr<const ndn::Data>& data, 
+                                const ndn::shared_ptr<const ndn::Data>& data,
                                 const ndn::OnDataValidationFailed& onValidationFailed);
 
   void
@@ -136,7 +136,7 @@
 
   // Syncprefix
   ndn::Name m_prefix;
-  
+
   // The map
   typedef std::map<const ndn::Name, IntroNode> Nodes;
   typedef std::map<const ndn::Name, IntroCertificate> Edges;
@@ -147,7 +147,7 @@
   typedef std::map<const ndn::Name, ndn::PublicKey> TrustNodes;
   ndn::IdentityCertificate m_anchor;
   TrustNodes m_trustedNodes;
-  
+
   // others
   int m_stepLimit;
   ndn::shared_ptr<ndn::CertificateCache> m_certificateCache;
@@ -167,7 +167,7 @@
     IntroNode(const ndn::IdentityCertificate& idCert)
       : m_nodeName(idCert.getName().getPrefix(-1))
     {}
-    
+
     IntroNode(const IntroCertificate& introCert, bool isIntroducer)
     {
       if(isIntroducer)
@@ -180,8 +180,8 @@
           m_nodeName = introCert.getIntroduceeCertName();
           m_introducerCerts.push_back(introCert.getName());
         }
-    } 
-    
+    }
+
     ~IntroNode()
     {}
 
@@ -221,14 +221,14 @@
       if(std::find(m_introduceeCerts.begin(), m_introduceeCerts.end(), introCertName) == m_introduceeCerts.end())
         m_introduceeCerts.push_back(introCertName);
     }
-    
+
     void
     addIntroCertAsIntroducee(const ndn::Name& introCertName)
     {
       if(std::find(m_introducerCerts.begin(), m_introducerCerts.end(), introCertName) == m_introducerCerts.end())
         m_introducerCerts.push_back(introCertName);
     }
-  
+
   private:
     ndn::Name m_nodeName;
     std::vector<ndn::Name> m_introducerCerts;
@@ -241,7 +241,7 @@
 SyncValidator::setAnchor(const ndn::IdentityCertificate& anchor)
 {
   m_anchor = anchor;
-  
+
   // Add anchor into trust graph if it does not exist.
   IntroNode origin(m_anchor);
   Nodes::const_iterator nodeIt = m_introNodes.find(origin.name());
@@ -296,7 +296,7 @@
     = ndn::shared_ptr<IntroCertificate>(new IntroCertificate(m_prefix, introducee, m_anchor.getName().getPrefix(-1)));
 
   m_keychain.sign(*introCert, m_anchor.getName());
-  
+
   addParticipant(*introCert);
 
   // Publish certificate as normal data.
diff --git a/tests/test-sync-validator.cc b/tests/test-sync-validator.cc
index 6f77f86..ec50717 100644
--- a/tests/test-sync-validator.cc
+++ b/tests/test-sync-validator.cc
@@ -8,33 +8,33 @@
 
 BOOST_AUTO_TEST_SUITE(TestSyncValidator)
 
-void 
+void
 onValidated(const ndn::shared_ptr<const ndn::Data>& data)
 {
   BOOST_CHECK(true);
 }
 
-void 
+void
 onValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
                    const std::string& failureInfo)
 {
   BOOST_CHECK(false);
 }
 
-void 
+void
 onValidated2(const ndn::shared_ptr<const ndn::Data>& data)
 {
   BOOST_CHECK(false);
 }
 
-void 
+void
 onValidationFailed2(const ndn::shared_ptr<const ndn::Data>& data,
                     const std::string& failureInfo)
 {
   BOOST_CHECK(true);
 }
 
-void 
+void
 publishData(const uint8_t* buf, size_t len, int freshness)
 {
 }
@@ -70,13 +70,13 @@
   shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
   shared_ptr<Face> face = make_shared<Face>(ioService);
   shared_ptr<SecRuleRelative> rule;
-  SyncValidator validator(prefix, *anchor, face, 
+  SyncValidator validator(prefix, *anchor, *face,
                           bind(&publishData, _1, _2, _3),
                           rule);
 
   validator.addParticipant(*introducer);
   BOOST_CHECK(validator.canTrust(certName2));
-  
+
   IntroCertificate introCert(prefix, *introducee, certName2.getPrefix(-1));
   keychain.sign(introCert, certName2);
   validator.addParticipant(introCert);
@@ -108,7 +108,7 @@
   BOOST_CHECK(validator.canTrust(certName3));
   BOOST_CHECK(validator.canTrust(certName4) == false);
   BOOST_CHECK(validator.canTrust(certName5));
-  
+
 
   keychain.deleteIdentity(identity1);
   keychain.deleteIdentity(identity2);
@@ -153,13 +153,13 @@
   shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
   shared_ptr<Face> face = make_shared<Face>(ioService);
   shared_ptr<SecRuleRelative> rule;
-  SyncValidator validator(prefix, *anchor, face,
+  SyncValidator validator(prefix, *anchor, *face,
                           bind(&publishData, _1, _2, _3),
                           rule);
 
   validator.addParticipant(*introducer);
   BOOST_CHECK(validator.canTrust(certName2));
-  
+
   IntroCertificate introCert(prefix, *introducee, certName2.getPrefix(-1));
   keychain.sign(introCert, certName2);
   validator.addParticipant(introCert);
@@ -211,7 +211,7 @@
     : regPrefixId(0)
     , regPrefixId2(0)
   {}
-  
+
   void
   onInterest(ndn::shared_ptr<ndn::Face> face, ndn::shared_ptr<ndn::Data> data)
   {
@@ -231,7 +231,7 @@
   {}
 
   void
-  validate(ndn::shared_ptr<Sync::SyncValidator> validator, ndn::shared_ptr<ndn::Data> data, 
+  validate(ndn::shared_ptr<Sync::SyncValidator> validator, ndn::shared_ptr<ndn::Data> data,
            const ndn::Name& certName3, const ndn::Name& certName4)
   {
     validator->validate(*data,
@@ -261,17 +261,17 @@
   Name prefix("/Sync/TestSyncValidator/OnlineValidate");
   KeyChain keychain;
 
-  Name identity1("/TestSyncValidator/OnlineValidate-1/" 
+  Name identity1("/TestSyncValidator/OnlineValidate-1/"
                  + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
   Name certName1 = keychain.createIdentity(identity1);
   shared_ptr<IdentityCertificate> anchor = keychain.getCertificate(certName1);
 
-  Name identity2("/TestSyncValidator/OnlineValidate-2/" 
+  Name identity2("/TestSyncValidator/OnlineValidate-2/"
                  + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
   Name certName2 = keychain.createIdentity(identity2);
   shared_ptr<IdentityCertificate> introducer = keychain.getCertificate(certName2);
 
-  Name identity3("/TestSyncValidator/OnlineValidate-3/" 
+  Name identity3("/TestSyncValidator/OnlineValidate-3/"
                  + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count()));
   Name certName3 = keychain.createIdentity(identity3);
   shared_ptr<IdentityCertificate> introducee = keychain.getCertificate(certName3);
@@ -287,11 +287,11 @@
 
   shared_ptr<SecRuleRelative> rule;
   shared_ptr<SyncValidator> validator = shared_ptr<SyncValidator>
-    (new SyncValidator(prefix, *anchor, face2, bind(&publishData, _1, _2, _3), rule));
+    (new SyncValidator(prefix, *anchor, *face2, bind(&publishData, _1, _2, _3), rule));
 
   validator->addParticipant(*introducer);
   BOOST_CHECK(validator->canTrust(certName2));
-  
+
   shared_ptr<IntroCertificate> introCert = shared_ptr<IntroCertificate>(new IntroCertificate(prefix, *introducee, certName2.getPrefix(-1)));
   keychain.sign(*introCert, certName2);
   BOOST_CHECK(validator->canTrust(certName3) == false);
@@ -313,7 +313,7 @@
   regPrefixId = face->setInterestFilter(introCert->getName().getPrefix(-1),
                                        bind(&FacesFixture::onInterest, this, face, introCert),
                                        bind(&FacesFixture::onRegFailed, this));
-  
+
   regPrefixId2 = face->setInterestFilter(introCert2->getName().getPrefix(-1),
 					bind(&FacesFixture::onInterest2, this, face, introCert2),
 					bind(&FacesFixture::onRegFailed, this));
