fix crash when cleaning environment
fix crash when specifying exec on command line