Lots of path handling tweaking, finally seems fairly happy.