refactor linear_coefficients

What about the following? Using together is going to be a little more robust if there are extra factors of x in the expression and will also put all encountered ratios in a canonical form.