Added threaded version.