Fixed add_instance issue, where, if same instance with different new checksum is added then all instances are deleted before adding the new instance
Fixed design and made all existing tests pass.