Limit the number of threads to fix a bug. Cleaned up the code. More work needs t obe done.
Fixed Makefile.