Group commands and correct variable quoting.