Make coverity shut up about file descriptors.
Fix memory leak
Fix uninitialized things from coverity. Probably.
Explicitly check for NULL because C doesn't have fucking bool
Fix tree null dereferences. Maybe.
Removed stupid check, should make Static analyzers happy