cleanups and bugfixes due to pychecker