Fine-grained interoperability through contracts and mirrors