Fix #270
Fix threading issue
Fix #277
Merge remote-tracking branch 'origin/master'