Refactor to use getopts.