diff --git a/src/security/in-memory-pib-impl.cpp b/src/security/in-memory-pib-impl.cpp
deleted file mode 100644
index bf9d299..0000000
--- a/src/security/in-memory-pib-impl.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library 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 Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#include "in-memory-pib-impl.hpp"
-#include "pib.hpp"
-
-namespace ndn {
-namespace security {
-
-InMemoryPibImpl::InMemoryPibImpl()
-  : m_hasDefaultIdentity(false)
-{
-}
-
-void
-InMemoryPibImpl::setTpmLocator(const std::string& tpmLocator)
-{
-  throw Error("InMemoryPib/Tpm does not need a locator");
-}
-
-std::string
-InMemoryPibImpl::getTpmLocator() const
-{
-  return "tpm-memory:";
-}
-
-bool
-InMemoryPibImpl::hasIdentity(const Name& identity) const
-{
-  return (m_identities.count(identity) > 0);
-}
-
-void
-InMemoryPibImpl::addIdentity(const Name& identity)
-{
-  m_identities.insert(identity);
-}
-
-void
-InMemoryPibImpl::removeIdentity(const Name& identity)
-{
-  m_identities.erase(identity);
-  if (identity == m_defaultIdentity)
-    m_hasDefaultIdentity = false;
-}
-
-std::set<Name>
-InMemoryPibImpl::getIdentities() const
-{
-  return m_identities;
-}
-
-void
-InMemoryPibImpl::setDefaultIdentity(const Name& identityName)
-{
-  addIdentity(identityName);
-  m_defaultIdentity = identityName;
-  m_hasDefaultIdentity = true;
-}
-
-Name
-InMemoryPibImpl::getDefaultIdentity() const
-{
-  if (m_hasDefaultIdentity)
-    return m_defaultIdentity;
-
-  throw Pib::Error("No default identity");
-}
-
-bool
-InMemoryPibImpl::hasKey(const Name& identity, const name::Component& keyId) const
-{
-  return (m_keys.count(getKeyName(identity, keyId)) > 0);
-}
-
-void
-InMemoryPibImpl::addKey(const Name& identity, const name::Component& keyId, const PublicKey& publicKey)
-{
-  m_keys[getKeyName(identity, keyId)] = publicKey;
-}
-
-void
-InMemoryPibImpl::removeKey(const Name& identity, const name::Component& keyId)
-{
-  m_keys.erase(getKeyName(identity, keyId));
-}
-
-PublicKey
-InMemoryPibImpl::getKeyBits(const Name& identity, const name::Component& keyId) const
-{
-  auto it = m_keys.find(getKeyName(identity, keyId));
-  if (it == m_keys.end())
-    throw Pib::Error("No default certificate");
-
-  return it->second;
-}
-
-std::set<name::Component>
-InMemoryPibImpl::getKeysOfIdentity(const Name& identity) const
-{
-  std::set<name::Component> ids;
-  for (const auto& it : m_keys) {
-    if (identity == it.first.getPrefix(-1))
-      ids.insert(it.first.get(-1));
-  }
-  return ids;
-}
-
-void
-InMemoryPibImpl::setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId)
-{
-  Name keyName = getKeyName(identity, keyId);
-
-  if (!hasKey(identity, keyId))
-    throw Pib::Error("No key");
-
-  m_defaultKey[identity] = keyName;
-}
-
-name::Component
-InMemoryPibImpl::getDefaultKeyOfIdentity(const Name& identity) const
-{
-  auto it = m_defaultKey.find(identity);
-  if (it == m_defaultKey.end())
-    throw Pib::Error("No default key");
-
-  return it->second.get(-1);
-}
-
-Name
-InMemoryPibImpl::getKeyName(const Name& identity, const name::Component& keyId) const
-{
-  Name keyName = identity;
-  keyName.append(keyId);
-  return keyName;
-}
-
-bool
-InMemoryPibImpl::hasCertificate(const Name& certName) const
-{
-  return (m_certs.count(certName) > 0);
-}
-
-void
-InMemoryPibImpl::addCertificate(const IdentityCertificate& certificate)
-{
-  m_certs[certificate.getName()] = certificate;
-}
-
-void
-InMemoryPibImpl::removeCertificate(const Name& certName)
-{
-  m_certs.erase(certName);
-}
-
-IdentityCertificate
-InMemoryPibImpl::getCertificate(const Name& certName) const
-{
-  auto it = m_certs.find(certName);
-  if (it == m_certs.end())
-    throw Pib::Error("No cert");
-
-  return it->second;
-}
-
-std::set<Name>
-InMemoryPibImpl::getCertificatesOfKey(const Name& identity, const name::Component& keyId) const
-{
-  Name keyName = getKeyName(identity, keyId);
-
-  std::set<Name> certNames;
-  for (const auto& it : m_certs) {
-    if (it.second.getPublicKeyName() == keyName)
-      certNames.insert(it.first);
-  }
-  return certNames;
-}
-
-void
-InMemoryPibImpl::setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, const Name& certName)
-{
-  if (!hasCertificate(certName))
-    throw Pib::Error("No cert");
-
-  Name keyName = getKeyName(identity, keyId);
-  m_defaultCert[keyName] = certName;
-}
-
-IdentityCertificate
-InMemoryPibImpl::getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const
-{
-  Name keyName = getKeyName(identity, keyId);
-
-  auto it = m_defaultCert.find(keyName);
-  if (it == m_defaultCert.end())
-    throw Pib::Error("No default certificate");
-
-  auto certIt = m_certs.find(it->second);
-  if (certIt == m_certs.end())
-    throw Pib::Error("No default certificate");
-  else
-    return certIt->second;
-}
-
-} // namespace security
-} // namespace ndn
diff --git a/src/security/pib-impl.hpp b/src/security/pib-impl.hpp
index 5ece79e..fae035e 100644
--- a/src/security/pib-impl.hpp
+++ b/src/security/pib-impl.hpp
@@ -94,6 +94,7 @@
    * @brief Add an identity.
    *
    * If the identity already exists, do nothing.
+   * If no default identity has been set, set the added one as default identity.
    *
    * @param identity The name of the identity to add.
    */
@@ -104,6 +105,7 @@
    * @brief Remove an identity
    *
    * If the identity does not exist, do nothing.
+   * Remove related keys and certificates as well.
    *
    * @param identity The name of the identity to remove.
    */
@@ -151,6 +153,8 @@
    *
    * If the key already exists, do nothing.
    * If the identity does not exist, add the identity as well.
+   * If no default key of the identity has been set, set the added one as default
+   * key of the identity.
    *
    * @param identity The name of the belonged identity.
    * @param keyId The key id component.
@@ -163,6 +167,7 @@
    * @brief Remove a key.
    *
    * If the key does not exist, do nothing.
+   * Remove related certificates as well.
    *
    * @param identity The name of the belonged identity.
    * @param keyId The key id component.
@@ -227,6 +232,8 @@
    *
    * If the certificate already exists, do nothing.
    * If the key or identity do not exist, add them as well.
+   * If no default certificate of the key has been set, set the added one as
+   * default certificate of the key.
    *
    * @param certificate The certificate to add.
    */
diff --git a/src/security/pib-memory.cpp b/src/security/pib-memory.cpp
new file mode 100644
index 0000000..397b0db
--- /dev/null
+++ b/src/security/pib-memory.cpp
@@ -0,0 +1,257 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2015 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "pib-memory.hpp"
+#include "pib.hpp"
+
+namespace ndn {
+namespace security {
+
+PibMemory::PibMemory()
+  : m_hasDefaultIdentity(false)
+{
+}
+
+void
+PibMemory::setTpmLocator(const std::string& tpmLocator)
+{
+  throw Error("PibMemory does not need a locator");
+}
+
+std::string
+PibMemory::getTpmLocator() const
+{
+  return "tpm-memory:";
+}
+
+bool
+PibMemory::hasIdentity(const Name& identity) const
+{
+  return (m_identities.count(identity) > 0);
+}
+
+void
+PibMemory::addIdentity(const Name& identity)
+{
+  m_identities.insert(identity);
+
+  if (!m_hasDefaultIdentity) {
+    m_defaultIdentity = identity;
+    m_hasDefaultIdentity = true;
+  }
+}
+
+void
+PibMemory::removeIdentity(const Name& identity)
+{
+  m_identities.erase(identity);
+  if (identity == m_defaultIdentity)
+    m_hasDefaultIdentity = false;
+
+  auto keyIds = this->getKeysOfIdentity(identity);
+  for (const name::Component& keyId : keyIds) {
+    this->removeKey(identity, keyId);
+  }
+}
+
+std::set<Name>
+PibMemory::getIdentities() const
+{
+  return m_identities;
+}
+
+void
+PibMemory::setDefaultIdentity(const Name& identityName)
+{
+  addIdentity(identityName);
+  m_defaultIdentity = identityName;
+  m_hasDefaultIdentity = true;
+}
+
+Name
+PibMemory::getDefaultIdentity() const
+{
+  if (m_hasDefaultIdentity)
+    return m_defaultIdentity;
+
+  throw Pib::Error("No default identity");
+}
+
+bool
+PibMemory::hasKey(const Name& identity, const name::Component& keyId) const
+{
+  return (m_keys.count(getKeyName(identity, keyId)) > 0);
+}
+
+void
+PibMemory::addKey(const Name& identity, const name::Component& keyId, const PublicKey& publicKey)
+{
+  this->addIdentity(identity);
+
+  Name keyName = getKeyName(identity, keyId);
+  m_keys[keyName] = publicKey;
+
+  if (m_defaultKey.find(identity) == m_defaultKey.end())
+    m_defaultKey[identity] = keyName;
+}
+
+void
+PibMemory::removeKey(const Name& identity, const name::Component& keyId)
+{
+  Name keyName = getKeyName(identity, keyId);
+  m_keys.erase(keyName);
+  m_defaultKey.erase(identity);
+
+
+  auto certNames = this->getCertificatesOfKey(identity, keyId);
+  for (const auto& certName : certNames) {
+    this->removeCertificate(certName);
+  }
+}
+
+PublicKey
+PibMemory::getKeyBits(const Name& identity, const name::Component& keyId) const
+{
+  if (!hasKey(identity, keyId))
+    throw Pib::Error("No key");
+
+  auto it = m_keys.find(getKeyName(identity, keyId));
+  return it->second;
+}
+
+std::set<name::Component>
+PibMemory::getKeysOfIdentity(const Name& identity) const
+{
+  std::set<name::Component> ids;
+  for (const auto& it : m_keys) {
+    if (identity == it.first.getPrefix(-1))
+      ids.insert(it.first.get(-1));
+  }
+  return ids;
+}
+
+void
+PibMemory::setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId)
+{
+  Name keyName = getKeyName(identity, keyId);
+
+  if (!hasKey(identity, keyId))
+    throw Pib::Error("No key");
+
+  m_defaultKey[identity] = keyName;
+}
+
+name::Component
+PibMemory::getDefaultKeyOfIdentity(const Name& identity) const
+{
+  auto it = m_defaultKey.find(identity);
+  if (it == m_defaultKey.end())
+    throw Pib::Error("No default key");
+
+  return it->second.get(-1);
+}
+
+Name
+PibMemory::getKeyName(const Name& identity, const name::Component& keyId) const
+{
+  Name keyName = identity;
+  keyName.append(keyId);
+  return keyName;
+}
+
+bool
+PibMemory::hasCertificate(const Name& certName) const
+{
+  return (m_certs.count(certName) > 0);
+}
+
+void
+PibMemory::addCertificate(const IdentityCertificate& certificate)
+{
+  this->addKey(certificate.getPublicKeyName().getPrefix(-1),
+               certificate.getPublicKeyName().get(-1),
+               certificate.getPublicKeyInfo());
+
+  m_certs[certificate.getName()] = certificate;
+
+  const Name& keyName = certificate.getPublicKeyName();
+  if (m_defaultCert.find(keyName) == m_defaultCert.end())
+    m_defaultCert[keyName] = certificate.getName();
+}
+
+void
+PibMemory::removeCertificate(const Name& certName)
+{
+  m_certs.erase(certName);
+  m_defaultCert.erase(IdentityCertificate::certificateNameToPublicKeyName(certName));
+}
+
+IdentityCertificate
+PibMemory::getCertificate(const Name& certName) const
+{
+  if (!hasCertificate(certName))
+    throw Pib::Error("No cert");
+
+  auto it = m_certs.find(certName);
+  return it->second;
+}
+
+std::set<Name>
+PibMemory::getCertificatesOfKey(const Name& identity, const name::Component& keyId) const
+{
+  Name keyName = getKeyName(identity, keyId);
+
+  std::set<Name> certNames;
+  for (const auto& it : m_certs) {
+    if (it.second.getPublicKeyName() == keyName)
+      certNames.insert(it.first);
+  }
+  return certNames;
+}
+
+void
+PibMemory::setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, const Name& certName)
+{
+  if (!hasCertificate(certName))
+    throw Pib::Error("No cert");
+
+  Name keyName = getKeyName(identity, keyId);
+  m_defaultCert[keyName] = certName;
+}
+
+IdentityCertificate
+PibMemory::getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const
+{
+  Name keyName = getKeyName(identity, keyId);
+
+  auto it = m_defaultCert.find(keyName);
+  if (it == m_defaultCert.end())
+    throw Pib::Error("No default certificate");
+
+  auto certIt = m_certs.find(it->second);
+  if (certIt == m_certs.end())
+    throw Pib::Error("No default certificate");
+  else
+    return certIt->second;
+}
+
+} // namespace security
+} // namespace ndn
diff --git a/src/security/in-memory-pib-impl.hpp b/src/security/pib-memory.hpp
similarity index 95%
rename from src/security/in-memory-pib-impl.hpp
rename to src/security/pib-memory.hpp
index 8ef5bab..f21af00 100644
--- a/src/security/in-memory-pib-impl.hpp
+++ b/src/security/pib-memory.hpp
@@ -19,8 +19,8 @@
  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
  */
 
-#ifndef NDN_SECURITY_IN_MEMORY_PIB_IMPL_HPP
-#define NDN_SECURITY_IN_MEMORY_PIB_IMPL_HPP
+#ifndef NDN_SECURITY_PIB_MEMORY_HPP
+#define NDN_SECURITY_PIB_MEMORY_HPP
 
 #include "pib-impl.hpp"
 
@@ -33,7 +33,7 @@
  * All the contents in Pib are stored in memory
  * and have the same lifetime as the implementation instance.
  */
-class InMemoryPibImpl : public PibImpl
+class PibMemory : public PibImpl
 {
 public:
   class Error : public PibImpl::Error
@@ -47,7 +47,7 @@
   };
 
 public:
-  InMemoryPibImpl();
+  PibMemory();
 
 public: // TpmLocator management
 
@@ -150,4 +150,4 @@
 } // namespace security
 } // namespace ndn
 
-#endif // NDN_SECURITY_SEC_PIB_MEMORY_IMPL_HPP
+#endif // NDN_SECURITY_PIB_MEMORY_HPP
