2.7 compat

Hey @hadim, can you have a look?

I'll merge if it's ok with you