I think I fixed some bugs with multithreading