Work on #720, needs testing.