Fixes to work on MacOS 10.9 (Mavericks)

These are some patches to make it work on MacOS 10.9 (Mavericks)