Corrected a few minor bugs that appeared in the new script procedures
chain is tested and working