Fix errors and warnings on OSX