Manually integrated some FreeBSD changes from @lye #132 pull request.