Adding handling of insufficient memory