Refactor and simplify option parsing