added branch detection support

Here is what we changed to get branch support working.