Add some more FreeBSD fixes, now also tested on Ubuntu