Fix daemon log being clobbered by running another instance with same config dir

Also includes small fixes and code cleanup