More work on bug #4663.  This fixes #4655.