Added multipart helper to write the tempfile. Moved proxy and ssl code into own methods.