Finally working patch for #9.