cleaning up the daemon code