Some optimizations in drawing