Added out-of-memory catches