New attempt at fixing issue 966

I really hope I've got it right this time.