Fixed some directory-changing bugs