Fix undefined name + PEP8. Fixes #3607.
Merge pull request #3609 from s0undt3ch/issues/3607

Fix undefined name + PEP8. Fixes #3607.