More robust scripts

Once this PR is merged, the script(s) will fail on CI until all the problems that it highlights are fixed.