Added optimisation for drawing graphs.