Bug fixes for OSX platform