Refactor OS/CPU-count detection