Fix assorted build errors on FreeBSD