spreading the string or unicode check for variables.

Some cases had only str while others both str and unicode. I came across a specific case where having only str broke it for me.

Nitpicking a bit the 'proper' way to do this would be:

    from types import StringTypes

    if isinstance(var, StringTypes):
      # do something

as there's always a chance another string type gets added to the core lib (though I seriously doubt it).