This fixes bug #8297.
More work on bug #8296.