Pylint fixes

### Changelog:
* Fix undefined variables.
* Drop unused imports.
* Fix style errors.