More work with CDD - cleaning code

following the suggestions by Hugh