OSX 10.9 fixes

These fixes make a working packaged build for OSX. This also fixes #1008 (or at least provides a workaround to block the crash). Also fixes #1005.