refactoring and clean-up with Pylint. Not perfect