bug fixes regarding routing, and added new global variables