Add routing prioritization to handle similar paths properly. Fixed a few bugs.