Not the best solution, but maybe @tagr has a better idea.
Regressions from 7688b8ae and ef5d4274
Todos: