Added multithread support;