Fix memory leaks in lexer