Fixed bugs in scripts