FreeBSD support and cleanup