Added the removal of segments that are small and in the same direction.
Also remove points that are completely linear.