Finish core codes of the model with covariates. More tests are needed.