Finish implementing DCM code and move everything out of main test file.