Refactor optparse