Refactor initialisation of the daemon