Handle route changes more correctly.