Fix segfault in lambdas when constructed via API.
Fix valgrind-flagged error about uninitialized value.