Split out various vars-related things to avoid merging too early

Fixes #9498