Reapply (PUP-659) Optimize qualified variables

This reverts commit 17caf5e8dd97e34f7633f99ebc627662459d2756.

Since we've determined that the issue around the pull request
this commit was reverting was out of date acceptance tests,
undo the revert and reapply the changes.