Fix locking
Merge remote-tracking branch 'upstream/master' into envlock