Merge pull request #849 from JoesCat/master

osx fix, segfault fix