fix tempfile leaks