Fix a few osx/bsd compile bugs