Assorted code cleanup suggested by PyCharm