Various fixes

Notably related to environment and signal handling in the new command engine