Overhaul error handling and logging.
Add verbose option.