https support, cleanup and fixes