Made some improvements with lex