diff --git a/src/utils/RecordOutputMgr/RecordOutputMgr.cpp b/src/utils/RecordOutputMgr/RecordOutputMgr.cpp
index fcde19077eaf84399131b03d74c475e2f7647377..4f33b211f576f9b9ae65168ea259098f4ea6633e 100644
--- a/src/utils/RecordOutputMgr/RecordOutputMgr.cpp
+++ b/src/utils/RecordOutputMgr/RecordOutputMgr.cpp
@@ -137,20 +137,23 @@ void RecordOutputMgr::printRecord(const Record *record, const QuickString & valu
 }
 
 void RecordOutputMgr::printClosest(RecordKeyVector &keyList, const vector<int> *dists) {
+
 	const ContextClosest *context = static_cast<const ContextClosest *>(_context);
 	bool deleteBlocks = false;
-	RecordKeyVector blockList(keyList.getKey());
-	if (keyList.getKey()->getType() == FileRecordTypeChecker::BAM_RECORD_TYPE) {
+	const Record *keyRec = keyList.getKey();
+	RecordKeyVector blockList(keyRec);
+	if (keyRec->getType() == FileRecordTypeChecker::BAM_RECORD_TYPE) {
 		_bamBlockMgr->getBlocks(blockList, deleteBlocks);
 		_currBamBlockList = &blockList;
 	}
 	if (!keyList.empty()) {
 		int distCount = 0;
 		for (RecordKeyVector::const_iterator_type iter = keyList.begin(); iter != keyList.end(); iter = keyList.next()) {
-			printKey(keyList.getKey());
+			const Record *hitRec = *iter;
+			printKey(keyRec, keyRec->getStartPosStr(), keyRec->getEndPosStr());
 			tab();
-			addDbFileId((*iter)->getFileIdx());
-			(*iter)->print(_outBuf);
+			addDbFileId(hitRec->getFileIdx());
+			printKey(hitRec, hitRec->getStartPosStr(), hitRec->getEndPosStr());
 			if (dists != NULL) {
 				tab();
 				_outBuf.append((*dists)[distCount]);
@@ -160,9 +163,9 @@ void RecordOutputMgr::printClosest(RecordKeyVector &keyList, const vector<int> *
 			if (needsFlush()) flush();
 		}
 	} else {
-		printKey(keyList.getKey());
+		printKey(keyRec, keyRec->getStartPosStr(), keyRec->getEndPosStr());
 		tab();
-		null(true, false);
+		null(false, true);
 		if (context->reportDistance()) {
 			tab();
 			_outBuf.append(-1);
diff --git a/src/utils/general/ParseTools.h b/src/utils/general/ParseTools.h
index 2ba28df37578a7fc5f31148ca2c84a8e28787abe..a58495d14f3408ca5b4f84253eca8b78376b6c7b 100644
--- a/src/utils/general/ParseTools.h
+++ b/src/utils/general/ParseTools.h
@@ -12,6 +12,8 @@
 #include <string>
 #include <vector>
 #include "QuickString.h"
+#include <cstdio>
+#include <cstdlib>
 
 using namespace std;
 
@@ -35,7 +37,11 @@ int str2chrPos(const QuickString &str);
 template<class T>
 void int2str(int number, T& buffer, bool appendToBuf = false)
 {
-
+	int maxVal = (1 << 31) -1;
+	if (((int)(abs(number))) > maxVal) {
+		fprintf(stderr, "ERROR: number out of bounds.\n");
+		exit(1);
+	}
 	register int useNum = number;
 	if (useNum == 0) {
 		if (appendToBuf) {