Fixed thread spawning logic to only spawn the required number of threads. Reorganized code to be more similar to the predownload hook.