Added support for daemonization and log redirection.