Alternative patch for issue #340

#340