Refactoring the subprocess creation code into internal methods with common parts. More readibility is better :)