Optimized the drawing and the colorize function.