Move all path handling to a single place