Fixed some bugs in run scripts