Create ConstraintMapping class and fix bugs