Adds IIS compatibility and minor tweaks to redirecting logic