Some unexpected crashes fixed