Fix branch detection