Restructured code to allow recomputing routes