Handle changing of directories better.