Added intermediate tempdir functionality