Fixed bug in the encoding guessing code