replaced instances of 'has_key' with 'in'
define basestring manually if not running in Python 3