Fix build issues on BSD