added better handling of missing library, added (unstable) code for supporting OS X

**must be tested on OS X**