Daemonized main loop.