better path handling, complete rewrite
merge