cda: error checks and remove testing code