Corrected CLOSEPOLY in new contour algorithm