Refactor tokenizer