pep8 compliant code, inactivation of debug messages, small logic change