use syslog for reporting errors while running as server
fixed ignoring return code of daemon()
some minor cosmetic fixes