Fix issues 6885 and 7267