fixed compilation warnings and a severe bug causing daemon to hang