Refactored Https stuff to a separate Factory.