Optimized the image tile painting implementation