Adjusted for FreeBSD compatibility.