Some fine-tuning of the script