diff --git a/src/intersectBed/intersectBed.cpp b/src/intersectBed/intersectBed.cpp
index 1535703d96a8f9649014a82f58ffc2b15d8df161..1ad73134b2083aeb3855d73132776d23ca3f3a05 100644
--- a/src/intersectBed/intersectBed.cpp
+++ b/src/intersectBed/intersectBed.cpp
@@ -88,21 +88,11 @@ BedIntersect::BedIntersect(string bedAFile, string bedBFile, bool anyHit,
 	// create new BED file objects for A and B
 	_bedA = new BedFile(bedAFile);
 	_bedB = new BedFile(bedBFile);
-	
-	// dealing with a proper file
-	if (_bedA->bedFile != "stdin") {   
-		if (_bamInput == false) 
-			IntersectBed();
-		else
-			IntersectBam(_bedA->bedFile);
-	}
-	// reading from stdin
-	else {  
-		if (_bamInput == false)
-			IntersectBed();
-		else
-			IntersectBam("stdin");			
-	}
+	  
+	if (_bamInput == false)
+		IntersectBed();
+	else
+		IntersectBam(bedAFile);			
 }
 
 
diff --git a/src/pairToBed/pairToBed.cpp b/src/pairToBed/pairToBed.cpp
index 5485f96c707f2dc1c5e7ed531e86f32c0f96fdce..4357d55d18a223aa645caa07f206fd96f8cbef19 100644
--- a/src/pairToBed/pairToBed.cpp
+++ b/src/pairToBed/pairToBed.cpp
@@ -33,35 +33,26 @@ bool IsCorrectMappingForBEDPE (const BamAlignment &bam) {
 */
 
 BedIntersectPE::BedIntersectPE(string bedAFilePE, string bedBFile, float overlapFraction, 
-						       string searchType, bool forceStrand, bool bamInput, bool bamOutput,
-						       bool useEditDistance) {
-
-	_bedAFilePE      = bedAFilePE;
-	_bedBFile        = bedBFile;
-	_overlapFraction = overlapFraction;
-	_forceStrand     = forceStrand;
-	_useEditDistance = useEditDistance;
-	_searchType      = searchType;
-	_bamInput        = bamInput;
-	_bamOutput       = bamOutput;
+						       string searchType, bool forceStrand, bool bamInput, 
+						       bool bamOutput,  bool uncompressedBam, bool useEditDistance) {
+
+	_bedAFilePE        = bedAFilePE;
+	_bedBFile          = bedBFile;
+	_overlapFraction   = overlapFraction;
+	_forceStrand       = forceStrand;
+	_useEditDistance   = useEditDistance;
+	_searchType        = searchType;
+	_bamInput          = bamInput;
+	_bamOutput         = bamOutput;
+    _isUncompressedBam = uncompressedBam;
 	
 	_bedA = new BedFilePE(bedAFilePE);
 	_bedB = new BedFile(bedBFile);
 	
-	// dealing with a proper file
-	if (_bedA->bedFile != "stdin") {   
-		if (_bamInput == false) 
-			IntersectBedPE();
-		else
-			IntersectBamPE(_bedA->bedFile);
-	}
-	// reading from stdin
-	else {  
-		if (_bamInput == false)
-			IntersectBedPE();
-		else
-			IntersectBamPE("stdin");			
-	}
+	if (_bamInput == false)
+		IntersectBedPE();
+	else
+		IntersectBamPE(_bedAFilePE);
 }
 
 
@@ -396,7 +387,7 @@ void BedIntersectPE::IntersectBamPE(string bamFile) {
 	// open a BAM output to stdout if we are writing BAM
 	if (_bamOutput == true) {
 		// open our BAM writer
-		writer.Open("stdout", header, refs);
+		writer.Open("stdout", header, refs, _isUncompressedBam);
 	}
 
 	// track the previous and current sequence
diff --git a/src/pairToBed/pairToBed.h b/src/pairToBed/pairToBed.h
index 68063c3484162c463cf0b042f965c286454c762a..0dd3910b3ed437db7c68772c4dab796d3ed0250b 100644
--- a/src/pairToBed/pairToBed.h
+++ b/src/pairToBed/pairToBed.h
@@ -43,7 +43,7 @@ public:
 
 	// constructor 
 	BedIntersectPE(string bedAFilePE, string bedBFile, float overlapFraction, 
-		string searchType, bool forceStrand, bool bamInput, bool bamOutput, bool useEditDistance);
+		string searchType, bool forceStrand, bool bamInput, bool bamOutput, bool uncompressedBam, bool useEditDistance);
 
 	// destructor
 	~BedIntersectPE(void);
@@ -70,6 +70,7 @@ private:
 	bool _useEditDistance;
 	bool _bamInput;
 	bool _bamOutput;
+	bool  _isUncompressedBam;
 
 	// instance of a paired-end bed file class.
 	BedFilePE *_bedA;
diff --git a/src/pairToBed/pairToBedMain.cpp b/src/pairToBed/pairToBedMain.cpp
index d50466fa00477d1d91e3cac35f972e01c545ab40..a26d3fe9c45eb929c201c55a00e055be40b52125 100644
--- a/src/pairToBed/pairToBedMain.cpp
+++ b/src/pairToBed/pairToBedMain.cpp
@@ -37,14 +37,15 @@ int main(int argc, char* argv[]) {
 	string searchType = "either";
 
 	// flags to track parameters
-	bool haveBedA        = false;
-	bool haveBedB        = false;
-	bool haveSearchType  = false;
-	bool haveFraction    = false;
-	bool forceStrand     = false;
-	bool useEditDistance = false;
-	bool inputIsBam      = false;
-	bool outputIsBam     = true;
+	bool haveBedA           = false;
+	bool haveBedB           = false;
+	bool haveSearchType     = false;
+	bool haveFraction       = false;
+	bool forceStrand        = false;
+	bool useEditDistance    = false;
+	bool inputIsBam         = false;
+	bool outputIsBam        = true;
+	bool uncompressedBam    = false;	
 	
 	// check to see if we should print out some help
 	if(argc <= 1) showHelp = true;
@@ -110,7 +111,10 @@ int main(int argc, char* argv[]) {
 		}
 		else if (PARAMETER_CHECK("-s", 2, parameterLength)) {
 			forceStrand = true;
-		}		
+		}
+		else if(PARAMETER_CHECK("-ubam", 5, parameterLength)) {
+            uncompressedBam = true;
+		}	
 		else {
 			cerr << endl << "*****ERROR: Unrecognized parameter: " << argv[i] << " *****" << endl << endl;
 			showHelp = true;
@@ -146,7 +150,7 @@ int main(int argc, char* argv[]) {
 
 		BedIntersectPE *bi = new BedIntersectPE(bedAFile, bedBFile, overlapFraction, 
 												searchType, forceStrand, inputIsBam, 
-												outputIsBam, useEditDistance);
+												outputIsBam, uncompressedBam, useEditDistance);
 		delete bi;
 		return 0;
 	}
diff --git a/src/windowBed/windowBed.cpp b/src/windowBed/windowBed.cpp
index dfd5622658659a3d7c5bd10bee7face9003041ce..65273c5325eb2de9212acc6e444dc60dab2d1635 100644
--- a/src/windowBed/windowBed.cpp
+++ b/src/windowBed/windowBed.cpp
@@ -38,20 +38,10 @@ BedWindow::BedWindow(string bedAFile, string bedBFile, int leftSlop, int rightSl
 	_bedA          = new BedFile(bedAFile);
 	_bedB          = new BedFile(bedBFile);
 	
-	// dealing with a proper file
-	if (_bedA->bedFile != "stdin") {   
-		if (_bamInput == false) 
-			WindowIntersectBed();
-		else
-			WindowIntersectBam(_bedA->bedFile);
-	}
-	// reading from stdin
-	else {  
-		if (_bamInput == false)
-			WindowIntersectBed();
-		else
-			WindowIntersectBam("stdin");			
-	}
+	if (_bamInput == false)
+		WindowIntersectBed();
+	else
+		WindowIntersectBam(_bedAFile);			
 }
 
 
diff --git a/src/windowBed/windowMain.cpp b/src/windowBed/windowMain.cpp
index 7e0f7a4b867f98d6e20c93e3990e5dfd9a4e6e3f..5eb3465f8e00cd4dc13b1704232078041fb40531 100644
--- a/src/windowBed/windowMain.cpp
+++ b/src/windowBed/windowMain.cpp
@@ -34,21 +34,22 @@ int main(int argc, char* argv[]) {
 	string bedBFile;
 
 	// input arguments
-	int leftSlop = 1000;
+	int leftSlop  = 1000;
 	int rightSlop = 1000;
 
-	bool haveBedA = false;
-	bool haveBedB = false;
-	bool noHit = false;
-	bool anyHit = false;
-	bool writeCount = false;
-	bool haveSlop = false;
-	bool haveLeft = false;
-	bool haveRight = false;
-	bool strandWindows = false;
-	bool matchOnStrand = false;
-	bool inputIsBam         = false;
-	bool outputIsBam        = true;	
+	bool haveBedA        = false;
+	bool haveBedB        = false;
+	bool noHit           = false;
+	bool anyHit          = false;
+	bool writeCount      = false;
+	bool haveSlop        = false;
+	bool haveLeft        = false;
+	bool haveRight       = false;
+	bool strandWindows   = false;
+	bool matchOnStrand   = false;
+	bool inputIsBam      = false;
+	bool outputIsBam     = true;	
+    bool uncompressedBam = false;
 
 	// check to see if we should print out some help
 	if(argc <= 1) showHelp = true;
@@ -130,6 +131,9 @@ int main(int argc, char* argv[]) {
 				rightSlop = atoi(argv[i + 1]);
 				i++;
 			}
+		}
+		else if(PARAMETER_CHECK("-ubam", 5, parameterLength)) {
+            uncompressedBam = true;
 		}		
 		else {
 			cerr << endl << "*****ERROR: Unrecognized parameter: " << argv[i] << " *****" << endl << endl;
@@ -175,7 +179,8 @@ int main(int argc, char* argv[]) {
 	
 	if (!showHelp) {
 		BedWindow *bi = new BedWindow(bedAFile, bedBFile, leftSlop, rightSlop, anyHit, 
-		                              noHit, writeCount, strandWindows, matchOnStrand, inputIsBam, outputIsBam);
+		                              noHit, writeCount, strandWindows, matchOnStrand, 
+		                              inputIsBam, outputIsBam, uncompressedBam);
 		delete bi;
 		return 0;
 	}
@@ -200,6 +205,8 @@ void ShowHelp(void) {
 	cerr << "Options: " << endl;
 	
 	cerr << "\t-abam\t"			<< "The A input file is in BAM format.  Output will be BAM as well." << endl << endl;
+	
+	cerr << "\t-ubam\t"			<< "Write uncompressed BAM output. Default is to write compressed BAM." << endl << endl;
 
 	cerr << "\t-bed\t"			<< "When using BAM input (-abam), write output as BED. The default" << endl;
 	cerr 						<< "\t\tis to write output in BAM when using -abam." << endl << endl;