Modified for daemon mode.