Made necessary changes so it builds in FreeBSD.