Support long paths

Hi all,

here's my take on the long paths issue, carrying on ideas from #85, #86, #110 and #113 discussions.

Unfortunately, I won't have the time to test this with long paths (the test suite passes). So I'd like to ask interested parties (@nitram509, @vangdfang) to give it a try and report back if it fixes your issues.

Have fun,
Karsten