Various fixes for OSX and to silence warnings