Fixes for linux and mac osx