Various bits of cleanups to the python code.