Index: trunk/lang/python/Rappture/PyRpEncode.cc
===================================================================
--- trunk/lang/python/Rappture/PyRpEncode.cc	(revision 1367)
+++ trunk/lang/python/Rappture/PyRpEncode.cc	(revision 1368)
@@ -64,5 +64,4 @@
     PyObject* rv = NULL;
     Rappture::Outcome err;
-    Rappture::Buffer buf;
 
     static char *kwlist[] = {
@@ -83,7 +82,6 @@
     }
 
-    buf = Rappture::Buffer(data,dlen);
-    err &= Rappture::encoding::encode(buf,flags);
-    if (int(err) != 0) {
+    Rappture::Buffer buf(data, dlen);
+    if (!Rappture::encoding::encode(err, buf, flags)) {
 	std::string outStr;
 
@@ -91,11 +89,9 @@
 	outStr += "\n";
 	outStr += err.context();
-        PyErr_SetString(PyExc_RuntimeError,outStr.c_str());
+        PyErr_SetString(PyExc_RuntimeError, outStr.c_str());
         buf.clear();
         return NULL;
     }
-
     rv = PyString_FromStringAndSize(buf.bytes(),buf.size());
-
     return rv;
 }
@@ -115,5 +111,4 @@
     PyObject* rv = NULL;
     Rappture::Outcome err;
-    Rappture::Buffer buf;
 
     static char *kwlist[] = {
@@ -134,7 +129,6 @@
     }
 
-    buf = Rappture::Buffer(data,dlen);
-    err &= Rappture::encoding::decode(buf,flags);
-    if (int(err) != 0) {
+    Rappture::Buffer buf(data, dlen);
+    if (!Rappture::encoding::decode(err, buf, flags)) {
 	std::string outStr;
 
@@ -145,7 +139,5 @@
         return NULL;
     }
-
     rv = PyString_FromStringAndSize(buf.bytes(),buf.size());
-
     return rv;
 }
Index: trunk/lang/python/Rappture/PyRpUnits.cc
===================================================================
--- trunk/lang/python/Rappture/PyRpUnits.cc	(revision 1367)
+++ trunk/lang/python/Rappture/PyRpUnits.cc	(revision 1368)
@@ -519,5 +519,5 @@
     /* Add some symbolic constants to the module */
     if (ErrorObject == NULL) {
-        ErrorObject = PyErr_NewException("RpUnits.error", NULL, NULL);
+        ErrorObject = PyErr_NewException((char *)"RpUnits.error", NULL, NULL);
         if (ErrorObject == NULL)
             return;
Index: trunk/lang/tcl/src/RpEncodeTclInterface.cc
===================================================================
--- trunk/lang/tcl/src/RpEncodeTclInterface.cc	(revision 1367)
+++ trunk/lang/tcl/src/RpEncodeTclInterface.cc	(revision 1368)
@@ -14,4 +14,7 @@
 #include <tcl.h>
 #include "RpEncode.h"
+
+#define TRUE	1
+#define FALSE	0
 
 extern "C" Tcl_AppInitProc RpEncoding_Init;
@@ -76,26 +79,26 @@
 
     int bufLen;
-    const char *buf = (const char*) Tcl_GetByteArrayFromObj(objv[2],&bufLen);
-
+    const char *buf;
+    buf = (const char*) Tcl_GetByteArrayFromObj(objv[2], &bufLen);
     if (('b' == *type) && (strcmp(type,"binary") == 0)) {
         if (Rappture::encoding::isbinary(buf,bufLen) != 0) {
             // non-ascii character found, return yes
-            Tcl_AppendResult(interp, "yes", (char*)NULL);
+            Tcl_SetResult(interp, (char *)"yes", TCL_STATIC);
         } else {
-            Tcl_AppendResult(interp, "no",(char*)NULL);
+            Tcl_SetResult(interp, (char *)"no", TCL_STATIC);
         }
         return TCL_OK;
     } else if (('e' == *type) && (strcmp(type,"encoded") == 0)) {
-        if (Rappture::encoding::isencoded(buf,bufLen) != 0) {
+        if (Rappture::encoding::isencoded(buf, bufLen) != 0) {
             // valid "@@RP-ENC:" header found, return yes
-            Tcl_AppendResult(interp, "yes", (char*)NULL);
+            Tcl_SetResult(interp, (char *)"yes", TCL_STATIC);
         } else {
-            Tcl_AppendResult(interp, "no",(char*)NULL);
+            Tcl_SetResult(interp, (char *)"no", TCL_STATIC);
         }
         return TCL_OK;
-    }
-    Tcl_AppendResult(interp, "bad option \"", type,
-            "\": should be one of binary, encoded",
-            (char*)NULL);
+    } else {
+	Tcl_AppendResult(interp, "bad option \"", type, 
+		"\": should be binary or encoded", (char*)NULL);
+    }
     return TCL_ERROR;
 }
@@ -124,17 +127,13 @@
 
     const char* encodeType    = NULL; // name of the units provided by user
-    const char* option        = NULL;
     const char* cmdName       = NULL;
-    Rappture::Buffer buf; // name of the units provided by user
     Rappture::Outcome err;
 
-    int optionLen             = 0;
     int typeLen               = 0;
     int nextarg               = 0; // start parsing using the '2'th argument
 
-    int compress              = 1;
-    int base64                = 1;
-    int addHeader             = 1;
-    int flags                 = 0;
+    bool compress, base64, addHeader;
+
+    compress = base64 = addHeader = true;
 
     Tcl_Obj *result           = NULL;
@@ -153,4 +152,7 @@
 
     while ((objc - nextarg) > 0) {
+	const char *option;
+	int optionLen;
+
         option = Tcl_GetStringFromObj(objv[nextarg], &optionLen);
         if (*option == '-') {
@@ -164,16 +166,16 @@
                 if (        (typeLen == 1) &&
                             (strncmp(encodeType,"z",typeLen) == 0) ) {
-                    compress = 1;
-                    base64 = 0;
+                    compress = TRUE;
+                    base64 = FALSE;
                 }
                 else if (   (typeLen == 3) &&
                             (strncmp(encodeType,"b64",typeLen) == 0) ) {
-                    compress = 0;
-                    base64 = 1;
+                    compress = FALSE;
+                    base64 = TRUE;
                 }
                 else if (   (typeLen == 4) &&
                             (strncmp(encodeType,"zb64",typeLen) == 0) ) {
-                    compress = 1;
-                    base64 = 1;
+                    compress = TRUE;
+                    base64 = TRUE;
                 }
                 else {
@@ -191,5 +193,5 @@
             else if ( strncmp(option,"-no-header",optionLen) == 0 ) {
                 nextarg++;
-                addHeader = 0;
+                addHeader = FALSE;
             }
             else if ( strcmp(option,"--") == 0 ) {
@@ -216,27 +218,25 @@
     }
 
+    int optionLen;
+    const char* option;
     option = (const char*) Tcl_GetByteArrayFromObj(objv[nextarg++], &optionLen);
-    buf = Rappture::Buffer(option,optionLen);
-
-    if (compress == 1) {
-        flags = flags | RPENC_Z;
-    }
-    if (base64 == 1) {
-        flags = flags | RPENC_B64;
-    }
-    if (addHeader == 1) {
-        flags = flags | RPENC_HDR;
-    }
-
-    err &= Rappture::encoding::encode(buf,flags);
-
-    if (!err) {
-        result = Tcl_NewByteArrayObj(
-            (const unsigned char*)buf.bytes(), buf.size());
-        Tcl_SetObjResult(interp, result);
-    }
-    else {
+    Rappture::Buffer buf(option,optionLen);
+
+    unsigned int flags = 0;
+    if (compress) {
+        flags |= RPENC_Z;
+    }
+    if (base64) {
+        flags |= RPENC_B64;
+    }
+    if (addHeader) {
+        flags |= RPENC_HDR;
+    }
+    if (!Rappture::encoding::encode(err, buf, flags)) {
         Tcl_AppendResult(interp, err.remark(), "\n", err.context(), NULL);
-    }
+	return TCL_ERROR;
+    }
+    result = Tcl_NewByteArrayObj((const unsigned char*)buf.bytes(), buf.size());
+    Tcl_SetObjResult(interp, result);
     return TCL_OK;
 }
@@ -262,20 +262,12 @@
 
     const char* encodeType    = NULL; // name of the units provided by user
-    const char* option        = NULL;
     const char* cmdName       = NULL;
-    Rappture::Buffer buf      = ""; // name of the units provided by user
     Rappture::Outcome err;
 
-    int optionLen             = 0;
     int typeLen               = 0;
     int nextarg               = 0; // start parsing using the '2'th argument
 
-    int decompress            = 0;
-    int base64                = 0;
-    int flags                 = 0;
-
-    Tcl_Obj *result           = NULL;
-
-    Tcl_ResetResult(interp);
+    bool decompress, base64;
+    decompress = base64 = false;
 
     cmdName = Tcl_GetString(objv[nextarg++]);
@@ -290,4 +282,7 @@
 
     while ((objc - nextarg) > 0) {
+	const char *option;
+	int optionLen;
+
         option = Tcl_GetStringFromObj(objv[nextarg], &optionLen);
         if (*option == '-') {
@@ -301,16 +296,16 @@
                 if (        (typeLen == 1) &&
                             (strncmp(encodeType,"z",typeLen) == 0) ) {
-                    decompress = 1;
-                    base64 = 0;
+                    decompress = true;
+                    base64 = false;
                 }
                 else if (   (typeLen == 3) &&
                             (strncmp(encodeType,"b64",typeLen) == 0) ) {
-                    decompress = 0;
-                    base64 = 1;
+                    decompress = false;
+                    base64 = true;
                 }
                 else if (   (typeLen == 4) &&
                             (strncmp(encodeType,"zb64",typeLen) == 0) ) {
-                    decompress = 1;
-                    base64 = 1;
+                    decompress = true;
+                    base64 = true;
                 }
                 else {
@@ -346,25 +341,23 @@
     }
 
+    int optionLen;
+    const char* option;
     option = (const char*) Tcl_GetByteArrayFromObj(objv[nextarg++], &optionLen);
 
-    buf = Rappture::Buffer(option,optionLen);
-
-    if (decompress == 1) {
-        flags = flags | RPENC_Z;
-    }
-    if (base64 == 1) {
-        flags = flags | RPENC_B64;
-    }
-
-    err &= Rappture::encoding::decode(buf,flags);
-
-    if (!err) {
-        result = Tcl_NewByteArrayObj(
-            (const unsigned char*)buf.bytes(), buf.size());
-        Tcl_SetObjResult(interp, result);
-    }
-    else {
+    unsigned int flags = 0;
+    if (decompress) {
+        flags |= RPENC_Z;
+    }
+    if (base64) {
+        flags |= RPENC_B64;
+    }
+    Rappture::Buffer buf(option, optionLen); 
+    if (!Rappture::encoding::decode(err, buf,flags)) {
         Tcl_AppendResult(interp, err.remark(), "\n", err.context(), NULL);
-    }
+	return TCL_ERROR;
+    }
+    Tcl_Obj *objPtr;
+    objPtr = Tcl_NewByteArrayObj((const unsigned char*)buf.bytes(), buf.size());
+    Tcl_SetObjResult(interp, objPtr);
     return TCL_OK;
 }
