Thanks Jan Murre, Reinout van Rees and Wim Feijen, plus Remco Wendt for reviewing. Backport of i6c730da1f from master.