Fix compile errors on BSD