Put duplicated thread-start code in start_daemon().

Also some reformatting, making sure that stdout is flushed and keeps
logger as a daemon so it can be killed by KeyboardInterrupt.