This should fix #7760, but I will need to do more testing to make sure that it doesn't break anything else.