Fixed some bugs caused by directory change