write files in execution directory (and some minor changes).