Fix out of memory error on OS X