Fixed errors handling for python2.
Respect PEPs.
More logging.