Imported changes that eliminate random crashes.