diff --git a/include/ndn-cpp/name.hpp b/include/ndn-cpp/name.hpp
index 59caef8..7d533d0 100644
--- a/include/ndn-cpp/name.hpp
+++ b/include/ndn-cpp/name.hpp
@@ -153,18 +153,29 @@
      * @param escapedString The escaped string.  It does not need to be null-terminated because we only scan to endOffset.
      * @param beginOffset The offset in escapedString of the beginning of the portion to decode.
      * @param endOffset The offset in escapedString of the end of the portion to decode.
-     * @return The component value as a Blob, or a Blob with a null pointer if escapedString is not a valid escaped component.
+     * @return The component value. If the escapedString is not a valid escaped component, then the component value is a null pointer.
      */
-    static Blob 
-    makeFromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset);
+    static Component 
+    fromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset);
+
+    /**
+     * Create a component whose value is the network-ordered encoding of the number.
+     * Note: if the number is zero, the result is empty.
+     * @param number The number to be encoded.
+     * @return The component value.
+     */
+    static Component 
+    fromNumber(uint64_t number);
     
     /**
-     * Make a component as the encoded segment number.
-     * @param segment The segment number.
-     * @return The component value as a Blob.
+     * Create a component whose value is the marker appended with the network-ordered encoding of the number.
+     * Note: if the number is zero, no bytes are used for the number - the result will have only the marker.
+     * @param number The number to be encoded.  
+     * @param marker The marker to use as the first byte of the component.
+     * @return The component value.
      */
-    static Blob 
-    makeSegment(unsigned long segment);
+    static Component 
+    fromNumberWithMarker(uint64_t number, uint8_t marker);
   
   private:
     Blob value_;
@@ -398,9 +409,22 @@
    * @return This name so that you can chain calls to append.
    */  
   Name& 
-  appendSegment(unsigned long segment)
+  appendSegment(uint64_t segment)
   {
-    components_.push_back(Component(Component::makeSegment(segment)));
+    components_.push_back(Component::fromNumberWithMarker(segment, 0x00));
+    return *this;
+  }
+
+  /**
+   * Append a component with the encoded version number.
+   * Note that this encodes the exact value of version without converting from a time representation.
+   * @param version The version number.
+   * @return This name so that you can chain calls to append.
+   */  
+  Name& 
+  appendVersion(uint64_t version)
+  {
+    components_.push_back(Component::fromNumberWithMarker(version, 0xFD));
     return *this;
   }
   
diff --git a/ndn-cpp/name.cpp b/ndn-cpp/name.cpp
index 4e619cc..c9b5e7f 100644
--- a/ndn-cpp/name.cpp
+++ b/ndn-cpp/name.cpp
@@ -124,8 +124,8 @@
   return result;
 }
 
-Blob 
-Name::Component::makeFromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset)
+Name::Component 
+Name::Component::fromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset)
 {
   string trimmedString(escapedString + beginOffset, escapedString + endOffset);
   trim(trimmedString);
@@ -135,27 +135,43 @@
     // Special case for component of only periods.  
     if (component.size() <= 2)
       // Zero, one or two periods is illegal.  Ignore this component.
-      return Blob();
+      return Component();
     else
       // Remove 3 periods.
-      return Blob((const uint8_t *)&component[3], component.size() - 3); 
+      return Component((const uint8_t *)&component[3], component.size() - 3); 
   }
   else
-    return Blob((const uint8_t *)&component[0], component.size()); 
+    return Component((const uint8_t *)&component[0], component.size()); 
 }
 
-Blob 
-Name::Component::makeSegment(unsigned long segment)
+Name::Component 
+Name::Component::fromNumber(uint64_t number)
 {
   shared_ptr<vector<uint8_t> > value(new vector<uint8_t>());
   
-  // Add the leading zero.
-  value->push_back(0);
+  // First encode in little endian.
+  while (number != 0) {
+    value->push_back(number & 0xff);
+    number >>= 8;
+  }
+  
+  // Make it big endian.
+  reverse(value->begin(), value->end());
+  return Blob(value);
+}
+
+Name::Component 
+Name::Component::fromNumberWithMarker(uint64_t number, uint8_t marker)
+{
+  shared_ptr<vector<uint8_t> > value(new vector<uint8_t>());
+  
+  // Add the leading marker.
+  value->push_back(marker);
   
   // First encode in little endian.
-  while (segment != 0) {
-    value->push_back(segment & 0xff);
-    segment >>= 8;
+  while (number != 0) {
+    value->push_back(number & 0xff);
+    number >>= 8;
   }
   
   // Make it big endian.
@@ -225,9 +241,9 @@
     if (iComponentEnd == string::npos)
       iComponentEnd = uri.size();
     
-    Blob component = Component::makeFromEscapedString(&uri[0], iComponentStart, iComponentEnd);
+    Component component = Component::fromEscapedString(&uri[0], iComponentStart, iComponentEnd);
     // Ignore illegal components.  This also gets rid of a trailing '/'.
-    if (component)
+    if (component.getValue())
       components_.push_back(Component(component));
     
     iComponentStart = iComponentEnd + 1;
