Fix build on Windows
Fix selection of # threads, set default to 1 thread
Remove dead code, relocate some code