Refactor library to use lexer