Improved drawing algorithm.