Fix potential crash on OS X