Fixes and hacks for OS X
Merge pull request #13 from detunized/master

Fix the build on OS X