added caching, fixed tdColour 'switch statement'