Thanks Tuttle for the report and draft patch, and Carl Meyer for help and review. Backport of c633667d from master