diff --git a/js/ccnxProtocol.xpi b/js/ccnxProtocol.xpi
index f1b730a..1e59e8b 100644
--- a/js/ccnxProtocol.xpi
+++ b/js/ccnxProtocol.xpi
Binary files differ
diff --git a/js/ccnxProtocol/components/ccnxProtocolService.js b/js/ccnxProtocol/components/ccnxProtocolService.js
index 7651764..108b569 100644
--- a/js/ccnxProtocol/components/ccnxProtocolService.js
+++ b/js/ccnxProtocol/components/ccnxProtocolService.js
@@ -259,7 +259,7 @@
         var key = keyValue[0].trim();
         if (key.substr(0, 5) == "ccnx.") {
             if (keyValue.length >= 1) {
-                var value = keyValue[1].trim;
+                var value = keyValue[1].trim();
                 var nonNegativeInt = parseInt(value);
                 
                 if (key == "ccnx.MinSuffixComponents" && nonNegativeInt >= 0)
diff --git a/js/ccnxProtocol/modules/ndn-js.jsm b/js/ccnxProtocol/modules/ndn-js.jsm
index 268435c..e15a290 100644
--- a/js/ccnxProtocol/modules/ndn-js.jsm
+++ b/js/ccnxProtocol/modules/ndn-js.jsm
@@ -1,7 +1,7 @@
 /* This file is created by running make-ndn-js.jsm.sh in this directory.
  * It concatenates ndn-js-header.txt with all the ndn-js source files to
  *   make ndn-js.jsm .
- * author: ucla-cs
+ * author: Jeff Thompson
  * See COPYING for copyright and distribution information.
  */
 
@@ -27,7 +27,7 @@
 };
 
 /* 
- * @author: ucla-cs
+ * @author: Jeff Thompson
  * See COPYING for copyright and distribution information.
  * Provide the callback closure for the async communication methods in the NDN class.
  * This is a port of Closure.py from PyCCN, written by: 
@@ -123,142 +123,6 @@
 	this.port=port;
 }
 
-NDN.prototype.get = function(message){
-	if(this.host!=null && this.port!=null){
-		var output ='';
-		message = message.trim();
-		if(message==null || message =="" ){
-			console.log('INVALID INPUT TO GET');
-			return null;
-		}
-
-
-		//var array = Name.createNameArray(message);
-
-		int = new Interest(new Name(message));
-
-		int.InterestLifetime = 4200;
-
-		var hex = encodeToHexInterest(int);
-
-		//var result = get_java_socket_bridge().connectAndStart(ndnurl,ndnport,hex);
-
-		var result = get(this.host,this.port, hex);
-
-
-		if(LOG>0)console.log('BINARY RESPONSE IS ' +result);
-
-		if(result==null || result==undefined || result =="" ){
-			/*if(result[0] != '0'||result[1]!='4') {
-				if(LOG>2)console.log('INVALID ANSWER');
-			}*/
-			return null;
-		}
-
-		else{
-
-			co = decodeHexContentObject(result);
-
-			if(LOG>2) {
-				console.log('DECODED CONTENT OBJECT');
-				console.log(co);
-			}
-			return co;
-		}
-	}
-	else{
-
-		console.log('ERROR URL OR PORT NOT SET');
-
-		return null;
-
-	}
-
-
-}
-
-NDN.prototype.put = function(name,content){
-	if(this.host!=null && this.port!=null){
-
-		var co = this.get("/%C1.M.S.localhost/%C1.M.SRV/ccnd");
-
-		if(!co || !co.signedInfo || !co.signedInfo.publisher || !co.signedInfo.publisher.publisherPublicKeyDigest){
-			alert("Cannot contact router");
-
-			return null;
-		}
-
-		var ccnxnodename = co.signedInfo.publisher.publisherPublicKeyDigest;
-
-		name = name.trim();
-
-		var fe = new ForwardingEntry('selfreg',new Name(name),null, null, 3,2147483647);
-
-		var bytes = encodeForwardingEntry(fe);
-
-
-		var si = new SignedInfo();
-		si.setFields();
-
-		var co = new ContentObject(new Name(),si,bytes,new Signature()); 
-		co.sign();
-
-		var coBinary = encodeToBinaryContentObject(co);
-
-		//var ccnxnodename = unescape('%E0%A0%1E%099h%F9t%0C%E7%F46%1B%AB%F5%BB%05%A4%E5Z%AC%A5%E5%8Fs%ED%DE%B8%E0%13%AA%8F');
-
-		var interestName = new Name(['ccnx',ccnxnodename,'selfreg',coBinary]);
-
-		int = new Interest(interestName);
-		int.scope = 1;
-
-		var hex = encodeToHexInterest(int);
-
-		console.log('GOING TO PUT INTEREST OBJECT');
-
-		console.log(hex);
-
-		//var result = put(this.host,this.port, hex,name);
-
-
-	//if(LOG>3)console.log('received interest'); //from host'+ host +':'+port+' with name '+name);
-
-	//if(LOG>3)console.log('DATA ');
-
-	//if(LOG>3)console.log(result);
-
-	//interest = decodeHexInterest(result);
-
-	//console.log('SUCCESSFULLY PARSED INTEREST');
-
-	console.log('CREATING ANSWER');
-	var si = new SignedInfo();
-	si.setFields();
-
-	var answer = DataUtils.toNumbersFromString(content);
-
-	var co = new ContentObject(new Name(name),si,answer,new Signature()); 
-	co.sign();
-
-
-	var outputHex = encodeToHexContentObject(co);
-
-	//console.log('SENDING ANSWER');
-
-	//return get_java_socket_bridge().putAnswer(outputHex,name);
-
-	var result = put(this.host,this.port, hex,name,outputHex);
-
-
-	return result;
-	}
-	else{
-		console.log('ERROR URL OR PORT NOT SET');
-
-		return null;
-	}
-}
-
 /** Encode name as an Interest. If template is not null, use its attributes.
  *  Send the interest to host:port, read the entire response and call
  *  closure.upcall(Closure.UPCALL_CONTENT (or Closure.UPCALL_CONTENT_UNVERIFIED),
@@ -411,7 +275,7 @@
 
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class contains all CCNx tags
  */
@@ -568,7 +432,7 @@
 
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class represents CCNTime Objects
  */
@@ -672,55 +536,42 @@
 	
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui, Jeff Thompson
  * See COPYING for copyright and distribution information.
  * This class represents a Name as an array of components where each is a byte array.
  */
  
-
+/*
+ * Create a new Name from _components.
+ * If _components is a string, parse it as a URI.  Otherwise it is an array of components
+ * where each is a string, byte array, ArrayBuffer or Uint8Array. 
+ * Convert and store as an array of Uint8Array.
+ * If a component is a string, encode as utf8.
+ */
 var Name = function Name(_components){
-
-	if( typeof _components == 'string') {
-		
+	if( typeof _components == 'string') {		
 		if(LOG>3)console.log('Content Name String '+_components);
-		this.components = Name.makeBlob(Name.createNameArray(_components));
+		this.components = Name.createNameArray(_components);
 	}
-	else if(typeof _components === 'object' && _components instanceof Array ){
-		
+	else if(typeof _components === 'object'){		
 		if(LOG>4)console.log('Content Name Array '+_components);
-		this.components = Name.makeBlob(_components);
-
+		this.components = [];
+        for (var i = 0; i < _components.length; ++i)
+            this.add(_components[i]);
 	}
-	else if(_components==null){
+	else if(_components==null)
 		this.components =[];
-	}
-	else{
-
+	else
 		if(LOG>1)console.log("NO CONTENT NAME GIVEN");
-
-	}
 };
 
 Name.prototype.getName = function() {
     return this.to_uri();
 };
 
-Name.makeBlob=function(name){
-	
-	var blobArrays = new Array(name.length);
-
-	for(var i=0;i<name.length;i++){
-		if(typeof name[i] == 'string')
-			blobArrays[i]= DataUtils.toNumbersFromString( name[i] );
-		else if(typeof name[i] == 'object')
-			blobArrays[i]= name[i] ;
-		else 
-			if(LOG>4)console.log('NAME COMPONENT INVALID');
-	}
-	
-	return blobArrays;
-};
-
+/* Parse name as a URI and return an array of Uint8Array components.
+ *
+ */
 Name.createNameArray = function(name) {
     name = name.trim();
     if (name.length <= 0)
@@ -770,6 +621,9 @@
         }
         else
             array[i] = component;
+        
+        // Change the component to Uint8Array now.
+        array[i] = DataUtils.toNumbersFromString(array[i]);
     }
 
 	return array;
@@ -806,8 +660,27 @@
 	return CCNProtocolDTags.Name;
 };
 
-Name.prototype.add = function(param){
-	return this.components.push(param);
+/*
+ * component is a string, byte array, ArrayBuffer or Uint8Array.
+ * Convert to Uint8Array and add to this Name.
+ * If a component is a string, encode as utf8.
+ * Return the converted value.
+ */
+Name.prototype.add = function(component){
+    var result = null;
+    if(typeof component == 'string')
+        result = DataUtils.stringToUtf8Array(component);
+	else if(typeof component == 'object' && component instanceof Array)
+        result = new Uint8Array(component);
+	else if(typeof component == 'object' && component instanceof Uint8Array)
+        result = new Uint8Array(component);
+	else if(typeof component == 'object' && component instanceof ArrayBuffer)
+        // Make a copy.
+        result = new Uint8Array(component.slice(0, component.byteLength));
+	else 
+		if(LOG>4)console.log('NAME COMPONENT INVALID');
+    
+	return this.components.push(result);
 };
 
 // Return the escaped name string according to "CCNx URI Scheme".  Does not include "ccnx:".
@@ -820,6 +693,22 @@
 	return result;	
 };
 
+/*
+ * Return a new Name with the first nComponents components of this Name.
+ */
+Name.prototype.getPrefix = function(nComponents) {
+    return new Name(this.components.slice(0, nComponents));
+}
+
+/*
+ * Return a new ArrayBuffer of the component at i.
+ */
+Name.prototype.getComponent = function(i) {
+    var result = new ArrayBuffer(this.components[i].length);
+    new Uint8Array(result).set(this.components[i]);
+    return result;
+}
+
 /**
  * Return component as an escaped string according to "CCNx URI Scheme".
  * We can't use encodeURIComponent because that doesn't encode all the characters we want to.
@@ -855,7 +744,7 @@
 };
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class represents ContentObject Objects
  */
@@ -1443,7 +1332,7 @@
 };
 
  /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class represents Interest Objects
  */
@@ -1460,9 +1349,8 @@
 	this.childSelector = _childSelector;
 	this.answerOriginKind = _answerOriginKind;
 	this.scope = _scope;
-	this.interestLifetime = null;		// For now we don't have the ability to set an interest lifetime
-	this.nonce = _nonce;
-	
+	this.interestLifetime = _interestLifetime;  // number of seconds
+	this.nonce = _nonce;	
 
 	this.RECURSIVE_POSTFIX = "*";
 
@@ -1484,16 +1372,14 @@
 		this.name = new Name();
 		this.name.from_ccnb(decoder);
 
-		if (decoder.peekStartElement(CCNProtocolDTags.MinSuffixComponents)) {
+		if (decoder.peekStartElement(CCNProtocolDTags.MinSuffixComponents))
 			this.minSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MinSuffixComponents);
-		}
 
-		if (decoder.peekStartElement(CCNProtocolDTags.MaxSuffixComponents)) {
+		if (decoder.peekStartElement(CCNProtocolDTags.MaxSuffixComponents)) 
 			this.maxSuffixComponents = decoder.readIntegerElement(CCNProtocolDTags.MaxSuffixComponents);
-		}
 			
 		if (decoder.peekStartElement(CCNProtocolDTags.PublisherPublicKeyDigest)) {
-			this.publisherPublicKeyDigest = new publisherPublicKeyDigest();
+			this.publisherPublicKeyDigest = new PublisherPublicKeyDigest();
 			this.publisherPublicKeyDigest.from_ccnb(decoder);
 		}
 
@@ -1502,26 +1388,21 @@
 			this.exclude.from_ccnb(decoder);
 		}
 		
-		if (decoder.peekStartElement(CCNProtocolDTags.ChildSelector)) {
+		if (decoder.peekStartElement(CCNProtocolDTags.ChildSelector))
 			this.childSelector = decoder.readIntegerElement(CCNProtocolDTags.ChildSelector);
-		}
 		
-		if (decoder.peekStartElement(CCNProtocolDTags.AnswerOriginKind)) {
-			// call setter to handle defaulting
+		if (decoder.peekStartElement(CCNProtocolDTags.AnswerOriginKind))
 			this.answerOriginKind = decoder.readIntegerElement(CCNProtocolDTags.AnswerOriginKind);
-		}
 		
-		if (decoder.peekStartElement(CCNProtocolDTags.Scope)) {
+		if (decoder.peekStartElement(CCNProtocolDTags.Scope))
 			this.scope = decoder.readIntegerElement(CCNProtocolDTags.Scope);
-		}
 
-		if (decoder.peekStartElement(CCNProtocolDTags.InterestLifetime)) {
-			this.interestLifetime = decoder.readBinaryElement(CCNProtocolDTags.InterestLifetime);
-		}
+		if (decoder.peekStartElement(CCNProtocolDTags.InterestLifetime))
+			this.interestLifetime = DataUtils.bigEndianToUnsignedInt
+                (decoder.readBinaryElement(CCNProtocolDTags.InterestLifetime)) / 4096;
 		
-		if (decoder.peekStartElement(CCNProtocolDTags.Nonce)) {
+		if (decoder.peekStartElement(CCNProtocolDTags.Nonce))
 			this.nonce = decoder.readBinaryElement(CCNProtocolDTags.Nonce);
-		}
 		
 		decoder.readEndElement();
 };
@@ -1548,13 +1429,16 @@
 		if (null != this.childSelector) 
 			encoder.writeElement(CCNProtocolDTags.ChildSelector, this.childSelector);
 
-		//TODO Encode OriginKind
 		if (this.DEFAULT_ANSWER_ORIGIN_KIND != this.answerOriginKind && this.answerOriginKind!=null) 
 			encoder.writeElement(CCNProtocolDTags.AnswerOriginKind, this.answerOriginKind);
 		
 		if (null != this.scope) 
 			encoder.writeElement(CCNProtocolDTags.Scope, this.scope);
 		
+		if (null != this.interestLifetime) 
+			encoder.writeElement(CCNProtocolDTags.InterestLifetime, 
+                DataUtils.nonNegativeIntToBigEndian(this.interestLifetime * 4096));
+		
 		if (null != this.nonce)
 			encoder.writeElement(CCNProtocolDTags.Nonce, this.nonce);
 		
@@ -1673,7 +1557,7 @@
 ExcludeComponent.prototype.getElementLabel = function() { return CCNProtocolDTags.Component; };
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class represents Key Objects
  */
@@ -1869,7 +1753,7 @@
 };
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class represents Publisher and PublisherType Objects
  */
@@ -1966,7 +1850,7 @@
 
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class represents PublisherPublicKeyDigest Objects
  */
@@ -2018,7 +1902,7 @@
 };
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class represents Face Instances
  */
@@ -2180,7 +2064,7 @@
 
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  * This class represents Forwarding Entries
  */
@@ -2284,7 +2168,7 @@
 /*
  * This class is used to encode ccnb binary elements (blob, type/value pairs).
  * 
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  */
 
@@ -2329,20 +2213,21 @@
 	this.CODEC_NAME = "Binary";
 };
 
-
+/*
+ * Encode utf8Content as utf8.
+ */
 BinaryXMLEncoder.prototype.writeUString = function(/*String*/ utf8Content) {
-	this.encodeUString(this.ostream, utf8Content, XML_UDATA);
+	this.encodeUString(utf8Content, XML_UDATA);
 };
 
 
 BinaryXMLEncoder.prototype.writeBlob = function(
 		/*Uint8Array*/ binaryContent
-		//, /*int*/ offset, /*int*/ length
 		) {
 	
 	if(LOG >3) console.log(binaryContent);
 	
-	this.encodeBlob(this.ostream, binaryContent, this.offset, binaryContent.length);
+	this.encodeBlob(binaryContent, binaryContent.length);
 };
 
 
@@ -2351,12 +2236,12 @@
 	/*TreeMap<String,String>*/ attributes
 	) {
 
-	/*Long*/ dictionaryVal = tag; //stringToTag(tag);
+	/*Long*/ var dictionaryVal = tag; //stringToTag(tag);
 	
 	if (null == dictionaryVal) {
-		this.encodeUString(this.ostream, tag, XML_TAG);
+		this.encodeUString(tag, XML_TAG);
 	} else {
-		this.encodeTypeAndVal(XML_DTAG, dictionaryVal, this.ostream);
+		this.encodeTypeAndVal(XML_DTAG, dictionaryVal);
 	}
 	
 	if (null != attributes) {
@@ -2388,12 +2273,12 @@
 			// compressed format wants length of tag represented as length-1
 			// to save that extra bit, as tag cannot be 0 length.
 			// encodeUString knows to do that.
-			this.encodeUString(this.ostream, strAttr, XML_ATTR);
+			this.encodeUString(strAttr, XML_ATTR);
 		} else {
-			this.encodeTypeAndVal(XML_DATTR, dictionaryAttr, this.ostream);
+			this.encodeTypeAndVal(XML_DATTR, dictionaryAttr);
 		}
 		// Write value
-		this.encodeUString(this.ostream, strValue);
+		this.encodeUString(strValue);
 		
 	}
 }
@@ -2423,7 +2308,9 @@
 	return null;
 };
 
-
+/*
+ * If Content is a string, then encode as utf8 and write UDATA.
+ */
 BinaryXMLEncoder.prototype.writeElement = function(
 		//long 
 		tag, 
@@ -2471,9 +2358,7 @@
 		//int
 		type, 
 		//long 
-		val, 
-		//ArrayBufferView 
-		ostream
+		val
 		) {
 	
 	if(LOG>4) console.log('Encoding type '+ type+ ' and value '+ val);
@@ -2487,14 +2372,14 @@
 	// Encode backwards. Calculate how many bytes we need:
 	var numEncodingBytes = this.numEncodingBytes(val);
 	
-	if ((this.offset + numEncodingBytes) > ostream.length) {
-		throw new Error("Buffer space of " + (ostream.length - this.offset) + 
+	if ((this.offset + numEncodingBytes) > this.ostream.length) {
+		throw new Error("Buffer space of " + (this.ostream.length - this.offset) + 
 											" bytes insufficient to hold " + 
 											numEncodingBytes + " of encoded type and value.");
 	}
 
 	// Bottom 4 bits of val go in last byte with tag.
-	ostream[this.offset + numEncodingBytes - 1] = 
+	this.ostream[this.offset + numEncodingBytes - 1] = 
 		//(byte)
 			(BYTE_MASK &
 					(((XML_TT_MASK & type) | 
@@ -2506,7 +2391,7 @@
 	// is "more" flag.
 	var i = this.offset + numEncodingBytes - 2;
 	while ((0 != val) && (i >= this.offset)) {
-		ostream[i] = //(byte)
+		this.ostream[i] = //(byte)
 				(BYTE_MASK & (val & XML_REG_VAL_MASK)); // leave top bit unset
 		val = val >>> XML_REG_VAL_BITS;
 		--i;
@@ -2520,37 +2405,29 @@
 	return numEncodingBytes;
 };
 
-
+/*
+ * Encode ustring as utf8.
+ */
 BinaryXMLEncoder.prototype.encodeUString = function(
-		//OutputStream 
-		ostream, 
 		//String 
 		ustring, 
 		//byte 
 		type) {
 	
-	if ((null == ustring) || (ustring.length == 0)) {
+	if (null == ustring)
 		return;
-	}
+	if (type == XML_TAG || type == XML_ATTR && ustring.length == 0)
+		return;
 	
 	if(LOG>3) console.log("The string to write is ");
 	if(LOG>3) console.log(ustring);
 
-	//COPY THE STRING TO AVOID PROBLEMS
-	strBytes = new Array(ustring.length);
-
-	for (i = 0; i < ustring.length; i++) //in InStr.ToCharArray())
-	{
-		if(LOG>3) console.log('ustring[' + i + '] = ' + ustring[i]);
-		strBytes[i] = ustring.charCodeAt(i);
-	}
-	
-	//strBytes = DataUtils.getBytesFromUTF8String(ustring);
+	var strBytes = DataUtils.stringToUtf8Array(ustring);
 	
 	this.encodeTypeAndVal(type, 
 						(((type == XML_TAG) || (type == XML_ATTR)) ?
 								(strBytes.length-1) :
-								strBytes.length), ostream);
+								strBytes.length));
 	
 	if(LOG>3) console.log("THE string to write is ");
 	
@@ -2563,13 +2440,9 @@
 
 
 BinaryXMLEncoder.prototype.encodeBlob = function(
-		//OutputStream 
-		ostream, 
 		//Uint8Array 
 		blob, 
 		//int 
-		offset, 
-		//int 
 		length) {
 
 
@@ -2585,7 +2458,7 @@
 		blobCopy[i] = blob[i];
 	}*/
 
-	this.encodeTypeAndVal(XML_BLOB, length, ostream, offset);
+	this.encodeTypeAndVal(XML_BLOB, length);
 
 	this.writeBlobArray(blob, this.offset);
 	this.offset += length;
@@ -2694,7 +2567,7 @@
 /*
  * This class is used to decode ccnb binary elements (blob, type/value pairs).
  * 
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  */
 
@@ -2778,13 +2651,13 @@
 	try {
 
 		//this.TypeAndVal 
-		nextTV = this.peekTypeAndVal();
+		var nextTV = this.peekTypeAndVal();
 
 		while ((null != nextTV) && ((XML_ATTR == nextTV.type()) ||
 				(XML_DATTR == nextTV.type()))) {
 
 			//this.TypeAndVal 
-			thisTV = this.decodeTypeAndVal();
+			var thisTV = this.decodeTypeAndVal();
 
 			var attributeName = null;
 			if (XML_ATTR == thisTV.type()) {
@@ -2846,7 +2719,7 @@
 			}
 			
 			//String 
-			decodedTag = null;
+			var decodedTag = null;
 			//console.log(tv);
 			//console.log(typeof tv);
 			
@@ -2903,17 +2776,17 @@
 	try {
 		// Now need to get attributes.
 		//TypeAndVal 
-		nextTV = this.peekTypeAndVal();
+		var nextTV = this.peekTypeAndVal();
 
 		while ((null != nextTV) && ((XML_ATTR == nextTV.type()) ||
 				(XML_DATTR == nextTV.type()))) {
 
 			// Decode this attribute. First, really read the type and value.
 			//this.TypeAndVal 
-			thisTV = this.decodeTypeAndVal();
+			var thisTV = this.decodeTypeAndVal();
 
 			//String 
-			attributeName = null;
+			var attributeName = null;
 			if (XML_ATTR == thisTV.type()) {
 				// Tag value represents length-1 as attribute names cannot be empty.
 				var valval ;
@@ -2934,7 +2807,7 @@
 			}
 			// Attribute values are always UDATA
 			//String
-			attributeValue = this.decodeUString();
+			var attributeValue = this.decodeUString();
 
 			//
 			attributes.push([attributeName, attributeValue]);
@@ -2951,13 +2824,13 @@
 	//this.istream.mark(MARK_LEN);
 
 	//String 
-	decodedTag = null;
+	var decodedTag = null;
 	var previousOffset = this.offset;
 	try {
 		// Have to distinguish genuine errors from wrong tags. Could either use
 		// a special exception subtype, or redo the work here.
 		//this.TypeAndVal 
-		tv = this.decodeTypeAndVal();
+		var tv = this.decodeTypeAndVal();
 
 		if (null != tv) {
 
@@ -3002,7 +2875,7 @@
 		startTag) {
 	//String 
 	if(typeof startTag == 'string'){
-		decodedTag = this.peekStartElementAsString();
+		var decodedTag = this.peekStartElementAsString();
 		
 		if ((null !=  decodedTag) && decodedTag == startTag) {
 			return true;
@@ -3010,7 +2883,7 @@
 		return false;
 	}
 	else if(typeof startTag == 'number'){
-		decodedTag = this.peekStartElementAsLong();
+		var decodedTag = this.peekStartElementAsLong();
 		if ((null !=  decodedTag) && decodedTag == startTag) {
 			return true;
 		}
@@ -3025,7 +2898,7 @@
 		//this.istream.mark(MARK_LEN);
 
 		//Long
-		decodedTag = null;
+		var decodedTag = null;
 		
 		var previousOffset = this.offset;
 		
@@ -3033,7 +2906,7 @@
 			// Have to distinguish genuine errors from wrong tags. Could either use
 			// a special exception subtype, or redo the work here.
 			//this.TypeAndVal
-			tv = this.decodeTypeAndVal();
+			var tv = this.decodeTypeAndVal();
 
 			if (null != tv) {
 
@@ -3051,7 +2924,7 @@
 					
 					// Tag value represents length-1 as tags can never be empty.
 					//String 
-					strTag = this.decodeUString(valval);
+					var strTag = this.decodeUString(valval);
 					
 					decodedTag = stringToTag(strTag);
 					
@@ -3085,14 +2958,12 @@
 		//TreeMap<String, String> 
 		attributes){
 	//byte [] 
-	blob = null;
+	var blob = null;
 	
-		this.readStartElement(startTag, attributes);
-		blob = this.readBlob();
-	
+	this.readStartElement(startTag, attributes);
+	blob = this.readBlob();	
 
 	return blob;
-
 };
 	
 	
@@ -3117,7 +2988,7 @@
 //String	
 BinaryXMLDecoder.prototype.readUString = function(){
 			//String 
-			ustring = this.decodeUString();	
+			var ustring = this.decodeUString();	
 			this.readEndElement();
 			return ustring;
 
@@ -3128,7 +2999,7 @@
 BinaryXMLDecoder.prototype.readBlob = function() {
 			//byte []
 			
-			blob = this.decodeBlob();	
+			var blob = this.decodeBlob();	
 			this.readEndElement();
 			return blob;
 
@@ -3145,12 +3016,12 @@
 
 	//var lontimestamp = DataUtils.byteArrayToUnsignedLong(byteTimestamp);
 
-	var byteTimestamp = DataUtils.toHex(byteTimestamp);
+	byteTimestamp = DataUtils.toHex(byteTimestamp);
 	
 	
-	var byteTimestamp = parseInt(byteTimestamp, 16);
+	byteTimestamp = parseInt(byteTimestamp, 16);
 
-	lontimestamp = (byteTimestamp/ 4096) * 1000;
+	var lontimestamp = (byteTimestamp/ 4096) * 1000;
 
 	//if(lontimestamp<0) lontimestamp =  - lontimestamp;
 
@@ -3159,7 +3030,7 @@
 	
 
 	//CCNTime 
-	timestamp = new CCNTime(lontimestamp);
+	var timestamp = new CCNTime(lontimestamp);
 	//timestamp.setDateBinary(byteTimestamp);
 	
 	if (null == timestamp) {
@@ -3213,7 +3084,7 @@
 //TypeAndVal
 BinaryXMLDecoder.peekTypeAndVal = function() {
 	//TypeAndVal 
-	tv = null;
+	var tv = null;
 	
 	//this.istream.mark(LONG_BYTES*2);		
 	
@@ -3237,7 +3108,7 @@
 	
 	if(null == blobLength){
 		//TypeAndVal
-		tv = this.decodeTypeAndVal();
+		var tv = this.decodeTypeAndVal();
 
 		var valval ;
 		
@@ -3325,7 +3196,7 @@
 		var tempStreamPosition = this.offset;
 			
 		//TypeAndVal 
-		tv = this.decodeTypeAndVal();
+		var tv = this.decodeTypeAndVal();
 		
 		if(LOG>3)console.log('TV is '+tv);
 		if(LOG>3)console.log(tv);
@@ -3345,7 +3216,7 @@
 	}
 	else{
 		//byte [] 
-		stringBytes = this.decodeBlob(byteLength);
+		var stringBytes = this.decodeBlob(byteLength);
 		
 		//return DataUtils.getUTF8StringFromBytes(stringBytes);
 		return  DataUtils.toString(stringBytes);
@@ -3381,7 +3252,7 @@
 	if(LOG>4) console.log('READING INTEGER '+ startTag);
 	if(LOG>4) console.log('TYPE OF '+ typeof startTag);
 	
-	strVal = this.readUTF8Element(startTag);
+	var strVal = this.readUTF8Element(startTag);
 	
 	return parseInt(strVal);
 };
@@ -3396,7 +3267,7 @@
 
 		this.readStartElement(startTag, attributes); // can't use getElementText, can't get attributes
 		//String 
-		strElementText = this.readUString();
+		var strElementText = this.readUString();
 		return strElementText;
 };
 
@@ -3427,7 +3298,7 @@
  * This class uses BinaryXMLDecoder to follow the structure of a ccnb binary element to 
  * determine its end.
  * 
- * @author: ucla-cs
+ * @author: Jeff Thompson
  * See COPYING for copyright and distribution information.
  */
 
@@ -3547,7 +3418,7 @@
 
 /*
  * This class contains utilities to help parse the data
- * author: ucla-cs
+ * author: Meki Cheraoui, Jeff Thompson
  * See COPYING for copyright and distribution information.
  */
  
@@ -3831,6 +3702,14 @@
 }
 
 /*
+ * Encode str as utf8 and return as Uint8Array.
+ * TODO: Use TextEncoder when available.
+ */
+DataUtils.stringToUtf8Array = function(str) {
+    return DataUtils.toNumbersFromString(str2rstr_utf8(str));
+}
+
+/*
  * Return a new Uint8Array which is the Uint8Array concatenated with raw String str. 
  */
 DataUtils.concatFromString = function(array, str) {
@@ -3840,35 +3719,8 @@
 		bytes[array.length + i] = str.charCodeAt(i);
 	return bytes;
 }
-
-// TODO: Use TextEncoder and return Uint8Array.
-DataUtils.encodeUtf8 = function (string) {
-		string = string.replace(/\r\n/g,"\n");
-		var utftext = "";
  
-		for (var n = 0; n < string.length; n++) {
- 
-			var c = string.charCodeAt(n);
- 
-			if (c < 128) {
-				utftext += String.fromCharCode(c);
-			}
-			else if((c > 127) && (c < 2048)) {
-				utftext += String.fromCharCode((c >> 6) | 192);
-				utftext += String.fromCharCode((c & 63) | 128);
-			}
-			else {
-				utftext += String.fromCharCode((c >> 12) | 224);
-				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
-				utftext += String.fromCharCode((c & 63) | 128);
-			}
- 
-		}
- 
-		return utftext;
-	};
- 
-// TODO: Take Uint8Array and use TextDecoder.
+// TODO: Take Uint8Array and use TextDecoder when available.
 DataUtils.decodeUtf8 = function (utftext) {
 		var string = "";
 		var i = 0;
@@ -3974,19 +3826,28 @@
  * If value is 0 or negative, return Uint8Array(0). 
  */
 DataUtils.nonNegativeIntToBigEndian = function(value) {
+    value = Math.round(value);
     if (value <= 0)
         return new Uint8Array(0);
     
     // Assume value is not over 64 bits.
-    var result = new Uint8Array(8);
+    var size = 8;
+    var result = new Uint8Array(size);
     var i = 0;
     while (value != 0) {
-        result[i++] = value & 0xff;
+        ++i;
+        result[size - i] = value & 0xff;
         value >>= 8;
     }
-    return result.subarray(0, i);
+    return result.subarray(size - i, size);
 };
 
+/*
+ * This class defines MOME types based on the filename extension.
+ * author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+ 
 var MimeTypes = {
   /*
    * Based on filename, return an object with properties contentType and charset.
@@ -4532,53 +4393,32 @@
 
 /*
  * This file contains utilities to help encode and decode NDN objects.
- * author: ucla-cs
+ * author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  */
 
 function encodeToHexInterest(interest){
-	var enc = new BinaryXMLEncoder();
- 
-	interest.to_ccnb(enc);
-	
-	var hex = DataUtils.toHex(enc.getReducedOstream());
-
-	return hex;
-	
+    return DataUtils.toHex(encodeToBinaryInterest(interest));
 }
 
 
-function encodeToBinaryInterest(interest){
+function encodeToBinaryInterest(interest) {
 	var enc = new BinaryXMLEncoder();
- 
 	interest.to_ccnb(enc);
 	
-	var hex = enc.getReducedOstream();
-
-	return hex;
+	return enc.getReducedOstream();
 }
 
 
 function encodeToHexContentObject(co){
-	var enc = new BinaryXMLEncoder();
- 
-	co.to_ccnb(enc);
-	
-	var hex = DataUtils.toHex(enc.getReducedOstream());
-	
-	return hex;
-
-	
+    return DataUtils.toHex(encodeToBinaryContentObject(co));
 }
 
 function encodeToBinaryContentObject(co){
 	var enc = new BinaryXMLEncoder();
- 
 	co.to_ccnb(enc);
-	
-	var hex = enc.getReducedOstream();
 
-	return hex;
+	return enc.getReducedOstream();
 }
 
 function encodeForwardingEntry(co){
@@ -4675,11 +4515,8 @@
 	output+= "CONTENT NAME IS EMPTY"
     else{
 	if(co.name!=null && co.name.components!=null){
-	    output+= "NAME: ";
-	    
-	    for(var i=0;i<co.name.components.length;i++){
-		output+= "/"+ escape(DataUtils.toString(co.name.components[i]));
-	    }
+	    output+= "NAME: " + co.name.to_uri();
+        
 	    output+= "<br />";
 	    output+= "<br />";
 	}
@@ -4901,7 +4738,7 @@
 }
 
 /*
- * @author: ucla-cs
+ * @author: Meki Cheraoui
  * See COPYING for copyright and distribution information.
  */
 
@@ -7470,7 +7307,7 @@
 }
 
 
-//@author: ucla-cs
+//@author: Meki Cheraoui
 function _rsasign_getHexPaddedDigestInfoForStringHEX(s, keySize, hashAlg) {
   var pmStrLen = keySize / 4;
   var hashFunc = _RSASIGN_HASHHEXFUNC[hashAlg];
