Updated setup script to be more robust