Added API variables to allow for easy replacement

also added deleting of local temp files.