fixed some scope and formatting issues pointed out by @mrclay
Merge pull request #5733 from cash/scope

fixed some scope and formatting issues pointed out by @mrclay