Added directories for more state and actual running commands
Use tempfile to avoid problems from weird characters in file names