Add more robust path handling