Fix URI generation bugs on Windows #1639