Fixes for building on UNIX and OSX platforms