Fixed directory detection to allow absolute paths