Some important code was left out in the transition.  Add it back in, and
solve some regtest problems.  Most importantly, get scoping working
again.