fixed some random crashes