Fixed multi threading issues