Factor fix_def_expr() to fit on one page.

TODO: Order and indentation of the original code was preserved to minimize the text
differences.  Sometime later, indentation should be readjusted.