Code whitespace cleanup
Fix bgImage scope issue

It broke because `img` is no longer global.