Rewrite of spec_params and spec_diag to make it more factorized
and clearer.
Compiles but untested!