Ported v3.1 fixes for #2007 to v3.0.
Merge pull request #2046 from pjackson28/v3.0

Ported v3.1 fixes for #2007 to v3.0