Why do we import the same thing twice?
In general this change looks extremely hacky, please add a bunch of comments to help people understand what's being done  here and why is it being done in this particular way.

A multi-line comment with an example of command line equivalent of the commands being spawned here could also be extremely helpful.