OSX/BSD compatibility

Fixes #7 
Fixes #9