Fixed Unicode problems in optimize_mentions function