Very simple: shortcut coding version of changing the values of $firstOrderByFieldIfClause, $groupByClause and [$orderByClause possibly but not for now]
I think I got it, but it's not pretty:
if ($firstOrderByFieldIfClause && $groupByClause) {
$array = array(&$firstOrderByFieldIfClause, &$groupByClause);
@array_walk($array, create_function('&$a', '$a = substr($a, 0, strrpos(trim($a), ",")); if ($a) $a = ", $a";'));
}