Converted the refine method that breaks and straighens lines.