Fixing code contract violations