TODO
Extract Lib.Fresh
Oops: loop detection was broken
BuildTargetEnv to group common parameters
Move IORefs around runCmd into runCmd. Group outputs in RunCmdResults