Optimization: replace flat curves with lines & join colinear lines