Move lock to outer scope.