Python fixes. Thanks @nedbat :)