Internal refactoring to better integrate with argparse.