Use subshell

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