Add fail flag, some bug fixed
Merge remote-tracking branch 'upstream/master'
trivial changes