Reworked to function as a daemon