refactoring for reuse in selbench

I think I've got it down to only changing three of the variables at the
top of the script, to port this over to selbench.