optimized pathsanitise again

hopefully now it won't break stuff
Merge pull request #6 from Divran/patch-2

optimized pathsanitise again