Fix issue 6767 for all relevant cases