Fix EXC_BAD_ACCESS multithreading crash