diff --git a/common/rfb/PixelTransformer.cxx b/common/rfb/PixelTransformer.cxx
index cedf900..73ec349 100644
--- a/common/rfb/PixelTransformer.cxx
+++ b/common/rfb/PixelTransformer.cxx
@@ -22,10 +22,7 @@
 #include <string.h>
 #include <rfb/PixelFormat.h>
 #include <rfb/Exception.h>
-#include <rfb/ColourMap.h>
-#include <rfb/TrueColourMap.h>
 #include <rfb/PixelBuffer.h>
-#include <rfb/ColourCube.h>
 #include <rfb/PixelTransformer.h>
 
 using namespace rfb;
@@ -100,50 +97,23 @@
   { transRGB16to8, transRGB16to16, transRGB16to32 },
   { transRGB32to8, transRGB32to16, transRGB32to32 }
 };
-static transFnType transRGBCubeFns[][3] = {
-  { transRGBCube16to8, transRGBCube16to16, transRGBCube16to32 },
-  { transRGBCube32to8, transRGBCube32to16, transRGBCube32to32 }
-};
 
 // Table initialisation functions.
 
-typedef void (*initCMtoTCFnType)(rdr::U8** tablep, const PixelFormat& inPF,
-                                 ColourMap* cm, const PixelFormat& outPF);
-typedef void (*initTCtoTCFnType)(rdr::U8** tablep, const PixelFormat& inPF,
-                                 const PixelFormat& outPF);
-typedef void (*initCMtoCubeFnType)(rdr::U8** tablep, const PixelFormat& inPF,
-                                   ColourMap* cm, ColourCube* cube);
-typedef void (*initTCtoCubeFnType)(rdr::U8** tablep, const PixelFormat& inPF,
-                                   ColourCube* cube);
+typedef void (*initFnType)(rdr::U8** tablep, const PixelFormat& inPF,
+                           const PixelFormat& outPF);
 
-
-static initCMtoTCFnType initSimpleCMtoTCFns[] = {
-    initSimpleCMtoTC8, initSimpleCMtoTC16, initSimpleCMtoTC32
+static initFnType initSimpleFns[] = {
+    initSimple8, initSimple16, initSimple32
 };
 
-static initTCtoTCFnType initSimpleTCtoTCFns[] = {
-    initSimpleTCtoTC8, initSimpleTCtoTC16, initSimpleTCtoTC32
-};
-
-static initCMtoCubeFnType initSimpleCMtoCubeFns[] = {
-    initSimpleCMtoCube8, initSimpleCMtoCube16, initSimpleCMtoCube32
-};
-
-static initTCtoCubeFnType initSimpleTCtoCubeFns[] = {
-    initSimpleTCtoCube8, initSimpleTCtoCube16, initSimpleTCtoCube32
-};
-
-static initTCtoTCFnType initRGBTCtoTCFns[] = {
-    initRGBTCtoTC8, initRGBTCtoTC16, initRGBTCtoTC32
-};
-
-static initTCtoCubeFnType initRGBTCtoCubeFns[] = {
-    initRGBTCtoCube8, initRGBTCtoCube16, initRGBTCtoCube32
+static initFnType initRGBFns[] = {
+    initRGB8, initRGB16, initRGB32
 };
 
 
 PixelTransformer::PixelTransformer(bool econ)
-  : economic(econ), cmCallback(0), cube(0), table(0), transFn(0)
+  : economic(econ), table(0), transFn(0)
 {
 }
 
@@ -152,17 +122,11 @@
   delete [] table;
 }
 
-void PixelTransformer::init(const PixelFormat& inPF_, ColourMap* inCM_,
-                            const PixelFormat& outPF_, ColourCube* cube_,
-                            setCMFnType cmCallback_, void *cbData_)
+void PixelTransformer::init(const PixelFormat& inPF_,
+                            const PixelFormat& outPF_)
 {
   inPF = inPF_;
-  inCM = inCM_;
-
   outPF = outPF_;
-  cube = cube_;
-  cmCallback = cmCallback_;
-  cbData = cbData_;
 
   if (table)
     delete [] table;
@@ -175,79 +139,17 @@
   if ((outPF.bpp != 8) && (outPF.bpp != 16) && (outPF.bpp != 32))
     throw Exception("PixelTransformer: bpp out not 8, 16 or 32");
 
-  if (!outPF.trueColour) {
-    if (outPF.bpp != 8)
-      throw Exception("PixelTransformer: outPF has color map but not 8bpp");
-
-    if (!inPF.trueColour) {
-      if (inPF.bpp != 8)
-        throw Exception("PixelTransformer: inPF has colorMap but not 8bpp");
-      if (!inCM)
-        throw Exception("PixelTransformer: inPF has colorMap but no colour map specified");
-
-      // CM to CM/Cube
-
-      if (cube) {
-        transFn = transSimpleFns[0][0];
-        (*initSimpleCMtoCubeFns[0]) (&table, inPF, inCM, cube);
-      } else {
-        transFn = noTransFn;
-        setColourMapEntries(0, 256);
-      }
-      return;
-    }
-
-    // TC to CM/Cube
-
-    ColourCube defaultCube(6,6,6);
-    if (!cube) cube = &defaultCube;
-
-    if ((inPF.bpp > 16) || (economic && (inPF.bpp == 16))) {
-      transFn = transRGBCubeFns[inPF.bpp/32][0];
-      (*initRGBTCtoCubeFns[0]) (&table, inPF, cube);
-    } else {
-      transFn = transSimpleFns[inPF.bpp/16][0];
-      (*initSimpleTCtoCubeFns[0]) (&table, inPF, cube);
-    }
-
-    if (cube != &defaultCube)
-      return;
-
-    if (!cmCallback)
-      throw Exception("PixelTransformer: Neither colour map callback nor colour cube provided");
-
-    cmCallback(0, 216, cube, cbData);
-    cube = 0;
-    return;
-  }
-
   if (inPF.equal(outPF)) {
     transFn = noTransFn;
     return;
   }
 
-  if (!inPF.trueColour) {
-
-    // CM to TC
-
-    if (inPF.bpp != 8)
-      throw Exception("PixelTransformer: inPF has colorMap but not 8bpp");
-    if (!inCM)
-      throw Exception("PixelTransformer: inPF has colorMap but no colour map specified");
-
-    transFn = transSimpleFns[0][outPF.bpp/16];
-    (*initSimpleCMtoTCFns[outPF.bpp/16]) (&table, inPF, inCM, outPF);
-    return;
-  }
-
-  // TC to TC
-
   if ((inPF.bpp > 16) || (economic && (inPF.bpp == 16))) {
     transFn = transRGBFns[inPF.bpp/32][outPF.bpp/16];
-    (*initRGBTCtoTCFns[outPF.bpp/16]) (&table, inPF, outPF);
+    (*initRGBFns[outPF.bpp/16]) (&table, inPF, outPF);
   } else {
     transFn = transSimpleFns[inPF.bpp/16][outPF.bpp/16];
-    (*initSimpleTCtoTCFns[outPF.bpp/16]) (&table, inPF, outPF);
+    (*initSimpleFns[outPF.bpp/16]) (&table, inPF, outPF);
   }
 }
 
@@ -256,39 +158,11 @@
   return inPF;
 }
 
-const ColourMap *PixelTransformer::getInColourMap() const
-{
-  return inCM;
-}
-
 const PixelFormat &PixelTransformer::getOutPF() const
 {
   return outPF;
 }
 
-const ColourCube *PixelTransformer::getOutColourCube() const
-{
-  return cube;
-}
-
-void PixelTransformer::setColourMapEntries(int firstCol, int nCols)
-{
-  if (nCols == 0)
-    nCols = (1 << inPF.depth) - firstCol;
-
-  if (inPF.trueColour) return; // shouldn't be called in this case
-
-  if (outPF.trueColour) {
-    (*initSimpleCMtoTCFns[outPF.bpp/16]) (&table, inPF, inCM, outPF);
-  } else if (cube) {
-    (*initSimpleCMtoCubeFns[outPF.bpp/16]) (&table, inPF, inCM, cube);
-  } else {
-    if (!cmCallback)
-      throw Exception("PixelTransformer: Neither colour map callback nor colour cube provided");
-    cmCallback(firstCol, nCols, inCM, cbData);
-  }
-}
-
 void PixelTransformer::translatePixels(const void* inPtr, void* outPtr,
                                        int nPixels) const
 {
