Better support for https

Squashed commits, see #283