There is a lot of repetitive code in all the scripts. We should mode to a common file that's sourced by all scripts.