Fix build problems on FreeBSD