For internal methods, don't pass istream as an argument since we use this.istream.
Added method seek(offset).
diff --git a/js/encoding/BinaryXMLDecoder.js b/js/encoding/BinaryXMLDecoder.js
index 23276cf..609bd99 100644
--- a/js/encoding/BinaryXMLDecoder.js
+++ b/js/encoding/BinaryXMLDecoder.js
@@ -1,5 +1,5 @@
 /*
- * This class is used to encode and decode binary elements ( blog, type/value pairs)
+ * This class is used to decode ccnb binary elements (blob, type/value pairs).
  * 
  * @author: ucla-cs
  * See COPYING for copyright and distribution information.
@@ -71,49 +71,9 @@
 	var DEBUG_MAX_LEN =  32768;
 	
 	this.istream = istream;
-	//console.log('istream is '+ this.istream);
 	this.offset = 0;
 };
 
-
-BinaryXMLDecoder.prototype.readStartElement =function(
-	//String
-	startTag,				    
-	//TreeMap<String, String>
-	attributes) {
-
-	try {
-		//this.TypeAndVal 
-		tv = this.decodeTypeAndVal(this.istream);
-
-		if (null == tv) {
-			throw new Error("Expected start element: " + startTag + " got something not a tag.");
-		}
-		
-		//String 
-		decodedTag = null;
-		
-		if (tv.type() == XML_TAG) {
-			
-			decodedTag = this.decodeUString(this.Istream, tv.val()+1);
-			
-		} else if (tv.type() == XML_DTAG) {
-			decodedTag = tagToString(tv.val());	
-		}
-		
-		if ((null ==  decodedTag) || decodedTag != startTag) {
-			throw new Error("Expected start element: " + startTag + " got: " + decodedTag + "(" + tv.val() + ")");
-		}
-		
-		if (null != attributes) {
-			readAttributes(attributes); 
-		}
-		
-	} catch (e) {
-		throw new Error("readStartElement", e);
-	}
-};
-
 BinaryXMLDecoder.prototype.readAttributes = function(
 	//TreeMap<String,String> 
 	attributes){
@@ -125,18 +85,18 @@
 	try {
 
 		//this.TypeAndVal 
-		nextTV = this.peekTypeAndVal(this.istream);
+		nextTV = this.peekTypeAndVal();
 
 		while ((null != nextTV) && ((XML_ATTR == nextTV.type()) ||
 				(XML_DATTR == nextTV.type()))) {
 
 			//this.TypeAndVal 
-			thisTV = this.decodeTypeAndVal(this.Istream);
+			thisTV = this.decodeTypeAndVal();
 
 			var attributeName = null;
 			if (XML_ATTR == thisTV.type()) {
 				
-				attributeName = this.decodeUString(this.istream, thisTV.val()+1);
+				attributeName = this.decodeUString(thisTV.val()+1);
 
 			} else if (XML_DATTR == thisTV.type()) {
 				// DKS TODO are attributes same or different dictionary?
@@ -146,11 +106,11 @@
 				}
 			}
 			
-			var attributeValue = this.decodeUString(this.istream);
+			var attributeValue = this.decodeUString();
 
 			attributes.put(attributeName, attributeValue);
 
-			nextTV = this.peekTypeAndVal(this.istream);
+			nextTV = this.peekTypeAndVal();
 		}
 
 	} catch ( e) {
@@ -187,7 +147,7 @@
 		
 		//try {
 			//TypeAndVal 
-			tv = this.decodeTypeAndVal(this.istream);
+			tv = this.decodeTypeAndVal();
 			
 			if (null == tv) {
 				throw new Error("Expected start element: " + startTag + " got something not a tag.");
@@ -212,7 +172,7 @@
 				
 				//console.log('valval is ' +valval);
 				
-				decodedTag = this.decodeUString(this.istream,  valval);
+				decodedTag = this.decodeUString(valval);
 				
 			} else if (tv.type() == XML_DTAG) {
 				//console.log('gothere');
@@ -256,14 +216,14 @@
 	try {
 		// Now need to get attributes.
 		//TypeAndVal 
-		nextTV = this.peekTypeAndVal(this.istream);
+		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(this.istream);
+			thisTV = this.decodeTypeAndVal();
 
 			//String 
 			attributeName = null;
@@ -276,7 +236,7 @@
 				else
 					valval = (tv.val())+ 1;
 				
-				attributeName = this.decodeUString(this.istream,valval);
+				attributeName = this.decodeUString(valval);
 
 			} else if (XML_DATTR == thisTV.type()) {
 				// DKS TODO are attributes same or different dictionary?
@@ -287,12 +247,12 @@
 			}
 			// Attribute values are always UDATA
 			//String
-			attributeValue = this.decodeUString(this.istream);
+			attributeValue = this.decodeUString();
 
 			//
 			attributes.push([attributeName, attributeValue]);
 
-			nextTV = this.peekTypeAndVal(this.istream);
+			nextTV = this.peekTypeAndVal();
 		}
 
 	} catch ( e) {
@@ -312,7 +272,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(this.istream);
+		tv = this.decodeTypeAndVal();
 
 		if (null != tv) {
 
@@ -329,7 +289,7 @@
 				else
 					valval = (tv.val())+ 1;
 				
-				decodedTag = this.decodeUString(this.istream, valval);
+				decodedTag = this.decodeUString(valval);
 				
 				//Log.info(Log.FAC_ENCODING, "Unexpected: got text tag in peekStartElement; length: " + valval + " decoded tag = " + decodedTag);
 
@@ -388,7 +348,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(this.istream);
+			tv = this.decodeTypeAndVal();
 
 			if (null != tv) {
 
@@ -406,7 +366,7 @@
 					
 					// Tag value represents length-1 as tags can never be empty.
 					//String 
-					strTag = this.decodeUString(this.istream, valval);
+					strTag = this.decodeUString(valval);
 					
 					decodedTag = stringToTag(strTag);
 					
@@ -476,7 +436,7 @@
 //String	
 BinaryXMLDecoder.prototype.readUString = function(){
 			//String 
-			ustring = this.decodeUString(this.istream);	
+			ustring = this.decodeUString();	
 			this.readEndElement();
 			return ustring;
 
@@ -487,7 +447,7 @@
 BinaryXMLDecoder.prototype.readBlob = function() {
 			//byte []
 			
-			blob = this.decodeBlob(this.istream);	
+			blob = this.decodeBlob();	
 			this.readEndElement();
 			return blob;
 
@@ -527,9 +487,7 @@
 	return timestamp;
 };
 
-BinaryXMLDecoder.prototype.decodeTypeAndVal = function(
-		/*InputStream*/
-		istream) {
+BinaryXMLDecoder.prototype.decodeTypeAndVal = function() {
 	
 	/*int*/next;
 	/*int*/type = -1;
@@ -577,20 +535,18 @@
 
 
 //TypeAndVal
-BinaryXMLDecoder.peekTypeAndVal = function(
-		//InputStream 
-		istream) {
+BinaryXMLDecoder.peekTypeAndVal = function() {
 	//TypeAndVal 
 	tv = null;
 	
-	//istream.mark(LONG_BYTES*2);		
+	//this.istream.mark(LONG_BYTES*2);		
 	
 	var previousOffset = this.offset;
 	
 	try {
-		tv = this.decodeTypeAndVal(this.istream);
+		tv = this.decodeTypeAndVal();
 	} finally {
-		//istream.reset();
+		//this.istream.reset();
 		this.offset = previousOffset;
 	}
 	
@@ -600,15 +556,13 @@
 
 //byte[]
 BinaryXMLDecoder.prototype.decodeBlob = function(
-		//InputStream 
-		istream, 
 		//int 
 		blobLength) {
 	
 	
 	if(null == blobLength){
 		//TypeAndVal
-		tv = this.decodeTypeAndVal(this.istream);
+		tv = this.decodeTypeAndVal();
 
 		var valval ;
 		
@@ -619,7 +573,7 @@
 			valval = (tv.val());
 		
 		//console.log('valval here is ' + valval);
-		return  this.decodeBlob(this.istream, valval);
+		return  this.decodeBlob(valval);
 	}
 	
 	//
@@ -639,8 +593,6 @@
 
 //String
 BinaryXMLDecoder.prototype.decodeUString = function(
-		//InputStream 
-		istream, 
 		//int 
 		byteLength) {
 	
@@ -650,7 +602,7 @@
 	count++;
 	if(null == byteLength||  undefined == byteLength){
 		console.log("!!!!");
-		tv = this.decodeTypeAndVal(this.istream);
+		tv = this.decodeTypeAndVal();
 		var valval ;
 		if(typeof tv.val() == 'string'){
 			valval = (parseInt(tv.val()));
@@ -659,7 +611,7 @@
 			valval = (tv.val());
 		
 		if(LOG>4) console.log('valval  is ' + valval);
-		byteLength= this.decodeUString(this.istream, valval);
+		byteLength= this.decodeUString(valval);
 		
 		//if(LOG>4) console.log('byte Length found in type val is '+ byteLength.charCodeAt(0));
 		byteLength = parseInt(byteLength);
@@ -671,7 +623,7 @@
 	if(LOG>4)console.log('byteLength is '+byteLength);
 	if(LOG>4)console.log('type of byteLength is '+typeof byteLength);
 	
-	stringBytes = this.decodeBlob(this.istream, byteLength);
+	stringBytes = this.decodeBlob(byteLength);
 	
 	//console.log('String bytes are '+ stringBytes);
 	//console.log('stringBytes);
@@ -703,7 +655,7 @@
 		var tempStreamPosition = this.offset;
 			
 		//TypeAndVal 
-		tv = this.decodeTypeAndVal(istream);
+		tv = this.decodeTypeAndVal();
 		
 		if(LOG>3)console.log('TV is '+tv);
 		if(LOG>3)console.log(tv);
@@ -719,11 +671,11 @@
 			return "";
 		}
 			
-		return this.decodeUString(istream, tv.val());
+		return this.decodeUString(tv.val());
 	}
 	else{
 		//byte [] 
-		stringBytes = this.decodeBlob(istream, byteLength);
+		stringBytes = this.decodeBlob(byteLength);
 		
 		//return DataUtils.getUTF8StringFromBytes(stringBytes);
 		return  DataUtils.toString(stringBytes);
@@ -787,3 +739,12 @@
 		strElementText = this.readUString();
 		return strElementText;
 };
+
+/* 
+ * Set the offset into the input, used for the next read.
+ */
+BinaryXMLDecoder.prototype.seek = function(
+        //int
+        offset) {
+    this.offset = offset;        
+}