improved daemon handling