code cleanup
and https fix