Fix handling of symlinked directories on Windows

Add various tweaks to ensure proper handling of symlinked directories on
Windows.