Refactor lexing process.