https redirection not working,bugfixes
minor refactoring