Fixed a bunch of pylint warnings, many of which would have caused logic errors