Slight optimizations to drawing code