Lexer internal refactor