This is just a rebased version of the patch over revision #1275. Jan