fixed many bugs in the nightly build scripts.