a bit more tuning and better https handling