Works on Mac. Hopefully I didn't break too much on other platforms
Merge pull request #30 from DanielOaks/mac_fix_build

Works on Mac.