Now using https. Also did some refactoring