fixed #547. Better end of word handling.