improved how subprocess is spawned