Improved pathfromreg logic a bit.