Refactor the scripts a bit so they can be run all at once.