Added var to properly declare local variables so that they don't pollute the global namespace and risk multi-threading conflicts.
diff --git a/js/tools/build/ndn-js-uncomp.js b/js/tools/build/ndn-js-uncomp.js
index e1d626d..e16d843 100644
--- a/js/tools/build/ndn-js-uncomp.js
+++ b/js/tools/build/ndn-js-uncomp.js
@@ -1144,7 +1144,7 @@
 		}
 
 		if (decoder.peekStartElement(CCNProtocolDTags.Type)) {
-			binType = decoder.readBinaryElement(CCNProtocolDTags.Type);//byte [] 
+			var binType = decoder.readBinaryElement(CCNProtocolDTags.Type);//byte [] 
 		
 			
 			//TODO Implement type of Key Reading
@@ -1714,7 +1714,7 @@
 
 	if (decoder.peekStartElement(CCNProtocolDTags.Key)) {
 		try {
-			encodedKey = decoder.readBinaryElement(CCNProtocolDTags.Key);
+			var encodedKey = decoder.readBinaryElement(CCNProtocolDTags.Key);
 			// This is a DER-encoded SubjectPublicKeyInfo.
 			
 			//TODO FIX THIS, This should create a Key Object instead of keeping bytes
@@ -1737,7 +1737,7 @@
 
 	} else if ( decoder.peekStartElement(CCNProtocolDTags.Certificate)) {
 		try {
-			encodedCert = decoder.readBinaryElement(CCNProtocolDTags.Certificate);
+			var encodedCert = decoder.readBinaryElement(CCNProtocolDTags.Certificate);
 			
 			/*
 			 * Certificates not yet working
@@ -1934,7 +1934,7 @@
 PublisherID.peek = function(/* XMLDecoder */ decoder) {
 
 		//Long
-		nextTag = decoder.peekStartElementAsLong();
+		var nextTag = decoder.peekStartElementAsLong();
 		
 		if (null == nextTag) {
 			// on end element
@@ -2780,52 +2780,6 @@
 	this.offset = 0;
 };
 
-BinaryXMLDecoder.prototype.readAttributes = function(
-	//TreeMap<String,String> 
-	attributes){
-	
-	if (null == attributes) {
-		return;
-	}
-
-	try {
-
-		//this.TypeAndVal 
-		var nextTV = this.peekTypeAndVal();
-
-		while ((null != nextTV) && ((XML_ATTR == nextTV.type()) ||
-				(XML_DATTR == nextTV.type()))) {
-
-			//this.TypeAndVal 
-			var thisTV = this.decodeTypeAndVal();
-
-			var attributeName = null;
-			if (XML_ATTR == thisTV.type()) {
-				
-				attributeName = this.decodeUString(thisTV.val()+1);
-
-			} else if (XML_DATTR == thisTV.type()) {
-				// DKS TODO are attributes same or different dictionary?
-				attributeName = tagToString(thisTV.val());
-				if (null == attributeName) {
-					throw new ContentDecodingException(new Error("Unknown DATTR value" + thisTV.val()));
-				}
-			}
-			
-			var attributeValue = this.decodeUString();
-
-			attributes.put(attributeName, attributeValue);
-
-			nextTV = this.peekTypeAndVal();
-		}
-
-	} catch ( e) {
-
-		throw new ContentDecodingException(new Error("readStartElement", e));
-	}
-};
-
-
 BinaryXMLDecoder.prototype.initializeDecoding = function() {
 		//if (!this.istream.markSupported()) {
 			//throw new IllegalArgumentException(this.getClass().getName() + ": input stream must support marking!");
@@ -2852,7 +2806,7 @@
 			//startTag = tagToString(startTag);
 		
 			//TypeAndVal 
-			tv = this.decodeTypeAndVal();
+			var tv = this.decodeTypeAndVal();
 			
 			if (null == tv) {
 				throw new ContentDecodingException(new Error("Expected start element: " + startTag + " got something not a tag."));
@@ -2906,7 +2860,7 @@
 	
 
 BinaryXMLDecoder.prototype.readAttributes = function(
-	//TreeMap<String,String> 
+	// array of [attributeName, attributeValue] 
 	attributes) {
 	
 	if (null == attributes) {
@@ -2930,11 +2884,11 @@
 			if (XML_ATTR == thisTV.type()) {
 				// Tag value represents length-1 as attribute names cannot be empty.
 				var valval ;
-				if(typeof tv.val() == 'string'){
-					valval = (parseInt(tv.val())) + 1;
+				if(typeof thisTV.val() == 'string'){
+					valval = (parseInt(thisTV.val())) + 1;
 				}
 				else
-					valval = (tv.val())+ 1;
+					valval = (thisTV.val())+ 1;
 				
 				attributeName = this.decodeUString(valval);
 
@@ -3270,68 +3224,10 @@
 	return bytes;
 };
 
-var count =0;
-
 //String
 BinaryXMLDecoder.prototype.decodeUString = function(
 		//int 
 		byteLength) {
-	
-	/*
-	console.log('COUNT IS '+count);
-	console.log('INPUT BYTELENGTH IS '+byteLength);
-	count++;
-	if(null == byteLength||  undefined == byteLength){
-		console.log("!!!!");
-		tv = this.decodeTypeAndVal();
-		var valval ;
-		if(typeof tv.val() == 'string'){
-			valval = (parseInt(tv.val()));
-		}
-		else
-			valval = (tv.val());
-		
-		if(LOG>4) console.log('valval  is ' + valval);
-		byteLength= this.decodeUString(valval);
-		
-		//if(LOG>4) console.log('byte Length found in type val is '+ byteLength.charCodeAt(0));
-		byteLength = parseInt(byteLength);
-		
-		
-		//byteLength = byteLength.charCodeAt(0);
-		//if(LOG>4) console.log('byte Length found in type val is '+ byteLength);
-	}
-	if(LOG>4)console.log('byteLength is '+byteLength);
-	if(LOG>4)console.log('type of byteLength is '+typeof byteLength);
-	
-	stringBytes = this.decodeBlob(byteLength);
-	
-	//console.log('String bytes are '+ stringBytes);
-	//console.log('stringBytes);
-	
-	if(LOG>4)console.log('byteLength is '+byteLength);
-	if(LOG>4)console.log('this.offset is '+this.offset);
-
-	tempBuffer = this.istream.slice(this.offset, this.offset+byteLength);
-	if(LOG>4)console.log('TEMPBUFFER IS' + tempBuffer);
-	if(LOG>4)console.log( tempBuffer);
-
-	if(LOG>4)console.log('ADDING to offset value' + byteLength);
-	this.offset+= byteLength;
-	//if(LOG>3)console.log('read the String' + tempBuffer.toString('ascii'));
-	//return tempBuffer.toString('ascii');//
-	
-	
-	//if(LOG>3)console.log( 'STRING READ IS '+ DataUtils.getUTF8StringFromBytes(stringBytes) ) ;
-	//if(LOG>3)console.log( 'STRING READ IS '+ DataUtils.getUTF8StringFromBytes(tempBuffer) ) ;
-	//if(LOG>3)console.log(DataUtils.getUTF8StringFromBytes(tempBuffer) ) ;
-	//return DataUtils.getUTF8StringFromBytes(tempBuffer);
-	
-	if(LOG>3)console.log( 'STRING READ IS '+ DataUtils.toString(stringBytes) ) ;
-	if(LOG>3)console.log( 'TYPE OF STRING READ IS '+ typeof DataUtils.toString(stringBytes) ) ;
-
-	return  DataUtils.toString(stringBytes);*/
-
 	if(null == byteLength ){
 		var tempStreamPosition = this.offset;
 			
@@ -3364,9 +3260,6 @@
 	}
 };
 
-
-
-
 //OBject containg a pair of type and value
 var TypeAndVal = function TypeAndVal(_type,_val) {
 	this.t = _type;
@@ -4092,7 +3985,7 @@
 	var numbers = DataUtils.toNumbers(result);
 			
 	
-	decoder = new BinaryXMLDecoder(numbers);
+	var decoder = new BinaryXMLDecoder(numbers);
 	
 	if(LOG>3)console.log('DECODING HEX FACE INSTANCE  \n'+numbers);
 
@@ -4109,7 +4002,7 @@
 function decodeHexInterest(result){
 	var numbers = DataUtils.toNumbers(result);	
 	
-	decoder = new BinaryXMLDecoder(numbers);
+	var decoder = new BinaryXMLDecoder(numbers);
 	
 	if(LOG>3)console.log('DECODING HEX INTERST  \n'+numbers);
 
@@ -4126,11 +4019,11 @@
 function decodeHexContentObject(result){
 	var numbers = DataUtils.toNumbers(result);
 	
-	decoder = new BinaryXMLDecoder(numbers);
+	var decoder = new BinaryXMLDecoder(numbers);
 	
 	if(LOG>3)console.log('DECODED HEX CONTENT OBJECT \n'+numbers);
 	
-	co = new ContentObject();
+	var co = new ContentObject();
 
 	co.from_ccnb(decoder);
 
@@ -4143,11 +4036,11 @@
 function decodeHexForwardingEntry(result){
 	var numbers = DataUtils.toNumbers(result);
 
-	decoder = new BinaryXMLDecoder(numbers);
+	var decoder = new BinaryXMLDecoder(numbers);
 	
 	if(LOG>3)console.log('DECODED HEX FORWARDING ENTRY \n'+numbers);
 	
-	forwardingEntry = new ForwardingEntry();
+	var forwardingEntry = new ForwardingEntry();
 
 	forwardingEntry.from_ccnb(decoder);
 
@@ -4554,7 +4447,7 @@
 			if (step == 4) {
 				// Start to decode digest hex string
 				len = witness[i+1];  // XXX: digest hex should always be 32 bytes
-				str = DataUtils.toHex(witness.subarray(i + 2, i + 2 + len));
+				var str = DataUtils.toHex(witness.subarray(i + 2, i + 2 + len));
 				this.path.digestList.push(str);  // digest hex string
 				//console.log(str);
 			}
@@ -5068,7 +4961,7 @@
   var slop;

   for(i = 0; i < s.length; ++i) {

     if(s.charAt(i) == b64pad) break;

-    v = b64map.indexOf(s.charAt(i));

+    var v = b64map.indexOf(s.charAt(i));

     if(v < 0) continue;

     if(k == 0) {

       ret += int2char(v >> 2);

@@ -5775,9 +5668,9 @@
 	  	msgHashValue = ff(byteArray);

 	  } else {

 	  	// Compute merkle hash

-		  h = hex_sha256_from_bytes(byteArray);

-		  index = witness.path.index;

-		  for (i = witness.path.digestList.length - 1; i >= 0; i--) {

+		  var h = hex_sha256_from_bytes(byteArray);

+		  var index = witness.path.index;

+		  for (var i = witness.path.digestList.length - 1; i >= 0; i--) {

 		  	var str = "";

 		  	if (index % 2 == 0) {

 		  		str = h + witness.path.digestList[i];

@@ -7625,12 +7518,13 @@
 /**
  * settings is an associative array with the following defaults:
  * {
- *   getTransport: function() { return new WebSocketTransport(); }
+ *   getTransport: function() { return new WebSocketTransport(); },
  *   getHostAndPort: transport.defaultGetHostAndPort,
  *   host: null, // If null, use getHostAndPort when connecting.
  *   port: 9696,
- *   onopen: function() { if (LOG > 3) console.log("NDN connection established."); }
- *   onclose: function() { if (LOG > 3) console.log("NDN connection closed."); }
+ *   onopen: function() { if (LOG > 3) console.log("NDN connection established."); },
+ *   onclose: function() { if (LOG > 3) console.log("NDN connection closed."); },
+ *   verify: true // If false, don't verify and call upcall with Closure.UPCALL_CONTENT_UNVERIFIED.
  * }
  * 
  * getHostAndPort is a function, on each call it returns a new { host: host, port: port } or