lots of changes to get https working