Add modifications to get it to build in FreeBSD
Make the FreeBSD-specific changes compile when defined(__FreeBSD__)