added support for running as a daemon / background process