Fix pipe_shell_replace, together with other fixes