Attempt to reinstate the new colour-code stuff.

  I managed to make a mess of the previous merge.