tempfile refactoring.