Make scripts more idempotent