Improved error handling of daemon