Add better error handling and logging to bart.

Add --logfile option for easier manual testing.