Fix bugs in setup script