Updates scripts with some improvements and bug fixes