xrange to range and basestring to str
remove __unicode__ and change some methods for python 3 compatible code