Make the BSD handling less NETBSD specific, so that it works for FreeBSD also