[Enhancement] Use subshell

Get rid off the bad patter cd somewhere; cd -
Instead use the subshell which runs into another
process, and thus affecting only its state and
not the calling script. Also remove the global
variable branch. Use echo instead.