Minor tweaks to make the script run more consistently