Add logging.
Remove printf debug statements.
Add command-line parameter for log-level.