Fixed error checking when listing branches
Fixed error checking when counting branches