added a very ad hoc FreeBSD support (revise later) and fixed a couple warnings