Fix clip-rect code and some other optimisation.