Improved handling of encoded-words

Now accounts for optional language information in encoded-words.