Written to support this Stack Overflow answer.