minor code cleanup
optimise isinstance(obj, basestring) and map basestring to unicode in Py3