diff --git a/src/category.cpp b/src/category.cpp
index 48176d3..c1f2cbc 100644
--- a/src/category.cpp
+++ b/src/category.cpp
@@ -765,7 +765,7 @@ void ibis::category::getString(uint32_t i, std::string &str) const {
 	ibis::array_t<uint32_t> ints;
 	ierr = ibis::fileManager::instance().getFile(fnm.c_str(), ints);
 	if (ierr >= 0 && ints.size() == thePart->nRows()) {
-	    if (i < ints.size()) {
+	    if (i < ints.size() && ints[i] > 0) {
 		str = dic[ints[i]];
 	    }
 	    return;
diff --git a/src/colValues.cpp b/src/colValues.cpp
index 75062fe..2bcb820 100755
--- a/src/colValues.cpp
+++ b/src/colValues.cpp
@@ -30,6 +30,7 @@ ibis::colValues* ibis::colValues::create(const ibis::column* c,
     case ibis::SHORT:
 	return new colShorts(c, hits);
     case ibis::UINT:
+    case ibis::CATEGORY:
 	return new colUInts(c, hits);
     case ibis::INT:
 	return new colInts(c, hits);
@@ -41,7 +42,6 @@ ibis::colValues* ibis::colValues::create(const ibis::column* c,
 	return new colFloats(c, hits);
     case ibis::DOUBLE:
 	return new colDoubles(c, hits);
-    case ibis::CATEGORY:
     case ibis::TEXT:
 	return new colStrings(c, hits);
     default:
@@ -101,6 +101,7 @@ ibis::colValues* ibis::colValues::create(const ibis::column* c) {
     case ibis::SHORT:
 	return new colShorts(c);
     case ibis::UINT:
+    case ibis::CATEGORY:
 	return new colUInts(c);
     case ibis::INT:
 	return new colInts(c);
@@ -112,7 +113,6 @@ ibis::colValues* ibis::colValues::create(const ibis::column* c) {
 	return new colFloats(c);
     case ibis::DOUBLE:
 	return new colDoubles(c);
-    case ibis::CATEGORY:
     case ibis::TEXT:
 	return new colStrings(c);
     default:
@@ -1037,7 +1037,7 @@ ibis::colStrings::colStrings(const ibis::column* c)
 	hits.set(1, c->partition()->nRows());
 	array = c->selectStrings(hits);
     }
-    else if (c->type() == ibis::TEXT) {
+    if (c->type() == ibis::TEXT) {
 	array =new std::vector<std::string>;
 	c->getValuesArray(array);
     }
diff --git a/src/colValues.h b/src/colValues.h
index ff7c1c3..232be61 100755
--- a/src/colValues.h
+++ b/src/colValues.h
@@ -239,10 +239,9 @@ public:
     }
     /// Write the ith element as text.
     virtual void write(std::ostream& out, uint32_t i) const {
-	if (col->type() == ibis::CATEGORY || col->type() == ibis::TEXT) {
-	    std::string str;
-	    col->getString((*array)[i], str);
-	    if (str.empty()) {
+	if (col->type() == ibis::CATEGORY) {
+	    const char * str = reinterpret_cast<const ibis::category*>(col)->getKey((*array)[i]);
+	    if (str == 0 || (*str) == 0) {
 		out << "<NULL>";
 	    }
 	    else {
