Polyline smoothing routine.