Fix a number of issues with the setup.sh script

This commit fixes all the  issues arisen when trying it out.