Refactor and clean up lexer