diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/utils/UTF8CharSequence.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/utils/UTF8CharSequence.java
index a6d1c54..a3ebbbd 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/utils/UTF8CharSequence.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/utils/UTF8CharSequence.java
@@ -5,58 +5,73 @@
 
 public class UTF8CharSequence implements CharSequence {
 
-    private int start;
-    private int len;
-    private char[] buf;
+	private int start;
+	private int len;
+	private char[] buf;
 
-    public UTF8CharSequence(IValueReference valueRef, int start) {
-        reset(valueRef, start);
-    }
+	public UTF8CharSequence(IValueReference valueRef, int start) {
+		reset(valueRef, start);
+	}
 
-    public UTF8CharSequence() {
-    }
+	public UTF8CharSequence() {
+	}
 
-    @Override
-    public char charAt(int index) {
-        if (index >= len || index < 0) {
-            throw new IndexOutOfBoundsException("No index " + index + " for string of length " + len);
-        }
-        return buf[index];
-    }
+	@Override
+	public char charAt(int index) {
+		if (index >= len || index < 0) {
+			throw new IndexOutOfBoundsException("No index " + index
+					+ " for string of length " + len);
+		}
+		return buf[index];
+	}
 
-    @Override
-    public int length() {
-        return len;
-    }
+	@Override
+	public int length() {
+		return len;
+	}
 
-    @Override
-    public CharSequence subSequence(int start, int end) {
-        UTF8CharSequence carSeq = new UTF8CharSequence();
-        carSeq.len = end - start + 1;
-        carSeq.buf = new char[carSeq.len];
-        System.arraycopy(buf, start, carSeq.buf, 0, carSeq.len);
-        return carSeq;
-    }
+	@Override
+	public CharSequence subSequence(int start, int end) {
+		UTF8CharSequence carSeq = new UTF8CharSequence();
+		carSeq.len = end - start;
+		if (end != start) {
+			carSeq.buf = new char[carSeq.len];
+			System.arraycopy(buf, start, carSeq.buf, 0, carSeq.len);
+		}
+		return carSeq;
+	}
 
-    public void reset(IValueReference valueRef, int start) {
-        this.start = start;
-        resetLength(valueRef);
-        if (buf == null || buf.length < len) {
-            buf = new char[len];
-        }
-        int sStart = start + 2;
-        int c = 0;
-        int i = 0;
-        byte[] bytes = valueRef.getByteArray();
-        while (c < len) {
-            buf[i++] = UTF8StringPointable.charAt(bytes, sStart + c);
-            c += UTF8StringPointable.charSize(bytes, sStart + c);
-        }
+	public void reset(IValueReference valueRef, int start) {
+		this.start = start;
+		resetLength(valueRef);
+		if (buf == null || buf.length < len) {
+			buf = new char[len];
+		}
+		int sStart = start + 2;
+		int c = 0;
+		int i = 0;
+		byte[] bytes = valueRef.getByteArray();
+		while (c < len) {
+			buf[i++] = UTF8StringPointable.charAt(bytes, sStart + c);
+			c += UTF8StringPointable.charSize(bytes, sStart + c);
+		}
 
-    }
+	}
 
-    private void resetLength(IValueReference valueRef) {
-        this.len = UTF8StringPointable.getUTFLength(valueRef.getByteArray(), start);
-    }
+	private void resetLength(IValueReference valueRef) {
+		this.len = UTF8StringPointable.getUTFLength(valueRef.getByteArray(),
+				start);
+	}
+
+	@Override
+	public String toString() {
+		StringBuffer bf = new StringBuffer();
+		if (buf != null) {
+			for (int i = 0; i < buf.length; i++) {
+				bf.append(buf[i]);
+			}
+		}
+		return new String(bf);
+	}
 
 }
