Generalise the new background daemon code