patch for issue #142 (patch imported from alpha branch, see fix for issue #136)