Improved route processing algorithm.