Reorganize risch's fix into if/else.
dsolve: use as_independent to simplify the code.