diff --git a/ndn-cpp/node.cpp b/ndn-cpp/node.cpp
index 5bee365..1461dbf 100644
--- a/ndn-cpp/node.cpp
+++ b/ndn-cpp/node.cpp
@@ -6,7 +6,6 @@
 #include <sys/time.h>
 #include "encoding/binary-xml-decoder.hpp"
 #include "c/encoding/binary-xml.h"
-#include "data.hpp"
 #include "node.hpp"
 
 using namespace std;
@@ -21,54 +20,23 @@
   gettimeofday(&t, NULL);
   return t.tv_sec * 1000.0 + t.tv_usec / 1000.0;
 }
-  
-Node::PitEntry::PitEntry(const ptr_lib::shared_ptr<const Interest> &interest, const OnData &onData, const OnTimeout &onTimeout)
-: interest_(interest), onData_(onData), onTimeout_(onTimeout)
-{
-  // Set up timeoutTime_.
-  if (interest_->getInterestLifetimeMilliseconds() >= 0.0)
-    timeoutTimeMilliseconds_ = getNowMilliseconds() + interest_->getInterestLifetimeMilliseconds();
-  else
-    // No timeout.
-    timeoutTimeMilliseconds_ = -1.0;
-  
-  // Set up interestStruct_.
-  // TODO: Doesn't this belong in the Interest class?
-  nameComponents_.reserve(interest_->getName().getComponentCount());
-  excludeEntries_.reserve(interest_->getExclude().getEntryCount());
-  ndn_Interest_init
-    (&interestStruct_, &nameComponents_[0], nameComponents_.capacity(), &excludeEntries_[0], excludeEntries_.capacity());
-  interest_->get(interestStruct_);  
-}
 
-bool Node::PitEntry::checkTimeout(Node *parent, double nowMilliseconds)
+void Node::construct()
 {
-  if (timeoutTimeMilliseconds_ >= 0.0 && nowMilliseconds >= timeoutTimeMilliseconds_) {
-    if (onTimeout_) {
-      // Ignore all exceptions.
-      try {
-        onTimeout_(interest_);
-      }
-      catch (...) { }
-    }
-    
-    return true;
-  }
-  else
-    return false;
+  ndndIdFetcherInterest_ = Interest(Name("/%C1.M.S.localhost/%C1.M.SRV/ndnd/KEY"), 4000.0);
 }
 
 void Node::expressInterest(const Interest &interest, const OnData &onData, const OnTimeout &onTimeout)
 {
+  // TODO: Properly check if we are already connected to the expected host.
+  if (!transport_->getIsConnected())
+    transport_->connect(*connectionInfo_, *this);
+  
   shared_ptr<PitEntry> pitEntry(new PitEntry(shared_ptr<const Interest>(new Interest(interest)), onData, onTimeout));
   pit_.push_back(pitEntry);
   
   shared_ptr<vector<unsigned char> > encoding = pitEntry->getInterest()->wireEncode();  
   
-  // TODO: Properly check if we are already connected to the expected host.
-  if (!transport_->getIsConnected())
-    transport_->connect(*connectionInfo_, *this);
-  
   transport_->send(*encoding);
 }
 
@@ -84,6 +52,38 @@
     expressInterest(Interest(name, 4000.0), onData, onTimeout);
 }
 
+void Node::registerPrefix(const Name &prefix, const OnInterest &onInterest, int flags)
+{
+  if (ndndId_.size() == 0) {
+    // First fetch the ndndId of the connected hub.
+    NdndIdFetcher fetcher(make_shared<NdndIdFetcher::Info>(this, prefix, onInterest, flags));
+    // It is OK for func_lib::function make a copy of the function object because the Info is in a shared_ptr.
+    expressInterest(ndndIdFetcherInterest_, fetcher, fetcher);
+  }
+  else
+    registerPrefixHelper(prefix, onInterest, flags);
+}
+
+void Node::NdndIdFetcher::operator()(const ptr_lib::shared_ptr<const Interest> &interest, const ptr_lib::shared_ptr<Data> &ndndIdData)
+{
+  if (ndndIdData->getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0) {
+    // Set the ndndId_ and continue.
+    info_->node_.ndndId_ = ndndIdData->getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest();
+    info_->node_.registerPrefixHelper(info_->prefix_, info_->onInterest_, info_->flags_);
+  }
+  // TODO: else need to log not getting the ndndId.
+}
+
+void Node::NdndIdFetcher::operator()(const ptr_lib::shared_ptr<const Interest> &timedOutInterest)
+{
+  // TODO: Log the timeout.
+}
+
+void Node::registerPrefixHelper(const Name &prefix, const OnInterest &onInterest, int flags)
+{
+  throw logic_error("need to finish implementing registerPrefix");
+}
+
 void Node::processEvents()
 {
   transport_->processEvents();
@@ -146,5 +146,41 @@
     
 	return iResult;
 }
+  
+Node::PitEntry::PitEntry(const ptr_lib::shared_ptr<const Interest> &interest, const OnData &onData, const OnTimeout &onTimeout)
+: interest_(interest), onData_(onData), onTimeout_(onTimeout)
+{
+  // Set up timeoutTime_.
+  if (interest_->getInterestLifetimeMilliseconds() >= 0.0)
+    timeoutTimeMilliseconds_ = getNowMilliseconds() + interest_->getInterestLifetimeMilliseconds();
+  else
+    // No timeout.
+    timeoutTimeMilliseconds_ = -1.0;
+  
+  // Set up interestStruct_.
+  // TODO: Doesn't this belong in the Interest class?
+  nameComponents_.reserve(interest_->getName().getComponentCount());
+  excludeEntries_.reserve(interest_->getExclude().getEntryCount());
+  ndn_Interest_init
+    (&interestStruct_, &nameComponents_[0], nameComponents_.capacity(), &excludeEntries_[0], excludeEntries_.capacity());
+  interest_->get(interestStruct_);  
+}
+
+bool Node::PitEntry::checkTimeout(Node *parent, double nowMilliseconds)
+{
+  if (timeoutTimeMilliseconds_ >= 0.0 && nowMilliseconds >= timeoutTimeMilliseconds_) {
+    if (onTimeout_) {
+      // Ignore all exceptions.
+      try {
+        onTimeout_(interest_);
+      }
+      catch (...) { }
+    }
+    
+    return true;
+  }
+  else
+    return false;
+}
 
 }
