Fix portability issues for FreeBSD.