diff --git a/src/interest.cpp b/src/interest.cpp
index fe8faf3..2caffb1 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -8,139 +8,76 @@
 #include <stdexcept>
 #include <ndn-cpp/common.hpp>
 #include <ndn-cpp/interest.hpp>
-#include "c/interest.h"
 
 using namespace std;
 
 namespace ndn {
-  
-void 
-Exclude::Entry::get(struct ndn_ExcludeEntry& excludeEntryStruct) const 
+
+bool
+Interest::matchesName(const Name &name) const
 {
-  excludeEntryStruct.type = type_;
-  if (type_ == ndn_Exclude_COMPONENT)
-    component_.get(excludeEntryStruct.component);
+  if (!name_.isPrefixOf(name))
+    return false;
+  
+  if (minSuffixComponents_ >= 0 &&
+    // Add 1 for the implicit digest.
+      !(name.size() + 1 - name_.size() >= minSuffixComponents_))
+    return false;
+
+  if (maxSuffixComponents_ >= 0 &&
+    // Add 1 for the implicit digest.
+    !(name.size() + 1 - name_.size() <= maxSuffixComponents_))
+    return false;
+
+  if (!exclude_.empty() && name.size() > name_.size() &&
+      exclude_.isExcluded(name[name_.size()]))
+    return false;
+
+  return true;
 }
 
-void 
-Exclude::get(struct ndn_Exclude& excludeStruct) const
+std::ostream &
+operator << (std::ostream &os, const Interest &interest)
 {
-  if (excludeStruct.maxEntries < entries_.size())
-    throw runtime_error("excludeStruct.maxEntries must be >= this exclude getEntryCount()");
-  
-  excludeStruct.nEntries = entries_.size();
-  for (size_t i = 0; i < excludeStruct.nEntries; ++i)
-    entries_[i].get(excludeStruct.entries[i]);  
-}
+  os << interest.getName();
 
-void 
-Exclude::set(const struct ndn_Exclude& excludeStruct)
-{
-  entries_.clear();
-  for (size_t i = 0; i < excludeStruct.nEntries; ++i) {
-    ndn_ExcludeEntry *entry = &excludeStruct.entries[i];
-    
-    if (entry->type == ndn_Exclude_COMPONENT)
-      appendComponent(entry->component.value.value, entry->component.value.length);
-    else if (entry->type == ndn_Exclude_ANY)
-      appendAny();
-    else
-      throw runtime_error("unrecognized ndn_ExcludeType");
+  char delim = '?';
+
+  if (interest.getMinSuffixComponents() >= 0) {
+    os << delim << "ndn.MinSuffixComponents=" << interest.getMinSuffixComponents();
+    delim = '&';
   }
-}
-
-string 
-Exclude::toUri() const
-{
-  if (entries_.size() == 0)
-    return "";
-
-  ostringstream result;
-  for (unsigned i = 0; i < entries_.size(); ++i) {
-    if (i > 0)
-      result << ",";
-        
-    if (entries_[i].getType() == ndn_Exclude_ANY)
-      result << "*";
-    else
-      Name::toEscapedString(*entries_[i].getComponent().getValue(), result);
+  if (interest.getMaxSuffixComponents() >= 0) {
+    os << delim << "ndn.MaxSuffixComponents=" << interest.getMaxSuffixComponents();
+    delim = '&';
   }
-  
-  return result.str();  
-}
-
-void 
-Interest::set(const struct ndn_Interest& interestStruct) 
-{
-  name_.set(interestStruct.name);
-  minSuffixComponents_ = interestStruct.minSuffixComponents;
-  maxSuffixComponents_ = interestStruct.maxSuffixComponents;
-  
-  publisherPublicKeyDigest_.set(interestStruct.publisherPublicKeyDigest);
-  
-  exclude_.set(interestStruct.exclude);
-  childSelector_ = interestStruct.childSelector;
-  answerOriginKind_ = interestStruct.answerOriginKind;
-  scope_ = interestStruct.scope;
-  interestLifetimeMilliseconds_ = interestStruct.interestLifetimeMilliseconds;
-  nonce_ = Blob(interestStruct.nonce);
-}
-
-void 
-Interest::get(struct ndn_Interest& interestStruct) const 
-{
-  name_.get(interestStruct.name);
-  interestStruct.minSuffixComponents = minSuffixComponents_;
-  interestStruct.maxSuffixComponents = maxSuffixComponents_;
-  publisherPublicKeyDigest_.get(interestStruct.publisherPublicKeyDigest);
-  exclude_.get(interestStruct.exclude);
-  interestStruct.childSelector = childSelector_;
-  interestStruct.answerOriginKind = answerOriginKind_;
-  interestStruct.scope = scope_;
-  interestStruct.interestLifetimeMilliseconds = interestLifetimeMilliseconds_;
-  nonce_.get(interestStruct.nonce);
-}
-
-string 
-Interest::toUri() const
-{
-  ostringstream selectors;
-
-  if (minSuffixComponents_ >= 0)
-    selectors << "&ndn.MinSuffixComponents=" << minSuffixComponents_;
-  if (maxSuffixComponents_ >= 0)
-    selectors << "&ndn.MaxSuffixComponents=" << maxSuffixComponents_;
-  if (childSelector_ >= 0)
-    selectors << "&ndn.ChildSelector=" << childSelector_;
-  if (answerOriginKind_ >= 0)
-    selectors << "&ndn.AnswerOriginKind=" << answerOriginKind_;
-  if (scope_ >= 0)
-    selectors << "&ndn.Scope=" << scope_;
-  if (interestLifetimeMilliseconds_ >= 0)
-    selectors << "&ndn.InterestLifetime=" << interestLifetimeMilliseconds_;
-  if (publisherPublicKeyDigest_.getPublisherPublicKeyDigest().size() > 0) {
-    selectors << "&ndn.PublisherPublicKeyDigest=";
-    Name::toEscapedString(*publisherPublicKeyDigest_.getPublisherPublicKeyDigest(), selectors);
+  if (interest.getChildSelector() >= 0) {
+    os << delim << "ndn.ChildSelector=" << interest.getChildSelector();
+    delim = '&';
   }
-  if (nonce_.size() > 0) {
-    selectors << "&ndn.Nonce=";
-    Name::toEscapedString(*nonce_, selectors);
+  if (interest.getMustBeFresh()) {
+    os << delim << "ndn.MustBeFresh=" << interest.getMustBeFresh();
+    delim = '&';
   }
-  if (exclude_.size() > 0)
-    selectors << "&ndn.Exclude=" << exclude_.toUri();
-
-  ostringstream result;
-
-  result << name_.toUri();
-  string selectorsString(selectors.str());
-  if (selectorsString.size() > 0) {
-    // Replace the first & with ?.
-    result << "?";
-    result.write(&selectorsString[1], selectorsString.size() - 1);
+  if (interest.getScope() >= 0) {
+    os << delim << "ndn.Scope=" << interest.getScope();
+    delim = '&';
   }
-  
-  return result.str();  
+  if (interest.getInterestLifetime() >= 0) {
+    os << delim << "ndn.InterestLifetime=" << interest.getInterestLifetime();
+    delim = '&';
+  }
+
+  if (interest.getNonce() > 0) {
+    os << delim << "ndn.Nonce=" << interest.getNonce();
+    delim = '&';
+  }
+  if (!interest.getExclude().empty()) {
+    os << delim << "ndn.Exclude=" << interest.getExclude();
+    delim = '&';
+  }
+
+  return os;
 }
 
 }
-
