A patch for issue #309