diff --git a/rib/rib-entry.cpp b/rib/rib-entry.cpp
index db72d37..98c3b90 100644
--- a/rib/rib-entry.cpp
+++ b/rib/rib-entry.cpp
@@ -43,6 +43,11 @@
 
   if (it == end())
     {
+      if (entry.flags & ndn::nfd::ROUTE_FLAG_CAPTURE)
+        {
+          m_nFacesWithCaptureSet++;
+        }
+
       m_faces.push_back(entry);
       return true;
     }
@@ -56,8 +61,14 @@
 RibEntry::eraseFace(const FaceEntry& face)
 {
   RibEntry::iterator it = std::find_if(begin(), end(), bind(&compareFaceIdAndOrigin, _1, face));
+
   if (it != m_faces.end())
     {
+      if (it->flags & ndn::nfd::ROUTE_FLAG_CAPTURE)
+        {
+          m_nFacesWithCaptureSet--;
+        }
+
       m_faces.erase(it);
       return true;
     }
@@ -68,11 +79,20 @@
 }
 
 bool
+RibEntry::hasFace(const FaceEntry& face)
+{
+  RibEntry::const_iterator it = std::find_if(cbegin(), cend(),
+                                             bind(&compareFaceIdAndOrigin, _1, face));
+
+  return it != cend();
+}
+
+bool
 RibEntry::hasFaceId(const uint64_t faceId) const
 {
   RibEntry::const_iterator it = std::find_if(cbegin(), cend(), bind(&compareFaceId, _1, faceId));
 
-  return (it != cend());
+  return it != cend();
 }
 
 void
@@ -94,7 +114,115 @@
 RibEntry::FaceList::iterator
 RibEntry::eraseFace(FaceList::iterator face)
 {
-  return m_faces.erase(face);
+  if (face != m_faces.end())
+    {
+      if (face->flags & ndn::nfd::ROUTE_FLAG_CAPTURE)
+        {
+          m_nFacesWithCaptureSet--;
+        }
+
+      return m_faces.erase(face);
+    }
+
+  return m_faces.end();
+}
+
+void
+RibEntry::addInheritedFace(const FaceEntry& face)
+{
+  m_inheritedFaces.push_back(face);
+}
+
+void
+RibEntry::removeInheritedFace(const FaceEntry& face)
+{
+  FaceList::iterator it = findInheritedFace(face);
+  m_inheritedFaces.erase(it);
+}
+
+RibEntry::FaceList::iterator
+RibEntry::findInheritedFace(const FaceEntry& face)
+{
+  return std::find_if(m_inheritedFaces.begin(), m_inheritedFaces.end(),
+                      bind(&compareFaceId, _1, face.faceId));
+}
+
+bool
+RibEntry::hasInheritedFace(const FaceEntry& face)
+{
+  FaceList::const_iterator it = findInheritedFace(face);
+
+  return (it != m_inheritedFaces.end());
+}
+
+bool
+RibEntry::hasCapture() const
+{
+  return m_nFacesWithCaptureSet > 0;
+}
+
+bool
+RibEntry::hasChildInheritOnFaceId(uint64_t faceId) const
+{
+  for (RibEntry::const_iterator it = m_faces.begin(); it != m_faces.end(); ++it)
+    {
+      if (it->faceId == faceId && (it->flags & ndn::nfd::ROUTE_FLAG_CHILD_INHERIT))
+        {
+          return true;
+        }
+    }
+
+  return false;
+}
+
+shared_ptr<FaceEntry>
+RibEntry::getFaceWithLowestCostByFaceId(uint64_t faceId)
+{
+  shared_ptr<FaceEntry> face;
+
+  for (FaceList::iterator it = begin(); it != end(); ++it)
+    {
+      // Correct face ID
+      if (it->faceId == faceId)
+        {
+          // If this is the first face with this ID found
+          if (!static_cast<bool>(face))
+            {
+              face = make_shared<FaceEntry>(*it);
+            }
+          else if (it->cost < face->cost) // Found a face with a lower cost
+            {
+              face = make_shared<FaceEntry>(*it);
+            }
+        }
+    }
+
+    return face;
+}
+
+shared_ptr<FaceEntry>
+RibEntry::getFaceWithLowestCostAndChildInheritByFaceId(uint64_t faceId)
+{
+  shared_ptr<FaceEntry> face;
+
+  for (FaceList::iterator it = begin(); it != end(); ++it)
+    {
+      // Correct face ID and Child Inherit flag set
+      if (it->faceId == faceId && it->flags & ndn::nfd::ROUTE_FLAG_CHILD_INHERIT)
+        {
+          // If this is the first face with this ID found
+          if (!static_cast<bool>(face))
+            {
+              face = make_shared<FaceEntry>(*it);
+            }
+          else if (it->cost < face->cost) // Found a face with a lower cost
+            {
+              face = make_shared<FaceEntry>(*it);
+            }
+        }
+    }
+
+    return face;
 }
 
 std::ostream&
