Merge FreeBSD fixes upstream