Fix various issues detected by PyCharm.