r6738: My version of the patch by metze that I just reverted (-r 6734).