make setup scripts a bit more robust and improve module script