Fixing segfault on OS X