Use value instead of reference captures in lambda.

This should allow the lambda to be copied around.