Undo revert "Simplified routing code"