Tokenizer performance improvments and bug fixes