Many fixes to path handling