bug fix and improvements
Merge remote-tracking branch 'upstream/master'