Refactor command-line argument parsing.
Add docstring.