fixed logging and threading issues