Fixed text-encoding bugs