Fixes to variable issues introduced by recent changes

Fixes #6801
Fixes #6832