Fix some problems with the script