added tmp_dir option to middleware