Finished recoding all functions except getSparseCoefficients.