fix issue #961
fix bug #963
Merge remote-tracking branch 'upstream/master'