Use PREPARE hook to make suer temp files are always removed.