Fixes #2694

This is a WIP, pushing the failing test now, working on a fix.