Code cleanup, coefficient computation generalized.