Improve config and log file, and some minor code tweaks.