Minor optimizations
speed up the drawing function