Now handles the out of memory case correctly.