Adding average_confidence method and some pep8 and pylint cleaning