Bugs/2674/utf8

It's fixing #2674. It also significantly increases performance of UTF encoding.
Do we need these commented parts?