Issue #1949682 by jeqq, m1r1k, podarok, elachlan: Latest patch from the issue