Main algorithms implemented in daemon.