Minor EBADF fixes.