remove unnecessary cd and subshells in several functions