Fixed bugs in routing