Fixed issue with HTTPS and added initial directory detection and change