middleware: use promises
draft of the mediator core
integration layer: some bug fixes