add support for daemonize and better logging