FreeBSD compile fixes

Minor fixes to build latest version on FreeBSD.
Also fix for non-init variable usage.