[based on patch submitted in PR, but greatly re-worked by me] PR: 14970 Submitted by: Andrew J. Korty <ajk@waterspout.com>