Fix script bugs when downloading repo