Make scripts more robust