Use sed for *PATH stripping

This is an attempt of replacing shell string replacement for sed.

Also replaced some logic, I now always strip any version from the different `*PATH`'s and prepending the new one, where previously the version was replaced if available and otherwise prepended. Or at least, that was what I could make of it.