some script cleanup tested from CLI and on a cluster