Overhauled the line drawing algorithm