Some small tweaks for bug #7409.
This fixes #7409.  The register generation code is completely separated out now.