Fix and improve the script.