Fixed some bugs if build directory does not exist