Fix daemon-related bugs