Fix internal error, added logginx, pep8 code