Refactored version of dcs.c

I made code refactoring of dcs.c to make it clear for feature addition of CCS.