First pass at adding FreeBSD support (some TODO comments inline)