Some python 2 related fixes

I found some issues. If you find the useful accept them. Probably this is not the perfect implementation .. :)