Trying to fix threading issues