Optimizing lexer