integrated change for upstream issue #20