updated library scripts to be more utilitarian and the main scripts to use those helpers.