Use temp files appopriately