This is a reimplementation of a small part of !244 (closed) following discussions with @kbedarka and @sbozhko