Https usage, some refactor