Improve tmp directory strategy