fixed redDet.c and did cleanup