Adding multithread capability