Multithreaded fixes, test added, and more equal distribution of jobs across threads.