Fixed bugs in improved setup script