Daemon refactoring