Issue #8487 by tj, added patch