FIX: add braces to remove warnings
FIX: check return values of some important functions
FIX: warning in usage of syslog(3)