Added multithreading, even though it may not help speed very much...