Coupling

sync with Hermes

- fixes std::bad_alloc related problems etc.
- please test before merge