Improved finding of current branch