Fixed some bugs in the scripts.