OK - I think have found it. When comparing path names, to build the "best relative path", I sometimes scanned too far (when several directories start with the same char(s)). This bug seems to have been around for a while - no changes in this part of the code for 4.0.
A fix will be in the next beta version (I will wait a little, first).
Pelle