Fix bugs in tokenizer