Refactoring and pylint improvements.