refactor and organize code, added headers, options. Verifying SSL Cert