minor optimisation and improved colouring