tempfiles

As per commit message, make it work on broken filesystems.

This will probably throw merge conflicts with the other one. I based em seperately in case you didn't like the look of one/either.