some code cleanup, adding argparse parameter handling, logging, and user
configuration