Avoid invalid capturelex operations.

Fixes various (maybe not all) wrong-frame errors.