move some generally useful functions out of jump threading