Fixed bugs in setup script. Issue: #743