Fix to patterns + root directory detection