Use six.text_type instead of str everywhere