clean up and change directory