Improve performance, fixing #342
Merge remote-tracking branch 'upstream/master' into startup