Fixed bugs found by PyChecker.