Bug fixes in the scripts