Some more variable scoping fixes.

Refs #5846