Fix errors and style issues found by pylint