code of constraint manager fully commented.