Code review according to PyCharm

- Corrected risks of unbound variables