Fixed a lot of pylint issues.
Fixed infinite loop