Fixed handling of invalid paths