Some fixes for Python 2.6

I don't know if these are all the changes needed to re-enable support for Python 2.6, but it got me as far as I needed to go.