Refactored spawning code to its own module, capturing stdout/err