Added option to specify temp dir