some fixes for FreeBSD compile