path shortening that takes into account different encodings
small fixes and some comments