Replaced str and unicode with basestring in type check